From 917b46bb861e330d3fa9ef61074e7884dedbdc78 Mon Sep 17 00:00:00 2001 From: Sven Depoorter Date: Mon, 27 May 2024 16:46:16 +0200 Subject: [PATCH] modules: lvgl: fix not taking into account initial display orientation Certain display drivers allow for setting an initial display orientation using a device tree property. LVGL should take this into account while initializing. I could have written "disp_drv.rotated = disp_data.cap.current_orientation" because the enums match, but they are different types and they might get mismatched in the future. Signed-off-by: Sven Depoorter --- modules/lvgl/lvgl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/lvgl/lvgl.c b/modules/lvgl/lvgl.c index 76df359e7fc73..1b0c70cbd8ba0 100644 --- a/modules/lvgl/lvgl.c +++ b/modules/lvgl/lvgl.c @@ -225,6 +225,24 @@ static int lvgl_init(void) lv_disp_drv_init(&disp_drv); disp_drv.user_data = (void *)&disp_data; + switch (disp_data.cap.current_orientation) { + case DISPLAY_ORIENTATION_NORMAL: + disp_drv.rotated = LV_DISP_ROT_NONE; + break; + case DISPLAY_ORIENTATION_ROTATED_90: + disp_drv.rotated = LV_DISP_ROT_90; + break; + case DISPLAY_ORIENTATION_ROTATED_180: + disp_drv.rotated = LV_DISP_ROT_180; + break; + case DISPLAY_ORIENTATION_ROTATED_270: + disp_drv.rotated = LV_DISP_ROT_270; + break; + default: + LOG_ERR("Invalid display orientation"); + return -EINVAL; + } + #ifdef CONFIG_LV_Z_FULL_REFRESH disp_drv.full_refresh = 1; #endif