2121
2222#if CONFIG_BSP_LCD_TYPE_1024_600
2323#include "esp_lcd_ek79007.h"
24+ #elif CONFIG_BSP_LCD_TYPE_HDMI
25+ #include "esp_lcd_lt8912b.h"
2426#else
2527#include "esp_lcd_ili9881c.h"
2628#endif
@@ -402,12 +404,14 @@ esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_hand
402404esp_err_t bsp_display_new_with_handles (const bsp_display_config_t * config , bsp_lcd_handles_t * ret_handles )
403405{
404406 esp_err_t ret = ESP_OK ;
407+ esp_lcd_panel_io_handle_t io = NULL ;
408+ esp_lcd_panel_handle_t disp_panel = NULL ;
405409
406410 ESP_RETURN_ON_ERROR (bsp_display_brightness_init (), TAG , "Brightness init failed" );
407411 ESP_RETURN_ON_ERROR (bsp_enable_dsi_phy_power (), TAG , "DSI PHY power failed" );
408412
409413 /* create MIPI DSI bus first, it will initialize the DSI PHY as well */
410- esp_lcd_dsi_bus_handle_t mipi_dsi_bus ;
414+ esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL ;
411415 esp_lcd_dsi_bus_config_t bus_config = {
412416 .bus_id = 0 ,
413417 .num_data_lanes = BSP_LCD_MIPI_DSI_LANE_NUM ,
@@ -416,17 +420,17 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
416420 };
417421 ESP_RETURN_ON_ERROR (esp_lcd_new_dsi_bus (& bus_config , & mipi_dsi_bus ), TAG , "New DSI bus init failed" );
418422
423+ #if !CONFIG_BSP_LCD_TYPE_HDMI
419424 ESP_LOGI (TAG , "Install MIPI DSI LCD control panel" );
420425 // we use DBI interface to send LCD commands and parameters
421- esp_lcd_panel_io_handle_t io ;
422426 esp_lcd_dbi_io_config_t dbi_config = {
423427 .virtual_channel = 0 ,
424- .lcd_cmd_bits = 8 , // according to the LCD ILI9881C spec
425- .lcd_param_bits = 8 , // according to the LCD ILI9881C spec
428+ .lcd_cmd_bits = 8 , // according to the LCD spec
429+ .lcd_param_bits = 8 , // according to the LCD spec
426430 };
427431 ESP_GOTO_ON_ERROR (esp_lcd_new_panel_io_dbi (mipi_dsi_bus , & dbi_config , & io ), err , TAG , "New panel IO failed" );
432+ #endif
428433
429- esp_lcd_panel_handle_t disp_panel = NULL ;
430434#if CONFIG_BSP_LCD_TYPE_1024_600
431435 // create EK79007 control panel
432436 ESP_LOGI (TAG , "Install EK79007 LCD control panel" );
@@ -453,7 +457,7 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
453457 ESP_GOTO_ON_ERROR (esp_lcd_new_panel_ek79007 (io , & lcd_dev_config , & disp_panel ), err , TAG , "New LCD panel EK79007 failed" );
454458 ESP_GOTO_ON_ERROR (esp_lcd_panel_reset (disp_panel ), err , TAG , "LCD panel reset failed" );
455459 ESP_GOTO_ON_ERROR (esp_lcd_panel_init (disp_panel ), err , TAG , "LCD panel init failed" );
456- #else
460+ #elif CONFIG_BSP_LCD_TYPE_1280_800
457461 // create ILI9881C control panel
458462 ESP_LOGI (TAG , "Install ILI9881C LCD control panel" );
459463#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
@@ -480,15 +484,100 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
480484 ESP_GOTO_ON_ERROR (esp_lcd_panel_reset (disp_panel ), err , TAG , "LCD panel reset failed" );
481485 ESP_GOTO_ON_ERROR (esp_lcd_panel_init (disp_panel ), err , TAG , "LCD panel init failed" );
482486 ESP_GOTO_ON_ERROR (esp_lcd_panel_disp_on_off (disp_panel , true), err , TAG , "LCD panel ON failed" );
487+
488+ #elif CONFIG_BSP_LCD_TYPE_HDMI
489+
490+ #if !CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
491+ #error The color format must be RGB888 in HDMI display type!
492+ #endif
493+ ESP_LOGI (TAG , "Install MIPI DSI HDMI control panel" );
494+ ESP_RETURN_ON_ERROR (bsp_i2c_init (), TAG , "I2C init failed" );
495+
496+ /* Main IO */
497+ esp_lcd_panel_io_i2c_config_t io_config = LT8912B_IO_CFG (CONFIG_BSP_I2C_CLK_SPEED_HZ , LT8912B_IO_I2C_MAIN_ADDRESS );
498+ ESP_ERROR_CHECK (esp_lcd_new_panel_io_i2c (i2c_handle , & io_config , & io ));
499+
500+ /* CEC DSI IO */
501+ esp_lcd_panel_io_handle_t io_cec_dsi = NULL ;
502+ esp_lcd_panel_io_i2c_config_t io_config_cec = LT8912B_IO_CFG (CONFIG_BSP_I2C_CLK_SPEED_HZ , LT8912B_IO_I2C_CEC_ADDRESS );
503+ ESP_ERROR_CHECK (esp_lcd_new_panel_io_i2c (i2c_handle , & io_config_cec , & io_cec_dsi ));
504+
505+ /* AVI IO */
506+ esp_lcd_panel_io_handle_t io_avi = NULL ;
507+ esp_lcd_panel_io_i2c_config_t io_config_avi = LT8912B_IO_CFG (CONFIG_BSP_I2C_CLK_SPEED_HZ , LT8912B_IO_I2C_AVI_ADDRESS );
508+ ESP_ERROR_CHECK (esp_lcd_new_panel_io_i2c (i2c_handle , & io_config_avi , & io_avi ));
509+
510+ /* DPI config */
511+ #if CONFIG_BSP_LCD_HDMI_800x600_60HZ
512+ ESP_LOGI (TAG , "HDMI configuration for 800x600@60HZ" );
513+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_800x600_PANEL_60HZ_DPI_CONFIG ();
514+ #elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ
515+ ESP_LOGI (TAG , "HDMI configuration for 1024x768@60HZ" );
516+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1024x768_PANEL_60HZ_DPI_CONFIG ();
517+ #elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ
518+ ESP_LOGI (TAG , "HDMI configuration for 1280x720@60HZ" );
519+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1280x720_PANEL_60HZ_DPI_CONFIG ();
520+ #elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ
521+ ESP_LOGI (TAG , "HDMI configuration for 1280x800@60HZ" );
522+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1280x800_PANEL_60HZ_DPI_CONFIG ();
523+ #elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ
524+ ESP_LOGI (TAG , "HDMI configuration for 1920x1080@30HZ" );
525+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_30HZ_DPI_CONFIG ();
526+ #elif CONFIG_BSP_LCD_HDMI_1920x1080_60HZ
527+ ESP_LOGI (TAG , "HDMI configuration for 1920x1080@60HZ" );
528+ /* This setting is not working yet, it is only for developing and testing */
529+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_60HZ_DPI_CONFIG ();
530+ #else
531+ #error Unsupported display type
483532#endif
533+ dpi_config .num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS ;
534+ lt8912b_vendor_config_t vendor_config = {
535+ #if CONFIG_BSP_LCD_HDMI_800x600_60HZ
536+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_800x600_60Hz (),
537+ #elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ
538+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1024x768_60Hz (),
539+ #elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ
540+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x720_60Hz (),
541+ #elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ
542+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x800_60Hz (),
543+ #elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ
544+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_30Hz (),
545+ #elif CONFIG_BSP_LCD_HDMI_1920x1080_60HZ
546+ /* This setting is not working yet, it is only for developing and testing */
547+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_60Hz (),
548+ #else
549+ #error Unsupported display type
550+ #endif
551+ .mipi_config = {
552+ .dsi_bus = mipi_dsi_bus ,
553+ .dpi_config = & dpi_config ,
554+ .lane_num = BSP_LCD_MIPI_DSI_LANE_NUM ,
555+ },
556+ };
557+ const esp_lcd_panel_dev_config_t panel_config = {
558+ .bits_per_pixel = 24 ,
559+ .rgb_ele_order = BSP_LCD_COLOR_SPACE ,
560+ .reset_gpio_num = BSP_LCD_RST ,
561+ .vendor_config = & vendor_config ,
562+ };
563+ const esp_lcd_panel_lt8912b_io_t io_all = {
564+ .main = io ,
565+ .cec_dsi = io_cec_dsi ,
566+ .avi = io_avi ,
567+ };
568+ ESP_ERROR_CHECK (esp_lcd_new_panel_lt8912b (& io_all , & panel_config , & disp_panel ));
569+ ESP_GOTO_ON_ERROR (esp_lcd_panel_reset (disp_panel ), err , TAG , "LCD panel reset failed" );
570+ ESP_GOTO_ON_ERROR (esp_lcd_panel_init (disp_panel ), err , TAG , "LCD panel init failed" );
571+
572+ #endif //CONFIG_BSP_LCD_TYPE_
484573
485574 /* Return all handles */
486575 ret_handles -> io = io ;
487576 ret_handles -> mipi_dsi_bus = mipi_dsi_bus ;
488577 ret_handles -> panel = disp_panel ;
489578 ret_handles -> control = NULL ;
490579
491- ESP_LOGI (TAG , "Display initialized" );
580+ ESP_LOGI (TAG , "Display initialized with resolution %dx%d" , BSP_LCD_H_RES , BSP_LCD_V_RES );
492581
493582 return ret ;
494583
@@ -499,12 +588,21 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
499588 if (io ) {
500589 esp_lcd_panel_io_del (io );
501590 }
591+ #if CONFIG_BSP_LCD_TYPE_HDMI
592+ if (io_cec_dsi ) {
593+ esp_lcd_panel_io_del (io_cec_dsi );
594+ }
595+ if (io_avi ) {
596+ esp_lcd_panel_io_del (io_avi );
597+ }
598+ #endif
502599 if (mipi_dsi_bus ) {
503600 esp_lcd_del_dsi_bus (mipi_dsi_bus );
504601 }
505602 return ret ;
506603}
507604
605+ #if !CONFIG_BSP_LCD_TYPE_HDMI
508606esp_err_t bsp_touch_new (const bsp_touch_config_t * config , esp_lcd_touch_handle_t * ret_touch )
509607{
510608 /* Initilize I2C */
@@ -537,6 +635,7 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
537635 ESP_RETURN_ON_ERROR (esp_lcd_new_panel_io_i2c (i2c_handle , & tp_io_config , & tp_io_handle ), TAG , "" );
538636 return esp_lcd_touch_new_i2c_gt911 (tp_io_handle , & tp_cfg , ret_touch );
539637}
638+ #endif //!CONFIG_BSP_LCD_TYPE_HDMI
540639
541640#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0 )
542641static lv_display_t * bsp_display_lcd_init (const bsp_display_cfg_t * cfg )
@@ -601,6 +700,7 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
601700 return lvgl_port_add_disp_dsi (& disp_cfg , & dpi_cfg );
602701}
603702
703+ #if !CONFIG_BSP_LCD_TYPE_HDMI
604704static lv_indev_t * bsp_display_indev_init (lv_display_t * disp )
605705{
606706 esp_lcd_touch_handle_t tp ;
@@ -615,6 +715,7 @@ static lv_indev_t *bsp_display_indev_init(lv_display_t *disp)
615715
616716 return lvgl_port_add_touch (& touch_cfg );
617717}
718+ #endif //!CONFIG_BSP_LCD_TYPE_HDMI
618719
619720lv_display_t * bsp_display_start (void )
620721{
@@ -645,9 +746,9 @@ lv_display_t *bsp_display_start_with_config(const bsp_display_cfg_t *cfg)
645746 BSP_ERROR_CHECK_RETURN_NULL (bsp_display_brightness_init ());
646747
647748 BSP_NULL_CHECK (disp = bsp_display_lcd_init (cfg ), NULL );
648-
749+ #if ! CONFIG_BSP_LCD_TYPE_HDMI
649750 BSP_NULL_CHECK (disp_indev = bsp_display_indev_init (disp ), NULL );
650-
751+ #endif
651752 return disp ;
652753}
653754
0 commit comments