| 1 |
.. _esp_ppa: |
| 2 |
|
| 3 |
========================================== |
| 4 |
PPA (Pixel Processing Accelerator) Support |
| 5 |
========================================== |
| 6 |
|
| 7 |
Overview |
| 8 |
******** |
| 9 |
|
| 10 |
Some ESP32 chip series, like the ESP32-P4 support the Pixel Processing Accelerator hardware (PPA), which is capable of |
| 11 |
speeding-up the filling and image blending operations, this peripheral works with the |
| 12 |
DMA-2D hardware which is responsible to move the input/output buffers into/from the PPA processing engine. |
| 13 |
|
| 14 |
Supported devices |
| 15 |
----------------- |
| 16 |
|
| 17 |
The Espressif targets that support the PPA are: |
| 18 |
|
| 19 |
- ESP32-P4 series. |
| 20 |
|
| 21 |
|
| 22 |
Using the LVGL PPA draw unit on your ESP-IDF project |
| 23 |
**************************************************** |
| 24 |
|
| 25 |
LVGL supports, in experimental level, the filling and the image blending |
| 26 |
acceleration through the PPA, the user can enable it in their ``sdkconfig.defaults`` by |
| 27 |
adding the following option to enable the PPA draw unit in conjunction with the software renderer, also: |
| 28 |
don't forget to make the draw buffers aligned with the cache line size, typically 64bytes: |
| 29 |
|
| 30 |
.. code:: c |
| 31 |
|
| 32 |
CONFIG_LV_USE_PPA=y |
| 33 |
CONFIG_LV_DRAW_BUF_ALIGN=64 |
| 34 |
|
| 35 |
Save the file and then rebuild the project, this will be sufficient to add the PPA code and it will start to run automatically, so |
| 36 |
no further steps are required from the user code perspective. |
| 37 |
|
| 38 |
Is it suggested to use PPA with the double buffer support of the ESP LVGL Port since it will not offer performance increase when using it in partial mode due |
| 39 |
to DMA2D memory bandwith. To have te best performance and experience you can use the following snippet code to start the LVGL subsystem |
| 40 |
for ESP-IDF: |
| 41 |
|
| 42 |
.. code:: c |
| 43 |
|
| 44 |
#include "lvgl.h" |
| 45 |
#include "bsp/esp-bsp.h" |
| 46 |
|
| 47 |
void app_main(void) |
| 48 |
{ |
| 49 |
bsp_display_cfg_t cfg = { |
| 50 |
.lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(), |
| 51 |
|
| 52 |
/* Use buffers with the same size of the screen in pixels */ |
| 53 |
.buffer_size = BSP_LCD_H_RES * BSP_LCD_V_RES, |
| 54 |
/* Use double buffer (possible with SPIRAM) */ |
| 55 |
.double_buffer = 1, |
| 56 |
.hw_cfg = { |
| 57 |
#if CONFIG_BSP_LCD_TYPE_HDMI |
| 58 |
#if CONFIG_BSP_LCD_HDMI_800x600_60HZ |
| 59 |
.hdmi_resolution = BSP_HDMI_RES_800x600, |
| 60 |
#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ |
| 61 |
.hdmi_resolution = BSP_HDMI_RES_1280x720, |
| 62 |
#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ |
| 63 |
.hdmi_resolution = BSP_HDMI_RES_1280x800, |
| 64 |
#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ |
| 65 |
.hdmi_resolution = BSP_HDMI_RES_1920x1080, |
| 66 |
#endif |
| 67 |
#else |
| 68 |
.hdmi_resolution = BSP_HDMI_RES_NONE, |
| 69 |
#endif |
| 70 |
.dsi_bus = { |
| 71 |
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, |
| 72 |
.lane_bit_rate_mbps = BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS, |
| 73 |
} |
| 74 |
}, |
| 75 |
.flags = { |
| 76 |
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 |
| 77 |
.buff_dma = false, |
| 78 |
#else |
| 79 |
.buff_dma = true, |
| 80 |
#endif |
| 81 |
/* Use SPIRAM when available */ |
| 82 |
.buff_spiram = true, |
| 83 |
.sw_rotate = true, |
| 84 |
} |
| 85 |
}; |
| 86 |
|
| 87 |
bsp_display_start_with_config(&cfg); |
| 88 |
bsp_display_backlight_on(); |
| 89 |
bsp_display_lock(0); |
| 90 |
lv_demo_widgets(); |
| 91 |
bsp_display_unlock(); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
Benchmarking |
| 96 |
------------ |
| 97 |
|
| 98 |
When running the `lv_demo_benchmark` from LVGL the user can compare the performance when |
| 99 |
the PPA is enabled versus the pure software rendering, by using the latest version of the |
| 100 |
LVGL and LVGL port component it can be observed an average saving of 30% of the rendering |
| 101 |
time for draw tasks that are image and rectangle fill. On some cases for pure filling on |
| 102 |
integer multiples of the display size it is possible to observe up 9x of speed increase when |
| 103 |
the PPA is enabled. |
| 104 |
|
| 105 |
Limitations |
| 106 |
----------- |
| 107 |
|
| 108 |
Please notice that the PPA is at experimental level where some performance gains are expected on drawing tasks related |
| 109 |
to rectangle copy or filling, while for image blending, even though it is operational, there are no significant gains, |
| 110 |
the initial cause for that according to the PPA section from reference manual is due to the DMA-2D memory bandwidth. |
| 111 |
|
| 112 |
|
| 113 |
Using the Espressif LVGL component PPA features |
| 114 |
*********************************************** |
| 115 |
|
| 116 |
The Espressif IDF LVGL port component also offers hardware acceleration |
| 117 |
for the display operations, that is it, once the LVGL render completes |
| 118 |
an operation and the draw buffer is already handled to the display driver, |
| 119 |
the Espressif component can optionally perform mirror and rotation of |
| 120 |
the rendered data using hardware assistance. |
| 121 |
|
| 122 |
The LVGL display driver for Espressif operates by reading the |
| 123 |
descriptor of the drawn data to check if rotation and mirror are flags |
| 124 |
set on the data properties, in positive case, before sending the data |
| 125 |
to the display, the mirror and rotation are performed first using the |
| 126 |
PPA rotation and mirror client. |
| 127 |
|
| 128 |
When compared to pure software rotation, using the PPA to rotate the objects |
| 129 |
can save up 40% of rendering time in average, while keeping the CPU in idle |
| 130 |
saving power, or using it to perform other tasks, PPA rotation is asynchronous, |
| 131 |
and once started it will signal the application using its dedicated interrupt. |
| 132 |
|
| 133 |
To enable such behavior on the display driver, the PPA acceleration should |
| 134 |
be set on the project `sdkconfig.defaults` via the symbol `CONFIG_LVGL_PORT_ENABLE_PPA`, |
| 135 |
setting it to true will make the hardware assistance for image rotation and mirroring |
| 136 |
automatic. No extra code is required. |
| 137 |
|
| 138 |
Please notice that such option can be set via menuconfig using the |
| 139 |
standard IDF command for configuration: `idf.py menuconfig`. |
| 140 |
|
| 141 |
API |
| 142 |
*** |
| 143 |
|
| 144 |
.. API startswith: lv_draw_ppa_ |