diff --git a/core/embed/io/display/inc/io/display.h b/core/embed/io/display/inc/io/display.h index c64df9af68..be0e474fc4 100644 --- a/core/embed/io/display/inc/io/display.h +++ b/core/embed/io/display/inc/io/display.h @@ -59,7 +59,9 @@ typedef enum { // // If `mode` is `DISPLAY_RETAIN_CONTENT`, ensure the driver was previously // initialized and `display_deinit(DISPLAY_RETAIN_CONTENT)` was called. -void display_init(display_content_mode_t mode); +// +// Returns `true` if the initialization was successful. +bool display_init(display_content_mode_t mode); // Deinitializes the display controller. // diff --git a/core/embed/io/display/ltdc_dsi/display_driver.c b/core/embed/io/display/ltdc_dsi/display_driver.c index c0acf8bb78..5e6245de79 100644 --- a/core/embed/io/display/ltdc_dsi/display_driver.c +++ b/core/embed/io/display/ltdc_dsi/display_driver.c @@ -265,9 +265,13 @@ bool display_set_fb(uint32_t fb_addr) { } // Fully initializes the display controller. -void display_init(display_content_mode_t mode) { +bool display_init(display_content_mode_t mode) { display_driver_t *drv = &g_display_driver; + if (drv->initialized) { + return true; + } + GPIO_InitTypeDef GPIO_InitStructure = {0}; __HAL_RCC_DSI_FORCE_RESET(); @@ -353,7 +357,7 @@ void display_init(display_content_mode_t mode) { __HAL_LTDC_ENABLE_IT(&drv->hlcd_ltdc, LTDC_IT_LI | LTDC_IT_FU | LTDC_IT_TE); drv->initialized = true; - return; + return true; cleanup: NVIC_DisableIRQ(LTDC_IRQn); @@ -371,6 +375,7 @@ cleanup: #endif drv->initialized = false; + return false; } int display_set_backlight(int level) { diff --git a/core/embed/io/display/st-7789/display_driver.c b/core/embed/io/display/st-7789/display_driver.c index c8165a727f..d731119f82 100644 --- a/core/embed/io/display/st-7789/display_driver.c +++ b/core/embed/io/display/st-7789/display_driver.c @@ -47,11 +47,11 @@ display_driver_t g_display_driver = { .initialized = false, }; -void display_init(display_content_mode_t mode) { +bool display_init(display_content_mode_t mode) { display_driver_t* drv = &g_display_driver; if (drv->initialized) { - return; + return true; } memset(drv, 0, sizeof(display_driver_t)); @@ -84,6 +84,7 @@ void display_init(display_content_mode_t mode) { #endif drv->initialized = true; + return true; } void display_deinit(display_content_mode_t mode) { diff --git a/core/embed/io/display/stm32f429i-disc1/display_driver.c b/core/embed/io/display/stm32f429i-disc1/display_driver.c index 268fadfddc..1f7170acbe 100644 --- a/core/embed/io/display/stm32f429i-disc1/display_driver.c +++ b/core/embed/io/display/stm32f429i-disc1/display_driver.c @@ -50,11 +50,11 @@ static display_driver_t g_display_driver = { .initialized = false, }; -void display_init(display_content_mode_t mode) { +bool display_init(display_content_mode_t mode) { display_driver_t *drv = &g_display_driver; if (drv->initialized) { - return; + return true; } memset(drv, 0, sizeof(display_driver_t)); @@ -68,6 +68,7 @@ void display_init(display_content_mode_t mode) { } drv->initialized = true; + return true; } void display_deinit(display_content_mode_t mode) { diff --git a/core/embed/io/display/unix/display_driver.c b/core/embed/io/display/unix/display_driver.c index bdb25c787d..77ff5eeaba 100644 --- a/core/embed/io/display/unix/display_driver.c +++ b/core/embed/io/display/unix/display_driver.c @@ -89,11 +89,11 @@ static void display_exit_handler(void) { display_deinit(DISPLAY_RESET_CONTENT); } -void display_init(display_content_mode_t mode) { +bool display_init(display_content_mode_t mode) { display_driver_t *drv = &g_display_driver; if (drv->initialized) { - return; + return true; } if (SDL_Init(SDL_INIT_VIDEO) != 0) { @@ -179,6 +179,7 @@ void display_init(display_content_mode_t mode) { drv->orientation_angle = 0; #endif drv->initialized = true; + return true; } void display_deinit(display_content_mode_t mode) { diff --git a/core/embed/io/display/vg-2864/display_driver.c b/core/embed/io/display/vg-2864/display_driver.c index 8373e4d6c0..680e4cc740 100644 --- a/core/embed/io/display/vg-2864/display_driver.c +++ b/core/embed/io/display/vg-2864/display_driver.c @@ -243,11 +243,11 @@ static void display_sync_with_fb(display_driver_t *drv) { HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_RESET); } -void display_init(display_content_mode_t mode) { +bool display_init(display_content_mode_t mode) { display_driver_t *drv = &g_display_driver; if (drv->initialized) { - return; + return true; } memset(drv, 0, sizeof(display_driver_t)); @@ -319,6 +319,7 @@ void display_init(display_content_mode_t mode) { } drv->initialized = true; + return true; } void display_deinit(display_content_mode_t mode) {