Merge branch 'bugfix/lcd_edma_buffer_align_check' into 'master'

esp_lcd: propagate the error on cache sync failure

Closes IDF-6955

See merge request espressif/esp-idf!23022
This commit is contained in:
morris 2023-04-03 17:49:43 +08:00
commit bcbe8fec39
3 changed files with 8 additions and 15 deletions

View File

@ -7,7 +7,7 @@ set(srcs "src/esp_lcd_common.c"
"src/esp_lcd_panel_st7789.c" "src/esp_lcd_panel_st7789.c"
"src/esp_lcd_panel_ops.c") "src/esp_lcd_panel_ops.c")
set(includes "include" "interface") set(includes "include" "interface")
set(priv_requires "driver" "esp_mm") set(priv_requires "driver" "esp_mm" "esp_psram")
if(CONFIG_SOC_I2S_LCD_I80_VARIANT) if(CONFIG_SOC_I2S_LCD_I80_VARIANT)
list(APPEND srcs "src/esp_lcd_panel_io_i2s.c") list(APPEND srcs "src/esp_lcd_panel_io_i2s.c")
@ -21,7 +21,3 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes} INCLUDE_DIRS ${includes}
PRIV_REQUIRES ${priv_requires} PRIV_REQUIRES ${priv_requires}
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)
if(CONFIG_SPIRAM)
idf_component_optional_requires(PRIVATE esp_psram)
endif()

View File

@ -36,6 +36,7 @@
#include "soc/lcd_periph.h" #include "soc/lcd_periph.h"
#include "hal/lcd_ll.h" #include "hal/lcd_ll.h"
#include "hal/lcd_hal.h" #include "hal/lcd_hal.h"
#include "esp_cache.h"
static const char *TAG = "lcd_panel.io.i80"; static const char *TAG = "lcd_panel.io.i80";
@ -43,9 +44,6 @@ typedef struct esp_lcd_i80_bus_t esp_lcd_i80_bus_t;
typedef struct lcd_panel_io_i80_t lcd_panel_io_i80_t; typedef struct lcd_panel_io_i80_t lcd_panel_io_i80_t;
typedef struct lcd_i80_trans_descriptor_t lcd_i80_trans_descriptor_t; typedef struct lcd_i80_trans_descriptor_t lcd_i80_trans_descriptor_t;
// This function is located in ROM (also see esp_rom/${target}/ld/${target}.rom.ld)
extern int Cache_WriteBack_Addr(uint32_t addr, uint32_t size);
static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size); static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size);
static esp_err_t panel_io_i80_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size); static esp_err_t panel_io_i80_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size);
static esp_err_t panel_io_i80_del(esp_lcd_panel_io_t *io); static esp_err_t panel_io_i80_del(esp_lcd_panel_io_t *io);
@ -471,8 +469,9 @@ static esp_err_t panel_io_i80_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, cons
trans_desc->user_ctx = i80_device->user_ctx; trans_desc->user_ctx = i80_device->user_ctx;
if (esp_ptr_external_ram(color)) { if (esp_ptr_external_ram(color)) {
// flush framebuffer from cache to the physical PSRAM // flush frame buffer from cache to the physical PSRAM
Cache_WriteBack_Addr((uint32_t)color, color_size); // note the esp_cache_msync function will check the alignment of the address and size, and error out if either of them is not matched
ESP_RETURN_ON_ERROR(esp_cache_msync((void *)color, color_size, 0), TAG, "flush cache buffer failed");
} }
// send transaction to trans_queue // send transaction to trans_queue

View File

@ -33,9 +33,7 @@
#include "driver/gpio.h" #include "driver/gpio.h"
#include "esp_bit_defs.h" #include "esp_bit_defs.h"
#include "esp_private/periph_ctrl.h" #include "esp_private/periph_ctrl.h"
#if CONFIG_SPIRAM
#include "esp_psram.h" #include "esp_psram.h"
#endif
#include "esp_lcd_common.h" #include "esp_lcd_common.h"
#include "soc/lcd_periph.h" #include "soc/lcd_periph.h"
#include "hal/lcd_hal.h" #include "hal/lcd_hal.h"
@ -593,7 +591,7 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
int pixels_per_line = rgb_panel->timings.h_res; int pixels_per_line = rgb_panel->timings.h_res;
uint32_t bytes_per_line = bytes_per_pixel * pixels_per_line; uint32_t bytes_per_line = bytes_per_pixel * pixels_per_line;
uint8_t *fb = rgb_panel->fbs[rgb_panel->cur_fb_index]; uint8_t *fb = rgb_panel->fbs[rgb_panel->cur_fb_index];
uint32_t bytes_to_flush = v_res * h_res * bytes_per_pixel; size_t bytes_to_flush = v_res * h_res * bytes_per_pixel;
uint8_t *flush_ptr = fb; uint8_t *flush_ptr = fb;
if (do_copy) { if (do_copy) {
@ -796,10 +794,10 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
} }
// Note that if we use a bounce buffer, the data gets read by the CPU as well so no need to write back
if (rgb_panel->flags.fb_in_psram && !rgb_panel->bb_size) { if (rgb_panel->flags.fb_in_psram && !rgb_panel->bb_size) {
// CPU writes data to PSRAM through DCache, data in PSRAM might not get updated, so write back // CPU writes data to PSRAM through DCache, data in PSRAM might not get updated, so write back
// Note that if we use a bounce buffer, the data gets read by the CPU as well so no need to write back ESP_RETURN_ON_ERROR(esp_cache_msync(flush_ptr, bytes_to_flush, 0), TAG, "flush cache buffer failed");
esp_cache_msync((void *)(flush_ptr), (size_t)bytes_to_flush, 0);
} }
if (!rgb_panel->bb_size) { if (!rgb_panel->bb_size) {