Merge branch 'bugfix/dvp_isp_yuv_submodule_workaround' into 'master'

fix(isp): fix some submodule dependence for specific isp output format

See merge request espressif/esp-idf!35532
This commit is contained in:
Song Ruo Jing
2024-12-24 12:25:11 +08:00
9 changed files with 20 additions and 60 deletions

View File

@@ -111,7 +111,6 @@ 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
}

View File

@@ -81,7 +81,6 @@ 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);
@@ -155,7 +154,6 @@ 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);

View File

@@ -49,7 +49,6 @@ 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);
@@ -62,7 +61,6 @@ 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);

View File

@@ -145,6 +145,10 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
isp_ll_yuv_set_range(proc->hal.hw, proc_config->yuv_range);
}
if (out_color_format.color_space == COLOR_SPACE_RGB && proc_config->input_data_source == ISP_INPUT_DATA_SOURCE_DVP) {
isp_ll_color_enable(proc->hal.hw, true); // workaround for DIG-474
}
proc->in_color_format = in_color_format;
proc->out_color_format = out_color_format;
proc->h_res = proc_config->h_res;
@@ -390,29 +394,3 @@ 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;
}

View File

@@ -59,7 +59,10 @@ esp_err_t esp_isp_demosaic_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->demosaic_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "demosaic isn't enabled yet");
isp_ll_demosaic_enable(proc->hal.hw, false);
if (proc->out_color_format.color_space == (uint32_t)COLOR_SPACE_RAW) {
// for other out_color_format, demosaic module is needed for rgb interpolation algorithm
isp_ll_demosaic_enable(proc->hal.hw, false);
}
proc->demosaic_fsm = ISP_FSM_INIT;
return ESP_OK;

View File

@@ -51,7 +51,6 @@ 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);
@@ -65,7 +64,6 @@ 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);

View File

@@ -396,15 +396,15 @@ static inline bool isp_ll_set_output_data_color_format(isp_dev_t *hw, color_spac
case COLOR_PIXEL_RGB888:
hw->cntl.isp_out_type = 2;
hw->cntl.demosaic_en = 1;
hw->cntl.rgb2yuv_en = 0;
hw->cntl.yuv2rgb_en = 0;
hw->cntl.rgb2yuv_en = 1;
hw->cntl.yuv2rgb_en = 1;
valid = true;
break;
case COLOR_PIXEL_RGB565:
hw->cntl.isp_out_type = 4;
hw->cntl.demosaic_en = 1;
hw->cntl.rgb2yuv_en = 0;
hw->cntl.yuv2rgb_en = 0;
hw->cntl.rgb2yuv_en = 1;
hw->cntl.yuv2rgb_en = 1;
valid = true;
break;
default:
@@ -456,28 +456,6 @@ 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
*

View File

@@ -597,6 +597,10 @@ After calling :cpp:func:`esp_isp_color_configure`, you need to enable the ISP co
Calling :cpp:func:`esp_isp_color_disable` does the opposite, that is, put the driver back to the **init** state.
.. note::
When the ISP DVP peripheral is used with the output color format set to the RGB color space, :ref:`isp-color` is automatically enabled in the camera driver to ensure correct data output. The function :cpp:func:`esp_isp_color_disable` should never be called in this case, otherwise it may result in disarrayed camera data.
.. _isp-ccm-config:
Configure CCM

View File

@@ -597,6 +597,10 @@ ISP 色彩控制器
调用 :cpp:func:`esp_isp_color_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。
.. note::
当 ISP DVP 外设在使用且输出颜色格式设置为 RGB 色彩空间时,摄像头驱动程序会自动启用 :ref:`isp-color` 以确保数据输出正确。在这种情况下,禁止调用 :cpp:func:`esp_isp_color_disable` 函数,否则可能导致摄像头数据混乱。
.. _isp-ccm-config:
配置 CCM