mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/esp_lcd_modify_bounce_buffer_index' into 'master'
RGB LCD: support multi frame buffer in bounce buffer mode See merge request espressif/esp-idf!21555
This commit is contained in:
commit
3d09cc32a1
@ -97,7 +97,8 @@ struct esp_rgb_panel_t {
|
||||
esp_pm_lock_handle_t pm_lock; // Power management lock
|
||||
size_t num_dma_nodes; // Number of DMA descriptors that used to carry the frame buffer
|
||||
uint8_t *fbs[RGB_LCD_PANEL_MAX_FB_NUM]; // Frame buffers
|
||||
uint8_t cur_fb_index; // Current frame buffer index (0 or 1)
|
||||
uint8_t cur_fb_index; // Current frame buffer index
|
||||
uint8_t bb_fb_index; // Current frame buffer index which used by bounce buffer
|
||||
size_t fb_size; // Size of frame buffer
|
||||
int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; // GPIOs used for data lines, we keep these GPIOs for action like "invert_color"
|
||||
uint32_t src_clk_hz; // Peripheral source clock resolution
|
||||
@ -165,6 +166,7 @@ static esp_err_t lcd_rgb_panel_alloc_frame_buffers(const esp_lcd_rgb_panel_confi
|
||||
}
|
||||
}
|
||||
rgb_panel->cur_fb_index = 0;
|
||||
rgb_panel->bb_fb_index = 0;
|
||||
rgb_panel->flags.fb_in_psram = fb_in_psram;
|
||||
|
||||
return ESP_OK;
|
||||
@ -223,10 +225,6 @@ esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_conf
|
||||
ESP_ERR_INVALID_ARG, err, TAG, "must set bounce buffer if there's no frame buffer");
|
||||
ESP_GOTO_ON_FALSE(!(rgb_panel_config->flags.refresh_on_demand && rgb_panel_config->bounce_buffer_size_px),
|
||||
ESP_ERR_INVALID_ARG, err, TAG, "refresh on demand is not supported under bounce buffer mode");
|
||||
#if CONFIG_LCD_RGB_ISR_IRAM_SAFE
|
||||
ESP_GOTO_ON_FALSE(rgb_panel_config->bounce_buffer_size_px == 0,
|
||||
ESP_ERR_INVALID_ARG, err, TAG, "bounce buffer mode is not IRAM Safe");
|
||||
#endif
|
||||
|
||||
// determine number of framebuffers
|
||||
size_t num_fbs = 1;
|
||||
@ -962,25 +960,26 @@ static IRAM_ATTR bool lcd_rgb_panel_fill_bounce_buffer(esp_rgb_panel_t *panel, u
|
||||
} else {
|
||||
// We do have frame buffer; copy from there.
|
||||
// Note: if the cache is diabled, and accessing the PSRAM by DCACHE will crash.
|
||||
memcpy(buffer, &panel->fbs[panel->cur_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
memcpy(buffer, &panel->fbs[panel->bb_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
if (panel->flags.bb_invalidate_cache) {
|
||||
// We don't need the bytes we copied from the psram anymore
|
||||
// Make sure that if anything happened to have changed (because the line already was in cache) we write the data back.
|
||||
Cache_WriteBack_Addr((uint32_t)&panel->fbs[panel->cur_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
Cache_WriteBack_Addr((uint32_t)&panel->fbs[panel->bb_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
// Invalidate the data.
|
||||
// Note: possible race: perhaps something on the other core can squeeze a write between this and the writeback,
|
||||
// in which case that data gets discarded.
|
||||
Cache_Invalidate_Addr((uint32_t)&panel->fbs[panel->cur_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
Cache_Invalidate_Addr((uint32_t)&panel->fbs[panel->bb_fb_index][panel->bounce_pos_px * bytes_per_pixel], panel->bb_size);
|
||||
}
|
||||
}
|
||||
panel->bounce_pos_px += panel->bb_size / bytes_per_pixel;
|
||||
// If the bounce pos is larger than the frame buffer size, wrap around so the next isr starts pre-loading the next frame.
|
||||
if (panel->bounce_pos_px >= panel->fb_size / bytes_per_pixel) {
|
||||
panel->bounce_pos_px = 0;
|
||||
panel->bb_fb_index = panel->cur_fb_index;
|
||||
}
|
||||
if (panel->num_fbs > 0) {
|
||||
// Preload the next bit of buffer from psram
|
||||
Cache_Start_DCache_Preload((uint32_t)&panel->fbs[panel->cur_fb_index][panel->bounce_pos_px * bytes_per_pixel],
|
||||
Cache_Start_DCache_Preload((uint32_t)&panel->fbs[panel->bb_fb_index][panel->bounce_pos_px * bytes_per_pixel],
|
||||
panel->bb_size, 0);
|
||||
}
|
||||
return need_yield;
|
||||
|
@ -159,8 +159,6 @@ TEST_CASE("lcd_rgb_panel_refresh_on_demand", "[lcd]")
|
||||
free(img);
|
||||
}
|
||||
|
||||
#if !CONFIG_LCD_RGB_ISR_IRAM_SAFE
|
||||
// bounce buffer mode is not IRAM safe, so we don't test it
|
||||
TEST_CASE("lcd_rgb_panel_bounce_buffer", "[lcd]")
|
||||
{
|
||||
uint8_t *img = malloc(TEST_IMG_SIZE);
|
||||
@ -184,7 +182,6 @@ TEST_CASE("lcd_rgb_panel_bounce_buffer", "[lcd]")
|
||||
TEST_ESP_OK(esp_lcd_panel_del(panel_handle));
|
||||
free(img);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE("lcd_rgb_panel_update_pclk", "[lcd]")
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
CONFIG_COMPILER_DUMP_RTL_FILES=y
|
||||
CONFIG_LCD_RGB_ISR_IRAM_SAFE=y
|
||||
CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y
|
||||
# bounce buffer mode relies on GDMA EOF interrupt to be service-able
|
||||
CONFIG_GDMA_ISR_IRAM_SAFE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_NONE=y
|
||||
# silent the error check, as the error string are stored in rodata, causing RTL check failure
|
||||
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
|
||||
|
@ -1,3 +1,7 @@
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
|
||||
# Enable the XIP-PSRAM feature, so the ext-mem cache won't be disabled when SPI1 is operating the main flash
|
||||
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
|
||||
CONFIG_SPIRAM_RODATA=y
|
||||
|
@ -381,7 +381,11 @@ More LCD panel drivers and touch drivers are available in `IDF Component Registr
|
||||
Bounce Buffer with Single PSRAM Frame Buffer
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This mode allocates two so-called ``bounce buffers`` from the internal memory, and a main frame buffer that is still in PSRAM. This mode is selected by setting the :cpp:member:`esp_lcd_rgb_panel_config_t::fb_in_psram` flag and additionally specifying a non-zero :cpp:member:`esp_lcd_rgb_panel_config_t::bounce_buffer_size_px` value. The bounce buffers only need to be large enough to hold a few lines of display data, which is significantly less than the main frame buffer. The LCD peripheral will use DMA to read data from one of the bounce buffers, and meanwhile an interrupt routine will use the CPU DCache to copy data from the main PSRAM frame buffer into the other bounce buffer. Once the LCD peripheral has finished reading the bounce buffer, the two buffers change place and the CPU can fill the others. The advantage of this mode is that, you can achieve higher pixel clock frequency. As the bounce buffers are larger than the FIFOs in the EDMA path, this method is also more robust against short bandwidth spikes. The downside is a major increase in CPU use and the LCD **CAN'T** work if the cache is disabled by flash operations, e.g. OTA or NVS write.
|
||||
This mode allocates two so-called ``bounce buffers`` from the internal memory, and a main frame buffer that is still in PSRAM. This mode is selected by setting the :cpp:member:`esp_lcd_rgb_panel_config_t::fb_in_psram` flag and additionally specifying a non-zero :cpp:member:`esp_lcd_rgb_panel_config_t::bounce_buffer_size_px` value. The bounce buffers only need to be large enough to hold a few lines of display data, which is significantly less than the main frame buffer. The LCD peripheral will use DMA to read data from one of the bounce buffers, and meanwhile an interrupt routine will use the CPU DCache to copy data from the main PSRAM frame buffer into the other bounce buffer. Once the LCD peripheral has finished reading the bounce buffer, the two buffers change place and the CPU can fill the others. The advantage of this mode is that, you can achieve higher pixel clock frequency. As the bounce buffers are larger than the FIFOs in the EDMA path, this method is also more robust against short bandwidth spikes. The downside is a major increase in CPU use and the LCD **CAN'T** work if we disable the cache of the external memory, via e.g. OTA or NVS write to the main flash.
|
||||
|
||||
.. note::
|
||||
|
||||
It's highly recommended to turn on the "PSRAM XIP (Execute In Place)" feature in this mode by enabling the Kconfig options: :ref:`CONFIG_SPIRAM_FETCH_INSTRUCTIONS` and :ref:`CONFIG_SPIRAM_RODATA`, which allows the CPU to fetch instructions and readonly data from the PSRAM instead of the main flash. What's more, the external memory cache won't be disabled even if you attempt to write to the main flash through SPI1. This makes it possible to display an OTA progress bar for your application.
|
||||
|
||||
.. code:: c
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user