feat(esp_lvgl_port): Out-of-tree PPA and DMA2D LVGL draw units#806
feat(esp_lvgl_port): Out-of-tree PPA and DMA2D LVGL draw units#806uLipe wants to merge 13 commits into
Conversation
lv_disp_rotation_t was renamed to lv_display_rotation_t in LVGL 9, so the BSP rotate API failed to build against current LVGL headers.
… 5.5 esp_lcd_dpi_panel_event_callbacks_t still exposes on_refresh_done on IDF 5.5; on_frame_buf_complete belongs to the RGB panel API and broke P4 DSI builds when gated only by IDF version.
Host the Espressif PPA/DMA2D draw units in esp_lvgl_port for LVGL 9+, register them after lv_init(), and gate them with ESP_LVGL_PORT_* Kconfig so the full composer path does not wait on upstream LVGL merges.
…ions Replace LVGL section banners and include guards with the port layout (#pragma once, esp-bsp section headers, quoted IDF includes, extern "C" around declarations only) so the imported units match the rest of the tree.
Add an lvgl_public.h shim, include the mask rect descriptor definition, and widen set_pending_trans to uint16_t so the units compile with LVGL from the Component Registry (validated with 9.5.0).
Describe the ESP_LVGL_PORT_* menuconfig path, buffer alignment and stock LV_USE_PPA conflict, and record the docs/CI notes in CHANGELOG.
Add a ppa_dma2d sdkconfig.ci variant for test_apps/lvgl_port and restrict it to esp32p4 / IDF >= 5.4 so CI compiles the out-of-tree draw unit path.
Reject oversized tile-composer layers in evaluate, release tiles on composite early-exit, finalize active tasks during runtime retune, share cache handlers for DMA2D-only builds, and disable a half-initialized DMA2D unit instead of leaving it registered.
| #include "lv_draw_esp_dma2d_private.h" | ||
|
|
||
| #if LV_USE_ESP_DMA2D | ||
|
|
There was a problem hiding this comment.
FYI, maybe we can reuse the async color convert driver in the esp-idf? https://docs.espressif.com/projects/esp-idf/en/latest/esp32p4/api-reference/peripherals/async_color_convert.html The driver can be used to do either color conversion or 2D window copy.
There was a problem hiding this comment.
@suda-morris this would be great, is this feature also present on IDF5.5? When I made the DMA2D I was using what IDF oferred in terms of its driver.
There was a problem hiding this comment.
I can backport the feature to 5.5. Currently it's available on 6.x
There was a problem hiding this comment.
It would be great then the DMA2D draw can benefit from this driver
There was a problem hiding this comment.
sorry, it's not easy to backport the driver to v5.5 because there's no esp_color_fourcc_t definitions. Feel free to continue your original solution.
There was a problem hiding this comment.
Directly calling esp_private APIs from external components is not recommended because there's no assurance in compatibility. Can we apply this PPA and DMA2D enhancement for IDF v6.x only? @uLipe
Drain leftover binary-semaphore tokens when the last ISR completes before pending_ops is sampled, and stop calling vSemaphoreDelete on the statically allocated done_sem.
Write back the decoded source buffer before DMA2D reads it, and fall back to lv_draw_sw_image when enqueue/transfer fails so preferred-unit tasks are not left blank.
Preferred-unit tasks already mark FINISHED on return; empty tile pool or a failed pass left blank holes. Recover with lv_draw_sw_layer instead.
Copy the child layer draw_buf header before DMA2D image blit, and redraw with software when PPA blend/SRM enqueue fails on a claimed task.
Call dma2d_force_end when the completion wait times out so an in-flight transfer cannot overwrite the destination after lv_draw_sw_image redraws it.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 22c9521. Configure here.
espzav
left a comment
There was a problem hiding this comment.
@uLipe Thank you very much for this PR. Only for clarification:
- Is this same like
CONFIG_LV_USE_PPA? Or these changes are for better performance? - What is the recommended settings? Is it safe to enable this recommended settings in P4 BSP - in examples
sdkconfig.bsp.esp32_p4_function_ev_board? - Please, Could you bump LVGL port version (+changelog) for release it after merge?
LGTM
| #else | ||
| /* IDF DPI API still exposes on_refresh_done (vsync). Do not use | ||
| * on_frame_buf_complete here — that name belongs to the RGB panel | ||
| * callbacks, not esp_lcd_dpi_panel_event_callbacks_t on IDF 5.5. */ |
There was a problem hiding this comment.
I see this warning in CI:
/__w/esp-bsp/esp-bsp/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:162:13: warning: 'on_refresh_done' is deprecated: Deprecated, use on_frame_buf_complete instead [-Wdeprecated-declarations]
162 | cbs.on_refresh_done = lvgl_port_flush_dpi_vsync_ready_callback;
| ^~~
In file included from /__w/esp-bsp/esp-bsp/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:33:
/opt/esp/idf/components/esp_lcd/dsi/include/esp_lcd_mipi_dsi.h:205:45: note: declared here
205 | esp_lcd_dpi_panel_refresh_done_cb_t on_refresh_done __attribute__((deprecated("Deprecated, use on_frame_buf_complete instead"))); /*!< Deprecated, use on_frame_buf_complete instead */
| ^~~~~~~~~~~~~~~

Summary
esp_lvgl_port(LVGL 9+, ESP32-P4), registered afterlv_init()viaCONFIG_ESP_LVGL_PORT_*(keep stockCONFIG_LV_USE_PPAunset).test_apps/lvgl_port/ppa_dma2d) so the draw-unit path is compiled in CI.Test plan
components/esp_lvgl_port/test_apps/lvgl_portforesp32p4withsdkconfig.ci.ppa_dma2d(LVGL 9.5.0 from Component Registry)Board output log:
Note
Medium Risk
Large new rendering path touches cache coherency, async PPA completion, and hardware fallbacks; misconfiguration (e.g. duplicate
CONFIG_LV_USE_PPA) is caught at build time but runtime draw bugs could still affect UI correctness on P4.Overview
Adds out-of-tree LVGL 9 hardware draw units for ESP32-P4: optional PPA (fills, blends, images/layers, borders, gradients, tile composer, async, stats/tuning) and DMA2D (blit/convert), wired through new Kconfig (
CONFIG_ESP_LVGL_PORT_*), CMake (esp_lvgl_port_draw_units.cmake), and registration fromlvgl_portright afterlv_init().Robustness and integration: shared
esp_cachedraw-buffer handlers, SW fallbacks when PPA/DMA2D cannot handle or fails a task, DPI avoid-tearing keepson_refresh_doneon IDF 5.5 (not RGB’son_frame_buf_complete), P4 BSPbsp_display_rotateuseslv_display_rotation_t, plus README/CHANGELOG and CIsdkconfig.ci.ppa_dma2dfortest_apps/lvgl_port.Reviewed by Cursor Bugbot for commit 22c9521. Bugbot is set up for automated code reviews on this repo. Configure here.