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,94 @@ 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 1280x800@30HZ" );
525+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_30HZ_DPI_CONFIG ();
526+ #else
527+ ESP_LOGI (TAG , "HDMI configuration for 1920x1080@60HZ" );
528+ esp_lcd_dpi_panel_config_t dpi_config = LT8912B_1920x1080_PANEL_60HZ_DPI_CONFIG ();
483529#endif
530+ dpi_config .num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS ;
531+ lt8912b_vendor_config_t vendor_config = {
532+ #if CONFIG_BSP_LCD_HDMI_800x600_60HZ
533+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_800x600_60Hz (),
534+ #elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ
535+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1024x768_60Hz (),
536+ #elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ
537+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x720_60Hz (),
538+ #elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ
539+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1280x800_60Hz (),
540+ #elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ
541+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_30Hz (),
542+ #else
543+ .video_timing = ESP_LCD_LT8912B_VIDEO_TIMING_1920x1080_60Hz (),
544+ #endif
545+ .mipi_config = {
546+ .dsi_bus = mipi_dsi_bus ,
547+ .dpi_config = & dpi_config ,
548+ .lane_num = BSP_LCD_MIPI_DSI_LANE_NUM ,
549+ },
550+ };
551+ const esp_lcd_panel_dev_config_t panel_config = {
552+ .bits_per_pixel = 24 ,
553+ .rgb_ele_order = BSP_LCD_COLOR_SPACE ,
554+ .reset_gpio_num = BSP_LCD_RST ,
555+ .vendor_config = & vendor_config ,
556+ };
557+ const esp_lcd_panel_lt8912b_io_t io_all = {
558+ .main = io ,
559+ .cec_dsi = io_cec_dsi ,
560+ .avi = io_avi ,
561+ };
562+ ESP_ERROR_CHECK (esp_lcd_new_panel_lt8912b (& io_all , & panel_config , & disp_panel ));
563+ ESP_GOTO_ON_ERROR (esp_lcd_panel_reset (disp_panel ), err , TAG , "LCD panel reset failed" );
564+ ESP_GOTO_ON_ERROR (esp_lcd_panel_init (disp_panel ), err , TAG , "LCD panel init failed" );
565+
566+ #endif //CONFIG_BSP_LCD_TYPE_
484567
485568 /* Return all handles */
486569 ret_handles -> io = io ;
487570 ret_handles -> mipi_dsi_bus = mipi_dsi_bus ;
488571 ret_handles -> panel = disp_panel ;
489572 ret_handles -> control = NULL ;
490573
491- ESP_LOGI (TAG , "Display initialized" );
574+ ESP_LOGI (TAG , "Display initialized with resolution %dx%d" , BSP_LCD_H_RES , BSP_LCD_V_RES );
492575
493576 return ret ;
494577
@@ -499,12 +582,21 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
499582 if (io ) {
500583 esp_lcd_panel_io_del (io );
501584 }
585+ #if CONFIG_BSP_LCD_TYPE_HDMI
586+ if (io_cec_dsi ) {
587+ esp_lcd_panel_io_del (io_cec_dsi );
588+ }
589+ if (io_avi ) {
590+ esp_lcd_panel_io_del (io_avi );
591+ }
592+ #endif
502593 if (mipi_dsi_bus ) {
503594 esp_lcd_del_dsi_bus (mipi_dsi_bus );
504595 }
505596 return ret ;
506597}
507598
599+ #if !CONFIG_BSP_LCD_TYPE_HDMI
508600esp_err_t bsp_touch_new (const bsp_touch_config_t * config , esp_lcd_touch_handle_t * ret_touch )
509601{
510602 /* Initilize I2C */
@@ -537,6 +629,7 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
537629 ESP_RETURN_ON_ERROR (esp_lcd_new_panel_io_i2c (i2c_handle , & tp_io_config , & tp_io_handle ), TAG , "" );
538630 return esp_lcd_touch_new_i2c_gt911 (tp_io_handle , & tp_cfg , ret_touch );
539631}
632+ #endif //!CONFIG_BSP_LCD_TYPE_HDMI
540633
541634#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0 )
542635static lv_display_t * bsp_display_lcd_init (const bsp_display_cfg_t * cfg )
@@ -601,6 +694,7 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
601694 return lvgl_port_add_disp_dsi (& disp_cfg , & dpi_cfg );
602695}
603696
697+ #if !CONFIG_BSP_LCD_TYPE_HDMI
604698static lv_indev_t * bsp_display_indev_init (lv_display_t * disp )
605699{
606700 esp_lcd_touch_handle_t tp ;
@@ -615,6 +709,7 @@ static lv_indev_t *bsp_display_indev_init(lv_display_t *disp)
615709
616710 return lvgl_port_add_touch (& touch_cfg );
617711}
712+ #endif //!CONFIG_BSP_LCD_TYPE_HDMI
618713
619714lv_display_t * bsp_display_start (void )
620715{
@@ -645,9 +740,9 @@ lv_display_t *bsp_display_start_with_config(const bsp_display_cfg_t *cfg)
645740 BSP_ERROR_CHECK_RETURN_NULL (bsp_display_brightness_init ());
646741
647742 BSP_NULL_CHECK (disp = bsp_display_lcd_init (cfg ), NULL );
648-
743+ #if ! CONFIG_BSP_LCD_TYPE_HDMI
649744 BSP_NULL_CHECK (disp_indev = bsp_display_indev_init (disp ), NULL );
650-
745+ #endif
651746 return disp ;
652747}
653748
0 commit comments