WIP - drawlib - bootloader

cepetr/drawlib-integration
cepetr 2 months ago
parent a65e45f6ed
commit b8a0e67e8a

@ -5,6 +5,7 @@ import tools
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
if TREZOR_MODEL in ('1', ):
# skip boardloader build
@ -20,6 +21,9 @@ if TREZOR_MODEL in ('1', ):
FEATURES_WANTED = ["sd_card"]
if NEW_RENDERING:
FEATURES_WANTED.append("new_rendering")
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = ["BOARDLOADER"]
@ -59,14 +63,27 @@ CPPPATH_MOD += [
]
SOURCE_MOD += [
'embed/lib/colors.c',
'embed/lib/display_draw.c',
'embed/lib/display_utils.c',
'embed/lib/fonts/font_bitmap.c',
'embed/lib/fonts/fonts.c',
'embed/lib/gl_color.c',
'embed/lib/gl_dma2d_rgb565.c',
'embed/lib/gl_dma2d_mono8.c',
'embed/lib/image.c',
'embed/lib/mini_printf.c',
'embed/lib/terminal.c',
]
if NEW_RENDERING:
CPPDEFINES_MOD += ['NEW_RENDERING']
SOURCE_MOD += [
'embed/lib/gl_draw.c',
]
else:
SOURCE_MOD += [
'embed/lib/display_draw.c',
]
env = Environment(ENV=os.environ,
CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')),

@ -7,6 +7,7 @@ TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
BOOTLOADER_QA = ARGUMENTS.get('BOOTLOADER_QA', '0') == '1'
PRODUCTION = 0 if BOOTLOADER_QA else ARGUMENTS.get('PRODUCTION', '0') == '1'
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
if TREZOR_MODEL in ('1', ):
# skip bootloader build
@ -22,6 +23,9 @@ if TREZOR_MODEL in ('1', ):
FEATURES_WANTED = ["input", "rgb_led", "consumption_mask", "usb", "optiga", "dma2d"]
if NEW_RENDERING:
FEATURES_WANTED.append("new_rendering")
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -83,7 +87,6 @@ SOURCE_MOD += [
'embed/extmod/modtrezorcrypto/rand.c',
'embed/lib/buffers.c',
'embed/lib/colors.c',
'embed/lib/display_draw.c',
'embed/lib/display_utils.c',
'embed/lib/fonts/font_bitmap.c',
'embed/lib/fonts/fonts.c',
@ -99,6 +102,17 @@ SOURCE_MOD += [
'vendor/micropython/lib/uzlib/tinflate.c',
]
if NEW_RENDERING:
CPPDEFINES_MOD += ['NEW_RENDERING']
SOURCE_MOD += [
'embed/lib/gl_draw.c',
]
else:
SOURCE_MOD += [
'embed/lib/display_draw.c',
]
SOURCE_NANOPB = [
'vendor/nanopb/pb_common.c',
'vendor/nanopb/pb_decode.c',
@ -223,6 +237,9 @@ def cargo_build():
features.append("bootloader")
features.extend(FEATURES_AVAILABLE)
if NEW_RENDERING:
features.append('new_rendering')
if TREZOR_MODEL in ('T',):
features.append('ui_antialiasing')

@ -5,6 +5,7 @@ import tools
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
if TREZOR_MODEL in ('1', 'DISC1', 'DISC2'):
# skip bootloader_ci build

@ -6,6 +6,7 @@ import boards
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
DMA2D = False
if TREZOR_MODEL in ('1', 'DISC1'):
@ -22,6 +23,9 @@ if TREZOR_MODEL in ('1', 'DISC1'):
FEATURES_WANTED = ["input", "rgb_led"]
if NEW_RENDERING:
FEATURES_WANTED.append("new_rendering")
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -80,10 +84,12 @@ SOURCE_MOD += [
'embed/extmod/modtrezorcrypto/rand.c',
'embed/lib/buffers.c',
'embed/lib/colors.c',
'embed/lib/display_draw.c',
'embed/lib/display_utils.c',
'embed/lib/fonts/font_bitmap.c',
'embed/lib/fonts/fonts.c',
'embed/lib/gl_color.c',
'embed/lib/gl_dma2d_mono8.c',
'embed/lib/gl_dma2d_rgb565.c',
'embed/lib/image.c',
'embed/lib/terminal.c',
'embed/lib/touch.c',
@ -94,6 +100,22 @@ SOURCE_MOD += [
'vendor/trezor-storage/flash_area.c',
]
if NEW_RENDERING:
CPPDEFINES_MOD += ['NEW_RENDERING']
if TREZOR_MODEL in ('T',):
CPPDEFINES_MOD += ['DISPLAY_RGB565']
elif TREZOR_MODEL in ('R', '1',):
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_MONO']
elif TREZOR_MODEL in ('T3T1',):
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_RGB565']
SOURCE_MOD += [
'embed/lib/gl_draw.c',
]
else:
SOURCE_MOD += [
'embed/lib/display_draw.c',
]
if TREZOR_MODEL in ('1', ):
SOURCE_MOD += [
'embed/models/model_T1B1_layout.c',
@ -128,7 +150,6 @@ SOURCE_BOOTLOADER = [
SOURCE_TREZORHAL = [
'embed/trezorhal/unix/boot_args.c',
'embed/trezorhal/unix/display-unix.c',
'embed/trezorhal/unix/fault_handlers.c',
'embed/trezorhal/unix/flash.c',
'embed/trezorhal/unix/flash_otp.c',
@ -139,6 +160,16 @@ SOURCE_TREZORHAL = [
'embed/trezorhal/unix/random_delays.c',
]
if NEW_RENDERING:
SOURCE_TREZORHAL += [
'embed/trezorhal/unix/display_driver.c',
'embed/trezorhal/xdisplay_legacy.c',
]
else:
SOURCE_TREZORHAL += [
'embed/trezorhal/unix/display-unix.c',
]
if TREZOR_MODEL in ('R', 'T3T1'):
SOURCE_TREZORHAL += [
'embed/trezorhal/unix/secret.c',
@ -253,17 +284,18 @@ cmake_gen = env.Command(
#
RUST_TARGET = 'x86_64-unknown-linux-gnu'
RUST_PROFILE = 'release'
RUST_LIB = 'trezor_lib'
RUST_LIBDIR = f'build/bootloader_emu/rust/{RUST_TARGET}/{RUST_PROFILE}'
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', '0') == '1':
RUST_PROFILE = 'dev'
RUST_LIBDIR = f'build/bootloader_emu/rust/{RUST_TARGET}/debug'
else:
RUST_PROFILE = 'release'
RUST_LIBDIR = f'build/bootloader_emu/rust/{RUST_TARGET}/release'
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
def cargo_build():
# Determine the profile build flags.
if RUST_PROFILE == 'release':
profile = '--release'
else:
profile = ''
if TREZOR_MODEL in ("1",):
features = ["model_t1"]
elif TREZOR_MODEL in ("R",):
@ -271,6 +303,19 @@ def cargo_build():
else:
features = ["model_tt"]
if NEW_RENDERING:
features.append('new_rendering')
if TREZOR_MODEL in ('T',):
features.append('display_rgb565')
features.append('ui_antialiasing')
elif TREZOR_MODEL in ('R', '1',):
features.append('display_mono')
features.append('xframebuffer')
elif TREZOR_MODEL in ('T3T1',):
features.append('display_rgb565')
features.append('xframebuffer')
features.append('ui_antialiasing')
if TREZOR_MODEL in ('T', 'T3T1'):
features.append('touch')
features.append('backlight')
@ -289,7 +334,7 @@ def cargo_build():
'-Z build-std-features=panic_immediate_abort',
]
return f'cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
return f'cd embed/rust; cargo build --profile {RUST_PROFILE} ' + ' '.join(cargo_opts)
rust = env.Command(
target=RUST_LIBPATH,

@ -856,10 +856,8 @@ if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', '0') == '1':
RUST_PROFILE = 'dev'
RUST_LIBDIR = f'build/unix/rust/{TARGET}/debug'
else:
RUST_PROFILE = 'dev'
RUST_LIBDIR = f'build/unix/rust/{TARGET}/debug'
# RUST_PROFILE = 'release'
# RUST_LIBDIR = f'build/unix/rust/{TARGET}/release'
RUST_PROFILE = 'release'
RUST_LIBDIR = f'build/unix/rust/{TARGET}/release'
RUST_LIB = 'trezor_lib'
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'

@ -130,11 +130,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorui_Display_backlight_obj,
/// Saves current display contents to PNG file with given prefix.
/// """
STATIC mp_obj_t mod_trezorui_Display_save(mp_obj_t self, mp_obj_t prefix) {
#ifdef TREZOR_EMULATOR
mp_buffer_info_t pfx = {0};
mp_get_buffer_raise(prefix, &pfx, MP_BUFFER_READ);
if (pfx.len > 0) {
display_save(pfx.buf);
}
#endif
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorui_Display_save_obj,
@ -145,7 +147,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorui_Display_save_obj,
/// Clears buffers in display saving.
/// """
STATIC mp_obj_t mod_trezorui_Display_clear_save(mp_obj_t self) {
#ifdef TREZOR_EMULATOR
display_clear_save();
#endif
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorui_Display_clear_save_obj,

@ -87,6 +87,11 @@ SECTIONS {
. = ALIGN(4);
} >SRAM
.buf : ALIGN(4) {
*(.buf*);
. = ALIGN(4);
} >SRAM
.heap : ALIGN(4) {
. = 37K; /* this acts as a build time assertion that at least this much memory is available for heap use */
. = ABSOLUTE(sram_end); /* this explicitly sets the end of the heap */

@ -97,10 +97,14 @@ static inline gl_color16_t gl_color32_to_color16(gl_color32_t color) {
}
// Converts 16-bit color into luminance (ranging from 0 to 255)
static inline uint8_t gl_color_lum(gl_color16_t color) {
uint16_t r = (color & 0x00F80000) >> 8;
uint16_t g = (color & 0x0000FC00) >> 5;
uint16_t b = (color & 0x000000F8) >> 3;
static inline uint8_t gl_color16_lum(gl_color16_t color) {
uint32_t r = (color & 0xF800) >> 8;
uint32_t g = (color & 0x07E0) >> 3;
uint32_t b = (color & 0x001F) << 3;
r |= (r >> 5);
g |= (g >> 6);
b |= (b >> 5);
return (r + g + b) / 3;
}

@ -88,6 +88,24 @@ static inline gl_clip_t gl_clip(gl_rect_t dst, const gl_bitmap_t* bitmap) {
return clip;
}
void gl_clear(void) {
dma2d_params_t dp = {
// Destination bitmap
.height = DISPLAY_RESX,
.width = DISPLAY_RESY,
.dst_row = NULL,
.dst_x = 0,
.dst_y = 0,
.dst_stride = 0,
// Source bitmap
.src_fg = 0,
.src_alpha = 255,
};
display_fill(&dp);
}
void gl_draw_bar(gl_rect_t rect, gl_color_t color) {
gl_clip_t clip = gl_clip(rect, NULL);
@ -175,7 +193,7 @@ void gl_draw_bitmap(gl_rect_t rect, const gl_bitmap_t* bitmap) {
#define GLYPH_BEARING_Y(g) ((g)[4])
#define GLYPH_DATA(g) ((void*)&(g)[5])
void gl_draw_text(gl_rect_t rect, const char* text, size_t maxlen,
void gl_draw_text(gl_offset_t pos, const char* text, size_t maxlen,
const gl_text_attr_t* attr) {
if (text == NULL) {
return;
@ -193,7 +211,7 @@ void gl_draw_text(gl_rect_t rect, const char* text, size_t maxlen,
for (int i = 0; i < maxlen; i++) {
uint8_t ch = (uint8_t)text[i];
if (ch == 0 || rect.x0 >= rect.x1) {
if (ch == 0 || pos.x >= DISPLAY_RESX) {
break;
}
@ -211,16 +229,40 @@ void gl_draw_text(gl_rect_t rect, const char* text, size_t maxlen,
bitmap.offset.x = -GLYPH_BEARING_X(glyph);
bitmap.offset.y = -(max_height - baseline - GLYPH_BEARING_Y(glyph));
gl_draw_bitmap(rect, &bitmap);
gl_draw_bitmap(gl_rect(pos.x, pos.y, DISPLAY_RESX, DISPLAY_RESY), &bitmap);
rect.x0 += GLYPH_ADVANCE(glyph);
pos.x += GLYPH_ADVANCE(glyph);
}
}
// ===============================================================
// emulation of legacy functions
void display_bar(int x, int y, int w, int h, uint16_t c) {}
void display_clear(void) { gl_clear(); }
void display_bar(int x, int y, int w, int h, uint16_t c) {
gl_draw_bar(gl_rect_wh(x, y, w, h), c);
}
void display_text(int x, int y, const char* text, int textlen, int font,
uint16_t fgcolor, uint16_t bgcolor) {}
uint16_t fg_color, uint16_t bg_color) {
gl_text_attr_t attr = {
.font = font,
.fg_color = fg_color,
.bg_color = bg_color,
};
gl_draw_text(gl_offset(x, y), text, textlen, &attr);
}
void display_text_center(int x, int y, const char* text, int textlen, int font,
uint16_t fg_color, uint16_t bg_color) {
gl_text_attr_t attr = {
.font = font,
.fg_color = fg_color,
.bg_color = bg_color,
};
int w = font_text_width(font, text, textlen);
gl_draw_text(gl_offset(x - w / 2, y), text, textlen, &attr);
}

@ -62,12 +62,12 @@ typedef struct {
} gl_offset_t;
static inline gl_offset_t gl_offset(int16_t x, int16_t y) {
gl_offset_t size = {
gl_offset_t offset = {
.x = x,
.y = y,
};
return size;
return offset;
}
// 2D size in pixels
@ -129,7 +129,7 @@ void gl_draw_bar(gl_rect_t rect, gl_color_t color);
void gl_draw_bitmap(gl_rect_t rect, const gl_bitmap_t* bitmap);
// !@# TODO
void gl_draw_text(gl_rect_t rect, const char* text, size_t maxlen,
void gl_draw_text(gl_offset_t offset, const char* text, size_t maxlen,
const gl_text_attr_t* attr);
#endif // GL_DRAW_H

@ -1,4 +1,4 @@
use crate::trezorhal::dma2d_new::Dma2d;
use crate::trezorhal::{display, dma2d_new::Dma2d};
use crate::ui::{
display::Color,
@ -43,6 +43,8 @@ where
func(&mut target);
target.render(16);
display::refresh();
}
}

@ -26,7 +26,6 @@
#include "display_panel.h"
#include "backlight_pwm.h"
#include "supervise.h"
#ifndef BOARDLOADER
@ -151,10 +150,6 @@ void display_wait_for_sync(void) {
#endif
}
const char* display_save(const char* prefix) { return NULL; }
void display_clear_save(void) {}
void display_set_compatible_settings(void) { display_panel_set_big_endian(); }
static inline void set_window(const dma2d_params_t* dp) {
@ -162,7 +157,6 @@ static inline void set_window(const dma2d_params_t* dp) {
dp->dst_y + dp->height + 1);
}
// Fills a rectangle with a specified color
void display_fill(const dma2d_params_t* dp) {
set_window(dp);
@ -175,7 +169,6 @@ void display_fill(const dma2d_params_t* dp) {
}
}
// Copies an RGB565 bitmap to specified rectangle
void display_copy_rgb565(const dma2d_params_t* dp) {
set_window(dp);
@ -190,5 +183,37 @@ void display_copy_rgb565(const dma2d_params_t* dp) {
}
}
// Copies a MONO4 bitmap to specified rectangle
// void display_copy_mono4(gdc_dma2d_t *dp);
void display_copy_mono1p(const dma2d_params_t* dp) {
set_window(dp);
uint8_t* src = (uint8_t*)dp->src_row;
uint16_t src_ofs = dp->src_stride * dp->src_y + dp->src_x;
uint16_t height = dp->height;
while (height-- > 0) {
for (int x = 0; x < dp->width; x++) {
uint8_t mask = 1 << (7 - ((src_ofs + x) & 7));
uint8_t data = src[(src_ofs + x) / 8];
ISSUE_PIXEL_DATA((data & mask) ? dp->src_fg : dp->src_bg);
}
src_ofs += dp->src_stride;
}
}
void display_copy_mono4(const dma2d_params_t* dp) {
set_window(dp);
const gl_color16_t* gradient = gl_color16_gradient_a4(dp->src_fg, dp->src_bg);
uint8_t* src_row = (uint8_t*)dp->src_row;
uint16_t height = dp->height;
while (height-- > 0) {
for (int x = 0; x < dp->width; x++) {
uint8_t fg_data = src_row[(x + dp->src_x) / 2];
uint8_t fg_lum = (x + dp->src_x) & 1 ? fg_data >> 4 : fg_data & 0xF;
ISSUE_PIXEL_DATA(gradient[fg_lum]);
}
src_row += dp->src_stride / sizeof(*src_row);
}
}

@ -54,7 +54,9 @@ ALIGN_32BYTES(uint8_t physical_frame_buffer_1[PHYSICAL_FRAME_BUFFER_SIZE]);
__attribute__((section(".framebuffer_select"))) uint32_t current_frame_buffer =
0;
#ifndef BOARDLOADER
static bool pending_fb_switch = false;
#endif
#ifndef BOARDLOADER
void DISPLAY_TE_INTERRUPT_HANDLER(void) {

@ -79,7 +79,7 @@ uint32_t display_panel_identify(void) {
return id;
}
#else
uint32_t display_panbel_identify(void) { return DISPLAY_ID_ST7789V; }
uint32_t display_panel_identify(void) { return DISPLAY_ID_ST7789V; }
#endif
bool display_panel_is_inverted() {
@ -176,7 +176,7 @@ void display_panel_set_big_endian(void) {
}
}
void display_panal_init(void) {
void display_panel_init(void) {
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, GPIO_PIN_RESET); // LCD_RST/PC14
// wait 10 milliseconds. only needs to be low for 10 microseconds.
// my dev display module ties display reset and touch panel reset together.

@ -33,6 +33,8 @@
// Display driver context.
typedef struct {
// Pointer to the frame buffer
uint16_t *framebuf;
// Current display orientation (0, 90, 180, 270)
int orientation_angle;
// Current backlight level ranging from 0 to 255
@ -45,6 +47,7 @@ static display_driver_t g_display_driver;
void display_init(void) {
display_driver_t *drv = &g_display_driver;
memset(drv, 0, sizeof(display_driver_t));
drv->framebuf = (uint16_t *)FRAME_BUFFER_ADDR;
// Initialize LTDC controller
BSP_LCD_Init();
@ -55,6 +58,7 @@ void display_init(void) {
void display_reinit(void) {
display_driver_t *drv = &g_display_driver;
memset(drv, 0, sizeof(display_driver_t));
drv->framebuf = (uint16_t *)FRAME_BUFFER_ADDR;
}
void display_finish_actions(void) {
@ -92,30 +96,44 @@ int display_get_orientation(void) {
return drv->orientation_angle;
}
void *display_get_frame_addr(void) { return (void *)FRAME_BUFFER_ADDR; }
void *display_get_frame_addr(void) {
display_driver_t *drv = &g_display_driver;
return (void *)drv->framebuf;
}
void display_refresh(void) {
// Do nothing as using just a single frame buffer
}
const char *display_save(const char *prefix) { return NULL; }
void display_set_compatible_settings() {}
void display_clear_save(void) {}
void display_fill(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
void display_set_compatible_settings() {}
dma2d_params_t dp_new = *dp;
dp_new.dst_row = drv->framebuf + (DISPLAY_RESX * dp_new.dst_y);
dp_new.dst_stride = DISPLAY_RESX * 2;
// Functions for drawing on display
/*
rgb565_fill(&dp_new);
}
// Fills a rectangle with a specified color
void display_fill(gdc_dma2d_t *dp);
void display_copy_rgb565(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
// Copies an RGB565 bitmap to specified rectangle
void display_copy_rgb565(gdc_dma2d_t *dp);
dma2d_params_t dp_new = *dp;
dp_new.dst_row = drv->framebuf + (DISPLAY_RESX * dp_new.dst_y);
dp_new.dst_stride = DISPLAY_RESX * 2;
// Copies a MONO4 bitmap to specified rectangle
void display_copy_mono4(gdc_dma2d_t *dp);
rgb565_copy_rgb565(&dp_new);
}
// Copies a MONO1P bitmap to specified rectangle
void display_copy_mono1p(gdc_dma2d_t *dp);
*/
void display_copy_mono4(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
dma2d_params_t dp_new = *dp;
dp_new.dst_row = drv->framebuf + (DISPLAY_RESX * dp_new.dst_y);
dp_new.dst_stride = DISPLAY_RESX * 2;
rgb565_copy_mono4(&dp_new);
}

@ -370,24 +370,24 @@ void *display_get_frame_addr(void) {
void display_refresh(void) { display_sync_with_fb(); }
const char *display_save(const char *prefix) { return NULL; }
void display_clear_save(void) {}
void display_set_compatible_settings() {}
// Functions for drawing on display
/*
void display_fill(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
// Fills a rectangle with a specified color
void display_fill(gdc_dma2d_t *dp);
dma2d_params_t dp_new = *dp;
dp_new.dst_row = &drv->framebuf[DISPLAY_RESX * dp_new.dst_y];
dp_new.dst_stride = DISPLAY_RESX;
// Copies an RGB565 bitmap to specified rectangle
void display_copy_rgb565(gdc_dma2d_t *dp);
mono8_fill(&dp_new);
}
void display_copy_mono1p(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
// Copies a MONO4 bitmap to specified rectangle
void display_copy_mono4(gdc_dma2d_t *dp);
dma2d_params_t dp_new = *dp;
dp_new.dst_row = &drv->framebuf[DISPLAY_RESX * dp_new.dst_y];
dp_new.dst_stride = DISPLAY_RESX;
// Copies a MONO1P bitmap to specified rectangle
void display_copy_mono1p(gdc_dma2d_t *dp);
*/
mono8_copy_mono1p(&dp_new);
}

@ -330,22 +330,24 @@ void display_refresh(void) {
display_sync_with_fb(drv);
}
const char *display_save(const char *prefix) { return NULL; }
void display_clear_save(void) {}
void display_set_compatible_settings() {}
/*
void display_fill(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
// Fills a rectangle with a specified color
void display_fill(dma2d_params_t *dp) {
dma2d_params_t dp_new = *dp;
dp_new.dst_row = &drv->framebuf[DISPLAY_RESX * dp_new.dst_y];
dp_new.dst_stride = DISPLAY_RESX;
mono8_fill(&dp_new);
}
// Copies a MONO1P bitmap to specified rectangle
void display_copy_mono1p(dma2d_params_t *dp) {
void display_copy_mono1p(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
}
dma2d_params_t dp_new = *dp;
dp_new.dst_row = &drv->framebuf[DISPLAY_RESX * dp_new.dst_y];
dp_new.dst_stride = DISPLAY_RESX;
*/
mono8_copy_mono1p(&dp_new);
}

@ -112,24 +112,17 @@ int display_get_orientation(void) {
return drv->orientation_angle;
}
const char* display_save(const char* prefix) { return NULL; }
void display_clear_save(void) {}
void display_set_compatible_settings() {}
// Functions for drawing on display
/*
/*void display_fill(dma2d_params_t *dp) {
// Fills a rectangle with a specified color
void display_fill(gdc_dma2d_t *dp);
}
// Copies an RGB565 bitmap to specified rectangle
void display_copy_rgb565(gdc_dma2d_t *dp);
void display_copy_rgb565(dma2d_params_t *dp) {
// Copies a MONO4 bitmap to specified rectangle
void display_copy_mono4(gdc_dma2d_t *dp);
}
void display_copy_mono4(dma2d_params_t *dp) {
// Copies a MONO1P bitmap to specified rectangle
void display_copy_mono1p(gdc_dma2d_t *dp);
}
*/

@ -354,3 +354,5 @@ void display_clear_save(void) {
uint8_t *display_get_wr_addr(void) { return (uint8_t *)DISPLAY_DATA_ADDRESS; }
void display_finish_actions(void) {}
void display_reinit(void) {}

@ -286,13 +286,13 @@ void display_wait_for_sync(void) {
#ifdef DISPLAY_MONO
// Copies driver's monochromatic framebuffer into the RGB framebuffer used by
// SDL
void copy_mono_framebuf(display_driver_t *drv) {
static void copy_mono_framebuf(display_driver_t *drv) {
for (int y = 0; y < DISPLAY_RESY; y++) {
uint16_t *dst =
(uint16_t *)((uint8_t *)drv->buffer->pixels + drv->buffer->pitch * y);
uint8_t *src = &drv->mono_framebuf[y * DISPLAY_RESX];
for (int x = 0; x < DISPLAY_RESX; x++) {
uint8_t lum = src[x];
uint8_t lum = src[x] > 40 ? 255 : 0;
dst[x] = gl_color16_rgb(lum, lum, lum);
}
}
@ -340,6 +340,8 @@ void display_set_compatible_settings(void) {
// not used
}
#ifndef DISPLAY_MONO
void display_fill(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
@ -363,13 +365,44 @@ void display_copy_rgb565(const dma2d_params_t *dp) {
}
void display_copy_mono4(const dma2d_params_t *dp) {
// !@# TODO
display_driver_t *drv = &g_display_driver;
dma2d_params_t dp_new = *dp;
dp_new.dst_row =
(uint8_t *)drv->buffer->pixels + (drv->buffer->pitch * dp_new.dst_y);
dp_new.dst_stride = drv->buffer->pitch;
rgb565_copy_mono4(&dp_new);
}
void display_copy_mono1p(const dma2d_params_t *dp) {
// !@# TODO
// !@# proc to tu musi byt?????
}
#else // DISPLAY_MONO
void display_fill(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
dma2d_params_t dp_new = *dp;
dp_new.dst_row = drv->mono_framebuf + (DISPLAY_RESX * dp_new.dst_y);
dp_new.dst_stride = DISPLAY_RESX;
mono8_fill(&dp_new);
}
void display_copy_mono1p(const dma2d_params_t *dp) {
display_driver_t *drv = &g_display_driver;
dma2d_params_t dp_new = *dp;
dp_new.dst_row = drv->mono_framebuf + (DISPLAY_RESX * dp_new.dst_y);
dp_new.dst_stride = DISPLAY_RESX;
mono8_copy_mono1p(&dp_new);
}
#endif
const char *display_save(const char *prefix) {
display_driver_t *drv = &g_display_driver;

@ -111,7 +111,6 @@ void display_refresh(void);
//
void display_set_compatible_settings(void);
// Functions for drawing on the display
// Fills a rectangle with a specified color
void display_fill(const dma2d_params_t *dp);
@ -124,11 +123,12 @@ void display_copy_mono4(const dma2d_params_t *dp);
// Copies a MONO1P bitmap to a specified rectangle
void display_copy_mono1p(const dma2d_params_t *dp);
#ifdef TREZOR_EMULATOR
// Save the screen content to a file.
//
// The function is available only on the emulator
// The function is available only on the emulator.
const char *display_save(const char *prefix);
void display_clear_save(void);
#endif
#include "xdisplay_legacy.h"

@ -44,7 +44,5 @@ void display_offset(int set_xy[2], int *get_x, int *get_y) {
*get_y = 0;
}
void display_clear(void) {}
void display_text_render_buffer(const char *text, int textlen, int font,
buffer_text_t *buffer, int text_offset) {}

Loading…
Cancel
Save