diff --git a/components/esp_lcd/dsi/esp_lcd_panel_dpi.c b/components/esp_lcd/dsi/esp_lcd_panel_dpi.c index de46cbb589..2b546f39a2 100644 --- a/components/esp_lcd/dsi/esp_lcd_panel_dpi.c +++ b/components/esp_lcd/dsi/esp_lcd_panel_dpi.c @@ -612,7 +612,7 @@ esp_err_t esp_lcd_dpi_panel_register_event_callbacks(esp_lcd_panel_handle_t pane { ESP_RETURN_ON_FALSE(panel && cbs, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); esp_lcd_dpi_panel_t *dpi_panel = __containerof(panel, esp_lcd_dpi_panel_t, base); -#if CONFIG_LCD_DSI_ISR_HANDLER_IN_IRAM +#if CONFIG_LCD_DSI_ISR_CACHE_SAFE if (cbs->on_color_trans_done) { ESP_RETURN_ON_FALSE(esp_ptr_in_iram(cbs->on_color_trans_done), ESP_ERR_INVALID_ARG, TAG, "on_color_trans_done callback not in IRAM"); } diff --git a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c index 30f45cddd2..443d5c8957 100644 --- a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c +++ b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c @@ -9,45 +9,12 @@ // In fact, we're simulating the Intel 8080 bus with I2S peripheral, in a special parallel mode. ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include "sdkconfig.h" -#if CONFIG_LCD_ENABLE_DEBUG_LOG -// The local log level must be defined before including esp_log.h -// Set the maximum log level for this source file -#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG -#endif -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_attr.h" -#include "esp_check.h" -#include "esp_intr_alloc.h" -#include "esp_heap_caps.h" -#include "esp_pm.h" -#include "esp_lcd_panel_io_interface.h" -#include "esp_lcd_panel_io.h" -#include "esp_lcd_common.h" -#include "esp_rom_gpio.h" -#include "soc/soc_caps.h" -#include "hal/gpio_hal.h" -#include "driver/gpio.h" -#include "esp_clk_tree.h" -#include "esp_private/periph_ctrl.h" +#include "i80_io_priv.h" #include "esp_private/i2s_platform.h" -#include "esp_private/gdma_link.h" -#include "esp_private/esp_dma_utils.h" -#include "esp_private/gpio.h" -#include "soc/lcd_periph.h" #include "hal/i2s_hal.h" #include "hal/i2s_ll.h" #include "hal/i2s_types.h" -static const char *TAG = "lcd_panel.io.i80"; - 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; @@ -126,9 +93,6 @@ struct lcd_panel_io_i80_t { esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lcd_i80_bus_handle_t *ret_bus) { -#if CONFIG_LCD_ENABLE_DEBUG_LOG - esp_log_level_set(TAG, ESP_LOG_DEBUG); -#endif esp_err_t ret = ESP_OK; esp_lcd_i80_bus_t *bus = NULL; ESP_GOTO_ON_FALSE(bus_config && ret_bus, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument"); @@ -178,7 +142,12 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc // initialize HAL layer i2s_hal_init(&bus->hal, bus->bus_id); // set peripheral clock resolution - ret = i2s_lcd_select_periph_clock(bus, bus_config->clk_src); + lcd_clock_source_t clk_src = bus_config->clk_src; + // if user doesn't specify a clock source, use the default one + if (clk_src == 0) { + clk_src = LCD_CLK_SRC_DEFAULT; + } + ret = i2s_lcd_select_periph_clock(bus, clk_src); ESP_GOTO_ON_ERROR(ret, err, TAG, "select periph clock failed"); // reset peripheral, DMA channel and FIFO i2s_ll_tx_reset(bus->hal.dev); @@ -855,3 +824,11 @@ static IRAM_ATTR void i2s_lcd_default_isr_handler(void *args) portYIELD_FROM_ISR(); } } + +#if CONFIG_LCD_ENABLE_DEBUG_LOG +__attribute__((constructor)) +static void i2s_lcd_override_default_log_level(void) +{ + esp_log_level_set(TAG, ESP_LOG_VERBOSE); +} +#endif diff --git a/components/esp_lcd/i80/esp_lcd_panel_io_i80.c b/components/esp_lcd/i80/esp_lcd_panel_io_i80.c index 70acb1fe72..179cf7c7ab 100644 --- a/components/esp_lcd/i80/esp_lcd_panel_io_i80.c +++ b/components/esp_lcd/i80/esp_lcd_panel_io_i80.c @@ -4,41 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include -#include -#include -#include -#include "sdkconfig.h" -#if CONFIG_LCD_ENABLE_DEBUG_LOG -// The local log level must be defined before including esp_log.h -// Set the maximum log level for this source file -#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG -#endif -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_attr.h" -#include "esp_check.h" -#include "esp_pm.h" -#include "esp_lcd_panel_io_interface.h" -#include "esp_lcd_panel_io.h" -#include "esp_rom_gpio.h" -#include "soc/soc_caps.h" -#include "esp_clk_tree.h" -#include "esp_memory_utils.h" -#include "esp_cache.h" -#include "driver/gpio.h" -#include "esp_private/esp_clk_tree_common.h" -#include "esp_private/gpio.h" +#include "i80_io_priv.h" #include "esp_private/gdma.h" -#include "esp_private/gdma_link.h" -#include "esp_private/esp_dma_utils.h" -#include "esp_private/periph_ctrl.h" -#include "esp_lcd_common.h" -#include "soc/lcd_periph.h" -#include "soc/io_mux_reg.h" -#include "soc/gpio_sig_map.h" #include "hal/lcd_ll.h" #include "hal/lcd_hal.h" #include "hal/cache_ll.h" @@ -60,8 +27,6 @@ #define LCD_CACHE_ADDR_TO_NON_CACHE_ADDR(addr) (addr) #endif -static const char *TAG = "lcd_panel.io.i80"; - 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; @@ -146,9 +111,6 @@ struct lcd_panel_io_i80_t { esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lcd_i80_bus_handle_t *ret_bus) { -#if CONFIG_LCD_ENABLE_DEBUG_LOG - esp_log_level_set(TAG, ESP_LOG_DEBUG); -#endif esp_err_t ret = ESP_OK; esp_lcd_i80_bus_t *bus = NULL; ESP_RETURN_ON_FALSE(bus_config && ret_bus, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); @@ -187,8 +149,13 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc lcd_ll_enable_clock(bus->hal.dev, true); } // set peripheral clock resolution - ret = lcd_i80_select_periph_clock(bus, bus_config->clk_src); - ESP_GOTO_ON_ERROR(ret, err, TAG, "select periph clock %d failed", bus_config->clk_src); + lcd_clock_source_t clk_src = bus_config->clk_src; + // if user doesn't specify a clock source, use the default one + if (clk_src == 0) { + clk_src = LCD_CLK_SRC_DEFAULT; + } + ret = lcd_i80_select_periph_clock(bus, clk_src); + ESP_GOTO_ON_ERROR(ret, err, TAG, "select periph clock %d failed", clk_src); // reset peripheral and FIFO after we select a correct clock source lcd_ll_reset(bus->hal.dev); lcd_ll_fifo_reset(bus->hal.dev); @@ -830,3 +797,11 @@ IRAM_ATTR static void i80_lcd_default_isr_handler(void *args) portYIELD_FROM_ISR(); } } + +#if CONFIG_LCD_ENABLE_DEBUG_LOG +__attribute__((constructor)) +static void i80_lcd_override_default_log_level(void) +{ + esp_log_level_set(TAG, ESP_LOG_VERBOSE); +} +#endif diff --git a/components/esp_lcd/i80/i80_io_priv.h b/components/esp_lcd/i80/i80_io_priv.h new file mode 100644 index 0000000000..dc07da0976 --- /dev/null +++ b/components/esp_lcd/i80/i80_io_priv.h @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include +#include +#include +#include +#include +#include "sdkconfig.h" +#if CONFIG_LCD_ENABLE_DEBUG_LOG +// The local log level must be defined before including esp_log.h +// Set the maximum log level for gptimer driver +#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE +#endif +#include "soc/soc_caps_full.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_check.h" +#include "esp_attr.h" +#include "esp_heap_caps.h" +#include "esp_intr_alloc.h" +#include "esp_clk_tree.h" +#include "esp_pm.h" +#include "esp_cache.h" +#include "esp_memory_utils.h" +#include "esp_lcd_panel_io_interface.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_common.h" +#include "driver/gpio.h" +#include "esp_private/periph_ctrl.h" +#include "esp_private/esp_clk_tree_common.h" +#include "esp_private/gdma_link.h" +#include "esp_private/esp_dma_utils.h" +#include "esp_private/gpio.h" +#include "soc/lcd_periph.h" +#include "soc/io_mux_reg.h" +#include "soc/gpio_sig_map.h" + +///!< Logging settings +#define TAG "lcd.i80" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif