From a7115b6b36021e4677fe7c4e3e4f9f9550eb00f8 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 30 Oct 2025 17:56:10 +0800 Subject: [PATCH] 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/esp_system/CMakeLists.txt | 1 + components/hal/CMakeLists.txt | 4 ---- docs/doxygen/Doxyfile | 1 + docs/doxygen/Doxyfile_esp32p4 | 1 - docs/en/api-reference/peripherals/jpeg.rst | 2 +- docs/zh_CN/api-reference/peripherals/jpeg.rst | 2 +- 13 files changed, 35 insertions(+), 9 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 f11b56696d..1cdab7607d 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/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index d09f05a906..5d38d8bffe 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -82,6 +82,7 @@ else() esp_hal_wdt esp_hal_lcd esp_hal_mcpwm + esp_hal_jpeg LDFRAGMENTS "linker.lf" "app.lf") add_subdirectory(port) diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index b0dfd60ec0..354b357cd8 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -184,10 +184,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_PPA_SUPPORTED) list(APPEND srcs "ppa_hal.c") endif() diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 84bf5fbf10..06ed3a4174 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -166,6 +166,7 @@ INPUT = \ $(PROJECT_PATH)/components/esp_event/include/esp_event.h \ $(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_jpeg/include/hal/jpeg_types.h \ $(PROJECT_PATH)/components/esp_hal_lcd/include/hal/lcd_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 \ diff --git a/docs/doxygen/Doxyfile_esp32p4 b/docs/doxygen/Doxyfile_esp32p4 index 1d9292344d..03861fc311 100644 --- a/docs/doxygen/Doxyfile_esp32p4 +++ b/docs/doxygen/Doxyfile_esp32p4 @@ -21,7 +21,6 @@ INPUT += \ $(PROJECT_PATH)/components/esp_driver_cam/csi/include/esp_cam_ctlr_csi.h \ $(PROJECT_PATH)/components/esp_driver_cam/isp_dvp/include/esp_cam_ctlr_isp_dvp.h \ $(PROJECT_PATH)/components/hal/include/hal/isp_types.h \ - $(PROJECT_PATH)/components/hal/include/hal/jpeg_types.h \ $(PROJECT_PATH)/components/hal/include/hal/ppa_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 \ 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