refactor(core/build): board-driven display and touch driver selection
What changed, and why it matters
This commit is a build-system refactor for the Trezor firmware. It changes how the firmware selects display and touch drivers, moving from model-specific feature flags (like 'model_t2t1') to board-specific and peripheral-specific feature flags (like 'display_st7789' and 'display_panel_t2t1'). It also extracts the Trezor Model T display panel logic into a new dedicated file. There is no indication of a security fix or vulnerability being addressed.
No security action required. Treat as normal build refactor; standard code review and CI validation are sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the Rust/Cargo build scripts in core/embed/io/display/build.rs and core/embed/io/touch/build.rs, plus Cargo.toml and a SCons model file. It replaces per-model feature blocks with per-driver/per-panel feature blocks. A new panels/t2t1.c/h encapsulates the runtime display controller detection and init/rotate/reinit logic previously embedded in display_panel.c. The functional code paths are preserved; only the compile-time selection mechanism and code organization changed. No security-relevant behavior changes are visible in the diff.
Changed components
core/embed/io/Cargo.tomlcore/embed/io/display/build.rscore/embed/io/display/st-7789/display_driver.ccore/embed/io/display/st-7789/display_panel.ccore/embed/io/display/st-7789/display_panel.hcore/embed/io/display/st-7789/panels/t2t1.ccore/embed/io/display/st-7789/panels/t2t1.hcore/embed/io/touch/build.rscore/site_scons/models/T2T1/trezor_t.pyInspect captured patch +281 / −190
diff --git a/core/embed/io/Cargo.toml b/core/embed/io/Cargo.toml
index edbc0fe5..0d20183f 100644
--- a/core/embed/io/Cargo.toml
+++ b/core/embed/io/Cargo.toml
@@ -10,24 +10,12 @@ color-eyre.workspace = true
xbuild.workspace = true
[dependencies]
+models.workspace = true
sec.workspace = true
sys.workspace = true
[features]
-# --------------------------------------------------------------------------
-# Model features
-# --------------------------------------------------------------------------
-
-model_d001 = ["sec/model_d001", "touch_stmpe811"]
-model_d002 = ["sec/model_d002", "backlight_pin", "touch_sitronix"]
-model_t2t1 = ["sec/model_t2t1", "backlight_tps61043", "touch_ft6x36_t2t1"]
-model_t2b1 = ["sec/model_t2b1"]
-model_t3b1 = ["sec/model_t3b1"]
-model_t3t1 = ["sec/model_t3t1", "backlight_tps61043", "touch_ft6x36_t3t1"]
-model_t3w1 = ["sec/model_t3w1", "backlight_tps61062", "touch_ft3168"]
-
-
# --------------------------------------------------------------------------
# MCU features
# --------------------------------------------------------------------------
@@ -81,7 +69,7 @@ usb_iface_wire = ["usb"]
test = [
"mcu_stm32u5g",
- "model_t3w1",
+ "models/model_t3w1",
"emulator",
"kernel_mode",
"secure_mode",
@@ -109,6 +97,26 @@ touch_ft3168 = []
touch_stmpe811 = []
touch_sitronix = []
+framebuffer = []
+
+# Drivers below that always need framebuffer pull it in implicitly,
+# so any project selecting them via the board peripheral chain doesn't have
+# to also advertise `framebuffer` in its target.toml. display_unix and
+# display_st7789 support both modes — the model.toml decides.
+display_unix = []
+display_ltdc_dsi = ["framebuffer"]
+display_st7789 = []
+display_vg2864 = ["framebuffer"]
+display_stm32f429i_disc1 = ["framebuffer"]
+
+display_panel_lx250a2401a = []
+display_panel_stm32u5a9j_dk = []
+display_panel_t2t1 = []
+display_panel_lx154a2482 = []
+display_panel_vg2864 = []
+
+touch_unix = []
+
diff --git a/core/embed/io/display/build.rs b/core/embed/io/display/build.rs
index 2f58a786..cca2c805 100644
--- a/core/embed/io/display/build.rs
+++ b/core/embed/io/display/build.rs
@@ -15,18 +15,20 @@ pub fn def_module(lib: &mut CLibrary) -> Result<()> {
lib.add_source("display/stm32f4/compatibility.c");
}
- if cfg!(feature = "model_t3w1") {
- define_display_t3w1(lib)?;
- } else if cfg!(feature = "model_t3t1") {
- define_display_t3t1(lib)?;
- } else if cfg!(feature = "model_t2t1") {
- define_display_t2t1(lib)?;
- } else if cfg!(feature = "model_t2b1") || cfg!(feature = "model_t3b1") {
- define_display_t2b1_t3b1(lib)?;
- } else if cfg!(feature = "model_d001") {
- define_display_d001(lib)?;
- } else if cfg!(feature = "model_d002") {
- define_display_d002(lib)?;
+ if cfg!(feature = "framebuffer") {
+ lib.add_define("FRAMEBUFFER", Some("1"));
+ }
+
+ if cfg!(feature = "display_unix") {
+ add_driver_unix(lib)?;
+ } else if cfg!(feature = "display_ltdc_dsi") {
+ add_driver_ltdc_dsi(lib)?;
+ } else if cfg!(feature = "display_st7789") {
+ add_driver_st7789(lib)?;
+ } else if cfg!(feature = "display_vg2864") {
+ add_driver_vg2864(lib)?;
+ } else if cfg!(feature = "display_stm32f429i_disc1") {
+ add_driver_stm32f429i_disc1(lib)?;
} else {
bail_unsupported!();
}
@@ -34,10 +36,13 @@ pub fn def_module(lib: &mut CLibrary) -> Result<()> {
Ok(())
}
-fn define_display_t3w1(lib: &mut CLibrary) -> Result<()> {
+// --------------------------------------------------------------------------
+// Panel functions: defines only, no sources, no driver knowledge
+// --------------------------------------------------------------------------
+
+fn set_panel_lx250a2401a(lib: &mut CLibrary) {
lib.add_defines([
("UI_COLOR_32BIT", Some("1")),
- ("FRAMEBUFFER", Some("1")),
("USE_RGB_COLORS", Some("1")),
("DISPLAY_RESX", Some("380")),
("DISPLAY_RESY", Some("520")),
@@ -45,87 +50,140 @@ fn define_display_t3w1(lib: &mut CLibrary) -> Result<()> {
("TERMINAL_X_PADDING", Some("4")),
("TERMINAL_Y_PADDING", Some("12")),
]);
+}
- if cfg!(feature = "emulator") {
- lib.add_source("display/unix/display_driver.c");
- } else if cfg!(feature = "mcu_stm32u5g") {
- lib.add_sources([
- "display/ltdc_dsi/display_driver.c",
- "display/ltdc_dsi/panels/lx250a2401a/lx250a2401a.c",
- "display/ltdc_dsi/display_fb.c",
- "display/ltdc_dsi/display_fb_rgb888.c",
- "display/ltdc_dsi/display_gfxmmu.c",
- "display/fb_queue/fb_queue.c",
- ]);
- } else {
- bail_unsupported!();
- }
- Ok(())
+fn set_panel_stm32u5a9j_dk(lib: &mut CLibrary) {
+ lib.add_defines([
+ ("UI_COLOR_32BIT", Some("1")),
+ ("USE_RGB_COLORS", Some("1")),
+ ("DISPLAY_RESX", Some("240")),
+ ("DISPLAY_RESY", Some("240")),
+ ]);
}
-fn define_display_t3t1(lib: &mut CLibrary) -> Result<()> {
+fn set_panel_lx154a2482(lib: &mut CLibrary) {
lib.add_defines([
- ("FRAMEBUFFER", Some("1")),
("USE_RGB_COLORS", Some("1")),
("DISPLAY_RESX", Some("240")),
("DISPLAY_RESY", Some("240")),
]);
+}
- if cfg!(feature = "emulator") {
- lib.add_source("display/unix/display_driver.c");
- } else if cfg!(feature = "mcu_stm32u58") {
+fn set_panel_t2t1(lib: &mut CLibrary) {
+ lib.add_defines([
+ ("USE_RGB_COLORS", Some("1")),
+ ("DISPLAY_RESX", Some("240")),
+ ("DISPLAY_RESY", Some("240")),
+ ]);
+}
+
+fn set_panel_vg2864(lib: &mut CLibrary) {
+ lib.add_defines([("DISPLAY_RESX", Some("128")), ("DISPLAY_RESY", Some("64"))]);
+ lib.add_private_define("DISPLAY_MONO", Some("1"));
+}
+
+// --------------------------------------------------------------------------
+// Driver functions: select panel (defines), then add sources
+// --------------------------------------------------------------------------
+
+fn add_driver_unix(lib: &mut CLibrary) -> Result<()> {
+ if cfg!(feature = "display_panel_lx250a2401a") {
+ set_panel_lx250a2401a(lib);
+ } else if cfg!(feature = "display_panel_stm32u5a9j_dk") {
+ set_panel_stm32u5a9j_dk(lib);
+ } else if cfg!(feature = "display_panel_lx154a2482") {
+ set_panel_lx154a2482(lib);
+ } else if cfg!(feature = "display_panel_t2t1") {
+ set_panel_t2t1(lib);
+ } else if cfg!(feature = "display_panel_vg2864") {
+ set_panel_vg2864(lib);
+ } else {
+ bail_unsupported!();
+ }
+ lib.add_source("display/unix/display_driver.c");
+ Ok(())
+}
+
+fn add_driver_ltdc_dsi(lib: &mut CLibrary) -> Result<()> {
+ if cfg!(feature = "mcu_stm32u5g") {
lib.add_sources([
- "display/bg_copy/stm32u5/bg_copy.c",
+ "display/ltdc_dsi/display_driver.c",
+ "display/ltdc_dsi/display_fb.c",
+ "display/ltdc_dsi/display_fb_rgb888.c",
"display/fb_queue/fb_queue.c",
- "display/st-7789/display_driver.c",
- "display/st-7789/display_fb.c",
- "display/st-7789/display_io.c",
- "display/st-7789/display_panel.c",
- "display/st-7789/panels/lx154a2482.c",
]);
+ if cfg!(feature = "display_panel_lx250a2401a") {
+ set_panel_lx250a2401a(lib);
+ lib.add_sources([
+ "display/ltdc_dsi/panels/lx250a2401a/lx250a2401a.c",
+ "display/ltdc_dsi/display_gfxmmu.c",
+ ]);
+ } else if cfg!(feature = "display_panel_stm32u5a9j_dk") {
+ set_panel_stm32u5a9j_dk(lib);
+ lib.add_source("display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.c");
+ } else {
+ bail_unsupported!();
+ }
} else {
bail_unsupported!();
}
Ok(())
}
-fn define_display_t2t1(lib: &mut CLibrary) -> Result<()> {
- lib.add_defines([
- ("USE_RGB_COLORS", Some("1")),
- ("DISPLAY_RESX", Some("240")),
- ("DISPLAY_RESY", Some("240")),
- ]);
-
- if cfg!(feature = "emulator") {
- lib.add_source("display/unix/display_driver.c");
+fn add_driver_st7789(lib: &mut CLibrary) -> Result<()> {
+ if cfg!(feature = "mcu_stm32u58") {
+ lib.add_sources([
+ "display/st-7789/display_driver.c",
+ "display/st-7789/display_io.c",
+ "display/st-7789/display_panel.c",
+ ]);
+ if cfg!(feature = "display_panel_lx154a2482") {
+ set_panel_lx154a2482(lib);
+ lib.add_source("display/st-7789/panels/lx154a2482.c");
+ } else {
+ bail_unsupported!();
+ }
+ if cfg!(feature = "framebuffer") {
+ lib.add_sources([
+ "display/bg_copy/stm32u5/bg_copy.c",
+ "display/fb_queue/fb_queue.c",
+ "display/st-7789/display_fb.c",
+ ]);
+ } else {
+ lib.add_source("display/st-7789/display_nofb.c");
+ }
} else if cfg!(feature = "mcu_stm32f4") {
lib.add_sources([
"display/st-7789/display_nofb.c",
"display/st-7789/display_driver.c",
"display/st-7789/display_io.c",
"display/st-7789/display_panel.c",
- "display/st-7789/panels/tf15411a.c",
- "display/st-7789/panels/154a.c",
- "display/st-7789/panels/lx154a2411.c",
- "display/st-7789/panels/lx154a2422.c",
]);
+ if cfg!(feature = "display_panel_t2t1") {
+ set_panel_t2t1(lib);
+ lib.add_sources([
+ "display/st-7789/panels/t2t1.c",
+ "display/st-7789/panels/tf15411a.c",
+ "display/st-7789/panels/154a.c",
+ "display/st-7789/panels/lx154a2411.c",
+ "display/st-7789/panels/lx154a2422.c",
+ ]);
+ } else {
+ bail_unsupported!();
+ }
} else {
bail_unsupported!();
}
Ok(())
}
-fn define_display_t2b1_t3b1(lib: &mut CLibrary) -> Result<()> {
- lib.add_defines([
- ("FRAMEBUFFER", Some("1")),
- ("DISPLAY_RESX", Some("128")),
- ("DISPLAY_RESY", Some("64")),
- ]);
-
- if cfg!(feature = "emulator") {
- lib.add_private_define("DISPLAY_MONO", Some("1"));
- lib.add_source("display/unix/display_driver.c");
- } else if cfg!(feature = "mcu_stm32u58") || cfg!(feature = "mcu_stm32f4") {
+fn add_driver_vg2864(lib: &mut CLibrary) -> Result<()> {
+ if cfg!(feature = "display_panel_vg2864") {
+ set_panel_vg2864(lib);
+ } else {
+ bail_unsupported!();
+ }
+ if cfg!(feature = "mcu_stm32u58") || cfg!(feature = "mcu_stm32f4") {
lib.add_source("display/vg-2864/display_driver.c");
} else {
bail_unsupported!();
@@ -133,17 +191,13 @@ fn define_display_t2b1_t3b1(lib: &mut CLibrary) -> Result<()> {
Ok(())
}
-fn define_display_d001(lib: &mut CLibrary) -> Result<()> {
+fn add_driver_stm32f429i_disc1(lib: &mut CLibrary) -> Result<()> {
lib.add_defines([
- ("FRAMEBUFFER", Some("1")),
("USE_RGB_COLORS", Some("1")),
("DISPLAY_RESX", Some("240")),
("DISPLAY_RESY", Some("320")),
]);
-
- if cfg!(feature = "emulator") {
- lib.add_source("display/unix/display_driver.c");
- } else if cfg!(feature = "mcu_stm32f4") {
+ if cfg!(feature = "mcu_stm32f4") {
lib.add_sources([
"display/stm32f429i-disc1/display_driver.c",
"display/stm32f429i-disc1/display_ltdc.c",
@@ -154,28 +208,3 @@ fn define_display_d001(lib: &mut CLibrary) -> Result<()> {
}
Ok(())
}
-
-fn define_display_d002(lib: &mut CLibrary) -> Result<()> {
- lib.add_defines([
- ("FRAMEBUFFER", Some("1")),
- ("UI_COLOR_32BIT", Some("1")),
- ("USE_RGB_COLORS", Some("1")),
- ("DISPLAY_RESX", Some("240")),
- ("DISPLAY_RESY", Some("240")),
- ]);
-
- if cfg!(feature = "emulator") {
- lib.add_source("display/unix/display_driver.c");
- } else if cfg!(feature = "mcu_stm32u5g") {
- lib.add_sources([
- "display/ltdc_dsi/display_driver.c",
- "display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.c",
- "display/ltdc_dsi/display_fb.c",
- "display/ltdc_dsi/display_fb_rgb888.c",
- "display/fb_queue/fb_queue.c",
- ]);
- } else {
- bail_unsupported!();
- }
- Ok(())
-}
diff --git a/core/embed/io/display/st-7789/display_driver.c b/core/embed/io/display/st-7789/display_driver.c
index fd4b4792..8ea3c457 100644
--- a/core/embed/io/display/st-7789/display_driver.c
+++ b/core/embed/io/display/st-7789/display_driver.c
@@ -61,10 +61,9 @@ bool display_init(display_content_mode_t mode) {
#endif
if (mode == DISPLAY_RESET_CONTENT) {
-#if defined TREZOR_MODEL_T2T1 && !defined BOARDLOADER
- // This is required for the model T to work correctly.
- // Boardloader does this by constant in binary, other stages need to read
- // this from the display
+#if defined(DISPLAY_PANEL_T2T1) && !defined(BOARDLOADER)
+ // Boardloader sets DISPLAY_ST7789V_INVERT_COLORS2 as a const in binary;
+ // other stages must read the current state from the display before reset.
display_panel_preserve_inversion();
#endif
display_io_init_gpio();
@@ -119,9 +118,9 @@ void display_deinit(display_content_mode_t mode) {
backlight_deinit(mode == DISPLAY_RESET_CONTENT ? BACKLIGHT_RESET
: BACKLIGHT_RETAIN);
-#ifdef TREZOR_MODEL_T2T1
- // This ensures backward compatibility with legacy bootloader/firmware
- // that relies on this hardware settings from the previous boot stage
+#ifdef DISPLAY_PANEL_T2T1
+ // Ensures backward compatibility with legacy bootloader/firmware
+ // that relies on these hardware settings from the previous boot stage.
if (mode == DISPLAY_RESET_CONTENT) {
display_set_orientation(0);
}
diff --git a/core/embed/io/display/st-7789/display_panel.c b/core/embed/io/display/st-7789/display_panel.c
index 6064165a..283bdc7a 100644
--- a/core/embed/io/display/st-7789/display_panel.c
+++ b/core/embed/io/display/st-7789/display_panel.c
@@ -17,24 +17,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// using const volatile instead of #define results in binaries that change
-// only in 1-byte when the flag changes.
-// using #define leads compiler to over-optimize the code leading to bigger
-// differencies in the resulting binaries.
+#include <trezor_bsp.h>
-#include "display_panel.h"
#include "display_io.h"
+#include "display_panel.h"
-#ifdef TREZOR_MODEL_T2T1
-#include "panels/154a.h"
-#include "panels/lx154a2411.h"
-#include "panels/lx154a2422.h"
-#include "panels/tf15411a.h"
-#else
-#ifdef DISPLAY_PANEL_LX154A2482
+#ifdef DISPLAY_PANEL_T2T1
+#include "panels/t2t1.h"
+#define PANEL_INIT_SEQ t2t1_init_seq
+#define PANEL_ROTATE t2t1_rotate
+#define PANEL_REINIT t2t1_reinit
+#elif defined(DISPLAY_PANEL_LX154A2482)
#include "panels/lx154a2482.h"
#define PANEL_INIT_SEQ lx154a2482_init_seq
#define PANEL_ROTATE lx154a2482_rotate
+#define PANEL_REINIT lx154a2482_init_seq
#elif defined(DISPLAY_PANEL_LHS200KB_IF21)
#include "panels/lhs200kb-if21.h"
#define PANEL_INIT_SEQ lhs200kb_if21_init_seq
@@ -43,28 +40,8 @@
#error "No display panel defined"
#endif
-#endif
-
#ifdef KERNEL_MODE
-#ifdef TREZOR_MODEL_T2T1
-#ifdef BOARDLOADER
-// using const volatile instead of #define results in binaries that change
-// only in 1-byte when the flag changes.
-// using #define leads compiler to over-optimize the code leading to bigger
-// differences in the resulting binaries.
-const volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS2 = 1;
-
-#else
-
-volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS2 = 0;
-
-void display_panel_preserve_inversion(void) {
- DISPLAY_ST7789V_INVERT_COLORS2 = display_panel_is_inverted();
-}
-#endif
-#endif
-
// Window padding (correction) when using 90dg or 270dg orientation
// (internally the display is 240x320, but we use only 240x240)
static display_padding_t g_window_padding;
@@ -210,6 +187,10 @@ void display_panel_set_big_endian(void) {
}
}
+#if defined(DISPLAY_PANEL_T2T1) && !defined(BOARDLOADER)
+void display_panel_preserve_inversion(void) { t2t1_preserve_inversion(); }
+#endif
+
void display_panel_init(void) {
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); // LCD_RST/PC14
// wait 10 milliseconds. only needs to be low for 10 microseconds.
@@ -222,23 +203,7 @@ void display_panel_init(void) {
// (experienced display flakiness using only 5ms wait before sending commands)
HAL_Delay(120);
- // identify the controller we will communicate with
-#ifdef TREZOR_MODEL_T2T1
- uint32_t id = display_panel_identify();
- if (id == DISPLAY_ID_GC9307) {
- tf15411a_init_seq();
- } else if (id == DISPLAY_ID_ST7789V) {
- if (DISPLAY_ST7789V_INVERT_COLORS2) {
- lx154a2422_init_seq();
- } else {
- lx154a2411_init_seq();
- }
- } else if (id == DISPLAY_ID_ILI9341V) {
- _154a_init_seq();
- }
-#else
PANEL_INIT_SEQ();
-#endif
display_panel_unsleep();
}
@@ -246,32 +211,11 @@ void display_panel_init(void) {
void display_panel_reinit(void) {
// reinitialization is needed due to original sequence is unchangeable in
// boardloader
-#ifdef TREZOR_MODEL_T2T1
- // model TT has new gamma settings
- uint32_t id = display_panel_identify();
- if (id == DISPLAY_ID_ST7789V && display_panel_is_inverted()) {
- // newest TT display - set proper gamma
- lx154a2422_gamma();
- } else if (id == DISPLAY_ID_ST7789V) {
- lx154a2411_gamma();
- }
-#elif defined TREZOR_MODEL_T3T1
- // reduced touch-display interference in T3T1
- lx154a2482_init_seq();
+#ifdef PANEL_REINIT
+ PANEL_REINIT();
#endif
}
-void display_panel_rotate(int angle) {
-#ifdef TREZOR_MODEL_T2T1
- uint32_t id = display_panel_identify();
- if (id == DISPLAY_ID_GC9307) {
- tf15411a_rotate(angle, &g_window_padding);
- } else {
- lx154a2422_rotate(angle, &g_window_padding);
- }
-#else
- PANEL_ROTATE(angle, &g_window_padding);
-#endif
-}
+void display_panel_rotate(int angle) { PANEL_ROTATE(angle, &g_window_padding); }
#endif // KERNEL_MODE
diff --git a/core/embed/io/display/st-7789/display_panel.h b/core/embed/io/display/st-7789/display_panel.h
index ac551d13..571d0874 100644
--- a/core/embed/io/display/st-7789/display_panel.h
+++ b/core/embed/io/display/st-7789/display_panel.h
@@ -55,7 +55,7 @@ void display_panel_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
uint16_t y1);
void display_panel_rotate(int angle);
-#if defined TREZOR_MODEL_T2T1 && !defined BOARDLOADER
+#if defined(DISPLAY_PANEL_T2T1) && !defined(BOARDLOADER)
void display_panel_preserve_inversion(void);
#endif
diff --git a/core/embed/io/display/st-7789/panels/t2t1.c b/core/embed/io/display/st-7789/panels/t2t1.c
new file mode 100644
index 00000000..2ab37e5d
--- /dev/null
+++ b/core/embed/io/display/st-7789/panels/t2t1.c
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Using const volatile instead of #define results in binaries that change
+// only in 1 byte when the flag changes.
+// Using #define leads the compiler to over-optimize the code, resulting in
+// larger differences in the binaries.
+
+#include "t2t1.h"
+
+#include "154a.h"
+#include "lx154a2411.h"
+#include "lx154a2422.h"
+#include "tf15411a.h"
+
+#ifdef BOARDLOADER
+const volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS2 = 1;
+#else
+volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS2 = 0;
+
+void t2t1_preserve_inversion(void) {
+ DISPLAY_ST7789V_INVERT_COLORS2 = display_panel_is_inverted();
+}
+#endif
+
+void t2t1_init_seq(void) {
+ uint32_t id = display_panel_identify();
+ if (id == DISPLAY_ID_GC9307) {
+ tf15411a_init_seq();
+ } else if (id == DISPLAY_ID_ST7789V) {
+ if (DISPLAY_ST7789V_INVERT_COLORS2) {
+ lx154a2422_init_seq();
+ } else {
+ lx154a2411_init_seq();
+ }
+ } else if (id == DISPLAY_ID_ILI9341V) {
+ _154a_init_seq();
+ }
+}
+
+void t2t1_reinit(void) {
+ uint32_t id = display_panel_identify();
+ if (id == DISPLAY_ID_ST7789V && display_panel_is_inverted()) {
+ lx154a2422_gamma();
+ } else if (id == DISPLAY_ID_ST7789V) {
+ lx154a2411_gamma();
+ }
+}
+
+void t2t1_rotate(int degrees, display_padding_t* padding) {
+ uint32_t id = display_panel_identify();
+ if (id == DISPLAY_ID_GC9307) {
+ tf15411a_rotate(degrees, padding);
+ } else {
+ lx154a2422_rotate(degrees, padding);
+ }
+}
diff --git a/core/embed/io/display/st-7789/panels/t2t1.h b/core/embed/io/display/st-7789/panels/t2t1.h
new file mode 100644
index 00000000..e8ffb94e
--- /dev/null
+++ b/core/embed/io/display/st-7789/panels/t2t1.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef T2T1_H_
+#define T2T1_H_
+
+#include "../display_panel.h"
+
+// Composed panel for Trezor Model T (T2T1).
+// Dispatches at runtime between GC9307, ST7789V, and ILI9341V controllers
+// based on display IC identification.
+
+void t2t1_init_seq(void);
+void t2t1_reinit(void);
+void t2t1_rotate(int degrees, display_padding_t* padding);
+
+#ifndef BOARDLOADER
+void t2t1_preserve_inversion(void);
+#endif
+
+#endif // T2T1_H_
diff --git a/core/embed/io/touch/build.rs b/core/embed/io/touch/build.rs
index 5415730b..7c115af1 100644
--- a/core/embed/io/touch/build.rs
+++ b/core/embed/io/touch/build.rs
@@ -18,7 +18,7 @@ pub fn def_module(lib: &mut CLibrary) -> Result<()> {
lib.add_define("USE_TOUCH_WAKEUP", Some("1"));
}
- if cfg!(feature = "emulator") {
+ if cfg!(feature = "touch_unix") {
lib.add_source("touch/unix/touch.c");
} else if cfg!(feature = "touch_ft3168") {
lib.add_define("TOUCH_WAKEUP_ENABLED", Some("0"));
diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py
index eb64ded9..eccab176 100644
--- a/core/site_scons/models/T2T1/trezor_t.py
+++ b/core/site_scons/models/T2T1/trezor_t.py
@@ -63,6 +63,7 @@ def configure(
sources += ["embed/io/display/st-7789/panels/154a.c"]
sources += ["embed/io/display/st-7789/panels/lx154a2411.c"]
sources += ["embed/io/display/st-7789/panels/lx154a2422.c"]
+ sources += ["embed/io/display/st-7789/panels/t2t1.c"]
paths += ["embed/io/display/inc"]
defines += [("USE_DISPLAY", "1")]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.