From e047a35949fd34ce701a7839be8a8b7371666d5e Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Fri, 11 Sep 2026 17:03:29 +0800 Subject: [PATCH] fix(rgb_lcd): resync bounce buffer index when restarting DMA Closes https://github.com/espressif/esp-idf/issues/19070 --- components/esp_lcd/rgb/esp_lcd_panel_rgb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_lcd/rgb/esp_lcd_panel_rgb.c b/components/esp_lcd/rgb/esp_lcd_panel_rgb.c index a46ca2a29e0..8791af84c36 100644 --- a/components/esp_lcd/rgb/esp_lcd_panel_rgb.c +++ b/components/esp_lcd/rgb/esp_lcd_panel_rgb.c @@ -1043,10 +1043,10 @@ static IRAM_ATTR void lcd_rgb_panel_try_restart_transmission(esp_rgb_panel_t *pa { int bb_size_px = panel->bb_size / (panel->fb_bits_per_pixel / 8); bool do_restart = false; + portENTER_CRITICAL_ISR(&panel->spinlock); #if CONFIG_LCD_RGB_RESTART_IN_VSYNC do_restart = true; #else - portENTER_CRITICAL_ISR(&panel->spinlock); if (panel->flags.need_restart) { panel->flags.need_restart = false; do_restart = true; @@ -1054,9 +1054,10 @@ static IRAM_ATTR void lcd_rgb_panel_try_restart_transmission(esp_rgb_panel_t *pa if (panel->bb_eof_count < panel->expect_eof_count) { do_restart = true; } +#endif // CONFIG_LCD_RGB_RESTART_IN_VSYNC + // DMA restart always relaunches from bounce buffer 0. Keep the software index in sync panel->bb_eof_count = 0; portEXIT_CRITICAL_ISR(&panel->spinlock); -#endif // CONFIG_LCD_RGB_RESTART_IN_VSYNC if (!do_restart) { return; @@ -1106,6 +1107,7 @@ static void lcd_rgb_panel_start_transmission(esp_rgb_panel_t *rgb_panel) // pre-fill bounce buffers if needed if (rgb_panel->bb_size) { rgb_panel->bounce_pos_px = 0; + rgb_panel->bb_eof_count = 0; lcd_rgb_panel_fill_bounce_buffer(rgb_panel, rgb_panel->bounce_buffer[0]); lcd_rgb_panel_fill_bounce_buffer(rgb_panel, rgb_panel->bounce_buffer[1]); }