mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'feat/isp_driver_use_four_cc' into 'master'
isp: use fourcc for isp color formats Closes IDF-14233 See merge request espressif/esp-idf!44210
This commit is contained in:
@@ -110,12 +110,12 @@ esp_err_t esp_cam_new_isp_dvp_ctlr(isp_proc_handle_t isp_proc, const esp_cam_ctl
|
||||
dvp_ctlr->trans_que = xQueueCreateWithCaps(ctlr_config->queue_items, sizeof(esp_cam_ctlr_trans_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
ESP_GOTO_ON_FALSE(dvp_ctlr->trans_que, ESP_ERR_NO_MEM, err, TAG, "no memory for transaction queue");
|
||||
//in color type
|
||||
int in_bits_per_pixel = color_hal_pixel_format_get_bit_depth(isp_proc->in_color_format);
|
||||
int in_bits_per_pixel = color_hal_pixel_format_fourcc_get_bit_depth(isp_proc->in_color_format);
|
||||
dvp_ctlr->in_bpp = in_bits_per_pixel;
|
||||
ESP_LOGD(TAG, "dvp_ctlr->in_bpp: 0d %d", dvp_ctlr->in_bpp);
|
||||
|
||||
//out color type
|
||||
int out_bits_per_pixel = color_hal_pixel_format_get_bit_depth(isp_proc->out_color_format);
|
||||
int out_bits_per_pixel = color_hal_pixel_format_fourcc_get_bit_depth(isp_proc->out_color_format);
|
||||
dvp_ctlr->out_bpp = out_bits_per_pixel;
|
||||
ESP_LOGD(TAG, "dvp_ctlr->out_bpp: 0d %d", dvp_ctlr->out_bpp);
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ typedef struct isp_processor_t {
|
||||
#endif
|
||||
ISP_ATOMIC_TYPE(isp_fsm_t) isp_fsm;
|
||||
DECLARE_CRIT_SECTION_LOCK_IN_STRUCT(spinlock);
|
||||
color_space_pixel_format_t in_color_format;
|
||||
color_space_pixel_format_t out_color_format;
|
||||
isp_color_t in_color_format;
|
||||
isp_color_t out_color_format;
|
||||
uint32_t h_res;
|
||||
uint32_t v_res;
|
||||
color_raw_element_order_t bayer_order;
|
||||
|
||||
@@ -132,13 +132,10 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
|
||||
INIT_CRIT_SECTION_LOCK_RUNTIME(&proc->spinlock);
|
||||
|
||||
//Input & Output color format
|
||||
color_space_pixel_format_t in_color_format = {
|
||||
.color_type_id = proc_config->input_data_color_type,
|
||||
};
|
||||
color_space_pixel_format_t out_color_format = {
|
||||
.color_type_id = proc_config->output_data_color_type,
|
||||
};
|
||||
int in_bits_per_pixel = color_hal_pixel_format_get_bit_depth(in_color_format);
|
||||
isp_color_t in_color_format = proc_config->input_data_color_type;
|
||||
isp_color_t out_color_format = proc_config->output_data_color_type;
|
||||
|
||||
int in_bits_per_pixel = color_hal_pixel_format_fourcc_get_bit_depth(in_color_format);
|
||||
|
||||
if (!proc_config->flags.bypass_isp) {
|
||||
bool valid_format = false;
|
||||
@@ -167,11 +164,11 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
|
||||
isp_ll_set_intput_data_v_row_num(proc->hal.hw, proc_config->v_res);
|
||||
isp_ll_set_bayer_mode(proc->hal.hw, proc_config->bayer_order);
|
||||
isp_ll_yuv_set_std(proc->hal.hw, proc_config->yuv_std);
|
||||
if (out_color_format.color_space == COLOR_SPACE_YUV) {
|
||||
if (out_color_format == ISP_COLOR_YUV422 || out_color_format == ISP_COLOR_YUV420) {
|
||||
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) {
|
||||
if ((out_color_format == ISP_COLOR_RGB888 || out_color_format == ISP_COLOR_RGB565) && proc_config->input_data_source == ISP_INPUT_DATA_SOURCE_DVP) {
|
||||
isp_ll_color_enable(proc->hal.hw, true); // workaround for DIG-474
|
||||
}
|
||||
if (proc_config->flags.byte_swap_en) {
|
||||
|
||||
@@ -60,7 +60,7 @@ esp_err_t esp_isp_demosaic_disable(isp_proc_handle_t proc)
|
||||
isp_fsm_t expected_fsm = ISP_FSM_ENABLE;
|
||||
ESP_RETURN_ON_FALSE(atomic_compare_exchange_strong(&proc->demosaic_fsm, &expected_fsm, ISP_FSM_INIT), ESP_ERR_INVALID_STATE, TAG, "demosaic isn't enabled yet");
|
||||
|
||||
if (proc->out_color_format.color_space == (uint32_t)COLOR_SPACE_RAW) {
|
||||
if (proc->out_color_format == ISP_COLOR_RAW8 || proc->out_color_format == ISP_COLOR_RAW10 || proc->out_color_format == ISP_COLOR_RAW12) {
|
||||
// for other out_color_format, demosaic module is needed for rgb interpolation algorithm
|
||||
isp_ll_demosaic_enable(proc->hal.hw, false);
|
||||
}
|
||||
|
||||
@@ -393,31 +393,29 @@ static inline void isp_ll_set_input_data_source(isp_dev_t *hw, isp_input_data_so
|
||||
* @brief Set input data color format
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] format color format, see `color_space_pixel_format_t`
|
||||
* @param[in] format color format, see `isp_color_t`
|
||||
*
|
||||
* @return true for valid format, false for invalid format
|
||||
*/
|
||||
static inline bool isp_ll_set_input_data_color_format(isp_dev_t *hw, color_space_pixel_format_t format)
|
||||
static inline bool isp_ll_set_input_data_color_format(isp_dev_t *hw, isp_color_t format)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
if (format.color_space == COLOR_SPACE_RAW) {
|
||||
switch (format.pixel_format) {
|
||||
case COLOR_PIXEL_RAW8:
|
||||
hw->cntl.isp_data_type = 0;
|
||||
valid = true;
|
||||
break;
|
||||
case COLOR_PIXEL_RAW10:
|
||||
hw->cntl.isp_data_type = 1;
|
||||
valid = true;
|
||||
break;
|
||||
case COLOR_PIXEL_RAW12:
|
||||
hw->cntl.isp_data_type = 2;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (format) {
|
||||
case ISP_COLOR_RAW8:
|
||||
hw->cntl.isp_data_type = 0;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RAW10:
|
||||
hw->cntl.isp_data_type = 1;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RAW12:
|
||||
hw->cntl.isp_data_type = 2;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return valid;
|
||||
@@ -449,64 +447,52 @@ static inline void isp_ll_set_intput_data_v_row_num(isp_dev_t *hw, uint32_t row_
|
||||
* @brief Set output data color format
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] format color format, see `color_space_pixel_format_t`
|
||||
* @param[in] format color format, see `isp_color_t`
|
||||
*
|
||||
* @return true for valid format, false for invalid format
|
||||
*/
|
||||
static inline bool isp_ll_set_output_data_color_format(isp_dev_t *hw, color_space_pixel_format_t format)
|
||||
static inline bool isp_ll_set_output_data_color_format(isp_dev_t *hw, isp_color_t format)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
if (format.color_space == COLOR_SPACE_RAW) {
|
||||
switch (format.pixel_format) {
|
||||
case COLOR_PIXEL_RAW8:
|
||||
hw->cntl.isp_out_type = 0;
|
||||
hw->cntl.demosaic_en = 0;
|
||||
hw->cntl.rgb2yuv_en = 0;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (format.color_space == COLOR_SPACE_RGB) {
|
||||
switch (format.pixel_format) {
|
||||
case COLOR_PIXEL_RGB888:
|
||||
hw->cntl.isp_out_type = 2;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
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 = 1;
|
||||
hw->cntl.yuv2rgb_en = 1;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (format.color_space == COLOR_SPACE_YUV) {
|
||||
switch (format.pixel_format) {
|
||||
case COLOR_PIXEL_YUV422:
|
||||
hw->cntl.isp_out_type = 1;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
case COLOR_PIXEL_YUV420:
|
||||
hw->cntl.isp_out_type = 3;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (format) {
|
||||
case ISP_COLOR_RAW8:
|
||||
hw->cntl.isp_out_type = 0;
|
||||
hw->cntl.demosaic_en = 0;
|
||||
hw->cntl.rgb2yuv_en = 0;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RGB888:
|
||||
hw->cntl.isp_out_type = 2;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 1;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RGB565:
|
||||
hw->cntl.isp_out_type = 4;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 1;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_YUV422:
|
||||
hw->cntl.isp_out_type = 1;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_YUV420:
|
||||
hw->cntl.isp_out_type = 3;
|
||||
hw->cntl.demosaic_en = 1;
|
||||
hw->cntl.rgb2yuv_en = 1;
|
||||
hw->cntl.yuv2rgb_en = 0;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return valid;
|
||||
@@ -1144,31 +1130,29 @@ static inline void isp_ll_color_set_brigntness(isp_dev_t *hw, int8_t color_brigh
|
||||
* @brief Set dvp data color format
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] format color format, see `color_space_pixel_format_t`
|
||||
* @param[in] format color format, see `isp_color_t`
|
||||
*
|
||||
* @return true for valid format, false for invalid format
|
||||
*/
|
||||
static inline bool isp_ll_dvp_set_data_type(isp_dev_t *hw, color_space_pixel_format_t format)
|
||||
static inline bool isp_ll_dvp_set_data_type(isp_dev_t *hw, isp_color_t format)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
if (format.color_space == COLOR_SPACE_RAW) {
|
||||
switch (format.pixel_format) {
|
||||
case COLOR_PIXEL_RAW8:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW8;
|
||||
valid = true;
|
||||
break;
|
||||
case COLOR_PIXEL_RAW10:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW10;
|
||||
valid = true;
|
||||
break;
|
||||
case COLOR_PIXEL_RAW12:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW12;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (format) {
|
||||
case ISP_COLOR_RAW8:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW8;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RAW10:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW10;
|
||||
valid = true;
|
||||
break;
|
||||
case ISP_COLOR_RAW12:
|
||||
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW12;
|
||||
valid = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return valid;
|
||||
|
||||
@@ -66,13 +66,13 @@ typedef enum {
|
||||
* @brief ISP Color Type
|
||||
*/
|
||||
typedef enum {
|
||||
ISP_COLOR_RAW8 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW8), ///< RAW8
|
||||
ISP_COLOR_RAW10 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW10), ///< RAW10
|
||||
ISP_COLOR_RAW12 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW12), ///< RAW12
|
||||
ISP_COLOR_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), ///< RGB888
|
||||
ISP_COLOR_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), ///< RGB565
|
||||
ISP_COLOR_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), ///< YUV422
|
||||
ISP_COLOR_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< YUV420
|
||||
ISP_COLOR_RAW8 = ESP_COLOR_FOURCC_RAW8, ///< RAW8
|
||||
ISP_COLOR_RAW10 = ESP_COLOR_FOURCC_RAW10, ///< RAW10
|
||||
ISP_COLOR_RAW12 = ESP_COLOR_FOURCC_RAW12, ///< RAW12
|
||||
ISP_COLOR_RGB888 = ESP_COLOR_FOURCC_BGR24, ///< RGB888
|
||||
ISP_COLOR_RGB565 = ESP_COLOR_FOURCC_RGB16, ///< RGB565
|
||||
ISP_COLOR_YUV422 = ESP_COLOR_FOURCC_UYVY, ///< YUV422 packed in UYVY order
|
||||
ISP_COLOR_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, ///< YUV420
|
||||
} isp_color_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,11 @@ uint32_t color_hal_pixel_format_fourcc_get_bit_depth(esp_color_fourcc_t four_cha
|
||||
return 4;
|
||||
case ESP_COLOR_FOURCC_ALPHA8:
|
||||
case ESP_COLOR_FOURCC_GREY:
|
||||
case ESP_COLOR_FOURCC_RAW8:
|
||||
return 8;
|
||||
case ESP_COLOR_FOURCC_RAW10:
|
||||
return 10;
|
||||
case ESP_COLOR_FOURCC_RAW12:
|
||||
case ESP_COLOR_FOURCC_OUYY_EVYY:
|
||||
return 12;
|
||||
case ESP_COLOR_FOURCC_YUYV:
|
||||
|
||||
@@ -133,6 +133,38 @@ typedef uint32_t esp_color_fourcc_t;
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_OUYY_EVYY ESP_COLOR_FOURCC('O', 'U', 'E', 'V') /* 12 bpp, Espressif Y-U-V 4:2:0 */
|
||||
|
||||
/**
|
||||
* RAW8
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* R0 R1 R2 R3
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RAW8 ESP_COLOR_FOURCC('R', 'A', 'W', '8') /* 8 bpp, raw8 */
|
||||
|
||||
/**
|
||||
* RAW10
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* R0[7:0] R0[1:0] R1[7:0] R1[1:0]
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RAW10 ESP_COLOR_FOURCC('R', 'A', 'W', 'A') /* 10 bpp, raw10 */
|
||||
|
||||
/**
|
||||
* RAW12
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* R0[7:0] R0[3:0] R1[7:0] R1[3:0]
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RAW12 ESP_COLOR_FOURCC('R', 'A', 'W', 'C') /* 12 bpp, raw12 */
|
||||
|
||||
/**
|
||||
* RAW16
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* R0[7:0] R0[7:0] R1[7:0] R1[7:0]
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RAW16 ESP_COLOR_FOURCC('R', 'A', 'W', 'G') /* 16 bpp, raw16 */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color Conversion
|
||||
|
||||
@@ -354,6 +354,7 @@ typedef union {
|
||||
/** Group: csi host color mode control registers. */
|
||||
/** Type of host_cm_ctrl register
|
||||
* CSI HOST color mode convert configuration.
|
||||
* Valid when ISP is bypassed.
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
@@ -362,23 +363,24 @@ typedef union {
|
||||
*/
|
||||
uint32_t csi_host_cm_en:1;
|
||||
/** csi_host_cm_bypass : R/W; bitpos: [1]; default: 1;
|
||||
* Configures whether to bypass cm
|
||||
* Configures whether to bypass cm, input directly to output
|
||||
*/
|
||||
uint32_t csi_host_cm_bypass:1;
|
||||
/** csi_host_cm_rx : R/W; bitpos: [3:2]; default: 0;
|
||||
* Configures whether to bypass cm
|
||||
* 0: RGB888, 1: RGB565, 2: YUV422, 3: YUV420
|
||||
*/
|
||||
uint32_t csi_host_cm_rx:2;
|
||||
/** csi_host_cm_rx_rgb_format : R/W; bitpos: [6:4]; default: 0;
|
||||
* Configures whether to bypass cm
|
||||
* 0: RGB, 1: BGR, 2: RBG, 3: BRG, 4: GRB, 5: GBR
|
||||
*/
|
||||
uint32_t csi_host_cm_rx_rgb_format:3;
|
||||
/** csi_host_cm_rx_yuv422_format : R/W; bitpos: [8:7]; default: 0;
|
||||
* Configures whether to bypass cm
|
||||
* 0: YVYU, 1: YUYV, 2: VYUY, 3: UYVY
|
||||
*/
|
||||
uint32_t csi_host_cm_rx_yuv422_format:2;
|
||||
/** csi_host_cm_tx : R/W; bitpos: [10:9]; default: 0;
|
||||
* Configures whether to bypass cm
|
||||
* 0: RGB888, 1: RGB565, 2: YUV422, 3: YUV420
|
||||
*/
|
||||
uint32_t csi_host_cm_tx:2;
|
||||
/** csi_host_cm_lane_num : R/W; bitpos: [11]; default: 1;
|
||||
|
||||
Reference in New Issue
Block a user