mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 07:20:56 +00:00
refactor(core): make display resolution constants global, board specific
[no changelog]
This commit is contained in:
parent
6e2486a2e2
commit
b97390a73a
@ -26,8 +26,6 @@
|
|||||||
#define IMAGE_HASH_BLAKE2S
|
#define IMAGE_HASH_BLAKE2S
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
||||||
#define DISPLAY_RESX 240
|
|
||||||
#define DISPLAY_RESY 320
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE
|
// SHARED WITH MAKEFILE
|
||||||
// common
|
// common
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
#define IMAGE_HASH_SHA256
|
#define IMAGE_HASH_SHA256
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
||||||
#define DISPLAY_RESX 240
|
|
||||||
#define DISPLAY_RESY 240
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
||||||
// misc
|
// misc
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#define IMAGE_HASH_BLAKE2S
|
#define IMAGE_HASH_BLAKE2S
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
||||||
#define DISPLAY_RESX 128
|
|
||||||
#define DISPLAY_RESY 64
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE
|
// SHARED WITH MAKEFILE
|
||||||
// common
|
// common
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#define IMAGE_HASH_BLAKE2S
|
#define IMAGE_HASH_BLAKE2S
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
||||||
#define DISPLAY_RESX 240
|
|
||||||
#define DISPLAY_RESY 240
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE
|
// SHARED WITH MAKEFILE
|
||||||
// common
|
// common
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#define IMAGE_HASH_SHA256
|
#define IMAGE_HASH_SHA256
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
||||||
#define DISPLAY_RESX 128
|
|
||||||
#define DISPLAY_RESY 64
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
||||||
// misc
|
// misc
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#define IMAGE_HASH_SHA256
|
#define IMAGE_HASH_SHA256
|
||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
|
||||||
#define DISPLAY_RESX 240
|
|
||||||
#define DISPLAY_RESY 240
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
||||||
// misc
|
// misc
|
||||||
|
@ -29,14 +29,6 @@
|
|||||||
|
|
||||||
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
|
||||||
|
|
||||||
#ifdef TREZOR_EMULATOR
|
|
||||||
#define DISPLAY_RESX 380
|
|
||||||
#define DISPLAY_RESY 520
|
|
||||||
#else
|
|
||||||
#define DISPLAY_RESX 240
|
|
||||||
#define DISPLAY_RESY 320
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
|
||||||
// misc
|
// misc
|
||||||
#define FLASH_START 0x0C004000
|
#define FLASH_START 0x0C004000
|
||||||
|
@ -59,6 +59,8 @@ const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[
|
|||||||
"-DTREZOR_MODEL_T",
|
"-DTREZOR_MODEL_T",
|
||||||
"-DFLASH_BIT_ACCESS=1",
|
"-DFLASH_BIT_ACCESS=1",
|
||||||
"-DFLASH_BLOCK_WORDS=1",
|
"-DFLASH_BLOCK_WORDS=1",
|
||||||
|
"-DDISPLAY_RESX=240",
|
||||||
|
"-DDISPLAY_RESY=240",
|
||||||
"-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"",
|
"-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"",
|
||||||
];
|
];
|
||||||
#[cfg(not(feature = "model_tt"))]
|
#[cfg(not(feature = "model_tt"))]
|
||||||
@ -70,6 +72,8 @@ const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[
|
|||||||
"-DTREZOR_MODEL_R",
|
"-DTREZOR_MODEL_R",
|
||||||
"-DFLASH_BIT_ACCESS=1",
|
"-DFLASH_BIT_ACCESS=1",
|
||||||
"-DFLASH_BLOCK_WORDS=1",
|
"-DFLASH_BLOCK_WORDS=1",
|
||||||
|
"-DDISPLAY_RESX=128",
|
||||||
|
"-DDISPLAY_RESY=64",
|
||||||
"-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"",
|
"-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"",
|
||||||
];
|
];
|
||||||
#[cfg(not(feature = "model_tr"))]
|
#[cfg(not(feature = "model_tr"))]
|
||||||
@ -81,6 +85,8 @@ const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[
|
|||||||
"-DTREZOR_MODEL_T3T1",
|
"-DTREZOR_MODEL_T3T1",
|
||||||
"-DFLASH_BIT_ACCESS=0",
|
"-DFLASH_BIT_ACCESS=0",
|
||||||
"-DFLASH_BLOCK_WORDS=4",
|
"-DFLASH_BLOCK_WORDS=4",
|
||||||
|
"-DDISPLAY_RESX=240",
|
||||||
|
"-DDISPLAY_RESY=240",
|
||||||
"-DTREZOR_BOARD=\"T3T1/boards/t3t1-unix.h\"",
|
"-DTREZOR_BOARD=\"T3T1/boards/t3t1-unix.h\"",
|
||||||
];
|
];
|
||||||
#[cfg(not(feature = "model_mercury"))]
|
#[cfg(not(feature = "model_mercury"))]
|
||||||
@ -353,8 +359,8 @@ fn generate_trezorhal_bindings() {
|
|||||||
.allowlist_function("display_set_backlight")
|
.allowlist_function("display_set_backlight")
|
||||||
.allowlist_function("display_get_backlight")
|
.allowlist_function("display_get_backlight")
|
||||||
.allowlist_function("display_wait_for_sync")
|
.allowlist_function("display_wait_for_sync")
|
||||||
.allowlist_var("DISPLAY_RESX")
|
.allowlist_var("DISPLAY_RESX_")
|
||||||
.allowlist_var("DISPLAY_RESY")
|
.allowlist_var("DISPLAY_RESY_")
|
||||||
.allowlist_type("display_fb_info_t")
|
.allowlist_type("display_fb_info_t")
|
||||||
.allowlist_function("display_get_frame_buffer")
|
.allowlist_function("display_get_frame_buffer")
|
||||||
.allowlist_function("display_fill")
|
.allowlist_function("display_fill")
|
||||||
|
@ -6,6 +6,8 @@ use crate::ui::{
|
|||||||
shape::{Bitmap, BitmapFormat, BitmapView},
|
shape::{Bitmap, BitmapFormat, BitmapView},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::trezorhal::display::{DISPLAY_RESX, DISPLAY_RESY};
|
||||||
|
|
||||||
/// Waits for the DMA2D peripheral transfer to complete.
|
/// Waits for the DMA2D peripheral transfer to complete.
|
||||||
pub fn wait_for_transfer() {
|
pub fn wait_for_transfer() {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
@ -203,8 +205,8 @@ impl BitBltFill {
|
|||||||
|
|
||||||
/// Fills a rectangle on the display with the specified color.
|
/// Fills a rectangle on the display with the specified color.
|
||||||
pub fn display_fill(&self) {
|
pub fn display_fill(&self) {
|
||||||
assert!(self.bitblt.dst_x + self.bitblt.width <= ffi::DISPLAY_RESX as u16);
|
assert!(self.bitblt.dst_x + self.bitblt.width <= DISPLAY_RESX as u16);
|
||||||
assert!(self.bitblt.dst_y + self.bitblt.height <= ffi::DISPLAY_RESY as u16);
|
assert!(self.bitblt.dst_y + self.bitblt.height <= DISPLAY_RESY as u16);
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// - The destination rectangle is completely inside the display.
|
// - The destination rectangle is completely inside the display.
|
||||||
unsafe { ffi::display_fill(&self.bitblt) };
|
unsafe { ffi::display_fill(&self.bitblt) };
|
||||||
@ -423,8 +425,8 @@ impl<'a> BitBltCopy<'a> {
|
|||||||
///
|
///
|
||||||
/// - The source bitmap uses the RGB565 format.
|
/// - The source bitmap uses the RGB565 format.
|
||||||
pub fn display_copy(&self) {
|
pub fn display_copy(&self) {
|
||||||
assert!(self.bitblt.dst_x + self.bitblt.width <= ffi::DISPLAY_RESX as u16);
|
assert!(self.bitblt.dst_x + self.bitblt.width <= DISPLAY_RESX as u16);
|
||||||
assert!(self.bitblt.dst_y + self.bitblt.height <= ffi::DISPLAY_RESY as u16);
|
assert!(self.bitblt.dst_y + self.bitblt.height <= DISPLAY_RESY as u16);
|
||||||
|
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// - The source bitmap is in the correct formats.
|
// - The source bitmap is in the correct formats.
|
||||||
|
@ -3,7 +3,10 @@ use super::ffi;
|
|||||||
#[cfg(feature = "framebuffer")]
|
#[cfg(feature = "framebuffer")]
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
|
||||||
pub use ffi::{DISPLAY_RESX, DISPLAY_RESY};
|
use ffi::{DISPLAY_RESX_, DISPLAY_RESY_};
|
||||||
|
|
||||||
|
pub const DISPLAY_RESX: u32 = DISPLAY_RESX_;
|
||||||
|
pub const DISPLAY_RESY: u32 = DISPLAY_RESY_;
|
||||||
|
|
||||||
pub type FontInfo = ffi::font_info_t;
|
pub type FontInfo = ffi::font_info_t;
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <trezor_model.h>
|
#include <trezor_model.h>
|
||||||
|
|
||||||
#include <gfx/fonts.h>
|
#include <gfx/fonts.h>
|
||||||
@ -32,3 +34,7 @@
|
|||||||
#include "slip39.h"
|
#include "slip39.h"
|
||||||
|
|
||||||
#include "uzlib.h"
|
#include "uzlib.h"
|
||||||
|
|
||||||
|
// force bindgen to include these constants
|
||||||
|
const uint32_t DISPLAY_RESX_ = DISPLAY_RESX;
|
||||||
|
const uint32_t DISPLAY_RESY_ = DISPLAY_RESY;
|
||||||
|
@ -53,11 +53,15 @@ def configure(
|
|||||||
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
|
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
|
||||||
]
|
]
|
||||||
defines += ["USE_DMA2D"]
|
defines += ["USE_DMA2D"]
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
|
||||||
features_available.append("dma2d")
|
features_available.append("dma2d")
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER"]
|
defines += [
|
||||||
defines += ["DISPLAY_RGB565"]
|
"FRAMEBUFFER",
|
||||||
|
"DISPLAY_RGB565",
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "320"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_rgb565")
|
features_available.append("display_rgb565")
|
||||||
|
|
||||||
|
@ -75,20 +75,20 @@ def configure(
|
|||||||
paths += ["embed/io/usb/inc"]
|
paths += ["embed/io/usb/inc"]
|
||||||
|
|
||||||
defines += [
|
defines += [
|
||||||
"USE_DMA2D",
|
"FRAMEBUFFER",
|
||||||
|
"DISPLAY_RGBA8888",
|
||||||
("UI_COLOR_32BIT", "1"),
|
("UI_COLOR_32BIT", "1"),
|
||||||
("USE_RGB_COLORS", "1"),
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "240"),
|
||||||
]
|
]
|
||||||
|
|
||||||
sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"]
|
|
||||||
|
|
||||||
features_available.append("dma2d")
|
|
||||||
features_available.append("ui_color_32bit")
|
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER"]
|
|
||||||
defines += ["DISPLAY_RGBA8888"]
|
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_rgba8888")
|
features_available.append("display_rgba8888")
|
||||||
|
features_available.append("ui_color_32bit")
|
||||||
|
|
||||||
|
defines += (["USE_DMA2D"],)
|
||||||
|
features_available.append("dma2d")
|
||||||
|
sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"]
|
||||||
|
|
||||||
defines += [
|
defines += [
|
||||||
"USE_HASH_PROCESSOR=1",
|
"USE_HASH_PROCESSOR=1",
|
||||||
|
@ -17,7 +17,12 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
mcu = "STM32F427xx"
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER", "DISPLAY_MONO"]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
"DISPLAY_MONO",
|
||||||
|
("DISPLAY_RESX", "128"),
|
||||||
|
("DISPLAY_RESY", "64"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_mono")
|
features_available.append("display_mono")
|
||||||
|
|
||||||
|
@ -16,7 +16,11 @@ def configure(
|
|||||||
hw_revision = 10
|
hw_revision = 10
|
||||||
board = "T2B1/boards/trezor_r_v10.h"
|
board = "T2B1/boards/trezor_r_v10.h"
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER"]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
("DISPLAY_RESX", "128"),
|
||||||
|
("DISPLAY_RESY", "64"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_mono")
|
features_available.append("display_mono")
|
||||||
|
|
||||||
|
@ -17,9 +17,13 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
mcu = "STM32F427xx"
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
defines += ["DISPLAY_RGB565"]
|
|
||||||
features_available.append("display_rgb565")
|
features_available.append("display_rgb565")
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
defines += [
|
||||||
|
"DISPLAY_RGB565",
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "240"),
|
||||||
|
]
|
||||||
|
|
||||||
defines += [
|
defines += [
|
||||||
mcu,
|
mcu,
|
||||||
|
@ -16,9 +16,13 @@ def configure(
|
|||||||
hw_model = get_hw_model_as_number("T2T1")
|
hw_model = get_hw_model_as_number("T2T1")
|
||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
|
|
||||||
defines += ["DISPLAY_RGB565"]
|
|
||||||
features_available.append("display_rgb565")
|
features_available.append("display_rgb565")
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
defines += [
|
||||||
|
"DISPLAY_RGB565",
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "240"),
|
||||||
|
]
|
||||||
|
|
||||||
mcu = "STM32F427xx"
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
@ -17,7 +17,12 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
mcu = "STM32U585xx"
|
mcu = "STM32U585xx"
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER", "DISPLAY_MONO"]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
"DISPLAY_MONO",
|
||||||
|
("DISPLAY_RESX", "128"),
|
||||||
|
("DISPLAY_RESY", "64"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_mono")
|
features_available.append("display_mono")
|
||||||
|
|
||||||
|
@ -16,7 +16,11 @@ def configure(
|
|||||||
hw_model = get_hw_model_as_number("T3B1")
|
hw_model = get_hw_model_as_number("T3B1")
|
||||||
hw_revision = ord("B")
|
hw_revision = ord("B")
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER"]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
("DISPLAY_RESX", "128"),
|
||||||
|
("DISPLAY_RESY", "64"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_mono")
|
features_available.append("display_mono")
|
||||||
|
|
||||||
|
@ -17,10 +17,15 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
mcu = "STM32U585xx"
|
mcu = "STM32U585xx"
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER", "DISPLAY_RGB565"]
|
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_rgb565")
|
features_available.append("display_rgb565")
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
"DISPLAY_RGB565",
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "240"),
|
||||||
|
]
|
||||||
|
|
||||||
defines += [
|
defines += [
|
||||||
mcu,
|
mcu,
|
||||||
|
@ -18,9 +18,13 @@ def configure(
|
|||||||
|
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_rgb565")
|
features_available.append("display_rgb565")
|
||||||
defines += [("DISPLAY_RGB565", "1")]
|
defines += [
|
||||||
defines += [("FRAMEBUFFER", "1")]
|
("DISPLAY_RGB565", "1"),
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
("FRAMEBUFFER", "1"),
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
("DISPLAY_RESX", "240"),
|
||||||
|
("DISPLAY_RESY", "240"),
|
||||||
|
]
|
||||||
|
|
||||||
mcu = "STM32U585xx"
|
mcu = "STM32U585xx"
|
||||||
linker_script = """embed/sys/linker/stm32u58/{target}.ld"""
|
linker_script = """embed/sys/linker/stm32u58/{target}.ld"""
|
||||||
|
@ -17,11 +17,17 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
mcu = "STM32U5G9xx"
|
mcu = "STM32U5G9xx"
|
||||||
|
|
||||||
defines += ["FRAMEBUFFER", "DISPLAY_RGBA8888", "UI_COLOR_32BIT"]
|
defines += [
|
||||||
|
"FRAMEBUFFER",
|
||||||
|
("USE_RGB_COLORS", "1"),
|
||||||
|
"DISPLAY_RGBA8888",
|
||||||
|
"UI_COLOR_32BIT",
|
||||||
|
("DISPLAY_RESX", "380"),
|
||||||
|
("DISPLAY_RESY", "520"),
|
||||||
|
]
|
||||||
features_available.append("framebuffer")
|
features_available.append("framebuffer")
|
||||||
features_available.append("display_rgba8888")
|
features_available.append("display_rgba8888")
|
||||||
features_available.append("ui_color_32bit")
|
features_available.append("ui_color_32bit")
|
||||||
defines += [("USE_RGB_COLORS", "1")]
|
|
||||||
|
|
||||||
defines += [
|
defines += [
|
||||||
mcu,
|
mcu,
|
||||||
|
Loading…
Reference in New Issue
Block a user