diff --git a/components/esp_driver_ppa/CMakeLists.txt b/components/esp_driver_ppa/CMakeLists.txt index defc8c5e24..4b9ad27f9d 100644 --- a/components/esp_driver_ppa/CMakeLists.txt +++ b/components/esp_driver_ppa/CMakeLists.txt @@ -18,5 +18,6 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} + REQUIRES esp_hal_ppa PRIV_REQUIRES "${priv_requires}" ) diff --git a/components/esp_driver_ppa/test_apps/.build-test-rules.yml b/components/esp_driver_ppa/test_apps/.build-test-rules.yml index 7767104a7f..acad758640 100644 --- a/components/esp_driver_ppa/test_apps/.build-test-rules.yml +++ b/components/esp_driver_ppa/test_apps/.build-test-rules.yml @@ -5,3 +5,4 @@ components/esp_driver_ppa/test_apps: - if: SOC_PPA_SUPPORTED != 1 depends_components: - esp_driver_ppa + - esp_hal_ppa diff --git a/components/esp_hal_ppa/CMakeLists.txt b/components/esp_hal_ppa/CMakeLists.txt new file mode 100644 index 0000000000..73f1be5202 --- /dev/null +++ b/components/esp_hal_ppa/CMakeLists.txt @@ -0,0 +1,17 @@ +idf_build_get_property(target IDF_TARGET) + +set(srcs) +set(includes "include") + +# Add target-specific include directory if it exists +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include") + list(APPEND includes "${target}/include") +endif() + +if(CONFIG_SOC_PPA_SUPPORTED) + list(APPEND srcs "ppa_hal.c") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${includes} + REQUIRES soc hal) diff --git a/components/esp_hal_ppa/README.md b/components/esp_hal_ppa/README.md new file mode 100644 index 0000000000..1ad4b56bcb --- /dev/null +++ b/components/esp_hal_ppa/README.md @@ -0,0 +1,33 @@ +# ESP Hardware Abstraction Layer for PPA Peripheral + +> [!NOTE] +> This component is currently in beta. Its API, behavior, and compatibility may change at any time and without notice; backward compatibility is not guaranteed. Use caution when integrating into production systems. + +## Overview + +The `esp_hal_ppa` component provides a **Hardware Abstraction Layer** for the PPA (Pixel Processing Accelerator) peripheral across ESP-IDF supported targets that implement it. + +## Architecture + +The PPA HAL is structured in two main sub-layers: + +1. **HAL Layer (Upper)**: Defines the operational steps and data structures required to control the PPA peripheral (e.g., initialization, task submission, engine control, and synchronization). +2. **Low-Level Layer (Bottom)**: Serves as a translation layer between the HAL and the register files defined in the `soc` component, handling target-specific register configurations. + +## Features + +- Engine initialization and reset helpers +- Task/command configuration helpers (depending on target capabilities) +- Interrupt and status helpers +- Clock and power-management hooks (on supported chips) + +## Usage + +The HAL functions primarily serve ESP-IDF peripheral drivers such as `esp_driver_ppa`. + +Advanced developers can use these interfaces directly when implementing custom drivers, with the understanding that API stability is not guaranteed. + +## Dependencies + +- `soc`: Provides chip-specific register definitions +- `hal`: Core hardware abstraction utilities and macros diff --git a/components/hal/esp32p4/include/hal/ppa_ll.h b/components/esp_hal_ppa/esp32p4/include/hal/ppa_ll.h similarity index 99% rename from components/hal/esp32p4/include/hal/ppa_ll.h rename to components/esp_hal_ppa/esp32p4/include/hal/ppa_ll.h index ceba15d768..4ecbf7cad0 100644 --- a/components/hal/esp32p4/include/hal/ppa_ll.h +++ b/components/esp_hal_ppa/esp32p4/include/hal/ppa_ll.h @@ -16,10 +16,6 @@ #include "hal/misc.h" #include "hal/config.h" -#ifdef __cplusplus -extern "C" { -#endif - #define PPA_LL_GET_HW &PPA #define PPA_LL_BLEND0_CLUT_MEM_ADDR_OFFSET 0x400 @@ -28,6 +24,10 @@ extern "C" { #define PPA_LL_SRM_SCALING_INT_MAX (PPA_SR_SCAL_X_INT_V + 1) #define PPA_LL_SRM_SCALING_FRAG_MAX (PPA_SR_SCAL_X_FRAG_V + 1) +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enumeration of PPA SRM macro block size options */ @@ -273,7 +273,7 @@ static inline bool ppa_ll_srm_is_color_mode_supported(ppa_srm_color_mode_t color static inline void ppa_ll_srm_set_rx_color_mode(ppa_dev_t *dev, ppa_srm_color_mode_t color_mode) { uint32_t val = 0; - bool is_yuv422 __attribute__ ((unused)) = false; + bool is_yuv422 __attribute__((unused)) = false; switch (color_mode) { case PPA_SRM_COLOR_MODE_ARGB8888: val = 0; @@ -712,8 +712,8 @@ static inline bool ppa_ll_blend_is_color_mode_supported(ppa_blend_color_mode_t c case PPA_BLEND_COLOR_MODE_RGB565: case PPA_BLEND_COLOR_MODE_A8: case PPA_BLEND_COLOR_MODE_A4: - // case PPA_BLEND_COLOR_MODE_L8: - // case PPA_BLEND_COLOR_MODE_L4: + // case PPA_BLEND_COLOR_MODE_L8: + // case PPA_BLEND_COLOR_MODE_L4: #if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300 case PPA_BLEND_COLOR_MODE_YUV420: case PPA_BLEND_COLOR_MODE_YUV422_UYVY: @@ -737,7 +737,7 @@ static inline bool ppa_ll_blend_is_color_mode_supported(ppa_blend_color_mode_t c static inline void ppa_ll_blend_set_rx_bg_color_mode(ppa_dev_t *dev, ppa_blend_color_mode_t color_mode) { uint32_t val = 0; - bool is_yuv422 __attribute__ ((unused)) = false; + bool is_yuv422 __attribute__((unused)) = false; switch (color_mode) { case PPA_BLEND_COLOR_MODE_ARGB8888: val = 0; @@ -748,12 +748,12 @@ static inline void ppa_ll_blend_set_rx_bg_color_mode(ppa_dev_t *dev, ppa_blend_c case PPA_BLEND_COLOR_MODE_RGB565: val = 2; break; - // case PPA_BLEND_COLOR_MODE_L8: - // val = 4; - // break; - // case PPA_BLEND_COLOR_MODE_L4: - // val = 5; - // break; + // case PPA_BLEND_COLOR_MODE_L8: + // val = 4; + // break; + // case PPA_BLEND_COLOR_MODE_L4: + // val = 5; + // break; #if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300 case PPA_BLEND_COLOR_MODE_YUV420: val = 8; diff --git a/components/hal/include/hal/ppa_hal.h b/components/esp_hal_ppa/include/hal/ppa_hal.h similarity index 93% rename from components/hal/include/hal/ppa_hal.h rename to components/esp_hal_ppa/include/hal/ppa_hal.h index 1cbfc30005..f046812531 100644 --- a/components/hal/include/hal/ppa_hal.h +++ b/components/esp_hal_ppa/include/hal/ppa_hal.h @@ -12,6 +12,11 @@ #pragma once +#include "soc/soc_caps.h" +#if SOC_HAS(PPA) +#include "hal/ppa_ll.h" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/include/hal/ppa_types.h b/components/esp_hal_ppa/include/hal/ppa_types.h similarity index 100% rename from components/hal/include/hal/ppa_types.h rename to components/esp_hal_ppa/include/hal/ppa_types.h diff --git a/components/hal/ppa_hal.c b/components/esp_hal_ppa/ppa_hal.c similarity index 92% rename from components/hal/ppa_hal.c rename to components/esp_hal_ppa/ppa_hal.c index a2cd073fe8..5f057f5428 100644 --- a/components/hal/ppa_hal.c +++ b/components/esp_hal_ppa/ppa_hal.c @@ -6,7 +6,6 @@ #include #include "hal/ppa_hal.h" -#include "hal/ppa_ll.h" void ppa_hal_init(ppa_hal_context_t *hal) { diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index 31926a9c2e..c29b1ea55c 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -140,10 +140,6 @@ elseif(NOT BOOTLOADER_BUILD) list(APPEND srcs "vbat_hal.c") endif() - if(CONFIG_SOC_PPA_SUPPORTED) - list(APPEND srcs "ppa_hal.c") - endif() - if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED) list(APPEND srcs "sdio_slave_hal.c") endif() diff --git a/docs/doxygen/Doxyfile_esp32p4 b/docs/doxygen/Doxyfile_esp32p4 index aa5c73451c..ed18d201b8 100644 --- a/docs/doxygen/Doxyfile_esp32p4 +++ b/docs/doxygen/Doxyfile_esp32p4 @@ -29,6 +29,7 @@ INPUT += \ $(PROJECT_PATH)/components/esp_driver_jpeg/include/driver/jpeg_encode.h \ $(PROJECT_PATH)/components/esp_driver_jpeg/include/driver/jpeg_types.h \ $(PROJECT_PATH)/components/esp_driver_ppa/include/driver/ppa.h \ + $(PROJECT_PATH)/components/esp_hal_ppa/include/hal/ppa_types.h \ $(PROJECT_PATH)/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h \ $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens.h \ $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens_types.h \ @@ -36,7 +37,6 @@ INPUT += \ $(PROJECT_PATH)/components/esp_hal_cam/include/hal/isp_types.h \ $(PROJECT_PATH)/components/esp_lcd/dsi/include/esp_lcd_mipi_dsi.h \ $(PROJECT_PATH)/components/esp_lcd/rgb/include/esp_lcd_panel_rgb.h \ - $(PROJECT_PATH)/components/hal/include/hal/ppa_types.h \ $(PROJECT_PATH)/components/sdmmc/include/sd_pwr_ctrl.h \ $(PROJECT_PATH)/components/sdmmc/include/sd_pwr_ctrl_by_on_chip_ldo.h \ $(PROJECT_PATH)/components/esp_hal_dma/esp32p4/include/hal/bitscrambler_peri_select.h \ diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index 2ac3d159c5..71e3ee9007 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -380,6 +380,7 @@ examples/peripherals/ppa/ppa_dsi: - if: SOC_PPA_SUPPORTED != 1 or SOC_MIPI_DSI_SUPPORTED != 1 depends_components: - esp_driver_ppa + - esp_hal_ppa - esp_lcd examples/peripherals/rmt: