Skip to content

Commit 5c04252

Browse files
committed
lt8912b: HDMI support.
1 parent e5a3498 commit 5c04252

File tree

11 files changed

+1527
-13
lines changed

11 files changed

+1527
-13
lines changed

bsp/esp32_p4_function_ev_board/Kconfig

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
menu "Board Support Package(ESP32-P4)"
1+
menu "Board Support Package (ESP32-P4)"
22

33
config BSP_ERROR_CHECK
44
bool "Enable error check in BSP"
@@ -131,7 +131,30 @@ menu "Board Support Package(ESP32-P4)"
131131
bool "LCD 7-inch 1024x600 - ek79007"
132132
config BSP_LCD_TYPE_1280_800
133133
bool "LCD 1280x800 - ili9881c"
134-
endchoice
134+
config BSP_LCD_TYPE_HDMI
135+
bool "HDMI - lt8912b"
136+
endchoice
137+
138+
choice BSP_LCD_HDMI_RESOLUTION
139+
depends on BSP_LCD_TYPE_HDMI
140+
prompt "Select HDMI resolution"
141+
default BSP_LCD_HDMI_1280x720_60HZ
142+
help
143+
Select the HDMI resolution.
144+
145+
config BSP_LCD_HDMI_800x600_60HZ
146+
bool "800x600@60HZ"
147+
config BSP_LCD_HDMI_1024x768_60HZ
148+
bool "1024x768@60HZ"
149+
config BSP_LCD_HDMI_1280x720_60HZ
150+
bool "1280x720@60HZ"
151+
config BSP_LCD_HDMI_1280x800_60HZ
152+
bool "1280x800@60HZ"
153+
config BSP_LCD_HDMI_1920x1080_30HZ
154+
bool "1920x1080@30HZ"
155+
config BSP_LCD_HDMI_1920x1080_60HZ
156+
bool "1920x1080@60HZ"
157+
endchoice
135158

136159
endmenu
137160

bsp/esp32_p4_function_ev_board/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@ ESP32-P4 Function EV Board is internal Espressif board for testing features on E
1515
Configuration in `menuconfig`.
1616

1717
Selection LCD display `Board Support Package(ESP32-P4) --> Display --> Select LCD type`
18-
- LCD 7-inch 1280x800 - ili9881c (default)
18+
- LCD 1280x800 - ili9881c (default)
1919
- LCD 1024x600 - ek79007
20+
- HDMI - lt8912b
21+
- 800x600@60HZ
22+
- 1024x768@60HZ
23+
- 1280x720@60HZ
24+
- 1280x800@60HZ
25+
- 1920x1080@30HZ
26+
- 1920x1080@60HZ
2027

2128
Selection color format `Board Support Package(ESP32-P4) --> Display --> Select LCD color format`
2229
- RGB565 (default)
2330
- RGB888
2431

32+
## HDMI Support
33+
34+
This BSP supports HDMI converter Lontium LT8912B. Follow these rules for using it with HDMI:
35+
- Use ESP-IDF 5.4 or older (from commit [93fdbf2](https://github.com/espressif/esp-idf/commit/93fdbf25b3ea7e44d1f519ed61050847dcc8a076))
36+
- Only RGB888 is supported with HDMI
37+
- Use MIPI-DSI to HDMI converter from this link ([Schematic](), [PCB]())
2538

2639
<!-- Autogenerated start: Dependencies -->
2740
### Capabilities and dependencies

bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c

Lines changed: 104 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
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
402404
esp_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
508600
esp_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)
542635
static 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
604698
static 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

619714
lv_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

bsp/esp32_p4_function_ev_board/idf_component.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "4.1.1"
1+
version: "4.2.0"
22
description: Board Support Package (BSP) for ESP32-P4 Function EV Board (preview)
33
url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_p4_function_ev_board
44

@@ -23,3 +23,7 @@ dependencies:
2323
esp_codec_dev:
2424
version: "1.2.*"
2525
public: true
26+
27+
espressif/esp_lcd_lt8912b:
28+
version: ">=0.1.0,<1.0.0"
29+
override_path: "../../components/lcd/esp_lcd_lt8912b"

bsp/esp32_p4_function_ev_board/include/bsp/display.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,34 @@
4747
#define BSP_LCD_MIPI_DSI_LCD_VSYNC (635)
4848
#define BSP_LCD_MIPI_DSI_LCD_VBP (23)
4949
#define BSP_LCD_MIPI_DSI_LCD_VFP (12)
50+
51+
#elif CONFIG_BSP_LCD_TYPE_HDMI
52+
#if CONFIG_BSP_LCD_HDMI_800x600_60HZ
53+
/* LCD display definition 800x600 */
54+
#define BSP_LCD_H_RES (800)
55+
#define BSP_LCD_V_RES (600)
56+
#elif CONFIG_BSP_LCD_HDMI_1024x768_60HZ
57+
/* LCD display definition 1024x768 */
58+
#define BSP_LCD_H_RES (1024)
59+
#define BSP_LCD_V_RES (768)
60+
#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ
61+
/* LCD display definition 1280x720 */
62+
#define BSP_LCD_H_RES (1280)
63+
#define BSP_LCD_V_RES (720)
64+
#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ
65+
/* LCD display definition 1280x800 */
66+
#define BSP_LCD_H_RES (1280)
67+
#define BSP_LCD_V_RES (800)
68+
#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ
69+
/* LCD display definition 1920x1080 */
70+
#define BSP_LCD_H_RES (1920)
71+
#define BSP_LCD_V_RES (1080)
72+
#else
73+
/* LCD display definition 1920x1080 */
74+
#define BSP_LCD_H_RES (1920)
75+
#define BSP_LCD_V_RES (1080)
76+
#endif
77+
5078
#else
5179
/* LCD display definition 1280x800 */
5280
#define BSP_LCD_H_RES (800)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
idf_component_register(SRCS "esp_lcd_lt8912b.c"
2+
INCLUDE_DIRS "include"
3+
REQUIRES "esp_lcd"
4+
PRIV_REQUIRES "esp_driver_gpio")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ESP LCD LT8912B
2+
3+
[![Component Registry](https://components.espressif.com/components/espressif/esp_lcd_ili9881c/badge.svg)](https://components.espressif.com/components/espressif/esp_lcd_lt8912b)
4+
5+
Implementation of the LT8912B LCD controller with esp_lcd component.
6+
7+
| LCD controller | Communication interface | Component name | Link to datasheet |
8+
| :------------: | :---------------------: | :------------: | :---------------: |
9+
| LT8912B | I2C | esp_lcd_lt8912b | [Specification](http://www.lontiumsemi.com/UploadFiles/2022-03/LT8912B_Brief_R1.3.pdf) |
10+
11+
> [!WARNING]
12+
> This controller suports only RGB888 color mode.
13+
14+
## Add to project
15+
16+
Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/).
17+
You can add them to your project via `idf.py add-dependency`, e.g.
18+
19+
```text
20+
idf.py add-dependency esp_lcd_lt8912b
21+
```
22+
23+
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
24+

0 commit comments

Comments
 (0)