Skip to content

Commit 0fa1204

Browse files
committed
fix(lcd): use new mipi dma2d api
1 parent fc8bd32 commit 0fa1204

File tree

10 files changed

+75
-11
lines changed

10 files changed

+75
-11
lines changed

bsp/esp32_p4_function_ev_board/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ menu "Board Support Package (ESP32-P4)"
121121
bool "RGB888"
122122
endchoice
123123

124+
config BSP_LCD_USE_DMA2D
125+
bool "Select whether to use DMA2D"
126+
default "y"
127+
help
128+
Select whether to use DMA2D to draw the bitmap.
129+
124130
choice BSP_LCD_TYPE
125131
prompt "Select LCD type"
126132
default BSP_LCD_TYPE_1024_600

bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
606606
#endif
607607
dpi_config.num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS;
608608

609+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
610+
dpi_config.use_dma2d = true;
611+
#endif
612+
609613
ek79007_vendor_config_t vendor_config = {
610614
.mipi_config = {
611615
.dsi_bus = mipi_dsi_bus,
@@ -619,6 +623,11 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
619623
.vendor_config = &vendor_config,
620624
};
621625
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ek79007(io, &lcd_dev_config, &disp_panel), err, TAG, "New LCD panel EK79007 failed");
626+
627+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
628+
ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_enable_dma2d(disp_panel), err, TAG, "LCD panel enable DMA2D failed");
629+
#endif
630+
622631
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(disp_panel), err, TAG, "LCD panel reset failed");
623632
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "LCD panel init failed");
624633
#elif CONFIG_BSP_LCD_TYPE_1280_800
@@ -631,6 +640,10 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
631640
#endif
632641
dpi_config.num_fbs = CONFIG_BSP_LCD_DPI_BUFFER_NUMS;
633642

643+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
644+
dpi_config.use_dma2d = true;
645+
#endif
646+
634647
ili9881c_vendor_config_t vendor_config = {
635648
.mipi_config = {
636649
.dsi_bus = mipi_dsi_bus,
@@ -645,6 +658,11 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
645658
.vendor_config = &vendor_config,
646659
};
647660
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ili9881c(io, &lcd_dev_config, &disp_panel), err, TAG, "New LCD panel ILI9881C failed");
661+
662+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
663+
ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_enable_dma2d(disp_panel), err, TAG, "LCD panel enable DMA2D failed");
664+
#endif
665+
648666
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(disp_panel), err, TAG, "LCD panel reset failed");
649667
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "LCD panel init failed");
650668
ESP_GOTO_ON_ERROR(esp_lcd_panel_disp_on_off(disp_panel, true), err, TAG, "LCD panel ON failed");
@@ -679,6 +697,12 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
679697
LT8912B_1920x1080_PANEL_30HZ_DPI_CONFIG_WITH_FBS(CONFIG_BSP_LCD_DPI_BUFFER_NUMS)
680698
};
681699

700+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
701+
for (int i = 0; i < sizeof(dpi_configs) / sizeof(dpi_configs[0]); i++) {
702+
dpi_configs[i].use_dma2d = true;
703+
}
704+
#endif
705+
682706
const esp_lcd_panel_lt8912b_video_timing_t video_timings[] = {
683707
ESP_LCD_LT8912B_VIDEO_TIMING_800x600_60Hz(),
684708
ESP_LCD_LT8912B_VIDEO_TIMING_1024x768_60Hz(),
@@ -736,6 +760,11 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
736760
.avi = io_avi,
737761
};
738762
ESP_ERROR_CHECK(esp_lcd_new_panel_lt8912b(&io_all, &panel_config, &disp_panel));
763+
764+
#if CONFIG_BSP_LCD_USE_DMA2D && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
765+
ESP_GOTO_ON_ERROR(esp_lcd_dpi_panel_enable_dma2d(disp_panel), err, TAG, "LCD panel enable DMA2D failed");
766+
#endif
767+
739768
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(disp_panel), err, TAG, "LCD panel reset failed");
740769
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "LCD panel init failed");
741770

bsp/esp32_p4_function_ev_board/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "5.1.2"
1+
version: "5.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

components/lcd/esp_lcd_ili9881c/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.3"
1+
version: "1.1.0"
22
targets:
33
- esp32p4
44
description: ESP LCD ILI9881C (MIPI DSI)

components/lcd/esp_lcd_ili9881c/include/esp_lcd_ili9881c.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <stdint.h>
1414
#include "soc/soc_caps.h"
15+
#include "esp_idf_version.h"
1516

1617
#if SOC_MIPI_DSI_SUPPORTED
1718
#include "esp_lcd_panel_vendor.h"
@@ -90,6 +91,7 @@ esp_err_t esp_lcd_new_panel_ili9881c(const esp_lcd_panel_io_handle_t io, const e
9091
.lcd_param_bits = 8, \
9192
}
9293

94+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
9395
/**
9496
* @brief MIPI DPI configuration structure
9597
*
@@ -118,6 +120,7 @@ esp_err_t esp_lcd_new_panel_ili9881c(const esp_lcd_panel_io_handle_t io, const e
118120
}, \
119121
.flags.use_dma2d = true, \
120122
}
123+
#endif
121124

122125
/**
123126
* @brief MIPI DPI configuration structure
@@ -145,7 +148,6 @@ esp_err_t esp_lcd_new_panel_ili9881c(const esp_lcd_panel_io_handle_t io, const e
145148
.vsync_pulse_width = 4, \
146149
.vsync_front_porch = 16, \
147150
}, \
148-
.flags.use_dma2d = true, \
149151
}
150152
#endif
151153

components/lcd/esp_lcd_lt8912b/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "0.1.3"
1+
version: "0.2.0"
22
description: ESP LCD LT8912B (MIPI DSI - HDMI)
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_lt8912b
44
repository: "https://github.com/espressif/esp-bsp.git"

components/lcd/esp_lcd_lt8912b/include/esp_lcd_lt8912b.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
170170
.vsync_pulse_width = 4, \
171171
.vsync_front_porch = 1, \
172172
}, \
173-
.flags.use_dma2d = true, \
174173
.flags.disable_lp = true, \
175174
}
176175

@@ -215,7 +214,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
215214
.vsync_pulse_width = 4, \
216215
.vsync_front_porch = 3, \
217216
}, \
218-
.flags.use_dma2d = true, \
219217
.flags.disable_lp = true, \
220218
}
221219

@@ -260,7 +258,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
260258
.vsync_pulse_width = 5, \
261259
.vsync_front_porch = 3, \
262260
}, \
263-
.flags.use_dma2d = true, \
264261
.flags.disable_lp = true, \
265262
}
266263

@@ -305,7 +302,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
305302
.vsync_pulse_width = 6, \
306303
.vsync_front_porch = 3, \
307304
}, \
308-
.flags.use_dma2d = true, \
309305
.flags.disable_lp = true, \
310306
}
311307

@@ -350,7 +346,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
350346
.vsync_pulse_width = 5, \
351347
.vsync_front_porch = 3, \
352348
}, \
353-
.flags.use_dma2d = true, \
354349
.flags.disable_lp = true, \
355350
}
356351

@@ -398,7 +393,6 @@ bool esp_lcd_panel_lt8912b_is_ready(esp_lcd_panel_t *panel);
398393
.vsync_pulse_width = 5, \
399394
.vsync_front_porch = 3, \
400395
}, \
401-
.flags.use_dma2d = true, \
402396
.flags.disable_lp = true, \
403397
}
404398

components/lcd/esp_lcd_st7796/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.3.6"
1+
version: "1.4.0"
22
targets:
33
- esp32
44
- esp32s2

components/lcd/esp_lcd_st7796/include/esp_lcd_st7796.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp
186186
.lcd_param_bits = 8, \
187187
}
188188

189+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
189190
/**
190191
* @brief MIPI DPI configuration structure
191192
*
@@ -214,6 +215,35 @@ esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp
214215
}, \
215216
.flags.use_dma2d = true, \
216217
}
218+
#endif
219+
220+
/**
221+
* @brief MIPI DPI configuration structure
222+
*
223+
* @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch)
224+
* / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch)
225+
*
226+
* @param[in] color_format Input color format of the panel
227+
*
228+
*/
229+
#define ST7796_320_480_PANEL_60HZ_DPI_CONFIG_CF(color_format) \
230+
{ \
231+
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \
232+
.dpi_clock_freq_mhz = 10, \
233+
.virtual_channel = 0, \
234+
.in_color_format = color_format, \
235+
.num_fbs = 1, \
236+
.video_timing = { \
237+
.h_size = 320, \
238+
.v_size = 480, \
239+
.hsync_back_porch = 10, \
240+
.hsync_pulse_width = 10, \
241+
.hsync_front_porch = 20, \
242+
.vsync_back_porch = 10, \
243+
.vsync_pulse_width = 10, \
244+
.vsync_front_porch = 10, \
245+
}, \
246+
}
217247

218248
#ifdef __cplusplus
219249
}

components/lcd/esp_lcd_st7796/test_apps/main/test_esp_lcd_st7796_mipi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ static void test_init_lcd(void)
108108
.vendor_config = &vendor_config,
109109
};
110110
TEST_ESP_OK(esp_lcd_new_panel_st7796(mipi_dbi_io, &panel_config, &panel_handle));
111+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
112+
TEST_ESP_OK(esp_lcd_dpi_panel_enable_dma2d(panel_handle));
113+
#endif
111114
TEST_ESP_OK(esp_lcd_panel_reset(panel_handle));
112115
TEST_ESP_OK(esp_lcd_panel_init(panel_handle));
113116
TEST_ESP_OK(esp_lcd_panel_disp_on_off(panel_handle, true));

0 commit comments

Comments
 (0)