diff --git a/components/esp_lcd/CMakeLists.txt b/components/esp_lcd/CMakeLists.txt index 535aebda00..e761342d15 100644 --- a/components/esp_lcd/CMakeLists.txt +++ b/components/esp_lcd/CMakeLists.txt @@ -7,7 +7,7 @@ set(srcs "src/esp_lcd_common.c" "src/esp_lcd_panel_st7789.c" "src/esp_lcd_panel_ops.c") 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) list(APPEND srcs "src/esp_lcd_panel_io_i2s.c") @@ -21,7 +21,3 @@ idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} PRIV_REQUIRES ${priv_requires} LDFRAGMENTS linker.lf) - -if(CONFIG_SPIRAM) - idf_component_optional_requires(PRIVATE esp_psram) -endif() diff --git a/components/esp_lcd/src/esp_lcd_panel_io_i80.c b/components/esp_lcd/src/esp_lcd_panel_io_i80.c index 0b5e00f8dd..fb6f3ce284 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_i80.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_i80.c @@ -36,6 +36,7 @@ #include "soc/lcd_periph.h" #include "hal/lcd_ll.h" #include "hal/lcd_hal.h" +#include "esp_cache.h" 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_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_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); @@ -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; if (esp_ptr_external_ram(color)) { - // flush framebuffer from cache to the physical PSRAM - Cache_WriteBack_Addr((uint32_t)color, color_size); + // flush frame buffer from cache to the physical PSRAM + // 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 diff --git a/components/esp_lcd/src/esp_lcd_panel_rgb.c b/components/esp_lcd/src/esp_lcd_panel_rgb.c index d3415fa701..51c6f30299 100644 --- a/components/esp_lcd/src/esp_lcd_panel_rgb.c +++ b/components/esp_lcd/src/esp_lcd_panel_rgb.c @@ -33,9 +33,7 @@ #include "driver/gpio.h" #include "esp_bit_defs.h" #include "esp_private/periph_ctrl.h" -#if CONFIG_SPIRAM #include "esp_psram.h" -#endif #include "esp_lcd_common.h" #include "soc/lcd_periph.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; uint32_t bytes_per_line = bytes_per_pixel * pixels_per_line; 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; 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) { // 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_cache_msync((void *)(flush_ptr), (size_t)bytes_to_flush, 0); + ESP_RETURN_ON_ERROR(esp_cache_msync(flush_ptr, bytes_to_flush, 0), TAG, "flush cache buffer failed"); } if (!rgb_panel->bb_size) {