diff --git a/core/embed/models/D001/model_D001.h b/core/embed/models/D001/model_D001.h index a4a0be34da..261d59d921 100644 --- a/core/embed/models/D001/model_D001.h +++ b/core/embed/models/D001/model_D001.h @@ -26,8 +26,6 @@ #define IMAGE_HASH_BLAKE2S #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT -#define DISPLAY_RESX 240 -#define DISPLAY_RESY 320 // SHARED WITH MAKEFILE // common diff --git a/core/embed/models/D002/model_D002.h b/core/embed/models/D002/model_D002.h index 0fec46238a..919bec3d9c 100644 --- a/core/embed/models/D002/model_D002.h +++ b/core/embed/models/D002/model_D002.h @@ -28,8 +28,6 @@ #define IMAGE_HASH_SHA256 #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT -#define DISPLAY_RESX 240 -#define DISPLAY_RESY 240 // SHARED WITH MAKEFILE, LINKER SCRIPT etc. // misc diff --git a/core/embed/models/T2B1/model_T2B1.h b/core/embed/models/T2B1/model_T2B1.h index 47a2c1d2ce..329fd7a1d7 100644 --- a/core/embed/models/T2B1/model_T2B1.h +++ b/core/embed/models/T2B1/model_T2B1.h @@ -26,8 +26,6 @@ #define IMAGE_HASH_BLAKE2S #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT -#define DISPLAY_RESX 128 -#define DISPLAY_RESY 64 // SHARED WITH MAKEFILE // common diff --git a/core/embed/models/T2T1/model_T2T1.h b/core/embed/models/T2T1/model_T2T1.h index 526e2e6430..238a36b21d 100644 --- a/core/embed/models/T2T1/model_T2T1.h +++ b/core/embed/models/T2T1/model_T2T1.h @@ -26,8 +26,6 @@ #define IMAGE_HASH_BLAKE2S #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT -#define DISPLAY_RESX 240 -#define DISPLAY_RESY 240 // SHARED WITH MAKEFILE // common diff --git a/core/embed/models/T3B1/model_T3B1.h b/core/embed/models/T3B1/model_T3B1.h index 240ec27607..c558ba598f 100644 --- a/core/embed/models/T3B1/model_T3B1.h +++ b/core/embed/models/T3B1/model_T3B1.h @@ -27,8 +27,6 @@ #define IMAGE_HASH_SHA256 #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT -#define DISPLAY_RESX 128 -#define DISPLAY_RESY 64 // SHARED WITH MAKEFILE, LINKER SCRIPT etc. // misc diff --git a/core/embed/models/T3T1/model_T3T1.h b/core/embed/models/T3T1/model_T3T1.h index a3ed31e4bf..19212bc86c 100644 --- a/core/embed/models/T3T1/model_T3T1.h +++ b/core/embed/models/T3T1/model_T3T1.h @@ -27,8 +27,6 @@ #define IMAGE_HASH_SHA256 #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT -#define DISPLAY_RESX 240 -#define DISPLAY_RESY 240 // SHARED WITH MAKEFILE, LINKER SCRIPT etc. // misc diff --git a/core/embed/models/T3W1/model_T3W1.h b/core/embed/models/T3W1/model_T3W1.h index f9fd1146f4..a6488d8866 100644 --- a/core/embed/models/T3W1/model_T3W1.h +++ b/core/embed/models/T3W1/model_T3W1.h @@ -29,14 +29,6 @@ #define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT -#ifdef TREZOR_EMULATOR -#define DISPLAY_RESX 380 -#define DISPLAY_RESY 520 -#else -#define DISPLAY_RESX 240 -#define DISPLAY_RESY 320 -#endif - // SHARED WITH MAKEFILE, LINKER SCRIPT etc. // misc #define FLASH_START 0x0C004000 diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 83e4022894..f03823eed0 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -59,6 +59,8 @@ const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[ "-DTREZOR_MODEL_T", "-DFLASH_BIT_ACCESS=1", "-DFLASH_BLOCK_WORDS=1", + "-DDISPLAY_RESX=240", + "-DDISPLAY_RESY=240", "-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"", ]; #[cfg(not(feature = "model_tt"))] @@ -70,6 +72,8 @@ const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[ "-DTREZOR_MODEL_R", "-DFLASH_BIT_ACCESS=1", "-DFLASH_BLOCK_WORDS=1", + "-DDISPLAY_RESX=128", + "-DDISPLAY_RESY=64", "-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"", ]; #[cfg(not(feature = "model_tr"))] @@ -81,6 +85,8 @@ const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[ "-DTREZOR_MODEL_T3T1", "-DFLASH_BIT_ACCESS=0", "-DFLASH_BLOCK_WORDS=4", + "-DDISPLAY_RESX=240", + "-DDISPLAY_RESY=240", "-DTREZOR_BOARD=\"T3T1/boards/t3t1-unix.h\"", ]; #[cfg(not(feature = "model_mercury"))] @@ -353,8 +359,8 @@ fn generate_trezorhal_bindings() { .allowlist_function("display_set_backlight") .allowlist_function("display_get_backlight") .allowlist_function("display_wait_for_sync") - .allowlist_var("DISPLAY_RESX") - .allowlist_var("DISPLAY_RESY") + .allowlist_var("DISPLAY_RESX_") + .allowlist_var("DISPLAY_RESY_") .allowlist_type("display_fb_info_t") .allowlist_function("display_get_frame_buffer") .allowlist_function("display_fill") diff --git a/core/embed/rust/src/trezorhal/bitblt.rs b/core/embed/rust/src/trezorhal/bitblt.rs index f11e9bf470..7d4fcc2f00 100644 --- a/core/embed/rust/src/trezorhal/bitblt.rs +++ b/core/embed/rust/src/trezorhal/bitblt.rs @@ -6,6 +6,8 @@ use crate::ui::{ shape::{Bitmap, BitmapFormat, BitmapView}, }; +use crate::trezorhal::display::{DISPLAY_RESX, DISPLAY_RESY}; + /// Waits for the DMA2D peripheral transfer to complete. pub fn wait_for_transfer() { // SAFETY: @@ -203,8 +205,8 @@ impl BitBltFill { /// Fills a rectangle on the display with the specified color. pub fn display_fill(&self) { - assert!(self.bitblt.dst_x + self.bitblt.width <= ffi::DISPLAY_RESX as u16); - assert!(self.bitblt.dst_y + self.bitblt.height <= ffi::DISPLAY_RESY as u16); + assert!(self.bitblt.dst_x + self.bitblt.width <= DISPLAY_RESX as u16); + assert!(self.bitblt.dst_y + self.bitblt.height <= DISPLAY_RESY as u16); // SAFETY: // - The destination rectangle is completely inside the display. unsafe { ffi::display_fill(&self.bitblt) }; @@ -423,8 +425,8 @@ impl<'a> BitBltCopy<'a> { /// /// - The source bitmap uses the RGB565 format. pub fn display_copy(&self) { - assert!(self.bitblt.dst_x + self.bitblt.width <= ffi::DISPLAY_RESX as u16); - assert!(self.bitblt.dst_y + self.bitblt.height <= ffi::DISPLAY_RESY as u16); + assert!(self.bitblt.dst_x + self.bitblt.width <= DISPLAY_RESX as u16); + assert!(self.bitblt.dst_y + self.bitblt.height <= DISPLAY_RESY as u16); // SAFETY: // - The source bitmap is in the correct formats. diff --git a/core/embed/rust/src/trezorhal/display.rs b/core/embed/rust/src/trezorhal/display.rs index d972780044..78d29f8bcf 100644 --- a/core/embed/rust/src/trezorhal/display.rs +++ b/core/embed/rust/src/trezorhal/display.rs @@ -3,7 +3,10 @@ use super::ffi; #[cfg(feature = "framebuffer")] use core::ptr; -pub use ffi::{DISPLAY_RESX, DISPLAY_RESY}; +use ffi::{DISPLAY_RESX_, DISPLAY_RESY_}; + +pub const DISPLAY_RESX: u32 = DISPLAY_RESX_; +pub const DISPLAY_RESY: u32 = DISPLAY_RESY_; pub type FontInfo = ffi::font_info_t; diff --git a/core/embed/rust/trezorhal.h b/core/embed/rust/trezorhal.h index fcec05f276..3267801220 100644 --- a/core/embed/rust/trezorhal.h +++ b/core/embed/rust/trezorhal.h @@ -1,3 +1,5 @@ + + #include #include @@ -32,3 +34,7 @@ #include "slip39.h" #include "uzlib.h" + +// force bindgen to include these constants +const uint32_t DISPLAY_RESX_ = DISPLAY_RESX; +const uint32_t DISPLAY_RESY_ = DISPLAY_RESY; diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index 2c73ff77a0..1b7f8359ac 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -53,11 +53,15 @@ def configure( "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] defines += ["USE_DMA2D"] - defines += [("USE_RGB_COLORS", "1")] features_available.append("dma2d") - defines += ["FRAMEBUFFER"] - defines += ["DISPLAY_RGB565"] + defines += [ + "FRAMEBUFFER", + "DISPLAY_RGB565", + ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "320"), + ] features_available.append("framebuffer") features_available.append("display_rgb565") diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 84fe59c14b..f5fed76720 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -75,20 +75,20 @@ def configure( paths += ["embed/io/usb/inc"] defines += [ - "USE_DMA2D", + "FRAMEBUFFER", + "DISPLAY_RGBA8888", ("UI_COLOR_32BIT", "1"), ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "240"), ] - - sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] - - features_available.append("dma2d") - features_available.append("ui_color_32bit") - - defines += ["FRAMEBUFFER"] - defines += ["DISPLAY_RGBA8888"] features_available.append("framebuffer") features_available.append("display_rgba8888") + features_available.append("ui_color_32bit") + + defines += (["USE_DMA2D"],) + features_available.append("dma2d") + sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] defines += [ "USE_HASH_PROCESSOR=1", diff --git a/core/site_scons/models/T2B1/emulator.py b/core/site_scons/models/T2B1/emulator.py index 15a39cdb28..6f20161db2 100644 --- a/core/site_scons/models/T2B1/emulator.py +++ b/core/site_scons/models/T2B1/emulator.py @@ -17,7 +17,12 @@ def configure( hw_revision = 0 mcu = "STM32F427xx" - defines += ["FRAMEBUFFER", "DISPLAY_MONO"] + defines += [ + "FRAMEBUFFER", + "DISPLAY_MONO", + ("DISPLAY_RESX", "128"), + ("DISPLAY_RESY", "64"), + ] features_available.append("framebuffer") features_available.append("display_mono") diff --git a/core/site_scons/models/T2B1/trezor_r_v10.py b/core/site_scons/models/T2B1/trezor_r_v10.py index 739a443813..002775b511 100644 --- a/core/site_scons/models/T2B1/trezor_r_v10.py +++ b/core/site_scons/models/T2B1/trezor_r_v10.py @@ -16,7 +16,11 @@ def configure( hw_revision = 10 board = "T2B1/boards/trezor_r_v10.h" - defines += ["FRAMEBUFFER"] + defines += [ + "FRAMEBUFFER", + ("DISPLAY_RESX", "128"), + ("DISPLAY_RESY", "64"), + ] features_available.append("framebuffer") features_available.append("display_mono") diff --git a/core/site_scons/models/T2T1/emulator.py b/core/site_scons/models/T2T1/emulator.py index 52e32555f7..a4ad3f97d9 100644 --- a/core/site_scons/models/T2T1/emulator.py +++ b/core/site_scons/models/T2T1/emulator.py @@ -17,9 +17,13 @@ def configure( hw_revision = 0 mcu = "STM32F427xx" - defines += ["DISPLAY_RGB565"] features_available.append("display_rgb565") - defines += [("USE_RGB_COLORS", "1")] + defines += [ + "DISPLAY_RGB565", + ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "240"), + ] defines += [ mcu, diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 5f132699b6..39718b7b14 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -16,9 +16,13 @@ def configure( hw_model = get_hw_model_as_number("T2T1") hw_revision = 0 - defines += ["DISPLAY_RGB565"] features_available.append("display_rgb565") - defines += [("USE_RGB_COLORS", "1")] + defines += [ + "DISPLAY_RGB565", + ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "240"), + ] mcu = "STM32F427xx" diff --git a/core/site_scons/models/T3B1/emulator.py b/core/site_scons/models/T3B1/emulator.py index 3ba72c72ed..4a4654b516 100644 --- a/core/site_scons/models/T3B1/emulator.py +++ b/core/site_scons/models/T3B1/emulator.py @@ -17,7 +17,12 @@ def configure( hw_revision = 0 mcu = "STM32U585xx" - defines += ["FRAMEBUFFER", "DISPLAY_MONO"] + defines += [ + "FRAMEBUFFER", + "DISPLAY_MONO", + ("DISPLAY_RESX", "128"), + ("DISPLAY_RESY", "64"), + ] features_available.append("framebuffer") features_available.append("display_mono") diff --git a/core/site_scons/models/T3B1/trezor_t3b1_revB.py b/core/site_scons/models/T3B1/trezor_t3b1_revB.py index d4c6fd472b..8aa3229818 100644 --- a/core/site_scons/models/T3B1/trezor_t3b1_revB.py +++ b/core/site_scons/models/T3B1/trezor_t3b1_revB.py @@ -16,7 +16,11 @@ def configure( hw_model = get_hw_model_as_number("T3B1") hw_revision = ord("B") - defines += ["FRAMEBUFFER"] + defines += [ + "FRAMEBUFFER", + ("DISPLAY_RESX", "128"), + ("DISPLAY_RESY", "64"), + ] features_available.append("framebuffer") features_available.append("display_mono") diff --git a/core/site_scons/models/T3T1/emulator.py b/core/site_scons/models/T3T1/emulator.py index 6e912d7c5d..ad6af823e0 100644 --- a/core/site_scons/models/T3T1/emulator.py +++ b/core/site_scons/models/T3T1/emulator.py @@ -17,10 +17,15 @@ def configure( hw_revision = 0 mcu = "STM32U585xx" - defines += ["FRAMEBUFFER", "DISPLAY_RGB565"] features_available.append("framebuffer") features_available.append("display_rgb565") - defines += [("USE_RGB_COLORS", "1")] + defines += [ + "FRAMEBUFFER", + "DISPLAY_RGB565", + ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "240"), + ] defines += [ mcu, diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 5229e2379a..a9473d669b 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -18,9 +18,13 @@ def configure( features_available.append("framebuffer") features_available.append("display_rgb565") - defines += [("DISPLAY_RGB565", "1")] - defines += [("FRAMEBUFFER", "1")] - defines += [("USE_RGB_COLORS", "1")] + defines += [ + ("DISPLAY_RGB565", "1"), + ("FRAMEBUFFER", "1"), + ("USE_RGB_COLORS", "1"), + ("DISPLAY_RESX", "240"), + ("DISPLAY_RESY", "240"), + ] mcu = "STM32U585xx" linker_script = """embed/sys/linker/stm32u58/{target}.ld""" diff --git a/core/site_scons/models/T3W1/emulator.py b/core/site_scons/models/T3W1/emulator.py index 622f2bf603..56483240ad 100644 --- a/core/site_scons/models/T3W1/emulator.py +++ b/core/site_scons/models/T3W1/emulator.py @@ -17,11 +17,17 @@ def configure( hw_revision = 0 mcu = "STM32U5G9xx" - defines += ["FRAMEBUFFER", "DISPLAY_RGBA8888", "UI_COLOR_32BIT"] + defines += [ + "FRAMEBUFFER", + ("USE_RGB_COLORS", "1"), + "DISPLAY_RGBA8888", + "UI_COLOR_32BIT", + ("DISPLAY_RESX", "380"), + ("DISPLAY_RESY", "520"), + ] features_available.append("framebuffer") features_available.append("display_rgba8888") features_available.append("ui_color_32bit") - defines += [("USE_RGB_COLORS", "1")] defines += [ mcu,