From 8d769753e013cb81c53973078111283a676f7d80 Mon Sep 17 00:00:00 2001 From: Emma Patterson <54838146+MrSumi@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:00:46 +0800 Subject: [PATCH 1/3] Update esp_lvgl_port_disp.c --- .../src/lvgl9/esp_lvgl_port_disp.c | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c index 99021737a..cf28e3724 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c @@ -25,11 +25,11 @@ #include "../common/ppa/lcd_ppa.h" #endif -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) #include "esp_lcd_panel_rgb.h" #endif -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) #include "esp_lcd_mipi_dsi.h" #endif @@ -78,10 +78,10 @@ typedef struct { static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_disp_priv_cfg_t *priv_cfg); #if LVGL_PORT_HANDLE_FLUSH_READY static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx); -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) static bool lvgl_port_flush_rgb_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx); #endif -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) static bool lvgl_port_flush_dpi_panel_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx); static bool lvgl_port_flush_dpi_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx); #endif @@ -127,6 +127,7 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co { assert(dsi_cfg != NULL); const lvgl_port_disp_priv_cfg_t priv_cfg = { + .disp_type = LVGL_PORT_DISP_TYPE_DSI, .avoid_tearing = dsi_cfg->flags.avoid_tearing, }; lvgl_port_lock(0); @@ -137,7 +138,7 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co /* Set display type */ disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_DSI; -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) esp_lcd_dpi_panel_event_callbacks_t cbs = {0}; if (dsi_cfg->flags.avoid_tearing) { cbs.on_refresh_done = lvgl_port_flush_dpi_vsync_ready_callback; @@ -164,6 +165,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co lvgl_port_lock(0); assert(rgb_cfg != NULL); const lvgl_port_disp_priv_cfg_t priv_cfg = { + .disp_type = LVGL_PORT_DISP_TYPE_RGB, .avoid_tearing = rgb_cfg->flags.avoid_tearing, }; lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg); @@ -173,16 +175,14 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co /* Set display type */ disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_RGB; -#if (CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) /* Register done callback */ const esp_lcd_rgb_panel_event_callbacks_t vsync_cbs = { .on_vsync = lvgl_port_flush_rgb_vsync_ready_callback, }; const esp_lcd_rgb_panel_event_callbacks_t bb_cbs = { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0) - .on_frame_buf_complete = lvgl_port_flush_rgb_vsync_ready_callback, -#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2) +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2) .on_bounce_frame_finish = lvgl_port_flush_rgb_vsync_ready_callback, #endif }; @@ -193,7 +193,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co ESP_ERROR_CHECK(esp_lcd_rgb_panel_register_event_callbacks(disp_ctx->panel_handle, &vsync_cbs, disp_ctx->disp_drv)); } #else - ESP_RETURN_ON_FALSE(false, NULL, TAG, "RGB is supported only on ESP32S3 and from IDF 5.0!"); + ESP_RETURN_ON_FALSE(false, NULL, TAG, "RGB is supported only on ESP32S3/ESP32P4 and from IDF 5.0!"); #endif /* Apply rotation from initial display configuration */ @@ -316,12 +316,16 @@ static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp /* Use RGB internal buffers for avoid tearing effect */ if (priv_cfg && priv_cfg->avoid_tearing) { -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - buffer_size = disp_cfg->hres * disp_cfg->vres; - ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); -#elif CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) - buffer_size = disp_cfg->hres * disp_cfg->vres; - ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); +#if CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + if(priv_cfg->disp_type == LVGL_PORT_DISP_TYPE_RGB) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); + } +#elif CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) + if(priv_cfg->disp_type == LVGL_PORT_DISP_TYPE_DSI) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); + } #endif trans_sem = xSemaphoreCreateCounting(1, 0); @@ -455,7 +459,7 @@ static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io return false; } -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) static bool lvgl_port_flush_dpi_panel_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx) { lv_display_t *disp_drv = (lv_display_t *)user_ctx; @@ -481,7 +485,7 @@ static bool lvgl_port_flush_dpi_vsync_ready_callback(esp_lcd_panel_handle_t pane } #endif -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) static bool lvgl_port_flush_rgb_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx) { BaseType_t need_yield = pdFALSE; From 997c6b9b9bd77ae1b34641813f7397c553101bbb Mon Sep 17 00:00:00 2001 From: Emma Patterson <54838146+MrSumi@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:53:58 +0800 Subject: [PATCH 2/3] Update esp_lvgl_port_priv.h --- components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h b/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h index 16bdca3bd..5d88aef0e 100644 --- a/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h +++ b/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h @@ -28,6 +28,7 @@ typedef enum { * @brief Rotation configuration */ typedef struct { + lvgl_port_disp_type_t disp_type; unsigned int avoid_tearing: 1; /*!< Use internal RGB buffers as a LVGL draw buffers to avoid tearing effect */ } lvgl_port_disp_priv_cfg_t; From 7b4ca82d3021359bce6b56e97fcfe9f0f2992f33 Mon Sep 17 00:00:00 2001 From: Emma Patterson <54838146+MrSumi@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:55:27 +0800 Subject: [PATCH 3/3] Update esp_lvgl_port_disp.c --- .../src/lvgl8/esp_lvgl_port_disp.c | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c index 30075b356..ce4796a31 100644 --- a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c +++ b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c @@ -18,11 +18,11 @@ #include "freertos/task.h" #include "freertos/semphr.h" -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) #include "esp_lcd_panel_rgb.h" #endif -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) #include "esp_lcd_mipi_dsi.h" #endif @@ -57,10 +57,10 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf static lvgl_port_display_ctx_t *lvgl_port_get_display_ctx(lv_disp_t *disp); #if LVGL_PORT_HANDLE_FLUSH_READY static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx); -#if (CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) static bool lvgl_port_flush_rgb_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx); #endif -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) static bool lvgl_port_flush_dpi_panel_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx); static bool lvgl_port_flush_dpi_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx); #endif @@ -100,6 +100,7 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co { assert(dsi_cfg != NULL); const lvgl_port_disp_priv_cfg_t priv_cfg = { + .disp_type = LVGL_PORT_DISP_TYPE_DSI, .avoid_tearing = dsi_cfg->flags.avoid_tearing, }; lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg); @@ -109,7 +110,7 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co /* Set display type */ disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_DSI; -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) esp_lcd_dpi_panel_event_callbacks_t cbs = {0}; if (dsi_cfg->flags.avoid_tearing) { cbs.on_refresh_done = lvgl_port_flush_dpi_vsync_ready_callback; @@ -130,6 +131,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co { assert(rgb_cfg != NULL); const lvgl_port_disp_priv_cfg_t priv_cfg = { + .disp_type = LVGL_PORT_DISP_TYPE_RGB, .avoid_tearing = rgb_cfg->flags.avoid_tearing, }; lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg); @@ -139,16 +141,14 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co /* Set display type */ disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_RGB; -#if (CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) /* Register done callback */ const esp_lcd_rgb_panel_event_callbacks_t vsync_cbs = { .on_vsync = lvgl_port_flush_rgb_vsync_ready_callback, }; const esp_lcd_rgb_panel_event_callbacks_t bb_cbs = { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0) - .on_frame_buf_complete = lvgl_port_flush_rgb_vsync_ready_callback, -#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2) +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2) .on_bounce_frame_finish = lvgl_port_flush_rgb_vsync_ready_callback, #endif }; @@ -159,7 +159,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co ESP_ERROR_CHECK(esp_lcd_rgb_panel_register_event_callbacks(disp_ctx->panel_handle, &vsync_cbs, &disp_ctx->disp_drv)); } #else - ESP_RETURN_ON_FALSE(false, NULL, TAG, "RGB is supported only on ESP32S3 and from IDF 5.0!"); + ESP_RETURN_ON_FALSE(false, NULL, TAG, "RGB is supported only on ESP32S3/ESP32P4 and from IDF 5.0!"); #endif } @@ -254,12 +254,16 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf /* Use RGB internal buffers for avoid tearing effect */ if (priv_cfg && priv_cfg->avoid_tearing) { -#if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - buffer_size = disp_cfg->hres * disp_cfg->vres; - ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); -#elif CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) - buffer_size = disp_cfg->hres * disp_cfg->vres; - ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); +#if CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + if(priv_cfg->disp_type == LVGL_PORT_DISP_TYPE_RGB) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); + } +#elif CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) + if(priv_cfg->disp_type == LVGL_PORT_DISP_TYPE_DSI) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); + } #endif trans_sem = xSemaphoreCreateCounting(1, 0); @@ -378,7 +382,7 @@ static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io return false; } -#if (CONFIG_IDF_TARGET_ESP32P4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) +#if (CONFIG_SOC_MIPI_DSI_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) static bool lvgl_port_flush_dpi_panel_ready_callback(esp_lcd_panel_handle_t panel_io, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx) { BaseType_t taskAwake = pdFALSE; @@ -413,7 +417,7 @@ static bool lvgl_port_flush_dpi_vsync_ready_callback(esp_lcd_panel_handle_t pane } #endif -#if (CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) +#if (CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) static bool lvgl_port_flush_rgb_vsync_ready_callback(esp_lcd_panel_handle_t panel_io, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx) { BaseType_t need_yield = pdFALSE;