From d235ed3d3da13d800965bd6aa4bab7392c8573b9 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Tue, 31 Dec 2024 16:09:35 +0100 Subject: [PATCH] fix(core): properly limit the display area used in application (ltdc_dsi driver) [no changelog] wip: use only part of display area --- core/embed/io/display/ltdc_dsi/display_fb.c | 9 ++++++--- .../io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.h | 3 +++ .../ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.h | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/embed/io/display/ltdc_dsi/display_fb.c b/core/embed/io/display/ltdc_dsi/display_fb.c index ecef41231c..ecac772e82 100644 --- a/core/embed/io/display/ltdc_dsi/display_fb.c +++ b/core/embed/io/display/ltdc_dsi/display_fb.c @@ -126,15 +126,18 @@ bool display_get_frame_buffer(display_fb_info_t *fb_dest) { uint32_t fb_stride = FRAME_BUFFER_PIXELS_PER_LINE * FB_PIXEL_SIZE; // We may not utilize whole area of the display - addr += (LCD_HEIGHT - DISPLAY_RESY) / 2 * FB_PIXEL_SIZE; - addr += (LCD_WIDTH - DISPLAY_RESX) / 2 * fb_stride; + addr += PANEL_USED_AREA_OFFSET_X * FB_PIXEL_SIZE; + addr += PANEL_USED_AREA_OFFSET_Y * fb_stride; display_fb_info_t fb = { .ptr = (void *)addr, .stride = fb_stride, }; - mpu_set_active_fb((void *)addr, VIRTUAL_FRAME_BUFFER_SIZE); + size_t fb_size = fb_stride * (DISPLAY_RESY - 1) * FB_PIXEL_SIZE + + DISPLAY_RESX * FB_PIXEL_SIZE; + + mpu_set_active_fb((void *)addr, fb_size); memcpy(fb_dest, &fb, sizeof(display_fb_info_t)); diff --git a/core/embed/io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.h b/core/embed/io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.h index b696dde2fe..db3da3d197 100644 --- a/core/embed/io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.h +++ b/core/embed/io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.h @@ -47,3 +47,6 @@ // Pitch (in pixels) of the virtual frame buffer #define FRAME_BUFFER_PIXELS_PER_LINE 240 + +#define PANEL_USED_AREA_OFFSET_X 0 +#define PANEL_USED_AREA_OFFSET_Y 0 diff --git a/core/embed/io/display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.h b/core/embed/io/display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.h index db27320de0..6c7f62c02c 100644 --- a/core/embed/io/display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.h +++ b/core/embed/io/display/ltdc_dsi/panels/stm32u5a9j-dk/stm32u5a9j-dk.h @@ -53,3 +53,6 @@ // Size of the virtual frame buffer in bytes #define VIRTUAL_FRAME_BUFFER_SIZE \ (FRAME_BUFFER_PIXELS_PER_LINE * LCD_HEIGHT * 4) + +#define PANEL_USED_AREA_OFFSET_X 120 +#define PANEL_USED_AREA_OFFSET_Y 120