From a3ca5b610d005c3488083f79f2bf6f61bb2ef480 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 30 Oct 2025 17:56:10 +0800 Subject: [PATCH 1/2] refactor(jpeg): Split hal layer for jpeg --- components/esp_driver_jpeg/CMakeLists.txt | 2 ++ components/esp_hal_jpeg/CMakeLists.txt | 20 +++++++++++++++++++ components/esp_hal_jpeg/README.md | 9 +++++++++ .../esp32p4/include/hal/jpeg_ll.h | 2 -- .../include/hal/jpeg_hal.h | 0 .../include/hal/jpeg_types.h | 0 components/{hal => esp_hal_jpeg}/jpeg_hal.c | 0 components/hal/CMakeLists.txt | 4 ---- docs/doxygen/Doxyfile | 1 + docs/en/api-reference/peripherals/jpeg.rst | 2 +- docs/zh_CN/api-reference/peripherals/jpeg.rst | 2 +- 11 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 components/esp_hal_jpeg/CMakeLists.txt create mode 100644 components/esp_hal_jpeg/README.md rename components/{hal => esp_hal_jpeg}/esp32p4/include/hal/jpeg_ll.h (99%) rename components/{hal => esp_hal_jpeg}/include/hal/jpeg_hal.h (100%) rename components/{hal => esp_hal_jpeg}/include/hal/jpeg_types.h (100%) rename components/{hal => esp_hal_jpeg}/jpeg_hal.c (100%) diff --git a/components/esp_driver_jpeg/CMakeLists.txt b/components/esp_driver_jpeg/CMakeLists.txt index 4e8c7a8a84..59ba4ecad3 100644 --- a/components/esp_driver_jpeg/CMakeLists.txt +++ b/components/esp_driver_jpeg/CMakeLists.txt @@ -23,6 +23,7 @@ if(CONFIG_SOC_JPEG_CODEC_SUPPORTED) endif() endif() +set(requires esp_hal_jpeg) if(${target} STREQUAL "linux") set(priv_requires "") else() @@ -32,4 +33,5 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} PRIV_REQUIRES "${priv_requires}" + REQUIRES "${requires}" ) diff --git a/components/esp_hal_jpeg/CMakeLists.txt b/components/esp_hal_jpeg/CMakeLists.txt new file mode 100644 index 0000000000..acfc9a39d6 --- /dev/null +++ b/components/esp_hal_jpeg/CMakeLists.txt @@ -0,0 +1,20 @@ +idf_build_get_property(target IDF_TARGET) +if(${target} STREQUAL "linux") + return() # This component is not supported by the POSIX/Linux simulator +endif() + +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include") + list(APPEND includes "${target}/include") +endif() +list(APPEND includes "include") + +set(srcs) + +# JPEG related source files +if(CONFIG_SOC_JPEG_CODEC_SUPPORTED) + list(APPEND srcs "jpeg_hal.c") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${includes} + REQUIRES soc hal) diff --git a/components/esp_hal_jpeg/README.md b/components/esp_hal_jpeg/README.md new file mode 100644 index 0000000000..953e02b470 --- /dev/null +++ b/components/esp_hal_jpeg/README.md @@ -0,0 +1,9 @@ +# `esp_hal_jpeg` + +⚠️ This HAL component is still under heavy development at the moment, so we don't guarantee the stability and backward-compatibility among versions. + +The `esp_hal_jpeg` component provides a **Hardware Abstraction Layer** of JPEG for all targets supported by ESP-IDF. + +In a broad sense, the HAL layer consists of two sub-layers: HAL (upper) and Low-Level(bottom). The HAL layer defines the steps and data that is required to operate a peripheral (e.g. initialization, parameter settings). The low-level is a translation layer above the register files under the `soc` component, it only covers general conceptions to register configurations. + +The functions in this file mainly provide hardware abstraction for IDF peripheral drivers. For advanced developers, the HAL layer functions can also be directly used to assist in implementing their own drivers. However, it needs to be mentioned again that the interfaces here do not guarantee stability. diff --git a/components/hal/esp32p4/include/hal/jpeg_ll.h b/components/esp_hal_jpeg/esp32p4/include/hal/jpeg_ll.h similarity index 99% rename from components/hal/esp32p4/include/hal/jpeg_ll.h rename to components/esp_hal_jpeg/esp32p4/include/hal/jpeg_ll.h index 775b9c17a2..c6ad4c4b2f 100644 --- a/components/hal/esp32p4/include/hal/jpeg_ll.h +++ b/components/esp_hal_jpeg/esp32p4/include/hal/jpeg_ll.h @@ -67,7 +67,6 @@ typedef enum { JPEG_LL_INTR_UNDETECT | \ JPEG_LL_INTR_DECODE_TIMEOUT) - typedef enum { JPEG_LL_RLE_PARALLEL_ERR = (1 << 1), JPEG_LL_BS_LAST_BLOCK_EOF = (1 << 12), @@ -437,7 +436,6 @@ static inline void jpeg_ll_codec_pause(jpeg_dev_t *hw, bool en) hw->config.pause_en = en; } - /** * @brief Apply soft reset, this will reset the hardware fsm and fifo. * diff --git a/components/hal/include/hal/jpeg_hal.h b/components/esp_hal_jpeg/include/hal/jpeg_hal.h similarity index 100% rename from components/hal/include/hal/jpeg_hal.h rename to components/esp_hal_jpeg/include/hal/jpeg_hal.h diff --git a/components/hal/include/hal/jpeg_types.h b/components/esp_hal_jpeg/include/hal/jpeg_types.h similarity index 100% rename from components/hal/include/hal/jpeg_types.h rename to components/esp_hal_jpeg/include/hal/jpeg_types.h diff --git a/components/hal/jpeg_hal.c b/components/esp_hal_jpeg/jpeg_hal.c similarity index 100% rename from components/hal/jpeg_hal.c rename to components/esp_hal_jpeg/jpeg_hal.c diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index 18ec4a7d5b..b9a82d859a 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -72,10 +72,6 @@ elseif(NOT BOOTLOADER_BUILD) list(APPEND srcs "vbat_hal.c") endif() - if(CONFIG_SOC_JPEG_CODEC_SUPPORTED) - list(APPEND srcs "jpeg_hal.c") - endif() - if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED) list(APPEND srcs "sdio_slave_hal.c") endif() diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 20a5633d23..c039e7c2d2 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -175,6 +175,7 @@ INPUT = \ $(PROJECT_PATH)/components/esp_hal_timg/include/hal/timer_types.h \ $(PROJECT_PATH)/components/esp_hal_i2c/include/hal/i2c_types.h \ $(PROJECT_PATH)/components/esp_hal_i2s/include/hal/i2s_types.h \ + $(PROJECT_PATH)/components/esp_hal_jpeg/include/hal/jpeg_types.h \ $(PROJECT_PATH)/components/esp_hal_lcd/include/hal/lcd_types.h \ $(PROJECT_PATH)/components/esp_hal_ledc/include/hal/ledc_types.h \ $(PROJECT_PATH)/components/esp_hal_parlio/include/hal/parlio_types.h \ diff --git a/docs/en/api-reference/peripherals/jpeg.rst b/docs/en/api-reference/peripherals/jpeg.rst index 462c4d1e39..96ca38f3f2 100644 --- a/docs/en/api-reference/peripherals/jpeg.rst +++ b/docs/en/api-reference/peripherals/jpeg.rst @@ -465,4 +465,4 @@ API Reference .. include-build-file:: inc/jpeg_encode.inc .. include-build-file:: inc/components/esp_driver_jpeg/include/driver/jpeg_types.inc -.. include-build-file:: inc/components/hal/include/hal/jpeg_types.inc +.. include-build-file:: inc/components/esp_hal_jpeg/include/hal/jpeg_types.inc diff --git a/docs/zh_CN/api-reference/peripherals/jpeg.rst b/docs/zh_CN/api-reference/peripherals/jpeg.rst index 561af27af0..cd523aa224 100644 --- a/docs/zh_CN/api-reference/peripherals/jpeg.rst +++ b/docs/zh_CN/api-reference/peripherals/jpeg.rst @@ -465,4 +465,4 @@ API 参考 .. include-build-file:: inc/jpeg_encode.inc .. include-build-file:: inc/components/esp_driver_jpeg/include/driver/jpeg_types.inc -.. include-build-file:: inc/components/hal/include/hal/jpeg_types.inc +.. include-build-file:: inc/components/esp_hal_jpeg/include/hal/jpeg_types.inc From e794bd6c5c98c54fabe51f36aa25906dff203edc Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 25 Dec 2025 16:29:38 +0800 Subject: [PATCH 2/2] refactor(hal): Cleanup some missing hal files --- .../include/hal/dma2d_types.h | 0 .../include/hal/dma_types.h | 0 .../include/hal/gdma_types.h | 0 .../include/hal/glitch_filter_types.h | 0 .../include/hal/i2s_hal.h | 1 - .../include/hal/lp_i2s_hal.h | 0 .../include/hal/jpeg_defs.h | 2 -- .../include/hal/mcpwm_types.h | 0 .../include/hal/psram_types.h | 0 .../include/hal/usb_serial_jtag_types.h | 0 .../ldo/include/esp_ldo_regulator.h | 1 - components/hal/include/hal/ldo_types.h | 28 ------------------- docs/doxygen/Doxyfile | 2 +- docs/doxygen/Doxyfile_esp32p4 | 1 - docs/en/api-reference/peripherals/mcpwm.rst | 2 +- .../zh_CN/api-reference/peripherals/mcpwm.rst | 2 +- 16 files changed, 3 insertions(+), 36 deletions(-) rename components/{hal => esp_hal_dma}/include/hal/dma2d_types.h (100%) rename components/{hal => esp_hal_dma}/include/hal/dma_types.h (100%) rename components/{hal => esp_hal_dma}/include/hal/gdma_types.h (100%) rename components/{hal => esp_hal_gpio}/include/hal/glitch_filter_types.h (100%) rename components/{hal => esp_hal_i2s}/include/hal/i2s_hal.h (99%) rename components/{hal => esp_hal_i2s}/include/hal/lp_i2s_hal.h (100%) rename components/{hal => esp_hal_jpeg}/include/hal/jpeg_defs.h (99%) rename components/{hal => esp_hal_mcpwm}/include/hal/mcpwm_types.h (100%) rename components/{hal => esp_hal_mspi}/include/hal/psram_types.h (100%) rename components/{hal => esp_hal_usb}/include/hal/usb_serial_jtag_types.h (100%) delete mode 100644 components/hal/include/hal/ldo_types.h diff --git a/components/hal/include/hal/dma2d_types.h b/components/esp_hal_dma/include/hal/dma2d_types.h similarity index 100% rename from components/hal/include/hal/dma2d_types.h rename to components/esp_hal_dma/include/hal/dma2d_types.h diff --git a/components/hal/include/hal/dma_types.h b/components/esp_hal_dma/include/hal/dma_types.h similarity index 100% rename from components/hal/include/hal/dma_types.h rename to components/esp_hal_dma/include/hal/dma_types.h diff --git a/components/hal/include/hal/gdma_types.h b/components/esp_hal_dma/include/hal/gdma_types.h similarity index 100% rename from components/hal/include/hal/gdma_types.h rename to components/esp_hal_dma/include/hal/gdma_types.h diff --git a/components/hal/include/hal/glitch_filter_types.h b/components/esp_hal_gpio/include/hal/glitch_filter_types.h similarity index 100% rename from components/hal/include/hal/glitch_filter_types.h rename to components/esp_hal_gpio/include/hal/glitch_filter_types.h diff --git a/components/hal/include/hal/i2s_hal.h b/components/esp_hal_i2s/include/hal/i2s_hal.h similarity index 99% rename from components/hal/include/hal/i2s_hal.h rename to components/esp_hal_i2s/include/hal/i2s_hal.h index fb4b2b9313..ed9b4581b9 100644 --- a/components/hal/include/hal/i2s_hal.h +++ b/components/esp_hal_i2s/include/hal/i2s_hal.h @@ -371,7 +371,6 @@ void i2s_hal_tdm_enable_rx_channel(i2s_hal_context_t *hal); */ #define i2s_hal_rx_reset_fifo(hal) i2s_ll_rx_reset_fifo((hal)->dev) - #if !SOC_GDMA_SUPPORTED /** * @brief Enable I2S TX DMA diff --git a/components/hal/include/hal/lp_i2s_hal.h b/components/esp_hal_i2s/include/hal/lp_i2s_hal.h similarity index 100% rename from components/hal/include/hal/lp_i2s_hal.h rename to components/esp_hal_i2s/include/hal/lp_i2s_hal.h diff --git a/components/hal/include/hal/jpeg_defs.h b/components/esp_hal_jpeg/include/hal/jpeg_defs.h similarity index 99% rename from components/hal/include/hal/jpeg_defs.h rename to components/esp_hal_jpeg/include/hal/jpeg_defs.h index 1518edceb4..e17f5f8a56 100644 --- a/components/hal/include/hal/jpeg_defs.h +++ b/components/esp_hal_jpeg/include/hal/jpeg_defs.h @@ -13,7 +13,6 @@ extern "C" { #endif - /* * @brief Enum to define JPEG marker codes */ @@ -73,7 +72,6 @@ typedef enum { JPEG_M_INV = 0xFFFF, ///< Invalid marker } __attribute__((packed)) jpeg_marker_code_t; - #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/mcpwm_types.h b/components/esp_hal_mcpwm/include/hal/mcpwm_types.h similarity index 100% rename from components/hal/include/hal/mcpwm_types.h rename to components/esp_hal_mcpwm/include/hal/mcpwm_types.h diff --git a/components/hal/include/hal/psram_types.h b/components/esp_hal_mspi/include/hal/psram_types.h similarity index 100% rename from components/hal/include/hal/psram_types.h rename to components/esp_hal_mspi/include/hal/psram_types.h diff --git a/components/hal/include/hal/usb_serial_jtag_types.h b/components/esp_hal_usb/include/hal/usb_serial_jtag_types.h similarity index 100% rename from components/hal/include/hal/usb_serial_jtag_types.h rename to components/esp_hal_usb/include/hal/usb_serial_jtag_types.h diff --git a/components/esp_hw_support/ldo/include/esp_ldo_regulator.h b/components/esp_hw_support/ldo/include/esp_ldo_regulator.h index 8db67237ca..67c78727d5 100644 --- a/components/esp_hw_support/ldo/include/esp_ldo_regulator.h +++ b/components/esp_hw_support/ldo/include/esp_ldo_regulator.h @@ -9,7 +9,6 @@ #include #include #include "esp_err.h" -#include "hal/ldo_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/include/hal/ldo_types.h b/components/hal/include/hal/ldo_types.h deleted file mode 100644 index 600e2c4366..0000000000 --- a/components/hal/include/hal/ldo_types.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief LDO Unit - * - * @note See datasheet to know LDO, alias includes but not least to `VFB/VOn` - */ -typedef enum { - LDO_UNIT_1 = 1, ///< LDO 1 - LDO_UNIT_2, ///< LDO 2 - LDO_UNIT_3, ///< LDO 3 - LDO_UNIT_4, ///< LDO 4 -} ldo_unit_t; - -#ifdef __cplusplus -} -#endif diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index c039e7c2d2..171bbe45e8 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -179,6 +179,7 @@ INPUT = \ $(PROJECT_PATH)/components/esp_hal_lcd/include/hal/lcd_types.h \ $(PROJECT_PATH)/components/esp_hal_ledc/include/hal/ledc_types.h \ $(PROJECT_PATH)/components/esp_hal_parlio/include/hal/parlio_types.h \ + $(PROJECT_PATH)/components/esp_hal_mcpwm/include/hal/mcpwm_types.h \ $(PROJECT_PATH)/components/esp_hal_mspi/include/hal/esp_flash_err.h \ $(PROJECT_PATH)/components/esp_hal_mspi/include/hal/spi_flash_types.h \ $(PROJECT_PATH)/components/esp_hal_twai/include/hal/twai_types.h \ @@ -270,7 +271,6 @@ INPUT = \ $(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/task.h \ $(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/timers.h \ $(PROJECT_PATH)/components/hal/include/hal/color_types.h \ - $(PROJECT_PATH)/components/hal/include/hal/mcpwm_types.h \ $(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \ $(PROJECT_PATH)/components/hal/include/hal/efuse_hal.h \ $(PROJECT_PATH)/components/hal/include/hal/eth_types.h \ diff --git a/docs/doxygen/Doxyfile_esp32p4 b/docs/doxygen/Doxyfile_esp32p4 index 4b3879522a..df7585741b 100644 --- a/docs/doxygen/Doxyfile_esp32p4 +++ b/docs/doxygen/Doxyfile_esp32p4 @@ -38,7 +38,6 @@ INPUT += \ $(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/esp_hal_cam/include/hal/isp_types.h \ - $(PROJECT_PATH)/components/hal/include/hal/jpeg_types.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_etm.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_i2c.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_spi.h \ diff --git a/docs/en/api-reference/peripherals/mcpwm.rst b/docs/en/api-reference/peripherals/mcpwm.rst index f8b1530dbc..1b82458065 100644 --- a/docs/en/api-reference/peripherals/mcpwm.rst +++ b/docs/en/api-reference/peripherals/mcpwm.rst @@ -1065,7 +1065,7 @@ API Reference .. include-build-file:: inc/mcpwm_cap.inc .. include-build-file:: inc/mcpwm_etm.inc .. include-build-file:: inc/components/esp_driver_mcpwm/include/driver/mcpwm_types.inc -.. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc +.. include-build-file:: inc/components/esp_hal_mcpwm/include/hal/mcpwm_types.inc .. [1] diff --git a/docs/zh_CN/api-reference/peripherals/mcpwm.rst b/docs/zh_CN/api-reference/peripherals/mcpwm.rst index 76c0a17955..a5010ba289 100644 --- a/docs/zh_CN/api-reference/peripherals/mcpwm.rst +++ b/docs/zh_CN/api-reference/peripherals/mcpwm.rst @@ -1065,7 +1065,7 @@ API 参考 .. include-build-file:: inc/mcpwm_cap.inc .. include-build-file:: inc/mcpwm_etm.inc .. include-build-file:: inc/components/esp_driver_mcpwm/include/driver/mcpwm_types.inc -.. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc +.. include-build-file:: inc/components/esp_hal_mcpwm/include/hal/mcpwm_types.inc .. [1]