Skip to content

Commit 0e966ba

Browse files
committed
Merge branch 'feat/mipi_dsi_underrun_error_v5.4' into 'release/v5.4'
feat(mipi_dsi): enable underrun error interrupt (v5.4) See merge request espressif/esp-idf!34980
2 parents 9c2a5ac + 0960a60 commit 0e966ba

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

components/esp_lcd/dsi/esp_lcd_mipi_dsi_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static const char *TAG = "lcd.dsi.bus";
1616

1717
#define MIPI_DSI_DEFAULT_TIMEOUT_CLOCK_FREQ_MHZ 10
1818
// TxClkEsc frequency must be configured between 2 and 20 MHz
19-
#define MIPI_DSI_DEFAULT_ESCAPE_CLOCK_FREQ_MHZ 10
19+
#define MIPI_DSI_DEFAULT_ESCAPE_CLOCK_FREQ_MHZ 18
2020

2121
esp_err_t esp_lcd_new_dsi_bus(const esp_lcd_dsi_bus_config_t *bus_config, esp_lcd_dsi_bus_handle_t *ret_bus)
2222
{

components/esp_lcd/dsi/esp_lcd_panel_dpi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,20 @@ static bool dma_trans_done_cb(dw_gdma_channel_handle_t chan, const dw_gdma_trans
8080
{
8181
bool yield_needed = false;
8282
esp_lcd_dpi_panel_t *dpi_panel = (esp_lcd_dpi_panel_t *)user_data;
83+
mipi_dsi_hal_context_t *hal = &dpi_panel->bus->hal;
8384
uint8_t fb_index = dpi_panel->cur_fb_index;
8485
dw_gdma_link_list_handle_t link_list = dpi_panel->link_lists[fb_index];
8586

87+
// clear the interrupt status
88+
uint32_t error_status = mipi_dsi_brg_ll_get_interrupt_status(hal->bridge);
89+
mipi_dsi_brg_ll_clear_interrupt_status(hal->bridge, error_status);
90+
if (unlikely(error_status & MIPI_DSI_LL_EVENT_UNDERRUN)) {
91+
// when an underrun happens, the LCD display may already becomes blue
92+
// it's too late to recover the display, so we just print an error message
93+
// as a hint to the user that he should optimize the memory bandwidth (with AXI-ICM)
94+
ESP_DRAM_LOGE(TAG, "can't fetch data from external memory fast enough, underrun happens");
95+
}
96+
8697
// restart the DMA transfer, keep refreshing the LCD
8798
dw_gdma_block_markers_t markers = {
8899
.is_valid = true,
@@ -440,6 +451,10 @@ static esp_err_t dpi_panel_init(esp_lcd_panel_t *panel)
440451
mipi_dsi_brg_ll_enable_dpi_output(hal->bridge, true);
441452
mipi_dsi_brg_ll_update_dpi_config(hal->bridge);
442453

454+
// enable the underrun interrupt, we use this as a signal of bandwidth shortage
455+
// note, we opt to not install a dedicated interrupt handler just for this error condition, instead, we check it in the DMA callback
456+
mipi_dsi_brg_ll_enable_interrupt(hal->bridge, MIPI_DSI_LL_EVENT_UNDERRUN, true);
457+
443458
return ESP_OK;
444459
}
445460

components/hal/esp32p4/include/hal/mipi_dsi_host_ll.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static inline void mipi_dsi_host_ll_power_on_off(dsi_host_dev_t *dev, bool on)
8282
*/
8383
static inline void mipi_dsi_host_ll_set_timeout_clock_division(dsi_host_dev_t *dev, uint32_t div)
8484
{
85-
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->clkmgr_cfg, to_clk_division, div - 1);
85+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->clkmgr_cfg, to_clk_division, div);
8686
}
8787

8888
/**
@@ -95,7 +95,8 @@ static inline void mipi_dsi_host_ll_set_timeout_clock_division(dsi_host_dev_t *d
9595
*/
9696
static inline void mipi_dsi_host_ll_set_escape_clock_division(dsi_host_dev_t *dev, uint32_t div)
9797
{
98-
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->clkmgr_cfg, tx_esc_clk_division, div - 1);
98+
HAL_ASSERT(div > 1 && div < 256);
99+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->clkmgr_cfg, tx_esc_clk_division, div);
99100
}
100101

101102
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies:
2-
lvgl/lvgl: "9.2.0"
2+
lvgl/lvgl: "9.2.2"
33
esp_lcd_ili9881c: "^1.0.0"
44
esp_lcd_ek79007: "^1.0.0"

0 commit comments

Comments
 (0)