diff --git a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c index e8584812..6c8405b0 100644 --- a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c +++ b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c @@ -1,9 +1,10 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ +#include #include "sdkconfig.h" #include "driver/gpio.h" #include "driver/ledc.h" @@ -415,12 +416,16 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l esp_lcd_dsi_bus_config_t bus_config = { .bus_id = 0, .num_data_lanes = BSP_LCD_MIPI_DSI_LANE_NUM, - .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, - .lane_bit_rate_mbps = BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS, + .phy_clk_src = config->dsi_bus.phy_clk_src, + .lane_bit_rate_mbps = config->dsi_bus.lane_bit_rate_mbps, }; ESP_RETURN_ON_ERROR(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus), TAG, "New DSI bus init failed"); #if !CONFIG_BSP_LCD_TYPE_HDMI + if (config->hdmi_resolution != BSP_HDMI_RES_NONE) { + ESP_LOGW(TAG, "Please select HDMI in menuconfig, if you want to use it."); + } + ESP_LOGI(TAG, "Install MIPI DSI LCD control panel"); // we use DBI interface to send LCD commands and parameters esp_lcd_dbi_io_config_t dbi_config = { @@ -507,53 +512,62 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l esp_lcd_panel_io_i2c_config_t io_config_avi = LT8912B_IO_CFG(CONFIG_BSP_I2C_CLK_SPEED_HZ, LT8912B_IO_I2C_AVI_ADDRESS); ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_handle, &io_config_avi, &io_avi)); - /* DPI config */ -#if CONFIG_BSP_LCD_HDMI_800x600_60HZ - ESP_LOGI(TAG, "HDMI configuration for 800x600@60HZ"); - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_800x600_PANEL_60HZ_DPI_CONFIG(); -#elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ - ESP_LOGI(TAG, "HDMI configuration for 1024x768@60HZ"); - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1024x768_PANEL_60HZ_DPI_CONFIG(); -#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ - ESP_LOGI(TAG, "HDMI configuration for 1280x720@60HZ"); - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1280x720_PANEL_60HZ_DPI_CONFIG(); -#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ - ESP_LOGI(TAG, "HDMI configuration for 1280x800@60HZ"); - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1280x800_PANEL_60HZ_DPI_CONFIG(); -#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ - ESP_LOGI(TAG, "HDMI configuration for 1920x1080@30HZ"); - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_30HZ_DPI_CONFIG(); -#elif CONFIG_BSP_LCD_HDMI_1920x1080_60HZ - ESP_LOGI(TAG, "HDMI configuration for 1920x1080@60HZ"); - /* This setting is not working yet, it is only for developing and testing */ - esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_60HZ_DPI_CONFIG(); -#else -#error Unsupported display type -#endif - dpi_config.num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS; + esp_lcd_dpi_panel_config_t dpi_config; + const esp_lcd_dpi_panel_config_t dpi_configs[] = { + LT8912B_800x600_PANEL_60HZ_DPI_CONFIG(), + LT8912B_1024x768_PANEL_60HZ_DPI_CONFIG(), + LT8912B_1280x720_PANEL_60HZ_DPI_CONFIG(), + LT8912B_1280x800_PANEL_60HZ_DPI_CONFIG(), + LT8912B_1920x1080_PANEL_30HZ_DPI_CONFIG() + }; + + const esp_lcd_panel_lt8912b_video_timing_t video_timings[] = { + ESP_LCD_LT8912B_VIDEO_TIMING_800x600_60Hz(), + ESP_LCD_LT8912B_VIDEO_TIMING_1024x768_60Hz(), + ESP_LCD_LT8912B_VIDEO_TIMING_1280x720_60Hz(), + ESP_LCD_LT8912B_VIDEO_TIMING_1280x800_60Hz(), + ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_30Hz() + }; lt8912b_vendor_config_t vendor_config = { -#if CONFIG_BSP_LCD_HDMI_800x600_60HZ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_800x600_60Hz(), -#elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1024x768_60Hz(), -#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x720_60Hz(), -#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x800_60Hz(), -#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_30Hz(), -#elif CONFIG_BSP_LCD_HDMI_1920x1080_60HZ - /* This setting is not working yet, it is only for developing and testing */ - .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_60Hz(), -#else -#error Unsupported display type -#endif .mipi_config = { .dsi_bus = mipi_dsi_bus, .dpi_config = &dpi_config, .lane_num = BSP_LCD_MIPI_DSI_LANE_NUM, }, }; + + /* DPI config */ + switch (config->hdmi_resolution) { + case BSP_HDMI_RES_800x600: + ESP_LOGI(TAG, "HDMI configuration for 800x600@60HZ"); + memcpy(&dpi_config, &dpi_configs[0], sizeof(esp_lcd_dpi_panel_config_t)); + memcpy(&vendor_config.video_timing, &video_timings[0], sizeof(esp_lcd_panel_lt8912b_video_timing_t)); + break; + case BSP_HDMI_RES_1024x768: + ESP_LOGI(TAG, "HDMI configuration for 1024x768@60HZ"); + memcpy(&dpi_config, &dpi_configs[1], sizeof(esp_lcd_dpi_panel_config_t)); + memcpy(&vendor_config.video_timing, &video_timings[1], sizeof(esp_lcd_panel_lt8912b_video_timing_t)); + break; + case BSP_HDMI_RES_1280x720: + ESP_LOGI(TAG, "HDMI configuration for 1280x720@60HZ"); + memcpy(&dpi_config, &dpi_configs[2], sizeof(esp_lcd_dpi_panel_config_t)); + memcpy(&vendor_config.video_timing, &video_timings[2], sizeof(esp_lcd_panel_lt8912b_video_timing_t)); + break; + case BSP_HDMI_RES_1280x800: + ESP_LOGI(TAG, "HDMI configuration for 1280x800@60HZ"); + memcpy(&dpi_config, &dpi_configs[3], sizeof(esp_lcd_dpi_panel_config_t)); + memcpy(&vendor_config.video_timing, &video_timings[3], sizeof(esp_lcd_panel_lt8912b_video_timing_t)); + break; + case BSP_HDMI_RES_1920x1080: + ESP_LOGI(TAG, "HDMI configuration for 1920x1080@30HZ"); + memcpy(&dpi_config, &dpi_configs[4], sizeof(esp_lcd_dpi_panel_config_t)); + memcpy(&vendor_config.video_timing, &video_timings[4], sizeof(esp_lcd_panel_lt8912b_video_timing_t)); + break; + default: + ESP_LOGE(TAG, "Unsupported display type"); + } + + dpi_config.num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS; const esp_lcd_panel_dev_config_t panel_config = { .bits_per_pixel = 24, .rgb_ele_order = BSP_LCD_COLOR_SPACE, @@ -577,7 +591,7 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l ret_handles->panel = disp_panel; ret_handles->control = NULL; - ESP_LOGI(TAG, "Display initialized with resolution %dx%d", BSP_LCD_H_RES, BSP_LCD_V_RES); + ESP_LOGI(TAG, "Display initialized"); return ret; @@ -642,7 +656,41 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) { assert(cfg != NULL); bsp_lcd_handles_t lcd_panels; - BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new_with_handles(NULL, &lcd_panels)); + BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new_with_handles(&cfg->hw_cfg, &lcd_panels)); + + uint32_t display_hres = 0; + uint32_t display_vres = 0; +#if CONFIG_BSP_LCD_TYPE_HDMI + switch (cfg->hdmi_resolution) { + case BSP_HDMI_RES_800x600: + display_hres = 800; + display_vres = 600; + break; + case BSP_HDMI_RES_1024x768: + display_hres = 1024; + display_vres = 768; + break; + case BSP_HDMI_RES_1280x720: + display_hres = 1280; + display_vres = 720; + break; + case BSP_HDMI_RES_1280x800: + display_hres = 1280; + display_vres = 800; + break; + case BSP_HDMI_RES_1920x1080: + display_hres = 1920; + display_vres = 1080; + break; + default: + ESP_LOGE(TAG, "Unsupported HDMI resolution"); + } +#else + display_hres = BSP_LCD_H_RES; + display_vres = BSP_LCD_V_RES; +#endif + + ESP_LOGI(TAG, "Display resolution %ldx%ld", display_hres, display_vres); /* Add LCD screen */ ESP_LOGD(TAG, "Add LCD screen"); @@ -652,8 +700,8 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) .control_handle = lcd_panels.control, .buffer_size = cfg->buffer_size, .double_buffer = cfg->double_buffer, - .hres = BSP_LCD_H_RES, - .vres = BSP_LCD_V_RES, + .hres = display_hres, + .vres = display_vres, .monochrome = false, /* Rotation values must be same as used in esp_lcd for initial settings of the screen */ .rotation = { @@ -723,6 +771,25 @@ lv_display_t *bsp_display_start(void) .lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(), .buffer_size = BSP_LCD_DRAW_BUFF_SIZE, .double_buffer = BSP_LCD_DRAW_BUFF_DOUBLE, + .hw_cfg = { +#if CONFIG_BSP_LCD_TYPE_HDMI +#if BSP_LCD_HDMI_800x600_60HZ + .hdmi_resolution = BSP_HDMI_RES_800x600, +#elif BSP_LCD_HDMI_1280x720_60HZ + .hdmi_resolution = BSP_HDMI_RES_1280x720, +#elif BSP_LCD_HDMI_1280x800_60HZ + .hdmi_resolution = BSP_HDMI_RES_1280x800, +#elif BSP_LCD_HDMI_1920x1080_30HZ + .hdmi_resolution = BSP_HDMI_RES_1920x1080, +#endif +#else + .hdmi_resolution = BSP_HDMI_RES_NONE, +#endif + .dsi_bus = { + .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, + .lane_bit_rate_mbps = BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS, + } + }, .flags = { #if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 .buff_dma = false, diff --git a/bsp/esp32_p4_function_ev_board/idf_component.yml b/bsp/esp32_p4_function_ev_board/idf_component.yml index c2cf40e2..4c8fccdb 100644 --- a/bsp/esp32_p4_function_ev_board/idf_component.yml +++ b/bsp/esp32_p4_function_ev_board/idf_component.yml @@ -25,5 +25,5 @@ dependencies: public: true espressif/esp_lcd_lt8912b: - version: ">=0.1.0,<1.0.0" + version: ">=0.1.1,<1.0.0" override_path: "../../components/lcd/esp_lcd_lt8912b" diff --git a/bsp/esp32_p4_function_ev_board/include/bsp/display.h b/bsp/esp32_p4_function_ev_board/include/bsp/display.h index 97593857..8d0d1b9b 100644 --- a/bsp/esp32_p4_function_ev_board/include/bsp/display.h +++ b/bsp/esp32_p4_function_ev_board/include/bsp/display.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -40,55 +40,10 @@ /* LCD display definition 1024x600 */ #define BSP_LCD_H_RES (1024) #define BSP_LCD_V_RES (600) - -#define BSP_LCD_MIPI_DSI_LCD_HSYNC (1344) -#define BSP_LCD_MIPI_DSI_LCD_HBP (160) -#define BSP_LCD_MIPI_DSI_LCD_HFP (160) -#define BSP_LCD_MIPI_DSI_LCD_VSYNC (635) -#define BSP_LCD_MIPI_DSI_LCD_VBP (23) -#define BSP_LCD_MIPI_DSI_LCD_VFP (12) - -#elif CONFIG_BSP_LCD_TYPE_HDMI -#if CONFIG_BSP_LCD_HDMI_800x600_60HZ -/* LCD display definition 800x600 60Hz */ -#define BSP_LCD_H_RES (800) -#define BSP_LCD_V_RES (600) -#elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ -/* LCD display definition 1024x768 60Hz */ -#define BSP_LCD_H_RES (1024) -#define BSP_LCD_V_RES (768) -#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ -/* LCD display definition 1280x720 60Hz */ -#define BSP_LCD_H_RES (1280) -#define BSP_LCD_V_RES (720) -#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ -/* LCD display definition 1280x800 60Hz */ -#define BSP_LCD_H_RES (1280) -#define BSP_LCD_V_RES (800) -#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ -/* LCD display definition 1920x1080 30Hz */ -#define BSP_LCD_H_RES (1920) -#define BSP_LCD_V_RES (1080) -#elif CONFIG_BSP_LCD_HDMI_1920x1080_60HZ -/* LCD display definition 1920x1080 60Hz */ -/* This setting is not working yet, it is only for developing and testing */ -#define BSP_LCD_H_RES (1920) -#define BSP_LCD_V_RES (1080) -#else -#error Unsupported display type -#endif - #else /* LCD display definition 1280x800 */ #define BSP_LCD_H_RES (800) #define BSP_LCD_V_RES (1280) - -#define BSP_LCD_MIPI_DSI_LCD_HSYNC (40) -#define BSP_LCD_MIPI_DSI_LCD_HBP (140) -#define BSP_LCD_MIPI_DSI_LCD_HFP (40) -#define BSP_LCD_MIPI_DSI_LCD_VSYNC (4) -#define BSP_LCD_MIPI_DSI_LCD_VBP (16) -#define BSP_LCD_MIPI_DSI_LCD_VFP (16) #endif #define BSP_LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes @@ -101,12 +56,29 @@ extern "C" { #endif +/** + * @brief BSP HDMI resolution types + * + */ +typedef enum { + BSP_HDMI_RES_NONE = 0, + BSP_HDMI_RES_800x600, /*!< 800x600@60HZ */ + BSP_HDMI_RES_1024x768, /*!< 1024x768@60HZ */ + BSP_HDMI_RES_1280x720, /*!< 1280x720@60HZ */ + BSP_HDMI_RES_1280x800, /*!< 1280x800@60HZ */ + BSP_HDMI_RES_1920x1080 /*!< 1920x1080@30HZ */ +} bsp_hdmi_resolution_t; + /** * @brief BSP display configuration structure * */ typedef struct { - int dummy; + bsp_hdmi_resolution_t hdmi_resolution; /*!< HDMI resolution selection */ + struct { + mipi_dsi_phy_clock_source_t phy_clk_src; /*!< DSI bus config - clock source */ + uint32_t lane_bit_rate_mbps; /*!< DSI bus config - lane bit rate */ + } dsi_bus; } bsp_display_config_t; /** diff --git a/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h b/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h index 0fdc25c9..5829a565 100644 --- a/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h +++ b/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h @@ -273,6 +273,7 @@ typedef struct { lvgl_port_cfg_t lvgl_port_cfg; /*!< LVGL port configuration */ uint32_t buffer_size; /*!< Size of the buffer for the screen in pixels */ bool double_buffer; /*!< True, if should be allocated two buffers */ + bsp_display_config_t hw_cfg; /*!< Display HW configuration */ struct { unsigned int buff_dma: 1; /*!< Allocated LVGL buffer will be DMA capable */ unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */ diff --git a/components/lcd/esp_lcd_lt8912b/idf_component.yml b/components/lcd/esp_lcd_lt8912b/idf_component.yml index 964a358b..27a74230 100644 --- a/components/lcd/esp_lcd_lt8912b/idf_component.yml +++ b/components/lcd/esp_lcd_lt8912b/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.1.0" +version: "0.1.1" description: ESP LCD LT8912B (MIPI DSI - HDMI) url: https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_lt8912b repository: "https://github.com/espressif/esp-bsp.git" diff --git a/components/lcd/esp_lcd_lt8912b/include/esp_lcd_lt8912b.h b/components/lcd/esp_lcd_lt8912b/include/esp_lcd_lt8912b.h index 0b669ce3..902e82fd 100644 --- a/components/lcd/esp_lcd_lt8912b/include/esp_lcd_lt8912b.h +++ b/components/lcd/esp_lcd_lt8912b/include/esp_lcd_lt8912b.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -160,8 +160,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 800, \ + .v_size = 600, \ .hsync_back_porch = 88, \ .hsync_pulse_width = 128, \ .hsync_front_porch = 48, \ @@ -204,8 +204,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 1024, \ + .v_size = 768, \ .hsync_back_porch = 80, \ .hsync_pulse_width = 32, \ .hsync_front_porch = 48, \ @@ -248,8 +248,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 1280, \ + .v_size = 720, \ .hsync_back_porch = 80, \ .hsync_pulse_width = 32, \ .hsync_front_porch = 48, \ @@ -292,8 +292,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 1280, \ + .v_size = 800, \ .hsync_back_porch = 80, \ .hsync_pulse_width = 32, \ .hsync_front_porch = 48, \ @@ -336,8 +336,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 1920, \ + .v_size = 1080, \ .hsync_back_porch = 80, \ .hsync_pulse_width = 32, \ .hsync_front_porch = 48, \ @@ -383,8 +383,8 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel); .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, \ .num_fbs = 1, \ .video_timing = { \ - .h_size = BSP_LCD_H_RES, \ - .v_size = BSP_LCD_V_RES, \ + .h_size = 1920, \ + .v_size = 1080, \ .hsync_back_porch = 80, \ .hsync_pulse_width = 32, \ .hsync_front_porch = 48, \