Skip to content

Commit

Permalink
fix(core): fix flashing old display content on model T
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
TychoVrahe committed Jan 24, 2025
1 parent fa8043c commit 8bad0c8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
6 changes: 2 additions & 4 deletions core/embed/io/display/st-7789/display_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,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
Expand Down Expand Up @@ -138,13 +138,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);
Expand Down
2 changes: 0 additions & 2 deletions core/embed/io/display/st-7789/display_fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions core/embed/io/display/st-7789/display_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 28 additions & 1 deletion core/embed/io/display/st-7789/display_nofb.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@

#include <io/display.h>

#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;

if (!drv->initialized) {
return;
}

drv->update_pending = 2;
}

void display_wait_for_sync(void) {
Expand All @@ -47,6 +58,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);
Expand Down

0 comments on commit 8bad0c8

Please sign in to comment.