1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-15 18:00:59 +00:00

feat(core): add display_init return value

[no changelog]
This commit is contained in:
cepetr 2025-01-13 19:08:16 +01:00 committed by cepetr
parent 47f618c640
commit 1f3e640dd9
6 changed files with 22 additions and 11 deletions

View File

@ -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.
//

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {