feat(isp): added isp yuv2rgb / rgb2yuv configs

This commit is contained in:
Armando 2024-08-19 18:07:34 +08:00 committed by Armando (Dou Yiwen)
parent c01ccd1f62
commit e9f65051e7
4 changed files with 79 additions and 0 deletions

View File

@ -24,6 +24,8 @@ typedef struct {
isp_input_data_source_t input_data_source; ///< Input data source
isp_color_t input_data_color_type; ///< Input color type
isp_color_t output_data_color_type; ///< Output color type
isp_color_range_t yuv_range; ///< When the `output_data_color_type` is any YUV color space, this field is to describe its color range
isp_yuv_conv_std_t yuv_std; ///< This field is to describe YUV<->RGB conversion standard
bool has_line_start_packet; ///< Enable line start packet
bool has_line_end_packet; ///< Enable line end packet
uint32_t h_res; ///< Input horizontal resolution, i.e. the number of pixels in a line

View File

@ -136,6 +136,10 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
isp_ll_enable_line_end_packet_exist(proc->hal.hw, proc_config->has_line_end_packet);
isp_ll_set_intput_data_h_pixel_num(proc->hal.hw, proc_config->h_res);
isp_ll_set_intput_data_v_row_num(proc->hal.hw, proc_config->v_res);
isp_ll_yuv_set_std(proc->hal.hw, proc_config->yuv_std);
if (out_color_format.color_space == COLOR_SPACE_YUV) {
isp_ll_yuv_set_range(proc->hal.hw, proc_config->yuv_range);
}
proc->in_color_format = in_color_format;
proc->out_color_format = out_color_format;

View File

@ -1486,6 +1486,63 @@ static inline uint8_t isp_ll_sharp_get_high_freq_pixel_max(isp_dev_t *hw)
return hw->sharp_ctrl1.sharp_gradient_max;
}
/*---------------------------------------------------------------
RGB/YUV
---------------------------------------------------------------*/
/**
* @brief Enable / Disable rgb2yuv clock
*
* @param[in] hw Hardware instance address
* @param[in] enable 0: hw control; 1: always on
*/
static inline void isp_ll_rgb2yuv_clk_enable(isp_dev_t *hw, bool enable)
{
hw->clk_en.clk_rgb2yuv_force_on = enable;
}
/**
* @brief Enable / Disable yuv2rgb clock
*
* @param[in] hw Hardware instance address
* @param[in] enable 0: hw control; 1: always on
*/
static inline void isp_ll_yuv2rgb_clk_enable(isp_dev_t *hw, bool enable)
{
hw->clk_en.clk_yuv2rgb_force_on = enable;
}
/**
* @brief Set YUV range
*
* @param[in] hw Hardware instance address
* @param[in] range see `isp_color_range_t`
*/
static inline void isp_ll_yuv_set_range(isp_dev_t *hw, isp_color_range_t range)
{
switch (range) {
case ISP_COLOR_RANGE_LIMIT:
hw->yuv_format.yuv_range = 1;
break;
case ISP_COLOR_RANGE_FULL:
hw->yuv_format.yuv_range = 0;
break;
default:
// Unsupported color range
abort();
}
}
/**
* @brief Set YUV standard
*
* @param[in] hw Hardware instance address
* @param[in] std see `isp_yuv_conv_std_t`
*/
static inline void isp_ll_yuv_set_std(isp_dev_t *hw, isp_yuv_conv_std_t std)
{
hw->yuv_format.yuv_mode = std;
}
#ifdef __cplusplus
}
#endif

View File

@ -63,6 +63,22 @@ typedef enum {
ISP_COLOR_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< YUV420
} isp_color_t;
/**
* @brief ISP color range
*/
typedef enum {
ISP_COLOR_RANGE_LIMIT = COLOR_RANGE_LIMIT, /*!< Limited color range */
ISP_COLOR_RANGE_FULL = COLOR_RANGE_FULL, /*!< Full color range */
} isp_color_range_t;
/**
* @brief The standard used for conversion between RGB and YUV
*/
typedef enum {
ISP_YUV_CONV_STD_BT601 = COLOR_CONV_STD_RGB_YUV_BT601, /*!< YUV<->RGB conversion standard: BT.601 */
ISP_YUV_CONV_STD_BT709 = COLOR_CONV_STD_RGB_YUV_BT709, /*!< YUV<->RGB conversion standard: BT.709 */
} isp_yuv_conv_std_t;
/*---------------------------------------------------------------
AE
---------------------------------------------------------------*/