feat(isp): added isp sharp driver

This commit is contained in:
Armando
2024-07-24 15:47:48 +08:00
parent eff2e4eddd
commit f1b5846a55
18 changed files with 804 additions and 172 deletions

View File

@@ -33,6 +33,21 @@ typedef struct {
uint8_t padding_line_tail_valid_end_pixel; ///< BF edge padding line tail valid end pixel
} isp_hal_bf_cfg_t;
/**
* @brief Sharpen configurations
*/
typedef struct {
isp_sharpen_h_freq_coeff h_freq_coeff; ///< High freq pixel sharpeness coeff
isp_sharpen_m_freq_coeff m_freq_coeff; ///< Medium freq pixel sharpeness coeff
uint8_t h_thresh; ///< High threshold, pixel value higher than this threshold will be multiplied by `h_freq_coeff`
uint8_t l_thresh; ///< Low threshold, pixel value higher than this threshold but lower than `h_thresh` will be multiplied by `m_freq_coeff`. Pixel value lower than this threshold will be set to 0
isp_sharpen_edge_padding_mode_t padding_mode; ///< Sharpen edge padding mode
uint8_t padding_data; ///< Sharpen edge padding pixel data
uint8_t sharpen_template[ISP_SHARPEN_TEMPLATE_X_NUMS][ISP_SHARPEN_TEMPLATE_Y_NUMS]; ///< Sharpen template data
uint8_t padding_line_tail_valid_start_pixel; ///< Sharpen edge padding line tail valid start pixel
uint8_t padding_line_tail_valid_end_pixel; ///< Sharpen edge padding line tail valid end pixel
} isp_hal_sharpen_cfg_t;
/**
* @brief Context that should be maintained by both the driver and the HAL
*/
@@ -77,43 +92,6 @@ void isp_hal_af_window_config(isp_hal_context_t *hal, int window_id, const isp_w
*/
void isp_hal_ae_window_config(isp_hal_context_t *hal, const isp_window_t *window);
/*---------------------------------------------------------------
INTR
---------------------------------------------------------------*/
/**
* @brief Clear ISP HW intr event
*
* @param[in] hal Context of the HAL layer
* @param[in] mask HW event mask
*/
uint32_t isp_hal_check_clear_intr_event(isp_hal_context_t *hal, uint32_t mask);
/*---------------------------------------------------------------
BF
---------------------------------------------------------------*/
/**
* @brief Configure ISP BF registers
*
* @param[in] hal Context of the HAL layer
* @param[in] config BF config, set NULL to de-config the ISP BF
*/
void isp_hal_bf_config(isp_hal_context_t *hal, isp_hal_bf_cfg_t *config);
/*---------------------------------------------------------------
Color Correction Matrix
---------------------------------------------------------------*/
/**
* @brief Set Color Correction Matrix
*
* @param[in] hal Context of the HAL layer
* @param[in] saturation Whether to enable saturation when float data overflow
* @param[in] flt_matrix 3x3 RGB correction matrix
* @return
* - true Set success
* - false Invalid argument
*/
bool isp_hal_ccm_set_matrix(isp_hal_context_t *hal, bool saturation, const float flt_matrix[ISP_CCM_DIMENSION][ISP_CCM_DIMENSION]);
/*---------------------------------------------------------------
AWB
---------------------------------------------------------------*/
@@ -162,6 +140,54 @@ bool isp_hal_awb_set_rg_ratio_range(isp_hal_context_t *hal, float rg_min, float
*/
bool isp_hal_awb_set_bg_ratio_range(isp_hal_context_t *hal, float bg_min, float bg_max);
/*---------------------------------------------------------------
BF
---------------------------------------------------------------*/
/**
* @brief Configure ISP BF
*
* @param[in] hal Context of the HAL layer
* @param[in] config BF config, set NULL to de-config the ISP BF
*/
void isp_hal_bf_config(isp_hal_context_t *hal, isp_hal_bf_cfg_t *config);
/*---------------------------------------------------------------
Color Correction Matrix
---------------------------------------------------------------*/
/**
* @brief Set Color Correction Matrix
*
* @param[in] hal Context of the HAL layer
* @param[in] saturation Whether to enable saturation when float data overflow
* @param[in] flt_matrix 3x3 RGB correction matrix
* @return
* - true Set success
* - false Invalid argument
*/
bool isp_hal_ccm_set_matrix(const isp_hal_context_t *hal, bool saturation, const float flt_matrix[ISP_CCM_DIMENSION][ISP_CCM_DIMENSION]);
/*---------------------------------------------------------------
INTR
---------------------------------------------------------------*/
/**
* @brief Clear ISP HW intr event
*
* @param[in] hal Context of the HAL layer
* @param[in] mask HW event mask
*/
uint32_t isp_hal_check_clear_intr_event(const isp_hal_context_t *hal, uint32_t mask);
/*---------------------------------------------------------------
Sharpness
---------------------------------------------------------------*/
/**
* @brief Configure ISP sharpeness
*
* @param[in] hal Context of the HAL layer
* @param[in] config Sharpness config, set NULL to de-config the ISP sharpness
*/
void isp_hal_sharpen_config(isp_hal_context_t *hal, isp_hal_sharpen_cfg_t *config);
#ifdef __cplusplus
}
#endif

View File

@@ -64,14 +64,26 @@ typedef enum {
} isp_color_t;
/*---------------------------------------------------------------
DVP
AE
---------------------------------------------------------------*/
#if SOC_ISP_DVP_DATA_WIDTH_MAX
#define ISP_DVP_DATA_SIG_NUM SOC_ISP_DVP_DATA_WIDTH_MAX // The ISP DVP data signal number
#if (SOC_ISP_AE_BLOCK_X_NUMS && SOC_ISP_AE_BLOCK_Y_NUMS)
#define ISP_AE_BLOCK_X_NUM SOC_ISP_AE_BLOCK_X_NUMS // The AF window number for sampling
#define ISP_AE_BLOCK_Y_NUM SOC_ISP_AE_BLOCK_Y_NUMS // The AF window number for sampling
#else
#define ISP_DVP_DATA_SIG_NUM 0
#define ISP_AE_BLOCK_X_NUM 0
#define ISP_AE_BLOCK_Y_NUM 0
#endif
/**
* @brief ISP AE input data source
*
*/
typedef enum {
ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, ///< AE input data after demosaic
ISP_AE_SAMPLE_POINT_AFTER_GAMMA, ///< AE input data after gamma
} isp_ae_sample_point_t;
/*---------------------------------------------------------------
AF
---------------------------------------------------------------*/
@@ -81,6 +93,19 @@ typedef enum {
#define ISP_AF_WINDOW_NUM 0
#endif
/*---------------------------------------------------------------
AWB
---------------------------------------------------------------*/
/**
* @brief ISP AWB sample point in the ISP pipeline
*
*/
typedef enum {
ISP_AWB_SAMPLE_POINT_BEFORE_CCM, ///< Sample AWB data before CCM (Color Correction Matrix)
ISP_AWB_SAMPLE_POINT_AFTER_CCM, ///< Sample AWB data after CCM (Color Correction Matrix)
} isp_awb_sample_point_t;
/*---------------------------------------------------------------
BF
---------------------------------------------------------------*/
@@ -110,38 +135,69 @@ typedef enum {
#endif
/*---------------------------------------------------------------
AWB
DVP
---------------------------------------------------------------*/
/**
* @brief ISP AWB sample point in the ISP pipeline
*
*/
typedef enum {
ISP_AWB_SAMPLE_POINT_BEFORE_CCM, ///< Sample AWB data before CCM (Color Correction Matrix)
ISP_AWB_SAMPLE_POINT_AFTER_CCM, ///< Sample AWB data after CCM (Color Correction Matrix)
} isp_awb_sample_point_t;
/*---------------------------------------------------------------
AE
---------------------------------------------------------------*/
#if (SOC_ISP_AE_BLOCK_X_NUMS && SOC_ISP_AE_BLOCK_Y_NUMS)
#define ISP_AE_BLOCK_X_NUM SOC_ISP_AE_BLOCK_X_NUMS // The AF window number for sampling
#define ISP_AE_BLOCK_Y_NUM SOC_ISP_AE_BLOCK_Y_NUMS // The AF window number for sampling
#if SOC_ISP_DVP_DATA_WIDTH_MAX
#define ISP_DVP_DATA_SIG_NUM SOC_ISP_DVP_DATA_WIDTH_MAX // The ISP DVP data signal number
#else
#define ISP_AE_BLOCK_X_NUM 0
#define ISP_AE_BLOCK_Y_NUM 0
#define ISP_DVP_DATA_SIG_NUM 0
#endif
/*---------------------------------------------------------------
Sharpen
---------------------------------------------------------------*/
#if SOC_ISP_SHARPEN_SUPPORTED
#define ISP_SHARPEN_TEMPLATE_X_NUMS SOC_ISP_SHARPEN_TEMPLATE_X_NUMS // Sharpen template x field nums
#define ISP_SHARPEN_TEMPLATE_Y_NUMS SOC_ISP_SHARPEN_TEMPLATE_Y_NUMS // Sharpen template y field nums
#define ISP_SHARPEN_H_FREQ_COEF_INT_BITS SOC_ISP_SHARPEN_H_FREQ_COEF_INT_BITS
#define ISP_SHARPEN_H_FREQ_COEF_DEC_BITS SOC_ISP_SHARPEN_H_FREQ_COEF_DEC_BITS
#define ISP_SHARPEN_H_FREQ_COEF_RES_BITS SOC_ISP_SHARPEN_H_FREQ_COEF_RES_BITS
#define ISP_SHARPEN_M_FREQ_COEF_INT_BITS SOC_ISP_SHARPEN_M_FREQ_COEF_INT_BITS
#define ISP_SHARPEN_M_FREQ_COEF_DEC_BITS SOC_ISP_SHARPEN_M_FREQ_COEF_DEC_BITS
#define ISP_SHARPEN_M_FREQ_COEF_RES_BITS SOC_ISP_SHARPEN_M_FREQ_COEF_RES_BITS
#else
#define ISP_SHARPEN_TEMPLATE_X_NUMS 0
#define ISP_SHARPEN_TEMPLATE_Y_NUMS 0
#define ISP_SHARPEN_H_FREQ_COEF_INT_BITS 8
#define ISP_SHARPEN_H_FREQ_COEF_DEC_BITS 8
#define ISP_SHARPEN_H_FREQ_COEF_RES_BITS 16
#define ISP_SHARPEN_M_FREQ_COEF_INT_BITS 8
#define ISP_SHARPEN_M_FREQ_COEF_DEC_BITS 8
#define ISP_SHARPEN_M_FREQ_COEF_RES_BITS 16
#endif
/**
* @brief ISP AE input data source
*
* @brief High freq pixel sharpeness coeff
*/
typedef union {
struct {
uint32_t decimal:ISP_SHARPEN_H_FREQ_COEF_DEC_BITS; ///< Integer part
uint32_t integer:ISP_SHARPEN_H_FREQ_COEF_INT_BITS; ///< Decimal part
uint32_t reserved:ISP_SHARPEN_H_FREQ_COEF_RES_BITS; ///< Reserved
};
uint32_t val;
} isp_sharpen_h_freq_coeff;
/**
* @brief Medium freq pixel sharpeness coeff
*/
typedef union {
struct {
uint32_t decimal:ISP_SHARPEN_M_FREQ_COEF_DEC_BITS; ///< Integer part
uint32_t integer:ISP_SHARPEN_M_FREQ_COEF_INT_BITS; ///< Decimal part
uint32_t reserved:ISP_SHARPEN_M_FREQ_COEF_RES_BITS; ///< Reserved
};
uint32_t val;
} isp_sharpen_m_freq_coeff;
/**
* @brief ISP Sharpen edge padding mode
*/
typedef enum {
ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, ///< AE input data after demosaic
ISP_AE_SAMPLE_POINT_AFTER_GAMMA, ///< AE input data after gamma
} isp_ae_sample_point_t;
ISP_SHARPEN_EDGE_PADDING_MODE_SRND_DATA, ///< Fill Sharpen edge padding data with surrounding pixel data
ISP_SHARPEN_EDGE_PADDING_MODE_CUSTOM_DATA, ///< Fill Sharpen edge padding data with custom pixel data
} isp_sharpen_edge_padding_mode_t;
#ifdef __cplusplus
}