diff --git a/components/esp_driver_isp/include/esp_private/isp_private.h b/components/esp_driver_isp/include/esp_private/isp_private.h index a0e6913ca5..34d3a0bdb7 100644 --- a/components/esp_driver_isp/include/esp_private/isp_private.h +++ b/components/esp_driver_isp/include/esp_private/isp_private.h @@ -111,6 +111,7 @@ bool esp_isp_ae_isr(isp_proc_handle_t proc, uint32_t ae_events); bool esp_isp_awb_isr(isp_proc_handle_t proc, uint32_t awb_events); bool esp_isp_sharpen_isr(isp_proc_handle_t proc, uint32_t sharp_events); bool esp_isp_hist_isr(isp_proc_handle_t proc, uint32_t hist_events); +esp_err_t esp_isp_enable_yuv_submodules(isp_proc_handle_t proc, bool en); #ifdef __cplusplus } diff --git a/components/esp_driver_isp/src/isp_af.c b/components/esp_driver_isp/src/isp_af.c index 28c2055328..2257103bb5 100644 --- a/components/esp_driver_isp/src/isp_af.c +++ b/components/esp_driver_isp/src/isp_af.c @@ -81,6 +81,7 @@ esp_err_t esp_isp_new_af_controller(isp_proc_handle_t isp_proc, const esp_isp_af { esp_err_t ret = ESP_FAIL; ESP_RETURN_ON_FALSE(isp_proc && af_config && ret_hdl, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(isp_proc, true), TAG, "failed to enable YUV submodules"); bool rgb2yuv_en = isp_ll_is_rgb2yuv_enabled(isp_proc->hal.hw); bool demosaic_en = isp_ll_is_demosaic_enabled(isp_proc->hal.hw); @@ -154,6 +155,7 @@ esp_err_t esp_isp_del_af_controller(isp_af_ctlr_t af_ctlr) // Deregister the AF ISR ESP_RETURN_ON_FALSE(esp_isp_deregister_isr(af_ctlr->isp_proc, ISP_SUBMODULE_AF) == ESP_OK, ESP_FAIL, TAG, "fail to deregister ISR"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(af_ctlr->isp_proc, false), TAG, "failed to disable YUV submodules"); s_isp_declaim_af_controller(af_ctlr); s_isp_af_free_controller(af_ctlr); diff --git a/components/esp_driver_isp/src/isp_color.c b/components/esp_driver_isp/src/isp_color.c index 09e118c626..f2430d1eb8 100644 --- a/components/esp_driver_isp/src/isp_color.c +++ b/components/esp_driver_isp/src/isp_color.c @@ -49,6 +49,7 @@ esp_err_t esp_isp_color_enable(isp_proc_handle_t proc) { ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(proc->color_fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "color is enabled already"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(proc, true), TAG, "failed to enable YUV submodules"); isp_ll_color_clk_enable(proc->hal.hw, true); isp_ll_color_enable(proc->hal.hw, true); @@ -61,6 +62,7 @@ esp_err_t esp_isp_color_disable(isp_proc_handle_t proc) { ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(proc->color_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "color isn't enabled yet"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(proc, false), TAG, "failed to disable YUV submodules"); isp_ll_color_enable(proc->hal.hw, false); isp_ll_color_clk_enable(proc->hal.hw, false); diff --git a/components/esp_driver_isp/src/isp_core.c b/components/esp_driver_isp/src/isp_core.c index f964aaa1cc..b39865ce29 100644 --- a/components/esp_driver_isp/src/isp_core.c +++ b/components/esp_driver_isp/src/isp_core.c @@ -390,3 +390,29 @@ esp_err_t esp_isp_deregister_isr(isp_proc_handle_t proc, isp_submodule_t submodu return ESP_OK; } + +esp_err_t esp_isp_enable_yuv_submodules(isp_proc_handle_t proc, bool en) +{ + ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); + + bool rgb2yuv = false; + bool yuv2rgb = false; + + if (proc->out_color_format.color_space == COLOR_SPACE_RGB) { + rgb2yuv = true; + yuv2rgb = true; + } else if (proc->out_color_format.color_space == COLOR_SPACE_YUV) { + rgb2yuv = true; + } + + portENTER_CRITICAL(&proc->spinlock); + if (rgb2yuv) { + isp_ll_enable_rgb2yuv(proc->hal.hw, en); + } + if (yuv2rgb) { + isp_ll_enable_yuv2rgb(proc->hal.hw, en); + } + portEXIT_CRITICAL(&proc->spinlock); + + return ESP_OK; +} diff --git a/components/esp_driver_isp/src/isp_sharpen.c b/components/esp_driver_isp/src/isp_sharpen.c index abd88956ce..84722aa884 100644 --- a/components/esp_driver_isp/src/isp_sharpen.c +++ b/components/esp_driver_isp/src/isp_sharpen.c @@ -51,6 +51,7 @@ esp_err_t esp_isp_sharpen_enable(isp_proc_handle_t proc) { ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(proc->sharpen_fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "sharpen is enabled already"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(proc, true), TAG, "failed to enable YUV submodules"); isp_ll_sharp_clk_enable(proc->hal.hw, true); isp_ll_enable_intr(proc->hal.hw, ISP_LL_EVENT_SHARP_FRAME, true); @@ -64,6 +65,7 @@ esp_err_t esp_isp_sharpen_disable(isp_proc_handle_t proc) { ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(proc->sharpen_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "sharpen isn't enabled yet"); + ESP_RETURN_ON_ERROR(esp_isp_enable_yuv_submodules(proc, false), TAG, "failed to disable YUV submodules"); isp_ll_sharp_enable(proc->hal.hw, false); isp_ll_enable_intr(proc->hal.hw, ISP_LL_EVENT_SHARP_FRAME, false); diff --git a/components/hal/esp32p4/include/hal/isp_ll.h b/components/hal/esp32p4/include/hal/isp_ll.h index bcb5312d07..9eb827208d 100644 --- a/components/hal/esp32p4/include/hal/isp_ll.h +++ b/components/hal/esp32p4/include/hal/isp_ll.h @@ -456,6 +456,28 @@ static inline void isp_ll_enable_line_end_packet_exist(isp_dev_t *hw, bool en) hw->frame_cfg.hsync_end_exist = en; } +/** + * @brief Enable rgb2yuv + * + * @param[in] hw Hardware instance address + * @param[in] en Enable / Disable + */ +static inline void isp_ll_enable_rgb2yuv(isp_dev_t *hw, bool en) +{ + hw->cntl.rgb2yuv_en = en; +} + +/** + * @brief Enable yuv2rgb + * + * @param[in] hw Hardware instance address + * @param[in] en Enable / Disable + */ +static inline void isp_ll_enable_yuv2rgb(isp_dev_t *hw, bool en) +{ + hw->cntl.yuv2rgb_en = en; +} + /** * @brief Get if demosaic is enabled * diff --git a/examples/peripherals/isp/multi_pipelines/main/example_config.h b/examples/peripherals/isp/multi_pipelines/main/example_config.h index 00775fd4c4..9c5482fe39 100644 --- a/examples/peripherals/isp/multi_pipelines/main/example_config.h +++ b/examples/peripherals/isp/multi_pipelines/main/example_config.h @@ -14,6 +14,26 @@ extern "C" { #define EXAMPLE_MIPI_SCCB_FREQ (100000) #define EXAMPLE_MIPI_CSI_LANE_BITRATE_MBPS 200 //line_rate = pclk * 4 +#define EXAMPLE_MIPI_CSI_CAM_SCCB_SCL_IO (8) +#define EXAMPLE_MIPI_CSI_CAM_SCCB_SDA_IO (7) + +#if CONFIG_EXAMPLE_MIPI_CSI_HRES_800 + +#if CONFIG_EXAMPLE_MIPI_CSI_VRES_640 +#define EXAMPLE_CAM_FORMAT "MIPI_2lane_24Minput_RAW8_800x640_50fps" +#elif CONFIG_EXAMPLE_MIPI_CSI_VRES_800 +#define EXAMPLE_CAM_FORMAT "MIPI_2lane_24Minput_RAW8_800x800_50fps" +#elif CONFIG_EXAMPLE_MIPI_CSI_VRES_1280 +#define EXAMPLE_CAM_FORMAT "MIPI_2lane_24Minput_RAW8_800x1280_50fps" +#endif + +#elif CONFIG_EXAMPLE_MIPI_CSI_HRES_1024 + +#if CONFIG_EXAMPLE_MIPI_CSI_VRES_600 +#define EXAMPLE_CAM_FORMAT "MIPI_2lane_24Minput_RAW8_1024x600_30fps" +#endif + +#endif #define EXAMPLE_DW9714_DEV_ADDR 0xC #ifdef __cplusplus } diff --git a/examples/peripherals/isp/multi_pipelines/main/idf_component.yml b/examples/peripherals/isp/multi_pipelines/main/idf_component.yml index 678ac3c33b..3081b5cd82 100644 --- a/examples/peripherals/isp/multi_pipelines/main/idf_component.yml +++ b/examples/peripherals/isp/multi_pipelines/main/idf_component.yml @@ -1,5 +1,5 @@ dependencies: - espressif/esp_cam_sensor: "^0.5.*" + espressif/esp_cam_sensor: ">=0.5.*" idf: version: ">=5.3.0" isp_af_schemes: diff --git a/examples/peripherals/isp/multi_pipelines/main/isp_dsi_main.c b/examples/peripherals/isp/multi_pipelines/main/isp_dsi_main.c index 3f2db636db..67d1a3d857 100644 --- a/examples/peripherals/isp/multi_pipelines/main/isp_dsi_main.c +++ b/examples/peripherals/isp/multi_pipelines/main/isp_dsi_main.c @@ -224,7 +224,14 @@ void app_main(void) //--------Camera Sensor and SCCB Init-----------// i2c_master_bus_handle_t i2c_bus_handle = NULL; - example_sensor_init(I2C_NUM_0, &i2c_bus_handle); + example_sensor_config_t cam_sensor_config = { + .i2c_port_num = I2C_NUM_0, + .i2c_sda_io_num = EXAMPLE_MIPI_CSI_CAM_SCCB_SDA_IO, + .i2c_scl_io_num = EXAMPLE_MIPI_CSI_CAM_SCCB_SCL_IO, + .port = ESP_CAM_SENSOR_MIPI_CSI, + .format_name = EXAMPLE_CAM_FORMAT, + }; + example_sensor_init(&cam_sensor_config, &i2c_bus_handle); //---------------VCM SCCB Init------------------// esp_sccb_io_handle_t dw9714_io_handle = NULL;