Skip to content

Commit 1e8fbc5

Browse files
committed
feat: update
1 parent 2a7c253 commit 1e8fbc5

File tree

18 files changed

+690
-162
lines changed

18 files changed

+690
-162
lines changed

examples/LVGL/v8/Porting/lvgl_port_v8.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static void *get_next_frame_buffer(ESP_PanelLcd *lcd)
2121
static void *fbs[2] = { NULL };
2222

2323
if (next_fb == NULL) {
24-
fbs[0] = lcd->getRgbBufferByIndex(0);
25-
fbs[1] = lcd->getRgbBufferByIndex(1);
24+
fbs[0] = lcd->getFrameBufferByIndex(0);
25+
fbs[1] = lcd->getFrameBufferByIndex(1);
2626
next_fb = fbs[1];
2727
} else {
2828
next_fb = (next_fb == fbs[0]) ? fbs[1] : fbs[0];
@@ -460,20 +460,20 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd)
460460

461461
// With the usage of three buffers and full-refresh, we always have one buffer available for rendering,
462462
// eliminating the need to wait for the RGB's sync signal
463-
lvgl_port_rgb_last_buf = lcd->getRgbBufferByIndex(0);
464-
buf[0] = lcd->getRgbBufferByIndex(1);
465-
buf[1] = lcd->getRgbBufferByIndex(2);
463+
lvgl_port_rgb_last_buf = lcd->getFrameBufferByIndex(0);
464+
buf[0] = lcd->getFrameBufferByIndex(1);
465+
buf[1] = lcd->getFrameBufferByIndex(2);
466466
lvgl_port_rgb_next_buf = lvgl_port_rgb_last_buf;
467467
lvgl_port_flush_next_buf = buf[1];
468468

469469
#elif (LVGL_PORT_DISP_BUFFER_NUM >= 3) && (LVGL_PORT_ROTATION_DEGREE != 0)
470470

471-
buf[0] = lcd->getRgbBufferByIndex(2);
471+
buf[0] = lcd->getFrameBufferByIndex(2);
472472

473473
#elif LVGL_PORT_DISP_BUFFER_NUM >= 2
474474

475475
for (int i = 0; (i < LVGL_PORT_DISP_BUFFER_NUM) && (i < LVGL_PORT_BUFFER_NUM_MAX); i++) {
476-
buf[i] = lcd->getRgbBufferByIndex(i);
476+
buf[i] = lcd->getFrameBufferByIndex(i);
477477
}
478478

479479
#endif

examples/LVGL/v8/Rotation/lvgl_port_v8.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static void *get_next_frame_buffer(ESP_PanelLcd *lcd)
2121
static void *fbs[2] = { NULL };
2222

2323
if (next_fb == NULL) {
24-
fbs[0] = lcd->getRgbBufferByIndex(0);
25-
fbs[1] = lcd->getRgbBufferByIndex(1);
24+
fbs[0] = lcd->getFrameBufferByIndex(0);
25+
fbs[1] = lcd->getFrameBufferByIndex(1);
2626
next_fb = fbs[1];
2727
} else {
2828
next_fb = (next_fb == fbs[0]) ? fbs[1] : fbs[0];
@@ -460,20 +460,20 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd)
460460

461461
// With the usage of three buffers and full-refresh, we always have one buffer available for rendering,
462462
// eliminating the need to wait for the RGB's sync signal
463-
lvgl_port_rgb_last_buf = lcd->getRgbBufferByIndex(0);
464-
buf[0] = lcd->getRgbBufferByIndex(1);
465-
buf[1] = lcd->getRgbBufferByIndex(2);
463+
lvgl_port_rgb_last_buf = lcd->getFrameBufferByIndex(0);
464+
buf[0] = lcd->getFrameBufferByIndex(1);
465+
buf[1] = lcd->getFrameBufferByIndex(2);
466466
lvgl_port_rgb_next_buf = lvgl_port_rgb_last_buf;
467467
lvgl_port_flush_next_buf = buf[1];
468468

469469
#elif (LVGL_PORT_DISP_BUFFER_NUM >= 3) && (LVGL_PORT_ROTATION_DEGREE != 0)
470470

471-
buf[0] = lcd->getRgbBufferByIndex(2);
471+
buf[0] = lcd->getFrameBufferByIndex(2);
472472

473473
#elif LVGL_PORT_DISP_BUFFER_NUM >= 2
474474

475475
for (int i = 0; (i < LVGL_PORT_DISP_BUFFER_NUM) && (i < LVGL_PORT_BUFFER_NUM_MAX); i++) {
476-
buf[i] = lcd->getRgbBufferByIndex(i);
476+
buf[i] = lcd->getFrameBufferByIndex(i);
477477
}
478478

479479
#endif

examples/PlatformIO/src/lvgl_port_v8.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static void *get_next_frame_buffer(ESP_PanelLcd *lcd)
2121
static void *fbs[2] = { NULL };
2222

2323
if (next_fb == NULL) {
24-
fbs[0] = lcd->getRgbBufferByIndex(0);
25-
fbs[1] = lcd->getRgbBufferByIndex(1);
24+
fbs[0] = lcd->getFrameBufferByIndex(0);
25+
fbs[1] = lcd->getFrameBufferByIndex(1);
2626
next_fb = fbs[1];
2727
} else {
2828
next_fb = (next_fb == fbs[0]) ? fbs[1] : fbs[0];
@@ -460,20 +460,20 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd)
460460

461461
// With the usage of three buffers and full-refresh, we always have one buffer available for rendering,
462462
// eliminating the need to wait for the RGB's sync signal
463-
lvgl_port_rgb_last_buf = lcd->getRgbBufferByIndex(0);
464-
buf[0] = lcd->getRgbBufferByIndex(1);
465-
buf[1] = lcd->getRgbBufferByIndex(2);
463+
lvgl_port_rgb_last_buf = lcd->getFrameBufferByIndex(0);
464+
buf[0] = lcd->getFrameBufferByIndex(1);
465+
buf[1] = lcd->getFrameBufferByIndex(2);
466466
lvgl_port_rgb_next_buf = lvgl_port_rgb_last_buf;
467467
lvgl_port_flush_next_buf = buf[1];
468468

469469
#elif (LVGL_PORT_DISP_BUFFER_NUM >= 3) && (LVGL_PORT_ROTATION_DEGREE != 0)
470470

471-
buf[0] = lcd->getRgbBufferByIndex(2);
471+
buf[0] = lcd->getFrameBufferByIndex(2);
472472

473473
#elif LVGL_PORT_DISP_BUFFER_NUM >= 2
474474

475475
for (int i = 0; (i < LVGL_PORT_DISP_BUFFER_NUM) && (i < LVGL_PORT_BUFFER_NUM_MAX); i++) {
476-
buf[i] = lcd->getRgbBufferByIndex(i);
476+
buf[i] = lcd->getFrameBufferByIndex(i);
477477
}
478478

479479
#endif

examples/SquareLine/v8/Porting/lvgl_port_v8.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static void *get_next_frame_buffer(ESP_PanelLcd *lcd)
2121
static void *fbs[2] = { NULL };
2222

2323
if (next_fb == NULL) {
24-
fbs[0] = lcd->getRgbBufferByIndex(0);
25-
fbs[1] = lcd->getRgbBufferByIndex(1);
24+
fbs[0] = lcd->getFrameBufferByIndex(0);
25+
fbs[1] = lcd->getFrameBufferByIndex(1);
2626
next_fb = fbs[1];
2727
} else {
2828
next_fb = (next_fb == fbs[0]) ? fbs[1] : fbs[0];
@@ -460,20 +460,20 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd)
460460

461461
// With the usage of three buffers and full-refresh, we always have one buffer available for rendering,
462462
// eliminating the need to wait for the RGB's sync signal
463-
lvgl_port_rgb_last_buf = lcd->getRgbBufferByIndex(0);
464-
buf[0] = lcd->getRgbBufferByIndex(1);
465-
buf[1] = lcd->getRgbBufferByIndex(2);
463+
lvgl_port_rgb_last_buf = lcd->getFrameBufferByIndex(0);
464+
buf[0] = lcd->getFrameBufferByIndex(1);
465+
buf[1] = lcd->getFrameBufferByIndex(2);
466466
lvgl_port_rgb_next_buf = lvgl_port_rgb_last_buf;
467467
lvgl_port_flush_next_buf = buf[1];
468468

469469
#elif (LVGL_PORT_DISP_BUFFER_NUM >= 3) && (LVGL_PORT_ROTATION_DEGREE != 0)
470470

471-
buf[0] = lcd->getRgbBufferByIndex(2);
471+
buf[0] = lcd->getFrameBufferByIndex(2);
472472

473473
#elif LVGL_PORT_DISP_BUFFER_NUM >= 2
474474

475475
for (int i = 0; (i < LVGL_PORT_DISP_BUFFER_NUM) && (i < LVGL_PORT_BUFFER_NUM_MAX); i++) {
476-
buf[i] = lcd->getRgbBufferByIndex(i);
476+
buf[i] = lcd->getFrameBufferByIndex(i);
477477
}
478478

479479
#endif

examples/SquareLine/v8/WiFiClock/lvgl_port_v8.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static void *get_next_frame_buffer(ESP_PanelLcd *lcd)
2121
static void *fbs[2] = { NULL };
2222

2323
if (next_fb == NULL) {
24-
fbs[0] = lcd->getRgbBufferByIndex(0);
25-
fbs[1] = lcd->getRgbBufferByIndex(1);
24+
fbs[0] = lcd->getFrameBufferByIndex(0);
25+
fbs[1] = lcd->getFrameBufferByIndex(1);
2626
next_fb = fbs[1];
2727
} else {
2828
next_fb = (next_fb == fbs[0]) ? fbs[1] : fbs[0];
@@ -460,20 +460,20 @@ static lv_disp_t *display_init(ESP_PanelLcd *lcd)
460460

461461
// With the usage of three buffers and full-refresh, we always have one buffer available for rendering,
462462
// eliminating the need to wait for the RGB's sync signal
463-
lvgl_port_rgb_last_buf = lcd->getRgbBufferByIndex(0);
464-
buf[0] = lcd->getRgbBufferByIndex(1);
465-
buf[1] = lcd->getRgbBufferByIndex(2);
463+
lvgl_port_rgb_last_buf = lcd->getFrameBufferByIndex(0);
464+
buf[0] = lcd->getFrameBufferByIndex(1);
465+
buf[1] = lcd->getFrameBufferByIndex(2);
466466
lvgl_port_rgb_next_buf = lvgl_port_rgb_last_buf;
467467
lvgl_port_flush_next_buf = buf[1];
468468

469469
#elif (LVGL_PORT_DISP_BUFFER_NUM >= 3) && (LVGL_PORT_ROTATION_DEGREE != 0)
470470

471-
buf[0] = lcd->getRgbBufferByIndex(2);
471+
buf[0] = lcd->getFrameBufferByIndex(2);
472472

473473
#elif LVGL_PORT_DISP_BUFFER_NUM >= 2
474474

475475
for (int i = 0; (i < LVGL_PORT_DISP_BUFFER_NUM) && (i < LVGL_PORT_BUFFER_NUM_MAX); i++) {
476-
buf[i] = lcd->getRgbBufferByIndex(i);
476+
buf[i] = lcd->getFrameBufferByIndex(i);
477477
}
478478

479479
#endif

src/ESP_PanelTypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#define ESP_PANEL_BUS_TYPE_RGB (3)
2020
#define ESP_PANEL_BUS_TYPE_I2C (4)
2121
#define ESP_PANEL_BUS_TYPE_I80 (5)
22-
#define ESP_PANEL_BUS_TYPE_MAX (6)
22+
#define ESP_PANEL_BUS_TYPE_MIPI_DSI (6)
23+
#define ESP_PANEL_BUS_TYPE_MAX (7)
2324

2425
/**
2526
* @brief This macro is used to generate the I2C panel IO configuration according to the touch panel name.

src/ESP_Panel_Library.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
#include "bus/SPI.h"
2222
#include "bus/RGB.h"
2323
#include "bus/QSPI.h"
24+
#include "bus/DSI.h"
2425

2526
/* LCD */
2627
#include "lcd/ESP_PanelLcd.h"
28+
#include "lcd/EK79007.h"
2729
#include "lcd/EK9716B.h"
2830
#include "lcd/GC9503.h"
2931
#include "lcd/GC9A01.h"

src/bus/DSI.cpp

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "soc/soc_caps.h"
8+
9+
#if SOC_MIPI_DSI_SUPPORTED
10+
#include <stdlib.h>
11+
#include <string.h>
12+
#include "ESP_PanelLog.h"
13+
#include "DSI.h"
14+
15+
#define MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV (2500)
16+
17+
static const char *TAG = "ESP_PanelBus_DSI";
18+
19+
ESP_PanelBus_DSI::ESP_PanelBus_DSI(uint32_t lane_rate, uint8_t lane_num, int ldo_id):
20+
ESP_PanelBus(ESP_PANEL_HOST_DSI_ID_DEFAULT, ESP_PANEL_BUS_TYPE_MIPI_DSI, true),
21+
ldo_chan_id(ldo_id),
22+
ldo_handle(NULL),
23+
host_config((esp_lcd_dsi_bus_config_t)ESP_PANEL_HOST_DSI_CONFIG_DEFAULT(lane_num, lane_rate)),
24+
host_handle(NULL),
25+
io_config((esp_lcd_dbi_io_config_t)ESP_PANEL_IO_DBI_CONFIG_DEFAULT())
26+
{
27+
}
28+
29+
ESP_PanelBus_DSI::ESP_PanelBus_DSI(uint32_t lane_rate, uint8_t lane_num, const esp_lcd_dbi_io_config_t &io_config, int ldo_id):
30+
ESP_PanelBus(ESP_PANEL_HOST_DSI_ID_DEFAULT, ESP_PANEL_BUS_TYPE_MIPI_DSI, true),
31+
ldo_chan_id(ldo_id),
32+
ldo_handle(NULL),
33+
host_config((esp_lcd_dsi_bus_config_t)ESP_PANEL_HOST_DSI_CONFIG_DEFAULT(lane_num, lane_rate)),
34+
host_handle(NULL),
35+
io_config(io_config)
36+
{
37+
}
38+
39+
ESP_PanelBus_DSI::ESP_PanelBus_DSI(const esp_lcd_dsi_bus_config_t &host_config, const esp_lcd_dbi_io_config_t &io_config, int ldo_id):
40+
ESP_PanelBus(ESP_PANEL_HOST_DSI_ID_DEFAULT, ESP_PANEL_BUS_TYPE_MIPI_DSI, true),
41+
ldo_chan_id(ldo_id),
42+
ldo_handle(NULL),
43+
host_config(host_config),
44+
host_handle(NULL),
45+
io_config(io_config)
46+
{
47+
}
48+
49+
ESP_PanelBus_DSI::~ESP_PanelBus_DSI()
50+
{
51+
if (handle == NULL) {
52+
goto end;
53+
}
54+
55+
if (!del()) {
56+
ESP_LOGE(TAG, "Delete panel io failed");
57+
}
58+
59+
end:
60+
ESP_LOGD(TAG, "Destroyed");
61+
}
62+
63+
bool ESP_PanelBus_DSI::del(void)
64+
{
65+
ESP_PANEL_ENABLE_TAG_DEBUG_LOG();
66+
67+
ESP_PANEL_CHECK_FALSE_RET(ESP_PanelBus::del(), false, "Delete base panel failed");
68+
if (host_handle != NULL) {
69+
if (esp_lcd_del_dsi_bus(host_handle) != ESP_OK) {
70+
ESP_LOGE(TAG, "Delete host_handle[%d] driver failed", host_id);
71+
} else {
72+
ESP_LOGD(TAG, "Delete host_handle[%d] driver", host_id);
73+
}
74+
host_handle = NULL;
75+
}
76+
if (ldo_handle != NULL) {
77+
if (esp_ldo_release_channel(ldo_handle) != ESP_OK) {
78+
ESP_LOGE(TAG, "Release LDO channel[%d] failed", ldo_chan_id);
79+
} else {
80+
ESP_LOGD(TAG, "MIPI DSI PHY (LDO %d) Powered off", ldo_chan_id);
81+
}
82+
ldo_handle = NULL;
83+
}
84+
85+
return true;
86+
}
87+
88+
// void ESP_PanelBus_DSI::configSpiMode(uint8_t mode)
89+
// {
90+
// io_config.spi_mode = mode;
91+
// }
92+
93+
bool ESP_PanelBus_DSI::begin(void)
94+
{
95+
ESP_PANEL_ENABLE_TAG_DEBUG_LOG();
96+
97+
if (ldo_chan_id >= 0) {
98+
// Turn on the power for MIPI DSI PHY, so it can go from "No Power" state to "Shutdown" state
99+
esp_ldo_channel_config_t ldo_config = {
100+
.chan_id = ldo_chan_id,
101+
.voltage_mv = MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV,
102+
};
103+
ESP_PANEL_CHECK_ERR_RET(esp_ldo_acquire_channel(&ldo_config, &ldo_handle), false, "Acquire LDO channel failed");
104+
ESP_LOGD(TAG, "MIPI DSI PHY (LDO %d) Powered on", ldo_chan_id);
105+
}
106+
if (host_need_init) {
107+
ESP_PANEL_CHECK_ERR_RET(esp_lcd_new_dsi_bus(&host_config, &host_handle), false, "Initialize Host[%d] failed", host_id);
108+
ESP_LOGD(TAG, "Init MIPI DSI host_handle[%d]", host_id);
109+
}
110+
ESP_PANEL_CHECK_ERR_RET(esp_lcd_new_panel_io_dbi(host_handle, &io_config, &handle), false, "Create panel io failed");
111+
ESP_LOGD(TAG, "Create panel io @%p", handle);
112+
113+
return true;
114+
}
115+
#endif /* SOC_MIPI_DSI_SUPPORTED */

0 commit comments

Comments
 (0)