1515#include "hal/config.h"
1616#include "hal/isp_types.h"
1717#include "hal/color_types.h"
18+ #include "hal/config.h"
1819#include "soc/isp_struct.h"
1920#include "soc/hp_sys_clkrst_struct.h"
2021#include "soc/clk_tree_defs.h"
@@ -67,11 +68,14 @@ extern "C" {
6768#define ISP_LL_EVENT_YUV2RGB_FRAME (1<<26)
6869#define ISP_LL_EVENT_TAIL_IDI_FRAME (1<<27)
6970#define ISP_LL_EVENT_HEADER_IDI_FRAME (1<<28)
71+ #define ISP_LL_EVENT_CROP_FRAME (1<<29)
72+ #define ISP_LL_EVENT_WBG_FRAME (1<<30)
73+ #define ISP_LL_EVENT_CROP_ERR (1<<31)
7074
7175#define ISP_LL_EVENT_ALL_MASK (0x1FFFFFFF)
7276#define ISP_LL_EVENT_AF_MASK (ISP_LL_EVENT_AF_FDONE | ISP_LL_EVENT_AF_ENV)
7377#define ISP_LL_EVENT_AE_MASK (ISP_LL_EVENT_AE_FDONE | ISP_LL_EVENT_AE_ENV)
74- #define ISP_LL_EVENT_AWB_MASK (ISP_LL_EVENT_AWB_FDONE)
78+ #define ISP_LL_EVENT_AWB_MASK (ISP_LL_EVENT_AWB_FDONE | ISP_LL_EVENT_WBG_FRAME )
7579#define ISP_LL_EVENT_SHARP_MASK (ISP_LL_EVENT_SHARP_FRAME)
7680#define ISP_LL_EVENT_HIST_MASK (ISP_LL_EVENT_HIST_FDONE)
7781#define ISP_LL_EVENT_COLOR_MASK (ISP_LL_EVENT_COLOR_FRAME)
@@ -172,8 +176,19 @@ typedef union {
172176typedef enum {
173177 ISP_LL_LUT_LSC , ///< LUT for LSC
174178 ISP_LL_LUT_DPC , ///< LUT for DPC
179+ ISP_LL_LUT_AWB , ///< LUT for AWB
175180} isp_ll_lut_t ;
176181
182+ /**
183+ * @brief ISP LUT AWB type
184+ */
185+ typedef enum {
186+ ISP_LL_LUT_AWB_WHITE_PATCH_CNT , ///< White patch count
187+ ISP_LL_LUT_AWB_ACCUMULATED_R , ///< Accumulated R
188+ ISP_LL_LUT_AWB_ACCUMULATED_G , ///< Accumulated G
189+ ISP_LL_LUT_AWB_ACCUMULATED_B , ///< Accumulated B
190+ } isp_ll_lut_awb_t ;
191+
177192/**
178193 * @brief ISP pipeline clock control mode
179194 */
@@ -1366,15 +1381,15 @@ static inline void isp_ll_lsc_set_xtablesize(isp_dev_t *hw, uint8_t xtablesize)
13661381 LUT
13671382---------------------------------------------------------------*/
13681383/**
1369- * @brief Select ISP LUT
1384+ * @brief Select ISP LUT for LSC usage
13701385 *
13711386 * @param[in] hw Hardware instance address
13721387 * @param[in] is_write Is write or not
13731388 * @param[in] is_gb_b Is gb_b or not
13741389 * @param[in] addr LUT addr
13751390 * @param[in] lut ISP LUT
13761391 */
1377- 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 )
1392+ 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 )
13781393{
13791394 uint32_t val = 0 ;
13801395 val |= is_write ? (1 << 16 ) : 0 ;
@@ -1391,7 +1406,7 @@ static inline void isp_ll_lut_set_cmd(isp_dev_t *hw, bool is_write, bool is_gb_b
13911406 * @param[in] gb_gain gb gain
13921407 * @param[in] b_gain b gain
13931408 */
1394- 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 )
1409+ 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 )
13951410{
13961411 hw -> lut_wdata .lut_wdata = (gb_gain .val & 0x3ff ) << 10 | (b_gain .val & 0x3ff );
13971412}
@@ -1403,11 +1418,75 @@ static inline void isp_ll_lut_set_wdata_gb_b(isp_dev_t *hw, isp_lsc_gain_t gb_ga
14031418 * @param[in] r_gain r gain
14041419 * @param[in] gr_gain gr gain
14051420 */
1406- 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 )
1421+ 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 )
14071422{
14081423 hw -> lut_wdata .lut_wdata = (r_gain .val & 0x3ff ) << 10 | (gr_gain .val & 0x3ff );
14091424}
14101425
1426+ /**
1427+ * @brief Set AWB LUT command
1428+ *
1429+ * @param[in] hw Hardware instance address
1430+ * @param[in] type ISP LUT AWB type
1431+ * @param[in] addr AWB sub window ID
1432+ */
1433+ 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 )
1434+ {
1435+ HAL_ASSERT (sub_window_id <= 25 );
1436+ uint32_t val = 0 ;
1437+ val |= 0x2000 + 4 * sub_window_id + type ;
1438+ val |= lut << 12 ;
1439+ hw -> lut_cmd .val = val ;
1440+ }
1441+
1442+ /**
1443+ * @brief Get AWB statistics of subwindow white patch count
1444+ *
1445+ * @param[in] hw Hardware instance address
1446+ *
1447+ * @return White patch number
1448+ */
1449+ static inline uint32_t isp_ll_lut_awb_get_subwindow_white_patch_cnt (isp_dev_t * hw )
1450+ {
1451+ return hw -> lut_rdata .lut_rdata ;
1452+ }
1453+
1454+ /**
1455+ * @brief Get AWB statistics of subwindow accumulated R
1456+ *
1457+ * @param[in] hw Hardware instance address
1458+ *
1459+ * @return Accumulated R
1460+ */
1461+ static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_r (isp_dev_t * hw )
1462+ {
1463+ return hw -> lut_rdata .lut_rdata ;
1464+ }
1465+
1466+ /**
1467+ * @brief Get AWB statistics of subwindow accumulated G
1468+ *
1469+ * @param[in] hw Hardware instance address
1470+ *
1471+ * @return Accumulated G
1472+ */
1473+ static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_g (isp_dev_t * hw )
1474+ {
1475+ return hw -> lut_rdata .lut_rdata ;
1476+ }
1477+
1478+ /**
1479+ * @brief Get AWB statistics of subwindow accumulated B
1480+ *
1481+ * @param[in] hw Hardware instance address
1482+ *
1483+ * @return Accumulated B
1484+ */
1485+ static inline uint32_t isp_ll_lut_awb_get_subwindow_accumulated_b (isp_dev_t * hw )
1486+ {
1487+ return hw -> lut_rdata .lut_rdata ;
1488+ }
1489+
14111490/*---------------------------------------------------------------
14121491 INTR
14131492---------------------------------------------------------------*/
@@ -1636,6 +1715,43 @@ static inline uint32_t isp_ll_awb_get_accumulated_b_value(isp_dev_t *hw)
16361715 return hw -> awb0_acc_b .awb0_acc_b ;
16371716}
16381717
1718+ #if HAL_CONFIG (CHIP_SUPPORT_MIN_REV ) >= 300
1719+ /**
1720+ * @brief Enable AWB white balance gain
1721+ *
1722+ * @param[in] hw Hardware instance address
1723+ * @param[in] enable Enable / Disable
1724+ */
1725+ static inline void isp_ll_awb_enable_wb_gain (isp_dev_t * hw , bool enable )
1726+ {
1727+ hw -> cntl .wbg_en = enable ;
1728+ }
1729+
1730+ /**
1731+ * @brief Set AWB white balance gain clock control mode
1732+ *
1733+ * @param[in] hw Hardware instance address
1734+ * @param[in] mode 'isp_ll_pipeline_clk_ctrl_t`
1735+ */
1736+ static inline void isp_ll_awb_set_wb_gain_clk_ctrl_mode (isp_dev_t * hw , isp_ll_pipeline_clk_ctrl_t mode )
1737+ {
1738+ hw -> clk_en .clk_wbg_force_on = mode ;
1739+ }
1740+
1741+ /**
1742+ * @brief Set AWB white balance gain
1743+ *
1744+ * @param[in] hw Hardware instance address
1745+ * @param[in] gain AWB white balance gain
1746+ */
1747+ static inline void isp_ll_awb_set_wb_gain (isp_dev_t * hw , isp_awb_gain_t gain )
1748+ {
1749+ hw -> wbg_coef_r .wbg_r = gain .gain_r ;
1750+ hw -> wbg_coef_g .wbg_g = gain .gain_g ;
1751+ hw -> wbg_coef_b .wbg_b = gain .gain_b ;
1752+ }
1753+ #endif //#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
1754+
16391755/*---------------------------------------------------------------
16401756 Demosaic
16411757---------------------------------------------------------------*/
0 commit comments