diff --git a/core/embed/io/display/st-7789/display_driver.c b/core/embed/io/display/st-7789/display_driver.c index c8165a727fa..fb7df3ba59b 100644 --- a/core/embed/io/display/st-7789/display_driver.c +++ b/core/embed/io/display/st-7789/display_driver.c @@ -93,11 +93,11 @@ void display_deinit(display_content_mode_t mode) { return; } -#ifdef FRAMEBUFFER #ifndef BOARDLOADER - // Ensure that the ready frame buffer is transfered to + // Ensure that the ready frame buffer is transferred to // the display controller display_ensure_refreshed(); +#ifdef FRAMEBUFFER // Disable periodical interrupt NVIC_DisableIRQ(DISPLAY_TE_INTERRUPT_NUM); #endif @@ -127,13 +127,11 @@ int display_set_backlight(int level) { return 0; } -#ifdef FRAMEBUFFER #ifndef BOARDLOADER // if turning on the backlight, wait until the panel is refreshed if (backlight_pwm_get() < level && !is_mode_exception()) { display_ensure_refreshed(); } -#endif #endif return backlight_pwm_set(level); diff --git a/core/embed/io/display/st-7789/display_fb.h b/core/embed/io/display/st-7789/display_fb.h index c7d1fbe5288..e723406636d 100644 --- a/core/embed/io/display/st-7789/display_fb.h +++ b/core/embed/io/display/st-7789/display_fb.h @@ -29,8 +29,6 @@ void display_fb_init(void); // Clears both physical frame buffers void display_fb_clear(void); -void display_ensure_refreshed(void); - #endif // FRAMEBUFFER #endif // TREZORHAL_DISPLAY_FB_H diff --git a/core/embed/io/display/st-7789/display_internal.h b/core/embed/io/display/st-7789/display_internal.h index 8aa00f0e71f..b8e9445588e 100644 --- a/core/embed/io/display/st-7789/display_internal.h +++ b/core/embed/io/display/st-7789/display_internal.h @@ -38,4 +38,6 @@ static inline uint32_t is_mode_exception(void) { return (isr_number != 0) && (isr_number != 11); } +void display_ensure_refreshed(void); + #endif // TREZORHAL_DISPLAY_INTERNAL_H diff --git a/core/embed/io/display/st-7789/display_nofb.c b/core/embed/io/display/st-7789/display_nofb.c index dde43a8bcf5..4eb73939a55 100644 --- a/core/embed/io/display/st-7789/display_nofb.c +++ b/core/embed/io/display/st-7789/display_nofb.c @@ -22,15 +22,21 @@ #include +#include "display_internal.h" #include "display_io.h" #include "display_panel.h" #ifdef KERNEL_MODE void display_refresh(void) { - // If the framebuffer is not used the, we do not need + // If the framebuffer is not used then, we do not need // to refresh the display explicitly as we write the data // directly to the display internal RAM. + + // but still, we will wait before raising backlight + // to make sure the display is showing new content + display_driver_t* drv = &g_display_driver; + drv->update_pending = 2; } void display_wait_for_sync(void) { @@ -47,6 +53,22 @@ void display_wait_for_sync(void) { #endif } +void display_ensure_refreshed(void) { +#ifndef BOARDLOADER + display_driver_t* drv = &g_display_driver; + + if (!drv->initialized) { + return; + } + + while (drv->update_pending > 0) { + display_wait_for_sync(); + drv->update_pending--; + } + +#endif +} + static inline void set_window(const gfx_bitblt_t* bb) { display_panel_set_window(bb->dst_x, bb->dst_y, bb->dst_x + bb->width - 1, bb->dst_y + bb->height + 1);