Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flashing old display content on model T #4515

Open
wants to merge 1 commit into
base: tychovrahe/bootloader/slow_fade_fix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand Down Expand Up @@ -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);
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
24 changes: 23 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,21 @@

#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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big issue, but we should check whether the driver is initialized before accessing drv->update_pending.

drv->update_pending = 2;
}

void display_wait_for_sync(void) {
Expand All @@ -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);
Expand Down
Loading