xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/algos/alsc/rk_aiq_types_alsc_algo_prvt.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *rk_aiq_types_alsc_algo_prvt.h
3  *
4  *  Copyright (c) 2019 Rockchip Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 
20 #ifndef _RK_AIQ_TYPES_ALSC_ALGO_PRVT_H_
21 #define _RK_AIQ_TYPES_ALSC_ALGO_PRVT_H_
22 
23 #include "rk_aiq_types.h"
24 #include "rk_aiq_types_alsc_algo_int.h"
25 #include "alsc_head.h"
26 #include "xcam_log.h"
27 #include "xcam_common.h"
28 #include "common/list.h"
29 #include "RkAiqCalibDbV2Helper.h"
30 
31 RKAIQ_BEGIN_DECLARE
32 
33 typedef enum AlscState_e {
34     ALSC_STATE_INVALID           = 0,                   /**< initialization value */
35     ALSC_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
36     ALSC_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
37     ALSC_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
38     ALSC_STATE_MAX                                      /**< max */
39 } AlscState_t;
40 
41 typedef const CalibDbV2_LscTableProfile_t* pLscTableProfile_t;
42 
43 typedef struct lsc_matrix
44 {
45     Cam17x17UShortMatrix_t  LscMatrix[CAM_4CH_COLOR_COMPONENT_MAX];
46 } lsc_matrix_t;
47 
48 /** @brief store LSC recent/last results*/
49 typedef struct alsc_rest_s {
50     uint32_t caseIndex;
51     float fVignetting;
52     struct list_head dominateIlluList;//to record domain illuminant
53     uint32_t estimateIlluCaseIdx;
54     uint32_t resIdx;
55     pLscTableProfile_t pLscProfile1;
56     pLscTableProfile_t pLscProfile2;
57     lsc_matrix_t undampedLscMatrixTable;
58     lsc_matrix_t dampedLscMatrixTable;
59 } alsc_rest_t;
60 
61 typedef struct illu_node_s {
62     list_head node;       /**< for adding to a list */
63     unsigned int value;
64 } illu_node_t;
65 
66 typedef struct alsc_illu_case_resolution {
67     resolution_t resolution;
68     pLscTableProfile_t *lsc_table_group;
69     int lsc_table_count;
70 } alsc_illu_case_resolution_t;
71 
72 /**
73  * @brief alsc illumination case is different in <enum CalibDb_Used_For_Case_e>,
74  *        <resolution>, <color temperature>.
75  */
76 typedef struct alsc_illu_case {
77     const CalibDbV2_AlscCof_ill_t *alsc_cof;
78     alsc_illu_case_resolution_t *res_group;
79     uint32_t res_count;
80     uint32_t current_res_idx;
81 } alsc_illu_case_t;
82 
83 typedef alsc_illu_case_t* pIlluCase_t;
84 /** @brief depends on enum  CalibDb_Used_For_Case_e */
85 typedef struct alsc_mode_data_s
86 {
87     //TODO: actually is const point and should add const
88     pIlluCase_t     *illu_case;
89     uint32_t        illu_case_count;
90 } alsc_mode_data_t;
91 
92 typedef struct alsc_grad_s
93 {
94     resolution_t    resolution;
95     uint16_t        LscXGradTbl[LSC_GRAD_TBL_SIZE];
96     uint16_t        LscYGradTbl[LSC_GRAD_TBL_SIZE];
97 } alsc_grad_t;
98 
99 typedef struct alsc_otp_grad_s
100 {
101     uint32_t flag;
102 
103     uint16_t width;
104     uint16_t height;
105     uint16_t table_size;
106 
107     uint16_t lsc_r[LSC_DATA_TBL_SIZE];
108     uint16_t lsc_b[LSC_DATA_TBL_SIZE];
109     uint16_t lsc_gr[LSC_DATA_TBL_SIZE];
110     uint16_t lsc_gb[LSC_DATA_TBL_SIZE];
111 } alsc_otp_grad_t;
112 
113 typedef struct smart_lsc_run_cfg_s {
114     bool  enable;
115     float gain_th;
116     float wbgain_th;
117 } smart_lsc_cfg_run_t;
118 
119 typedef struct smart_lsc_run_res_s {
120     bool forceRunFlag;//update by api or prepare;
121     float last_gain;
122     float last_awbGain[2];
123     bool res3aChg;
124     bool lscTableConverge;
125 } smart_lsc_run_res_t;
126 
127 typedef struct alsc_context_s {
128     const CalibDbV2_LSC_t   *calibLscV2;
129     CalibDbV2_LSC_t   fixed_calib;
130 
131     alsc_illu_case_t        *illu_case;
132     uint32_t                illu_case_count;
133 
134     alsc_mode_data_t        alsc_mode[USED_FOR_CASE_MAX];
135 
136     alsc_grad_t             *res_grad;
137     uint32_t                res_grad_count;
138 
139     resolution_t  cur_res;
140     alsc_sw_info_t alscSwInfo;
141     alsc_rest_t alscRest;
142     rk_aiq_lsc_cfg_t lscHwConf; //hw para
143     unsigned int count;
144 
145     //ctrl & api
146     rk_aiq_lsc_attrib_t mCurAtt;
147     //rk_aiq_lsc_attrib_t mNewAtt;
148     bool updateAtt;
149 
150     AlscState_t eState;
151 
152     // otp grad
153     alsc_otp_grad_t otpGrad;
154 
155     //smart run
156     smart_lsc_cfg_run_t smartRunCfg;
157     smart_lsc_run_res_t smartRunRes;
158     bool isReCal_;
159 } alsc_context_t ;
160 
161 typedef alsc_context_t* alsc_handle_t ;
162 
163 typedef struct _RkAiqAlgoContext {
164     alsc_handle_t alsc_para;
165 } RkAiqAlgoContext;
166 
167 
168 RKAIQ_END_DECLARE
169 
170 #endif
171 
172