PPA (Pixel Processing Accelerator) Support

The PPA of chips like the ESP32-P4 accelerates fill and image blending operations. LVGL has an experimental PPA draw unit, and the Espressif port can also rotate and mirror with it.

Edit on GitHub

Overview

Some ESP32 chip series, like the ESP32-P4, have a Pixel Processing Accelerator (PPA), which speeds up fill and image blending operations. This peripheral works together with the DMA2D hardware, which moves the input and output buffers into and from the PPA processing engine.

Supported devices

The Espressif targets that support the PPA are:

  • ESP32-P4 series.

Using the LVGL PPA draw unit on your ESP-IDF project

LVGL has experimental support for accelerating fills and image blending with the PPA. Enable the PPA draw unit, which runs in conjunction with the software renderer, by adding the following options to your sdkconfig.defaults. Don't forget to align the draw buffers to the cache line size, typically 64 bytes:

ini
CONFIG_LV_USE_PPA=y
CONFIG_LV_DRAW_BUF_ALIGN=64

Save the file and rebuild the project. That is all that is needed: the PPA code starts to run automatically, no further steps are required in the application code.

It is recommended to use the PPA with the double buffer support of the ESP LVGL port, since it offers no performance increase in partial mode due to DMA2D memory bandwidth. For the best performance, use the following snippet to start the LVGL subsystem for ESP-IDF:

 
#include "lvgl.h"
#include "bsp/esp-bsp.h"

void app_main(void)
{
    bsp_display_cfg_t cfg = {
        .lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(),

        /* Use buffers with the same size as the screen in pixels */
        .buffer_size = BSP_LCD_H_RES * BSP_LCD_V_RES,
        /* Use double buffer (possible with SPIRAM) */
        .double_buffer = 1,
        .hw_cfg = {
#if CONFIG_BSP_LCD_TYPE_HDMI
#if CONFIG_BSP_LCD_HDMI_800x600_60HZ
            .hdmi_resolution = BSP_HDMI_RES_800x600,
#elif CONFIG_BSP_LCD_HDMI_1280x720_60HZ
            .hdmi_resolution = BSP_HDMI_RES_1280x720,
#elif CONFIG_BSP_LCD_HDMI_1280x800_60HZ
            .hdmi_resolution = BSP_HDMI_RES_1280x800,
#elif CONFIG_BSP_LCD_HDMI_1920x1080_30HZ
            .hdmi_resolution = BSP_HDMI_RES_1920x1080,
#endif
#else
            .hdmi_resolution = BSP_HDMI_RES_NONE,
#endif
            .dsi_bus = {
                .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
                .lane_bit_rate_mbps = BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS,
            }
        },
        .flags = {
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
            .buff_dma = false,
#else
            .buff_dma = true,
#endif
            /* Use SPIRAM when available */
            .buff_spiram = true,
            .sw_rotate = true,
        }
    };

    bsp_display_start_with_config(&cfg);
    bsp_display_backlight_on();
    bsp_display_lock(0);
    lv_demo_widgets();
    bsp_display_unlock();
}

Benchmarking

When running the lv_demo_benchmark from LVGL the user can compare the performance when the PPA is enabled versus the pure software rendering, by using the latest version of the LVGL and LVGL port component, an average saving of 30% of the rendering time can be observed for image and rectangle fill draw tasks. In some cases, for pure fills on integer multiples of the display size, up to 9x speed increase is possible when the PPA is enabled.

Limitations

The PPA support is experimental. Performance gains are expected on drawing tasks related to rectangle copy or filling. Image blending is operational but shows no significant gain; according to the PPA section of the reference manual, this is caused by the DMA2D memory bandwidth.

Using the Espressif LVGL component PPA features

The Espressif IDF LVGL port component also offers hardware acceleration for the display operations: once LVGL has finished rendering and the draw buffer has been handed to the display driver, the Espressif component can optionally mirror and rotate the rendered data with hardware assistance.

The LVGL display driver for Espressif reads the descriptor of the drawn data to check whether the rotation and mirror flags are set on the data properties. If they are, the mirroring and rotation are performed with the PPA rotation and mirror client before the data is sent to the display.

Compared to pure software rotation, using the PPA to rotate saves up to 40% of the rendering time on average, while the CPU stays idle to save power or to perform other tasks. PPA rotation is asynchronous: once started, it signals the application through its dedicated interrupt.

To enable this behavior on the display driver, set CONFIG_LVGL_PORT_ENABLE_PPA in the project's sdkconfig.defaults. Setting it to true makes the hardware assistance for image rotation and mirroring automatic. No extra code is required.

The option can also be set via idf.py menuconfig.

Last updated on

On this page