mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-12 09:28:10 +00:00
fixup! refactor(core): extract framebuffer queue for reuse
This commit is contained in:
parent
6687a95b8e
commit
28f89601d7
@ -56,6 +56,12 @@ void display_init(display_content_mode_t mode) {
|
||||
|
||||
memset(drv, 0, sizeof(display_driver_t));
|
||||
|
||||
fb_queue_reset(&drv->empty_frames);
|
||||
fb_queue_reset(&drv->ready_frames);
|
||||
|
||||
fb_queue_put(&drv->empty_frames, 0);
|
||||
fb_queue_put(&drv->empty_frames, 1);
|
||||
|
||||
if (mode == DISPLAY_RESET_CONTENT) {
|
||||
display_io_init_gpio();
|
||||
display_io_init_fmc();
|
||||
|
@ -63,7 +63,7 @@ _Static_assert(FRAME_BUFFER_COUNT == 1 || FRAME_BUFFER_COUNT == 2);
|
||||
PHYSICAL_FRAME_BUFFER_ALIGNMENT)
|
||||
|
||||
// Physical frame buffers in internal SRAM memory.
|
||||
// Both frame buffers layes in the fixed addresses that
|
||||
// Both frame buffers layers in the fixed addresses that
|
||||
// are shared between bootloaders and the firmware.
|
||||
static
|
||||
__attribute__((section(".fb1"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
|
||||
@ -120,7 +120,7 @@ void display_physical_fb_clear(void) {
|
||||
static void bg_copy_callback(void) {
|
||||
display_driver_t *drv = &g_display_driver;
|
||||
|
||||
fb_queue_set_done(&drv->queue);
|
||||
fb_queue_put(&drv->empty_frames, fb_queue_take(&drv->ready_frames));
|
||||
}
|
||||
|
||||
// Interrupt routing handling TE signal
|
||||
@ -129,7 +129,7 @@ static void display_te_interrupt_handler(void) {
|
||||
|
||||
__HAL_GPIO_EXTI_CLEAR_FLAG(DISPLAY_TE_PIN);
|
||||
|
||||
int16_t fb_idx = fb_queue_get_for_transfer(&drv->queue);
|
||||
int16_t fb_idx = fb_queue_peek(&drv->ready_frames);
|
||||
|
||||
if (fb_idx >= 0) {
|
||||
display_panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1);
|
||||
@ -157,7 +157,8 @@ bool display_get_frame_buffer(display_fb_info_t *fb) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t fb_idx = fb_queue_get_for_write(&drv->queue);
|
||||
fb_queue_wait(&drv->empty_frames);
|
||||
uint8_t fb_idx = fb_queue_peek(&drv->empty_frames);
|
||||
|
||||
fb->ptr = get_fb_ptr(fb_idx);
|
||||
fb->stride = DISPLAY_RESX * sizeof(uint16_t);
|
||||
@ -200,9 +201,7 @@ void display_refresh(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t fb_idx = fb_queue_get_for_copy(&drv->queue);
|
||||
|
||||
if (fb_idx < 0) {
|
||||
if (!fb_queue_peeked(&drv->empty_frames)) {
|
||||
// No refresh needed as the frame buffer is not in
|
||||
// the state to be copied to the display
|
||||
return;
|
||||
@ -213,7 +212,7 @@ void display_refresh(void) {
|
||||
|
||||
#ifndef BOARDLOADER
|
||||
// Mark the buffer ready to switch to
|
||||
fb_queue_set_ready_for_transfer(&drv->queue);
|
||||
fb_queue_put(&drv->ready_frames, fb_queue_take(&drv->empty_frames));
|
||||
|
||||
#else // BOARDLOADER
|
||||
wait_for_te_signal();
|
||||
@ -241,7 +240,7 @@ void display_ensure_refreshed(void) {
|
||||
// so we can be sure there's not scheduled or pending
|
||||
// background copying
|
||||
do {
|
||||
copy_pending = !fb_queue_is_processed(&drv->queue);
|
||||
copy_pending = !fb_queue_empty(&drv->ready_frames);
|
||||
__WFI();
|
||||
} while (copy_pending);
|
||||
|
||||
|
@ -19,7 +19,8 @@ typedef struct {
|
||||
// Framebuffer queue
|
||||
// (accessed & updated in the context of the main thread
|
||||
// and the interrupt context)
|
||||
frame_buffer_queue_t queue;
|
||||
fb_queue_t empty_frames;
|
||||
fb_queue_t ready_frames;
|
||||
#endif
|
||||
|
||||
// Current display orientation (0, 90, 180, 270)
|
||||
|
Loading…
Reference in New Issue
Block a user