diff --git a/components/esp_lcd/include/esp_lcd_panel_rgb.h b/components/esp_lcd/include/esp_lcd_panel_rgb.h index da7e45a849..6349acf8a0 100644 --- a/components/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/components/esp_lcd/include/esp_lcd_panel_rgb.h @@ -168,6 +168,19 @@ esp_err_t esp_lcd_rgb_panel_register_event_callbacks(esp_lcd_panel_handle_t pane * * @param panel LCD panel handle, returned from `esp_lcd_new_rgb_panel()` * @param freq_hz Frequency of pixel clock, in Hz + +/** + * @brief Get the address of the frame buffer(s) that allocated by the driver + * + * @param[in] panel LCD panel handle, returned from `esp_lcd_new_rgb_panel()` + * @param[in] fb_num Number of frame buffer(s) to get. This value must be the same as the number of the following parameters. + * @param[out] fb0 Returned address of the frame buffer 0 + * @param[out] ... List of other frame buffer addresses + * @return + * - ESP_ERR_INVALID_ARG: Get frame buffer address failed because of invalid argument + * - ESP_OK: Get frame buffer address successfully + */ +esp_err_t esp_lcd_rgb_panel_get_frame_buffer(esp_lcd_panel_handle_t panel, uint32_t fb_num, void **fb0, ...); * @return * - ESP_ERR_NOT_SUPPORTED if frequency is unreachable * - ESP_ERR_INVALID_ARG if parameter panel is invalid diff --git a/components/esp_lcd/src/esp_lcd_rgb_panel.c b/components/esp_lcd/src/esp_lcd_rgb_panel.c index fa526a0aef..59c69ea7e1 100644 --- a/components/esp_lcd/src/esp_lcd_rgb_panel.c +++ b/components/esp_lcd/src/esp_lcd_rgb_panel.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -38,7 +39,7 @@ #include "soc/lcd_periph.h" #include "hal/lcd_hal.h" #include "hal/lcd_ll.h" -#include +#include "rom/cache.h" #if CONFIG_LCD_RGB_ISR_IRAM_SAFE #define LCD_RGB_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_INTRDISABLED) @@ -319,6 +320,24 @@ esp_err_t esp_lcd_rgb_panel_register_event_callbacks(esp_lcd_panel_handle_t pane return ESP_OK; } +esp_err_t esp_lcd_rgb_panel_get_frame_buffer(esp_lcd_panel_handle_t panel, uint32_t fb_num, void **fb0, ...) +{ + ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); + ESP_RETURN_ON_FALSE(fb_num && fb_num <= 2, ESP_ERR_INVALID_ARG, TAG, "invalid frame buffer number"); + esp_rgb_panel_t *rgb_panel = __containerof(panel, esp_rgb_panel_t, base); + void **fb_itor = fb0; + va_list args; + va_start(args, fb0); + for (int i = 0; i < fb_num; i++) { + if (fb_itor) { + *fb_itor = rgb_panel->fbs[i]; + fb_itor = va_arg(args, void **); + } + } + va_end(args); + return ESP_OK; +} + static esp_err_t rgb_panel_del(esp_lcd_panel_t *panel) { esp_rgb_panel_t *rgb_panel = __containerof(panel, esp_rgb_panel_t, base);