diff --git a/core/embed/trezorhal/dma2d_bitblt.h b/core/embed/drv/gfx/bitblt/dma2d_bitblt.h similarity index 100% rename from core/embed/trezorhal/dma2d_bitblt.h rename to core/embed/drv/gfx/bitblt/dma2d_bitblt.h diff --git a/core/embed/lib/gfx_bitblt_mono8.c b/core/embed/drv/gfx/bitblt/gfx_bitblt_mono8.c similarity index 100% rename from core/embed/lib/gfx_bitblt_mono8.c rename to core/embed/drv/gfx/bitblt/gfx_bitblt_mono8.c diff --git a/core/embed/lib/gfx_bitblt_rgb565.c b/core/embed/drv/gfx/bitblt/gfx_bitblt_rgb565.c similarity index 100% rename from core/embed/lib/gfx_bitblt_rgb565.c rename to core/embed/drv/gfx/bitblt/gfx_bitblt_rgb565.c diff --git a/core/embed/lib/gfx_bitblt_rgba8888.c b/core/embed/drv/gfx/bitblt/gfx_bitblt_rgba8888.c similarity index 100% rename from core/embed/lib/gfx_bitblt_rgba8888.c rename to core/embed/drv/gfx/bitblt/gfx_bitblt_rgba8888.c diff --git a/core/embed/trezorhal/stm32f4/dma2d_bitblt.c b/core/embed/drv/gfx/bitblt/stm32/dma2d_bitblt.c similarity index 100% rename from core/embed/trezorhal/stm32f4/dma2d_bitblt.c rename to core/embed/drv/gfx/bitblt/stm32/dma2d_bitblt.c diff --git a/core/embed/trezorhal/unix/dma2d_bitblt.c b/core/embed/drv/gfx/bitblt/unix/dma2d_bitblt.c similarity index 100% rename from core/embed/trezorhal/unix/dma2d_bitblt.c rename to core/embed/drv/gfx/bitblt/unix/dma2d_bitblt.c diff --git a/core/embed/lib/gfx_color.c b/core/embed/drv/gfx/draw/gfx_color.c similarity index 100% rename from core/embed/lib/gfx_color.c rename to core/embed/drv/gfx/draw/gfx_color.c diff --git a/core/embed/lib/gfx_draw.c b/core/embed/drv/gfx/draw/gfx_draw.c similarity index 100% rename from core/embed/lib/gfx_draw.c rename to core/embed/drv/gfx/draw/gfx_draw.c diff --git a/core/embed/lib/fonts/font_bitmap.c b/core/embed/drv/gfx/fonts/font_bitmap.c similarity index 100% rename from core/embed/lib/fonts/font_bitmap.c rename to core/embed/drv/gfx/fonts/font_bitmap.c diff --git a/core/embed/lib/fonts/font_bitmap.h b/core/embed/drv/gfx/fonts/font_bitmap.h similarity index 100% rename from core/embed/lib/fonts/font_bitmap.h rename to core/embed/drv/gfx/fonts/font_bitmap.h diff --git a/core/embed/lib/fonts/font_pixeloperator_bold_8.c b/core/embed/drv/gfx/fonts/font_pixeloperator_bold_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_bold_8.c rename to core/embed/drv/gfx/fonts/font_pixeloperator_bold_8.c diff --git a/core/embed/lib/fonts/font_pixeloperator_bold_8.h b/core/embed/drv/gfx/fonts/font_pixeloperator_bold_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_bold_8.h rename to core/embed/drv/gfx/fonts/font_pixeloperator_bold_8.h diff --git a/core/embed/lib/fonts/font_pixeloperator_regular_8.c b/core/embed/drv/gfx/fonts/font_pixeloperator_regular_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_regular_8.c rename to core/embed/drv/gfx/fonts/font_pixeloperator_regular_8.c diff --git a/core/embed/lib/fonts/font_pixeloperator_regular_8.h b/core/embed/drv/gfx/fonts/font_pixeloperator_regular_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperator_regular_8.h rename to core/embed/drv/gfx/fonts/font_pixeloperator_regular_8.h diff --git a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c b/core/embed/drv/gfx/fonts/font_pixeloperatormono_regular_8.c similarity index 100% rename from core/embed/lib/fonts/font_pixeloperatormono_regular_8.c rename to core/embed/drv/gfx/fonts/font_pixeloperatormono_regular_8.c diff --git a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.h b/core/embed/drv/gfx/fonts/font_pixeloperatormono_regular_8.h similarity index 100% rename from core/embed/lib/fonts/font_pixeloperatormono_regular_8.h rename to core/embed/drv/gfx/fonts/font_pixeloperatormono_regular_8.h diff --git a/core/embed/lib/fonts/font_roboto_bold_20.c b/core/embed/drv/gfx/fonts/font_roboto_bold_20.c similarity index 100% rename from core/embed/lib/fonts/font_roboto_bold_20.c rename to core/embed/drv/gfx/fonts/font_roboto_bold_20.c diff --git a/core/embed/lib/fonts/font_roboto_bold_20.h b/core/embed/drv/gfx/fonts/font_roboto_bold_20.h similarity index 100% rename from core/embed/lib/fonts/font_roboto_bold_20.h rename to core/embed/drv/gfx/fonts/font_roboto_bold_20.h diff --git a/core/embed/lib/fonts/font_roboto_regular_20.c b/core/embed/drv/gfx/fonts/font_roboto_regular_20.c similarity index 100% rename from core/embed/lib/fonts/font_roboto_regular_20.c rename to core/embed/drv/gfx/fonts/font_roboto_regular_20.c diff --git a/core/embed/lib/fonts/font_roboto_regular_20.h b/core/embed/drv/gfx/fonts/font_roboto_regular_20.h similarity index 100% rename from core/embed/lib/fonts/font_roboto_regular_20.h rename to core/embed/drv/gfx/fonts/font_roboto_regular_20.h diff --git a/core/embed/lib/fonts/font_robotomono_medium_20.c b/core/embed/drv/gfx/fonts/font_robotomono_medium_20.c similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_20.c rename to core/embed/drv/gfx/fonts/font_robotomono_medium_20.c diff --git a/core/embed/lib/fonts/font_robotomono_medium_20.h b/core/embed/drv/gfx/fonts/font_robotomono_medium_20.h similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_20.h rename to core/embed/drv/gfx/fonts/font_robotomono_medium_20.h diff --git a/core/embed/lib/fonts/font_robotomono_medium_21.c b/core/embed/drv/gfx/fonts/font_robotomono_medium_21.c similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_21.c rename to core/embed/drv/gfx/fonts/font_robotomono_medium_21.c diff --git a/core/embed/lib/fonts/font_robotomono_medium_21.h b/core/embed/drv/gfx/fonts/font_robotomono_medium_21.h similarity index 100% rename from core/embed/lib/fonts/font_robotomono_medium_21.h rename to core/embed/drv/gfx/fonts/font_robotomono_medium_21.h diff --git a/core/embed/lib/fonts/font_tthoves_bold_17.c b/core/embed/drv/gfx/fonts/font_tthoves_bold_17.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_bold_17.c rename to core/embed/drv/gfx/fonts/font_tthoves_bold_17.c diff --git a/core/embed/lib/fonts/font_tthoves_bold_17.h b/core/embed/drv/gfx/fonts/font_tthoves_bold_17.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_bold_17.h rename to core/embed/drv/gfx/fonts/font_tthoves_bold_17.h diff --git a/core/embed/lib/fonts/font_tthoves_demibold_21.c b/core/embed/drv/gfx/fonts/font_tthoves_demibold_21.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_demibold_21.c rename to core/embed/drv/gfx/fonts/font_tthoves_demibold_21.c diff --git a/core/embed/lib/fonts/font_tthoves_demibold_21.h b/core/embed/drv/gfx/fonts/font_tthoves_demibold_21.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_demibold_21.h rename to core/embed/drv/gfx/fonts/font_tthoves_demibold_21.h diff --git a/core/embed/lib/fonts/font_tthoves_regular_21.c b/core/embed/drv/gfx/fonts/font_tthoves_regular_21.c similarity index 100% rename from core/embed/lib/fonts/font_tthoves_regular_21.c rename to core/embed/drv/gfx/fonts/font_tthoves_regular_21.c diff --git a/core/embed/lib/fonts/font_tthoves_regular_21.h b/core/embed/drv/gfx/fonts/font_tthoves_regular_21.h similarity index 100% rename from core/embed/lib/fonts/font_tthoves_regular_21.h rename to core/embed/drv/gfx/fonts/font_tthoves_regular_21.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_18.c b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_18.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_18.c rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_18.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_18.h b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_18.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_18.h rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_18.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_21.c b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_21.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_21.c rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_21.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_21.h b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_21.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_21.h rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_21.h diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_42.c b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_42.c similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_42.c rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_42.c diff --git a/core/embed/lib/fonts/font_ttsatoshi_demibold_42.h b/core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_42.h similarity index 100% rename from core/embed/lib/fonts/font_ttsatoshi_demibold_42.h rename to core/embed/drv/gfx/fonts/font_ttsatoshi_demibold_42.h diff --git a/core/embed/lib/fonts/font_unifont_bold_16.c b/core/embed/drv/gfx/fonts/font_unifont_bold_16.c similarity index 100% rename from core/embed/lib/fonts/font_unifont_bold_16.c rename to core/embed/drv/gfx/fonts/font_unifont_bold_16.c diff --git a/core/embed/lib/fonts/font_unifont_bold_16.h b/core/embed/drv/gfx/fonts/font_unifont_bold_16.h similarity index 100% rename from core/embed/lib/fonts/font_unifont_bold_16.h rename to core/embed/drv/gfx/fonts/font_unifont_bold_16.h diff --git a/core/embed/lib/fonts/font_unifont_regular_16.c b/core/embed/drv/gfx/fonts/font_unifont_regular_16.c similarity index 100% rename from core/embed/lib/fonts/font_unifont_regular_16.c rename to core/embed/drv/gfx/fonts/font_unifont_regular_16.c diff --git a/core/embed/lib/fonts/font_unifont_regular_16.h b/core/embed/drv/gfx/fonts/font_unifont_regular_16.h similarity index 100% rename from core/embed/lib/fonts/font_unifont_regular_16.h rename to core/embed/drv/gfx/fonts/font_unifont_regular_16.h diff --git a/core/embed/lib/fonts/fonts.c b/core/embed/drv/gfx/fonts/fonts.c similarity index 100% rename from core/embed/lib/fonts/fonts.c rename to core/embed/drv/gfx/fonts/fonts.c diff --git a/core/embed/lib/fonts/fonts.h b/core/embed/drv/gfx/fonts/fonts.h similarity index 100% rename from core/embed/lib/fonts/fonts.h rename to core/embed/drv/gfx/fonts/fonts.h diff --git a/core/embed/lib/gfx_bitblt.h b/core/embed/drv/gfx/gfx_bitblt.h similarity index 100% rename from core/embed/lib/gfx_bitblt.h rename to core/embed/drv/gfx/gfx_bitblt.h diff --git a/core/embed/lib/gfx_color.h b/core/embed/drv/gfx/gfx_color.h similarity index 100% rename from core/embed/lib/gfx_color.h rename to core/embed/drv/gfx/gfx_color.h diff --git a/core/embed/lib/gfx_draw.h b/core/embed/drv/gfx/gfx_draw.h similarity index 100% rename from core/embed/lib/gfx_draw.h rename to core/embed/drv/gfx/gfx_draw.h diff --git a/core/embed/lib/qr-code-generator b/core/embed/drv/gfx/qr-code-generator similarity index 100% rename from core/embed/lib/qr-code-generator rename to core/embed/drv/gfx/qr-code-generator diff --git a/core/embed/lib/terminal.h b/core/embed/drv/gfx/terminal.h similarity index 100% rename from core/embed/lib/terminal.h rename to core/embed/drv/gfx/terminal.h diff --git a/core/embed/lib/terminal.c b/core/embed/drv/gfx/terminal/terminal.c similarity index 100% rename from core/embed/lib/terminal.c rename to core/embed/drv/gfx/terminal/terminal.c diff --git a/core/embed/trezorhal/button.h b/core/embed/drv/io/button.h similarity index 100% rename from core/embed/trezorhal/button.h rename to core/embed/drv/io/button.h diff --git a/core/embed/trezorhal/stm32f4/button.c b/core/embed/drv/io/button/stm32/button.c similarity index 100% rename from core/embed/trezorhal/stm32f4/button.c rename to core/embed/drv/io/button/stm32/button.c diff --git a/core/embed/trezorhal/unix/button.c b/core/embed/drv/io/button/unix/button.c similarity index 100% rename from core/embed/trezorhal/unix/button.c rename to core/embed/drv/io/button/unix/button.c diff --git a/core/embed/trezorhal/display.h b/core/embed/drv/io/display.h similarity index 100% rename from core/embed/trezorhal/display.h rename to core/embed/drv/io/display.h diff --git a/core/embed/trezorhal/stm32f4/backlight_pwm.c b/core/embed/drv/io/display/backlight/stm32/backlight_pwm.c similarity index 100% rename from core/embed/trezorhal/stm32f4/backlight_pwm.c rename to core/embed/drv/io/display/backlight/stm32/backlight_pwm.c diff --git a/core/embed/trezorhal/stm32f4/backlight_pwm.h b/core/embed/drv/io/display/backlight_pwm.h similarity index 100% rename from core/embed/trezorhal/stm32f4/backlight_pwm.h rename to core/embed/drv/io/display/backlight_pwm.h diff --git a/core/embed/trezorhal/bg_copy.h b/core/embed/drv/io/display/bg_copy.h similarity index 100% rename from core/embed/trezorhal/bg_copy.h rename to core/embed/drv/io/display/bg_copy.h diff --git a/core/embed/trezorhal/stm32u5/bg_copy.c b/core/embed/drv/io/display/bg_copy/stm32u5/bg_copy.c similarity index 100% rename from core/embed/trezorhal/stm32u5/bg_copy.c rename to core/embed/drv/io/display/bg_copy/stm32u5/bg_copy.c diff --git a/core/embed/lib/display_utils.c b/core/embed/drv/io/display/display_utils.c similarity index 100% rename from core/embed/lib/display_utils.c rename to core/embed/drv/io/display/display_utils.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c b/core/embed/drv/io/display/st-7789/display_driver.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_driver.c rename to core/embed/drv/io/display/st-7789/display_driver.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.c b/core/embed/drv/io/display/st-7789/display_fb.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.c rename to core/embed/drv/io/display/st-7789/display_fb.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.h b/core/embed/drv/io/display/st-7789/display_fb.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_fb.h rename to core/embed/drv/io/display/st-7789/display_fb.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_internal.h b/core/embed/drv/io/display/st-7789/display_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_internal.h rename to core/embed/drv/io/display/st-7789/display_internal.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c b/core/embed/drv/io/display/st-7789/display_io.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.c rename to core/embed/drv/io/display/st-7789/display_io.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.h b/core/embed/drv/io/display/st-7789/display_io.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_io.h rename to core/embed/drv/io/display/st-7789/display_io.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c b/core/embed/drv/io/display/st-7789/display_nofb.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_nofb.c rename to core/embed/drv/io/display/st-7789/display_nofb.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.c b/core/embed/drv/io/display/st-7789/display_panel.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.c rename to core/embed/drv/io/display/st-7789/display_panel.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.h b/core/embed/drv/io/display/st-7789/display_panel.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/display_panel.h rename to core/embed/drv/io/display/st-7789/display_panel.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c b/core/embed/drv/io/display/st-7789/panels/154a.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c rename to core/embed/drv/io/display/st-7789/panels/154a.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.h b/core/embed/drv/io/display/st-7789/panels/154a.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.h rename to core/embed/drv/io/display/st-7789/panels/154a.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.c b/core/embed/drv/io/display/st-7789/panels/lhs200kb-if21.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.c rename to core/embed/drv/io/display/st-7789/panels/lhs200kb-if21.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.h b/core/embed/drv/io/display/st-7789/panels/lhs200kb-if21.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lhs200kb-if21.h rename to core/embed/drv/io/display/st-7789/panels/lhs200kb-if21.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c b/core/embed/drv/io/display/st-7789/panels/lx154a2411.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c rename to core/embed/drv/io/display/st-7789/panels/lx154a2411.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.h b/core/embed/drv/io/display/st-7789/panels/lx154a2411.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.h rename to core/embed/drv/io/display/st-7789/panels/lx154a2411.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c b/core/embed/drv/io/display/st-7789/panels/lx154a2422.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c rename to core/embed/drv/io/display/st-7789/panels/lx154a2422.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.h b/core/embed/drv/io/display/st-7789/panels/lx154a2422.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.h rename to core/embed/drv/io/display/st-7789/panels/lx154a2422.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.c b/core/embed/drv/io/display/st-7789/panels/lx154a2482.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.c rename to core/embed/drv/io/display/st-7789/panels/lx154a2482.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.h b/core/embed/drv/io/display/st-7789/panels/lx154a2482.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2482.h rename to core/embed/drv/io/display/st-7789/panels/lx154a2482.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.c b/core/embed/drv/io/display/st-7789/panels/tf15411a.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.c rename to core/embed/drv/io/display/st-7789/panels/tf15411a.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.h b/core/embed/drv/io/display/st-7789/panels/tf15411a.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/tf15411a.h rename to core/embed/drv/io/display/st-7789/panels/tf15411a.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c b/core/embed/drv/io/display/stm32f429i-disc1/display_driver.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_driver.c rename to core/embed/drv/io/display/stm32f429i-disc1/display_driver.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_internal.h b/core/embed/drv/io/display/stm32f429i-disc1/display_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_internal.h rename to core/embed/drv/io/display/stm32f429i-disc1/display_internal.h diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c b/core/embed/drv/io/display/stm32f429i-disc1/display_ltdc.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/display_ltdc.c rename to core/embed/drv/io/display/stm32f429i-disc1/display_ltdc.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.c b/core/embed/drv/io/display/stm32f429i-disc1/ili9341_spi.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.c rename to core/embed/drv/io/display/stm32f429i-disc1/ili9341_spi.c diff --git a/core/embed/trezorhal/stm32f4/displays/ili9341_spi.h b/core/embed/drv/io/display/stm32f429i-disc1/ili9341_spi.h similarity index 100% rename from core/embed/trezorhal/stm32f4/displays/ili9341_spi.h rename to core/embed/drv/io/display/stm32f429i-disc1/ili9341_spi.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c b/core/embed/drv/io/display/stm32u5a9j-dk/display_driver.c similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_driver.c rename to core/embed/drv/io/display/stm32u5a9j-dk/display_driver.c diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c b/core/embed/drv/io/display/stm32u5a9j-dk/display_fb.c similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_fb.c rename to core/embed/drv/io/display/stm32u5a9j-dk/display_fb.c diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_gfxmmu_lut.h b/core/embed/drv/io/display/stm32u5a9j-dk/display_gfxmmu_lut.h similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_gfxmmu_lut.h rename to core/embed/drv/io/display/stm32u5a9j-dk/display_gfxmmu_lut.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_internal.h b/core/embed/drv/io/display/stm32u5a9j-dk/display_internal.h similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_internal.h rename to core/embed/drv/io/display/stm32u5a9j-dk/display_internal.h diff --git a/core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c b/core/embed/drv/io/display/stm32u5a9j-dk/display_ltdc_dsi.c similarity index 100% rename from core/embed/trezorhal/stm32u5/xdisplay/stm32u5a9j-dk/display_ltdc_dsi.c rename to core/embed/drv/io/display/stm32u5a9j-dk/display_ltdc_dsi.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c b/core/embed/drv/io/display/ug-2828/display_driver.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/ug-2828/display_driver.c rename to core/embed/drv/io/display/ug-2828/display_driver.c diff --git a/core/embed/trezorhal/unix/display_driver.c b/core/embed/drv/io/display/unix/display_driver.c similarity index 100% rename from core/embed/trezorhal/unix/display_driver.c rename to core/embed/drv/io/display/unix/display_driver.c diff --git a/core/embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c b/core/embed/drv/io/display/vg-2864/display_driver.c similarity index 100% rename from core/embed/trezorhal/stm32f4/xdisplay/vg-2864/display_driver.c rename to core/embed/drv/io/display/vg-2864/display_driver.c diff --git a/core/embed/lib/display_utils.h b/core/embed/drv/io/display_utils.h similarity index 100% rename from core/embed/lib/display_utils.h rename to core/embed/drv/io/display_utils.h diff --git a/core/embed/trezorhal/haptic.h b/core/embed/drv/io/haptic.h similarity index 100% rename from core/embed/trezorhal/haptic.h rename to core/embed/drv/io/haptic.h diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/actuators/vg1040003d.h b/core/embed/drv/io/haptic/drv2625/actuators/vg1040003d.h similarity index 100% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/actuators/vg1040003d.h rename to core/embed/drv/io/haptic/drv2625/actuators/vg1040003d.h diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c b/core/embed/drv/io/haptic/drv2625/drv2625.c similarity index 100% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c rename to core/embed/drv/io/haptic/drv2625/drv2625.c diff --git a/core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.h b/core/embed/drv/io/haptic/drv2625/drv2625.h similarity index 100% rename from core/embed/trezorhal/stm32u5/haptic/drv2625/drv2625.h rename to core/embed/drv/io/haptic/drv2625/drv2625.h diff --git a/core/embed/trezorhal/i2c_bus.h b/core/embed/drv/io/i2c_bus.h similarity index 100% rename from core/embed/trezorhal/i2c_bus.h rename to core/embed/drv/io/i2c_bus.h diff --git a/core/embed/trezorhal/stm32f4/i2c_bus.c b/core/embed/drv/io/i2c_bus/stm32f4/i2c_bus.c similarity index 100% rename from core/embed/trezorhal/stm32f4/i2c_bus.c rename to core/embed/drv/io/i2c_bus/stm32f4/i2c_bus.c diff --git a/core/embed/trezorhal/stm32u5/i2c_bus.c b/core/embed/drv/io/i2c_bus/stm32u5/i2c_bus.c similarity index 100% rename from core/embed/trezorhal/stm32u5/i2c_bus.c rename to core/embed/drv/io/i2c_bus/stm32u5/i2c_bus.c diff --git a/core/embed/trezorhal/rgb_led.h b/core/embed/drv/io/rgb_led.h similarity index 100% rename from core/embed/trezorhal/rgb_led.h rename to core/embed/drv/io/rgb_led.h diff --git a/core/embed/trezorhal/stm32f4/rgb_led.c b/core/embed/drv/io/rgbled/stm32f4/rgb_led.c similarity index 100% rename from core/embed/trezorhal/stm32f4/rgb_led.c rename to core/embed/drv/io/rgbled/stm32f4/rgb_led.c diff --git a/core/embed/trezorhal/sbu.h b/core/embed/drv/io/sbu.h similarity index 100% rename from core/embed/trezorhal/sbu.h rename to core/embed/drv/io/sbu.h diff --git a/core/embed/trezorhal/stm32f4/sbu.c b/core/embed/drv/io/sbu/stm32/sbu.c similarity index 100% rename from core/embed/trezorhal/stm32f4/sbu.c rename to core/embed/drv/io/sbu/stm32/sbu.c diff --git a/core/embed/trezorhal/unix/sbu.c b/core/embed/drv/io/sbu/unix/sbu.c similarity index 100% rename from core/embed/trezorhal/unix/sbu.c rename to core/embed/drv/io/sbu/unix/sbu.c diff --git a/core/embed/trezorhal/sdcard.h b/core/embed/drv/io/sdcard.h similarity index 100% rename from core/embed/trezorhal/sdcard.h rename to core/embed/drv/io/sdcard.h diff --git a/core/embed/trezorhal/stm32f4/sdcard-set_clr_card_detect.h b/core/embed/drv/io/sdcard/stm32f4/sdcard-set_clr_card_detect.h similarity index 100% rename from core/embed/trezorhal/stm32f4/sdcard-set_clr_card_detect.h rename to core/embed/drv/io/sdcard/stm32f4/sdcard-set_clr_card_detect.h diff --git a/core/embed/trezorhal/stm32f4/sdcard.c b/core/embed/drv/io/sdcard/stm32f4/sdcard.c similarity index 100% rename from core/embed/trezorhal/stm32f4/sdcard.c rename to core/embed/drv/io/sdcard/stm32f4/sdcard.c diff --git a/core/embed/trezorhal/stm32u5/sdcard.c b/core/embed/drv/io/sdcard/stm32u5/sdcard.c similarity index 100% rename from core/embed/trezorhal/stm32u5/sdcard.c rename to core/embed/drv/io/sdcard/stm32u5/sdcard.c diff --git a/core/embed/trezorhal/unix/sdcard.c b/core/embed/drv/io/sdcard/unix/sdcard.c similarity index 100% rename from core/embed/trezorhal/unix/sdcard.c rename to core/embed/drv/io/sdcard/unix/sdcard.c diff --git a/core/embed/trezorhal/touch.h b/core/embed/drv/io/touch.h similarity index 100% rename from core/embed/trezorhal/touch.h rename to core/embed/drv/io/touch.h diff --git a/core/embed/trezorhal/stm32f4/touch/ft6x36.c b/core/embed/drv/io/touch/ft6x36/ft6x36.c similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/ft6x36.c rename to core/embed/drv/io/touch/ft6x36/ft6x36.c diff --git a/core/embed/trezorhal/stm32f4/touch/ft6x36.h b/core/embed/drv/io/touch/ft6x36/ft6x36.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/ft6x36.h rename to core/embed/drv/io/touch/ft6x36/ft6x36.h diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c b/core/embed/drv/io/touch/ft6x36/panels/lhs200kb-if21.c similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c rename to core/embed/drv/io/touch/ft6x36/panels/lhs200kb-if21.c diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h b/core/embed/drv/io/touch/ft6x36/panels/lhs200kb-if21.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h rename to core/embed/drv/io/touch/ft6x36/panels/lhs200kb-if21.h diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.c b/core/embed/drv/io/touch/ft6x36/panels/lx154a2422cpt23.c similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.c rename to core/embed/drv/io/touch/ft6x36/panels/lx154a2422cpt23.c diff --git a/core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.h b/core/embed/drv/io/touch/ft6x36/panels/lx154a2422cpt23.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/panels/lx154a2422cpt23.h rename to core/embed/drv/io/touch/ft6x36/panels/lx154a2422cpt23.h diff --git a/core/embed/trezorhal/stm32u5/touch/sitronix.c b/core/embed/drv/io/touch/sitronix/sitronix.c similarity index 100% rename from core/embed/trezorhal/stm32u5/touch/sitronix.c rename to core/embed/drv/io/touch/sitronix/sitronix.c diff --git a/core/embed/trezorhal/stm32u5/touch/sitronix.h b/core/embed/drv/io/touch/sitronix/sitronix.h similarity index 100% rename from core/embed/trezorhal/stm32u5/touch/sitronix.h rename to core/embed/drv/io/touch/sitronix/sitronix.h diff --git a/core/embed/trezorhal/stm32f4/touch/stmpe811.c b/core/embed/drv/io/touch/stmpe811/stmpe811.c similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/stmpe811.c rename to core/embed/drv/io/touch/stmpe811/stmpe811.c diff --git a/core/embed/trezorhal/stm32f4/touch/stmpe811.h b/core/embed/drv/io/touch/stmpe811/stmpe811.h similarity index 100% rename from core/embed/trezorhal/stm32f4/touch/stmpe811.h rename to core/embed/drv/io/touch/stmpe811/stmpe811.h diff --git a/core/embed/trezorhal/unix/touch.c b/core/embed/drv/io/touch/unix/touch.c similarity index 100% rename from core/embed/trezorhal/unix/touch.c rename to core/embed/drv/io/touch/unix/touch.c diff --git a/core/embed/trezorhal/unit_properties.h b/core/embed/drv/io/unit_properties.h similarity index 100% rename from core/embed/trezorhal/unit_properties.h rename to core/embed/drv/io/unit_properties.h diff --git a/core/embed/trezorhal/usb.h b/core/embed/drv/io/usb.h similarity index 100% rename from core/embed/trezorhal/usb.h rename to core/embed/drv/io/usb.h diff --git a/core/embed/trezorhal/stm32f4/usb/usb.c b/core/embed/drv/io/usb/stm32/usb.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb.c rename to core/embed/drv/io/usb/stm32/usb.c diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_hid.c b/core/embed/drv/io/usb/stm32/usb_class_hid.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb_class_hid.c rename to core/embed/drv/io/usb/stm32/usb_class_hid.c diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_vcp.c b/core/embed/drv/io/usb/stm32/usb_class_vcp.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb_class_vcp.c rename to core/embed/drv/io/usb/stm32/usb_class_vcp.c diff --git a/core/embed/trezorhal/stm32f4/usb/usb_class_webusb.c b/core/embed/drv/io/usb/stm32/usb_class_webusb.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb_class_webusb.c rename to core/embed/drv/io/usb/stm32/usb_class_webusb.c diff --git a/core/embed/trezorhal/stm32f4/usb/usb_internal.h b/core/embed/drv/io/usb/stm32/usb_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usb_internal.h rename to core/embed/drv/io/usb/stm32/usb_internal.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_conf.c b/core/embed/drv/io/usb/stm32/usbd_conf.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_conf.c rename to core/embed/drv/io/usb/stm32/usbd_conf.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_conf.h b/core/embed/drv/io/usb/stm32/usbd_conf.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_conf.h rename to core/embed/drv/io/usb/stm32/usbd_conf.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_core.c b/core/embed/drv/io/usb/stm32/usbd_core.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_core.c rename to core/embed/drv/io/usb/stm32/usbd_core.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_core.h b/core/embed/drv/io/usb/stm32/usbd_core.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_core.h rename to core/embed/drv/io/usb/stm32/usbd_core.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.c b/core/embed/drv/io/usb/stm32/usbd_ctlreq.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.c rename to core/embed/drv/io/usb/stm32/usbd_ctlreq.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.h b/core/embed/drv/io/usb/stm32/usbd_ctlreq.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ctlreq.h rename to core/embed/drv/io/usb/stm32/usbd_ctlreq.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_def.h b/core/embed/drv/io/usb/stm32/usbd_def.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_def.h rename to core/embed/drv/io/usb/stm32/usbd_def.h diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ioreq.c b/core/embed/drv/io/usb/stm32/usbd_ioreq.c similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ioreq.c rename to core/embed/drv/io/usb/stm32/usbd_ioreq.c diff --git a/core/embed/trezorhal/stm32f4/usb/usbd_ioreq.h b/core/embed/drv/io/usb/stm32/usbd_ioreq.h similarity index 100% rename from core/embed/trezorhal/stm32f4/usb/usbd_ioreq.h rename to core/embed/drv/io/usb/stm32/usbd_ioreq.h diff --git a/core/embed/trezorhal/unix/usb.c b/core/embed/drv/io/usb/unix/usb.c similarity index 100% rename from core/embed/trezorhal/unix/usb.c rename to core/embed/drv/io/usb/unix/usb.c diff --git a/core/embed/trezorhal/usb_hid.h b/core/embed/drv/io/usb_hid.h similarity index 100% rename from core/embed/trezorhal/usb_hid.h rename to core/embed/drv/io/usb_hid.h diff --git a/core/embed/trezorhal/usb_vcp.h b/core/embed/drv/io/usb_vcp.h similarity index 100% rename from core/embed/trezorhal/usb_vcp.h rename to core/embed/drv/io/usb_vcp.h diff --git a/core/embed/trezorhal/usb_webusb.h b/core/embed/drv/io/usb_webusb.h similarity index 100% rename from core/embed/trezorhal/usb_webusb.h rename to core/embed/drv/io/usb_webusb.h diff --git a/core/embed/trezorhal/xdisplay.h b/core/embed/drv/io/xdisplay.h similarity index 100% rename from core/embed/trezorhal/xdisplay.h rename to core/embed/drv/io/xdisplay.h diff --git a/core/embed/trezorhal/stm32f4/linker/boardloader.ld b/core/embed/drv/linker/stm32f4/boardloader.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/boardloader.ld rename to core/embed/drv/linker/stm32f4/boardloader.ld diff --git a/core/embed/trezorhal/stm32f4/linker/bootloader.ld b/core/embed/drv/linker/stm32f4/bootloader.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/bootloader.ld rename to core/embed/drv/linker/stm32f4/bootloader.ld diff --git a/core/embed/trezorhal/stm32f4/linker/firmware.ld b/core/embed/drv/linker/stm32f4/firmware.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/firmware.ld rename to core/embed/drv/linker/stm32f4/firmware.ld diff --git a/core/embed/trezorhal/stm32f4/linker/kernel.ld b/core/embed/drv/linker/stm32f4/kernel.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/kernel.ld rename to core/embed/drv/linker/stm32f4/kernel.ld diff --git a/core/embed/trezorhal/stm32f4/linker/memory.ld b/core/embed/drv/linker/stm32f4/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/memory.ld rename to core/embed/drv/linker/stm32f4/memory.ld diff --git a/core/embed/trezorhal/stm32f4/linker/prodtest.ld b/core/embed/drv/linker/stm32f4/prodtest.ld similarity index 100% rename from core/embed/trezorhal/stm32f4/linker/prodtest.ld rename to core/embed/drv/linker/stm32f4/prodtest.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/boardloader.ld b/core/embed/drv/linker/stm32u58/boardloader.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/boardloader.ld rename to core/embed/drv/linker/stm32u58/boardloader.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/bootloader.ld b/core/embed/drv/linker/stm32u58/bootloader.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/bootloader.ld rename to core/embed/drv/linker/stm32u58/bootloader.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/firmware.ld b/core/embed/drv/linker/stm32u58/firmware.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/firmware.ld rename to core/embed/drv/linker/stm32u58/firmware.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/kernel.ld b/core/embed/drv/linker/stm32u58/kernel.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/kernel.ld rename to core/embed/drv/linker/stm32u58/kernel.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/memory.ld b/core/embed/drv/linker/stm32u58/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/memory.ld rename to core/embed/drv/linker/stm32u58/memory.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u58/prodtest.ld b/core/embed/drv/linker/stm32u58/prodtest.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u58/prodtest.ld rename to core/embed/drv/linker/stm32u58/prodtest.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/boardloader.ld b/core/embed/drv/linker/stm32u5a/boardloader.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/boardloader.ld rename to core/embed/drv/linker/stm32u5a/boardloader.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/bootloader.ld b/core/embed/drv/linker/stm32u5a/bootloader.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/bootloader.ld rename to core/embed/drv/linker/stm32u5a/bootloader.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/firmware.ld b/core/embed/drv/linker/stm32u5a/firmware.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/firmware.ld rename to core/embed/drv/linker/stm32u5a/firmware.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/kernel.ld b/core/embed/drv/linker/stm32u5a/kernel.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/kernel.ld rename to core/embed/drv/linker/stm32u5a/kernel.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/memory.ld b/core/embed/drv/linker/stm32u5a/memory.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/memory.ld rename to core/embed/drv/linker/stm32u5a/memory.ld diff --git a/core/embed/trezorhal/stm32u5/linker/u5a/prodtest.ld b/core/embed/drv/linker/stm32u5a/prodtest.ld similarity index 100% rename from core/embed/trezorhal/stm32u5/linker/u5a/prodtest.ld rename to core/embed/drv/linker/stm32u5a/prodtest.ld diff --git a/core/embed/trezorhal/consumption_mask.h b/core/embed/drv/sec/consumption_mask.h similarity index 100% rename from core/embed/trezorhal/consumption_mask.h rename to core/embed/drv/sec/consumption_mask.h diff --git a/core/embed/trezorhal/stm32f4/consumption_mask.c b/core/embed/drv/sec/consumption_mask/stm32f4/consumption_mask.c similarity index 100% rename from core/embed/trezorhal/stm32f4/consumption_mask.c rename to core/embed/drv/sec/consumption_mask/stm32f4/consumption_mask.c diff --git a/core/embed/trezorhal/stm32u5/consumption_mask.c b/core/embed/drv/sec/consumption_mask/stm32u5/consumption_mask.c similarity index 100% rename from core/embed/trezorhal/stm32u5/consumption_mask.c rename to core/embed/drv/sec/consumption_mask/stm32u5/consumption_mask.c diff --git a/core/embed/trezorhal/entropy.h b/core/embed/drv/sec/entropy.h similarity index 100% rename from core/embed/trezorhal/entropy.h rename to core/embed/drv/sec/entropy.h diff --git a/core/embed/trezorhal/stm32f4/entropy.c b/core/embed/drv/sec/entropy/stm32f4/entropy.c similarity index 100% rename from core/embed/trezorhal/stm32f4/entropy.c rename to core/embed/drv/sec/entropy/stm32f4/entropy.c diff --git a/core/embed/trezorhal/stm32u5/entropy.c b/core/embed/drv/sec/entropy/stm32u5/entropy.c similarity index 100% rename from core/embed/trezorhal/stm32u5/entropy.c rename to core/embed/drv/sec/entropy/stm32u5/entropy.c diff --git a/core/embed/trezorhal/unix/entropy.c b/core/embed/drv/sec/entropy/unix/entropy.c similarity index 100% rename from core/embed/trezorhal/unix/entropy.c rename to core/embed/drv/sec/entropy/unix/entropy.c diff --git a/core/embed/trezorhal/hash_processor.h b/core/embed/drv/sec/hash_processor.h similarity index 100% rename from core/embed/trezorhal/hash_processor.h rename to core/embed/drv/sec/hash_processor.h diff --git a/core/embed/trezorhal/stm32u5/hash_processor.c b/core/embed/drv/sec/hash_processor/stm32u5/hash_processor.c similarity index 100% rename from core/embed/trezorhal/stm32u5/hash_processor.c rename to core/embed/drv/sec/hash_processor/stm32u5/hash_processor.c diff --git a/core/embed/trezorhal/monoctr.h b/core/embed/drv/sec/monoctr.h similarity index 100% rename from core/embed/trezorhal/monoctr.h rename to core/embed/drv/sec/monoctr.h diff --git a/core/embed/trezorhal/stm32f4/monoctr.c b/core/embed/drv/sec/monoctr/stm32f4/monoctr.c similarity index 100% rename from core/embed/trezorhal/stm32f4/monoctr.c rename to core/embed/drv/sec/monoctr/stm32f4/monoctr.c diff --git a/core/embed/trezorhal/stm32u5/monoctr.c b/core/embed/drv/sec/monoctr/stm32u5/monoctr.c similarity index 100% rename from core/embed/trezorhal/stm32u5/monoctr.c rename to core/embed/drv/sec/monoctr/stm32u5/monoctr.c diff --git a/core/embed/trezorhal/unix/monoctr.c b/core/embed/drv/sec/monoctr/unix/monoctr.c similarity index 100% rename from core/embed/trezorhal/unix/monoctr.c rename to core/embed/drv/sec/monoctr/unix/monoctr.c diff --git a/core/embed/trezorhal/optiga.h b/core/embed/drv/sec/optiga.h similarity index 100% rename from core/embed/trezorhal/optiga.h rename to core/embed/drv/sec/optiga.h diff --git a/core/embed/trezorhal/optiga/optiga.c b/core/embed/drv/sec/optiga/optiga.c similarity index 100% rename from core/embed/trezorhal/optiga/optiga.c rename to core/embed/drv/sec/optiga/optiga.c diff --git a/core/embed/trezorhal/optiga/optiga_commands.c b/core/embed/drv/sec/optiga/optiga_commands.c similarity index 100% rename from core/embed/trezorhal/optiga/optiga_commands.c rename to core/embed/drv/sec/optiga/optiga_commands.c diff --git a/core/embed/trezorhal/optiga/optiga_transport.c b/core/embed/drv/sec/optiga/optiga_transport.c similarity index 100% rename from core/embed/trezorhal/optiga/optiga_transport.c rename to core/embed/drv/sec/optiga/optiga_transport.c diff --git a/core/embed/trezorhal/stm32f4/optiga_hal.c b/core/embed/drv/sec/optiga/stm32/optiga_hal.c similarity index 100% rename from core/embed/trezorhal/stm32f4/optiga_hal.c rename to core/embed/drv/sec/optiga/stm32/optiga_hal.c diff --git a/core/embed/trezorhal/unix/certs/README.md b/core/embed/drv/sec/optiga/unix/certs/README.md similarity index 100% rename from core/embed/trezorhal/unix/certs/README.md rename to core/embed/drv/sec/optiga/unix/certs/README.md diff --git a/core/embed/trezorhal/unix/certs/T2B1.der b/core/embed/drv/sec/optiga/unix/certs/T2B1.der similarity index 100% rename from core/embed/trezorhal/unix/certs/T2B1.der rename to core/embed/drv/sec/optiga/unix/certs/T2B1.der diff --git a/core/embed/trezorhal/unix/certs/T2B1.h b/core/embed/drv/sec/optiga/unix/certs/T2B1.h similarity index 100% rename from core/embed/trezorhal/unix/certs/T2B1.h rename to core/embed/drv/sec/optiga/unix/certs/T2B1.h diff --git a/core/embed/trezorhal/unix/certs/T3T1.der b/core/embed/drv/sec/optiga/unix/certs/T3T1.der similarity index 100% rename from core/embed/trezorhal/unix/certs/T3T1.der rename to core/embed/drv/sec/optiga/unix/certs/T3T1.der diff --git a/core/embed/trezorhal/unix/certs/T3T1.h b/core/embed/drv/sec/optiga/unix/certs/T3T1.h similarity index 100% rename from core/embed/trezorhal/unix/certs/T3T1.h rename to core/embed/drv/sec/optiga/unix/certs/T3T1.h diff --git a/core/embed/trezorhal/unix/certs/gen.sh b/core/embed/drv/sec/optiga/unix/certs/gen.sh similarity index 100% rename from core/embed/trezorhal/unix/certs/gen.sh rename to core/embed/drv/sec/optiga/unix/certs/gen.sh diff --git a/core/embed/trezorhal/unix/optiga.c b/core/embed/drv/sec/optiga/unix/optiga.c similarity index 100% rename from core/embed/trezorhal/unix/optiga.c rename to core/embed/drv/sec/optiga/unix/optiga.c diff --git a/core/embed/trezorhal/unix/optiga_hal.c b/core/embed/drv/sec/optiga/unix/optiga_hal.c similarity index 100% rename from core/embed/trezorhal/unix/optiga_hal.c rename to core/embed/drv/sec/optiga/unix/optiga_hal.c diff --git a/core/embed/trezorhal/optiga_commands.h b/core/embed/drv/sec/optiga_commands.h similarity index 100% rename from core/embed/trezorhal/optiga_commands.h rename to core/embed/drv/sec/optiga_commands.h diff --git a/core/embed/trezorhal/optiga_common.h b/core/embed/drv/sec/optiga_common.h similarity index 100% rename from core/embed/trezorhal/optiga_common.h rename to core/embed/drv/sec/optiga_common.h diff --git a/core/embed/trezorhal/optiga_hal.h b/core/embed/drv/sec/optiga_hal.h similarity index 100% rename from core/embed/trezorhal/optiga_hal.h rename to core/embed/drv/sec/optiga_hal.h diff --git a/core/embed/trezorhal/optiga_transport.h b/core/embed/drv/sec/optiga_transport.h similarity index 100% rename from core/embed/trezorhal/optiga_transport.h rename to core/embed/drv/sec/optiga_transport.h diff --git a/core/embed/trezorhal/random_delays.h b/core/embed/drv/sec/random_delays.h similarity index 100% rename from core/embed/trezorhal/random_delays.h rename to core/embed/drv/sec/random_delays.h diff --git a/core/embed/trezorhal/stm32f4/random_delays.c b/core/embed/drv/sec/random_delays/stm32/random_delays.c similarity index 100% rename from core/embed/trezorhal/stm32f4/random_delays.c rename to core/embed/drv/sec/random_delays/stm32/random_delays.c diff --git a/core/embed/trezorhal/unix/random_delays.c b/core/embed/drv/sec/random_delays/unix/random_delays.c similarity index 100% rename from core/embed/trezorhal/unix/random_delays.c rename to core/embed/drv/sec/random_delays/unix/random_delays.c diff --git a/core/embed/trezorhal/rng.h b/core/embed/drv/sec/rng.h similarity index 100% rename from core/embed/trezorhal/rng.h rename to core/embed/drv/sec/rng.h diff --git a/core/embed/trezorhal/stm32f4/rng.c b/core/embed/drv/sec/rng/stm32/rng.c similarity index 100% rename from core/embed/trezorhal/stm32f4/rng.c rename to core/embed/drv/sec/rng/stm32/rng.c diff --git a/core/embed/trezorhal/unix/rng.c b/core/embed/drv/sec/rng/unix/rng.c similarity index 100% rename from core/embed/trezorhal/unix/rng.c rename to core/embed/drv/sec/rng/unix/rng.c diff --git a/core/embed/trezorhal/secret.h b/core/embed/drv/sec/secret.h similarity index 100% rename from core/embed/trezorhal/secret.h rename to core/embed/drv/sec/secret.h diff --git a/core/embed/trezorhal/stm32f4/secret.c b/core/embed/drv/sec/secret/stm32f4/secret.c similarity index 100% rename from core/embed/trezorhal/stm32f4/secret.c rename to core/embed/drv/sec/secret/stm32f4/secret.c diff --git a/core/embed/trezorhal/stm32u5/secret.c b/core/embed/drv/sec/secret/stm32u5/secret.c similarity index 100% rename from core/embed/trezorhal/stm32u5/secret.c rename to core/embed/drv/sec/secret/stm32u5/secret.c diff --git a/core/embed/trezorhal/secure_aes.h b/core/embed/drv/sec/secure_aes.h similarity index 100% rename from core/embed/trezorhal/secure_aes.h rename to core/embed/drv/sec/secure_aes.h diff --git a/core/embed/trezorhal/stm32u5/secure_aes.c b/core/embed/drv/sec/secure_aes/stm32u5/secure_aes.c similarity index 100% rename from core/embed/trezorhal/stm32u5/secure_aes.c rename to core/embed/drv/sec/secure_aes/stm32u5/secure_aes.c diff --git a/core/embed/trezorhal/time_estimate.h b/core/embed/drv/sec/time_estimate.h similarity index 100% rename from core/embed/trezorhal/time_estimate.h rename to core/embed/drv/sec/time_estimate.h diff --git a/core/embed/trezorhal/stm32f4/time_estimate.c b/core/embed/drv/sec/time_estimate/stm32/time_estimate.c similarity index 100% rename from core/embed/trezorhal/stm32f4/time_estimate.c rename to core/embed/drv/sec/time_estimate/stm32/time_estimate.c diff --git a/core/embed/trezorhal/unix/time_estimate.c b/core/embed/drv/sec/time_estimate/unix/time_estimate.c similarity index 100% rename from core/embed/trezorhal/unix/time_estimate.c rename to core/embed/drv/sec/time_estimate/unix/time_estimate.c diff --git a/core/embed/trezorhal/applet.h b/core/embed/drv/sys/applet.h similarity index 100% rename from core/embed/trezorhal/applet.h rename to core/embed/drv/sys/applet.h diff --git a/core/embed/trezorhal/bootargs.h b/core/embed/drv/sys/bootargs.h similarity index 100% rename from core/embed/trezorhal/bootargs.h rename to core/embed/drv/sys/bootargs.h diff --git a/core/embed/trezorhal/bootutils.h b/core/embed/drv/sys/bootutils.h similarity index 100% rename from core/embed/trezorhal/bootutils.h rename to core/embed/drv/sys/bootutils.h diff --git a/core/embed/trezorhal/stm32f4/irq.h b/core/embed/drv/sys/irq.h similarity index 100% rename from core/embed/trezorhal/stm32f4/irq.h rename to core/embed/drv/sys/irq.h diff --git a/core/embed/trezorhal/mpu.h b/core/embed/drv/sys/mpu.h similarity index 100% rename from core/embed/trezorhal/mpu.h rename to core/embed/drv/sys/mpu.h diff --git a/core/embed/trezorhal/stm32f4/mpu.c b/core/embed/drv/sys/mpu/stm32f4/mpu.c similarity index 100% rename from core/embed/trezorhal/stm32f4/mpu.c rename to core/embed/drv/sys/mpu/stm32f4/mpu.c diff --git a/core/embed/trezorhal/stm32u5/mpu.c b/core/embed/drv/sys/mpu/stm32u5/mpu.c similarity index 100% rename from core/embed/trezorhal/stm32u5/mpu.c rename to core/embed/drv/sys/mpu/stm32u5/mpu.c diff --git a/core/embed/trezorhal/unix/mpu.c b/core/embed/drv/sys/mpu/unix/mpu.c similarity index 100% rename from core/embed/trezorhal/unix/mpu.c rename to core/embed/drv/sys/mpu/unix/mpu.c diff --git a/core/embed/trezorhal/pvd.h b/core/embed/drv/sys/pvd.h similarity index 100% rename from core/embed/trezorhal/pvd.h rename to core/embed/drv/sys/pvd.h diff --git a/core/embed/trezorhal/stm32f4/pvd.c b/core/embed/drv/sys/pvd/stm32/pvd.c similarity index 100% rename from core/embed/trezorhal/stm32f4/pvd.c rename to core/embed/drv/sys/pvd/stm32/pvd.c diff --git a/core/embed/trezorhal/reset_flags.h b/core/embed/drv/sys/reset_flags.h similarity index 100% rename from core/embed/trezorhal/reset_flags.h rename to core/embed/drv/sys/reset_flags.h diff --git a/core/embed/trezorhal/stm32f4/sdram.h b/core/embed/drv/sys/sdram/sdram.h similarity index 100% rename from core/embed/trezorhal/stm32f4/sdram.h rename to core/embed/drv/sys/sdram/sdram.h diff --git a/core/embed/trezorhal/stm32f4/sdram.c b/core/embed/drv/sys/sdram/stm32f4/sdram.c similarity index 100% rename from core/embed/trezorhal/stm32f4/sdram.c rename to core/embed/drv/sys/sdram/stm32f4/sdram.c diff --git a/core/embed/segger/Config/Global.h b/core/embed/drv/sys/segger/stm32/Config/Global.h similarity index 100% rename from core/embed/segger/Config/Global.h rename to core/embed/drv/sys/segger/stm32/Config/Global.h diff --git a/core/embed/segger/Config/SEGGER_RTT_Conf.h b/core/embed/drv/sys/segger/stm32/Config/SEGGER_RTT_Conf.h similarity index 100% rename from core/embed/segger/Config/SEGGER_RTT_Conf.h rename to core/embed/drv/sys/segger/stm32/Config/SEGGER_RTT_Conf.h diff --git a/core/embed/segger/Config/SEGGER_SYSVIEW_Conf.h b/core/embed/drv/sys/segger/stm32/Config/SEGGER_SYSVIEW_Conf.h similarity index 100% rename from core/embed/segger/Config/SEGGER_SYSVIEW_Conf.h rename to core/embed/drv/sys/segger/stm32/Config/SEGGER_SYSVIEW_Conf.h diff --git a/core/embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c b/core/embed/drv/sys/segger/stm32/Config/SEGGER_SYSVIEW_Config_NoOS.c similarity index 100% rename from core/embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c rename to core/embed/drv/sys/segger/stm32/Config/SEGGER_SYSVIEW_Config_NoOS.c diff --git a/core/embed/segger/SEGGER/SEGGER.h b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER.h rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER.h diff --git a/core/embed/segger/SEGGER/SEGGER_RTT.c b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT.c rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT.c diff --git a/core/embed/segger/SEGGER/SEGGER_RTT.h b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT.h rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT.h diff --git a/core/embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT_ASM_ARMv7M.S similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT_ASM_ARMv7M.S diff --git a/core/embed/segger/SEGGER/SEGGER_RTT_printf.c b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT_printf.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_RTT_printf.c rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_RTT_printf.c diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW.c b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW.c similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW.c rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW.c diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW.h b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW.h rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW.h diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h diff --git a/core/embed/segger/SEGGER/SEGGER_SYSVIEW_Int.h b/core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW_Int.h similarity index 100% rename from core/embed/segger/SEGGER/SEGGER_SYSVIEW_Int.h rename to core/embed/drv/sys/segger/stm32/SEGGER/SEGGER_SYSVIEW_Int.h diff --git a/core/embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c b/core/embed/drv/sys/segger/stm32/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c similarity index 100% rename from core/embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c rename to core/embed/drv/sys/segger/stm32/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c diff --git a/core/embed/trezorhal/stm32f4/bootutils.c b/core/embed/drv/sys/startup/stm32/bootutils.c similarity index 100% rename from core/embed/trezorhal/stm32f4/bootutils.c rename to core/embed/drv/sys/startup/stm32/bootutils.c diff --git a/core/embed/trezorhal/stm32f4/limited_util.S b/core/embed/drv/sys/startup/stm32f4/limited_util.S similarity index 100% rename from core/embed/trezorhal/stm32f4/limited_util.S rename to core/embed/drv/sys/startup/stm32f4/limited_util.S diff --git a/core/embed/trezorhal/stm32f4/reset_flags.c b/core/embed/drv/sys/startup/stm32f4/reset_flags.c similarity index 100% rename from core/embed/trezorhal/stm32f4/reset_flags.c rename to core/embed/drv/sys/startup/stm32f4/reset_flags.c diff --git a/core/embed/trezorhal/stm32f4/startup_init.c b/core/embed/drv/sys/startup/stm32f4/startup_init.c similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_init.c rename to core/embed/drv/sys/startup/stm32f4/startup_init.c diff --git a/core/embed/trezorhal/stm32f4/startup_init.h b/core/embed/drv/sys/startup/stm32f4/startup_init.h similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_init.h rename to core/embed/drv/sys/startup/stm32f4/startup_init.h diff --git a/core/embed/trezorhal/stm32f4/startup_stage_0.s b/core/embed/drv/sys/startup/stm32f4/startup_stage_0.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_0.s rename to core/embed/drv/sys/startup/stm32f4/startup_stage_0.s diff --git a/core/embed/trezorhal/stm32f4/startup_stage_1.s b/core/embed/drv/sys/startup/stm32f4/startup_stage_1.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_1.s rename to core/embed/drv/sys/startup/stm32f4/startup_stage_1.s diff --git a/core/embed/trezorhal/stm32f4/startup_stage_2.s b/core/embed/drv/sys/startup/stm32f4/startup_stage_2.s similarity index 100% rename from core/embed/trezorhal/stm32f4/startup_stage_2.s rename to core/embed/drv/sys/startup/stm32f4/startup_stage_2.s diff --git a/core/embed/trezorhal/stm32f4/util.S b/core/embed/drv/sys/startup/stm32f4/util.S similarity index 100% rename from core/embed/trezorhal/stm32f4/util.S rename to core/embed/drv/sys/startup/stm32f4/util.S diff --git a/core/embed/trezorhal/stm32f4/vectortable.S b/core/embed/drv/sys/startup/stm32f4/vectortable.S similarity index 100% rename from core/embed/trezorhal/stm32f4/vectortable.S rename to core/embed/drv/sys/startup/stm32f4/vectortable.S diff --git a/core/embed/trezorhal/stm32u5/limited_util.S b/core/embed/drv/sys/startup/stm32u5/limited_util.S similarity index 100% rename from core/embed/trezorhal/stm32u5/limited_util.S rename to core/embed/drv/sys/startup/stm32u5/limited_util.S diff --git a/core/embed/trezorhal/stm32u5/reset_flags.c b/core/embed/drv/sys/startup/stm32u5/reset_flags.c similarity index 100% rename from core/embed/trezorhal/stm32u5/reset_flags.c rename to core/embed/drv/sys/startup/stm32u5/reset_flags.c diff --git a/core/embed/trezorhal/stm32u5/startup_init.c b/core/embed/drv/sys/startup/stm32u5/startup_init.c similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_init.c rename to core/embed/drv/sys/startup/stm32u5/startup_init.c diff --git a/core/embed/trezorhal/stm32u5/startup_stage_0.s b/core/embed/drv/sys/startup/stm32u5/startup_stage_0.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_0.s rename to core/embed/drv/sys/startup/stm32u5/startup_stage_0.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_1.s b/core/embed/drv/sys/startup/stm32u5/startup_stage_1.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_1.s rename to core/embed/drv/sys/startup/stm32u5/startup_stage_1.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_2.s b/core/embed/drv/sys/startup/stm32u5/startup_stage_2.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_2.s rename to core/embed/drv/sys/startup/stm32u5/startup_stage_2.s diff --git a/core/embed/trezorhal/stm32u5/startup_stage_4.s b/core/embed/drv/sys/startup/stm32u5/startup_stage_4.s similarity index 100% rename from core/embed/trezorhal/stm32u5/startup_stage_4.s rename to core/embed/drv/sys/startup/stm32u5/startup_stage_4.s diff --git a/core/embed/trezorhal/stm32u5/util.S b/core/embed/drv/sys/startup/stm32u5/util.S similarity index 100% rename from core/embed/trezorhal/stm32u5/util.S rename to core/embed/drv/sys/startup/stm32u5/util.S diff --git a/core/embed/trezorhal/stm32u5/vectortable.S b/core/embed/drv/sys/startup/stm32u5/vectortable.S similarity index 100% rename from core/embed/trezorhal/stm32u5/vectortable.S rename to core/embed/drv/sys/startup/stm32u5/vectortable.S diff --git a/core/embed/trezorhal/unix/bootutils.c b/core/embed/drv/sys/startup/unix/bootutils.c similarity index 100% rename from core/embed/trezorhal/unix/bootutils.c rename to core/embed/drv/sys/startup/unix/bootutils.c diff --git a/core/embed/trezorhal/stm32f4/syscall.c b/core/embed/drv/sys/syscall/stm32/syscall.c similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall.c rename to core/embed/drv/sys/syscall/stm32/syscall.c diff --git a/core/embed/trezorhal/stm32f4/syscall.h b/core/embed/drv/sys/syscall/stm32/syscall.h similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall.h rename to core/embed/drv/sys/syscall/stm32/syscall.h diff --git a/core/embed/trezorhal/stm32f4/syscall_dispatch.c b/core/embed/drv/sys/syscall/stm32/syscall_dispatch.c similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_dispatch.c rename to core/embed/drv/sys/syscall/stm32/syscall_dispatch.c diff --git a/core/embed/trezorhal/stm32f4/syscall_probe.c b/core/embed/drv/sys/syscall/stm32/syscall_probe.c similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_probe.c rename to core/embed/drv/sys/syscall/stm32/syscall_probe.c diff --git a/core/embed/trezorhal/stm32f4/syscall_probe.h b/core/embed/drv/sys/syscall/stm32/syscall_probe.h similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_probe.h rename to core/embed/drv/sys/syscall/stm32/syscall_probe.h diff --git a/core/embed/trezorhal/stm32f4/syscall_stubs.c b/core/embed/drv/sys/syscall/stm32/syscall_stubs.c similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_stubs.c rename to core/embed/drv/sys/syscall/stm32/syscall_stubs.c diff --git a/core/embed/trezorhal/stm32f4/syscall_verifiers.c b/core/embed/drv/sys/syscall/stm32/syscall_verifiers.c similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_verifiers.c rename to core/embed/drv/sys/syscall/stm32/syscall_verifiers.c diff --git a/core/embed/trezorhal/stm32f4/syscall_numbers.h b/core/embed/drv/sys/syscall/syscall_numbers.h similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_numbers.h rename to core/embed/drv/sys/syscall/syscall_numbers.h diff --git a/core/embed/trezorhal/stm32f4/syscall_verifiers.h b/core/embed/drv/sys/syscall/syscall_verifiers.h similarity index 100% rename from core/embed/trezorhal/stm32f4/syscall_verifiers.h rename to core/embed/drv/sys/syscall/syscall_verifiers.h diff --git a/core/embed/trezorhal/systask.h b/core/embed/drv/sys/systask.h similarity index 100% rename from core/embed/trezorhal/systask.h rename to core/embed/drv/sys/systask.h diff --git a/core/embed/trezorhal/system.h b/core/embed/drv/sys/system.h similarity index 100% rename from core/embed/trezorhal/system.h rename to core/embed/drv/sys/system.h diff --git a/core/embed/trezorhal/systick.h b/core/embed/drv/sys/systick.h similarity index 100% rename from core/embed/trezorhal/systick.h rename to core/embed/drv/sys/systick.h diff --git a/core/embed/trezorhal/systimer.h b/core/embed/drv/sys/systimer.h similarity index 100% rename from core/embed/trezorhal/systimer.h rename to core/embed/drv/sys/systimer.h diff --git a/core/embed/trezorhal/tamper.h b/core/embed/drv/sys/tamper.h similarity index 100% rename from core/embed/trezorhal/tamper.h rename to core/embed/drv/sys/tamper.h diff --git a/core/embed/trezorhal/stm32u5/tamper.c b/core/embed/drv/sys/tamper/stm32u5/tamper.c similarity index 100% rename from core/embed/trezorhal/stm32u5/tamper.c rename to core/embed/drv/sys/tamper/stm32u5/tamper.c diff --git a/core/embed/trezorhal/stm32f4/applet.c b/core/embed/drv/sys/task/stm32/applet.c similarity index 100% rename from core/embed/trezorhal/stm32f4/applet.c rename to core/embed/drv/sys/task/stm32/applet.c diff --git a/core/embed/trezorhal/stm32f4/systask.c b/core/embed/drv/sys/task/stm32/systask.c similarity index 100% rename from core/embed/trezorhal/stm32f4/systask.c rename to core/embed/drv/sys/task/stm32/systask.c diff --git a/core/embed/trezorhal/stm32f4/system.c b/core/embed/drv/sys/task/stm32/system.c similarity index 100% rename from core/embed/trezorhal/stm32f4/system.c rename to core/embed/drv/sys/task/stm32/system.c diff --git a/core/embed/trezorhal/unix/system.c b/core/embed/drv/sys/task/unix/system.c similarity index 100% rename from core/embed/trezorhal/unix/system.c rename to core/embed/drv/sys/task/unix/system.c diff --git a/core/embed/trezorhal/stm32f4/systick.c b/core/embed/drv/sys/time/stm32/systick.c similarity index 100% rename from core/embed/trezorhal/stm32f4/systick.c rename to core/embed/drv/sys/time/stm32/systick.c diff --git a/core/embed/trezorhal/stm32f4/systick_internal.h b/core/embed/drv/sys/time/stm32/systick_internal.h similarity index 100% rename from core/embed/trezorhal/stm32f4/systick_internal.h rename to core/embed/drv/sys/time/stm32/systick_internal.h diff --git a/core/embed/trezorhal/stm32f4/systimer.c b/core/embed/drv/sys/time/stm32/systimer.c similarity index 100% rename from core/embed/trezorhal/stm32f4/systimer.c rename to core/embed/drv/sys/time/stm32/systimer.c diff --git a/core/embed/trezorhal/unix/systick.c b/core/embed/drv/sys/time/unix/systick.c similarity index 100% rename from core/embed/trezorhal/unix/systick.c rename to core/embed/drv/sys/time/unix/systick.c diff --git a/core/embed/trezorhal/unix/systimer.c b/core/embed/drv/sys/time/unix/systimer.c similarity index 100% rename from core/embed/trezorhal/unix/systimer.c rename to core/embed/drv/sys/time/unix/systimer.c diff --git a/core/embed/trezorhal/trustzone.h b/core/embed/drv/sys/trustzone.h similarity index 100% rename from core/embed/trezorhal/trustzone.h rename to core/embed/drv/sys/trustzone.h diff --git a/core/embed/trezorhal/stm32u5/trustzone.c b/core/embed/drv/sys/trustzone/stm32u5/trustzone.c similarity index 100% rename from core/embed/trezorhal/stm32u5/trustzone.c rename to core/embed/drv/sys/trustzone/stm32u5/trustzone.c diff --git a/core/embed/lib/bl_check.h b/core/embed/drv/utl/bl_check.h similarity index 100% rename from core/embed/lib/bl_check.h rename to core/embed/drv/utl/bl_check.h diff --git a/core/embed/lib/bl_check.c b/core/embed/drv/utl/bl_checks/bl_check.c similarity index 100% rename from core/embed/lib/bl_check.c rename to core/embed/drv/utl/bl_checks/bl_check.c diff --git a/core/embed/trezorhal/board_capabilities.h b/core/embed/drv/utl/board_capabilities.h similarity index 100% rename from core/embed/trezorhal/board_capabilities.h rename to core/embed/drv/utl/board_capabilities.h diff --git a/core/embed/trezorhal/stm32f4/board_capabilities.c b/core/embed/drv/utl/board_capabilities/stm32/board_capabilities.c similarity index 100% rename from core/embed/trezorhal/stm32f4/board_capabilities.c rename to core/embed/drv/utl/board_capabilities/stm32/board_capabilities.c diff --git a/core/embed/trezorhal/flash.h b/core/embed/drv/utl/flash.h similarity index 100% rename from core/embed/trezorhal/flash.h rename to core/embed/drv/utl/flash.h diff --git a/core/embed/lib/flash_utils.c b/core/embed/drv/utl/flash/flash_utils.c similarity index 100% rename from core/embed/lib/flash_utils.c rename to core/embed/drv/utl/flash/flash_utils.c diff --git a/core/embed/trezorhal/stm32f4/layout_helpers.h b/core/embed/drv/utl/flash/layout_helpers.h similarity index 100% rename from core/embed/trezorhal/stm32f4/layout_helpers.h rename to core/embed/drv/utl/flash/layout_helpers.h diff --git a/core/embed/trezorhal/stm32f4/flash.c b/core/embed/drv/utl/flash/stm32f4/flash.c similarity index 100% rename from core/embed/trezorhal/stm32f4/flash.c rename to core/embed/drv/utl/flash/stm32f4/flash.c diff --git a/core/embed/trezorhal/stm32f4/layout.c b/core/embed/drv/utl/flash/stm32f4/layout.c similarity index 100% rename from core/embed/trezorhal/stm32f4/layout.c rename to core/embed/drv/utl/flash/stm32f4/layout.c diff --git a/core/embed/trezorhal/stm32u5/flash.c b/core/embed/drv/utl/flash/stm32u5/flash.c similarity index 100% rename from core/embed/trezorhal/stm32u5/flash.c rename to core/embed/drv/utl/flash/stm32u5/flash.c diff --git a/core/embed/trezorhal/stm32u5/layout.c b/core/embed/drv/utl/flash/stm32u5/layout.c similarity index 100% rename from core/embed/trezorhal/stm32u5/layout.c rename to core/embed/drv/utl/flash/stm32u5/layout.c diff --git a/core/embed/trezorhal/unix/flash.c b/core/embed/drv/utl/flash/unix/flash.c similarity index 100% rename from core/embed/trezorhal/unix/flash.c rename to core/embed/drv/utl/flash/unix/flash.c diff --git a/core/embed/trezorhal/flash_otp.h b/core/embed/drv/utl/flash_otp.h similarity index 100% rename from core/embed/trezorhal/flash_otp.h rename to core/embed/drv/utl/flash_otp.h diff --git a/core/embed/lib/flash_utils.h b/core/embed/drv/utl/flash_utils.h similarity index 100% rename from core/embed/lib/flash_utils.h rename to core/embed/drv/utl/flash_utils.h diff --git a/core/embed/trezorhal/fwutils.h b/core/embed/drv/utl/fwutils.h similarity index 100% rename from core/embed/trezorhal/fwutils.h rename to core/embed/drv/utl/fwutils.h diff --git a/core/embed/trezorhal/stm32f4/fwutils.c b/core/embed/drv/utl/fwutils/fwutils.c similarity index 100% rename from core/embed/trezorhal/stm32f4/fwutils.c rename to core/embed/drv/utl/fwutils/fwutils.c diff --git a/core/embed/lib/image.h b/core/embed/drv/utl/image.h similarity index 100% rename from core/embed/lib/image.h rename to core/embed/drv/utl/image.h diff --git a/core/embed/lib/image.c b/core/embed/drv/utl/image/image.c similarity index 100% rename from core/embed/lib/image.c rename to core/embed/drv/utl/image/image.c diff --git a/core/embed/lib/image_hash_conf.h b/core/embed/drv/utl/image/image_hash_conf.h similarity index 100% rename from core/embed/lib/image_hash_conf.h rename to core/embed/drv/utl/image/image_hash_conf.h diff --git a/core/embed/trezorhal/layout.h b/core/embed/drv/utl/layout.h similarity index 100% rename from core/embed/trezorhal/layout.h rename to core/embed/drv/utl/layout.h diff --git a/core/embed/trezorhal/option_bytes.h b/core/embed/drv/utl/option_bytes.h similarity index 100% rename from core/embed/trezorhal/option_bytes.h rename to core/embed/drv/utl/option_bytes.h diff --git a/core/embed/trezorhal/stm32f4/option_bytes.c b/core/embed/drv/utl/option_bytes/stm32f4/option_bytes.c similarity index 100% rename from core/embed/trezorhal/stm32f4/option_bytes.c rename to core/embed/drv/utl/option_bytes/stm32f4/option_bytes.c diff --git a/core/embed/trezorhal/stm32u5/option_bytes.c b/core/embed/drv/utl/option_bytes/stm32u5/option_bytes.c similarity index 100% rename from core/embed/trezorhal/stm32u5/option_bytes.c rename to core/embed/drv/utl/option_bytes/stm32u5/option_bytes.c diff --git a/core/embed/trezorhal/stm32f4/flash_otp.c b/core/embed/drv/utl/otp/stm32f4/flash_otp.c similarity index 100% rename from core/embed/trezorhal/stm32f4/flash_otp.c rename to core/embed/drv/utl/otp/stm32f4/flash_otp.c diff --git a/core/embed/trezorhal/stm32u5/flash_otp.c b/core/embed/drv/utl/otp/stm32u5/flash_otp.c similarity index 100% rename from core/embed/trezorhal/stm32u5/flash_otp.c rename to core/embed/drv/utl/otp/stm32u5/flash_otp.c diff --git a/core/embed/trezorhal/unix/flash_otp.c b/core/embed/drv/utl/otp/unix/flash_otp.c similarity index 100% rename from core/embed/trezorhal/unix/flash_otp.c rename to core/embed/drv/utl/otp/unix/flash_otp.c diff --git a/core/embed/lib/translations.h b/core/embed/drv/utl/translations.h similarity index 100% rename from core/embed/lib/translations.h rename to core/embed/drv/utl/translations.h diff --git a/core/embed/lib/translations.c b/core/embed/drv/utl/translations/translations.c similarity index 100% rename from core/embed/lib/translations.c rename to core/embed/drv/utl/translations/translations.c diff --git a/core/embed/trezorhal/stm32f4/unit_properties.c b/core/embed/drv/utl/unit_properties/stm32/unit_properties.c similarity index 100% rename from core/embed/trezorhal/stm32f4/unit_properties.c rename to core/embed/drv/utl/unit_properties/stm32/unit_properties.c diff --git a/core/embed/trezorhal/unix/unit_properties.c b/core/embed/drv/utl/unit_properties/unix/unit_properties.c similarity index 100% rename from core/embed/trezorhal/unix/unit_properties.c rename to core/embed/drv/utl/unit_properties/unix/unit_properties.c diff --git a/core/embed/lib/buffers.c b/core/embed/lib/buffers.c deleted file mode 100644 index eddaef5607..0000000000 --- a/core/embed/lib/buffers.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 . - */ - -#include - -#include "buffers.h" -#include "fonts/fonts.h" -#include "memzero.h" - -const int32_t text_buffer_height = FONT_MAX_HEIGHT; -const int32_t buffer_width = DISPLAY_RESX; - -#define CONCAT_(a, b) a##b -#define CONCAT(a, b) CONCAT_(a, b) - -#define CONCAT3_(a, b, c) a##b##c -#define CONCAT3(a, b, c) CONCAT3_(a, b, c) - -#define STRUCT(name) CONCAT3(buffers_, name, _t) -#define TYPE(name) CONCAT3(buffer_, name, _t) -#define FUNCTION(name) CONCAT(buffers_get_, name) -#define FUNCTION_FREE(name) CONCAT(buffers_free_, name) -#define VARNAME(name) CONCAT(buffers_, name) - -#define BUFFER(section, name, count) \ - typedef struct { \ - TYPE(name) buffers[count]; \ - uint8_t allocated[count]; \ - } STRUCT(name); \ - section STRUCT(name) VARNAME(name); \ - \ - TYPE(name) * FUNCTION(name)(bool clear) { \ - int idx = -1; \ - for (int i = 0; i < (count); i++) { \ - if (VARNAME(name).allocated[i] == 0) { \ - idx = i; \ - break; \ - } \ - } \ - if (idx < 0) { \ - return NULL; \ - } \ - if (clear) { \ - memzero(&VARNAME(name).buffers[idx], \ - sizeof(VARNAME(name).buffers[idx])); \ - } \ - VARNAME(name).allocated[idx] = 1; \ - return &VARNAME(name).buffers[idx]; \ - } \ - void FUNCTION_FREE(name)(TYPE(name) * buffer) { \ - if (buffer == NULL) { \ - return; \ - } \ - for (uint16_t i = 0; i < (count); i++) { \ - if (buffer == &VARNAME(name).buffers[i]) { \ - VARNAME(name).allocated[i] = 0; \ - return; \ - } \ - } \ - } - -BUFFER(BUFFER_SECTION, line_16bpp, 3); -BUFFER(BUFFER_SECTION, line_4bpp, 3); -BUFFER(BUFFER_SECTION, text, 1); -BUFFER(NODMA_BUFFER_SECTION, jpeg, 1); -BUFFER(NODMA_BUFFER_SECTION, jpeg_work, 1); -BUFFER(NODMA_BUFFER_SECTION, blurring, 1); -BUFFER(NODMA_BUFFER_SECTION, blurring_totals, 1); diff --git a/core/embed/lib/buffers.h b/core/embed/lib/buffers.h deleted file mode 100644 index 6eac01580d..0000000000 --- a/core/embed/lib/buffers.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 . - */ - -#ifndef _BUFFERS_H -#define _BUFFERS_H - -#include -#include - -#define BUFFER_PIXELS DISPLAY_RESX - -#define TEXT_BUFFER_HEIGHT 36 - -#if TEXT_BUFFER_HEIGHT < FONT_MAX_HEIGHT -#error Text buffer height is too small, please adjust to match used fonts -#endif - -#define LINE_BUFFER_16BPP_SIZE (BUFFER_PIXELS * 2) -#define LINE_BUFFER_4BPP_SIZE (BUFFER_PIXELS / 2) -#define TEXT_BUFFER_SIZE ((BUFFER_PIXELS * TEXT_BUFFER_HEIGHT) / 2) -#define JPEG_BUFFER_SIZE (BUFFER_PIXELS * 16) - -// 3100 is needed according to tjpgd docs, -// 256 because we need non overlapping memory in rust -// 6 << 10 is for huffman decoding table -// 1000 bytes reserve, as we discovered that we are running out of memory -// sometimes -#define JPEG_WORK_SIZE (3100 + 256 + (6 << 10) + 1000) - -#if defined BOOTLOADER || defined BOARDLOADER -#define BUFFER_SECTION __attribute__((section(".buf"))) -#else -#define BUFFER_SECTION -#endif - -#if defined BOOTLOADER || defined TREZOR_EMULATOR -#define NODMA_BUFFER_SECTION -#else -#define NODMA_BUFFER_SECTION __attribute__((section(".no_dma_buffers"))) -#endif - -typedef __attribute__((aligned(4))) struct { - uint8_t buffer[LINE_BUFFER_16BPP_SIZE]; -} buffer_line_16bpp_t; - -typedef __attribute__((aligned(4))) struct { - uint8_t buffer[LINE_BUFFER_4BPP_SIZE]; -} buffer_line_4bpp_t; - -typedef __attribute__((aligned(4))) struct { - uint8_t buffer[TEXT_BUFFER_SIZE]; -} buffer_text_t; - -typedef __attribute__((aligned(4))) struct { - uint16_t buffer[JPEG_BUFFER_SIZE]; -} buffer_jpeg_t; - -typedef __attribute__((aligned(4))) struct { - uint8_t buffer[JPEG_WORK_SIZE]; -} buffer_jpeg_work_t; - -typedef __attribute__((aligned(4))) struct { - uint16_t buffer[10][3][BUFFER_PIXELS]; -} buffer_blurring_t; - -typedef __attribute__((aligned(4))) struct { - uint16_t buffer[3][BUFFER_PIXELS]; -} buffer_blurring_totals_t; - -extern const int32_t text_buffer_height; -extern const int32_t buffer_width; - -buffer_line_16bpp_t* buffers_get_line_16bpp(bool clear); -void buffers_free_line_16bpp(buffer_line_16bpp_t* buffer); - -buffer_line_4bpp_t* buffers_get_line_4bpp(bool clear); -void buffers_free_line_4bpp(buffer_line_4bpp_t* buffer); - -buffer_text_t* buffers_get_text(bool clear); -void buffers_free_text(buffer_text_t* buffer); - -buffer_jpeg_t* buffers_get_jpeg(bool clear); -void buffers_free_jpeg(buffer_jpeg_t* buffer); - -buffer_jpeg_work_t* buffers_get_jpeg_work(bool clear); -void buffers_free_jpeg_work(buffer_jpeg_work_t* buffer); - -buffer_blurring_t* buffers_get_blurring(bool clear); -void buffers_free_blurring(buffer_blurring_t* buffer); - -buffer_blurring_totals_t* buffers_get_blurring_totals(bool clear); -void buffers_free_blurring_totals(buffer_blurring_totals_t* buffer); - -#endif // _BUFFERS_H diff --git a/core/embed/lib/colors.c b/core/embed/lib/colors.c deleted file mode 100644 index f12eff8540..0000000000 --- a/core/embed/lib/colors.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 . - */ - -#include "colors.h" - -uint32_t rgb565_to_rgb888(uint16_t color) { - uint32_t res = 0; - res |= ((((((uint32_t)color & 0xF800) >> 11) * 527) + 23) >> 6) << 16; - res |= ((((((uint32_t)color & 0x07E0) >> 5) * 259) + 33) >> 6) << 8; - res |= ((((((uint32_t)color & 0x001F) >> 0) * 527) + 23) >> 6) << 0; - res |= 0xFF000000; - return res; -} - -uint32_t interpolate_rgb888_color(uint32_t color0, uint32_t color1, - uint8_t step) { - uint32_t cr, cg, cb; - cr = (((color0 & 0xFF0000) >> 16) * step + - ((color1 & 0xFF0000) >> 16) * (15 - step)) / - 15; - cg = (((color0 & 0xFF00) >> 8) * step + - ((color1 & 0xFF00) >> 8) * (15 - step)) / - 15; - cb = ((color0 & 0x00FF) * step + (color1 & 0x00FF) * (15 - step)) / 15; - return (cr << 16) | (cg << 8) | cb | 0xFF000000; -} diff --git a/core/embed/lib/colors.h b/core/embed/lib/colors.h deleted file mode 100644 index 7a92ca1761..0000000000 --- a/core/embed/lib/colors.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 . - */ - -#ifndef _COLORS_H -#define _COLORS_H - -#include - -#ifdef USE_RGB_COLORS -#define RGB16(R, G, B) ((R & 0xF8) << 8) | ((G & 0xFC) << 3) | ((B & 0xF8) >> 3) -#endif - -#define COLOR_WHITE 0xFFFF -#define COLOR_BLACK 0x0000 - -static inline uint16_t interpolate_color(uint16_t color0, uint16_t color1, - uint8_t step) { - uint8_t cr = 0, cg = 0, cb = 0; - cr = (((color0 & 0xF800) >> 11) * step + - ((color1 & 0xF800) >> 11) * (15 - step)) / - 15; - cg = (((color0 & 0x07E0) >> 5) * step + - ((color1 & 0x07E0) >> 5) * (15 - step)) / - 15; - cb = ((color0 & 0x001F) * step + (color1 & 0x001F) * (15 - step)) / 15; - return (cr << 11) | (cg << 5) | cb; -} - -static inline void set_color_table(uint16_t colortable[16], uint16_t fgcolor, - uint16_t bgcolor) { - for (int i = 0; i < 16; i++) { - colortable[i] = interpolate_color(fgcolor, bgcolor, i); - } -} - -uint32_t rgb565_to_rgb888(uint16_t color); - -uint32_t interpolate_rgb888_color(uint32_t color0, uint32_t color1, - uint8_t step); - -#endif //_COLORS_H diff --git a/core/embed/lib/display_draw.c b/core/embed/lib/display_draw.c deleted file mode 100644 index a90f3be3e5..0000000000 --- a/core/embed/lib/display_draw.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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 . - */ - -#define _GNU_SOURCE - -#include - -#include - -#include "buffers.h" -#include "display.h" -#include "display_draw.h" -#include "fonts/fonts.h" -#include "memzero.h" - -#ifdef USE_DMA2D -#include "dma2d.h" -#endif - -static struct { - int x, y; -} DISPLAY_OFFSET; - -// common display functions - -#define CLAMP(x, min, max) (MIN(MAX((x), (min)), (max))) - -static inline void clamp_coords(int x, int y, int w, int h, int *x0, int *y0, - int *x1, int *y1) { - *x0 = CLAMP(x, 0, DISPLAY_RESX); - *y0 = CLAMP(y, 0, DISPLAY_RESY); - *x1 = CLAMP(x + w - 1, -1, DISPLAY_RESX - 1); - *y1 = CLAMP(y + h - 1, -1, DISPLAY_RESY - 1); -} - -void display_clear(void) { -#ifdef DISPLAY_EFFICIENT_CLEAR - display_efficient_clear(); -#else - const int saved_orientation = display_get_orientation(); - - display_reset_state(); - - // set MADCTL first so that we can set the window correctly next - display_orientation(0); - // address the complete frame memory - display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - for (uint32_t i = 0; i < DISPLAY_RESX * DISPLAY_RESY; i++) { - // 2 bytes per pixel because we're using RGB 5-6-5 format - PIXELDATA(0x0000); - } - // go back to restricted window - display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - // if valid, go back to the saved orientation - display_orientation(saved_orientation); - // flag display for refresh -#endif - display_pixeldata_dirty(); -} - -void display_bar(int x, int y, int w, int h, uint16_t c) { - x += DISPLAY_OFFSET.x; - y += DISPLAY_OFFSET.y; - int x0 = 0, y0 = 0, x1 = 0, y1 = 0; - clamp_coords(x, y, w, h, &x0, &y0, &x1, &y1); - display_set_window(x0, y0, x1, y1); - for (int i = 0; i < (x1 - x0 + 1) * (y1 - y0 + 1); i++) { - PIXELDATA(c); - } - display_pixeldata_dirty(); -} - -void display_text_render_buffer(const char *text, int textlen, int font, - buffer_text_t *buffer, int text_offset) { - // determine text length if not provided - if (textlen < 0) { - textlen = strlen(text); - } - - int x = 0; - int max_height = font_max_height(font); - int baseline = font_baseline(font); - - // render glyphs - font_glyph_iter_t iter = font_glyph_iter_init(font, (uint8_t *)text, textlen); - const uint8_t *g = NULL; - while (font_next_glyph(&iter, &g)) { - const uint8_t w = g[0]; // width - const uint8_t h = g[1]; // height - const uint8_t adv = g[2]; // advance - const uint8_t bearX = g[3]; // bearingX - const uint8_t bearY = g[4]; // bearingY -#if TREZOR_FONT_BPP == 4 - uint8_t wa = w + (w & 1); -#else - uint8_t wa = w; -#endif - if (wa && h) { - for (int j = 0; j < h; j++) { - for (int i = 0; i < wa; i++) { - const int a = i + j * wa; -#if TREZOR_FONT_BPP == 1 - const uint8_t c = ((g[5 + a / 8] >> (7 - (a % 8) * 1)) & 0x01) * 15; -#elif TREZOR_FONT_BPP == 2 - const uint8_t c = ((g[5 + a / 4] >> (6 - (a % 4) * 2)) & 0x03) * 5; -#elif TREZOR_FONT_BPP == 4 - const uint8_t c = (g[5 + a / 2] >> ((a % 2) * 4)) & 0x0F; -#elif TREZOR_FONT_BPP == 8 -#error Rendering into buffer not supported when using TREZOR_FONT_BPP = 8 - // const uint8_t c = g[5 + a / 1] >> 4; -#else -#error Unsupported TREZOR_FONT_BPP value -#endif - - int x_pos = text_offset + i + x + bearX; - int y_pos = j + max_height - bearY - baseline; - - if (y_pos < 0) continue; - - if (x_pos >= BUFFER_PIXELS || x_pos < 0) { - continue; - } - - int buffer_pos = x_pos + y_pos * BUFFER_PIXELS; - - if (buffer_pos < (sizeof(buffer_text_t) * 2)) { - int b = buffer_pos / 2; - if (buffer_pos % 2) { - buffer->buffer[b] |= c << 4; - } else { - buffer->buffer[b] |= (c); - } - } - } - } - } - x += adv; - } -} - -#ifdef FRAMEBUFFER -static void display_text_render(int x, int y, const char *text, int textlen, - int font, uint16_t fgcolor, uint16_t bgcolor) { - // determine text length if not provided - if (textlen < 0) { - textlen = strlen(text); - } - - int total_adv = 0; - - uint32_t *fb = display_get_fb_addr(); - - uint16_t colortable[16] = {0}; - set_color_table(colortable, fgcolor, bgcolor); - - // render glyphs - font_glyph_iter_t iter = font_glyph_iter_init(font, (uint8_t *)text, textlen); - const uint8_t *g = NULL; - while (font_next_glyph(&iter, &g)) { - const uint8_t w = g[0]; // width - const uint8_t h = g[1]; // height - const uint8_t adv = g[2]; // advance - const uint8_t bearX = g[3]; // bearingX - const uint8_t bearY = g[4]; // bearingY - -#if TREZOR_FONT_BPP == 4 - uint8_t wa = w + (w & 1); -#else - uint8_t wa = w; -#endif - - if (w && h) { - for (int j = 0; j < h; j++) { - for (int i = 0; i < wa; i++) { - const int a = i + j * wa; -#if TREZOR_FONT_BPP == 1 - const uint8_t c = ((g[5 + a / 8] >> (7 - (a % 8) * 1)) & 0x01) * 15; -#elif TREZOR_FONT_BPP == 2 - const uint8_t c = ((g[5 + a / 4] >> (6 - (a % 4) * 2)) & 0x03) * 5; -#elif TREZOR_FONT_BPP == 4 - const uint8_t c = (g[5 + a / 2] >> ((a % 2) * 4)) & 0x0F; -#elif TREZOR_FONT_BPP == 8 -#error Rendering into buffer not supported when using TREZOR_FONT_BPP = 8 - // const uint8_t c = g[5 + a / 1] >> 4; -#else -#error Unsupported TREZOR_FONT_BPP value -#endif - - int x_pos = x + i + total_adv + bearX; - int y_pos = y + j - bearY; - - if (y_pos < 0) continue; - - if (x_pos >= DISPLAY_FRAMEBUFFER_WIDTH || x_pos < 0 || - y_pos >= DISPLAY_FRAMEBUFFER_HEIGHT || y_pos < 0) { - continue; - } - - display_pixel((uint8_t *)fb, x_pos, y_pos, colortable[c]); - } - } - } - total_adv += adv; - } - display_pixeldata_dirty(); -} - -#else -static void display_text_render(int x, int y, const char *text, int textlen, - int font, uint16_t fgcolor, uint16_t bgcolor) { - // determine text length if not provided - if (textlen < 0) { - textlen = strlen(text); - } - - uint16_t colortable[16] = {0}; - set_color_table(colortable, fgcolor, bgcolor); - - // render glyphs - font_glyph_iter_t iter = font_glyph_iter_init(font, (uint8_t *)text, textlen); - const uint8_t *g = NULL; - while (font_next_glyph(&iter, &g)) { - const uint8_t w = g[0]; // width - const uint8_t h = g[1]; // height - const uint8_t adv = g[2]; // advance - const uint8_t bearX = g[3]; // bearingX - const uint8_t bearY = g[4]; // bearingY - -#if TREZOR_FONT_BPP == 4 - uint8_t wa = w + (w & 1); -#else - uint8_t wa = w; -#endif - if (wa && h) { - const int sx = x + bearX; - const int sy = y - bearY; - int x0 = 0, y0 = 0, x1 = 0, y1 = 0; - clamp_coords(sx, sy, w, h, &x0, &y0, &x1, &y1); - display_set_window(x0, y0, x1, y1); - for (int j = y0; j <= y1; j++) { - for (int i = x0; i <= x1; i++) { - const int rx = i - sx; - const int ry = j - sy; - const int a = rx + ry * wa; -#if TREZOR_FONT_BPP == 1 - const uint8_t c = ((g[5 + a / 8] >> (7 - (a % 8) * 1)) & 0x01) * 15; -#elif TREZOR_FONT_BPP == 2 - const uint8_t c = ((g[5 + a / 4] >> (6 - (a % 4) * 2)) & 0x03) * 5; -#elif TREZOR_FONT_BPP == 4 - const uint8_t c = (g[5 + a / 2] >> ((a % 2) * 4)) & 0x0F; -#elif TREZOR_FONT_BPP == 8 - const uint8_t c = g[5 + a / 1] >> 4; -#else -#error Unsupported TREZOR_FONT_BPP value -#endif - PIXELDATA(colortable[c]); - } - } - } - x += adv; - } - display_pixeldata_dirty(); -} -#endif - -void display_text(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor) { - x += DISPLAY_OFFSET.x; - y += DISPLAY_OFFSET.y; - display_text_render(x, y, text, textlen, font, fgcolor, bgcolor); -} - -void display_text_center(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor) { - x += DISPLAY_OFFSET.x; - y += DISPLAY_OFFSET.y; - int w = font_text_width(font, text, textlen); - display_text_render(x - w / 2, y, text, textlen, font, fgcolor, bgcolor); -} - -void display_text_right(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor) { - x += DISPLAY_OFFSET.x; - y += DISPLAY_OFFSET.y; - int w = font_text_width(font, text, textlen); - display_text_render(x - w, y, text, textlen, font, fgcolor, bgcolor); -} - -#ifdef TREZOR_PRODTEST - -#include "qr-code-generator/qrcodegen.h" -#define QR_MAX_VERSION 9 - -void display_qrcode(int x, int y, const char *data, uint8_t scale) { - if (scale < 1 || scale > 10) return; - - uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0}; - uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0}; - - int side = 0; - if (qrcodegen_encodeText(data, tempdata, codedata, qrcodegen_Ecc_MEDIUM, - qrcodegen_VERSION_MIN, QR_MAX_VERSION, - qrcodegen_Mask_AUTO, true)) { - side = qrcodegen_getSize(codedata); - } - - x += DISPLAY_OFFSET.x - (side + 2) * scale / 2; - y += DISPLAY_OFFSET.y - (side + 2) * scale / 2; - int x0 = 0, y0 = 0, x1 = 0, y1 = 0; - clamp_coords(x, y, (side + 2) * scale, (side + 2) * scale, &x0, &y0, &x1, - &y1); - display_set_window(x0, y0, x1, y1); - for (int j = y0; j <= y1; j++) { - for (int i = x0; i <= x1; i++) { - int rx = (i - x) / scale - 1; - int ry = (j - y) / scale - 1; - // 1px border - if (rx < 0 || ry < 0 || rx >= side || ry >= side) { - PIXELDATA(0xFFFF); - continue; - } - if (qrcodegen_getModule(codedata, rx, ry)) { - PIXELDATA(0x0000); - } else { - PIXELDATA(0xFFFF); - } - } - } - display_pixeldata_dirty(); -} - -#endif - -void display_offset(int set_xy[2], int *get_x, int *get_y) { - if (set_xy) { - DISPLAY_OFFSET.x = set_xy[0]; - DISPLAY_OFFSET.y = set_xy[1]; - } - *get_x = DISPLAY_OFFSET.x; - *get_y = DISPLAY_OFFSET.y; -} diff --git a/core/embed/lib/display_draw.h b/core/embed/lib/display_draw.h deleted file mode 100644 index 0facb5db14..0000000000 --- a/core/embed/lib/display_draw.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 . - */ - -#ifndef __DISPLAY_DRAW_H__ -#define __DISPLAY_DRAW_H__ - -#include - -#include "buffers.h" -#include "colors.h" -#include "fonts/fonts.h" - -// provided by common - -void display_clear(void); - -void display_bar(int x, int y, int w, int h, uint16_t c); - -void display_text(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor); -void display_text_center(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor); -void display_text_right(int x, int y, const char *text, int textlen, int font, - uint16_t fgcolor, uint16_t bgcolor); -void display_text_render_buffer(const char *text, int textlen, int font, - buffer_text_t *buffer, int text_offset); - -void display_qrcode(int x, int y, const char *data, uint8_t scale); - -void display_offset(int set_xy[2], int *get_x, int *get_y); - -#endif diff --git a/core/embed/lib/dma2d_emul.c b/core/embed/lib/dma2d_emul.c deleted file mode 100644 index 99fb880be0..0000000000 --- a/core/embed/lib/dma2d_emul.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 . - */ - -#include "colors.h" -#include "display.h" - -typedef enum { - DMA2D_LAYER_FG = 1, - DMA2D_LAYER_BG = 0, -} dma2d_layer_t; - -typedef enum { - DMA2D_MODE_CONST = 0, - DMA2D_MODE_4BPP, - DMA2D_MODE_16BPP, - DMA2D_MODE_4BPP_OVER_4BPP, - DMA2D_MODE_4BPP_OVER_16BPP, -} dma2d_mode_t; - -static uint16_t clut_bg[16]; -static uint16_t clut_fg[16]; -static uint16_t dma2d_color; -static dma2d_mode_t mode = 0; - -void dma2d_init(void) { - // do nothing -} - -void dma2d_init_clut(uint16_t fg, uint16_t bg, dma2d_layer_t layer) { - uint16_t* table; - if (layer == DMA2D_LAYER_BG) { - table = clut_bg; - } else { - table = clut_fg; - } - - set_color_table(table, fg, bg); -} - -void dma2d_setup_const(void) { mode = DMA2D_MODE_CONST; } - -void dma2d_setup_4bpp(uint16_t fg_color, uint16_t bg_color) { - dma2d_init_clut(fg_color, bg_color, DMA2D_LAYER_FG); - mode = DMA2D_MODE_4BPP; -} - -void dma2d_setup_16bpp(void) { mode = DMA2D_MODE_16BPP; } - -void dma2d_setup_4bpp_over_16bpp(uint16_t overlay_color) { - mode = DMA2D_MODE_4BPP_OVER_16BPP; - dma2d_color = overlay_color; -} - -void dma2d_setup_4bpp_over_4bpp(uint16_t fg_color, uint16_t bg_color, - uint16_t overlay_color) { - mode = DMA2D_MODE_4BPP_OVER_4BPP; - - dma2d_color = overlay_color; - dma2d_init_clut(fg_color, bg_color, DMA2D_LAYER_BG); -} - -void dma2d_start(uint8_t* in_addr, uint8_t* out_addr, int32_t pixels) { - (void)out_addr; - for (int i = 0; i < pixels; i++) { - if (mode == DMA2D_MODE_4BPP) { - uint8_t c = ((uint8_t*)in_addr)[i / 2]; - uint8_t even_pix = c >> 4; - uint8_t odd_pix = c & 0xF; - PIXELDATA(clut_fg[odd_pix]); - PIXELDATA(clut_fg[even_pix]); - i++; // wrote two pixels - } - if (mode == DMA2D_MODE_16BPP) { - uint16_t c = ((uint16_t*)in_addr)[i]; - PIXELDATA(c); - } - } -} - -void dma2d_start_const(uint16_t color, uint8_t* out_addr, int32_t pixels) { - (void)out_addr; - for (int i = 0; i < pixels; i++) { - PIXELDATA(color); - } -} - -void dma2d_start_blend(uint8_t* overlay_addr, uint8_t* bg_addr, - uint8_t* out_addr, int32_t pixels) { - (void)out_addr; - for (int i = 0; i < pixels; i++) { - if (mode == DMA2D_MODE_4BPP_OVER_4BPP) { - uint8_t c = overlay_addr[i / 2]; - uint8_t b = bg_addr[i / 2]; - - uint8_t odd_overlay_pix = c & 0xF; - uint8_t odd_bg_pix = b & 0xF; - uint16_t c_odd_bg = clut_bg[odd_bg_pix]; - uint16_t final_odd_color = - interpolate_color(dma2d_color, c_odd_bg, odd_overlay_pix); - PIXELDATA(final_odd_color); - - uint8_t even_overlay_pix = c >> 4; - uint8_t even_bg_pix = b >> 4; - uint16_t c_even_bg = clut_bg[even_bg_pix]; - uint16_t final_even_color = - interpolate_color(dma2d_color, c_even_bg, even_overlay_pix); - PIXELDATA(final_even_color); - - i++; // wrote two pixels - } - if (mode == DMA2D_MODE_4BPP_OVER_16BPP) { - uint16_t c = ((uint16_t*)bg_addr)[i]; - uint8_t o = overlay_addr[i / 2]; - uint8_t o_pix; - if (i % 2 == 0) { - o_pix = o & 0xF; - } else { - o_pix = o >> 4; - } - uint16_t final_odd_color = interpolate_color(dma2d_color, c, o_pix); - PIXELDATA(final_odd_color); - } - } -} - -void dma2d_wait_for_transfer(void) { - // done in place when emulating, so no need for wait here -} diff --git a/core/embed/trezorhal/stm32f4/stm32f4xx_hal_conf.h b/core/embed/models/trezor_bsp/stm32f4/stm32f4xx_hal_conf.h similarity index 100% rename from core/embed/trezorhal/stm32f4/stm32f4xx_hal_conf.h rename to core/embed/models/trezor_bsp/stm32f4/stm32f4xx_hal_conf.h diff --git a/core/embed/trezorhal/stm32u5/stm32u5xx_hal_conf.h b/core/embed/models/trezor_bsp/stm32u5/stm32u5xx_hal_conf.h similarity index 100% rename from core/embed/trezorhal/stm32u5/stm32u5xx_hal_conf.h rename to core/embed/models/trezor_bsp/stm32u5/stm32u5xx_hal_conf.h diff --git a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c b/core/embed/mpymod/modtrezorconfig/modtrezorconfig.c similarity index 100% rename from core/embed/extmod/modtrezorconfig/modtrezorconfig.c rename to core/embed/mpymod/modtrezorconfig/modtrezorconfig.c diff --git a/core/embed/extmod/modtrezorconfig/norcow_config.h b/core/embed/mpymod/modtrezorconfig/norcow_config.h similarity index 100% rename from core/embed/extmod/modtrezorconfig/norcow_config.h rename to core/embed/mpymod/modtrezorconfig/norcow_config.h diff --git a/core/embed/extmod/modtrezorcrypto/crc.c b/core/embed/mpymod/modtrezorcrypto/crc.c similarity index 100% rename from core/embed/extmod/modtrezorcrypto/crc.c rename to core/embed/mpymod/modtrezorcrypto/crc.c diff --git a/core/embed/extmod/modtrezorcrypto/crc.h b/core/embed/mpymod/modtrezorcrypto/crc.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/crc.h rename to core/embed/mpymod/modtrezorcrypto/crc.h diff --git a/core/embed/extmod/modtrezorcrypto/hdnode.h b/core/embed/mpymod/modtrezorcrypto/hdnode.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/hdnode.h rename to core/embed/mpymod/modtrezorcrypto/hdnode.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aes.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-aes.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aes.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-aes.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aesgcm.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-aesgcm.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bech32.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bech32.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bech32.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bech32.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip32.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip32.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip340.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip340.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip340.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip340.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip39.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-bip39.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake256.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake256.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake2b.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2b.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake2b.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake2s.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-blake2s.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-blake2s.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-cardano.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-cardano.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-cardano.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-cardano.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-crc.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-crc.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-crc.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-crc.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-curve25519.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-curve25519.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-curve25519.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-ed25519.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ed25519.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-ed25519.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-elligator2.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-elligator2.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-elligator2.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-groestl.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-groestl.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-groestl.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-groestl.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-hmac.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-hmac.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-hmac.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-hmac.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-monero.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-monero.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nem.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-nem.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nem.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-nem.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-optiga.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-optiga.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-optiga.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-optiga.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-random.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-random.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-random.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-secp256k1.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha1.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha1.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha1.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha1.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha512.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-sha512.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-shamir.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-shamir.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-slip39.h similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto-slip39.h diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c b/core/embed/mpymod/modtrezorcrypto/modtrezorcrypto.c similarity index 100% rename from core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c rename to core/embed/mpymod/modtrezorcrypto/modtrezorcrypto.c diff --git a/core/embed/extmod/modtrezorcrypto/rand.c b/core/embed/mpymod/modtrezorcrypto/rand.c similarity index 100% rename from core/embed/extmod/modtrezorcrypto/rand.c rename to core/embed/mpymod/modtrezorcrypto/rand.c diff --git a/core/embed/extmod/modtrezorio/diskio.h b/core/embed/mpymod/modtrezorio/diskio.h similarity index 100% rename from core/embed/extmod/modtrezorio/diskio.h rename to core/embed/mpymod/modtrezorio/diskio.h diff --git a/core/embed/extmod/modtrezorio/ff.c b/core/embed/mpymod/modtrezorio/ff.c similarity index 100% rename from core/embed/extmod/modtrezorio/ff.c rename to core/embed/mpymod/modtrezorio/ff.c diff --git a/core/embed/extmod/modtrezorio/ff.h b/core/embed/mpymod/modtrezorio/ff.h similarity index 100% rename from core/embed/extmod/modtrezorio/ff.h rename to core/embed/mpymod/modtrezorio/ff.h diff --git a/core/embed/extmod/modtrezorio/ff_unifdef.sh b/core/embed/mpymod/modtrezorio/ff_unifdef.sh similarity index 100% rename from core/embed/extmod/modtrezorio/ff_unifdef.sh rename to core/embed/mpymod/modtrezorio/ff_unifdef.sh diff --git a/core/embed/extmod/modtrezorio/ffconf.h b/core/embed/mpymod/modtrezorio/ffconf.h similarity index 100% rename from core/embed/extmod/modtrezorio/ffconf.h rename to core/embed/mpymod/modtrezorio/ffconf.h diff --git a/core/embed/extmod/modtrezorio/ffunicode.c b/core/embed/mpymod/modtrezorio/ffunicode.c similarity index 100% rename from core/embed/extmod/modtrezorio/ffunicode.c rename to core/embed/mpymod/modtrezorio/ffunicode.c diff --git a/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h b/core/embed/mpymod/modtrezorio/modtrezorio-fatfs.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-fatfs.h rename to core/embed/mpymod/modtrezorio/modtrezorio-fatfs.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-haptic.h b/core/embed/mpymod/modtrezorio/modtrezorio-haptic.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-haptic.h rename to core/embed/mpymod/modtrezorio/modtrezorio-haptic.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-hid.h b/core/embed/mpymod/modtrezorio/modtrezorio-hid.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-hid.h rename to core/embed/mpymod/modtrezorio/modtrezorio-hid.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-poll.h b/core/embed/mpymod/modtrezorio/modtrezorio-poll.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-poll.h rename to core/embed/mpymod/modtrezorio/modtrezorio-poll.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-sdcard.h b/core/embed/mpymod/modtrezorio/modtrezorio-sdcard.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-sdcard.h rename to core/embed/mpymod/modtrezorio/modtrezorio-sdcard.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-usb.h b/core/embed/mpymod/modtrezorio/modtrezorio-usb.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-usb.h rename to core/embed/mpymod/modtrezorio/modtrezorio-usb.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-vcp.h b/core/embed/mpymod/modtrezorio/modtrezorio-vcp.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-vcp.h rename to core/embed/mpymod/modtrezorio/modtrezorio-vcp.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-webusb.h b/core/embed/mpymod/modtrezorio/modtrezorio-webusb.h similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio-webusb.h rename to core/embed/mpymod/modtrezorio/modtrezorio-webusb.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio.c b/core/embed/mpymod/modtrezorio/modtrezorio.c similarity index 100% rename from core/embed/extmod/modtrezorio/modtrezorio.c rename to core/embed/mpymod/modtrezorio/modtrezorio.c diff --git a/core/embed/extmod/modtrezorui/modtrezorui-display.h b/core/embed/mpymod/modtrezorui/modtrezorui-display.h similarity index 100% rename from core/embed/extmod/modtrezorui/modtrezorui-display.h rename to core/embed/mpymod/modtrezorui/modtrezorui-display.h diff --git a/core/embed/extmod/modtrezorui/modtrezorui.c b/core/embed/mpymod/modtrezorui/modtrezorui.c similarity index 100% rename from core/embed/extmod/modtrezorui/modtrezorui.c rename to core/embed/mpymod/modtrezorui/modtrezorui.c diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/mpymod/modtrezorutils/modtrezorutils-meminfo.h similarity index 100% rename from core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h rename to core/embed/mpymod/modtrezorutils/modtrezorutils-meminfo.h diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils.c b/core/embed/mpymod/modtrezorutils/modtrezorutils.c similarity index 100% rename from core/embed/extmod/modtrezorutils/modtrezorutils.c rename to core/embed/mpymod/modtrezorutils/modtrezorutils.c diff --git a/core/embed/extmod/modutime.c b/core/embed/mpymod/modutime.c similarity index 100% rename from core/embed/extmod/modutime.c rename to core/embed/mpymod/modutime.c diff --git a/core/embed/extmod/rustmods.c b/core/embed/mpymod/rustmods.c similarity index 100% rename from core/embed/extmod/rustmods.c rename to core/embed/mpymod/rustmods.c diff --git a/core/embed/extmod/trezorobj.c b/core/embed/mpymod/trezorobj.c similarity index 100% rename from core/embed/extmod/trezorobj.c rename to core/embed/mpymod/trezorobj.c diff --git a/core/embed/extmod/trezorobj.h b/core/embed/mpymod/trezorobj.h similarity index 100% rename from core/embed/extmod/trezorobj.h rename to core/embed/mpymod/trezorobj.h diff --git a/core/embed/boardloader/.changelog.d/.gitignore b/core/embed/prj/boardloader/.changelog.d/.gitignore similarity index 100% rename from core/embed/boardloader/.changelog.d/.gitignore rename to core/embed/prj/boardloader/.changelog.d/.gitignore diff --git a/core/embed/boardloader/.towncrier.template.md b/core/embed/prj/boardloader/.towncrier.template.md similarity index 100% rename from core/embed/boardloader/.towncrier.template.md rename to core/embed/prj/boardloader/.towncrier.template.md diff --git a/core/embed/boardloader/CHANGELOG.md b/core/embed/prj/boardloader/CHANGELOG.md similarity index 100% rename from core/embed/boardloader/CHANGELOG.md rename to core/embed/prj/boardloader/CHANGELOG.md diff --git a/core/embed/boardloader/CHANGELOG.unreleased b/core/embed/prj/boardloader/CHANGELOG.unreleased similarity index 100% rename from core/embed/boardloader/CHANGELOG.unreleased rename to core/embed/prj/boardloader/CHANGELOG.unreleased diff --git a/core/embed/boardloader/main.c b/core/embed/prj/boardloader/main.c similarity index 100% rename from core/embed/boardloader/main.c rename to core/embed/prj/boardloader/main.c diff --git a/core/embed/boardloader/towncrier.toml b/core/embed/prj/boardloader/towncrier.toml similarity index 100% rename from core/embed/boardloader/towncrier.toml rename to core/embed/prj/boardloader/towncrier.toml diff --git a/core/embed/boardloader/version.h b/core/embed/prj/boardloader/version.h similarity index 100% rename from core/embed/boardloader/version.h rename to core/embed/prj/boardloader/version.h diff --git a/core/embed/bootloader/.changelog.d/.gitignore b/core/embed/prj/bootloader/.changelog.d/.gitignore similarity index 100% rename from core/embed/bootloader/.changelog.d/.gitignore rename to core/embed/prj/bootloader/.changelog.d/.gitignore diff --git a/core/embed/bootloader/.towncrier.template.md b/core/embed/prj/bootloader/.towncrier.template.md similarity index 100% rename from core/embed/bootloader/.towncrier.template.md rename to core/embed/prj/bootloader/.towncrier.template.md diff --git a/core/embed/bootloader/CHANGELOG.md b/core/embed/prj/bootloader/CHANGELOG.md similarity index 100% rename from core/embed/bootloader/CHANGELOG.md rename to core/embed/prj/bootloader/CHANGELOG.md diff --git a/core/embed/bootloader/CHANGELOG.unreleased b/core/embed/prj/bootloader/CHANGELOG.unreleased similarity index 100% rename from core/embed/bootloader/CHANGELOG.unreleased rename to core/embed/prj/bootloader/CHANGELOG.unreleased diff --git a/core/embed/bootloader/bootloader_flash.jlink b/core/embed/prj/bootloader/bootloader_flash.jlink similarity index 100% rename from core/embed/bootloader/bootloader_flash.jlink rename to core/embed/prj/bootloader/bootloader_flash.jlink diff --git a/core/embed/bootloader/bootui.c b/core/embed/prj/bootloader/bootui.c similarity index 100% rename from core/embed/bootloader/bootui.c rename to core/embed/prj/bootloader/bootui.c diff --git a/core/embed/bootloader/bootui.h b/core/embed/prj/bootloader/bootui.h similarity index 100% rename from core/embed/bootloader/bootui.h rename to core/embed/prj/bootloader/bootui.h diff --git a/core/embed/bootloader/emulator.c b/core/embed/prj/bootloader/emulator.c similarity index 100% rename from core/embed/bootloader/emulator.c rename to core/embed/prj/bootloader/emulator.c diff --git a/core/embed/bootloader/emulator.h b/core/embed/prj/bootloader/emulator.h similarity index 100% rename from core/embed/bootloader/emulator.h rename to core/embed/prj/bootloader/emulator.h diff --git a/core/embed/bootloader/header.S b/core/embed/prj/bootloader/header.S similarity index 100% rename from core/embed/bootloader/header.S rename to core/embed/prj/bootloader/header.S diff --git a/core/embed/bootloader/main.c b/core/embed/prj/bootloader/main.c similarity index 100% rename from core/embed/bootloader/main.c rename to core/embed/prj/bootloader/main.c diff --git a/core/embed/bootloader/messages.c b/core/embed/prj/bootloader/messages.c similarity index 100% rename from core/embed/bootloader/messages.c rename to core/embed/prj/bootloader/messages.c diff --git a/core/embed/bootloader/messages.h b/core/embed/prj/bootloader/messages.h similarity index 100% rename from core/embed/bootloader/messages.h rename to core/embed/prj/bootloader/messages.h diff --git a/core/embed/bootloader/protob/.gitignore b/core/embed/prj/bootloader/protob/.gitignore similarity index 100% rename from core/embed/bootloader/protob/.gitignore rename to core/embed/prj/bootloader/protob/.gitignore diff --git a/core/embed/bootloader/protob/Makefile b/core/embed/prj/bootloader/protob/Makefile similarity index 100% rename from core/embed/bootloader/protob/Makefile rename to core/embed/prj/bootloader/protob/Makefile diff --git a/core/embed/bootloader/protob/messages.options b/core/embed/prj/bootloader/protob/messages.options similarity index 100% rename from core/embed/bootloader/protob/messages.options rename to core/embed/prj/bootloader/protob/messages.options diff --git a/core/embed/bootloader/protob/messages.pb.c b/core/embed/prj/bootloader/protob/messages.pb.c similarity index 100% rename from core/embed/bootloader/protob/messages.pb.c rename to core/embed/prj/bootloader/protob/messages.pb.c diff --git a/core/embed/bootloader/protob/messages.pb.h b/core/embed/prj/bootloader/protob/messages.pb.h similarity index 100% rename from core/embed/bootloader/protob/messages.pb.h rename to core/embed/prj/bootloader/protob/messages.pb.h diff --git a/core/embed/bootloader/protob/messages.proto b/core/embed/prj/bootloader/protob/messages.proto similarity index 100% rename from core/embed/bootloader/protob/messages.proto rename to core/embed/prj/bootloader/protob/messages.proto diff --git a/core/embed/bootloader/towncrier.toml b/core/embed/prj/bootloader/towncrier.toml similarity index 100% rename from core/embed/bootloader/towncrier.toml rename to core/embed/prj/bootloader/towncrier.toml diff --git a/core/embed/bootloader/version.h b/core/embed/prj/bootloader/version.h similarity index 100% rename from core/embed/bootloader/version.h rename to core/embed/prj/bootloader/version.h diff --git a/core/embed/bootloader/version_check.c b/core/embed/prj/bootloader/version_check.c similarity index 100% rename from core/embed/bootloader/version_check.c rename to core/embed/prj/bootloader/version_check.c diff --git a/core/embed/bootloader/version_check.h b/core/embed/prj/bootloader/version_check.h similarity index 100% rename from core/embed/bootloader/version_check.h rename to core/embed/prj/bootloader/version_check.h diff --git a/core/embed/bootloader_ci/.changelog.d/.gitignore b/core/embed/prj/bootloader_ci/.changelog.d/.gitignore similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/.gitignore rename to core/embed/prj/bootloader_ci/.changelog.d/.gitignore diff --git a/core/embed/bootloader_ci/.changelog.d/1049.added b/core/embed/prj/bootloader_ci/.changelog.d/1049.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/1049.added rename to core/embed/prj/bootloader_ci/.changelog.d/1049.added diff --git a/core/embed/bootloader_ci/.changelog.d/1599.changed b/core/embed/prj/bootloader_ci/.changelog.d/1599.changed similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/1599.changed rename to core/embed/prj/bootloader_ci/.changelog.d/1599.changed diff --git a/core/embed/bootloader_ci/.changelog.d/2243.added b/core/embed/prj/bootloader_ci/.changelog.d/2243.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2243.added rename to core/embed/prj/bootloader_ci/.changelog.d/2243.added diff --git a/core/embed/bootloader_ci/.changelog.d/2414.added b/core/embed/prj/bootloader_ci/.changelog.d/2414.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2414.added rename to core/embed/prj/bootloader_ci/.changelog.d/2414.added diff --git a/core/embed/bootloader_ci/.changelog.d/2623.added b/core/embed/prj/bootloader_ci/.changelog.d/2623.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/2623.added rename to core/embed/prj/bootloader_ci/.changelog.d/2623.added diff --git a/core/embed/bootloader_ci/.changelog.d/3205.added b/core/embed/prj/bootloader_ci/.changelog.d/3205.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/3205.added rename to core/embed/prj/bootloader_ci/.changelog.d/3205.added diff --git a/core/embed/bootloader_ci/.changelog.d/3370.added b/core/embed/prj/bootloader_ci/.changelog.d/3370.added similarity index 100% rename from core/embed/bootloader_ci/.changelog.d/3370.added rename to core/embed/prj/bootloader_ci/.changelog.d/3370.added diff --git a/core/embed/bootloader_ci/.towncrier.template.md b/core/embed/prj/bootloader_ci/.towncrier.template.md similarity index 100% rename from core/embed/bootloader_ci/.towncrier.template.md rename to core/embed/prj/bootloader_ci/.towncrier.template.md diff --git a/core/embed/bootloader_ci/CHANGELOG.md b/core/embed/prj/bootloader_ci/CHANGELOG.md similarity index 100% rename from core/embed/bootloader_ci/CHANGELOG.md rename to core/embed/prj/bootloader_ci/CHANGELOG.md diff --git a/core/embed/bootloader_ci/CHANGELOG.unreleased b/core/embed/prj/bootloader_ci/CHANGELOG.unreleased similarity index 100% rename from core/embed/bootloader_ci/CHANGELOG.unreleased rename to core/embed/prj/bootloader_ci/CHANGELOG.unreleased diff --git a/core/embed/bootloader_ci/README.md b/core/embed/prj/bootloader_ci/README.md similarity index 100% rename from core/embed/bootloader_ci/README.md rename to core/embed/prj/bootloader_ci/README.md diff --git a/core/embed/bootloader_ci/bootloader_flash.jlink b/core/embed/prj/bootloader_ci/bootloader_flash.jlink similarity index 100% rename from core/embed/bootloader_ci/bootloader_flash.jlink rename to core/embed/prj/bootloader_ci/bootloader_flash.jlink diff --git a/core/embed/bootloader_ci/bootui.c b/core/embed/prj/bootloader_ci/bootui.c similarity index 100% rename from core/embed/bootloader_ci/bootui.c rename to core/embed/prj/bootloader_ci/bootui.c diff --git a/core/embed/bootloader_ci/bootui.h b/core/embed/prj/bootloader_ci/bootui.h similarity index 100% rename from core/embed/bootloader_ci/bootui.h rename to core/embed/prj/bootloader_ci/bootui.h diff --git a/core/embed/bootloader_ci/header.S b/core/embed/prj/bootloader_ci/header.S similarity index 100% rename from core/embed/bootloader_ci/header.S rename to core/embed/prj/bootloader_ci/header.S diff --git a/core/embed/bootloader_ci/icon_done.h b/core/embed/prj/bootloader_ci/icon_done.h similarity index 100% rename from core/embed/bootloader_ci/icon_done.h rename to core/embed/prj/bootloader_ci/icon_done.h diff --git a/core/embed/bootloader_ci/icon_fail.h b/core/embed/prj/bootloader_ci/icon_fail.h similarity index 100% rename from core/embed/bootloader_ci/icon_fail.h rename to core/embed/prj/bootloader_ci/icon_fail.h diff --git a/core/embed/bootloader_ci/icon_install.h b/core/embed/prj/bootloader_ci/icon_install.h similarity index 100% rename from core/embed/bootloader_ci/icon_install.h rename to core/embed/prj/bootloader_ci/icon_install.h diff --git a/core/embed/bootloader_ci/icon_welcome.h b/core/embed/prj/bootloader_ci/icon_welcome.h similarity index 100% rename from core/embed/bootloader_ci/icon_welcome.h rename to core/embed/prj/bootloader_ci/icon_welcome.h diff --git a/core/embed/bootloader_ci/icon_wipe.h b/core/embed/prj/bootloader_ci/icon_wipe.h similarity index 100% rename from core/embed/bootloader_ci/icon_wipe.h rename to core/embed/prj/bootloader_ci/icon_wipe.h diff --git a/core/embed/bootloader_ci/main.c b/core/embed/prj/bootloader_ci/main.c similarity index 100% rename from core/embed/bootloader_ci/main.c rename to core/embed/prj/bootloader_ci/main.c diff --git a/core/embed/bootloader_ci/messages.c b/core/embed/prj/bootloader_ci/messages.c similarity index 100% rename from core/embed/bootloader_ci/messages.c rename to core/embed/prj/bootloader_ci/messages.c diff --git a/core/embed/bootloader_ci/messages.h b/core/embed/prj/bootloader_ci/messages.h similarity index 100% rename from core/embed/bootloader_ci/messages.h rename to core/embed/prj/bootloader_ci/messages.h diff --git a/core/embed/bootloader_ci/protob b/core/embed/prj/bootloader_ci/protob similarity index 100% rename from core/embed/bootloader_ci/protob rename to core/embed/prj/bootloader_ci/protob diff --git a/core/embed/bootloader_ci/towncrier.toml b/core/embed/prj/bootloader_ci/towncrier.toml similarity index 100% rename from core/embed/bootloader_ci/towncrier.toml rename to core/embed/prj/bootloader_ci/towncrier.toml diff --git a/core/embed/bootloader_ci/version.h b/core/embed/prj/bootloader_ci/version.h similarity index 100% rename from core/embed/bootloader_ci/version.h rename to core/embed/prj/bootloader_ci/version.h diff --git a/core/embed/bootloader_ci/version_check.c b/core/embed/prj/bootloader_ci/version_check.c similarity index 100% rename from core/embed/bootloader_ci/version_check.c rename to core/embed/prj/bootloader_ci/version_check.c diff --git a/core/embed/bootloader_ci/version_check.h b/core/embed/prj/bootloader_ci/version_check.h similarity index 100% rename from core/embed/bootloader_ci/version_check.h rename to core/embed/prj/bootloader_ci/version_check.h diff --git a/core/embed/firmware/header.S b/core/embed/prj/firmware/header.S similarity index 100% rename from core/embed/firmware/header.S rename to core/embed/prj/firmware/header.S diff --git a/core/embed/firmware/main.c b/core/embed/prj/firmware/main.c similarity index 100% rename from core/embed/firmware/main.c rename to core/embed/prj/firmware/main.c diff --git a/core/embed/firmware/mpconfigport.h b/core/embed/prj/firmware/mpconfigport.h similarity index 100% rename from core/embed/firmware/mpconfigport.h rename to core/embed/prj/firmware/mpconfigport.h diff --git a/core/embed/firmware/mphalport.c b/core/embed/prj/firmware/mphalport.c similarity index 100% rename from core/embed/firmware/mphalport.c rename to core/embed/prj/firmware/mphalport.c diff --git a/core/embed/firmware/mphalport.h b/core/embed/prj/firmware/mphalport.h similarity index 100% rename from core/embed/firmware/mphalport.h rename to core/embed/prj/firmware/mphalport.h diff --git a/core/embed/firmware/nlrthumb.c b/core/embed/prj/firmware/nlrthumb.c similarity index 100% rename from core/embed/firmware/nlrthumb.c rename to core/embed/prj/firmware/nlrthumb.c diff --git a/core/embed/firmware/systemview.c b/core/embed/prj/firmware/systemview.c similarity index 100% rename from core/embed/firmware/systemview.c rename to core/embed/prj/firmware/systemview.c diff --git a/core/embed/firmware/systemview.h b/core/embed/prj/firmware/systemview.h similarity index 100% rename from core/embed/firmware/systemview.h rename to core/embed/prj/firmware/systemview.h diff --git a/core/embed/firmware/version.h b/core/embed/prj/firmware/version.h similarity index 100% rename from core/embed/firmware/version.h rename to core/embed/prj/firmware/version.h diff --git a/core/embed/kernel/main.c b/core/embed/prj/kernel/main.c similarity index 100% rename from core/embed/kernel/main.c rename to core/embed/prj/kernel/main.c diff --git a/core/embed/kernel/version.h b/core/embed/prj/kernel/version.h similarity index 100% rename from core/embed/kernel/version.h rename to core/embed/prj/kernel/version.h diff --git a/core/embed/prodtest/.changelog.d/.keep b/core/embed/prj/prodtest/.changelog.d/.keep similarity index 100% rename from core/embed/prodtest/.changelog.d/.keep rename to core/embed/prj/prodtest/.changelog.d/.keep diff --git a/core/embed/prodtest/.changelog.d/4252.added b/core/embed/prj/prodtest/.changelog.d/4252.added similarity index 100% rename from core/embed/prodtest/.changelog.d/4252.added rename to core/embed/prj/prodtest/.changelog.d/4252.added diff --git a/core/embed/prodtest/.towncrier.template.md b/core/embed/prj/prodtest/.towncrier.template.md similarity index 100% rename from core/embed/prodtest/.towncrier.template.md rename to core/embed/prj/prodtest/.towncrier.template.md diff --git a/core/embed/prodtest/CHANGELOG.md b/core/embed/prj/prodtest/CHANGELOG.md similarity index 100% rename from core/embed/prodtest/CHANGELOG.md rename to core/embed/prj/prodtest/CHANGELOG.md diff --git a/core/embed/prodtest/CHANGELOG.unreleased b/core/embed/prj/prodtest/CHANGELOG.unreleased similarity index 100% rename from core/embed/prodtest/CHANGELOG.unreleased rename to core/embed/prj/prodtest/CHANGELOG.unreleased diff --git a/core/embed/prodtest/README.md b/core/embed/prj/prodtest/README.md similarity index 100% rename from core/embed/prodtest/README.md rename to core/embed/prj/prodtest/README.md diff --git a/core/embed/prodtest/header.S b/core/embed/prj/prodtest/header.S similarity index 100% rename from core/embed/prodtest/header.S rename to core/embed/prj/prodtest/header.S diff --git a/core/embed/prodtest/main.c b/core/embed/prj/prodtest/main.c similarity index 100% rename from core/embed/prodtest/main.c rename to core/embed/prj/prodtest/main.c diff --git a/core/embed/prodtest/optiga_prodtest.c b/core/embed/prj/prodtest/optiga_prodtest.c similarity index 100% rename from core/embed/prodtest/optiga_prodtest.c rename to core/embed/prj/prodtest/optiga_prodtest.c diff --git a/core/embed/prodtest/optiga_prodtest.h b/core/embed/prj/prodtest/optiga_prodtest.h similarity index 100% rename from core/embed/prodtest/optiga_prodtest.h rename to core/embed/prj/prodtest/optiga_prodtest.h diff --git a/core/embed/prodtest/prodtest_common.c b/core/embed/prj/prodtest/prodtest_common.c similarity index 100% rename from core/embed/prodtest/prodtest_common.c rename to core/embed/prj/prodtest/prodtest_common.c diff --git a/core/embed/prodtest/prodtest_common.h b/core/embed/prj/prodtest/prodtest_common.h similarity index 100% rename from core/embed/prodtest/prodtest_common.h rename to core/embed/prj/prodtest/prodtest_common.h diff --git a/core/embed/prodtest/towncrier.toml b/core/embed/prj/prodtest/towncrier.toml similarity index 100% rename from core/embed/prodtest/towncrier.toml rename to core/embed/prj/prodtest/towncrier.toml diff --git a/core/embed/prodtest/version.h b/core/embed/prj/prodtest/version.h similarity index 100% rename from core/embed/prodtest/version.h rename to core/embed/prj/prodtest/version.h diff --git a/core/embed/reflash/header.S b/core/embed/prj/reflash/header.S similarity index 100% rename from core/embed/reflash/header.S rename to core/embed/prj/reflash/header.S diff --git a/core/embed/reflash/main.c b/core/embed/prj/reflash/main.c similarity index 100% rename from core/embed/reflash/main.c rename to core/embed/prj/reflash/main.c diff --git a/core/embed/reflash/version.h b/core/embed/prj/reflash/version.h similarity index 100% rename from core/embed/reflash/version.h rename to core/embed/prj/reflash/version.h diff --git a/core/embed/unix/main.c b/core/embed/prj/unix/main.c similarity index 100% rename from core/embed/unix/main.c rename to core/embed/prj/unix/main.c diff --git a/core/embed/unix/main_main.c b/core/embed/prj/unix/main_main.c similarity index 100% rename from core/embed/unix/main_main.c rename to core/embed/prj/unix/main_main.c diff --git a/core/embed/unix/mpconfigport.h b/core/embed/prj/unix/mpconfigport.h similarity index 100% rename from core/embed/unix/mpconfigport.h rename to core/embed/prj/unix/mpconfigport.h diff --git a/core/embed/unix/profile.c b/core/embed/prj/unix/profile.c similarity index 100% rename from core/embed/unix/profile.c rename to core/embed/prj/unix/profile.c diff --git a/core/embed/unix/profile.h b/core/embed/prj/unix/profile.h similarity index 100% rename from core/embed/unix/profile.h rename to core/embed/prj/unix/profile.h diff --git a/core/embed/unix/version.h b/core/embed/prj/unix/version.h similarity index 100% rename from core/embed/unix/version.h rename to core/embed/prj/unix/version.h diff --git a/core/embed/lib/assert.h b/core/embed/rtl/assert.h similarity index 100% rename from core/embed/lib/assert.h rename to core/embed/rtl/assert.h diff --git a/core/embed/lib/common.h b/core/embed/rtl/common.h similarity index 100% rename from core/embed/lib/common.h rename to core/embed/rtl/common.h diff --git a/core/embed/lib/compiler_traits.h b/core/embed/rtl/compiler_traits.h similarity index 100% rename from core/embed/lib/compiler_traits.h rename to core/embed/rtl/compiler_traits.h diff --git a/core/embed/lib/error_handling.c b/core/embed/rtl/error_handling.c similarity index 100% rename from core/embed/lib/error_handling.c rename to core/embed/rtl/error_handling.c diff --git a/core/embed/lib/error_handling.h b/core/embed/rtl/error_handling.h similarity index 100% rename from core/embed/lib/error_handling.h rename to core/embed/rtl/error_handling.h diff --git a/core/embed/lib/mini_printf.c b/core/embed/rtl/mini_printf.c similarity index 100% rename from core/embed/lib/mini_printf.c rename to core/embed/rtl/mini_printf.c diff --git a/core/embed/lib/mini_printf.h b/core/embed/rtl/mini_printf.h similarity index 100% rename from core/embed/lib/mini_printf.h rename to core/embed/rtl/mini_printf.h diff --git a/core/embed/lib/rsod.c b/core/embed/rtl/rsod.c similarity index 100% rename from core/embed/lib/rsod.c rename to core/embed/rtl/rsod.c diff --git a/core/embed/lib/rsod.h b/core/embed/rtl/rsod.h similarity index 100% rename from core/embed/lib/rsod.h rename to core/embed/rtl/rsod.h diff --git a/core/embed/lib/secbool.h b/core/embed/rtl/secbool.h similarity index 100% rename from core/embed/lib/secbool.h rename to core/embed/rtl/secbool.h diff --git a/core/embed/lib/sizedefs.h b/core/embed/rtl/sizedefs.h similarity index 100% rename from core/embed/lib/sizedefs.h rename to core/embed/rtl/sizedefs.h diff --git a/core/embed/lib/trezor_rtl.h b/core/embed/rtl/trezor_rtl.h similarity index 100% rename from core/embed/lib/trezor_rtl.h rename to core/embed/rtl/trezor_rtl.h diff --git a/core/embed/lib/trezor_types.h b/core/embed/rtl/trezor_types.h similarity index 100% rename from core/embed/lib/trezor_types.h rename to core/embed/rtl/trezor_types.h diff --git a/core/embed/trezorhal/dma2d.h b/core/embed/trezorhal/dma2d.h deleted file mode 100644 index 642e9e9ec4..0000000000 --- a/core/embed/trezorhal/dma2d.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 . - */ - -#ifndef TREZORHAL_DMA2D_H -#define TREZORHAL_DMA2D_H - -#include - -void dma2d_init(void); - -void dma2d_setup_const(void); -void dma2d_setup_4bpp(uint16_t fg_color, uint16_t bg_color); -void dma2d_setup_16bpp(void); -void dma2d_setup_4bpp_over_4bpp(uint16_t fg_color, uint16_t bg_color, - uint16_t overlay_color); -void dma2d_setup_4bpp_over_16bpp(uint16_t overlay_color); - -void dma2d_start(uint8_t* in_addr, uint8_t* out_addr, int32_t pixels); -void dma2d_start_const(uint16_t color, uint8_t* out_addr, int32_t pixels); -void dma2d_start_const_multiline(uint16_t color, uint8_t* out_addr, - int32_t width, int32_t height); -void dma2d_start_blend(uint8_t* overlay_addr, uint8_t* bg_addr, - uint8_t* out_addr, int32_t pixels); - -void dma2d_wait_for_transfer(void); - -#endif // TREZORHAL_DMA2D_H diff --git a/core/embed/trezorhal/stm32f4/displays/ili9341_spi.c b/core/embed/trezorhal/stm32f4/displays/ili9341_spi.c deleted file mode 100644 index 1b317c6752..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/ili9341_spi.c +++ /dev/null @@ -1,512 +0,0 @@ - - -#include -#include - -#include "ili9341_spi.h" - -/** - * @brief ILI9341 chip IDs - */ -#define ILI9341_ID 0x9341 - -/** - * @brief ILI9341 Size - */ -#define ILI9341_LCD_PIXEL_WIDTH ((uint16_t)240) -#define ILI9341_LCD_PIXEL_HEIGHT ((uint16_t)320) - -/** - * @brief ILI9341 Timing - */ -/* Timing configuration (Typical configuration from ILI9341 datasheet) - HSYNC=10 (9+1) - HBP=20 (29-10+1) - ActiveW=240 (269-20-10+1) - HFP=10 (279-240-20-10+1) - - VSYNC=2 (1+1) - VBP=2 (3-2+1) - ActiveH=320 (323-2-2+1) - VFP=4 (327-320-2-2+1) -*/ - -/** - * @brief ILI9341 Registers - */ - -/* Level 1 Commands */ -#define LCD_SWRESET 0x01 /* Software Reset */ -#define LCD_READ_DISPLAY_ID 0x04 /* Read display identification information */ -#define LCD_RDDST 0x09 /* Read Display Status */ -#define LCD_RDDPM 0x0A /* Read Display Power Mode */ -#define LCD_RDDMADCTL 0x0B /* Read Display MADCTL */ -#define LCD_RDDCOLMOD 0x0C /* Read Display Pixel Format */ -#define LCD_RDDIM 0x0D /* Read Display Image Format */ -#define LCD_RDDSM 0x0E /* Read Display Signal Mode */ -#define LCD_RDDSDR 0x0F /* Read Display Self-Diagnostic Result */ -#define LCD_SPLIN 0x10 /* Enter Sleep Mode */ -#define LCD_SLEEP_OUT 0x11 /* Sleep out register */ -#define LCD_PTLON 0x12 /* Partial Mode ON */ -#define LCD_NORMAL_MODE_ON 0x13 /* Normal Display Mode ON */ -#define LCD_DINVOFF 0x20 /* Display Inversion OFF */ -#define LCD_DINVON 0x21 /* Display Inversion ON */ -#define LCD_GAMMA 0x26 /* Gamma register */ -#define LCD_DISPLAY_OFF 0x28 /* Display off register */ -#define LCD_DISPLAY_ON 0x29 /* Display on register */ -#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ -#define LCD_PAGE_ADDR 0x2B /* Page address register */ -#define LCD_GRAM 0x2C /* GRAM register */ -#define LCD_RGBSET 0x2D /* Color SET */ -#define LCD_RAMRD 0x2E /* Memory Read */ -#define LCD_PLTAR 0x30 /* Partial Area */ -#define LCD_VSCRDEF 0x33 /* Vertical Scrolling Definition */ -#define LCD_TEOFF 0x34 /* Tearing Effect Line OFF */ -#define LCD_TEON 0x35 /* Tearing Effect Line ON */ -#define LCD_MAC 0x36 /* Memory Access Control register*/ -#define LCD_VSCRSADD 0x37 /* Vertical Scrolling Start Address */ -#define LCD_IDMOFF 0x38 /* Idle Mode OFF */ -#define LCD_IDMON 0x39 /* Idle Mode ON */ -#define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ -#define LCD_WRITE_MEM_CONTINUE 0x3C /* Write Memory Continue */ -#define LCD_READ_MEM_CONTINUE 0x3E /* Read Memory Continue */ -#define LCD_SET_TEAR_SCANLINE 0x44 /* Set Tear Scanline */ -#define LCD_GET_SCANLINE 0x45 /* Get Scanline */ -#define LCD_WDB 0x51 /* Write Brightness Display register */ -#define LCD_RDDISBV 0x52 /* Read Display Brightness */ -#define LCD_WCD 0x53 /* Write Control Display register*/ -#define LCD_RDCTRLD 0x54 /* Read CTRL Display */ -#define LCD_WRCABC 0x55 /* Write Content Adaptive Brightness Control */ -#define LCD_RDCABC 0x56 /* Read Content Adaptive Brightness Control */ -#define LCD_WRITE_CABC 0x5E /* Write CABC Minimum Brightness */ -#define LCD_READ_CABC 0x5F /* Read CABC Minimum Brightness */ -#define LCD_READ_ID1 0xDA /* Read ID1 */ -#define LCD_READ_ID2 0xDB /* Read ID2 */ -#define LCD_READ_ID3 0xDC /* Read ID3 */ - -/* Level 2 Commands */ -#define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */ -#define LCD_FRMCTR1 0xB1 /* Frame Rate Control (In Normal Mode) */ -#define LCD_FRMCTR2 0xB2 /* Frame Rate Control (In Idle Mode) */ -#define LCD_FRMCTR3 0xB3 /* Frame Rate Control (In Partial Mode) */ -#define LCD_INVTR 0xB4 /* Display Inversion Control */ -#define LCD_BPC 0xB5 /* Blanking Porch Control register */ -#define LCD_DFC 0xB6 /* Display Function Control register */ -#define LCD_ETMOD 0xB7 /* Entry Mode Set */ -#define LCD_BACKLIGHT1 0xB8 /* Backlight Control 1 */ -#define LCD_BACKLIGHT2 0xB9 /* Backlight Control 2 */ -#define LCD_BACKLIGHT3 0xBA /* Backlight Control 3 */ -#define LCD_BACKLIGHT4 0xBB /* Backlight Control 4 */ -#define LCD_BACKLIGHT5 0xBC /* Backlight Control 5 */ -#define LCD_BACKLIGHT7 0xBE /* Backlight Control 7 */ -#define LCD_BACKLIGHT8 0xBF /* Backlight Control 8 */ -#define LCD_POWER1 0xC0 /* Power Control 1 register */ -#define LCD_POWER2 0xC1 /* Power Control 2 register */ -#define LCD_VCOM1 0xC5 /* VCOM Control 1 register */ -#define LCD_VCOM2 0xC7 /* VCOM Control 2 register */ -#define LCD_NVMWR 0xD0 /* NV Memory Write */ -#define LCD_NVMPKEY 0xD1 /* NV Memory Protection Key */ -#define LCD_RDNVM 0xD2 /* NV Memory Status Read */ -#define LCD_READ_ID4 0xD3 /* Read ID4 */ -#define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register */ -#define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register */ -#define LCD_DGAMCTRL1 0xE2 /* Digital Gamma Control 1 */ -#define LCD_DGAMCTRL2 0xE3 /* Digital Gamma Control 2 */ -#define LCD_INTERFACE 0xF6 /* Interface control register */ - -/* Extend register commands */ -#define LCD_POWERA 0xCB /* Power control A register */ -#define LCD_POWERB 0xCF /* Power control B register */ -#define LCD_DTCA 0xE8 /* Driver timing control A */ -#define LCD_DTCB 0xEA /* Driver timing control B */ -#define LCD_POWER_SEQ 0xED /* Power on sequence register */ -#define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */ -#define LCD_PRC 0xF7 /* Pump ratio control register */ - -/* Size of read registers */ -#define LCD_READ_ID4_SIZE 3 /* Size of Read ID4 */ - -/*############################### SPIx #######################################*/ -#define DISCOVERY_SPIx SPI5 -#define DISCOVERY_SPIx_CLK_ENABLE() __HAL_RCC_SPI5_CLK_ENABLE() -#define DISCOVERY_SPIx_GPIO_PORT GPIOF /* GPIOF */ -#define DISCOVERY_SPIx_AF GPIO_AF5_SPI5 -#define DISCOVERY_SPIx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() -#define DISCOVERY_SPIx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() -#define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_7 /* PF.07 */ -#define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_8 /* PF.08 */ -#define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_9 /* PF.09 */ -/* Maximum Timeout values for flags waiting loops. These timeouts are not based - on accurate values, they just guarantee that the application will not remain - stuck if the SPI communication is corrupted. - You may modify these timeout values depending on CPU frequency and - application conditions (interrupts routines ...). */ -#define SPIx_TIMEOUT_MAX ((uint32_t)0x1000) - -/*################################ LCD #######################################*/ -/* Chip Select macro definition */ -#define LCD_CS_LOW() \ - HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_RESET) -#define LCD_CS_HIGH() \ - HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_SET) - -/* Set WRX High to send data */ -#define LCD_WRX_LOW() \ - HAL_GPIO_WritePin(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, GPIO_PIN_RESET) -#define LCD_WRX_HIGH() \ - HAL_GPIO_WritePin(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, GPIO_PIN_SET) - -/* Set WRX High to send data */ -#define LCD_RDX_LOW() \ - HAL_GPIO_WritePin(LCD_RDX_GPIO_PORT, LCD_RDX_PIN, GPIO_PIN_RESET) -#define LCD_RDX_HIGH() \ - HAL_GPIO_WritePin(LCD_RDX_GPIO_PORT, LCD_RDX_PIN, GPIO_PIN_SET) - -/** - * @brief LCD Control pin - */ -#define LCD_NCS_PIN GPIO_PIN_2 -#define LCD_NCS_GPIO_PORT GPIOC -#define LCD_NCS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() -#define LCD_NCS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() -/** - * @} - */ -/** - * @brief LCD Command/data pin - */ -#define LCD_WRX_PIN GPIO_PIN_13 -#define LCD_WRX_GPIO_PORT GPIOD -#define LCD_WRX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define LCD_WRX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() - -#define LCD_RDX_PIN GPIO_PIN_12 -#define LCD_RDX_GPIO_PORT GPIOD -#define LCD_RDX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() -#define LCD_RDX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() - -static SPI_HandleTypeDef SpiHandle; -uint32_t SpixTimeout = - SPIx_TIMEOUT_MAX; /*. - */ - -#include -#include - -#include "display.h" -#include "ili9341_spi.h" -#include "memzero.h" -#include "sdram.h" - -#define MAX_LAYER_NUMBER 2 -#define LCD_FRAME_BUFFER ((uint32_t)SDRAM_DEVICE_ADDR) - -LTDC_HandleTypeDef LtdcHandler; -static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; - -/* Default LCD configuration with LCD Layer 1 */ -uint32_t ActiveLayer = 0; -// static LCD_DrawPropTypeDef DrawProp[MAX_LAYER_NUMBER]; -// LCD_DrvTypeDef *LcdDrv; - -static int DISPLAY_BACKLIGHT = -1; -static int DISPLAY_ORIENTATION = -1; - -// this is just for compatibility with DMA2D using algorithms -uint8_t *const DISPLAY_DATA_ADDRESS = 0; - -uint16_t cursor_x = 0; -uint16_t cursor_y = 0; -uint16_t window_x0 = 0; -uint16_t window_y0 = DISPLAY_RESX - 1; -uint16_t window_x1 = 0; -uint16_t window_y1 = DISPLAY_RESY - 1; - -void display_pixeldata(uint16_t c) { - ((uint16_t *)LCD_FRAME_BUFFER)[(cursor_y * DISPLAY_RESX) + cursor_x] = c; - - cursor_x++; - - if (cursor_x > window_x1) { - cursor_x = window_x0; - cursor_y++; - - if (cursor_y > window_y1) { - cursor_y = window_y0; - } - } -} - -void display_pixeldata_dirty(void) {} - -void display_reset_state() {} - -static void __attribute__((unused)) display_sleep(void) {} - -static void display_unsleep(void) {} - -/** - * @brief Initializes the LCD layers. - * @param LayerIndex: the layer foreground or background. - * @param FB_Address: the layer frame buffer. - */ -void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) { - LTDC_LayerCfgTypeDef Layercfg = {0}; - - /* Layer Init */ - Layercfg.WindowX0 = 0; - Layercfg.WindowX1 = DISPLAY_RESX; - Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = DISPLAY_RESY; - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; - Layercfg.FBStartAdress = FB_Address; - Layercfg.Alpha = 255; - Layercfg.Alpha0 = 0; - Layercfg.Backcolor.Blue = 0; - Layercfg.Backcolor.Green = 0; - Layercfg.Backcolor.Red = 0; - Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - Layercfg.ImageWidth = DISPLAY_RESX; - Layercfg.ImageHeight = DISPLAY_RESY; - - HAL_LTDC_ConfigLayer(&LtdcHandler, &Layercfg, LayerIndex); - - // DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; - // DrawProp[LayerIndex].pFont = &Font24; - // DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; - - /* Dithering activation */ - HAL_LTDC_EnableDither(&LtdcHandler); -} - -/** - * @brief Selects the LCD Layer. - * @param LayerIndex: the Layer foreground or background. - */ -void BSP_LCD_SelectLayer(uint32_t LayerIndex) { ActiveLayer = LayerIndex; } - -/** - * @brief Sets a LCD Layer visible. - * @param LayerIndex: the visible Layer. - * @param state: new state of the specified layer. - * This parameter can be: ENABLE or DISABLE. - */ -void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState state) { - if (state == ENABLE) { - __HAL_LTDC_LAYER_ENABLE(&LtdcHandler, LayerIndex); - } else { - __HAL_LTDC_LAYER_DISABLE(&LtdcHandler, LayerIndex); - } - __HAL_LTDC_RELOAD_CONFIG(&LtdcHandler); -} - -/** - * @brief Sets an LCD Layer visible without reloading. - * @param LayerIndex: Visible Layer - * @param State: New state of the specified layer - * This parameter can be one of the following values: - * @arg ENABLE - * @arg DISABLE - * @retval None - */ -void BSP_LCD_SetLayerVisible_NoReload(uint32_t LayerIndex, - FunctionalState State) { - if (State == ENABLE) { - __HAL_LTDC_LAYER_ENABLE(&LtdcHandler, LayerIndex); - } else { - __HAL_LTDC_LAYER_DISABLE(&LtdcHandler, LayerIndex); - } - /* Do not Sets the Reload */ -} - -/** - * @brief Configures the Transparency. - * @param LayerIndex: the Layer foreground or background. - * @param Transparency: the Transparency, - * This parameter must range from 0x00 to 0xFF. - */ -void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) { - HAL_LTDC_SetAlpha(&LtdcHandler, Transparency, LayerIndex); -} - -/** - * @brief Configures the transparency without reloading. - * @param LayerIndex: Layer foreground or background. - * @param Transparency: Transparency - * This parameter must be a number between Min_Data = 0x00 and - * Max_Data = 0xFF - * @retval None - */ -void BSP_LCD_SetTransparency_NoReload(uint32_t LayerIndex, - uint8_t Transparency) { - HAL_LTDC_SetAlpha_NoReload(&LtdcHandler, Transparency, LayerIndex); -} - -/** - * @brief Sets a LCD layer frame buffer address. - * @param LayerIndex: specifies the Layer foreground or background - * @param Address: new LCD frame buffer value - */ -void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) { - HAL_LTDC_SetAddress(&LtdcHandler, Address, LayerIndex); -} - -/** - * @brief Sets an LCD layer frame buffer address without reloading. - * @param LayerIndex: Layer foreground or background - * @param Address: New LCD frame buffer value - * @retval None - */ -void BSP_LCD_SetLayerAddress_NoReload(uint32_t LayerIndex, uint32_t Address) { - HAL_LTDC_SetAddress_NoReload(&LtdcHandler, Address, LayerIndex); -} - -// static struct { uint16_t x, y; } BUFFER_OFFSET; - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - window_x0 = x0; - window_x1 = x1; - window_y0 = y0; - window_y1 = y1; - cursor_x = x0; - cursor_y = y0; - - // /* Reconfigure the layer size */ - // HAL_LTDC_SetWindowSize_NoReload(&LtdcHandler, x1-x0 + 1, y1-y0 + 1, 0); - // - // /* Reconfigure the layer position */ - // HAL_LTDC_SetWindowPosition_NoReload(&LtdcHandler, x0, y0, 0); -} - -int display_orientation(int degrees) { return 0; } - -int display_get_orientation(void) { return DISPLAY_ORIENTATION; } - -int display_backlight(int val) { - if (DISPLAY_BACKLIGHT != val && val >= 0 && val <= 255) { - DISPLAY_BACKLIGHT = val; - // TIM1->CCR1 = LED_PWM_TIM_PERIOD * val / 255; - } - return DISPLAY_BACKLIGHT; -} - -void display_init_seq(void) { display_unsleep(); } - -void display_init_all(void) { - GPIO_InitTypeDef GPIO_InitStructure = {0}; - - /* Enable the LTDC and DMA2D Clock */ - __HAL_RCC_LTDC_CLK_ENABLE(); - __HAL_RCC_DMA2D_CLK_ENABLE(); - - /* Enable GPIOs clock */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - - /* GPIOs Configuration */ - /* - +------------------------+-----------------------+----------------------------+ - + LCD pins assignment + - +------------------------+-----------------------+----------------------------+ - | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | | - LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | - | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | | - LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | - | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | | - LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | - ------------------------------------------------------------------------------- - | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | - | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | - ----------------------------------------------------- - */ - - /* GPIOA configuration */ - GPIO_InitStructure.Pin = - GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_11 | GPIO_PIN_12; - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FAST; - GPIO_InitStructure.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; - HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOC configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - - /* GPIOD configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_3 | GPIO_PIN_6; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* GPIOF configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_10; - HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_11; - HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1; - GPIO_InitStructure.Alternate = GPIO_AF9_LTDC; - HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_12; - HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); - - /* On STM32F429I-DISCO, it is not possible to read ILI9341 ID because */ - /* PIN EXTC is not connected to VDD and then LCD_READ_ID4 is not accessible. - */ - /* In this case, ReadID function is bypassed.*/ - /*if(ili9341_drv.ReadID() == ILI9341_ID)*/ - - /* LTDC Configuration ----------------------------------------------------*/ - LtdcHandler.Instance = LTDC; - - /* Timing configuration (Typical configuration from ILI9341 datasheet) - HSYNC=10 (9+1) - HBP=20 (29-10+1) - ActiveW=240 (269-20-10+1) - HFP=10 (279-240-20-10+1) - - VSYNC=2 (1+1) - VBP=2 (3-2+1) - ActiveH=320 (323-2-2+1) - VFP=4 (327-320-2-2+1) - */ - - /* Configure horizontal synchronization width */ - LtdcHandler.Init.HorizontalSync = ILI9341_HSYNC; - /* Configure vertical synchronization height */ - LtdcHandler.Init.VerticalSync = ILI9341_VSYNC; - /* Configure accumulated horizontal back porch */ - LtdcHandler.Init.AccumulatedHBP = ILI9341_HBP; - /* Configure accumulated vertical back porch */ - LtdcHandler.Init.AccumulatedVBP = ILI9341_VBP; - /* Configure accumulated active width */ - LtdcHandler.Init.AccumulatedActiveW = 269; - /* Configure accumulated active height */ - LtdcHandler.Init.AccumulatedActiveH = 323; - /* Configure total width */ - LtdcHandler.Init.TotalWidth = 279; - /* Configure total height */ - LtdcHandler.Init.TotalHeigh = 327; - - /* Configure R,G,B component values for LCD background color */ - LtdcHandler.Init.Backcolor.Red = 0; - LtdcHandler.Init.Backcolor.Blue = 0; - LtdcHandler.Init.Backcolor.Green = 0; - - /* LCD clock configuration */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; - PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; - PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - - /* Polarity */ - LtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL; - LtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL; - LtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL; - LtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - - HAL_LTDC_Init(&LtdcHandler); - - /* Initialize the LCD Layers */ - BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER); - - memzero((void *)LCD_FRAME_BUFFER, 153600); - - ili9341_init(); - - display_init_seq(); -} - -void display_reinit(void) {} - -void display_refresh(void) {} - -void display_sync(void) {} - -const char *display_save(const char *prefix) { return NULL; } - -void display_clear_save(void) {} - -void display_efficient_clear(void) { - memzero((void *)LCD_FRAME_BUFFER, 153600); -} - -uint8_t *display_get_wr_addr(void) { - uint32_t address = LCD_FRAME_BUFFER; - /* Get the rectangle start address */ - address = (address + (2 * ((cursor_y)*DISPLAY_RESX + (cursor_x)))); - - return (uint8_t *)address; -} - -uint32_t *display_get_fb_addr(void) { return (uint32_t *)LCD_FRAME_BUFFER; } - -uint16_t display_get_window_width(void) { return window_x1 - window_x0 + 1; } - -uint16_t display_get_window_height(void) { return window_y1 - window_y0 + 1; } - -void display_shift_window(uint16_t pixels) { - uint16_t w = display_get_window_width(); - uint16_t h = display_get_window_height(); - - uint16_t line_rem = w - (cursor_x - window_x0); - - if (pixels < line_rem) { - cursor_x += pixels; - return; - } - - // start of next line - pixels = pixels - line_rem; - cursor_x = window_x0; - cursor_y++; - - // add the rest of pixels - cursor_y = window_y0 + (((cursor_y - window_y0) + (pixels / w)) % h); - cursor_x += pixels % w; -} - -uint16_t display_get_window_offset(void) { - return DISPLAY_RESX - display_get_window_width(); -} - -void display_finish_actions(void) {} diff --git a/core/embed/trezorhal/stm32f4/displays/ltdc.h b/core/embed/trezorhal/stm32f4/displays/ltdc.h deleted file mode 100644 index 34cb288a78..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/ltdc.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef _LTDC_H -#define _LTDC_H - -#include - -#define DISPLAY_FRAMEBUFFER_WIDTH DISPLAY_RESX -#define DISPLAY_FRAMEBUFFER_HEIGHT DISPLAY_RESY -#define DISPLAY_FRAMEBUFFER_OFFSET_X 0 -#define DISPLAY_FRAMEBUFFER_OFFSET_Y 0 -#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565 -#define DISPLAY_EFFICIENT_CLEAR 1 - -extern uint8_t* const DISPLAY_DATA_ADDRESS; - -static inline void display_pixel(uint8_t* fb, int16_t x, int16_t y, - uint16_t color) { - uint32_t p = 2 * (y * DISPLAY_FRAMEBUFFER_WIDTH + x); - *((uint16_t*)(fb + p)) = color; -} - -#endif //_LTDC_H diff --git a/core/embed/trezorhal/stm32f4/displays/panels/154a.c b/core/embed/trezorhal/stm32f4/displays/panels/154a.c deleted file mode 100644 index 4efeff70c2..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/154a.c +++ /dev/null @@ -1,115 +0,0 @@ - - -#include "displays/st7789v.h" - -void _154a_init_seq(void) { - // most recent manual: https://www.newhavendisplay.com/app_notes/ILI9341.pdf - // TEON: Tearing Effect Line On; V-blanking only - CMD(0x35); - DATA(0x00); - - // COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits - // input) - CMD(0x3A); - DATA(0x55); - - // Display Function Control: gate scan direction 319 -> 0 - CMD(0xB6); - DATA(0x0A); - DATA(0xC2); - DATA(0x27); - DATA(0x00); - - // Interface Control: XOR BGR as ST7789V does - CMD(0xF6); - DATA(0x09); - DATA(0x30); - DATA(0x00); - - // the above config is the most important and definitely necessary - - CMD(0xCF); - DATA(0x00); - DATA(0xC1); - DATA(0x30); - - CMD(0xED); - DATA(0x64); - DATA(0x03); - DATA(0x12); - DATA(0x81); - - CMD(0xE8); - DATA(0x85); - DATA(0x10); - DATA(0x7A); - - CMD(0xF7); - DATA(0x20); - - CMD(0xEA); - DATA(0x00); - DATA(0x00); - - // power control VRH[5:0] - CMD(0xC0); - DATA(0x23); - - // power control SAP[2:0] BT[3:0] - CMD(0xC1); - DATA(0x12); - - // vcm control 1 - CMD(0xC5); - DATA(0x60); - DATA(0x44); - - // vcm control 2 - CMD(0xC7); - DATA(0x8A); - - // framerate - CMD(0xB1); - DATA(0x00); - DATA(0x18); - - // 3 gamma func disable - CMD(0xF2); - DATA(0x00); - - // gamma curve 1 - CMD(0xE0); - DATA(0x0F); - DATA(0x2F); - DATA(0x2C); - DATA(0x0B); - DATA(0x0F); - DATA(0x09); - DATA(0x56); - DATA(0xD9); - DATA(0x4A); - DATA(0x0B); - DATA(0x14); - DATA(0x05); - DATA(0x0C); - DATA(0x06); - DATA(0x00); - - // gamma curve 2 - CMD(0xE1); - DATA(0x00); - DATA(0x10); - DATA(0x13); - DATA(0x04); - DATA(0x10); - DATA(0x06); - DATA(0x25); - DATA(0x26); - DATA(0x3B); - DATA(0x04); - DATA(0x0B); - DATA(0x0A); - DATA(0x33); - DATA(0x39); - DATA(0x0F); -} diff --git a/core/embed/trezorhal/stm32f4/displays/panels/154a.h b/core/embed/trezorhal/stm32f4/displays/panels/154a.h deleted file mode 100644 index e9e6d66819..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/154a.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _154A_H_ -#define _154A_H_ - -// ILI9341 IC controller - -void _154a_init_seq(void); - -#endif diff --git a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.c b/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.c deleted file mode 100644 index 7d1c878fc0..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.c +++ /dev/null @@ -1,82 +0,0 @@ - -#include "displays/st7789v.h" - -void lx154a2411_gamma(void) { - // positive voltage correction - CMD(0xE0); - DATA(0xD0); - DATA(0x03); - DATA(0x08); - DATA(0x0E); - DATA(0x11); - DATA(0x2B); - DATA(0x3B); - DATA(0x44); - DATA(0x4C); - DATA(0x2B); - DATA(0x16); - DATA(0x15); - DATA(0x1E); - DATA(0x21); - - // negative voltage correction - CMD(0xE1); - DATA(0xD0); - DATA(0x03); - DATA(0x08); - DATA(0x0E); - DATA(0x11); - DATA(0x2B); - DATA(0x3B); - DATA(0x54); - DATA(0x4C); - DATA(0x2B); - DATA(0x16); - DATA(0x15); - DATA(0x1E); - DATA(0x21); -} - -void lx154a2411_init_seq(void) { - // most recent manual: - // https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdf - // TEON: Tearing Effect Line On; V-blanking only - CMD(0x35); - DATA(0x00); - - // COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits - // input) - CMD(0x3A); - DATA(0x55); - - // CMD2EN: Commands in command table 2 can be executed when EXTC level is Low - CMD(0xDF); - DATA(0x5A); - DATA(0x69); - DATA(0x02); - DATA(0x01); - - // LCMCTRL: LCM Control: XOR RGB setting - CMD(0xC0); - DATA(0x20); - - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is gate 80.; - // gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - - // INVOFF (20h): Display Inversion Off - // INVON (21h): Display Inversion On - CMD(0x20); - - // the above config is the most important and definitely necessary - - // PWCTRL1: Power Control 1 - CMD(0xD0); - DATA(0xA4); - DATA(0xA1); - - lx154a2411_gamma(); -} diff --git a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.h b/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.h deleted file mode 100644 index a785ca6506..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2411.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LX154A2411_H_ -#define LX154A2411_H_ - -// ST7789_V IC controller -void lx154a2411_gamma(void); -void lx154a2411_init_seq(void); - -#endif diff --git a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.c b/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.c deleted file mode 100644 index 9a632fd684..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.c +++ /dev/null @@ -1,148 +0,0 @@ - -#include "display.h" -#include "displays/st7789v.h" -#include "touch.h" - -void lx154a2422_gamma(void) { - // positive voltage correction - CMD(0xE0); - DATA(0xD0); - DATA(0x0A); - DATA(0x10); - DATA(0x0A); - DATA(0x0A); - DATA(0x26); - DATA(0x36); - DATA(0x34); - DATA(0x4D); - DATA(0x18); - DATA(0x13); - DATA(0x14); - DATA(0x2F); - DATA(0x34); - - // negative voltage correction - CMD(0xE1); - DATA(0xD0); - DATA(0x0A); - DATA(0x10); - DATA(0x0A); - DATA(0x09); - DATA(0x26); - DATA(0x36); - DATA(0x53); - DATA(0x4C); - DATA(0x18); - DATA(0x14); - DATA(0x14); - DATA(0x2F); - DATA(0x34); -} - -void lx154a2422_init_seq(void) { - // most recent manual: - // https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdf - // TEON: Tearing Effect Line On; V-blanking only - CMD(0x35); - DATA(0x00); - - // COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits - // input) - CMD(0x3A); - DATA(0x55); - - // CMD2EN: Commands in command table 2 can be executed when EXTC level is Low - CMD(0xDF); - DATA(0x5A); - DATA(0x69); - DATA(0x02); - DATA(0x01); - - // LCMCTRL: LCM Control: XOR RGB setting - CMD(0xC0); - DATA(0x20); - - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is gate 80.; - // gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - - // INVOFF (20h): Display Inversion Off - // INVON (21h): Display Inversion On - CMD(0x21); - - // the above config is the most important and definitely necessary - - // PWCTRL1: Power Control 1 - CMD(0xD0); - DATA(0xA4); - DATA(0xA1); - - lx154a2422_gamma(); -} - -void lx154a2422_rotate(int degrees, display_padding_t* padding) { - uint16_t shift = 0; - char BX = 0, BY = 0; - -#define RGB (1 << 3) -#define ML (1 << 4) // vertical refresh order -#define MH (1 << 2) // horizontal refresh order -#define MV (1 << 5) -#define MX (1 << 6) -#define MY (1 << 7) - // MADCTL: Memory Data Access Control - reference: - // section 8.12 in the ST7789V manual - uint8_t display_command_parameter = 0; - switch (degrees) { - case 0: - display_command_parameter = 0; - BY = 0; - break; - case 90: - display_command_parameter = MV | MX | MH | ML; - BX = 1; - shift = 1; - break; - case 180: - display_command_parameter = MX | MY | MH | ML; - BY = 0; - shift = 1; - break; - case 270: - display_command_parameter = MV | MY; - BX = 1; - break; - } - - CMD(0x36); - DATA(display_command_parameter); - - if (shift) { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x00); - DATA(0x11); - } else { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - } - - // reset the column and page extents - display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - - padding->x = BX ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; - padding->y = BY ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; -} - -uint32_t lx154a2422_transform_touch_coords(uint16_t x, uint16_t y) { - return touch_pack_xy(x, y); -} diff --git a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.h b/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.h deleted file mode 100644 index 73687a58a3..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/lx154a2422.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef LX154A2422_H_ -#define LX154A2422_H_ - -#include "displays/st7789v.h" - -void lx154a2422_init_seq(void); -void lx154a2422_gamma(void); -void lx154a2422_rotate(int degrees, display_padding_t* padding); -uint32_t lx154a2422_transform_touch_coords(uint16_t x, uint16_t y); - -#endif diff --git a/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.c b/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.c deleted file mode 100644 index 179e3018f9..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.c +++ /dev/null @@ -1,158 +0,0 @@ -#include "display.h" -#include "displays/st7789v.h" - -void tf15411a_init_seq(void) { - // Inter Register Enable1 - CMD(0xFE); - - // Inter Register Enable2 - CMD(0xEF); - - // TEON: Tearing Effect Line On; V-blanking only - CMD(0x35); - DATA(0x00); - - // COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits - // input) - CMD(0x3A); - DATA(0x55); - - // Frame Rate - // CMD(0xE8); DATA(0x12); DATA(0x00); - - // Power Control 2 - CMD(0xC3); - DATA(0x27); - - // Power Control 3 - CMD(0xC4); - DATA(0x18); - - // Power Control 4 - CMD(0xC9); - DATA(0x1F); - - CMD(0xC5); - DATA(0x0F); - - CMD(0xC6); - DATA(0x00); - - CMD(0xC7); - DATA(0x10); - - CMD(0xC8); - DATA(0x01); - - CMD(0xFF); - DATA(0x62); - - CMD(0x99); - DATA(0x3E); - - CMD(0x9D); - DATA(0x4B); - - CMD(0x8E); - DATA(0x0F); - - // SET_GAMMA1 - CMD(0xF0); - DATA(0x8F); - DATA(0x1B); - DATA(0x05); - DATA(0x06); - DATA(0x07); - DATA(0x42); - - // SET_GAMMA3 - CMD(0xF2); - DATA(0x5C); - DATA(0x1F); - DATA(0x12); - DATA(0x10); - DATA(0x07); - DATA(0x43); - - // SET_GAMMA2 - CMD(0xF1); - DATA(0x59); - DATA(0xCF); - DATA(0xCF); - DATA(0x35); - DATA(0x37); - DATA(0x8F); - - // SET_GAMMA4 - CMD(0xF3); - DATA(0x58); - DATA(0xCF); - DATA(0xCF); - DATA(0x35); - DATA(0x37); - DATA(0x8F); -} - -void tf15411a_rotate(int degrees, display_padding_t* padding) { - uint16_t shift = 0; - char BX = 0, BY = 0; - -#define RGB (1 << 3) -#define ML (1 << 4) // vertical refresh order -#define MH (1 << 2) // horizontal refresh order -#define MV (1 << 5) -#define MX (1 << 6) -#define MY (1 << 7) - // MADCTL: Memory Data Access Control - reference: - // section 9.3 in the ILI9341 manual - // section 6.2.18 in the GC9307 manual - // section 8.12 in the ST7789V manual - uint8_t display_command_parameter = 0; - switch (degrees) { - case 0: - display_command_parameter = 0; - BY = 1; - break; - case 90: - display_command_parameter = MV | MX | MH | ML; - BX = 0; - shift = 1; - break; - case 180: - display_command_parameter = MX | MY | MH | ML; - BY = 1; - shift = 1; - break; - case 270: - display_command_parameter = MV | MY; - BX = 0; - break; - } - - display_command_parameter ^= RGB | MY; // XOR RGB and MY settings - - CMD(0x36); - DATA(display_command_parameter); - - if (shift) { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x00); - DATA(0x11); - } else { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - } - - // reset the column and page extents - display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - - padding->x = BX ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; - padding->y = BY ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; -} diff --git a/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.h b/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.h deleted file mode 100644 index fb5dd84e17..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/panels/tf15411a.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef TF15411A_H_ -#define TF15411A_H_ - -// GC9307 IC controller - -void tf15411a_init_seq(void); -void tf15411a_rotate(int degrees, display_padding_t* padding); - -#endif diff --git a/core/embed/trezorhal/stm32f4/displays/st7789v.c b/core/embed/trezorhal/stm32f4/displays/st7789v.c deleted file mode 100644 index 47c98c4972..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/st7789v.c +++ /dev/null @@ -1,769 +0,0 @@ -/* - * 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 . - */ - -#include -#include - -#include "backlight_pwm.h" -#include "display.h" -#include "irq.h" -#include "memzero.h" -#include "st7789v.h" - -#ifdef TREZOR_MODEL_T -#include "displays/panels/154a.h" -#include "displays/panels/lx154a2411.h" -#include "displays/panels/lx154a2422.h" -#include "displays/panels/tf15411a.h" -#else -#include "displays/panels/lx154a2482.h" -#endif - -// 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. -const volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS = 1; - -#ifndef FMC_BANK1 -#define FMC_BANK1 0x60000000U -#endif - -#define DISPLAY_MEMORY_BASE FMC_BANK1 -#define DISPLAY_MEMORY_PIN 16 -#ifdef DISPLAY_I8080_16BIT_DW -#define DISPLAY_ADDR_SHIFT 2 -#elif DISPLAY_I8080_8BIT_DW -#define DISPLAY_ADDR_SHIFT 1 -#endif - -__IO DISP_MEM_TYPE *const DISPLAY_CMD_ADDRESS = - (__IO DISP_MEM_TYPE *const)((uint32_t)DISPLAY_MEMORY_BASE); -__IO DISP_MEM_TYPE *const DISPLAY_DATA_ADDRESS = - (__IO DISP_MEM_TYPE *const)((uint32_t)DISPLAY_MEMORY_BASE | - (DISPLAY_ADDR_SHIFT << DISPLAY_MEMORY_PIN)); - -#ifdef FRAMEBUFFER -#ifndef STM32U5 -#error Framebuffer only supported on STM32U5 for now -#endif - -#ifndef BOARDLOADER -#include "bg_copy.h" -#endif - -#define DATA_TRANSFER(X) \ - DATA((X) & 0xFF); \ - DATA((X) >> 8) - -__attribute__((section(".fb1"))) -ALIGN_32BYTES(static uint16_t PhysFrameBuffer0[DISPLAY_RESX * DISPLAY_RESY]); -__attribute__((section(".fb2"))) -ALIGN_32BYTES(static uint16_t PhysFrameBuffer1[DISPLAY_RESX * DISPLAY_RESY]); - -__attribute__(( - section(".framebuffer_select"))) static uint32_t act_frame_buffer = 0; - -#ifndef BOARDLOADER -static bool pending_fb_switch = false; -#endif - -static uint16_t window_x0 = 0; -static uint16_t window_y0 = 0; -static uint16_t window_x1 = 0; -static uint16_t window_y1 = 0; -static uint16_t cursor_x = 0; -static uint16_t cursor_y = 0; - -#else -#define DATA_TRANSFER(X) PIXELDATA(X) -#endif - -// section "9.1.3 RDDID (04h): Read Display ID" -// of ST7789V datasheet -#define DISPLAY_ID_ST7789V 0x858552U - -// section "6.2.1. Read display identification information (04h)" -// of GC9307 datasheet -#define DISPLAY_ID_GC9307 0x009307U - -// section "8.3.23 Read ID4 (D3h)" -// of ILI9341V datasheet -#define DISPLAY_ID_ILI9341V 0x009341U - -static int DISPLAY_ORIENTATION = -1; -static display_padding_t DISPLAY_PADDING = {0}; - -void display_pixeldata_dirty(void) {} - -#ifdef DISPLAY_IDENTIFY - -static uint32_t read_display_id(uint8_t command) { - volatile uint8_t c = 0; - uint32_t id = 0; - CMD(command); - c = *DISPLAY_DATA_ADDRESS; // first returned value is a dummy value and - // should be discarded - c = *DISPLAY_DATA_ADDRESS; - id |= (c << 16); - c = *DISPLAY_DATA_ADDRESS; - id |= (c << 8); - c = *DISPLAY_DATA_ADDRESS; - id |= c; - return id; -} - -static uint32_t display_identify(void) { - static uint32_t id = 0x000000U; - static char id_set = 0; - - if (id_set) return id; // return if id has been already set - - id = read_display_id(0x04); // RDDID: Read Display ID - // the default RDDID for ILI9341 should be 0x8000. - // some display modules return 0x0. - // the ILI9341 has an extra id, let's check it here. - if ((id != DISPLAY_ID_ST7789V) && - (id != DISPLAY_ID_GC9307)) { // if not ST7789V and not GC9307 - uint32_t id4 = read_display_id(0xD3); // Read ID4 - if (id4 == DISPLAY_ID_ILI9341V) { // definitely found a ILI9341 - id = id4; - } - } - id_set = 1; - return id; -} -#else -static uint32_t display_identify(void) { return DISPLAY_ID_ST7789V; } -#endif - -bool display_is_inverted() { - bool inv_on = false; - uint32_t id = display_identify(); - if (id == DISPLAY_ID_ST7789V) { - volatile uint8_t c = 0; - CMD(0x09); // read display status - c = *DISPLAY_DATA_ADDRESS; // don't care - c = *DISPLAY_DATA_ADDRESS; // don't care - c = *DISPLAY_DATA_ADDRESS; // don't care - c = *DISPLAY_DATA_ADDRESS; - if (c & 0x20) { - inv_on = true; - } - c = *DISPLAY_DATA_ADDRESS; // don't care - } - - return inv_on; -} - -void display_reset_state() {} - -static void __attribute__((unused)) display_sleep(void) { - uint32_t id = display_identify(); - if ((id == DISPLAY_ID_ILI9341V) || (id == DISPLAY_ID_GC9307) || - (id == DISPLAY_ID_ST7789V)) { - CMD(0x28); // DISPOFF: Display Off - CMD(0x10); // SLPIN: Sleep in - HAL_Delay(5); // need to wait 5 milliseconds after "sleep in" before - // sending any new commands - } -} - -static void display_unsleep(void) { - uint32_t id = display_identify(); - if ((id == DISPLAY_ID_ILI9341V) || (id == DISPLAY_ID_GC9307) || - (id == DISPLAY_ID_ST7789V)) { - CMD(0x11); // SLPOUT: Sleep Out - HAL_Delay(5); // need to wait 5 milliseconds after "sleep out" before - // sending any new commands - CMD(0x29); // DISPON: Display On - } -} - -void panel_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - x0 += DISPLAY_PADDING.x; - x1 += DISPLAY_PADDING.x; - y0 += DISPLAY_PADDING.y; - y1 += DISPLAY_PADDING.y; - uint32_t id = display_identify(); - if ((id == DISPLAY_ID_ILI9341V) || (id == DISPLAY_ID_GC9307) || - (id == DISPLAY_ID_ST7789V)) { - CMD(0x2A); - DATA(x0 >> 8); - DATA(x0 & 0xFF); - DATA(x1 >> 8); - DATA(x1 & 0xFF); // column addr set - CMD(0x2B); - DATA(y0 >> 8); - DATA(y0 & 0xFF); - DATA(y1 >> 8); - DATA(y1 & 0xFF); // row addr set - CMD(0x2C); - } -} - -int display_orientation(int degrees) { - if (degrees != DISPLAY_ORIENTATION) { - if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) { - DISPLAY_ORIENTATION = degrees; - - panel_set_window(0, 0, MAX_DISPLAY_RESX - 1, MAX_DISPLAY_RESY - 1); -#ifdef FRAMEBUFFER - memzero(PhysFrameBuffer1, sizeof(PhysFrameBuffer1)); - memzero(PhysFrameBuffer0, sizeof(PhysFrameBuffer0)); -#endif - for (uint32_t i = 0; i < MAX_DISPLAY_RESX * MAX_DISPLAY_RESY; i++) { - // 2 bytes per pixel because we're using RGB 5-6-5 format - DATA_TRANSFER(0x0000); - } -#ifdef TREZOR_MODEL_T - uint32_t id = display_identify(); - if (id == DISPLAY_ID_GC9307) { - tf15411a_rotate(degrees, &DISPLAY_PADDING); - } else { - lx154a2422_rotate(degrees, &DISPLAY_PADDING); - } -#else - lx154a2482_rotate(degrees, &DISPLAY_PADDING); -#endif - panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - } - } - return DISPLAY_ORIENTATION; -} - -int display_get_orientation(void) { return DISPLAY_ORIENTATION; } - -static inline uint32_t is_mode_handler(void) { - uint32_t r0; - __asm__ volatile("mrs %0, ipsr" : "=r"(r0)); - return (r0 & 0x1FF) != 0; -} - -int display_backlight(int val) { -#ifdef FRAMEBUFFER -#ifndef BOARDLOADER - // wait for DMA transfer to finish before changing backlight - // so that we know that panel has current data - if (backlight_pwm_get() != val && !is_mode_handler()) { - bg_copy_wait(); - } -#endif -#endif - - return backlight_pwm_set(val); -} - -void display_init_seq(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. - // my dev display module ties display reset and touch panel reset together. - // keeping this low for max(display_reset_time, ctpm_reset_time) aids - // development and does not hurt. - HAL_Delay(10); - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_SET); // LCD_RST/PC14 - // max wait time for hardware reset is 120 milliseconds - // (experienced display flakiness using only 5ms wait before sending commands) - HAL_Delay(120); - - // identify the controller we will communicate with -#ifdef TREZOR_MODEL_T - uint32_t id = display_identify(); - if (id == DISPLAY_ID_GC9307) { - tf15411a_init_seq(); - } else if (id == DISPLAY_ID_ST7789V) { - if (DISPLAY_ST7789V_INVERT_COLORS) { - lx154a2422_init_seq(); - } else { - lx154a2411_init_seq(); - } - } else if (id == DISPLAY_ID_ILI9341V) { - _154a_init_seq(); - } -#else - lx154a2482_init_seq(); -#endif - - display_unsleep(); -} - -void display_setup_fmc(void) { - // Reference UM1725 "Description of STM32F4 HAL and LL drivers", - // section 64.2.1 "How to use this driver" - SRAM_HandleTypeDef external_display_data_sram = {0}; - external_display_data_sram.Instance = FMC_NORSRAM_DEVICE; - external_display_data_sram.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - external_display_data_sram.Init.NSBank = FMC_NORSRAM_BANK1; - external_display_data_sram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - external_display_data_sram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; -#ifdef DISPLAY_I8080_16BIT_DW - external_display_data_sram.Init.MemoryDataWidth = - FMC_NORSRAM_MEM_BUS_WIDTH_16; -#elif DISPLAY_I8080_8BIT_DW - external_display_data_sram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8; -#endif - external_display_data_sram.Init.BurstAccessMode = - FMC_BURST_ACCESS_MODE_DISABLE; - external_display_data_sram.Init.WaitSignalPolarity = - FMC_WAIT_SIGNAL_POLARITY_LOW; - external_display_data_sram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - external_display_data_sram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - external_display_data_sram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - external_display_data_sram.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - external_display_data_sram.Init.AsynchronousWait = - FMC_ASYNCHRONOUS_WAIT_DISABLE; - external_display_data_sram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; - external_display_data_sram.Init.ContinuousClock = - FMC_CONTINUOUS_CLOCK_SYNC_ONLY; - external_display_data_sram.Init.PageSize = FMC_PAGE_SIZE_NONE; - -#ifdef STM32F4 - // reference RM0090 section 37.5 Table 259, 37.5.4, Mode 1 SRAM, and 37.5.6 - FMC_NORSRAM_TimingTypeDef normal_mode_timing = {0}; - normal_mode_timing.AddressSetupTime = 5; - normal_mode_timing.AddressHoldTime = 1; // don't care - normal_mode_timing.DataSetupTime = 6; - normal_mode_timing.BusTurnAroundDuration = 0; // don't care - normal_mode_timing.CLKDivision = 2; // don't care - normal_mode_timing.DataLatency = 2; // don't care - normal_mode_timing.AccessMode = FMC_ACCESS_MODE_A; - - HAL_SRAM_Init(&external_display_data_sram, &normal_mode_timing, NULL); - -#else - external_display_data_sram.Init.ExtendedMode = FMC_EXTENDED_MODE_ENABLE; - - FMC_NORSRAM_TimingTypeDef normal_mode_timing = {0}; - normal_mode_timing.AddressSetupTime = 15; - normal_mode_timing.AddressHoldTime = 1; // don't care - normal_mode_timing.DataSetupTime = 11; - normal_mode_timing.BusTurnAroundDuration = 0; // don't care - normal_mode_timing.CLKDivision = 2; // don't care - normal_mode_timing.DataLatency = 2; // don't care - normal_mode_timing.DataHoldTime = 0; - normal_mode_timing.AccessMode = FMC_ACCESS_MODE_A; - - FMC_NORSRAM_TimingTypeDef ext_mode_timing = {0}; - ext_mode_timing.AddressSetupTime = 4; - ext_mode_timing.AddressHoldTime = 1; // don't care - ext_mode_timing.DataSetupTime = 5; - ext_mode_timing.BusTurnAroundDuration = 0; // don't care - ext_mode_timing.CLKDivision = 2; // don't care - ext_mode_timing.DataLatency = 2; // don't care - ext_mode_timing.DataHoldTime = 3; - ext_mode_timing.AccessMode = FMC_ACCESS_MODE_A; - - HAL_SRAM_Init(&external_display_data_sram, &normal_mode_timing, - &ext_mode_timing); - -#endif -} - -#ifdef FRAMEBUFFER -void display_setup_te_interrupt(void) { -#ifdef DISPLAY_TE_PIN - EXTI_HandleTypeDef EXTI_Handle = {0}; - EXTI_ConfigTypeDef EXTI_Config = {0}; - EXTI_Config.GPIOSel = DISPLAY_TE_INTERRUPT_GPIOSEL; - EXTI_Config.Line = DISPLAY_TE_INTERRUPT_EXTI_LINE; - EXTI_Config.Mode = EXTI_MODE_INTERRUPT; - EXTI_Config.Trigger = EXTI_TRIGGER_RISING; - HAL_EXTI_SetConfigLine(&EXTI_Handle, &EXTI_Config); - - // setup interrupt for tearing effect pin - NVIC_SetPriority(DISPLAY_TE_INTERRUPT_NUM, IRQ_PRI_NORMAL); -#endif -} -#endif - -void display_init_all(void) { - // init peripherals - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_FMC_CLK_ENABLE(); - - backlight_pwm_init(BACKLIGHT_RESET); - -#ifdef STM32F4 -#define DISPLAY_GPIO_SPEED GPIO_SPEED_FREQ_VERY_HIGH -#else -#define DISPLAY_GPIO_SPEED GPIO_SPEED_FREQ_LOW -#endif - - GPIO_InitTypeDef GPIO_InitStructure = {0}; - - // LCD_RST/PC14 - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = DISPLAY_GPIO_SPEED; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = GPIO_PIN_14; - // default to keeping display in reset - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - -#ifdef DISPLAY_TE_PIN - // LCD_FMARK (tearing effect) - GPIO_InitStructure.Mode = GPIO_MODE_INPUT; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = DISPLAY_GPIO_SPEED; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = DISPLAY_TE_PIN; - HAL_GPIO_Init(DISPLAY_TE_PORT, &GPIO_InitStructure); -#endif - - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = DISPLAY_GPIO_SPEED; - GPIO_InitStructure.Alternate = GPIO_AF12_FMC; - // LCD_CS/PD7 LCD_RS/PD11 LCD_RD/PD4 LCD_WR/PD5 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_11 | GPIO_PIN_4 | GPIO_PIN_5; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D0/PD14 LCD_D1/PD15 LCD_D2/PD0 LCD_D3/PD1 - GPIO_InitStructure.Pin = GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D4/PE7 LCD_D5/PE8 LCD_D6/PE9 LCD_D7/PE10 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); -#ifdef DISPLAY_I8080_16BIT_DW - // LCD_D8/PE11 LCD_D9/PE12 LCD_D10/PE13 LCD_D11/PE14 - GPIO_InitStructure.Pin = - GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); - // LCD_D12/PE15 - GPIO_InitStructure.Pin = GPIO_PIN_15; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); - // LCD_D13/PD8 LCD_D14/PD9 LCD_D15/PD10 - GPIO_InitStructure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); -#endif - - display_setup_fmc(); - - display_init_seq(); - - display_set_little_endian(); - - panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - -#ifdef FRAMEBUFFER - display_setup_te_interrupt(); -#endif -} - -void display_reinit(void) { - // reinitialize FMC to set correct timing, have to do this in reinit because - // boardloader is fixed. - display_setup_fmc(); - - // important for model T as this is not set in boardloader - display_set_little_endian(); - - backlight_pwm_init(BACKLIGHT_RETAIN); - -#ifdef TREZOR_MODEL_T - uint32_t id = display_identify(); - if (id == DISPLAY_ID_ST7789V && display_is_inverted()) { - // newest TT display - set proper gamma - lx154a2422_gamma(); - } else if (id == DISPLAY_ID_ST7789V) { - lx154a2411_gamma(); - } -#else - lx154a2482_init_seq(); -#endif - - DISPLAY_ORIENTATION = 0; - panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - -#ifdef FRAMEBUFFER - display_setup_te_interrupt(); -#endif -} - -void display_set_little_endian(void) { - uint32_t id = display_identify(); - if (id == DISPLAY_ID_GC9307) { - // CANNOT SET ENDIAN FOR GC9307 - } else if (id == DISPLAY_ID_ST7789V) { - CMD(0xB0); - DATA(0x00); - DATA(0xF8); - } else if (id == DISPLAY_ID_ILI9341V) { - // Interface Control: XOR BGR as ST7789V does - CMD(0xF6); - DATA(0x09); - DATA(0x30); - DATA(0x20); - } -} - -void display_set_big_endian(void) { - uint32_t id = display_identify(); - if (id == DISPLAY_ID_GC9307) { - // CANNOT SET ENDIAN FOR GC9307 - } else if (id == DISPLAY_ID_ST7789V) { - CMD(0xB0); - DATA(0x00); - DATA(0xF0); - } else if (id == DISPLAY_ID_ILI9341V) { - // Interface Control: XOR BGR as ST7789V does - CMD(0xF6); - DATA(0x09); - DATA(0x30); - DATA(0x00); - } -} - -const char *display_save(const char *prefix) { return NULL; } - -void display_clear_save(void) {} - -#ifdef FRAMEBUFFER - -void display_pixeldata(uint16_t c) { - uint16_t *address = 0; - - if (act_frame_buffer == 0) { - address = PhysFrameBuffer1; - } else { - address = PhysFrameBuffer0; - } - - /* Get the rectangle start address */ - address += cursor_y * DISPLAY_RESX + cursor_x; - - *address = c; - - cursor_x++; - if (cursor_x > window_x1) { - cursor_x = window_x0; - cursor_y++; - } - if (cursor_y > window_y1) { - cursor_y = window_y0; - } -} - -void display_sync(void) {} - -#ifndef BOARDLOADER -void DISPLAY_TE_INTERRUPT_HANDLER(void) { - NVIC_DisableIRQ(DISPLAY_TE_INTERRUPT_NUM); - - if (act_frame_buffer == 1) { - bg_copy_start_const_out_8((uint8_t *)PhysFrameBuffer1, - (uint8_t *)DISPLAY_DATA_ADDRESS, - DISPLAY_RESX * DISPLAY_RESY * 2, NULL); - - } else { - bg_copy_start_const_out_8((uint8_t *)PhysFrameBuffer0, - (uint8_t *)DISPLAY_DATA_ADDRESS, - DISPLAY_RESX * DISPLAY_RESY * 2, NULL); - } - - pending_fb_switch = false; - __HAL_GPIO_EXTI_CLEAR_FLAG(DISPLAY_TE_PIN); -} - -static void wait_for_fb_switch(void) { - while (pending_fb_switch) { - __WFI(); - } - bg_copy_wait(); -} -#endif - -static void copy_fb_to_display(uint16_t *fb) { - for (int i = 0; i < DISPLAY_RESX * DISPLAY_RESY; i++) { - // 2 bytes per pixel because we're using RGB 5-6-5 format - DATA_TRANSFER(fb[i]); - } -} - -static void switch_fb_manually(void) { - // sync with the panel refresh - while (GPIO_PIN_SET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN)) { - } - while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN)) { - } - - if (act_frame_buffer == 0) { - act_frame_buffer = 1; - copy_fb_to_display(PhysFrameBuffer1); - memcpy(PhysFrameBuffer0, PhysFrameBuffer1, sizeof(PhysFrameBuffer1)); - - } else { - act_frame_buffer = 0; - copy_fb_to_display(PhysFrameBuffer0); - memcpy(PhysFrameBuffer1, PhysFrameBuffer0, sizeof(PhysFrameBuffer1)); - } -} - -#ifndef BOARDLOADER -static void switch_fb_in_backround(void) { - if (act_frame_buffer == 0) { - act_frame_buffer = 1; - - memcpy(PhysFrameBuffer0, PhysFrameBuffer1, sizeof(PhysFrameBuffer1)); - - pending_fb_switch = true; - __HAL_GPIO_EXTI_CLEAR_FLAG(DISPLAY_TE_PIN); - NVIC_EnableIRQ(DISPLAY_TE_INTERRUPT_NUM); - } else { - act_frame_buffer = 0; - memcpy(PhysFrameBuffer1, PhysFrameBuffer0, sizeof(PhysFrameBuffer1)); - - pending_fb_switch = true; - __HAL_GPIO_EXTI_CLEAR_FLAG(DISPLAY_TE_PIN); - NVIC_EnableIRQ(DISPLAY_TE_INTERRUPT_NUM); - } -} -#endif - -void display_refresh(void) { -#ifndef BOARDLOADER - wait_for_fb_switch(); - - if (is_mode_handler()) { - switch_fb_manually(); - } else { - switch_fb_in_backround(); - } -#else - switch_fb_manually(); -#endif -} - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - window_x0 = x0; - window_y0 = y0; - window_x1 = x1; - window_y1 = y1; - cursor_x = x0; - cursor_y = y0; -} - -uint8_t *display_get_wr_addr(void) { - uint32_t address = 0; - - if (act_frame_buffer == 0) { - address = (uint32_t)PhysFrameBuffer1; - } else { - address = (uint32_t)PhysFrameBuffer0; - } - - /* Get the rectangle start address */ - address = (address + (2 * (cursor_y * DISPLAY_RESX + cursor_x))); - - return (uint8_t *)address; -} - -uint32_t *display_get_fb_addr(void) { - uint32_t address = 0; - - if (act_frame_buffer == 0) { - address = (uint32_t)PhysFrameBuffer1; - } else { - address = (uint32_t)PhysFrameBuffer0; - } - - return (uint32_t *)address; -} -uint16_t display_get_window_width(void) { return window_x1 - window_x0 + 1; } - -uint16_t display_get_window_height(void) { return window_y1 - window_y0 + 1; } - -void display_shift_window(uint16_t pixels) { - uint16_t w = display_get_window_width(); - uint16_t h = display_get_window_height(); - - uint16_t line_rem = w - (cursor_x - window_x0); - - if (pixels < line_rem) { - cursor_x += pixels; - return; - } - - // start of next line - pixels = pixels - line_rem; - cursor_x = window_x0; - cursor_y++; - - // add the rest of pixels - cursor_y = window_y0 + (((cursor_y - window_y0) + (pixels / w)) % h); - cursor_x += pixels % w; -} - -uint16_t display_get_window_offset(void) { - return DISPLAY_RESX - display_get_window_width(); -} - -void display_efficient_clear(void) { - memzero(PhysFrameBuffer1, sizeof(PhysFrameBuffer1)); - memzero(PhysFrameBuffer0, sizeof(PhysFrameBuffer0)); -} - -void display_finish_actions(void) { -#ifndef BOARDLOADER - bg_copy_wait(); -#endif - backlight_pwm_deinit(BACKLIGHT_RETAIN); -} -#else -// NOT FRAMEBUFFER - -void display_pixeldata(uint16_t c) { PIXELDATA(c); } - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - panel_set_window(x0, y0, x1, y1); -} - -void display_sync(void) { -#ifdef DISPLAY_TE_PIN - uint32_t id = display_identify(); - if (id && (id != DISPLAY_ID_GC9307)) { - // synchronize with the panel synchronization signal - // in order to avoid visual tearing effects - while (GPIO_PIN_SET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN)) - ; - while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN)) - ; - } -#endif -} - -void display_refresh(void) {} - -uint8_t *display_get_wr_addr(void) { return (uint8_t *)DISPLAY_DATA_ADDRESS; } - -uint16_t display_get_window_offset(void) { return 0; } - -void display_shift_window(uint16_t pixels) {} - -void display_finish_actions(void) { - backlight_pwm_deinit(BACKLIGHT_RETAIN); -#ifdef TREZOR_MODEL_T - display_set_big_endian(); -#endif -} - -#endif diff --git a/core/embed/trezorhal/stm32f4/displays/st7789v.h b/core/embed/trezorhal/stm32f4/displays/st7789v.h deleted file mode 100644 index 38851867de..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/st7789v.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _ST7789V_H -#define _ST7789V_H - -#include -#include - -typedef struct { - uint16_t x; - uint16_t y; -} display_padding_t; - -// ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution -#define MAX_DISPLAY_RESX 240 -#define MAX_DISPLAY_RESY 320 -#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565 - -#ifdef DISPLAY_I8080_16BIT_DW -#define DISP_MEM_TYPE uint16_t -#elif DISPLAY_I8080_8BIT_DW -#define DISP_MEM_TYPE uint8_t -#else -#error "Unsupported display interface" -#endif - -#define DISP_MEM_TYPE uint8_t - -extern __IO DISP_MEM_TYPE *const DISPLAY_CMD_ADDRESS; -extern __IO DISP_MEM_TYPE *const DISPLAY_DATA_ADDRESS; - -#define CMD(X) (*DISPLAY_CMD_ADDRESS = (X)) -#define DATA(X) (*DISPLAY_DATA_ADDRESS = (X)) - -void display_set_little_endian(void); -void display_set_big_endian(void); -void display_set_slow_pwm(void); - -#ifdef FRAMEBUFFER -#define DISPLAY_FRAMEBUFFER_WIDTH DISPLAY_RESX -#define DISPLAY_FRAMEBUFFER_HEIGHT DISPLAY_RESY - -#define DISPLAY_EFFICIENT_CLEAR 1 - -static inline void display_pixel(uint8_t *fb, int16_t x, int16_t y, - uint16_t color) { - uint32_t p = 2 * (y * DISPLAY_FRAMEBUFFER_WIDTH + x); - *((uint16_t *)(fb + p)) = color; -} -void display_efficient_clear(void); - -#else - -#ifdef DISPLAY_I8080_16BIT_DW -#define PIXELDATA(X) DATA(X) -#elif DISPLAY_I8080_8BIT_DW -#define PIXELDATA(X) \ - DATA((X) & 0xFF); \ - DATA((X) >> 8) -#endif - -#endif - -#endif //_ST7789V_H diff --git a/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.c b/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.c deleted file mode 100644 index 18a1519065..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * 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 . - */ - -#include -#include - -#include "display.h" -#include "memzero.h" - -// FSMC/FMC Bank 1 - NOR/PSRAM 1 -#define DISPLAY_MEMORY_BASE 0x60000000 -#define DISPLAY_MEMORY_PIN 16 - -#define CMD(X) (*((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE))) = (X)) -#define ADDR \ - (*((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE | \ - (1 << DISPLAY_MEMORY_PIN))))) -#define DATA(X) (ADDR) = (X) - -static int DISPLAY_BACKLIGHT = -1; -static int DISPLAY_ORIENTATION = -1; -struct { - uint8_t RAM[DISPLAY_RESY / 8][DISPLAY_RESX]; - uint32_t row; - uint32_t col; - uint32_t window_x0; - uint32_t window_x1; - uint32_t window_y0; - uint32_t window_y1; -} DISPLAY_STATE; - -static void display_set_page_and_col(uint8_t page, uint8_t col) { - if (page < (DISPLAY_RESY / 8)) { - CMD(0xB0 | (page & 0xF)); - - if (col < DISPLAY_RESX) { - CMD(0x10 | ((col & 0x70) >> 4)); - CMD(0x00 | (col & 0x0F)); - } else { - // Reset column to start - CMD(0x10); - CMD(0x00); - } - } -} - -void display_pixeldata(uint16_t c) { - uint8_t data = DISPLAY_STATE.RAM[DISPLAY_STATE.row / 8][DISPLAY_STATE.col]; - - uint8_t bit = 1 << (DISPLAY_STATE.row % 8); - - // set to white if highest bits of all R, G, B values are set to 1 - // bin(10000 100000 10000) = hex(0x8410) - // otherwise set to black - if (c & 0x8410) { - data |= bit; - } else { - data &= ~bit; - } - - DISPLAY_STATE.RAM[DISPLAY_STATE.row / 8][DISPLAY_STATE.col] = data; - - DISPLAY_STATE.col++; - - if (DISPLAY_STATE.col > DISPLAY_STATE.window_x1) { - // next line - DISPLAY_STATE.col = DISPLAY_STATE.window_x0; - DISPLAY_STATE.row++; - - if (DISPLAY_STATE.row > DISPLAY_STATE.window_y1) { - // reached end of the window, go to start - DISPLAY_STATE.row = DISPLAY_STATE.window_y1; - } - - // set display to start of next line, sets also page, even if it stays on - // the same one - display_set_page_and_col(DISPLAY_STATE.row / 8, DISPLAY_STATE.col); - } -} - -void display_pixeldata_dirty(void) {} - -void display_reset_state(void) { - memzero(DISPLAY_STATE.RAM, sizeof(DISPLAY_STATE.RAM)); - DISPLAY_STATE.row = 0; - DISPLAY_STATE.col = 0; - DISPLAY_STATE.window_x0 = 0; - DISPLAY_STATE.window_x1 = DISPLAY_RESX - 1; - DISPLAY_STATE.window_y0 = 0; - DISPLAY_STATE.window_y1 = DISPLAY_RESY - 1; -} - -static void __attribute__((unused)) display_sleep(void) { - CMD(0xAE); // DISPOFF: Display Off - HAL_Delay(5); - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET); // Vpp disable -} - -static void display_unsleep(void) { - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET); // Vpp enable - HAL_Delay(100); // 100 ms mandatory wait - CMD(0xAF); // Display ON -} - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - if (x1 >= DISPLAY_RESX) { - x1 = DISPLAY_RESX - 1; - } - if (y1 >= DISPLAY_RESY) { - y1 = DISPLAY_RESY - 1; - } - - if (x0 < DISPLAY_RESX && x1 < DISPLAY_RESX && x0 <= x1 && y0 < DISPLAY_RESY && - y1 < DISPLAY_RESY && y0 <= y1) { - DISPLAY_STATE.window_x0 = x0; - DISPLAY_STATE.window_x1 = x1; - DISPLAY_STATE.window_y0 = y0; - DISPLAY_STATE.window_y1 = y1; - DISPLAY_STATE.row = y0; - DISPLAY_STATE.col = x0; - - display_set_page_and_col(DISPLAY_STATE.row / 8, DISPLAY_STATE.col); - } -} - -int display_orientation(int degrees) { - if (degrees != DISPLAY_ORIENTATION) { - if (degrees == 0 || degrees == 180) { - DISPLAY_ORIENTATION = degrees; - if (degrees == 0) { - // Set Segment Re-map: (A0H - A1H) - CMD(0xA1); - // Set COM Output Scan Direction - CMD(0xC8); - } - if (degrees == 180) { - // Set Segment Re-map: (A0H - A1H) - CMD(0xA0); - // Set COM Output Scan Direction - CMD(0xC0); - } - } - } - - return DISPLAY_ORIENTATION; -} - -int display_get_orientation(void) { return DISPLAY_ORIENTATION; } - -int display_backlight(int val) { - if (DISPLAY_BACKLIGHT != val && val >= 0 && val <= 255) { - DISPLAY_BACKLIGHT = val; - // Set Contrast Control Register: (Double Bytes Command) - CMD(0x81); - CMD(val & 0xFF); - } - return DISPLAY_BACKLIGHT; -} - -static void send_init_seq_SH1107(void) { - // Display OFF - CMD(0xAE); - - // Set Display Clock Divide Ratio/Oscillator Frequency: (Double Bytes Command) - CMD(0xD5); - // Divide ratio 0, Oscillator Frequency +0% - CMD(0x50); - - // Set Memory Addressing Mode - page addressing mode - CMD(0x20); - - // Set Contrast Control Register: (Double Bytes Command) - CMD(0x81); - CMD(0x8F); - - // Set DC-DC Setting: (Double Bytes Command) - CMD(0xAD); - CMD(0x8A); - - // Set Segment Re-map: (A0H - A1H) - // CMD(0xA0); - CMD(0xA1); - - // Set COM Output Scan Direction - CMD(0xC8); - // CMD(0xC0); - - // Set Display Start Line:(Double Bytes Command) - CMD(0xDC); - CMD(0x00); - - // Set Display Offset:(Double Bytes Command) - CMD(0xD3); - CMD(0x00); - - // Set Discharge / Pre-Charge Period (Double Bytes Command) - CMD(0xD9); - CMD(0x22); - - // Set VCOM Deselect Level - CMD(0xDB); - CMD(0x35); - - // Set Multiplex Ratio - CMD(0xA8); - CMD(0x7F); - - // Set Page - CMD(0xB0); - // Set Column - CMD(0x00); - CMD(0x10); - - // Set Entire Display Off - // to be clear, this command turns of the function - // which turns entire display on, but it does not clear - // the data in display RAM - CMD(0xA4); - - // Set Normal Display - CMD(0xA6); - - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET); // Vpp enable - - // Vpp stabilization period - HAL_Delay(100); - - display_set_window(0, 0, MAX_DISPLAY_RESX - 1, MAX_DISPLAY_RESY - 1); - for (int i = 0; i < DISPLAY_RESY; i++) { - for (int j = 0; j < DISPLAY_RESX; j++) { - display_pixeldata(0); - } - } - - // Display ON - CMD(0xAF); -} - -void display_init_seq(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. - // my dev display module ties display reset and touch panel reset together. - // keeping this low for max(display_reset_time, ctpm_reset_time) aids - // development and does not hurt. - HAL_Delay(10); - - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_SET); // LCD_RST/PC14 - // max wait time for hardware reset is 120 milliseconds - // (experienced display flakiness using only 5ms wait before sending commands) - HAL_Delay(120); - - send_init_seq_SH1107(); - - display_unsleep(); -} - -void display_init_all(void) { - // init peripherals - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_FMC_CLK_ENABLE(); - - GPIO_InitTypeDef GPIO_InitStructure = {0}; - - // LCD_RST/PC14 - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = GPIO_PIN_14; - // default to keeping display in reset - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); - HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); - - // VPP Enable - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLDOWN; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = GPIO_PIN_8; - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET); - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStructure.Alternate = GPIO_AF12_FMC; - // LCD_CS/PD7 LCD_RS/PD11 LCD_RD/PD4 LCD_WR/PD5 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_11 | GPIO_PIN_4 | GPIO_PIN_5; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D0/PD14 LCD_D1/PD15 LCD_D2/PD0 LCD_D3/PD1 - GPIO_InitStructure.Pin = GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); - // LCD_D4/PE7 LCD_D5/PE8 LCD_D6/PE9 LCD_D7/PE10 - GPIO_InitStructure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10; - HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); - - // Reference UM1725 "Description of STM32F4 HAL and LL drivers", - // section 64.2.1 "How to use this driver" - SRAM_HandleTypeDef external_display_data_sram = {0}; - external_display_data_sram.Instance = FMC_NORSRAM_DEVICE; - external_display_data_sram.Extended = FMC_NORSRAM_EXTENDED_DEVICE; - external_display_data_sram.Init.NSBank = FMC_NORSRAM_BANK1; - external_display_data_sram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; - external_display_data_sram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; - external_display_data_sram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8; - external_display_data_sram.Init.BurstAccessMode = - FMC_BURST_ACCESS_MODE_DISABLE; - external_display_data_sram.Init.WaitSignalPolarity = - FMC_WAIT_SIGNAL_POLARITY_LOW; - external_display_data_sram.Init.WrapMode = FMC_WRAP_MODE_DISABLE; - external_display_data_sram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; - external_display_data_sram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; - external_display_data_sram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; - external_display_data_sram.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; - external_display_data_sram.Init.AsynchronousWait = - FMC_ASYNCHRONOUS_WAIT_DISABLE; - external_display_data_sram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; - external_display_data_sram.Init.ContinuousClock = - FMC_CONTINUOUS_CLOCK_SYNC_ONLY; - external_display_data_sram.Init.PageSize = FMC_PAGE_SIZE_NONE; - - // reference RM0090 section 37.5 Table 259, 37.5.4, Mode 1 SRAM, and 37.5.6 - FMC_NORSRAM_TimingTypeDef normal_mode_timing = {0}; - normal_mode_timing.AddressSetupTime = 10; - normal_mode_timing.AddressHoldTime = 10; - normal_mode_timing.DataSetupTime = 10; - normal_mode_timing.BusTurnAroundDuration = 0; - normal_mode_timing.CLKDivision = 2; - normal_mode_timing.DataLatency = 2; - normal_mode_timing.AccessMode = FMC_ACCESS_MODE_A; - - HAL_SRAM_Init(&external_display_data_sram, &normal_mode_timing, NULL); - - display_init_seq(); -} - -void display_sync(void) {} - -void display_refresh(void) { - for (int y = 0; y < (DISPLAY_RESY / 8); y++) { - display_set_page_and_col(y, 0); - for (int x = 0; x < DISPLAY_RESX; x++) { - DATA(DISPLAY_STATE.RAM[y][x]); - } - } -} - -void display_reinit(void) {} - -const char *display_save(const char *prefix) { return NULL; } - -void display_clear_save(void) {} - -void display_finish_actions(void) {} diff --git a/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.h b/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.h deleted file mode 100644 index 07978207fb..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/ug-2828tswig01.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _UG_2828TSWIG01_H -#define _UG_2828TSWIG01_H - -#define MAX_DISPLAY_RESX 128 -#define MAX_DISPLAY_RESY 128 -#define DISPLAY_RESX 128 -#define DISPLAY_RESY 128 - -#endif //_UG_2828TSWIG01_H diff --git a/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.c b/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.c deleted file mode 100644 index c72173f217..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 . - */ - -#include -#include - -#include "display.h" - -#ifdef USE_CONSUMPTION_MASK -#include "consumption_mask.h" -#endif - -#define OLED_BUFSIZE (DISPLAY_RESX * DISPLAY_RESY / 8) -#define OLED_OFFSET(x, y) (OLED_BUFSIZE - 1 - (x) - ((y) / 8) * DISPLAY_RESX) -#define OLED_MASK(x, y) (1 << (7 - (y) % 8)) - -#define OLED_SETCONTRAST 0x81 -#define OLED_DISPLAYALLON_RESUME 0xA4 -#define OLED_DISPLAYALLON 0xA5 -#define OLED_NORMALDISPLAY 0xA6 -#define OLED_INVERTDISPLAY 0xA7 -#define OLED_DISPLAYOFF 0xAE -#define OLED_DISPLAYON 0xAF -#define OLED_SETDISPLAYOFFSET 0xD3 -#define OLED_SETCOMPINS 0xDA -#define OLED_SETVCOMDETECT 0xDB -#define OLED_SETDISPLAYCLOCKDIV 0xD5 -#define OLED_SETPRECHARGE 0xD9 -#define OLED_SETMULTIPLEX 0xA8 -#define OLED_SETLOWCOLUMN 0x00 -#define OLED_SETHIGHCOLUMN 0x10 -#define OLED_SETSTARTLINE 0x40 -#define OLED_MEMORYMODE 0x20 -#define OLED_COMSCANINC 0xC0 -#define OLED_COMSCANDEC 0xC8 -#define OLED_SEGREMAP 0xA0 -#define OLED_CHARGEPUMP 0x8D - -static int DISPLAY_BACKLIGHT = -1; -static int DISPLAY_ORIENTATION = -1; -static uint8_t OLED_BUFFER[OLED_BUFSIZE]; - -static struct { - struct { - uint16_t x, y; - } start; - struct { - uint16_t x, y; - } end; - struct { - uint16_t x, y; - } pos; -} PIXELWINDOW; - -static bool pixeldata_dirty_flag = true; - -void display_pixeldata(uint16_t c) { - if (PIXELWINDOW.pos.x <= PIXELWINDOW.end.x && - PIXELWINDOW.pos.y <= PIXELWINDOW.end.y) { - // set to white if highest bits of all R, G, B values are set to 1 - // bin(10000 100000 10000) = hex(0x8410) - // otherwise set to black - if (c & 0x8410) { - OLED_BUFFER[OLED_OFFSET(PIXELWINDOW.pos.x, PIXELWINDOW.pos.y)] |= - OLED_MASK(PIXELWINDOW.pos.x, PIXELWINDOW.pos.y); - } else { - OLED_BUFFER[OLED_OFFSET(PIXELWINDOW.pos.x, PIXELWINDOW.pos.y)] &= - ~OLED_MASK(PIXELWINDOW.pos.x, PIXELWINDOW.pos.y); - } - } - PIXELWINDOW.pos.x++; - if (PIXELWINDOW.pos.x > PIXELWINDOW.end.x) { - PIXELWINDOW.pos.x = PIXELWINDOW.start.x; - PIXELWINDOW.pos.y++; - } -} - -void display_reset_state() {} - -void display_pixeldata_dirty(void) { pixeldata_dirty_flag = true; } - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - PIXELWINDOW.start.x = x0; - PIXELWINDOW.start.y = y0; - PIXELWINDOW.end.x = x1; - PIXELWINDOW.end.y = y1; - PIXELWINDOW.pos.x = x0; - PIXELWINDOW.pos.y = y0; -} - -int display_orientation(int degrees) { - if (degrees != DISPLAY_ORIENTATION) { - if (degrees == 0 || degrees == 180) { - DISPLAY_ORIENTATION = degrees; - display_refresh(); - } - } - return DISPLAY_ORIENTATION; -} - -int display_get_orientation(void) { return DISPLAY_ORIENTATION; } - -int display_backlight(int val) { - DISPLAY_BACKLIGHT = 255; - return DISPLAY_BACKLIGHT; -} - -SPI_HandleTypeDef spi_handle; - -static inline void spi_send(const uint8_t *data, int len) { - volatile int32_t timeout = 1000; - for (int i = 0; i < timeout; i++) - ; - - if (HAL_OK != HAL_SPI_Transmit(&spi_handle, (uint8_t *)data, len, 1000)) { - // TODO: error - return; - } - while (HAL_SPI_STATE_READY != HAL_SPI_GetState(&spi_handle)) { - } -} - -void display_handle_init(void) { - spi_handle.Instance = OLED_SPI; - spi_handle.State = HAL_SPI_STATE_RESET; - spi_handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; - spi_handle.Init.Direction = SPI_DIRECTION_2LINES; - spi_handle.Init.CLKPhase = SPI_PHASE_1EDGE; - spi_handle.Init.CLKPolarity = SPI_POLARITY_LOW; - spi_handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - spi_handle.Init.CRCPolynomial = 7; - spi_handle.Init.DataSize = SPI_DATASIZE_8BIT; - spi_handle.Init.FirstBit = SPI_FIRSTBIT_MSB; - spi_handle.Init.NSS = SPI_NSS_HARD_OUTPUT; - spi_handle.Init.TIMode = SPI_TIMODE_DISABLE; - spi_handle.Init.Mode = SPI_MODE_MASTER; -} - -void display_init_all(void) { - OLED_DC_CLK_ENA(); - OLED_CS_CLK_ENA(); - OLED_RST_CLK_ENA(); - OLED_SPI_SCK_CLK_ENA(); - OLED_SPI_MOSI_CLK_ENA(); - OLED_SPI_CLK_ENA(); - - GPIO_InitTypeDef GPIO_InitStructure = {0}; - - // set GPIO for OLED display - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStructure.Alternate = 0; - GPIO_InitStructure.Pin = OLED_CS_PIN; - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET); - HAL_GPIO_Init(OLED_CS_PORT, &GPIO_InitStructure); - GPIO_InitStructure.Pin = OLED_DC_PIN; - HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_RESET); - HAL_GPIO_Init(OLED_DC_PORT, &GPIO_InitStructure); - GPIO_InitStructure.Pin = OLED_RST_PIN; - HAL_GPIO_WritePin(OLED_RST_PORT, OLED_RST_PIN, GPIO_PIN_RESET); - HAL_GPIO_Init(OLED_RST_PORT, &GPIO_InitStructure); - - // enable SPI 1 for OLED display - GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; - GPIO_InitStructure.Pull = GPIO_NOPULL; - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStructure.Alternate = OLED_SPI_AF; - GPIO_InitStructure.Pin = OLED_SPI_SCK_PIN; - HAL_GPIO_Init(OLED_SPI_SCK_PORT, &GPIO_InitStructure); - GPIO_InitStructure.Pin = OLED_SPI_MOSI_PIN; - HAL_GPIO_Init(OLED_SPI_MOSI_PORT, &GPIO_InitStructure); - - display_handle_init(); - if (HAL_OK != HAL_SPI_Init(&spi_handle)) { - // TODO: error - return; - } - - // initialize display - - static const uint8_t s[25] = {OLED_DISPLAYOFF, - OLED_SETDISPLAYCLOCKDIV, - 0x80, - OLED_SETMULTIPLEX, - 0x3F, // 128x64 - OLED_SETDISPLAYOFFSET, - 0x00, - OLED_SETSTARTLINE | 0x00, - OLED_CHARGEPUMP, - 0x14, - OLED_MEMORYMODE, - 0x00, - OLED_SEGREMAP | 0x01, - OLED_COMSCANDEC, - OLED_SETCOMPINS, - 0x12, // 128x64 - OLED_SETCONTRAST, - 0xCF, - OLED_SETPRECHARGE, - 0xF1, - OLED_SETVCOMDETECT, - 0x40, - OLED_DISPLAYALLON_RESUME, - OLED_NORMALDISPLAY, - OLED_DISPLAYON}; - - HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_RESET); // set to CMD - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_SET); // SPI deselect - - // Reset the LCD - HAL_GPIO_WritePin(OLED_RST_PORT, OLED_RST_PIN, GPIO_PIN_SET); - HAL_Delay(1); - HAL_GPIO_WritePin(OLED_RST_PORT, OLED_RST_PIN, GPIO_PIN_RESET); - HAL_Delay(1); - HAL_GPIO_WritePin(OLED_RST_PORT, OLED_RST_PIN, GPIO_PIN_SET); - - // init - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET); // SPI select - spi_send(s, 25); - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_SET); // SPI deselect - - display_refresh(); -} - -void display_reinit(void) { - display_handle_init(); - HAL_SPI_Init(&spi_handle); -} - -static inline uint8_t reverse_byte(uint8_t b) { - b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; - b = (b & 0xCC) >> 2 | (b & 0x33) << 2; - b = (b & 0xAA) >> 1 | (b & 0x55) << 1; - return b; -} - -static void rotate_oled_buffer(void) { - for (int i = 0; i < OLED_BUFSIZE / 2; i++) { - uint8_t b = OLED_BUFFER[i]; - OLED_BUFFER[i] = reverse_byte(OLED_BUFFER[OLED_BUFSIZE - i - 1]); - OLED_BUFFER[OLED_BUFSIZE - i - 1] = reverse_byte(b); - } -} - -void display_sync(void) {} - -void display_refresh(void) { - static const uint8_t s[3] = {OLED_SETLOWCOLUMN | 0x00, - OLED_SETHIGHCOLUMN | 0x00, - OLED_SETSTARTLINE | 0x00}; - - if (!pixeldata_dirty_flag) { - return; - } - pixeldata_dirty_flag = false; - - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET); // SPI select - spi_send(s, 3); - -#if defined USE_CONSUMPTION_MASK && !defined BOARDLOADER - consumption_mask_randomize(); -#endif - - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_SET); // SPI deselect - - HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_SET); // set to DATA - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET); // SPI select - if (DISPLAY_ORIENTATION == 180) { // rotate buffer if needed - rotate_oled_buffer(); - } - spi_send(OLED_BUFFER, OLED_BUFSIZE); - if (DISPLAY_ORIENTATION == 180) { // rotate buffer back to original position - rotate_oled_buffer(); - } - HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_SET); // SPI deselect - HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_RESET); // set to CMD -} - -const char *display_save(const char *prefix) { return NULL; } - -void display_clear_save(void) {} - -void display_finish_actions(void) {} diff --git a/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.h b/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.h deleted file mode 100644 index 34a592c593..0000000000 --- a/core/embed/trezorhal/stm32f4/displays/vg-2864ksweg01.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _VG_2864KSWEG01_H -#define _VG_2864KSWEG01_H - -#define MAX_DISPLAY_RESX 128 -#define MAX_DISPLAY_RESY 64 -#define DISPLAY_RESX 128 -#define DISPLAY_RESY 64 - -#endif //_VG_2864KSWEG01_H diff --git a/core/embed/trezorhal/stm32f4/dma2d.c b/core/embed/trezorhal/stm32f4/dma2d.c deleted file mode 100644 index 861eadd66a..0000000000 --- a/core/embed/trezorhal/stm32f4/dma2d.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 . - */ - -#include - -#include "colors.h" -#include "display.h" -#include "dma2d.h" - -typedef enum { - DMA2D_LAYER_FG = 1, - DMA2D_LAYER_BG = 0, -} dma2d_layer_t; - -static DMA2D_HandleTypeDef dma2d_handle = {0}; -static uint16_t current_width = 0; -static uint16_t current_height = 0; - -void dma2d_init(void) { - __HAL_RCC_DMA2D_CLK_ENABLE(); - - dma2d_handle.Instance = (DMA2D_TypeDef*)DMA2D_BASE; - dma2d_handle.Init.ColorMode = DISPLAY_COLOR_MODE; - dma2d_handle.Init.OutputOffset = 0; -} - -static void dma2d_init_clut(uint16_t fg, uint16_t bg, dma2d_layer_t layer) { - volatile uint32_t* table = NULL; - if (layer == DMA2D_LAYER_BG) { - table = dma2d_handle.Instance->BGCLUT; - } else { - table = dma2d_handle.Instance->FGCLUT; - } - - uint32_t fg32 = rgb565_to_rgb888(fg); - uint32_t bg32 = rgb565_to_rgb888(bg); - - for (uint8_t i = 0; i < 16; i++) { - table[i] = interpolate_rgb888_color(fg32, bg32, i); - } - - DMA2D_CLUTCfgTypeDef clut = {0}; - clut.CLUTColorMode = DMA2D_CCM_ARGB8888; - clut.Size = 0xf; - clut.pCLUT = 0; // loading directly - - HAL_DMA2D_ConfigCLUT(&dma2d_handle, clut, layer); -} - -void dma2d_setup_const(void) { - dma2d_handle.Init.Mode = DMA2D_R2M; - dma2d_handle.Init.OutputOffset = display_get_window_offset(); - HAL_DMA2D_Init(&dma2d_handle); -} - -void dma2d_setup_4bpp(uint16_t fg_color, uint16_t bg_color) { - dma2d_handle.Init.Mode = DMA2D_M2M_PFC; - dma2d_handle.Init.OutputOffset = display_get_window_offset(); - dma2d_handle.LayerCfg[1].InputColorMode = DMA2D_INPUT_L4; - dma2d_handle.LayerCfg[1].InputOffset = 0; - dma2d_handle.LayerCfg[1].AlphaMode = 0; - dma2d_handle.LayerCfg[1].InputAlpha = 0; - - dma2d_init_clut(fg_color, bg_color, DMA2D_LAYER_FG); - - HAL_DMA2D_Init(&dma2d_handle); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 1); -} - -void dma2d_setup_16bpp(void) { - dma2d_handle.Init.Mode = DMA2D_M2M_PFC; - dma2d_handle.Init.OutputOffset = display_get_window_offset(); - dma2d_handle.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; - dma2d_handle.LayerCfg[1].InputOffset = 0; - dma2d_handle.LayerCfg[1].AlphaMode = 0; - dma2d_handle.LayerCfg[1].InputAlpha = 0; - - HAL_DMA2D_Init(&dma2d_handle); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 1); -} - -void dma2d_setup_4bpp_over_16bpp(uint16_t overlay_color) { - dma2d_handle.Init.Mode = DMA2D_M2M_BLEND; - dma2d_handle.Init.OutputOffset = display_get_window_offset(); - dma2d_handle.LayerCfg[1].InputColorMode = DMA2D_INPUT_A4; - dma2d_handle.LayerCfg[1].InputOffset = 0; - dma2d_handle.LayerCfg[1].AlphaMode = 0; - dma2d_handle.LayerCfg[1].InputAlpha = - 0xFF000000 | rgb565_to_rgb888(overlay_color); - - dma2d_handle.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565; - dma2d_handle.LayerCfg[0].InputOffset = 0; - dma2d_handle.LayerCfg[0].AlphaMode = 0; - dma2d_handle.LayerCfg[0].InputAlpha = 0; - - HAL_DMA2D_Init(&dma2d_handle); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 1); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 0); -} - -void dma2d_setup_4bpp_over_4bpp(uint16_t fg_color, uint16_t bg_color, - uint16_t overlay_color) { - dma2d_handle.Init.Mode = DMA2D_M2M_BLEND; - dma2d_handle.Init.OutputOffset = display_get_window_offset(); - dma2d_handle.LayerCfg[1].InputColorMode = DMA2D_INPUT_A4; - dma2d_handle.LayerCfg[1].InputOffset = 0; - dma2d_handle.LayerCfg[1].AlphaMode = 0; - dma2d_handle.LayerCfg[1].InputAlpha = rgb565_to_rgb888(overlay_color); - - dma2d_handle.LayerCfg[0].InputColorMode = DMA2D_INPUT_L4; - dma2d_handle.LayerCfg[0].InputOffset = 0; - dma2d_handle.LayerCfg[0].AlphaMode = DMA2D_REPLACE_ALPHA; - dma2d_handle.LayerCfg[0].InputAlpha = 0xFF; - - dma2d_init_clut(fg_color, bg_color, DMA2D_LAYER_BG); - - HAL_DMA2D_Init(&dma2d_handle); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 1); - HAL_DMA2D_ConfigLayer(&dma2d_handle, 0); -} - -void dma2d_start(uint8_t* in_addr, uint8_t* out_addr, int32_t pixels) { - current_width = pixels; - current_height = 1; - HAL_DMA2D_Start(&dma2d_handle, (uint32_t)in_addr, (uint32_t)out_addr, pixels, - 1); -} - -void dma2d_start_const(uint16_t color, uint8_t* out_addr, int32_t pixels) { - current_width = pixels; - current_height = 1; - HAL_DMA2D_Start(&dma2d_handle, rgb565_to_rgb888(color), (uint32_t)out_addr, - pixels, 1); -} - -void dma2d_start_const_multiline(uint16_t color, uint8_t* out_addr, - int32_t width, int32_t height) { - current_width = width; - current_height = height; - HAL_DMA2D_Start(&dma2d_handle, rgb565_to_rgb888(color), (uint32_t)out_addr, - width, height); -} - -void dma2d_start_blend(uint8_t* overlay_addr, uint8_t* bg_addr, - uint8_t* out_addr, int32_t pixels) { - current_width = pixels; - current_height = 1; - HAL_DMA2D_BlendingStart(&dma2d_handle, (uint32_t)overlay_addr, - (uint32_t)bg_addr, (uint32_t)out_addr, pixels, 1); -} - -void dma2d_wait_for_transfer(void) { - while (HAL_DMA2D_PollForTransfer(&dma2d_handle, 10) != HAL_OK) - ; - display_shift_window(current_width * current_height); - current_width = 0; - current_height = 0; -} diff --git a/core/embed/trezorhal/stm32f4/startup_stage_4.s b/core/embed/trezorhal/stm32f4/startup_stage_4.s deleted file mode 100644 index d1a921abb3..0000000000 --- a/core/embed/trezorhal/stm32f4/startup_stage_4.s +++ /dev/null @@ -1,37 +0,0 @@ - .syntax unified - - .text - - .global reset_handler - .type reset_handler, STT_FUNC -reset_handler: - - push {r0, r1} - - // setup the stack protector with provided random value - ldr r0, = __stack_chk_guard - str r2, [r0] - - ldr r0, =bss_start - ldr r1, =0 - ldr r2, =bss_end - sub r2, r2, r0 - bl memset - - // copy data in from flash - ldr r0, =data_vma // dst addr - ldr r1, =data_lma // src addr - ldr r2, =data_size // size in bytes - bl memcpy - - pop {r0, r1} - - // enter the application code - // returns exit code in r0 - bl main - - // terminate the application - // pass exit code in r0 - b system_exit - - .end diff --git a/core/embed/trezorhal/stm32f4/systemview.h b/core/embed/trezorhal/stm32f4/systemview.h deleted file mode 120000 index fda5c909e7..0000000000 --- a/core/embed/trezorhal/stm32f4/systemview.h +++ /dev/null @@ -1 +0,0 @@ -../../firmware/systemview.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.h b/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.h deleted file mode 100644 index 07766712d4..0000000000 --- a/core/embed/trezorhal/stm32f4/xdisplay/stm32f429i-disc1/ili9341_spi.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _ILI9341_SPI_H -#define _ILI9341_SPI_H - -#define ILI9341_HSYNC ((uint32_t)9) /* Horizontal synchronization */ -#define ILI9341_HBP ((uint32_t)29) /* Horizontal back porch */ -#define ILI9341_HFP ((uint32_t)2) /* Horizontal front porch */ -#define ILI9341_VSYNC ((uint32_t)1) /* Vertical synchronization */ -#define ILI9341_VBP ((uint32_t)3) /* Vertical back porch */ -#define ILI9341_VFP ((uint32_t)2) /* Vertical front porch */ - -void ili9341_init(void); - -#endif //_ILI9341_SPI_H diff --git a/core/embed/trezorhal/stm32u5/applet.c b/core/embed/trezorhal/stm32u5/applet.c deleted file mode 120000 index 0cdabf36aa..0000000000 --- a/core/embed/trezorhal/stm32u5/applet.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/applet.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/backlight_pwm.c b/core/embed/trezorhal/stm32u5/backlight_pwm.c deleted file mode 120000 index ca21f1a602..0000000000 --- a/core/embed/trezorhal/stm32u5/backlight_pwm.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/backlight_pwm.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/backlight_pwm.h b/core/embed/trezorhal/stm32u5/backlight_pwm.h deleted file mode 120000 index 37053b491d..0000000000 --- a/core/embed/trezorhal/stm32u5/backlight_pwm.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/backlight_pwm.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/board_capabilities.c b/core/embed/trezorhal/stm32u5/board_capabilities.c deleted file mode 120000 index da6d3b1a3d..0000000000 --- a/core/embed/trezorhal/stm32u5/board_capabilities.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/board_capabilities.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/bootutils.c b/core/embed/trezorhal/stm32u5/bootutils.c deleted file mode 120000 index cdb656edf3..0000000000 --- a/core/embed/trezorhal/stm32u5/bootutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/bootutils.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/button.c b/core/embed/trezorhal/stm32u5/button.c deleted file mode 120000 index 9c6b0a7704..0000000000 --- a/core/embed/trezorhal/stm32u5/button.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/button.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/dsi.c b/core/embed/trezorhal/stm32u5/displays/dsi.c deleted file mode 100644 index 5734a3f2e4..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/dsi.c +++ /dev/null @@ -1,1724 +0,0 @@ -/** - ****************************************************************************** - * @file stm32u5x9j_discovery_lcd.c - * @author MCD Application Team - * @brief This file includes the driver for Liquid Crystal Display (LCD) - module - * mounted on MB1829A board (ARGB8888 color format). - @verbatim - 1. How To use this driver: - -------------------------- - - This driver is used to drive directly in command mode a LCD TFT using the - DSI interface. - The following IPs are implied : DSI Host IP block working - in conjunction to the LTDC controller. - - This driver is linked by construction to LCD. - - 2. Driver description: - ---------------------- - + Initialization steps: - o Initialize the LCD using the BSP_LCD_Init() function. You can select - display orientation with "Orientation" parameter (portrait, landscape, - portrait with 180 degrees rotation or landscape with 180 degrees - rotation). - o Call BSP_LCD_GetXSize() and BSP_LCD_GetYsize() to get respectively - width and height in pixels of LCD in the current orientation. - o Call BSP_LCD_SetBrightness() and BSP_LCD_GetBrightness() to - respectively set and get LCD brightness. - o Call BSP_LCD_SetActiveLayer() to select the current active layer. - o Call BSP_LCD_GetFormat() to get LCD pixel format supported. - - + Display on LCD: - o Call BSP_LCD_DisplayOn() and BSP_LCD_DisplayOff() to respectively - switch on and switch off the LCD display. - o First, check that frame buffer is available using - BSP_LCD_IsFrameBufferAvailable(). o When frame buffer is available, modify it - using following functions: o Call BSP_LCD_WritePixel() and BSP_LCD_ReadPixel() - to respectively write and read a pixel. o Call BSP_LCD_DrawHLine() to draw a - horizontal line. o Call BSP_LCD_DrawVLine() to draw a vertical line. o Call - BSP_LCD_DrawBitmap() to draw a bitmap. o Call BSP_LCD_FillRect() to draw a - rectangle. o Call BSP_LCD_FillRGBRect() to draw a rectangle with RGB buffer. - o Call BSP_LCD_Refresh() to refresh LCD display. - - + De-initialization steps: - o De-initialize the LCD using the BSP_LCD_DeInit() function. - - @endverbatim - ****************************************************************************** - * @attention - * - * Copyright (c) 2023 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include -#include - -#include "colors.h" -#include "irq.h" - -/* Common Error codes */ -#define BSP_ERROR_NONE 0 -#define BSP_ERROR_NO_INIT -1 -#define BSP_ERROR_WRONG_PARAM -2 -#define BSP_ERROR_BUSY -3 -#define BSP_ERROR_PERIPH_FAILURE -4 -#define BSP_ERROR_COMPONENT_FAILURE -5 -#define BSP_ERROR_UNKNOWN_FAILURE -6 -#define BSP_ERROR_UNKNOWN_COMPONENT -7 -#define BSP_ERROR_BUS_FAILURE -8 -#define BSP_ERROR_CLOCK_FAILURE -9 -#define BSP_ERROR_MSP_FAILURE -10 -#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11 - -#define BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE (-102) -/* Button user interrupt priority */ -#define BSP_BUTTON_USER_IT_PRIORITY \ - 0x0FUL /* Default is lowest priority level */ - -#define LCD_PIXEL_FORMAT_ARGB8888 \ - 0x00000000U /*!< ARGB8888 LTDC pixel format \ - */ -#define LCD_PIXEL_FORMAT_RGB888 0x00000001U /*!< RGB888 LTDC pixel format */ -#define LCD_PIXEL_FORMAT_RGB565 0x00000002U /*!< RGB565 LTDC pixel format */ -#define LCD_PIXEL_FORMAT_ARGB1555 \ - 0x00000003U /*!< ARGB1555 LTDC pixel format \ - */ -#define LCD_PIXEL_FORMAT_ARGB4444 \ - 0x00000004U /*!< ARGB4444 LTDC pixel format \ - */ -#define LCD_PIXEL_FORMAT_L8 0x00000005U /*!< L8 LTDC pixel format */ -#define LCD_PIXEL_FORMAT_AL44 0x00000006U /*!< AL44 LTDC pixel format */ -#define LCD_PIXEL_FORMAT_AL88 0x00000007U /*!< AL88 LTDC pixel format */ -/* LCD instances */ -#define LCD_INSTANCES_NBR 1U - -/* LCD orientations */ -#define LCD_ORIENTATION_PORTRAIT 0U -#define LCD_ORIENTATION_LANDSCAPE 1U -#define LCD_ORIENTATION_PORTRAIT_ROT180 2U -#define LCD_ORIENTATION_LANDSCAPE_ROT180 3U - -#define DSI_POWERON_GPIO_PORT GPIOI -#define DSI_POWERON_GPIO_PIN GPIO_PIN_5 -#define DSI_POWERON_GPIO_CLOCK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE() - -#define DSI_RESET_GPIO_PORT GPIOD -#define DSI_RESET_GPIO_PIN GPIO_PIN_5 -#define DSI_RESET_GPIO_CLOCK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() - -#define VSYNC 1 -#define VBP 12 -#define VFP 50 -#define VACT 481 -#define HSYNC 2 -#define HBP 1 -#define HFP 1 -#define HACT 480 -#define LCD_WIDTH 480 -#define LCD_HEIGHT 480 - -#define PIXEL_PER_LINE 768U -#define BYTE_PER_PIXEL 4U /* ARGB8888 */ - -#include "gfxmmu_lut.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup STM32U5x9J_DISCOVERY - * @{ - */ - -/** @defgroup STM32U5x9J_DISCOVERY_LCD LCD - * @{ - */ - -/** @defgroup STM32U5x9J_DISCOVERY_LCD_Private_Defines LCD Private Constants - * @{ - */ - -/** - * @} - */ - -/** @defgroup STM32U5x9J_DISCOVERY_LCD_Private_Variables LCD Private Variables - * @{ - */ - -__attribute__((section(".fb1"))) -ALIGN_32BYTES(uint32_t PhysFrameBuffer0[184320]); -__attribute__((section(".fb2"))) -ALIGN_32BYTES(uint32_t PhysFrameBuffer1[184320]); - -__attribute__((section(".gfxmmu_table"))) -uint32_t gfxmmu_lut[2 * GFXMMU_LUT_SIZE]; -__attribute__((section(".framebuffer_select"))) uint32_t act_frame_buffer = 0; - -#if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) -static uint32_t LcdGfxmmu_IsMspCbValid[LCD_INSTANCES_NBR] = {0}; -#endif /* (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) */ - -#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) -static uint32_t LcdLtdc_IsMspCbValid[LCD_INSTANCES_NBR] = {0}; -#endif /* (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) */ - -#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1) -static uint32_t LcdDsi_IsMspCbValid[LCD_INSTANCES_NBR] = {0}; -#endif /* (USE_HAL_DSI_REGISTER_CALLBACKS == 1) */ - -GFXMMU_HandleTypeDef hlcd_gfxmmu = {0}; -LTDC_HandleTypeDef hlcd_ltdc = {0}; -DSI_HandleTypeDef hlcd_dsi = {0}; -static DSI_VidCfgTypeDef DSIVidCfg = {0}; - -uint16_t window_x0 = 0; -uint16_t window_y0 = 0; -uint16_t window_x1 = 0; -uint16_t window_y1 = 0; -uint16_t cursor_x = 0; -uint16_t cursor_y = 0; - -/** - * @} - */ - -/** @defgroup STM32U5x9J_DISCOVERY_LCD_Private_FunctionPrototypes LCD Private - * Function Prototypes - * @{ - */ -static int32_t LCD_Init(void); -static int32_t LCD_DeInit(void); - -static void GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu); -static void GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu); -static void LTDC_MspInit(LTDC_HandleTypeDef *hltdc); -static void LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc); -static void DSI_MspInit(DSI_HandleTypeDef *hdsi); -static void DSI_MspDeInit(DSI_HandleTypeDef *hdsi); -#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1) -static void DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi); -#endif /* (USE_HAL_DSI_REGISTER_CALLBACKS == 1) */ -/** - * @} - */ - -/** @addtogroup STM32U5x9J_DISCOVERY_LCD_Exported_Functions - * @{ - */ -/** - * @brief Initialize the LCD. - * @param Instance LCD Instance. - * @param Orientation LCD_ORIENTATION_PORTRAIT, LCD_ORIENTATION_LANDSCAPE, - * LCD_ORIENTATION_PORTRAIT_ROT180 or - * LCD_ORIENTATION_LANDSCAPE_ROT180. - * @retval BSP status. - */ -int32_t BSP_LCD_Init(uint32_t Instance, uint32_t Orientation) { - int32_t status = BSP_ERROR_NONE; - - if ((Instance >= LCD_INSTANCES_NBR) || - (Orientation > LCD_ORIENTATION_LANDSCAPE_ROT180)) { - status = BSP_ERROR_WRONG_PARAM; - } else if ((Orientation == LCD_ORIENTATION_LANDSCAPE) || - (Orientation == LCD_ORIENTATION_LANDSCAPE_ROT180)) { - status = BSP_ERROR_FEATURE_NOT_SUPPORTED; - } else { - if (LCD_Init() != 0) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - - return status; -} - -/** - * @brief De-Initialize the LCD. - * @param Instance LCD Instance. - * @retval BSP status. - */ -int32_t BSP_LCD_DeInit(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - if (LCD_DeInit() != 0) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - - return status; -} - -/** - * @brief Set the display on. - * @param Instance LCD Instance. - * @retval BSP status. - */ -int32_t BSP_LCD_DisplayOn(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Set the display on */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, - DSI_SET_DISPLAY_ON, 0x00) != HAL_OK) { - status = BSP_ERROR_WRONG_PARAM; - } - } - - return status; -} - -/** - * @brief Set the display off. - * @param Instance LCD Instance. - * @retval BSP status. - */ -int32_t BSP_LCD_DisplayOff(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Set the display off */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, - DSI_SET_DISPLAY_OFF, 0x00) != HAL_OK) { - status = BSP_ERROR_WRONG_PARAM; - } - } - - return status; -} - -/** - * @brief Set the display brightness. - * @param Instance LCD Instance. - * @param Brightness [00: Min (black), 100 Max]. - * @retval BSP status. - */ -int32_t BSP_LCD_SetBrightness(uint32_t Instance, uint32_t Brightness) { - int32_t status; - - if ((Instance >= LCD_INSTANCES_NBR) || (Brightness > 100U)) { - status = BSP_ERROR_WRONG_PARAM; - } else { - status = BSP_ERROR_FEATURE_NOT_SUPPORTED; - } - - return status; -} - -/** - * @brief Get the display brightness. - * @param Instance LCD Instance. - * @param Brightness [00: Min (black), 100 Max]. - * @retval BSP status. - */ -int32_t BSP_LCD_GetBrightness(uint32_t Instance, uint32_t *Brightness) { - int32_t status; - - if ((Instance >= LCD_INSTANCES_NBR) || (Brightness == NULL)) { - status = BSP_ERROR_WRONG_PARAM; - } else { - status = BSP_ERROR_FEATURE_NOT_SUPPORTED; - } - - return status; -} - -/** - * @brief Get the LCD X size. - * @param Instance LCD Instance. - * @param Xsize LCD X size. - * @retval BSP status. - */ -int32_t BSP_LCD_GetXSize(uint32_t Instance, uint32_t *Xsize) { - int32_t status = BSP_ERROR_NONE; - - if ((Instance >= LCD_INSTANCES_NBR) || (Xsize == NULL)) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Get the display Xsize */ - *Xsize = LCD_WIDTH; - } - - return status; -} - -/** - * @brief Get the LCD Y size. - * @param Instance LCD Instance. - * @param Ysize LCD Y size. - * @retval BSP status. - */ -int32_t BSP_LCD_GetYSize(uint32_t Instance, uint32_t *Ysize) { - int32_t status = BSP_ERROR_NONE; - - if ((Instance >= LCD_INSTANCES_NBR) || (Ysize == NULL)) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Get the display Ysize */ - *Ysize = LCD_HEIGHT; - } - - return status; -} - -/** - * @brief Set the LCD active layer. - * @param Instance LCD Instance. - * @param LayerIndex Active layer index. - * @retval BSP status. - */ -int32_t BSP_LCD_SetActiveLayer(uint32_t Instance, uint32_t LayerIndex) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Nothing to do */ - UNUSED(LayerIndex); - } - - return status; -} - -/** - * @brief Get pixel format supported by LCD. - * @param Instance LCD Instance. - * @param Format Pointer on pixel format. - * @retval BSP status. - */ -int32_t BSP_LCD_GetFormat(uint32_t Instance, uint32_t *Format) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - /* Get pixel format supported by LCD */ - *Format = LCD_PIXEL_FORMAT_ARGB8888; - } - - return status; -} - -void MX_GFXMMU_Reinit(GFXMMU_HandleTypeDef *hgfxmmu) { - /* Initialize GFXMMU */ - hgfxmmu->Instance = GFXMMU; - hgfxmmu->Init.BlocksPerLine = GFXMMU_192BLOCKS; - hgfxmmu->Init.DefaultValue = 0xFFFFFFFFU; - hgfxmmu->Init.Buffers.Buf0Address = (uint32_t)PhysFrameBuffer0; - hgfxmmu->Init.Buffers.Buf1Address = (uint32_t)PhysFrameBuffer1; - hgfxmmu->Init.Buffers.Buf2Address = 0; - hgfxmmu->Init.Buffers.Buf3Address = 0; -#if defined(GFXMMU_CR_CE) - hgfxmmu->Init.CachePrefetch.Activation = DISABLE; - hgfxmmu->Init.CachePrefetch.CacheLock = GFXMMU_CACHE_LOCK_DISABLE; - hgfxmmu->Init.CachePrefetch.CacheLockBuffer = - GFXMMU_CACHE_LOCK_BUFFER0; /* NU */ - hgfxmmu->Init.CachePrefetch.CacheForce = GFXMMU_CACHE_FORCE_ENABLE; /* NU */ - hgfxmmu->Init.CachePrefetch.OutterBufferability = - GFXMMU_OUTTER_BUFFERABILITY_DISABLE; - hgfxmmu->Init.CachePrefetch.OutterCachability = - GFXMMU_OUTTER_CACHABILITY_DISABLE; - hgfxmmu->Init.CachePrefetch.Prefetch = GFXMMU_PREFETCH_DISABLE; -#endif /* GFXMMU_CR_CE */ -#if defined(GFXMMU_CR_ACE) - hgfxmmu->Init.AddressCache.Activation = DISABLE; - hgfxmmu->Init.AddressCache.AddressCacheLockBuffer = - GFXMMU_ADDRESSCACHE_LOCK_BUFFER0; -#endif /* GFXMMU_CR_ACE */ - hgfxmmu->Init.Interrupts.Activation = DISABLE; - hgfxmmu->Init.Interrupts.UsedInterrupts = GFXMMU_AHB_MASTER_ERROR_IT; /* NU */ -} - -/** - * @brief MX GFXMMU initialization. - * @param hgfxmmu GFXMMU handle. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu) { - MX_GFXMMU_Reinit(hgfxmmu); - return HAL_GFXMMU_Init(hgfxmmu); -} - -/** - * @brief MX LTDC clock configuration. - * @param hltdc LTDC handle. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_LTDC_ClockConfig(LTDC_HandleTypeDef *hltdc) { - RCC_PeriphCLKInitTypeDef PLL3InitPeriph = {0}; - - /* Prevent unused argument(s) compilation warning */ - UNUSED(hltdc); - - /* Start and configurre PLL3 */ - /* HSE = 16MHZ */ - /* 16/(M=4) = 4MHz input (min) */ - /* 4*(N=125) = 500MHz VCO (almost max) */ - /* 500/(P=8) = 62.5 for DSI ie exactly the lane byte clock*/ - /* 500/(R=24) = 20.83 for LTDC exact match with DSI bandwidth */ - PLL3InitPeriph.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PLL3InitPeriph.LtdcClockSelection = RCC_LTDCCLKSOURCE_PLL3; - PLL3InitPeriph.PLL3.PLL3M = 4; - PLL3InitPeriph.PLL3.PLL3N = 125; - PLL3InitPeriph.PLL3.PLL3P = 8; - PLL3InitPeriph.PLL3.PLL3Q = 8; - PLL3InitPeriph.PLL3.PLL3R = 24; - PLL3InitPeriph.PLL3.PLL3FRACN = 0; - PLL3InitPeriph.PLL3.PLL3RGE = RCC_PLLVCIRANGE_1; - PLL3InitPeriph.PLL3.PLL3ClockOut = RCC_PLL3_DIVR | RCC_PLL3_DIVP; - PLL3InitPeriph.PLL3.PLL3Source = RCC_PLLSOURCE_HSE; - return HAL_RCCEx_PeriphCLKConfig(&PLL3InitPeriph); -} - -void MX_LTDC_Reinit(LTDC_HandleTypeDef *hltdc) { - /* LTDC initialization */ - hltdc->Instance = LTDC; - hltdc->Init.HSPolarity = LTDC_HSPOLARITY_AL; - hltdc->Init.VSPolarity = LTDC_VSPOLARITY_AL; - hltdc->Init.DEPolarity = LTDC_DEPOLARITY_AL; - hltdc->Init.PCPolarity = LTDC_PCPOLARITY_IPC; - hltdc->Init.HorizontalSync = HSYNC - 1; - hltdc->Init.AccumulatedHBP = HSYNC + HBP - 1; - hltdc->Init.AccumulatedActiveW = HACT + HBP + HSYNC - 1; - hltdc->Init.TotalWidth = HACT + HBP + HFP + HSYNC - 1; - hltdc->Init.Backcolor.Red = 0; /* Not used default value */ - hltdc->Init.Backcolor.Green = 0; /* Not used default value */ - hltdc->Init.Backcolor.Blue = 0; /* Not used default value */ - hltdc->Init.Backcolor.Reserved = 0xFF; - - HAL_LTDCEx_StructInitFromVideoConfig(&hlcd_ltdc, &DSIVidCfg); -} - -/** - * @brief MX LTDC initialization. - * @param hltdc LTDC handle. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_LTDC_Init(LTDC_HandleTypeDef *hltdc) { - MX_LTDC_Reinit(hltdc); - - return HAL_LTDC_Init(hltdc); -} - -// HAL_StatusTypeDef MX_LTDC_ReConfigLayer(LTDC_HandleTypeDef *hltdc, uint32_t -// LayerIndex) -//{ -// LTDC_LayerCfgTypeDef LayerCfg = {0}; -// -///* LTDC layer configuration */ -// LayerCfg.WindowX0 = 0; -// LayerCfg.WindowX1 = LCD_WIDTH; -// LayerCfg.WindowY0 = 1; -// LayerCfg.WindowY1 = (uint32_t)LCD_HEIGHT + 1UL; -// LayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; -// LayerCfg.Alpha = 0xFF; /* NU default value */ -// LayerCfg.Alpha0 = 0; /* NU default value */ -// LayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; /* Not Used: default -// value */ LayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; /* Not -// Used: default value */ LayerCfg.FBStartAdress = -// GFXMMU_VIRTUAL_BUFFER0_BASE; LayerCfg.ImageWidth = PIXEL_PER_LINE; /* -// Number of pixels per line in virtual frame buffer */ LayerCfg.ImageHeight = -// LCD_HEIGHT; LayerCfg.Backcolor.Red = 0; /* Not Used: default value */ -// LayerCfg.Backcolor.Green = 0; /* Not Used: default value */ -// LayerCfg.Backcolor.Blue = 0; /* Not Used: default value */ -// LayerCfg.Bac -// return HAL_LTDC_ConfigLayer(hltdc, &LayerCfg, LayerIndex);kcolor.Reserved = -// 0xFF; -//} - -/** - * @brief MX LTDC layer configuration. - * @param hltdc LTDC handle. - * @param LayerIndex LTDC layer index. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, - uint32_t LayerIndex, - uint32_t fb_addr) { - LTDC_LayerCfgTypeDef LayerCfg = {0}; - - /* LTDC layer configuration */ - LayerCfg.WindowX0 = 0; - LayerCfg.WindowX1 = LCD_WIDTH; - LayerCfg.WindowY0 = 1; - LayerCfg.WindowY1 = (uint32_t)LCD_HEIGHT + 1UL; - LayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; - LayerCfg.Alpha = 0xFF; /* NU default value */ - LayerCfg.Alpha0 = 0; /* NU default value */ - LayerCfg.BlendingFactor1 = - LTDC_BLENDING_FACTOR1_PAxCA; /* Not Used: default value */ - LayerCfg.BlendingFactor2 = - LTDC_BLENDING_FACTOR2_PAxCA; /* Not Used: default value */ - LayerCfg.FBStartAdress = fb_addr; - LayerCfg.ImageWidth = - PIXEL_PER_LINE; /* Number of pixels per line in virtual frame buffer */ - LayerCfg.ImageHeight = LCD_HEIGHT; - LayerCfg.Backcolor.Red = 0; /* Not Used: default value */ - LayerCfg.Backcolor.Green = 0; /* Not Used: default value */ - LayerCfg.Backcolor.Blue = 0; /* Not Used: default value */ - LayerCfg.Backcolor.Reserved = 0xFF; - return HAL_LTDC_ConfigLayer(hltdc, &LayerCfg, LayerIndex); -} - -/** - * @brief MX DSI initialization. - * @param hdsi DSI handle. - * @retval HAL status. - */ -HAL_StatusTypeDef MX_DSI_Reinit(DSI_HandleTypeDef *hdsi) { - /* DSI initialization */ - hdsi->Instance = DSI; - hdsi->Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE; - /* We have 1 data lane at 500Mbps => lane byte clock at 500/8 = 62,5 MHZ */ - /* We want TX escape clock at around 20MHz and under 20MHz so clock division - * is set to 4 */ - hdsi->Init.TXEscapeCkdiv = 4; - hdsi->Init.NumberOfLanes = DSI_TWO_DATA_LANES; - hdsi->Init.PHYFrequencyRange = DSI_DPHY_FRANGE_450MHZ_510MHZ; - hdsi->Init.PHYLowPowerOffset = 0; - - /* Configure the DSI for Video mode */ - DSIVidCfg.VirtualChannelID = 0; - DSIVidCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - DSIVidCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; - DSIVidCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; - DSIVidCfg.ColorCoding = DSI_RGB888; - DSIVidCfg.Mode = DSI_VID_MODE_BURST; - DSIVidCfg.PacketSize = LCD_WIDTH; - DSIVidCfg.NullPacketSize = 0xFFFU; - DSIVidCfg.HorizontalSyncActive = HSYNC * 3; - DSIVidCfg.HorizontalBackPorch = HBP * 3; - DSIVidCfg.HorizontalLine = (HACT + HSYNC + HBP + HFP) * 3; - DSIVidCfg.VerticalSyncActive = VSYNC; - DSIVidCfg.VerticalBackPorch = VBP; - DSIVidCfg.VerticalFrontPorch = VFP; - DSIVidCfg.VerticalActive = VACT; - DSIVidCfg.LPCommandEnable = DSI_LP_COMMAND_ENABLE; - DSIVidCfg.LPLargestPacketSize = 64; - /* Specify for each region of the video frame, if the transmission of command - * in LP mode is allowed in this region */ - /* while streaming is active in video mode */ - DSIVidCfg.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; - DSIVidCfg.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; - DSIVidCfg.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; - DSIVidCfg.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; - DSIVidCfg.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; - DSIVidCfg.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; - DSIVidCfg.FrameBTAAcknowledgeEnable = DSI_FBTAA_ENABLE; - DSIVidCfg.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE; - - return HAL_OK; -} - -/** - * @brief MX DSI initialization. - * @param hdsi DSI handle. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_DSI_Init(DSI_HandleTypeDef *hdsi) { - DSI_PLLInitTypeDef PLLInit = {0}; - - /* DSI initialization */ - hdsi->Instance = DSI; - hdsi->Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE; - /* We have 1 data lane at 500Mbps => lane byte clock at 500/8 = 62,5 MHZ */ - /* We want TX escape clock at around 20MHz and under 20MHz so clock division - * is set to 4 */ - hdsi->Init.TXEscapeCkdiv = 4; - hdsi->Init.NumberOfLanes = DSI_TWO_DATA_LANES; - hdsi->Init.PHYFrequencyRange = DSI_DPHY_FRANGE_450MHZ_510MHZ; - hdsi->Init.PHYLowPowerOffset = 0; - - PLLInit.PLLNDIV = 125; - PLLInit.PLLIDF = 4; - PLLInit.PLLODF = 2; - PLLInit.PLLVCORange = DSI_DPHY_VCO_FRANGE_800MHZ_1GHZ; - PLLInit.PLLChargePump = DSI_PLL_CHARGE_PUMP_2000HZ_4400HZ; - PLLInit.PLLTuning = DSI_PLL_LOOP_FILTER_2000HZ_4400HZ; - - if (HAL_DSI_Init(hdsi, &PLLInit) != HAL_OK) { - return HAL_ERROR; - } - - if (HAL_DSI_SetGenericVCID(&hlcd_dsi, 0) != HAL_OK) { - return HAL_ERROR; - } - - /* Configure the DSI for Video mode */ - DSIVidCfg.VirtualChannelID = 0; - DSIVidCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - DSIVidCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; - DSIVidCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; - DSIVidCfg.ColorCoding = DSI_RGB888; - DSIVidCfg.Mode = DSI_VID_MODE_BURST; - DSIVidCfg.PacketSize = LCD_WIDTH; - DSIVidCfg.NullPacketSize = 0xFFFU; - DSIVidCfg.HorizontalSyncActive = HSYNC * 3; - DSIVidCfg.HorizontalBackPorch = HBP * 3; - DSIVidCfg.HorizontalLine = (HACT + HSYNC + HBP + HFP) * 3; - DSIVidCfg.VerticalSyncActive = VSYNC; - DSIVidCfg.VerticalBackPorch = VBP; - DSIVidCfg.VerticalFrontPorch = VFP; - DSIVidCfg.VerticalActive = VACT; - DSIVidCfg.LPCommandEnable = DSI_LP_COMMAND_ENABLE; - DSIVidCfg.LPLargestPacketSize = 64; - /* Specify for each region of the video frame, if the transmission of command - * in LP mode is allowed in this region */ - /* while streaming is active in video mode */ - DSIVidCfg.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; - DSIVidCfg.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; - DSIVidCfg.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; - DSIVidCfg.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; - DSIVidCfg.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; - DSIVidCfg.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; - DSIVidCfg.FrameBTAAcknowledgeEnable = DSI_FBTAA_ENABLE; - DSIVidCfg.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE; - - /* Drive the display */ - if (HAL_DSI_ConfigVideoMode(&hlcd_dsi, &DSIVidCfg) != HAL_OK) { - return HAL_ERROR; - } - - return HAL_OK; -} - -/** - * @brief MX DMA2D initialization. - * @param hdma2d DMA2D handle. - * @param Mode DMA2D transfer mode. - * @param OffLine DMA2D output offset. - * @retval HAL status. - */ -__weak HAL_StatusTypeDef MX_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d, - uint32_t Mode, uint32_t OffLine) { - /* Register to memory mode with ARGB8888 as color Mode */ - hdma2d->Instance = DMA2D; - hdma2d->Init.Mode = Mode; - hdma2d->Init.ColorMode = DMA2D_OUTPUT_ARGB8888; - hdma2d->Init.OutputOffset = OffLine; - hdma2d->Init.AlphaInverted = DMA2D_REGULAR_ALPHA; - hdma2d->Init.RedBlueSwap = DMA2D_RB_REGULAR; - hdma2d->Init.BytesSwap = DMA2D_BYTES_REGULAR; - hdma2d->Init.LineOffsetMode = DMA2D_LOM_PIXELS; - - /* DMA2D Initialization */ - return HAL_DMA2D_Init(hdma2d); -} - -#if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1) -/** - * @brief Register Default LCD GFXMMU Msp Callbacks - * @retval BSP status - */ -int32_t BSP_LCD_GFXMMU_RegisterDefaultMspCallbacks(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_GFXMMU_RESET_HANDLE_STATE(&hlcd_gfxmmu); - - /* Register default MspInit/MspDeInit Callback */ - if (HAL_GFXMMU_RegisterCallback(&hlcd_gfxmmu, HAL_GFXMMU_MSPINIT_CB_ID, - GFXMMU_MspInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_GFXMMU_RegisterCallback(&hlcd_gfxmmu, - HAL_GFXMMU_MSPDEINIT_CB_ID, - GFXMMU_MspDeInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdGfxmmu_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} - -/** - * @brief Register LCD GFXMMU Msp Callback - * @param Callbacks pointer to LCD MspInit/MspDeInit callback functions - * @retval BSP status - */ -int32_t BSP_LCD_GFXMMU_RegisterMspCallbacks(uint32_t Instance, - BSP_LCD_GFXMMU_Cb_t *Callback) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_GFXMMU_RESET_HANDLE_STATE(&hlcd_gfxmmu); - - /* Register MspInit/MspDeInit Callbacks */ - if (HAL_GFXMMU_RegisterCallback(&hlcd_gfxmmu, HAL_GFXMMU_MSPINIT_CB_ID, - Callback->pMspGfxmmuInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_GFXMMU_RegisterCallback( - &hlcd_gfxmmu, HAL_GFXMMU_MSPDEINIT_CB_ID, - Callback->pMspGfxmmuDeInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdGfxmmu_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} -#endif /* USE_HAL_GFXMMU_REGISTER_CALLBACKS */ - -#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) -/** - * @brief Register Default LCD LTDC Msp Callbacks - * @retval BSP status - */ -int32_t BSP_LCD_LTDC_RegisterDefaultMspCallbacks(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_LTDC_RESET_HANDLE_STATE(&hlcd_ltdc); - - /* Register default MspInit/MspDeInit Callback */ - if (HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPINIT_CB_ID, - LTDC_MspInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPDEINIT_CB_ID, - LTDC_MspDeInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdLtdc_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} - -/** - * @brief Register LCD LTDC Msp Callback - * @param Callbacks pointer to LCD MspInit/MspDeInit callback functions - * @retval BSP status - */ -int32_t BSP_LCD_LTDC_RegisterMspCallbacks(uint32_t Instance, - BSP_LCD_LTDC_Cb_t *Callback) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_LTDC_RESET_HANDLE_STATE(&hlcd_ltdc); - - /* Register MspInit/MspDeInit Callbacks */ - if (HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPINIT_CB_ID, - Callback->pMspLtdcInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPDEINIT_CB_ID, - Callback->pMspLtdcDeInitCb) != - HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdLtdc_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} -#endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ - -#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1) -/** - * @brief Register Default LCD DSI Msp Callbacks - * @retval BSP status - */ -int32_t BSP_LCD_DSI_RegisterDefaultMspCallbacks(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_DSI_RESET_HANDLE_STATE(&hlcd_dsi); - - /* Register default MspInit/MspDeInit Callback */ - if (HAL_DSI_RegisterCallback(&hlcd_dsi, HAL_DSI_MSPINIT_CB_ID, - DSI_MspInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_DSI_RegisterCallback(&hlcd_dsi, HAL_DSI_MSPDEINIT_CB_ID, - DSI_MspDeInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdDsi_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} - -/** - * @brief Register LCD DSI Msp Callback - * @param Callbacks pointer to LCD MspInit/MspDeInit callback functions - * @retval BSP status - */ -int32_t BSP_LCD_DSI_RegisterMspCallbacks(uint32_t Instance, - BSP_LCD_DSI_Cb_t *Callback) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_DSI_RESET_HANDLE_STATE(&hlcd_dsi); - - /* Register MspInit/MspDeInit Callbacks */ - if (HAL_DSI_RegisterCallback(&hlcd_dsi, HAL_DSI_MSPINIT_CB_ID, - Callback->pMspDsiInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_DSI_RegisterCallback(&hlcd_dsi, HAL_DSI_MSPDEINIT_CB_ID, - Callback->pMspDsiDeInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdDsi_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} -#endif /* USE_HAL_DSI_REGISTER_CALLBACKS */ - -#if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1) -/** - * @brief Register Default LCD DMA2D Msp Callbacks - * @retval BSP status - */ -int32_t BSP_LCD_DMA2D_RegisterDefaultMspCallbacks(uint32_t Instance) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_DMA2D_RESET_HANDLE_STATE(&hlcd_dma2d); - - /* Register default MspInit/MspDeInit Callback */ - if (HAL_DMA2D_RegisterCallback(&hlcd_dma2d, HAL_DMA2D_MSPINIT_CB_ID, - DMA2D_MspInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_DMA2D_RegisterCallback(&hlcd_dma2d, - HAL_DMA2D_MSPDEINIT_CB_ID, - DMA2D_MspDeInit) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdDma2d_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} - -/** - * @brief Register LCD DMA2D Msp Callback - * @param Callbacks pointer to LCD MspInit/MspDeInit callback functions - * @retval BSP status - */ -int32_t BSP_LCD_DMA2D_RegisterMspCallbacks(uint32_t Instance, - BSP_LCD_DMA2D_Cb_t *Callback) { - int32_t status = BSP_ERROR_NONE; - - if (Instance >= LCD_INSTANCES_NBR) { - status = BSP_ERROR_WRONG_PARAM; - } else { - __HAL_DMA2D_RESET_HANDLE_STATE(&hlcd_dma2d); - - /* Register MspInit/MspDeInit Callbacks */ - if (HAL_DMA2D_RegisterCallback(&hlcd_dma2d, HAL_DMA2D_MSPINIT_CB_ID, - Callback->pMspDma2dInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else if (HAL_DMA2D_RegisterCallback( - &hlcd_dma2d, HAL_DMA2D_MSPDEINIT_CB_ID, - Callback->pMspDma2dDeInitCb) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - LcdDma2d_IsMspCbValid[Instance] = 1U; - } - } - - /* BSP status */ - return status; -} -#endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */ -/** - * @} - */ - -/** @defgroup STM32U5x9J_DISCOVERY_LCD_Private_Functions LCD Private Functions - * @{ - */ - -/** - * @brief Initialize LCD. - * @retval BSP status. - */ -static int32_t LCD_Init(void) { - int32_t status = BSP_ERROR_NONE; - uint32_t ErrorNumber = 0; - DSI_PHY_TimerTypeDef PhyTimers = {0}; - DSI_HOST_TimeoutTypeDef HostTimeouts = {0}; - - /***************/ - /* GFXMMU init */ - /***************/ -#if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 0) - GFXMMU_MspInit(&hlcd_gfxmmu); -#else - /* Register the GFXMMU MSP Callbacks */ - if (LcdGfxmmu_IsMspCbValid[0] == 0U) { - if (BSP_LCD_GFXMMU_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } -#endif /* (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 0) */ - - if (status == BSP_ERROR_NONE) { - /* GFXMMU peripheral initialization */ - if (MX_GFXMMU_Init(&hlcd_gfxmmu) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } - /* Initialize LUT */ - else if (HAL_GFXMMU_ConfigLut(&hlcd_gfxmmu, 0, LCD_WIDTH, - (uint32_t)&gfxmmu_lut) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - /* Disable non visible lines : from line 480 to 1023 */ - if (HAL_OK != HAL_GFXMMU_DisableLutLines(&hlcd_gfxmmu, LCD_WIDTH, 544)) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - } - - /************/ - /* DSI init */ - /************/ - if (status == BSP_ERROR_NONE) { -#if (USE_HAL_DSI_REGISTER_CALLBACKS == 0) - DSI_MspInit(&hlcd_dsi); -#else - /* Register the DSI MSP Callbacks */ - if (LcdDsi_IsMspCbValid[0] == 0U) { - if (BSP_LCD_DSI_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } -#endif /* (USE_HAL_DSI_REGISTER_CALLBACKS == 0) */ - - if (status == BSP_ERROR_NONE) { - /* DSI peripheral initialization */ - if (MX_DSI_Init(&hlcd_dsi) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - } - - /*********************/ - /* LCD configuration */ - /*********************/ - if (status == BSP_ERROR_NONE) { - PhyTimers.ClockLaneHS2LPTime = 11; - PhyTimers.ClockLaneLP2HSTime = 40; - PhyTimers.DataLaneHS2LPTime = 12; - PhyTimers.DataLaneLP2HSTime = 23; - PhyTimers.DataLaneMaxReadTime = 0; - PhyTimers.StopWaitTime = 7; - - if (HAL_DSI_ConfigPhyTimer(&hlcd_dsi, &PhyTimers) != HAL_OK) { - return 6; - } - - HostTimeouts.TimeoutCkdiv = 1; - HostTimeouts.HighSpeedTransmissionTimeout = 0; - HostTimeouts.LowPowerReceptionTimeout = 0; - HostTimeouts.HighSpeedReadTimeout = 0; - HostTimeouts.LowPowerReadTimeout = 0; - HostTimeouts.HighSpeedWriteTimeout = 0; - HostTimeouts.HighSpeedWritePrespMode = 0; - HostTimeouts.LowPowerWriteTimeout = 0; - HostTimeouts.BTATimeout = 0; - - if (HAL_DSI_ConfigHostTimeouts(&hlcd_dsi, &HostTimeouts) != HAL_OK) { - return 7; - } - - if (HAL_DSI_ConfigFlowControl(&hlcd_dsi, DSI_FLOW_CONTROL_BTA) != HAL_OK) { - return 7; - } - - /* Enable the DSI host */ - __HAL_DSI_ENABLE(&hlcd_dsi); - - /*************/ - /* LTDC init */ - /*************/ - if (status == BSP_ERROR_NONE) { - if (MX_LTDC_ClockConfig(&hlcd_ltdc) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { -#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 0) - LTDC_MspInit(&hlcd_ltdc); -#else - /* Register the LTDC MSP Callbacks */ - if (LcdLtdc_IsMspCbValid[0] == 0U) { - if (BSP_LCD_LTDC_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } -#endif /* (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 0) */ - - if (status == BSP_ERROR_NONE) { - /* LTDC peripheral initialization */ - if (MX_LTDC_Init(&hlcd_ltdc) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } else { - if (MX_LTDC_ConfigLayer(&hlcd_ltdc, LTDC_LAYER_1, - GFXMMU_VIRTUAL_BUFFER0_BASE_S) != HAL_OK) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - } - } - } - - /* Start DSI */ - if (HAL_DSI_Start(&(hlcd_dsi)) != HAL_OK) { - return 8; - } - - /* CMD Mode */ - uint8_t InitParam1[3] = {0xFF, 0x83, 0x79}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 3, 0xB9, - InitParam1) != HAL_OK) { - ErrorNumber++; - } - - /* SETPOWER */ - uint8_t InitParam2[16] = {0x44, 0x1C, 0x1C, 0x37, 0x57, 0x90, 0xD0, 0xE2, - 0x58, 0x80, 0x38, 0x38, 0xF8, 0x33, 0x34, 0x42}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 16, 0xB1, - InitParam2) != HAL_OK) { - ErrorNumber++; - } - - /* SETDISP */ - uint8_t InitParam3[9] = {0x80, 0x14, 0x0C, 0x30, 0x20, - 0x50, 0x11, 0x42, 0x1D}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 9, 0xB2, - InitParam3) != HAL_OK) { - ErrorNumber++; - } - - /* Set display cycle timing */ - uint8_t InitParam4[10] = {0x01, 0xAA, 0x01, 0xAF, 0x01, - 0xAF, 0x10, 0xEA, 0x1C, 0xEA}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 10, 0xB4, - InitParam4) != HAL_OK) { - ErrorNumber++; - } - - /* SETVCOM */ - uint8_t InitParam5[4] = {00, 00, 00, 0xC0}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 4, 0xC7, - InitParam5) != HAL_OK) { - ErrorNumber++; - } - - /* Set Panel Related Registers */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xCC, - 0x02) != HAL_OK) { - ErrorNumber++; - } - - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xD2, - 0x77) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam6[37] = {0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x08, 0x32, - 0x10, 0x01, 0x00, 0x01, 0x03, 0x72, 0x03, 0x72, - 0x00, 0x08, 0x00, 0x08, 0x33, 0x33, 0x05, 0x05, - 0x37, 0x05, 0x05, 0x37, 0x0A, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x01, 0x00, 0x0E}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 37, 0xD3, - InitParam6) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam7[34] = { - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18, - 0x18, 0x18, 0x19, 0x19, 0x01, 0x00, 0x03, 0x02, 0x05, 0x04, 0x07, 0x06, - 0x23, 0x22, 0x21, 0x20, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 34, 0xD5, - InitParam7) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam8[32] = {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x19, 0x19, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18, - 0x06, 0x07, 0x04, 0x05, 0x02, 0x03, 0x00, 0x01, - 0x20, 0x21, 0x22, 0x23, 0x18, 0x18, 0x18, 0x18}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 35, 0xD6, - InitParam8) != HAL_OK) { - ErrorNumber++; - } - - /* SET GAMMA */ - uint8_t InitParam9[42] = { - 0x00, 0x16, 0x1B, 0x30, 0x36, 0x3F, 0x24, 0x40, 0x09, 0x0D, 0x0F, - 0x18, 0x0E, 0x11, 0x12, 0x11, 0x14, 0x07, 0x12, 0x13, 0x18, 0x00, - 0x17, 0x1C, 0x30, 0x36, 0x3F, 0x24, 0x40, 0x09, 0x0C, 0x0F, 0x18, - 0x0E, 0x11, 0x14, 0x11, 0x12, 0x07, 0x12, 0x14, 0x18}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 42, 0xE0, - InitParam9) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam10[3] = {0x2C, 0x2C, 00}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 3, 0xB6, - InitParam10) != HAL_OK) { - ErrorNumber++; - } - - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xBD, - 0x00) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam11[] = { - 0x01, 0x00, 0x07, 0x0F, 0x16, 0x1F, 0x27, 0x30, 0x38, 0x40, 0x47, - 0x4E, 0x56, 0x5D, 0x65, 0x6D, 0x74, 0x7D, 0x84, 0x8A, 0x90, 0x99, - 0xA1, 0xA9, 0xB0, 0xB6, 0xBD, 0xC4, 0xCD, 0xD4, 0xDD, 0xE5, 0xEC, - 0xF3, 0x36, 0x07, 0x1C, 0xC0, 0x1B, 0x01, 0xF1, 0x34, 0x00}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 42, 0xC1, - InitParam11) != HAL_OK) { - ErrorNumber++; - } - - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xBD, - 0x01) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam12[] = { - 0x00, 0x08, 0x0F, 0x16, 0x1F, 0x28, 0x31, 0x39, 0x41, 0x48, 0x51, - 0x59, 0x60, 0x68, 0x70, 0x78, 0x7F, 0x87, 0x8D, 0x94, 0x9C, 0xA3, - 0xAB, 0xB3, 0xB9, 0xC1, 0xC8, 0xD0, 0xD8, 0xE0, 0xE8, 0xEE, 0xF5, - 0x3B, 0x1A, 0xB6, 0xA0, 0x07, 0x45, 0xC5, 0x37, 0x00}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 42, 0xC1, - InitParam12) != HAL_OK) { - ErrorNumber++; - } - - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xBD, - 0x02) != HAL_OK) { - ErrorNumber++; - } - - uint8_t InitParam13[42] = { - 0x00, 0x09, 0x0F, 0x18, 0x21, 0x2A, 0x34, 0x3C, 0x45, 0x4C, 0x56, - 0x5E, 0x66, 0x6E, 0x76, 0x7E, 0x87, 0x8E, 0x95, 0x9D, 0xA6, 0xAF, - 0xB7, 0xBD, 0xC5, 0xCE, 0xD5, 0xDF, 0xE7, 0xEE, 0xF4, 0xFA, 0xFF, - 0x0C, 0x31, 0x83, 0x3C, 0x5B, 0x56, 0x1E, 0x5A, 0xFF}; - if (HAL_DSI_LongWrite(&hlcd_dsi, 0, DSI_DCS_LONG_PKT_WRITE, 42, 0xC1, - InitParam13) != HAL_OK) { - ErrorNumber++; - } - - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, 0xBD, - 0x00) != HAL_OK) { - ErrorNumber++; - } - - /* Exit Sleep Mode*/ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P0, 0x11, - 0x00) != HAL_OK) { - ErrorNumber++; - } - - HAL_Delay(120); - - /* Display On */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P0, 0x29, - 0x00) != HAL_OK) { - ErrorNumber++; - } - - HAL_Delay(120); - - if (ErrorNumber != 0U) { - status = BSP_ERROR_PERIPH_FAILURE; - } - } - - return status; -} - -/** - * @brief De-Initialize LCD. - * @retval BSP status. - */ -static int32_t LCD_DeInit(void) { - int32_t status = BSP_ERROR_NONE; - uint32_t ErrorNumber = 0; - - /* Disable DSI wrapper */ - __HAL_DSI_WRAPPER_DISABLE(&hlcd_dsi); - - /* Set display off */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, - DSI_SET_DISPLAY_OFF, 0x00) != HAL_OK) { - ErrorNumber++; - } - - /* Wait before entering in sleep mode */ - HAL_Delay(2000); - - /* Put LCD in sleep mode */ - if (HAL_DSI_ShortWrite(&hlcd_dsi, 0, DSI_DCS_SHORT_PKT_WRITE_P0, - DSI_ENTER_SLEEP_MODE, 0x0) != HAL_OK) { - ErrorNumber++; - } - - HAL_Delay(120); - - /* De-initialize DSI */ - if (HAL_DSI_DeInit(&hlcd_dsi) != HAL_OK) { - ErrorNumber++; - } -#if (USE_HAL_DSI_REGISTER_CALLBACKS == 0) - DSI_MspDeInit(&hlcd_dsi); -#endif /* (USE_HAL_DSI_REGISTER_CALLBACKS == 0) */ - - /* De-initialize LTDC */ - if (HAL_LTDC_DeInit(&hlcd_ltdc) != HAL_OK) { - ErrorNumber++; - } -#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 0) - LTDC_MspDeInit(&hlcd_ltdc); -#endif /* (USE_HAL_LTDC_REGISTER_CALLBACKS == 0) */ - - /* De-initialize GFXMMU */ - if (HAL_GFXMMU_DeInit(&hlcd_gfxmmu) != HAL_OK) { - ErrorNumber++; - } -#if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 0) - GFXMMU_MspDeInit(&hlcd_gfxmmu); -#endif /* (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 0) */ - - if (ErrorNumber != 0U) { - status = BSP_ERROR_PERIPH_FAILURE; - } - - return status; -} - -/** - * @brief Initialize GFXMMU MSP. - * @param hgfxmmu GFXMMU handle - * @retval None - */ -static void GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu) { - /* Prevent unused argument(s) compilation warning */ - UNUSED(hgfxmmu); - - /* GFXMMU clock enable */ - __HAL_RCC_GFXMMU_CLK_ENABLE(); - - /* Enable GFXMMU interrupt */ - NVIC_SetPriority(GFXMMU_IRQn, IRQ_PRI_NORMAL); - NVIC_EnableIRQ(GFXMMU_IRQn); -} - -/** - * @brief De-Initialize GFXMMU MSP. - * @param hgfxmmu GFXMMU handle - * @retval None - */ -static void GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu) { - /* Prevent unused argument(s) compilation warning */ - UNUSED(hgfxmmu); - - /* Disable GFXMMU interrupt */ - NVIC_DisableIRQ(GFXMMU_IRQn); - - /* GFXMMU clock disable */ - __HAL_RCC_GFXMMU_CLK_DISABLE(); -} - -/** - * @brief Initialize LTDC MSP. - * @param hltdc LTDC handle - * @retval None - */ -static void LTDC_MspInit(LTDC_HandleTypeDef *hltdc) { - /* Prevent unused argument(s) compilation warning */ - UNUSED(hltdc); - - /* Enable LCD clock */ - __HAL_RCC_LTDC_CLK_ENABLE(); - - /* Enable LTDC interrupt */ - NVIC_SetPriority(LTDC_IRQn, IRQ_PRI_NORMAL); - NVIC_EnableIRQ(LTDC_IRQn); - - NVIC_SetPriority(LTDC_ER_IRQn, IRQ_PRI_NORMAL); - NVIC_EnableIRQ(LTDC_ER_IRQn); -} - -/** - * @brief De-Initialize LTDC MSP. - * @param hltdc LTDC handle - * @retval None - */ -static void LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc) { - /* Prevent unused argument(s) compilation warning */ - UNUSED(hltdc); - - /* Disable LTDC interrupts */ - NVIC_DisableIRQ(LTDC_ER_IRQn); - NVIC_DisableIRQ(LTDC_IRQn); - - /* LTDC clock disable */ - __HAL_RCC_LTDC_CLK_DISABLE(); -} - -/** - * @brief Initialize DSI MSP. - * @param hdsi DSI handle - * @retval None - */ -static void DSI_MspInit(DSI_HandleTypeDef *hdsi) { - RCC_PeriphCLKInitTypeDef PLL3InitPeriph = {0}; - RCC_PeriphCLKInitTypeDef DSIPHYInitPeriph = {0}; - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - UNUSED(hdsi); - - /* Enable GPIOI & GPIOD clocks */ - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOI_CLK_ENABLE(); - - /* Configure DSI Reset pin */ - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - GPIO_InitStruct.Pin = GPIO_PIN_5; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /* Configure LCD Backlight Pin */ - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Pin = GPIO_PIN_6; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - - /* Enable DSI clock */ - __HAL_RCC_DSI_CLK_ENABLE(); - - /** ################ Set DSI clock to D-PHY source clock ################## - * **/ - - /* Start and configurre PLL3 */ - /* HSE = 16MHZ */ - /* 16/(M=4) = 4MHz input (min) */ - /* 4*(N=125) = 500MHz VCO (almost max) */ - /* 500/(P=8) = 62.5 for DSI ie exactly the lane byte clock*/ - - PLL3InitPeriph.PeriphClockSelection = RCC_PERIPHCLK_DSI; - PLL3InitPeriph.DsiClockSelection = RCC_DSICLKSOURCE_PLL3; - PLL3InitPeriph.PLL3.PLL3M = 4; - PLL3InitPeriph.PLL3.PLL3N = 125; - PLL3InitPeriph.PLL3.PLL3P = 8; - PLL3InitPeriph.PLL3.PLL3Q = 8; - PLL3InitPeriph.PLL3.PLL3R = 24; - PLL3InitPeriph.PLL3.PLL3FRACN = 0; - PLL3InitPeriph.PLL3.PLL3RGE = RCC_PLLVCIRANGE_1; - PLL3InitPeriph.PLL3.PLL3ClockOut = RCC_PLL3_DIVR | RCC_PLL3_DIVP; - PLL3InitPeriph.PLL3.PLL3Source = RCC_PLLSOURCE_HSE; - (void)HAL_RCCEx_PeriphCLKConfig(&PLL3InitPeriph); - - __HAL_RCC_DSI_CLK_ENABLE(); - - /* Switch to D-PHY source clock */ - /* Enable the DSI host */ - hlcd_dsi.Instance = DSI; - - __HAL_DSI_ENABLE(&hlcd_dsi); - - /* Enable the DSI PLL */ - __HAL_DSI_PLL_ENABLE(&hlcd_dsi); - - HAL_Delay(1); - - /* Enable the clock lane and the digital section of the D-PHY */ - hlcd_dsi.Instance->PCTLR |= (DSI_PCTLR_CKE | DSI_PCTLR_DEN); - - /* Set the TX escape clock division factor */ - hlcd_dsi.Instance->CCR = 4; - - HAL_Delay(1); - - /* Config DSI Clock to DSI PHY */ - DSIPHYInitPeriph.PeriphClockSelection = RCC_PERIPHCLK_DSI; - DSIPHYInitPeriph.DsiClockSelection = RCC_DSICLKSOURCE_DSIPHY; - - (void)HAL_RCCEx_PeriphCLKConfig(&DSIPHYInitPeriph); - - /* Reset */ - HAL_Delay(11); - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_5, GPIO_PIN_SET); - HAL_Delay(150); - - /* Reset the TX escape clock division factor */ - hlcd_dsi.Instance->CCR &= ~DSI_CCR_TXECKDIV; - - /* Disable the DSI PLL */ - __HAL_DSI_PLL_DISABLE(&hlcd_dsi); - - /* Disable the DSI host */ - __HAL_DSI_DISABLE(&hlcd_dsi); - - /** ######################################################################### - * **/ - - /* Enable DSI NVIC interrupt */ - /* Default is lowest priority level */ - NVIC_SetPriority(DSI_IRQn, IRQ_PRI_NORMAL); - NVIC_EnableIRQ(DSI_IRQn); -} - -/** - * @brief De-Initialize DSI MSP. - * @param hdsi DSI handle - * @retval None - */ -static void DSI_MspDeInit(DSI_HandleTypeDef *hdsi) { - RCC_PeriphCLKInitTypeDef PLL3InitPeriph = {0}; - - UNUSED(hdsi); - - /* Switch to PLL3 before Disable */ - PLL3InitPeriph.PeriphClockSelection = RCC_PERIPHCLK_DSI; - PLL3InitPeriph.DsiClockSelection = RCC_DSICLKSOURCE_PLL3; - PLL3InitPeriph.PLL3.PLL3M = 4; - PLL3InitPeriph.PLL3.PLL3N = 125; - PLL3InitPeriph.PLL3.PLL3P = 8; - PLL3InitPeriph.PLL3.PLL3Q = 8; - PLL3InitPeriph.PLL3.PLL3R = 24; - PLL3InitPeriph.PLL3.PLL3FRACN = 0; - PLL3InitPeriph.PLL3.PLL3RGE = RCC_PLLVCIRANGE_1; - PLL3InitPeriph.PLL3.PLL3ClockOut = RCC_PLL3_DIVR | RCC_PLL3_DIVP; - PLL3InitPeriph.PLL3.PLL3Source = RCC_PLLSOURCE_HSE; - (void)HAL_RCCEx_PeriphCLKConfig(&PLL3InitPeriph); - - /* DSI clock disable */ - __HAL_RCC_DSI_CLK_DISABLE(); - - /** @brief Toggle Sw reset of DSI IP */ - __HAL_RCC_DSI_FORCE_RESET(); - __HAL_RCC_DSI_RELEASE_RESET(); - - /* Disable DSI interrupts */ - NVIC_DisableIRQ(DSI_IRQn); -} - -void display_pixeldata(uint16_t c) { - uint32_t address = 0; - - if (act_frame_buffer == 0) { - address = GFXMMU_VIRTUAL_BUFFER1_BASE_S; - } else { - address = GFXMMU_VIRTUAL_BUFFER0_BASE_S; - } - - /* Get the rectangle start address */ - address = - (address + (4 * ((cursor_y + 120) * PIXEL_PER_LINE + (cursor_x + 120)))); - - *(__IO uint32_t *)(address) = rgb565_to_rgb888(c) | 0xFF000000; - - cursor_x++; - if (cursor_x > window_x1) { - cursor_x = window_x0; - cursor_y++; - } - if (cursor_y > window_y1) { - cursor_y = window_y0; - } -} - -// this is just for compatibility with DMA2D using algorithms -uint8_t *const DISPLAY_DATA_ADDRESS = 0; - -void display_reset_state() {} - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - window_x0 = x0; - window_y0 = y0; - window_x1 = x1; - window_y1 = y1; - cursor_x = x0; - cursor_y = y0; -} - -uint8_t *display_get_wr_addr(void) { - uint32_t address = 0; - - if (act_frame_buffer == 0) { - address = GFXMMU_VIRTUAL_BUFFER1_BASE_S; - } else { - address = GFXMMU_VIRTUAL_BUFFER0_BASE_S; - } - - /* Get the rectangle start address */ - address = - (address + (4 * ((cursor_y + 120) * PIXEL_PER_LINE + (cursor_x + 120)))); - - return (uint8_t *)address; -} - -uint32_t *display_get_fb_addr(void) { - uint32_t address = 0; - - if (act_frame_buffer == 0) { - address = GFXMMU_VIRTUAL_BUFFER1_BASE_S; - } else { - address = GFXMMU_VIRTUAL_BUFFER0_BASE_S; - } - - return (uint32_t *)address; -} - -void display_efficient_clear(void) { - if (act_frame_buffer == 0) { - memset(PhysFrameBuffer1, 0x00, sizeof(PhysFrameBuffer1)); - } else { - memset(PhysFrameBuffer0, 0x00, sizeof(PhysFrameBuffer0)); - } -} - -uint16_t display_get_window_width(void) { return window_x1 - window_x0 + 1; } - -uint16_t display_get_window_height(void) { return window_y1 - window_y0 + 1; } - -void display_shift_window(uint16_t pixels) { - uint16_t w = display_get_window_width(); - uint16_t h = display_get_window_height(); - - uint16_t line_rem = w - (cursor_x - window_x0); - - if (pixels < line_rem) { - cursor_x += pixels; - return; - } - - // start of next line - pixels = pixels - line_rem; - cursor_x = window_x0; - cursor_y++; - - // add the rest of pixels - cursor_y = window_y0 + (((cursor_y - window_y0) + (pixels / w)) % h); - cursor_x += pixels % w; -} - -uint16_t display_get_window_offset(void) { - return PIXEL_PER_LINE - display_get_window_width(); -} - -int display_orientation(int degrees) { return degrees; } - -int display_get_orientation(void) { return 0; } -int display_backlight(int val) { return val; } - -void display_init_all(void) { - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - - /** Initializes the common periph clock - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LTDC | RCC_PERIPHCLK_DSI; - PeriphClkInit.DsiClockSelection = RCC_DSICLKSOURCE_PLL3; - PeriphClkInit.LtdcClockSelection = RCC_LTDCCLKSOURCE_PLL3; - PeriphClkInit.PLL3.PLL3Source = RCC_PLLSOURCE_HSE; - PeriphClkInit.PLL3.PLL3M = 4; - PeriphClkInit.PLL3.PLL3N = 125; - PeriphClkInit.PLL3.PLL3P = 8; - PeriphClkInit.PLL3.PLL3Q = 2; - PeriphClkInit.PLL3.PLL3R = 24; - PeriphClkInit.PLL3.PLL3RGE = RCC_PLLVCIRANGE_0; - PeriphClkInit.PLL3.PLL3FRACN = 0; - PeriphClkInit.PLL3.PLL3ClockOut = RCC_PLL3_DIVP | RCC_PLL3_DIVR; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); - - memset(PhysFrameBuffer0, 0x00, sizeof(PhysFrameBuffer0)); - memset(PhysFrameBuffer1, 0x00, sizeof(PhysFrameBuffer1)); - memcpy(gfxmmu_lut, gfxmmu_lut_config_argb8888, - sizeof(gfxmmu_lut_config_argb8888)); - - BSP_LCD_Init(0, LCD_ORIENTATION_PORTRAIT); - - BSP_LCD_SetBrightness(0, 100); - BSP_LCD_SetActiveLayer(0, 0); - BSP_LCD_DisplayOn(0); -} -void display_reinit(void) { - memcpy(gfxmmu_lut, gfxmmu_lut_config_argb8888, - sizeof(gfxmmu_lut_config_argb8888)); - - /* Switch to D-PHY source clock */ - /* Enable the DSI host */ - hlcd_dsi.Instance = DSI; - MX_GFXMMU_Reinit(&hlcd_gfxmmu); - MX_DSI_Reinit(&hlcd_dsi); - MX_LTDC_Reinit(&hlcd_ltdc); - - if (act_frame_buffer == 0) { - MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, GFXMMU_VIRTUAL_BUFFER0_BASE_S); - } else { - MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, GFXMMU_VIRTUAL_BUFFER1_BASE_S); - } -} -void display_sync(void) {} - -void display_refresh(void) { - if (act_frame_buffer == 0) { - act_frame_buffer = 1; - MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, GFXMMU_VIRTUAL_BUFFER1_BASE_S); - memcpy(PhysFrameBuffer0, PhysFrameBuffer1, sizeof(PhysFrameBuffer1)); - } else { - act_frame_buffer = 0; - MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, GFXMMU_VIRTUAL_BUFFER0_BASE_S); - memcpy(PhysFrameBuffer1, PhysFrameBuffer0, sizeof(PhysFrameBuffer1)); - } -} - -const char *display_save(const char *prefix) { return NULL; } - -void display_clear_save(void) {} - -void display_pixeldata_dirty(void) {} - -void display_finish_actions(void) {} diff --git a/core/embed/trezorhal/stm32u5/displays/dsi.h b/core/embed/trezorhal/stm32u5/displays/dsi.h deleted file mode 100644 index c23daf557d..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/dsi.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DSI_H_ -#define DSI_H_ - -#include -#include - -#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_ARGB8888 -#define DISPLAY_FRAMEBUFFER_WIDTH 768 -#define DISPLAY_FRAMEBUFFER_HEIGHT 480 -#define DISPLAY_FRAMEBUFFER_OFFSET_X 120 -#define DISPLAY_FRAMEBUFFER_OFFSET_Y 120 - -#define DISPLAY_EFFICIENT_CLEAR 1 - -extern uint8_t* const DISPLAY_DATA_ADDRESS; - -uint32_t rgb565_to_rgb888(uint16_t color); - -static inline void display_pixel(uint8_t* fb, int16_t x, int16_t y, - uint16_t color) { - uint32_t p = 4 * ((y + 120) * DISPLAY_FRAMEBUFFER_WIDTH + (x + 120)); - uint32_t c = rgb565_to_rgb888(color); - *((uint32_t*)(fb + p)) = c; -} - -#endif diff --git a/core/embed/trezorhal/stm32u5/displays/gfxmmu_lut.h b/core/embed/trezorhal/stm32u5/displays/gfxmmu_lut.h deleted file mode 100644 index 7360378e8c..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/gfxmmu_lut.h +++ /dev/null @@ -1,1006 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * File Name : gfxmmu_lut.h - * Description : header file for GFX MMU Configuration Table - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __gfxmmu_lut_H -#define __gfxmmu_lut_H -#ifdef __cplusplus -extern "C" { -#endif -// GFX MMU Configuration Table - -#define GFXMMU_FB_SIZE 733936 -#define GFXMMU_LUT_FIRST 0 -#define GFXMMU_LUT_LAST 479 -#define GFXMMU_LUT_SIZE 480 - -uint32_t gfxmmu_lut_config_argb8888[2 * GFXMMU_LUT_SIZE] = { - 0x00413601, // GFXMMU_LUT0L - 0x003FFCA0, // GFXMMU_LUT0H - 0x00433401, // GFXMMU_LUT1L - 0x003FFD80, // GFXMMU_LUT1H - 0x00453201, // GFXMMU_LUT2L - 0x003FFEA0, // GFXMMU_LUT2H - 0x00463101, // GFXMMU_LUT3L - 0x003FFFF0, // GFXMMU_LUT3H - 0x00482F01, // GFXMMU_LUT4L - 0x00000170, // GFXMMU_LUT4H - 0x00492E01, // GFXMMU_LUT5L - 0x00000320, // GFXMMU_LUT5H - 0x004A2D01, // GFXMMU_LUT6L - 0x000004F0, // GFXMMU_LUT6H - 0x004B2C01, // GFXMMU_LUT7L - 0x000006E0, // GFXMMU_LUT7H - 0x004C2B01, // GFXMMU_LUT8L - 0x000008F0, // GFXMMU_LUT8H - 0x004D2A01, // GFXMMU_LUT9L - 0x00000B20, // GFXMMU_LUT9H - 0x004D2A01, // GFXMMU_LUT10L - 0x00000D60, // GFXMMU_LUT10H - 0x004E2901, // GFXMMU_LUT11L - 0x00000FB0, // GFXMMU_LUT11H - 0x004F2801, // GFXMMU_LUT12L - 0x00001220, // GFXMMU_LUT12H - 0x00502701, // GFXMMU_LUT13L - 0x000014B0, // GFXMMU_LUT13H - 0x00502701, // GFXMMU_LUT14L - 0x00001750, // GFXMMU_LUT14H - 0x00512601, // GFXMMU_LUT15L - 0x00001A00, // GFXMMU_LUT15H - 0x00522501, // GFXMMU_LUT16L - 0x00001CD0, // GFXMMU_LUT16H - 0x00522501, // GFXMMU_LUT17L - 0x00001FB0, // GFXMMU_LUT17H - 0x00532401, // GFXMMU_LUT18L - 0x000022A0, // GFXMMU_LUT18H - 0x00532401, // GFXMMU_LUT19L - 0x000025A0, // GFXMMU_LUT19H - 0x00542301, // GFXMMU_LUT20L - 0x000028B0, // GFXMMU_LUT20H - 0x00552201, // GFXMMU_LUT21L - 0x00002BE0, // GFXMMU_LUT21H - 0x00552201, // GFXMMU_LUT22L - 0x00002F20, // GFXMMU_LUT22H - 0x00562101, // GFXMMU_LUT23L - 0x00003270, // GFXMMU_LUT23H - 0x00562101, // GFXMMU_LUT24L - 0x000035D0, // GFXMMU_LUT24H - 0x00572001, // GFXMMU_LUT25L - 0x00003940, // GFXMMU_LUT25H - 0x00572001, // GFXMMU_LUT26L - 0x00003CC0, // GFXMMU_LUT26H - 0x00581F01, // GFXMMU_LUT27L - 0x00004050, // GFXMMU_LUT27H - 0x00581F01, // GFXMMU_LUT28L - 0x000043F0, // GFXMMU_LUT28H - 0x00591E01, // GFXMMU_LUT29L - 0x000047A0, // GFXMMU_LUT29H - 0x00591E01, // GFXMMU_LUT30L - 0x00004B60, // GFXMMU_LUT30H - 0x00591E01, // GFXMMU_LUT31L - 0x00004F20, // GFXMMU_LUT31H - 0x005A1D01, // GFXMMU_LUT32L - 0x000052F0, // GFXMMU_LUT32H - 0x005A1D01, // GFXMMU_LUT33L - 0x000056D0, // GFXMMU_LUT33H - 0x005B1C01, // GFXMMU_LUT34L - 0x00005AC0, // GFXMMU_LUT34H - 0x005B1C01, // GFXMMU_LUT35L - 0x00005EC0, // GFXMMU_LUT35H - 0x005C1B01, // GFXMMU_LUT36L - 0x000062D0, // GFXMMU_LUT36H - 0x005C1B01, // GFXMMU_LUT37L - 0x000066F0, // GFXMMU_LUT37H - 0x005C1B01, // GFXMMU_LUT38L - 0x00006B10, // GFXMMU_LUT38H - 0x005D1A01, // GFXMMU_LUT39L - 0x00006F40, // GFXMMU_LUT39H - 0x005D1A01, // GFXMMU_LUT40L - 0x00007380, // GFXMMU_LUT40H - 0x005D1A01, // GFXMMU_LUT41L - 0x000077C0, // GFXMMU_LUT41H - 0x005E1901, // GFXMMU_LUT42L - 0x00007C10, // GFXMMU_LUT42H - 0x005E1901, // GFXMMU_LUT43L - 0x00008070, // GFXMMU_LUT43H - 0x005E1901, // GFXMMU_LUT44L - 0x000084D0, // GFXMMU_LUT44H - 0x005F1801, // GFXMMU_LUT45L - 0x00008940, // GFXMMU_LUT45H - 0x005F1801, // GFXMMU_LUT46L - 0x00008DC0, // GFXMMU_LUT46H - 0x00601801, // GFXMMU_LUT47L - 0x00009240, // GFXMMU_LUT47H - 0x00601701, // GFXMMU_LUT48L - 0x000096E0, // GFXMMU_LUT48H - 0x00601701, // GFXMMU_LUT49L - 0x00009B80, // GFXMMU_LUT49H - 0x00601701, // GFXMMU_LUT50L - 0x0000A020, // GFXMMU_LUT50H - 0x00611601, // GFXMMU_LUT51L - 0x0000A4D0, // GFXMMU_LUT51H - 0x00611601, // GFXMMU_LUT52L - 0x0000A990, // GFXMMU_LUT52H - 0x00611601, // GFXMMU_LUT53L - 0x0000AE50, // GFXMMU_LUT53H - 0x00621501, // GFXMMU_LUT54L - 0x0000B320, // GFXMMU_LUT54H - 0x00621501, // GFXMMU_LUT55L - 0x0000B800, // GFXMMU_LUT55H - 0x00621501, // GFXMMU_LUT56L - 0x0000BCE0, // GFXMMU_LUT56H - 0x00631401, // GFXMMU_LUT57L - 0x0000C1D0, // GFXMMU_LUT57H - 0x00631401, // GFXMMU_LUT58L - 0x0000C6D0, // GFXMMU_LUT58H - 0x00631401, // GFXMMU_LUT59L - 0x0000CBD0, // GFXMMU_LUT59H - 0x00631401, // GFXMMU_LUT60L - 0x0000D0D0, // GFXMMU_LUT60H - 0x00641301, // GFXMMU_LUT61L - 0x0000D5E0, // GFXMMU_LUT61H - 0x00641301, // GFXMMU_LUT62L - 0x0000DB00, // GFXMMU_LUT62H - 0x00641301, // GFXMMU_LUT63L - 0x0000E020, // GFXMMU_LUT63H - 0x00651201, // GFXMMU_LUT64L - 0x0000E550, // GFXMMU_LUT64H - 0x00651201, // GFXMMU_LUT65L - 0x0000EA90, // GFXMMU_LUT65H - 0x00651201, // GFXMMU_LUT66L - 0x0000EFD0, // GFXMMU_LUT66H - 0x00651201, // GFXMMU_LUT67L - 0x0000F510, // GFXMMU_LUT67H - 0x00661101, // GFXMMU_LUT68L - 0x0000FA60, // GFXMMU_LUT68H - 0x00661101, // GFXMMU_LUT69L - 0x0000FFC0, // GFXMMU_LUT69H - 0x00661101, // GFXMMU_LUT70L - 0x00010520, // GFXMMU_LUT70H - 0x00661101, // GFXMMU_LUT71L - 0x00010A80, // GFXMMU_LUT71H - 0x00671001, // GFXMMU_LUT72L - 0x00010FF0, // GFXMMU_LUT72H - 0x00671001, // GFXMMU_LUT73L - 0x00011570, // GFXMMU_LUT73H - 0x00671001, // GFXMMU_LUT74L - 0x00011AF0, // GFXMMU_LUT74H - 0x00671001, // GFXMMU_LUT75L - 0x00012070, // GFXMMU_LUT75H - 0x00680F01, // GFXMMU_LUT76L - 0x00012600, // GFXMMU_LUT76H - 0x00680F01, // GFXMMU_LUT77L - 0x00012BA0, // GFXMMU_LUT77H - 0x00680F01, // GFXMMU_LUT78L - 0x00013140, // GFXMMU_LUT78H - 0x00680F01, // GFXMMU_LUT79L - 0x000136E0, // GFXMMU_LUT79H - 0x00680F01, // GFXMMU_LUT80L - 0x00013C80, // GFXMMU_LUT80H - 0x00690E01, // GFXMMU_LUT81L - 0x00014230, // GFXMMU_LUT81H - 0x00690E01, // GFXMMU_LUT82L - 0x000147F0, // GFXMMU_LUT82H - 0x00690E01, // GFXMMU_LUT83L - 0x00014DB0, // GFXMMU_LUT83H - 0x00690E01, // GFXMMU_LUT84L - 0x00015370, // GFXMMU_LUT84H - 0x006A0D01, // GFXMMU_LUT85L - 0x00015940, // GFXMMU_LUT85H - 0x006A0D01, // GFXMMU_LUT86L - 0x00015F20, // GFXMMU_LUT86H - 0x006A0D01, // GFXMMU_LUT87L - 0x00016500, // GFXMMU_LUT87H - 0x006A0D01, // GFXMMU_LUT88L - 0x00016AE0, // GFXMMU_LUT88H - 0x006A0D01, // GFXMMU_LUT89L - 0x000170C0, // GFXMMU_LUT89H - 0x006B0C01, // GFXMMU_LUT90L - 0x000176B0, // GFXMMU_LUT90H - 0x006B0C01, // GFXMMU_LUT91L - 0x00017CB0, // GFXMMU_LUT91H - 0x006B0C01, // GFXMMU_LUT92L - 0x000182B0, // GFXMMU_LUT92H - 0x006B0C01, // GFXMMU_LUT93L - 0x000188B0, // GFXMMU_LUT93H - 0x006B0C01, // GFXMMU_LUT94L - 0x00018EB0, // GFXMMU_LUT94H - 0x006C0C01, // GFXMMU_LUT95L - 0x000194B0, // GFXMMU_LUT95H - 0x006C0B01, // GFXMMU_LUT96L - 0x00019AD0, // GFXMMU_LUT96H - 0x006C0B01, // GFXMMU_LUT97L - 0x0001A0F0, // GFXMMU_LUT97H - 0x006C0B01, // GFXMMU_LUT98L - 0x0001A710, // GFXMMU_LUT98H - 0x006C0B01, // GFXMMU_LUT99L - 0x0001AD30, // GFXMMU_LUT99H - 0x006C0B01, // GFXMMU_LUT100L - 0x0001B350, // GFXMMU_LUT100H - 0x006D0A01, // GFXMMU_LUT101L - 0x0001B980, // GFXMMU_LUT101H - 0x006D0A01, // GFXMMU_LUT102L - 0x0001BFC0, // GFXMMU_LUT102H - 0x006D0A01, // GFXMMU_LUT103L - 0x0001C600, // GFXMMU_LUT103H - 0x006D0A01, // GFXMMU_LUT104L - 0x0001CC40, // GFXMMU_LUT104H - 0x006D0A01, // GFXMMU_LUT105L - 0x0001D280, // GFXMMU_LUT105H - 0x006D0A01, // GFXMMU_LUT106L - 0x0001D8C0, // GFXMMU_LUT106H - 0x006E0901, // GFXMMU_LUT107L - 0x0001DF10, // GFXMMU_LUT107H - 0x006E0901, // GFXMMU_LUT108L - 0x0001E570, // GFXMMU_LUT108H - 0x006E0901, // GFXMMU_LUT109L - 0x0001EBD0, // GFXMMU_LUT109H - 0x006E0901, // GFXMMU_LUT110L - 0x0001F230, // GFXMMU_LUT110H - 0x006E0901, // GFXMMU_LUT111L - 0x0001F890, // GFXMMU_LUT111H - 0x006E0901, // GFXMMU_LUT112L - 0x0001FEF0, // GFXMMU_LUT112H - 0x006F0801, // GFXMMU_LUT113L - 0x00020560, // GFXMMU_LUT113H - 0x006F0801, // GFXMMU_LUT114L - 0x00020BE0, // GFXMMU_LUT114H - 0x006F0801, // GFXMMU_LUT115L - 0x00021260, // GFXMMU_LUT115H - 0x006F0801, // GFXMMU_LUT116L - 0x000218E0, // GFXMMU_LUT116H - 0x006F0801, // GFXMMU_LUT117L - 0x00021F60, // GFXMMU_LUT117H - 0x006F0801, // GFXMMU_LUT118L - 0x000225E0, // GFXMMU_LUT118H - 0x006F0801, // GFXMMU_LUT119L - 0x00022C60, // GFXMMU_LUT119H - 0x00700701, // GFXMMU_LUT120L - 0x000232F0, // GFXMMU_LUT120H - 0x00700701, // GFXMMU_LUT121L - 0x00023990, // GFXMMU_LUT121H - 0x00700701, // GFXMMU_LUT122L - 0x00024030, // GFXMMU_LUT122H - 0x00700701, // GFXMMU_LUT123L - 0x000246D0, // GFXMMU_LUT123H - 0x00700701, // GFXMMU_LUT124L - 0x00024D70, // GFXMMU_LUT124H - 0x00700701, // GFXMMU_LUT125L - 0x00025410, // GFXMMU_LUT125H - 0x00700701, // GFXMMU_LUT126L - 0x00025AB0, // GFXMMU_LUT126H - 0x00710601, // GFXMMU_LUT127L - 0x00026160, // GFXMMU_LUT127H - 0x00710601, // GFXMMU_LUT128L - 0x00026820, // GFXMMU_LUT128H - 0x00710601, // GFXMMU_LUT129L - 0x00026EE0, // GFXMMU_LUT129H - 0x00710601, // GFXMMU_LUT130L - 0x000275A0, // GFXMMU_LUT130H - 0x00710601, // GFXMMU_LUT131L - 0x00027C60, // GFXMMU_LUT131H - 0x00710601, // GFXMMU_LUT132L - 0x00028320, // GFXMMU_LUT132H - 0x00710601, // GFXMMU_LUT133L - 0x000289E0, // GFXMMU_LUT133H - 0x00710601, // GFXMMU_LUT134L - 0x000290A0, // GFXMMU_LUT134H - 0x00720501, // GFXMMU_LUT135L - 0x00029770, // GFXMMU_LUT135H - 0x00720501, // GFXMMU_LUT136L - 0x00029E50, // GFXMMU_LUT136H - 0x00720501, // GFXMMU_LUT137L - 0x0002A530, // GFXMMU_LUT137H - 0x00720501, // GFXMMU_LUT138L - 0x0002AC10, // GFXMMU_LUT138H - 0x00720501, // GFXMMU_LUT139L - 0x0002B2F0, // GFXMMU_LUT139H - 0x00720501, // GFXMMU_LUT140L - 0x0002B9D0, // GFXMMU_LUT140H - 0x00720501, // GFXMMU_LUT141L - 0x0002C0B0, // GFXMMU_LUT141H - 0x00720501, // GFXMMU_LUT142L - 0x0002C790, // GFXMMU_LUT142H - 0x00720501, // GFXMMU_LUT143L - 0x0002CE70, // GFXMMU_LUT143H - 0x00730401, // GFXMMU_LUT144L - 0x0002D560, // GFXMMU_LUT144H - 0x00730401, // GFXMMU_LUT145L - 0x0002DC60, // GFXMMU_LUT145H - 0x00730401, // GFXMMU_LUT146L - 0x0002E360, // GFXMMU_LUT146H - 0x00730401, // GFXMMU_LUT147L - 0x0002EA60, // GFXMMU_LUT147H - 0x00730401, // GFXMMU_LUT148L - 0x0002F160, // GFXMMU_LUT148H - 0x00730401, // GFXMMU_LUT149L - 0x0002F860, // GFXMMU_LUT149H - 0x00730401, // GFXMMU_LUT150L - 0x0002FF60, // GFXMMU_LUT150H - 0x00730401, // GFXMMU_LUT151L - 0x00030660, // GFXMMU_LUT151H - 0x00730401, // GFXMMU_LUT152L - 0x00030D60, // GFXMMU_LUT152H - 0x00740301, // GFXMMU_LUT153L - 0x00031470, // GFXMMU_LUT153H - 0x00740301, // GFXMMU_LUT154L - 0x00031B90, // GFXMMU_LUT154H - 0x00740301, // GFXMMU_LUT155L - 0x000322B0, // GFXMMU_LUT155H - 0x00740301, // GFXMMU_LUT156L - 0x000329D0, // GFXMMU_LUT156H - 0x00740301, // GFXMMU_LUT157L - 0x000330F0, // GFXMMU_LUT157H - 0x00740301, // GFXMMU_LUT158L - 0x00033810, // GFXMMU_LUT158H - 0x00740301, // GFXMMU_LUT159L - 0x00033F30, // GFXMMU_LUT159H - 0x00740301, // GFXMMU_LUT160L - 0x00034650, // GFXMMU_LUT160H - 0x00740301, // GFXMMU_LUT161L - 0x00034D70, // GFXMMU_LUT161H - 0x00740301, // GFXMMU_LUT162L - 0x00035490, // GFXMMU_LUT162H - 0x00740301, // GFXMMU_LUT163L - 0x00035BB0, // GFXMMU_LUT163H - 0x00740301, // GFXMMU_LUT164L - 0x000362D0, // GFXMMU_LUT164H - 0x00750201, // GFXMMU_LUT165L - 0x00036A00, // GFXMMU_LUT165H - 0x00750201, // GFXMMU_LUT166L - 0x00037140, // GFXMMU_LUT166H - 0x00750201, // GFXMMU_LUT167L - 0x00037880, // GFXMMU_LUT167H - 0x00750201, // GFXMMU_LUT168L - 0x00037FC0, // GFXMMU_LUT168H - 0x00750201, // GFXMMU_LUT169L - 0x00038700, // GFXMMU_LUT169H - 0x00750201, // GFXMMU_LUT170L - 0x00038E40, // GFXMMU_LUT170H - 0x00750201, // GFXMMU_LUT171L - 0x00039580, // GFXMMU_LUT171H - 0x00750201, // GFXMMU_LUT172L - 0x00039CC0, // GFXMMU_LUT172H - 0x00750201, // GFXMMU_LUT173L - 0x0003A400, // GFXMMU_LUT173H - 0x00750201, // GFXMMU_LUT174L - 0x0003AB40, // GFXMMU_LUT174H - 0x00750201, // GFXMMU_LUT175L - 0x0003B280, // GFXMMU_LUT175H - 0x00750201, // GFXMMU_LUT176L - 0x0003B9C0, // GFXMMU_LUT176H - 0x00750201, // GFXMMU_LUT177L - 0x0003C100, // GFXMMU_LUT177H - 0x00760101, // GFXMMU_LUT178L - 0x0003C850, // GFXMMU_LUT178H - 0x00760101, // GFXMMU_LUT179L - 0x0003CFB0, // GFXMMU_LUT179H - 0x00760101, // GFXMMU_LUT180L - 0x0003D710, // GFXMMU_LUT180H - 0x00760101, // GFXMMU_LUT181L - 0x0003DE70, // GFXMMU_LUT181H - 0x00760101, // GFXMMU_LUT182L - 0x0003E5D0, // GFXMMU_LUT182H - 0x00760101, // GFXMMU_LUT183L - 0x0003ED30, // GFXMMU_LUT183H - 0x00760101, // GFXMMU_LUT184L - 0x0003F490, // GFXMMU_LUT184H - 0x00760101, // GFXMMU_LUT185L - 0x0003FBF0, // GFXMMU_LUT185H - 0x00760101, // GFXMMU_LUT186L - 0x00040350, // GFXMMU_LUT186H - 0x00760101, // GFXMMU_LUT187L - 0x00040AB0, // GFXMMU_LUT187H - 0x00760101, // GFXMMU_LUT188L - 0x00041210, // GFXMMU_LUT188H - 0x00760101, // GFXMMU_LUT189L - 0x00041970, // GFXMMU_LUT189H - 0x00760101, // GFXMMU_LUT190L - 0x000420D0, // GFXMMU_LUT190H - 0x00760101, // GFXMMU_LUT191L - 0x00042830, // GFXMMU_LUT191H - 0x00760101, // GFXMMU_LUT192L - 0x00042F90, // GFXMMU_LUT192H - 0x00760101, // GFXMMU_LUT193L - 0x000436F0, // GFXMMU_LUT193H - 0x00760101, // GFXMMU_LUT194L - 0x00043E50, // GFXMMU_LUT194H - 0x00760101, // GFXMMU_LUT195L - 0x000445B0, // GFXMMU_LUT195H - 0x00770001, // GFXMMU_LUT196L - 0x00044D20, // GFXMMU_LUT196H - 0x00770001, // GFXMMU_LUT197L - 0x000454A0, // GFXMMU_LUT197H - 0x00770001, // GFXMMU_LUT198L - 0x00045C20, // GFXMMU_LUT198H - 0x00770001, // GFXMMU_LUT199L - 0x000463A0, // GFXMMU_LUT199H - 0x00770001, // GFXMMU_LUT200L - 0x00046B20, // GFXMMU_LUT200H - 0x00770001, // GFXMMU_LUT201L - 0x000472A0, // GFXMMU_LUT201H - 0x00770001, // GFXMMU_LUT202L - 0x00047A20, // GFXMMU_LUT202H - 0x00770001, // GFXMMU_LUT203L - 0x000481A0, // GFXMMU_LUT203H - 0x00770001, // GFXMMU_LUT204L - 0x00048920, // GFXMMU_LUT204H - 0x00770001, // GFXMMU_LUT205L - 0x000490A0, // GFXMMU_LUT205H - 0x00770001, // GFXMMU_LUT206L - 0x00049820, // GFXMMU_LUT206H - 0x00770001, // GFXMMU_LUT207L - 0x00049FA0, // GFXMMU_LUT207H - 0x00770001, // GFXMMU_LUT208L - 0x0004A720, // GFXMMU_LUT208H - 0x00770001, // GFXMMU_LUT209L - 0x0004AEA0, // GFXMMU_LUT209H - 0x00770001, // GFXMMU_LUT210L - 0x0004B620, // GFXMMU_LUT210H - 0x00770001, // GFXMMU_LUT211L - 0x0004BDA0, // GFXMMU_LUT211H - 0x00770001, // GFXMMU_LUT212L - 0x0004C520, // GFXMMU_LUT212H - 0x00770001, // GFXMMU_LUT213L - 0x0004CCA0, // GFXMMU_LUT213H - 0x00770001, // GFXMMU_LUT214L - 0x0004D420, // GFXMMU_LUT214H - 0x00770001, // GFXMMU_LUT215L - 0x0004DBA0, // GFXMMU_LUT215H - 0x00770001, // GFXMMU_LUT216L - 0x0004E320, // GFXMMU_LUT216H - 0x00770001, // GFXMMU_LUT217L - 0x0004EAA0, // GFXMMU_LUT217H - 0x00770001, // GFXMMU_LUT218L - 0x0004F220, // GFXMMU_LUT218H - 0x00770001, // GFXMMU_LUT219L - 0x0004F9A0, // GFXMMU_LUT219H - 0x00770001, // GFXMMU_LUT220L - 0x00050120, // GFXMMU_LUT220H - 0x00770001, // GFXMMU_LUT221L - 0x000508A0, // GFXMMU_LUT221H - 0x00770001, // GFXMMU_LUT222L - 0x00051020, // GFXMMU_LUT222H - 0x00770001, // GFXMMU_LUT223L - 0x000517A0, // GFXMMU_LUT223H - 0x00770001, // GFXMMU_LUT224L - 0x00051F20, // GFXMMU_LUT224H - 0x00770001, // GFXMMU_LUT225L - 0x000526A0, // GFXMMU_LUT225H - 0x00770001, // GFXMMU_LUT226L - 0x00052E20, // GFXMMU_LUT226H - 0x00770001, // GFXMMU_LUT227L - 0x000535A0, // GFXMMU_LUT227H - 0x00770001, // GFXMMU_LUT228L - 0x00053D20, // GFXMMU_LUT228H - 0x00770001, // GFXMMU_LUT229L - 0x000544A0, // GFXMMU_LUT229H - 0x00770001, // GFXMMU_LUT230L - 0x00054C20, // GFXMMU_LUT230H - 0x00770001, // GFXMMU_LUT231L - 0x000553A0, // GFXMMU_LUT231H - 0x00770001, // GFXMMU_LUT232L - 0x00055B20, // GFXMMU_LUT232H - 0x00770001, // GFXMMU_LUT233L - 0x000562A0, // GFXMMU_LUT233H - 0x00770001, // GFXMMU_LUT234L - 0x00056A20, // GFXMMU_LUT234H - 0x00770001, // GFXMMU_LUT235L - 0x000571A0, // GFXMMU_LUT235H - 0x00770001, // GFXMMU_LUT236L - 0x00057920, // GFXMMU_LUT236H - 0x00770001, // GFXMMU_LUT237L - 0x000580A0, // GFXMMU_LUT237H - 0x00770001, // GFXMMU_LUT238L - 0x00058820, // GFXMMU_LUT238H - 0x00770001, // GFXMMU_LUT239L - 0x00058FA0, // GFXMMU_LUT239H - 0x00780001, // GFXMMU_LUT240L - 0x00059720, // GFXMMU_LUT240H - 0x00770001, // GFXMMU_LUT241L - 0x00059EB0, // GFXMMU_LUT241H - 0x00770001, // GFXMMU_LUT242L - 0x0005A630, // GFXMMU_LUT242H - 0x00770001, // GFXMMU_LUT243L - 0x0005ADB0, // GFXMMU_LUT243H - 0x00770001, // GFXMMU_LUT244L - 0x0005B530, // GFXMMU_LUT244H - 0x00770001, // GFXMMU_LUT245L - 0x0005BCB0, // GFXMMU_LUT245H - 0x00770001, // GFXMMU_LUT246L - 0x0005C430, // GFXMMU_LUT246H - 0x00770001, // GFXMMU_LUT247L - 0x0005CBB0, // GFXMMU_LUT247H - 0x00770001, // GFXMMU_LUT248L - 0x0005D330, // GFXMMU_LUT248H - 0x00770001, // GFXMMU_LUT249L - 0x0005DAB0, // GFXMMU_LUT249H - 0x00770001, // GFXMMU_LUT250L - 0x0005E230, // GFXMMU_LUT250H - 0x00770001, // GFXMMU_LUT251L - 0x0005E9B0, // GFXMMU_LUT251H - 0x00770001, // GFXMMU_LUT252L - 0x0005F130, // GFXMMU_LUT252H - 0x00770001, // GFXMMU_LUT253L - 0x0005F8B0, // GFXMMU_LUT253H - 0x00770001, // GFXMMU_LUT254L - 0x00060030, // GFXMMU_LUT254H - 0x00770001, // GFXMMU_LUT255L - 0x000607B0, // GFXMMU_LUT255H - 0x00770001, // GFXMMU_LUT256L - 0x00060F30, // GFXMMU_LUT256H - 0x00770001, // GFXMMU_LUT257L - 0x000616B0, // GFXMMU_LUT257H - 0x00770001, // GFXMMU_LUT258L - 0x00061E30, // GFXMMU_LUT258H - 0x00770001, // GFXMMU_LUT259L - 0x000625B0, // GFXMMU_LUT259H - 0x00770001, // GFXMMU_LUT260L - 0x00062D30, // GFXMMU_LUT260H - 0x00770001, // GFXMMU_LUT261L - 0x000634B0, // GFXMMU_LUT261H - 0x00770001, // GFXMMU_LUT262L - 0x00063C30, // GFXMMU_LUT262H - 0x00770001, // GFXMMU_LUT263L - 0x000643B0, // GFXMMU_LUT263H - 0x00770001, // GFXMMU_LUT264L - 0x00064B30, // GFXMMU_LUT264H - 0x00770001, // GFXMMU_LUT265L - 0x000652B0, // GFXMMU_LUT265H - 0x00770001, // GFXMMU_LUT266L - 0x00065A30, // GFXMMU_LUT266H - 0x00770001, // GFXMMU_LUT267L - 0x000661B0, // GFXMMU_LUT267H - 0x00770001, // GFXMMU_LUT268L - 0x00066930, // GFXMMU_LUT268H - 0x00770001, // GFXMMU_LUT269L - 0x000670B0, // GFXMMU_LUT269H - 0x00770001, // GFXMMU_LUT270L - 0x00067830, // GFXMMU_LUT270H - 0x00770001, // GFXMMU_LUT271L - 0x00067FB0, // GFXMMU_LUT271H - 0x00770001, // GFXMMU_LUT272L - 0x00068730, // GFXMMU_LUT272H - 0x00770001, // GFXMMU_LUT273L - 0x00068EB0, // GFXMMU_LUT273H - 0x00770001, // GFXMMU_LUT274L - 0x00069630, // GFXMMU_LUT274H - 0x00770001, // GFXMMU_LUT275L - 0x00069DB0, // GFXMMU_LUT275H - 0x00770001, // GFXMMU_LUT276L - 0x0006A530, // GFXMMU_LUT276H - 0x00770001, // GFXMMU_LUT277L - 0x0006ACB0, // GFXMMU_LUT277H - 0x00770001, // GFXMMU_LUT278L - 0x0006B430, // GFXMMU_LUT278H - 0x00770001, // GFXMMU_LUT279L - 0x0006BBB0, // GFXMMU_LUT279H - 0x00770001, // GFXMMU_LUT280L - 0x0006C330, // GFXMMU_LUT280H - 0x00770001, // GFXMMU_LUT281L - 0x0006CAB0, // GFXMMU_LUT281H - 0x00770001, // GFXMMU_LUT282L - 0x0006D230, // GFXMMU_LUT282H - 0x00770001, // GFXMMU_LUT283L - 0x0006D9B0, // GFXMMU_LUT283H - 0x00770001, // GFXMMU_LUT284L - 0x0006E130, // GFXMMU_LUT284H - 0x00760101, // GFXMMU_LUT285L - 0x0006E8A0, // GFXMMU_LUT285H - 0x00760101, // GFXMMU_LUT286L - 0x0006F000, // GFXMMU_LUT286H - 0x00760101, // GFXMMU_LUT287L - 0x0006F760, // GFXMMU_LUT287H - 0x00760101, // GFXMMU_LUT288L - 0x0006FEC0, // GFXMMU_LUT288H - 0x00760101, // GFXMMU_LUT289L - 0x00070620, // GFXMMU_LUT289H - 0x00760101, // GFXMMU_LUT290L - 0x00070D80, // GFXMMU_LUT290H - 0x00760101, // GFXMMU_LUT291L - 0x000714E0, // GFXMMU_LUT291H - 0x00760101, // GFXMMU_LUT292L - 0x00071C40, // GFXMMU_LUT292H - 0x00760101, // GFXMMU_LUT293L - 0x000723A0, // GFXMMU_LUT293H - 0x00760101, // GFXMMU_LUT294L - 0x00072B00, // GFXMMU_LUT294H - 0x00760101, // GFXMMU_LUT295L - 0x00073260, // GFXMMU_LUT295H - 0x00760101, // GFXMMU_LUT296L - 0x000739C0, // GFXMMU_LUT296H - 0x00760101, // GFXMMU_LUT297L - 0x00074120, // GFXMMU_LUT297H - 0x00760101, // GFXMMU_LUT298L - 0x00074880, // GFXMMU_LUT298H - 0x00760101, // GFXMMU_LUT299L - 0x00074FE0, // GFXMMU_LUT299H - 0x00760101, // GFXMMU_LUT300L - 0x00075740, // GFXMMU_LUT300H - 0x00760101, // GFXMMU_LUT301L - 0x00075EA0, // GFXMMU_LUT301H - 0x00760101, // GFXMMU_LUT302L - 0x00076600, // GFXMMU_LUT302H - 0x00750201, // GFXMMU_LUT303L - 0x00076D50, // GFXMMU_LUT303H - 0x00750201, // GFXMMU_LUT304L - 0x00077490, // GFXMMU_LUT304H - 0x00750201, // GFXMMU_LUT305L - 0x00077BD0, // GFXMMU_LUT305H - 0x00750201, // GFXMMU_LUT306L - 0x00078310, // GFXMMU_LUT306H - 0x00750201, // GFXMMU_LUT307L - 0x00078A50, // GFXMMU_LUT307H - 0x00750201, // GFXMMU_LUT308L - 0x00079190, // GFXMMU_LUT308H - 0x00750201, // GFXMMU_LUT309L - 0x000798D0, // GFXMMU_LUT309H - 0x00750201, // GFXMMU_LUT310L - 0x0007A010, // GFXMMU_LUT310H - 0x00750201, // GFXMMU_LUT311L - 0x0007A750, // GFXMMU_LUT311H - 0x00750201, // GFXMMU_LUT312L - 0x0007AE90, // GFXMMU_LUT312H - 0x00750201, // GFXMMU_LUT313L - 0x0007B5D0, // GFXMMU_LUT313H - 0x00750201, // GFXMMU_LUT314L - 0x0007BD10, // GFXMMU_LUT314H - 0x00750201, // GFXMMU_LUT315L - 0x0007C450, // GFXMMU_LUT315H - 0x00740301, // GFXMMU_LUT316L - 0x0007CB80, // GFXMMU_LUT316H - 0x00740301, // GFXMMU_LUT317L - 0x0007D2A0, // GFXMMU_LUT317H - 0x00740301, // GFXMMU_LUT318L - 0x0007D9C0, // GFXMMU_LUT318H - 0x00740301, // GFXMMU_LUT319L - 0x0007E0E0, // GFXMMU_LUT319H - 0x00740301, // GFXMMU_LUT320L - 0x0007E800, // GFXMMU_LUT320H - 0x00740301, // GFXMMU_LUT321L - 0x0007EF20, // GFXMMU_LUT321H - 0x00740301, // GFXMMU_LUT322L - 0x0007F640, // GFXMMU_LUT322H - 0x00740301, // GFXMMU_LUT323L - 0x0007FD60, // GFXMMU_LUT323H - 0x00740301, // GFXMMU_LUT324L - 0x00080480, // GFXMMU_LUT324H - 0x00740301, // GFXMMU_LUT325L - 0x00080BA0, // GFXMMU_LUT325H - 0x00740301, // GFXMMU_LUT326L - 0x000812C0, // GFXMMU_LUT326H - 0x00740301, // GFXMMU_LUT327L - 0x000819E0, // GFXMMU_LUT327H - 0x00730401, // GFXMMU_LUT328L - 0x000820F0, // GFXMMU_LUT328H - 0x00730401, // GFXMMU_LUT329L - 0x000827F0, // GFXMMU_LUT329H - 0x00730401, // GFXMMU_LUT330L - 0x00082EF0, // GFXMMU_LUT330H - 0x00730401, // GFXMMU_LUT331L - 0x000835F0, // GFXMMU_LUT331H - 0x00730401, // GFXMMU_LUT332L - 0x00083CF0, // GFXMMU_LUT332H - 0x00730401, // GFXMMU_LUT333L - 0x000843F0, // GFXMMU_LUT333H - 0x00730401, // GFXMMU_LUT334L - 0x00084AF0, // GFXMMU_LUT334H - 0x00730401, // GFXMMU_LUT335L - 0x000851F0, // GFXMMU_LUT335H - 0x00730401, // GFXMMU_LUT336L - 0x000858F0, // GFXMMU_LUT336H - 0x00730401, // GFXMMU_LUT337L - 0x00085FF0, // GFXMMU_LUT337H - 0x00720501, // GFXMMU_LUT338L - 0x000866E0, // GFXMMU_LUT338H - 0x00720501, // GFXMMU_LUT339L - 0x00086DC0, // GFXMMU_LUT339H - 0x00720501, // GFXMMU_LUT340L - 0x000874A0, // GFXMMU_LUT340H - 0x00720501, // GFXMMU_LUT341L - 0x00087B80, // GFXMMU_LUT341H - 0x00720501, // GFXMMU_LUT342L - 0x00088260, // GFXMMU_LUT342H - 0x00720501, // GFXMMU_LUT343L - 0x00088940, // GFXMMU_LUT343H - 0x00720501, // GFXMMU_LUT344L - 0x00089020, // GFXMMU_LUT344H - 0x00720501, // GFXMMU_LUT345L - 0x00089700, // GFXMMU_LUT345H - 0x00710601, // GFXMMU_LUT346L - 0x00089DD0, // GFXMMU_LUT346H - 0x00710601, // GFXMMU_LUT347L - 0x0008A490, // GFXMMU_LUT347H - 0x00710601, // GFXMMU_LUT348L - 0x0008AB50, // GFXMMU_LUT348H - 0x00710601, // GFXMMU_LUT349L - 0x0008B210, // GFXMMU_LUT349H - 0x00710601, // GFXMMU_LUT350L - 0x0008B8D0, // GFXMMU_LUT350H - 0x00710601, // GFXMMU_LUT351L - 0x0008BF90, // GFXMMU_LUT351H - 0x00710601, // GFXMMU_LUT352L - 0x0008C650, // GFXMMU_LUT352H - 0x00710601, // GFXMMU_LUT353L - 0x0008CD10, // GFXMMU_LUT353H - 0x00700701, // GFXMMU_LUT354L - 0x0008D3C0, // GFXMMU_LUT354H - 0x00700701, // GFXMMU_LUT355L - 0x0008DA60, // GFXMMU_LUT355H - 0x00700701, // GFXMMU_LUT356L - 0x0008E100, // GFXMMU_LUT356H - 0x00700701, // GFXMMU_LUT357L - 0x0008E7A0, // GFXMMU_LUT357H - 0x00700701, // GFXMMU_LUT358L - 0x0008EE40, // GFXMMU_LUT358H - 0x00700701, // GFXMMU_LUT359L - 0x0008F4E0, // GFXMMU_LUT359H - 0x00700701, // GFXMMU_LUT360L - 0x0008FB80, // GFXMMU_LUT360H - 0x006F0801, // GFXMMU_LUT361L - 0x00090210, // GFXMMU_LUT361H - 0x006F0801, // GFXMMU_LUT362L - 0x00090890, // GFXMMU_LUT362H - 0x006F0801, // GFXMMU_LUT363L - 0x00090F10, // GFXMMU_LUT363H - 0x006F0801, // GFXMMU_LUT364L - 0x00091590, // GFXMMU_LUT364H - 0x006F0801, // GFXMMU_LUT365L - 0x00091C10, // GFXMMU_LUT365H - 0x006F0801, // GFXMMU_LUT366L - 0x00092290, // GFXMMU_LUT366H - 0x006F0801, // GFXMMU_LUT367L - 0x00092910, // GFXMMU_LUT367H - 0x006E0901, // GFXMMU_LUT368L - 0x00092F80, // GFXMMU_LUT368H - 0x006E0901, // GFXMMU_LUT369L - 0x000935E0, // GFXMMU_LUT369H - 0x006E0901, // GFXMMU_LUT370L - 0x00093C40, // GFXMMU_LUT370H - 0x006E0901, // GFXMMU_LUT371L - 0x000942A0, // GFXMMU_LUT371H - 0x006E0901, // GFXMMU_LUT372L - 0x00094900, // GFXMMU_LUT372H - 0x006E0901, // GFXMMU_LUT373L - 0x00094F60, // GFXMMU_LUT373H - 0x006D0A01, // GFXMMU_LUT374L - 0x000955B0, // GFXMMU_LUT374H - 0x006D0A01, // GFXMMU_LUT375L - 0x00095BF0, // GFXMMU_LUT375H - 0x006D0A01, // GFXMMU_LUT376L - 0x00096230, // GFXMMU_LUT376H - 0x006D0A01, // GFXMMU_LUT377L - 0x00096870, // GFXMMU_LUT377H - 0x006D0A01, // GFXMMU_LUT378L - 0x00096EB0, // GFXMMU_LUT378H - 0x006C0B01, // GFXMMU_LUT379L - 0x000974E0, // GFXMMU_LUT379H - 0x006C0B01, // GFXMMU_LUT380L - 0x00097B00, // GFXMMU_LUT380H - 0x006C0B01, // GFXMMU_LUT381L - 0x00098120, // GFXMMU_LUT381H - 0x006C0B01, // GFXMMU_LUT382L - 0x00098740, // GFXMMU_LUT382H - 0x006C0B01, // GFXMMU_LUT383L - 0x00098D60, // GFXMMU_LUT383H - 0x006C0B01, // GFXMMU_LUT384L - 0x00099380, // GFXMMU_LUT384H - 0x006B0C01, // GFXMMU_LUT385L - 0x00099990, // GFXMMU_LUT385H - 0x006B0C01, // GFXMMU_LUT386L - 0x00099F90, // GFXMMU_LUT386H - 0x006B0C01, // GFXMMU_LUT387L - 0x0009A590, // GFXMMU_LUT387H - 0x006B0C01, // GFXMMU_LUT388L - 0x0009AB90, // GFXMMU_LUT388H - 0x006B0C01, // GFXMMU_LUT389L - 0x0009B190, // GFXMMU_LUT389H - 0x006A0D01, // GFXMMU_LUT390L - 0x0009B780, // GFXMMU_LUT390H - 0x006A0D01, // GFXMMU_LUT391L - 0x0009BD60, // GFXMMU_LUT391H - 0x006A0D01, // GFXMMU_LUT392L - 0x0009C340, // GFXMMU_LUT392H - 0x006A0D01, // GFXMMU_LUT393L - 0x0009C920, // GFXMMU_LUT393H - 0x006A0D01, // GFXMMU_LUT394L - 0x0009CF00, // GFXMMU_LUT394H - 0x00690E01, // GFXMMU_LUT395L - 0x0009D4D0, // GFXMMU_LUT395H - 0x00690E01, // GFXMMU_LUT396L - 0x0009DA90, // GFXMMU_LUT396H - 0x00690E01, // GFXMMU_LUT397L - 0x0009E050, // GFXMMU_LUT397H - 0x00690E01, // GFXMMU_LUT398L - 0x0009E610, // GFXMMU_LUT398H - 0x00690E01, // GFXMMU_LUT399L - 0x0009EBD0, // GFXMMU_LUT399H - 0x00690E01, // GFXMMU_LUT400L - 0x0009F190, // GFXMMU_LUT400H - 0x00690E01, // GFXMMU_LUT401L - 0x0009F750, // GFXMMU_LUT401H - 0x00680F01, // GFXMMU_LUT402L - 0x0009FD00, // GFXMMU_LUT402H - 0x00680F01, // GFXMMU_LUT403L - 0x000A02A0, // GFXMMU_LUT403H - 0x00680F01, // GFXMMU_LUT404L - 0x000A0840, // GFXMMU_LUT404H - 0x00680F01, // GFXMMU_LUT405L - 0x000A0DE0, // GFXMMU_LUT405H - 0x00671001, // GFXMMU_LUT406L - 0x000A1370, // GFXMMU_LUT406H - 0x00671001, // GFXMMU_LUT407L - 0x000A18F0, // GFXMMU_LUT407H - 0x00671001, // GFXMMU_LUT408L - 0x000A1E70, // GFXMMU_LUT408H - 0x00671001, // GFXMMU_LUT409L - 0x000A23F0, // GFXMMU_LUT409H - 0x00661101, // GFXMMU_LUT410L - 0x000A2960, // GFXMMU_LUT410H - 0x00661101, // GFXMMU_LUT411L - 0x000A2EC0, // GFXMMU_LUT411H - 0x00661101, // GFXMMU_LUT412L - 0x000A3420, // GFXMMU_LUT412H - 0x00661101, // GFXMMU_LUT413L - 0x000A3980, // GFXMMU_LUT413H - 0x00651201, // GFXMMU_LUT414L - 0x000A3ED0, // GFXMMU_LUT414H - 0x00651201, // GFXMMU_LUT415L - 0x000A4410, // GFXMMU_LUT415H - 0x00651201, // GFXMMU_LUT416L - 0x000A4950, // GFXMMU_LUT416H - 0x00641301, // GFXMMU_LUT417L - 0x000A4E80, // GFXMMU_LUT417H - 0x00641301, // GFXMMU_LUT418L - 0x000A53A0, // GFXMMU_LUT418H - 0x00641301, // GFXMMU_LUT419L - 0x000A58C0, // GFXMMU_LUT419H - 0x00641301, // GFXMMU_LUT420L - 0x000A5DE0, // GFXMMU_LUT420H - 0x00631401, // GFXMMU_LUT421L - 0x000A62F0, // GFXMMU_LUT421H - 0x00631401, // GFXMMU_LUT422L - 0x000A67F0, // GFXMMU_LUT422H - 0x00631401, // GFXMMU_LUT423L - 0x000A6CF0, // GFXMMU_LUT423H - 0x00621501, // GFXMMU_LUT424L - 0x000A71E0, // GFXMMU_LUT424H - 0x00621501, // GFXMMU_LUT425L - 0x000A76C0, // GFXMMU_LUT425H - 0x00621501, // GFXMMU_LUT426L - 0x000A7BA0, // GFXMMU_LUT426H - 0x00621501, // GFXMMU_LUT427L - 0x000A8080, // GFXMMU_LUT427H - 0x00611601, // GFXMMU_LUT428L - 0x000A8550, // GFXMMU_LUT428H - 0x00611601, // GFXMMU_LUT429L - 0x000A8A10, // GFXMMU_LUT429H - 0x00611601, // GFXMMU_LUT430L - 0x000A8ED0, // GFXMMU_LUT430H - 0x00601701, // GFXMMU_LUT431L - 0x000A9380, // GFXMMU_LUT431H - 0x00601701, // GFXMMU_LUT432L - 0x000A9820, // GFXMMU_LUT432H - 0x00601701, // GFXMMU_LUT433L - 0x000A9CC0, // GFXMMU_LUT433H - 0x005F1801, // GFXMMU_LUT434L - 0x000AA150, // GFXMMU_LUT434H - 0x005F1801, // GFXMMU_LUT435L - 0x000AA5D0, // GFXMMU_LUT435H - 0x005F1801, // GFXMMU_LUT436L - 0x000AAA50, // GFXMMU_LUT436H - 0x005E1901, // GFXMMU_LUT437L - 0x000AAEC0, // GFXMMU_LUT437H - 0x005E1901, // GFXMMU_LUT438L - 0x000AB320, // GFXMMU_LUT438H - 0x005D1A01, // GFXMMU_LUT439L - 0x000AB770, // GFXMMU_LUT439H - 0x005D1A01, // GFXMMU_LUT440L - 0x000ABBB0, // GFXMMU_LUT440H - 0x005D1A01, // GFXMMU_LUT441L - 0x000ABFF0, // GFXMMU_LUT441H - 0x005C1B01, // GFXMMU_LUT442L - 0x000AC420, // GFXMMU_LUT442H - 0x005C1B01, // GFXMMU_LUT443L - 0x000AC840, // GFXMMU_LUT443H - 0x005B1C01, // GFXMMU_LUT444L - 0x000ACC50, // GFXMMU_LUT444H - 0x005B1C01, // GFXMMU_LUT445L - 0x000AD050, // GFXMMU_LUT445H - 0x005B1C01, // GFXMMU_LUT446L - 0x000AD450, // GFXMMU_LUT446H - 0x005A1D01, // GFXMMU_LUT447L - 0x000AD840, // GFXMMU_LUT447H - 0x005A1D01, // GFXMMU_LUT448L - 0x000ADC20, // GFXMMU_LUT448H - 0x00591E01, // GFXMMU_LUT449L - 0x000ADFF0, // GFXMMU_LUT449H - 0x00591E01, // GFXMMU_LUT450L - 0x000AE3B0, // GFXMMU_LUT450H - 0x00581F01, // GFXMMU_LUT451L - 0x000AE760, // GFXMMU_LUT451H - 0x00581F01, // GFXMMU_LUT452L - 0x000AEB00, // GFXMMU_LUT452H - 0x00572001, // GFXMMU_LUT453L - 0x000AEE90, // GFXMMU_LUT453H - 0x00572001, // GFXMMU_LUT454L - 0x000AF210, // GFXMMU_LUT454H - 0x00562101, // GFXMMU_LUT455L - 0x000AF580, // GFXMMU_LUT455H - 0x00562101, // GFXMMU_LUT456L - 0x000AF8E0, // GFXMMU_LUT456H - 0x00552201, // GFXMMU_LUT457L - 0x000AFC30, // GFXMMU_LUT457H - 0x00552201, // GFXMMU_LUT458L - 0x000AFF70, // GFXMMU_LUT458H - 0x00542301, // GFXMMU_LUT459L - 0x000B02A0, // GFXMMU_LUT459H - 0x00542301, // GFXMMU_LUT460L - 0x000B05C0, // GFXMMU_LUT460H - 0x00532401, // GFXMMU_LUT461L - 0x000B08D0, // GFXMMU_LUT461H - 0x00522501, // GFXMMU_LUT462L - 0x000B0BC0, // GFXMMU_LUT462H - 0x00522501, // GFXMMU_LUT463L - 0x000B0EA0, // GFXMMU_LUT463H - 0x00512601, // GFXMMU_LUT464L - 0x000B1170, // GFXMMU_LUT464H - 0x00502701, // GFXMMU_LUT465L - 0x000B1420, // GFXMMU_LUT465H - 0x00502701, // GFXMMU_LUT466L - 0x000B16C0, // GFXMMU_LUT466H - 0x004F2801, // GFXMMU_LUT467L - 0x000B1950, // GFXMMU_LUT467H - 0x004E2901, // GFXMMU_LUT468L - 0x000B1BC0, // GFXMMU_LUT468H - 0x004D2A01, // GFXMMU_LUT469L - 0x000B1E10, // GFXMMU_LUT469H - 0x004D2A01, // GFXMMU_LUT470L - 0x000B2050, // GFXMMU_LUT470H - 0x004C2B01, // GFXMMU_LUT471L - 0x000B2280, // GFXMMU_LUT471H - 0x004B2C01, // GFXMMU_LUT472L - 0x000B2490, // GFXMMU_LUT472H - 0x004A2D01, // GFXMMU_LUT473L - 0x000B2680, // GFXMMU_LUT473H - 0x00492E01, // GFXMMU_LUT474L - 0x000B2850, // GFXMMU_LUT474H - 0x00482F01, // GFXMMU_LUT475L - 0x000B2A00, // GFXMMU_LUT475H - 0x00463101, // GFXMMU_LUT476L - 0x000B2B80, // GFXMMU_LUT476H - 0x00453201, // GFXMMU_LUT477L - 0x000B2CD0, // GFXMMU_LUT477H - 0x00433401, // GFXMMU_LUT478L - 0x000B2DF0, // GFXMMU_LUT478H - 0x00413601, // GFXMMU_LUT479L - 0x000B2ED0 // GFXMMU_LUT479H -}; - -#ifdef __cplusplus -} -#endif -#endif /*__ gfxmmu_lut_H */ - -/** - * @} - */ - -/** - * @} - */ diff --git a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.c b/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.c deleted file mode 120000 index 9a06799343..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.c +++ /dev/null @@ -1 +0,0 @@ -../../../stm32f4/displays/panels/lx154a2422.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.h b/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.h deleted file mode 120000 index 3bff068489..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2422.h +++ /dev/null @@ -1 +0,0 @@ -../../../stm32f4/displays/panels/lx154a2422.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.c b/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.c deleted file mode 100644 index 3ce189a3ff..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.c +++ /dev/null @@ -1,179 +0,0 @@ - -#include "display.h" -#include "displays/st7789v.h" -#include "touch.h" - -void lx154a2482_gamma(void) { - // positive voltage correction - CMD(0xE0); - DATA(0xD0); - DATA(0x0A); - DATA(0x10); - DATA(0x0A); - DATA(0x0A); - DATA(0x26); - DATA(0x36); - DATA(0x34); - DATA(0x4D); - DATA(0x18); - DATA(0x13); - DATA(0x14); - DATA(0x2F); - DATA(0x34); - - // negative voltage correction - CMD(0xE1); - DATA(0xD0); - DATA(0x0A); - DATA(0x10); - DATA(0x0A); - DATA(0x09); - DATA(0x26); - DATA(0x36); - DATA(0x53); - DATA(0x4C); - DATA(0x18); - DATA(0x14); - DATA(0x14); - DATA(0x2F); - DATA(0x34); -} - -void lx154a2482_init_seq(void) { - // TEON: Tearing Effect Line On; V-blanking only - CMD(0x35); - DATA(0x00); - - // Memory Data Access Control (MADCTL) - CMD(0x36); - DATA(0x00); - - // Interface Pixel Format - CMD(0x3A); - DATA(0x05); - - // Column Address Set - CMD(0x2A); - DATA(0x00); - DATA(0x00); - DATA(0x00); - DATA(0xEF); - - // Row Address Set - CMD(0x2B); - DATA(0x00); - DATA(0x00); - DATA(0x00); - DATA(0xEF); - - // Porch Setting - CMD(0xB2); - DATA(0x0C); - DATA(0x0C); - DATA(0x00); - DATA(0x33); - DATA(0x33); - - // VCOM Setting - CMD(0xBB); - DATA(0x1F); - - // LCMCTRL: LCM Control: XOR RGB setting - CMD(0xC0); - DATA(0x20); - - // VDV and VRH Command Enable - CMD(0xC2); - DATA(0x01); - - // VRH Set - CMD(0xC3); - DATA(0x0F); // 4.3V - - // VDV Setting - CMD(0xC4); - DATA(0x20); - - // Frame Rate Control in Normal Mode - CMD(0xC6); - DATA(0xEF); // column inversion //0X0F Dot INV, 60Hz - - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is gate 80.; - // gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - - // INVOFF (20h): Display Inversion Off - // INVON (21h): Display Inversion On - CMD(0x21); - // the above config is the most important and definitely necessary - - // PWCTRL1: Power Control 1 - CMD(0xD0); - DATA(0xA4); - DATA(0xA1); - - lx154a2482_gamma(); -} - -void lx154a2482_rotate(int degrees, display_padding_t* padding) { - uint16_t shift = 0; - char BX = 0, BY = 0; - -#define RGB (1 << 3) -#define ML (1 << 4) // vertical refresh order -#define MH (1 << 2) // horizontal refresh order -#define MV (1 << 5) -#define MX (1 << 6) -#define MY (1 << 7) - // MADCTL: Memory Data Access Control - reference: - // section 8.12 in the ST7789V manual - uint8_t display_command_parameter = 0; - switch (degrees) { - case 0: - display_command_parameter = 0; - BY = 0; - break; - case 90: - display_command_parameter = MV | MX | MH | ML; - BX = 1; - shift = 1; - break; - case 180: - display_command_parameter = MX | MY | MH | ML; - BY = 0; - shift = 1; - break; - case 270: - display_command_parameter = MV | MY; - BX = 1; - break; - } - - CMD(0x36); - DATA(display_command_parameter); - - if (shift) { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x00); - DATA(0x11); - } else { - // GATECTRL: Gate Control; NL = 240 gate lines, first scan line is - // gate 80.; gate scan direction 319 -> 0 - CMD(0xE4); - DATA(0x1D); - DATA(0x0A); - DATA(0x11); - } - - // reset the column and page extents - display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); - - padding->x = BX ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; - padding->y = BY ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; -} diff --git a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.h b/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.h deleted file mode 100644 index fa1f6eab10..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/panels/lx154a2482.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef LX154A2422_H_ -#define LX154A2422_H_ - -#include "displays/st7789v.h" - -void lx154a2482_init_seq(void); -void lx154a2482_gamma(void); -void lx154a2482_rotate(int degrees, display_padding_t* padding); - -#endif diff --git a/core/embed/trezorhal/stm32u5/displays/st7789v.c b/core/embed/trezorhal/stm32u5/displays/st7789v.c deleted file mode 120000 index 5f8dcd4cb6..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/st7789v.c +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/displays/st7789v.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/st7789v.h b/core/embed/trezorhal/stm32u5/displays/st7789v.h deleted file mode 120000 index 7974c7d91f..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/st7789v.h +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/displays/st7789v.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.c b/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.c deleted file mode 120000 index 4a0a88bfeb..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.c +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/displays/vg-2864ksweg01.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.h b/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.h deleted file mode 120000 index f57ce0f36c..0000000000 --- a/core/embed/trezorhal/stm32u5/displays/vg-2864ksweg01.h +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/displays/vg-2864ksweg01.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/dma2d.c b/core/embed/trezorhal/stm32u5/dma2d.c deleted file mode 120000 index 449adb7584..0000000000 --- a/core/embed/trezorhal/stm32u5/dma2d.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/dma2d.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/dma2d_bitblt.c b/core/embed/trezorhal/stm32u5/dma2d_bitblt.c deleted file mode 120000 index faeb9cc40b..0000000000 --- a/core/embed/trezorhal/stm32u5/dma2d_bitblt.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/dma2d_bitblt.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/fwutils.c b/core/embed/trezorhal/stm32u5/fwutils.c deleted file mode 120000 index 8968a5a024..0000000000 --- a/core/embed/trezorhal/stm32u5/fwutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/fwutils.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/irq.h b/core/embed/trezorhal/stm32u5/irq.h deleted file mode 120000 index f2c8e555e6..0000000000 --- a/core/embed/trezorhal/stm32u5/irq.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/irq.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/layout_helpers.h b/core/embed/trezorhal/stm32u5/layout_helpers.h deleted file mode 120000 index fc9960bef7..0000000000 --- a/core/embed/trezorhal/stm32u5/layout_helpers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/layout_helpers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/optiga_hal.c b/core/embed/trezorhal/stm32u5/optiga_hal.c deleted file mode 120000 index bd07df7044..0000000000 --- a/core/embed/trezorhal/stm32u5/optiga_hal.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/optiga_hal.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/pvd.c b/core/embed/trezorhal/stm32u5/pvd.c deleted file mode 120000 index e94aab5b3e..0000000000 --- a/core/embed/trezorhal/stm32u5/pvd.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/pvd.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/random_delays.c b/core/embed/trezorhal/stm32u5/random_delays.c deleted file mode 120000 index eb47d77293..0000000000 --- a/core/embed/trezorhal/stm32u5/random_delays.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/random_delays.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/rng.c b/core/embed/trezorhal/stm32u5/rng.c deleted file mode 120000 index f16159d787..0000000000 --- a/core/embed/trezorhal/stm32u5/rng.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/rng.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/sbu.c b/core/embed/trezorhal/stm32u5/sbu.c deleted file mode 120000 index 54c434947d..0000000000 --- a/core/embed/trezorhal/stm32u5/sbu.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/sbu.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall.c b/core/embed/trezorhal/stm32u5/syscall.c deleted file mode 120000 index 4995488e2a..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall.h b/core/embed/trezorhal/stm32u5/syscall.h deleted file mode 120000 index 8563747ddf..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_dispatch.c b/core/embed/trezorhal/stm32u5/syscall_dispatch.c deleted file mode 120000 index f7542fb99e..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_dispatch.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_dispatch.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_numbers.h b/core/embed/trezorhal/stm32u5/syscall_numbers.h deleted file mode 120000 index f2e572e964..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_numbers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_numbers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_probe.c b/core/embed/trezorhal/stm32u5/syscall_probe.c deleted file mode 120000 index b9351466af..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_probe.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_probe.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_probe.h b/core/embed/trezorhal/stm32u5/syscall_probe.h deleted file mode 120000 index 92b93e98c2..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_probe.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_probe.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_stubs.c b/core/embed/trezorhal/stm32u5/syscall_stubs.c deleted file mode 120000 index 877f2904f0..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_stubs.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_stubs.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_verifiers.c b/core/embed/trezorhal/stm32u5/syscall_verifiers.c deleted file mode 120000 index 22b83e8c93..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_verifiers.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_verifiers.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/syscall_verifiers.h b/core/embed/trezorhal/stm32u5/syscall_verifiers.h deleted file mode 120000 index bd32627b4e..0000000000 --- a/core/embed/trezorhal/stm32u5/syscall_verifiers.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/syscall_verifiers.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systask.c b/core/embed/trezorhal/stm32u5/systask.c deleted file mode 120000 index 7b6c139ae3..0000000000 --- a/core/embed/trezorhal/stm32u5/systask.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systask.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/system.c b/core/embed/trezorhal/stm32u5/system.c deleted file mode 120000 index 36a84d685c..0000000000 --- a/core/embed/trezorhal/stm32u5/system.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/system.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systemview.h b/core/embed/trezorhal/stm32u5/systemview.h deleted file mode 120000 index fda5c909e7..0000000000 --- a/core/embed/trezorhal/stm32u5/systemview.h +++ /dev/null @@ -1 +0,0 @@ -../../firmware/systemview.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systick.c b/core/embed/trezorhal/stm32u5/systick.c deleted file mode 120000 index 1a5e42f109..0000000000 --- a/core/embed/trezorhal/stm32u5/systick.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systick.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systick_internal.h b/core/embed/trezorhal/stm32u5/systick_internal.h deleted file mode 120000 index 2060732867..0000000000 --- a/core/embed/trezorhal/stm32u5/systick_internal.h +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systick_internal.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/systimer.c b/core/embed/trezorhal/stm32u5/systimer.c deleted file mode 120000 index 035d4ff20f..0000000000 --- a/core/embed/trezorhal/stm32u5/systimer.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/systimer.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/time_estimate.c b/core/embed/trezorhal/stm32u5/time_estimate.c deleted file mode 120000 index 9c2a9b118e..0000000000 --- a/core/embed/trezorhal/stm32u5/time_estimate.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/time_estimate.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/ft6x36.c b/core/embed/trezorhal/stm32u5/touch/ft6x36.c deleted file mode 120000 index 68b33fbb6a..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/ft6x36.c +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/ft6x36.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/ft6x36.h b/core/embed/trezorhal/stm32u5/touch/ft6x36.h deleted file mode 120000 index 2c609d19bf..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/ft6x36.h +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/ft6x36.h \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/touch/panels b/core/embed/trezorhal/stm32u5/touch/panels deleted file mode 120000 index 1923ae8946..0000000000 --- a/core/embed/trezorhal/stm32u5/touch/panels +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/touch/panels/ \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/unit_properties.c b/core/embed/trezorhal/stm32u5/unit_properties.c deleted file mode 120000 index d1874a0bc4..0000000000 --- a/core/embed/trezorhal/stm32u5/unit_properties.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/unit_properties.c \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/usb b/core/embed/trezorhal/stm32u5/usb deleted file mode 120000 index cbd91c097f..0000000000 --- a/core/embed/trezorhal/stm32u5/usb +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/usb \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/xdisplay/st-7789 b/core/embed/trezorhal/stm32u5/xdisplay/st-7789 deleted file mode 120000 index e524c4e49a..0000000000 --- a/core/embed/trezorhal/stm32u5/xdisplay/st-7789 +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/xdisplay/st-7789 \ No newline at end of file diff --git a/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 b/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 deleted file mode 120000 index 5f1987533d..0000000000 --- a/core/embed/trezorhal/stm32u5/xdisplay/vg-2864 +++ /dev/null @@ -1 +0,0 @@ -../../stm32f4/xdisplay/vg-2864 \ No newline at end of file diff --git a/core/embed/trezorhal/unix/display-unix.c b/core/embed/trezorhal/unix/display-unix.c deleted file mode 100644 index 7fd62fb3fb..0000000000 --- a/core/embed/trezorhal/unix/display-unix.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 . - */ -#define _GNU_SOURCE - -#include -#include - -#include -#include - -#include -#include - -#include "display.h" -#include "profile.h" - -#define EMULATOR_BORDER 16 - -static SDL_Window *WINDOW; -static SDL_Renderer *RENDERER; -static SDL_Surface *BUFFER; -static SDL_Texture *TEXTURE, *BACKGROUND; - -static SDL_Surface *PREV_SAVED; - -static int DISPLAY_BACKLIGHT = -1; -static int DISPLAY_ORIENTATION = -1; - -int sdl_display_res_x = DISPLAY_RESX, sdl_display_res_y = DISPLAY_RESY; -int sdl_touch_offset_x, sdl_touch_offset_y; - -// Using RGB565 (16-bit) color format. -typedef uint16_t pixel_color; - -// this is just for compatibility with DMA2D using algorithms -uint8_t *const DISPLAY_DATA_ADDRESS = 0; - -static struct { - struct { - uint16_t x, y; - } start; - struct { - uint16_t x, y; - } end; - struct { - uint16_t x, y; - } pos; -} PIXELWINDOW; - -void display_pixeldata(pixel_color c) { -#if !defined USE_RGB_COLORS - // set to white if highest bits of all R, G, B values are set to 1 - // bin(10000 100000 10000) = hex(0x8410) - // otherwise set to black - c = (c & 0x8410) ? 0xFFFF : 0x0000; -#endif - if (!RENDERER) { - display_init_all(); - } - if (PIXELWINDOW.pos.x <= PIXELWINDOW.end.x && - PIXELWINDOW.pos.y <= PIXELWINDOW.end.y) { - ((pixel_color *) - BUFFER->pixels)[PIXELWINDOW.pos.x + PIXELWINDOW.pos.y * BUFFER->pitch / - sizeof(pixel_color)] = c; - } - PIXELWINDOW.pos.x++; - if (PIXELWINDOW.pos.x > PIXELWINDOW.end.x) { - PIXELWINDOW.pos.x = PIXELWINDOW.start.x; - PIXELWINDOW.pos.y++; - } -} - -void display_pixeldata_dirty(void) {} - -void display_reset_state() {} - -void display_init_seq(void) {} - -void display_exit_handler(void) { - SDL_FreeSurface(PREV_SAVED); - SDL_FreeSurface(BUFFER); - if (BACKGROUND != NULL) { - SDL_DestroyTexture(BACKGROUND); - } - if (TEXTURE != NULL) { - SDL_DestroyTexture(TEXTURE); - } - if (RENDERER != NULL) { - SDL_DestroyRenderer(RENDERER); - } - if (WINDOW != NULL) { - SDL_DestroyWindow(WINDOW); - } - SDL_Quit(); -} - -void display_init_all(void) { - if (SDL_Init(SDL_INIT_VIDEO) != 0) { - printf("%s\n", SDL_GetError()); - error_shutdown("SDL_Init error"); - } - atexit(display_exit_handler); - - char *window_title = NULL; - char *window_title_alloc = NULL; - if (asprintf(&window_title_alloc, "Trezor^emu: %s", profile_name()) > 0) { - window_title = window_title_alloc; - } else { - window_title = "Trezor^emu"; - window_title_alloc = NULL; - } - - WINDOW = - SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, -#ifdef TREZOR_EMULATOR_RASPI - SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN -#else - SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI -#endif - ); - free(window_title_alloc); - if (!WINDOW) { - printf("%s\n", SDL_GetError()); - error_shutdown("SDL_CreateWindow error"); - } - RENDERER = SDL_CreateRenderer(WINDOW, -1, SDL_RENDERER_SOFTWARE); - if (!RENDERER) { - printf("%s\n", SDL_GetError()); - SDL_DestroyWindow(WINDOW); - error_shutdown("SDL_CreateRenderer error"); - } - SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 255); - SDL_RenderClear(RENDERER); - BUFFER = SDL_CreateRGBSurface(0, DISPLAY_RESX, DISPLAY_RESY, 16, 0xF800, - 0x07E0, 0x001F, 0x0000); - TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, - SDL_TEXTUREACCESS_STREAMING, DISPLAY_RESX, - DISPLAY_RESY); - SDL_SetTextureBlendMode(TEXTURE, SDL_BLENDMODE_BLEND); -#ifdef __APPLE__ - // macOS Mojave SDL black screen workaround - SDL_PumpEvents(); - SDL_SetWindowSize(WINDOW, WINDOW_WIDTH, WINDOW_HEIGHT); -#endif -#include BACKGROUND_FILE -#define CONCAT_LEN_HELPER(name) name##_len -#define CONCAT_LEN(name) CONCAT_LEN_HELPER(name) - BACKGROUND = IMG_LoadTexture_RW( - RENDERER, SDL_RWFromMem(BACKGROUND_NAME, CONCAT_LEN(BACKGROUND_NAME)), 0); - if (BACKGROUND) { - SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE); - sdl_touch_offset_x = TOUCH_OFFSET_X; - sdl_touch_offset_y = TOUCH_OFFSET_Y; - } else { - SDL_SetWindowSize(WINDOW, DISPLAY_RESX + 2 * EMULATOR_BORDER, - DISPLAY_RESY + 2 * EMULATOR_BORDER); - sdl_touch_offset_x = EMULATOR_BORDER; - sdl_touch_offset_y = EMULATOR_BORDER; - } -#if !USE_BACKLIGHT - // some models do not have backlight capabilities in hardware, so - // setting its value here for emulator to avoid - // calling any `set_backlight` functions - DISPLAY_BACKLIGHT = 255; -#else - DISPLAY_BACKLIGHT = 0; -#endif -#ifdef TREZOR_EMULATOR_RASPI - DISPLAY_ORIENTATION = 270; - SDL_ShowCursor(SDL_DISABLE); -#else - DISPLAY_ORIENTATION = 0; -#endif -} - -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - if (!RENDERER) { - display_init_all(); - } - PIXELWINDOW.start.x = x0; - PIXELWINDOW.start.y = y0; - PIXELWINDOW.end.x = x1; - PIXELWINDOW.end.y = y1; - PIXELWINDOW.pos.x = x0; - PIXELWINDOW.pos.y = y0; -} - -void display_sync(void) {} - -void display_refresh(void) { - if (!RENDERER) { - display_init_all(); - } - if (BACKGROUND) { - const SDL_Rect r = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; - SDL_RenderCopy(RENDERER, BACKGROUND, NULL, &r); - } else { - SDL_RenderClear(RENDERER); - } - // Show the display buffer - SDL_UpdateTexture(TEXTURE, NULL, BUFFER->pixels, BUFFER->pitch); -#define BACKLIGHT_NORMAL 150 - SDL_SetTextureAlphaMod(TEXTURE, - MIN(255, 255 * DISPLAY_BACKLIGHT / BACKLIGHT_NORMAL)); - if (BACKGROUND) { - const SDL_Rect r = {TOUCH_OFFSET_X, TOUCH_OFFSET_Y, DISPLAY_RESX, - DISPLAY_RESY}; - SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0); - } else { - const SDL_Rect r = {EMULATOR_BORDER, EMULATOR_BORDER, DISPLAY_RESX, - DISPLAY_RESY}; - SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0); - } - SDL_RenderPresent(RENDERER); -} - -int display_orientation(int degrees) { - if (degrees != DISPLAY_ORIENTATION) { -#if defined ORIENTATION_NSEW - if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) { -#elif defined ORIENTATION_NS - if (degrees == 0 || degrees == 180) { -#else - if (degrees == 0) { -#endif - DISPLAY_ORIENTATION = degrees; - display_refresh(); - } - } - return DISPLAY_ORIENTATION; -} - -int display_get_orientation(void) { return DISPLAY_ORIENTATION; } - -int display_backlight(int val) { -#if !USE_BACKLIGHT - val = 255; -#endif - if (DISPLAY_BACKLIGHT != val && val >= 0 && val <= 255) { - DISPLAY_BACKLIGHT = val; - display_refresh(); - } - return DISPLAY_BACKLIGHT; -} - -const char *display_save(const char *prefix) { - if (!RENDERER) { - display_init_all(); - } - static int count; - static char filename[256]; - // take a cropped view of the screen contents - const SDL_Rect rect = {0, 0, DISPLAY_RESX, DISPLAY_RESY}; - SDL_Surface *crop = SDL_CreateRGBSurface( - BUFFER->flags, rect.w, rect.h, BUFFER->format->BitsPerPixel, - BUFFER->format->Rmask, BUFFER->format->Gmask, BUFFER->format->Bmask, - BUFFER->format->Amask); - SDL_BlitSurface(BUFFER, &rect, crop, NULL); - // compare with previous screen, skip if equal - if (PREV_SAVED != NULL) { - if (memcmp(PREV_SAVED->pixels, crop->pixels, crop->pitch * crop->h) == 0) { - SDL_FreeSurface(crop); - return filename; - } - SDL_FreeSurface(PREV_SAVED); - } - // save to png - snprintf(filename, sizeof(filename), "%s%08d.png", prefix, count++); - IMG_SavePNG(crop, filename); - PREV_SAVED = crop; - return filename; -} - -void display_clear_save(void) { - SDL_FreeSurface(PREV_SAVED); - PREV_SAVED = NULL; -} - -uint8_t *display_get_wr_addr(void) { return (uint8_t *)DISPLAY_DATA_ADDRESS; } - -void display_finish_actions(void) {} - -void display_reinit(void) {} diff --git a/core/embed/trezorhal/unix/fwutils.c b/core/embed/trezorhal/unix/fwutils.c deleted file mode 120000 index 8968a5a024..0000000000 --- a/core/embed/trezorhal/unix/fwutils.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/fwutils.c \ No newline at end of file diff --git a/core/embed/trezorhal/unix/secret.c b/core/embed/trezorhal/unix/secret.c deleted file mode 120000 index 91e08f2ec9..0000000000 --- a/core/embed/trezorhal/unix/secret.c +++ /dev/null @@ -1 +0,0 @@ -../stm32f4/secret.c \ No newline at end of file diff --git a/core/embed/trezorhal/xdisplay_legacy.c b/core/embed/trezorhal/xdisplay_legacy.c deleted file mode 100644 index 8f63db4bc9..0000000000 --- a/core/embed/trezorhal/xdisplay_legacy.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 . - */ - -#include "xdisplay_legacy.h" -#include "xdisplay.h" - -// This code emulates the legacy display interface and will be -// removed after final cleanup of display drivers when the legacy code -// is removed. - -int display_orientation(int angle) { - if (angle >= 0) { - return display_set_orientation(angle); - } else { - return display_get_orientation(); - } -} - -int display_backlight(int level) { - if (level >= 0) { - return display_set_backlight(level); - } else { - return display_get_backlight(); - } -} - -void display_sync(void) { -#ifndef XFRAMEBUFFER - display_wait_for_sync(); -#endif -} diff --git a/core/embed/trezorhal/xdisplay_legacy.h b/core/embed/trezorhal/xdisplay_legacy.h deleted file mode 100644 index 39766895e5..0000000000 --- a/core/embed/trezorhal/xdisplay_legacy.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 . - */ - -#ifndef TREZORHAL_DISPLAY_LEGACY_H -#define TREZORHAL_DISPLAY_LEGACY_H - -#include - -#include "buffers.h" - -// These declarations will be removed after the final cleanup -// of display drivers. They are here just to simplify integration -// with the legacy code. -// -// Most of these functions are not called when NEW_RENDERING=1, -// and they are only needed for successful code compilation. - -#define DISPLAY_FRAMEBUFFER_WIDTH 768 -#define DISPLAY_FRAMEBUFFER_HEIGHT 480 -#define DISPLAY_FRAMEBUFFER_OFFSET_X 0 -#define DISPLAY_FRAMEBUFFER_OFFSET_Y 0 - -int display_orientation(int angle); -int display_backlight(int level); -void display_refresh(void); -void display_shift_window(uint16_t pixels); -uint16_t display_get_window_offset(void); -void display_pixeldata_dirty(void); -uint8_t* display_get_wr_addr(void); -void display_sync(void); -void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); -void display_pixeldata(uint16_t c); -uint32_t* display_get_fb_addr(void); - -void display_clear(void); -void display_text_render_buffer(const char* text, int textlen, int font, - buffer_text_t* buffer, int text_offset); - -#define PIXELDATA(c) display_pixeldata(c) - -#endif // TREZORHAL_DISPLAY_LEGACY_H