feat(isp): support AWB driver setting wbgain and subwindow feature
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "hal/hal_utils.h"
|
||||
#include "hal/isp_types.h"
|
||||
#include "hal/color_types.h"
|
||||
#include "hal/config.h"
|
||||
#include "soc/isp_struct.h"
|
||||
#include "soc/hp_sys_clkrst_struct.h"
|
||||
#include "soc/clk_tree_defs.h"
|
||||
@@ -65,11 +66,14 @@ extern "C" {
|
||||
#define ISP_LL_EVENT_YUV2RGB_FRAME (1<<26)
|
||||
#define ISP_LL_EVENT_TAIL_IDI_FRAME (1<<27)
|
||||
#define ISP_LL_EVENT_HEADER_IDI_FRAME (1<<28)
|
||||
#define ISP_LL_EVENT_CROP_FRAME (1<<29)
|
||||
#define ISP_LL_EVENT_WBG_FRAME (1<<30)
|
||||
#define ISP_LL_EVENT_CROP_ERR (1<<31)
|
||||
|
||||
#define ISP_LL_EVENT_ALL_MASK (0x1FFFFFFF)
|
||||
#define ISP_LL_EVENT_AF_MASK (ISP_LL_EVENT_AF_FDONE | ISP_LL_EVENT_AF_ENV)
|
||||
#define ISP_LL_EVENT_AE_MASK (ISP_LL_EVENT_AE_FDONE | ISP_LL_EVENT_AE_ENV)
|
||||
#define ISP_LL_EVENT_AWB_MASK (ISP_LL_EVENT_AWB_FDONE)
|
||||
#define ISP_LL_EVENT_AWB_MASK (ISP_LL_EVENT_AWB_FDONE | ISP_LL_EVENT_WBG_FRAME)
|
||||
#define ISP_LL_EVENT_SHARP_MASK (ISP_LL_EVENT_SHARP_FRAME)
|
||||
#define ISP_LL_EVENT_HIST_MASK (ISP_LL_EVENT_HIST_FDONE)
|
||||
#define ISP_LL_EVENT_COLOR_MASK (ISP_LL_EVENT_COLOR_FRAME)
|
||||
@@ -165,8 +169,19 @@ typedef union {
|
||||
typedef enum {
|
||||
ISP_LL_LUT_LSC, ///< LUT for LSC
|
||||
ISP_LL_LUT_DPC, ///< LUT for DPC
|
||||
ISP_LL_LUT_AWB, ///< LUT for AWB
|
||||
} isp_ll_lut_t;
|
||||
|
||||
/**
|
||||
* @brief ISP LUT AWB type
|
||||
*/
|
||||
typedef enum {
|
||||
ISP_LL_LUT_AWB_WHITE_PATCH_CNT, ///< White patch count
|
||||
ISP_LL_LUT_AWB_ACCUMULATED_R, ///< Accumulated R
|
||||
ISP_LL_LUT_AWB_ACCUMULATED_G, ///< Accumulated G
|
||||
ISP_LL_LUT_AWB_ACCUMULATED_B, ///< Accumulated B
|
||||
} isp_ll_lut_awb_t;
|
||||
|
||||
/**
|
||||
* @brief ISP pipeline clock control mode
|
||||
*/
|
||||
@@ -1344,7 +1359,7 @@ static inline void isp_ll_lsc_set_xtablesize(isp_dev_t *hw, uint8_t xtablesize)
|
||||
LUT
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Select ISP LUT
|
||||
* @brief Select ISP LUT for LSC usage
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] is_write Is write or not
|
||||
@@ -1352,7 +1367,7 @@ static inline void isp_ll_lsc_set_xtablesize(isp_dev_t *hw, uint8_t xtablesize)
|
||||
* @param[in] addr LUT addr
|
||||
* @param[in] lut ISP LUT
|
||||
*/
|
||||
static inline void isp_ll_lut_set_cmd(isp_dev_t *hw, bool is_write, bool is_gb_b, uint32_t addr, isp_ll_lut_t lut)
|
||||
static inline void isp_ll_lut_lsc_set_cmd(isp_dev_t *hw, bool is_write, bool is_gb_b, uint32_t addr, isp_ll_lut_t lut)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
val |= is_write ? (1 << 16) : 0;
|
||||
@@ -1369,7 +1384,7 @@ static inline void isp_ll_lut_set_cmd(isp_dev_t *hw, bool is_write, bool is_gb_b
|
||||
* @param[in] gb_gain gb gain
|
||||
* @param[in] b_gain b gain
|
||||
*/
|
||||
static inline void isp_ll_lut_set_wdata_gb_b(isp_dev_t *hw, isp_lsc_gain_t gb_gain, isp_lsc_gain_t b_gain)
|
||||
static inline void isp_ll_lut_lsc_set_wdata_gb_b(isp_dev_t *hw, isp_lsc_gain_t gb_gain, isp_lsc_gain_t b_gain)
|
||||
{
|
||||
hw->lut_wdata.lut_wdata = (gb_gain.val & 0x3ff) << 10 | (b_gain.val & 0x3ff);
|
||||
}
|
||||
@@ -1381,11 +1396,75 @@ static inline void isp_ll_lut_set_wdata_gb_b(isp_dev_t *hw, isp_lsc_gain_t gb_ga
|
||||
* @param[in] r_gain r gain
|
||||
* @param[in] gr_gain gr gain
|
||||
*/
|
||||
static inline void isp_ll_lut_set_wdata_r_gr(isp_dev_t *hw, isp_lsc_gain_t r_gain, isp_lsc_gain_t gr_gain)
|
||||
static inline void isp_ll_lut_lsc_set_wdata_r_gr(isp_dev_t *hw, isp_lsc_gain_t r_gain, isp_lsc_gain_t gr_gain)
|
||||
{
|
||||
hw->lut_wdata.lut_wdata = (r_gain.val & 0x3ff) << 10 | (gr_gain.val & 0x3ff);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set AWB LUT command
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] type ISP LUT AWB type
|
||||
* @param[in] addr AWB sub window ID
|
||||
*/
|
||||
static inline void isp_ll_lut_awb_set_cmd(isp_dev_t *hw, isp_ll_lut_awb_t type, uint32_t sub_window_id, isp_ll_lut_t lut)
|
||||
{
|
||||
HAL_ASSERT(sub_window_id <= 25);
|
||||
uint32_t val = 0;
|
||||
val |= 0x2000 + 4 * sub_window_id + type;
|
||||
val |= lut << 12;
|
||||
hw->lut_cmd.val = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get AWB statistics of subwindow white patch count
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
*
|
||||
* @return White patch number
|
||||
*/
|
||||
static inline uint32_t isp_ll_lut_awb_get_subwindow_white_patch_cnt(isp_dev_t *hw)
|
||||
{
|
||||
return hw->lut_rdata.lut_rdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get AWB statistics of subwindow accumulated R
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
*
|
||||
* @return Accumulated R
|
||||
*/
|
||||
static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_r(isp_dev_t *hw)
|
||||
{
|
||||
return hw->lut_rdata.lut_rdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get AWB statistics of subwindow accumulated G
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
*
|
||||
* @return Accumulated G
|
||||
*/
|
||||
static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_g(isp_dev_t *hw)
|
||||
{
|
||||
return hw->lut_rdata.lut_rdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get AWB statistics of subwindow accumulated B
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
*
|
||||
* @return Accumulated B
|
||||
*/
|
||||
static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_b(isp_dev_t *hw)
|
||||
{
|
||||
return hw->lut_rdata.lut_rdata;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
INTR
|
||||
---------------------------------------------------------------*/
|
||||
@@ -1614,6 +1693,43 @@ static inline uint32_t isp_ll_awb_get_accumulated_b_value(isp_dev_t *hw)
|
||||
return hw->awb0_acc_b.awb0_acc_b;
|
||||
}
|
||||
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
/**
|
||||
* @brief Enable AWB white balance gain
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] enable Enable / Disable
|
||||
*/
|
||||
static inline void isp_ll_awb_enable_wb_gain(isp_dev_t *hw, bool enable)
|
||||
{
|
||||
hw->cntl.wbg_en = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set AWB white balance gain clock control mode
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] mode 'isp_ll_pipeline_clk_ctrl_t`
|
||||
*/
|
||||
static inline void isp_ll_awb_set_wb_gain_clk_ctrl_mode(isp_dev_t *hw, isp_ll_pipeline_clk_ctrl_t mode)
|
||||
{
|
||||
hw->clk_en.clk_wbg_force_on = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set AWB white balance gain
|
||||
*
|
||||
* @param[in] hw Hardware instance address
|
||||
* @param[in] gain AWB white balance gain
|
||||
*/
|
||||
static inline void isp_ll_awb_set_wb_gain(isp_dev_t *hw, isp_awb_gain_t gain)
|
||||
{
|
||||
hw->wbg_coef_r.wbg_r = gain.gain_r;
|
||||
hw->wbg_coef_g.wbg_g = gain.gain_g;
|
||||
hw->wbg_coef_b.wbg_b = gain.gain_b;
|
||||
}
|
||||
#endif //#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Demosaic
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user