xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/algos/adehaze/rk_aiq_adehaze_algo_v10.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * rk_aiq_adehaze_algo_v10.cpp
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 #include "rk_aiq_adehaze_algo_v10.h"
20 
21 #include <string.h>
22 
23 #include "xcam_log.h"
24 
LinearInterp(const float * pX,const float * pY,float posx,int XSize)25 float LinearInterp(const float* pX, const float* pY, float posx, int XSize) {
26     int index;
27     float yOut = 0;
28 
29     if (posx >= pX[XSize - 1]) {
30         yOut = pY[XSize - 1];
31     } else if (posx <= pX[0]) {
32         yOut = pY[0];
33     } else {
34         index = 0;
35         while ((posx >= pX[index]) && (index < XSize)) {
36             index++;
37         }
38         index -= 1;
39         yOut = ((pY[index + 1] - pY[index]) / (pX[index + 1] - pX[index]) * (posx - pX[index])) +
40                pY[index];
41     }
42 
43     return yOut;
44 }
45 
LinearInterpEnable(const float * pX,const unsigned char * pY,float posx,int XSize)46 int LinearInterpEnable(const float* pX, const unsigned char* pY, float posx, int XSize) {
47     int index;
48     float out;
49     int yOut = 0;
50     if (posx >= pX[XSize - 1]) {
51         out = (float)pY[XSize - 1];
52     } else if (posx <= pX[0]) {
53         out = pY[0];
54     } else {
55         index = 0;
56         while ((posx >= pX[index]) && (index < XSize)) {
57             index++;
58         }
59         index -= 1;
60         out = ((pY[index + 1] - pY[index]) / (pX[index + 1] - pX[index]) * (posx - pX[index])) +
61               pY[index];
62     }
63     yOut = out > 0.5 ? 1 : 0;
64 
65     return yOut;
66 }
67 
GetDehazeParams(CalibDbV2_dehaze_v10_t * pCalib,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)68 void GetDehazeParams(CalibDbV2_dehaze_v10_t* pCalib, RkAiqAdehazeProcResult_t* ProcRes,
69                      float CtrlValue) {
70     LOG1_ADEHAZE("ENTER: %s \n", __func__);
71 
72     int iso_len = pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO_len;
73     // dehaze_self_adp[7]
74     float dc_min_th  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
75                                    pCalib->DehazeTuningPara.dehaze_setting.DehazeData.dc_min_th,
76                                    CtrlValue, iso_len);
77     float dc_max_th  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
78                                    pCalib->DehazeTuningPara.dehaze_setting.DehazeData.dc_max_th,
79                                    CtrlValue, iso_len);
80     float yhist_th   = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
81                                   pCalib->DehazeTuningPara.dehaze_setting.DehazeData.yhist_th,
82                                   CtrlValue, iso_len);
83     float yblk_th    = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
84                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.yblk_th,
85                                  CtrlValue, iso_len);
86     float dark_th    = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
87                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.dark_th,
88                                  CtrlValue, iso_len);
89     float bright_min = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
90                                     pCalib->DehazeTuningPara.dehaze_setting.DehazeData.bright_min,
91                                     CtrlValue, iso_len);
92     float bright_max = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
93                                     pCalib->DehazeTuningPara.dehaze_setting.DehazeData.bright_max,
94                                     CtrlValue, iso_len);
95 
96     // dehaze_range_adj[6]
97     float wt_max =
98         LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
99                      pCalib->DehazeTuningPara.dehaze_setting.DehazeData.wt_max, CtrlValue, iso_len);
100     float air_max   = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
101                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.air_max,
102                                  CtrlValue, iso_len);
103     float air_min   = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
104                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.air_min,
105                                  CtrlValue, iso_len);
106     float tmax_base = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
107                                    pCalib->DehazeTuningPara.dehaze_setting.DehazeData.tmax_base,
108                                    CtrlValue, iso_len);
109     float tmax_off  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
110                                   pCalib->DehazeTuningPara.dehaze_setting.DehazeData.tmax_off,
111                                   CtrlValue, iso_len);
112     float tmax_max  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
113                                   pCalib->DehazeTuningPara.dehaze_setting.DehazeData.tmax_max,
114                                   CtrlValue, iso_len);
115 
116     // dehaze_iir_control[5]
117     float stab_fnum  = pCalib->DehazeTuningPara.dehaze_setting.stab_fnum;
118     float sigma      = pCalib->DehazeTuningPara.dehaze_setting.sigma;
119     float wt_sigma   = pCalib->DehazeTuningPara.dehaze_setting.wt_sigma;
120     float air_sigma  = pCalib->DehazeTuningPara.dehaze_setting.air_sigma;
121     float tmax_sigma = pCalib->DehazeTuningPara.dehaze_setting.tmax_sigma;
122 
123     float cfg_wt =
124         LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
125                      pCalib->DehazeTuningPara.dehaze_setting.DehazeData.cfg_wt, CtrlValue, iso_len);
126     float cfg_air  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
127                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.cfg_air,
128                                  CtrlValue, iso_len);
129     float cfg_tmax = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
130                                   pCalib->DehazeTuningPara.dehaze_setting.DehazeData.cfg_tmax,
131                                   CtrlValue, iso_len);
132 
133     // dehaze_bi_pAdehazeCtx[4]
134     float dc_thed     = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
135                                  pCalib->DehazeTuningPara.dehaze_setting.DehazeData.dc_thed,
136                                  CtrlValue, iso_len);
137     float dc_weitcur  = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
138                                     pCalib->DehazeTuningPara.dehaze_setting.DehazeData.dc_weitcur,
139                                     CtrlValue, iso_len);
140     float air_thed    = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
141                                   pCalib->DehazeTuningPara.dehaze_setting.DehazeData.air_thed,
142                                   CtrlValue, iso_len);
143     float air_weitcur = LinearInterp(pCalib->DehazeTuningPara.dehaze_setting.DehazeData.ISO,
144                                      pCalib->DehazeTuningPara.dehaze_setting.DehazeData.air_weitcur,
145                                      CtrlValue, iso_len);
146 
147     // dehaze_dc_bf_h[25]
148     float dc_bf_h[25] = {12.0000, 17.0000, 19.0000, 17.0000, 12.0000, 17.0000, 25.0000,
149                          28.0000, 25.0000, 17.0000, 19.0000, 28.0000, 32.0000, 28.0000,
150                          19.0000, 17.0000, 25.0000, 28.0000, 25.0000, 17.0000, 12.0000,
151                          17.0000, 19.0000, 17.0000, 12.0000};
152 
153     // dehaze_air_bf_h[9],dehaze_gaus_h[9]
154     float air_bf_h[9] = {25.0000, 28.0000, 25.0000, 28.0000, 32.0000,
155                          28.0000, 25.0000, 28.0000, 25.0000};
156     float gaus_h[9]   = {2.0000, 4.0000, 2.0000, 4.0000, 8.0000, 4.0000, 2.0000, 4.0000, 2.0000};
157 
158     LOGD_ADEHAZE(
159         "%s dc_min_th:%f dc_max_th:%f yhist_th:%f yblk_th:%f dark_th:%f bright_min:%f "
160         "bright_max:%f\n",
161         __func__, dc_min_th, dc_max_th, yhist_th, yblk_th, dark_th, bright_min, bright_max);
162     LOGD_ADEHAZE("%s wt_max:%f air_max:%f air_min:%f tmax_base:%f tmax_off:%f tmax_max:%f\n",
163                  __func__, wt_max, air_max, air_min, tmax_base, tmax_off, tmax_max);
164     LOGD_ADEHAZE("%s stab_fnum:%f sigma:%f wt_sigma:%f air_sigma:%f tmax_sigma:%f\n", __func__,
165                  stab_fnum, sigma, wt_sigma, air_sigma, tmax_sigma);
166     LOGD_ADEHAZE("%s  cfg_wt:%f cfg_air:%f cfg_tmax:%f\n", __func__, cfg_wt, cfg_air, cfg_tmax);
167     LOGD_ADEHAZE("%s dc_thed:%f dc_weitcur:%f air_thed:%f air_weitcur:%f\n", __func__, dc_thed,
168                  dc_weitcur, air_thed, air_weitcur);
169 
170     int rawWidth                   = 1920;
171     int rawHeight                  = 1080;
172     ProcRes->ProcResV10.dc_min_th  = int(dc_min_th);  // 0~255, (8bit) dc_min_th
173     ProcRes->ProcResV10.dc_max_th  = int(dc_max_th);  // 0~255, (8bit) dc_max_th
174     ProcRes->ProcResV10.yhist_th   = int(yhist_th);   // 0~255, (8bit) yhist_th
175     ProcRes->ProcResV10.yblk_th    = int(yblk_th * ((rawWidth + 15) / 16) *
176                                       ((rawHeight + 15) / 16));  // default:28,(9bit) yblk_th
177     ProcRes->ProcResV10.dark_th    = int(dark_th);                  // 0~255, (8bit) dark_th
178     ProcRes->ProcResV10.bright_min = int(bright_min);               // 0~255, (8bit) bright_min
179     ProcRes->ProcResV10.bright_max = int(bright_max);               // 0~255, (8bit) bright_max
180 
181     ProcRes->ProcResV10.wt_max    = int(wt_max * 256);     // 0~255, (9bit) wt_max
182     ProcRes->ProcResV10.air_min   = int(air_min);          // 0~255, (8bit) air_min
183     ProcRes->ProcResV10.air_max   = int(air_max);          // 0~256, (8bit) air_max
184     ProcRes->ProcResV10.tmax_base = int(tmax_base);        // 0~255, (8bit) tmax_base
185     ProcRes->ProcResV10.tmax_off  = int(tmax_off * 1024);  // 0~1024,(10bit) tmax_off
186     ProcRes->ProcResV10.tmax_max  = int(tmax_max * 1024);  // 0~1024,(10bit) tmax_max
187 
188     ProcRes->ProcResV10.stab_fnum = int(stab_fnum);  // 1~31,  (5bit) stab_fnum
189     ProcRes->ProcResV10.iir_sigma = int(sigma);      // 0~255, (8bit) sigma
190     ProcRes->ProcResV10.iir_wt_sigma =
191         int(wt_sigma * 8 + 0.5);                          //       (11bit),8bit+3bit, wt_sigma
192     ProcRes->ProcResV10.iir_air_sigma  = int(air_sigma);  //       (8bit) air_sigma
193     ProcRes->ProcResV10.iir_tmax_sigma = int(tmax_sigma * 1024 + 0.5);  //       (11bit) tmax_sigma
194 
195     ProcRes->ProcResV10.cfg_wt   = int(cfg_wt * 256);     // 0~256, (9bit) cfg_wt
196     ProcRes->ProcResV10.cfg_air  = int(cfg_air);          // 0~255, (8bit) cfg_air
197     ProcRes->ProcResV10.cfg_tmax = int(cfg_tmax * 1024);  // 0~1024,(11bit) cfg_tmax
198 
199     ProcRes->ProcResV10.dc_thed     = int(dc_thed);                  // 0~255, (8bit) dc_thed
200     ProcRes->ProcResV10.dc_weitcur  = int(dc_weitcur * 256 + 0.5);   // 0~256, (9bit) dc_weitcur
201     ProcRes->ProcResV10.air_thed    = int(air_thed);                 // 0~255, (8bit) air_thed
202     ProcRes->ProcResV10.air_weitcur = int(air_weitcur * 256 + 0.5);  // 0~256, (9bit) air_weitcur
203 
204     ProcRes->ProcResV10.gaus_h0          = int(gaus_h[4]);  // h0~h2  从大到小
205     ProcRes->ProcResV10.gaus_h1          = int(gaus_h[1]);
206     ProcRes->ProcResV10.gaus_h2          = int(gaus_h[0]);
207     ProcRes->ProcResV10.sw_dhaz_dc_bf_h0 = int(dc_bf_h[12]);  // h0~h5  从大到小
208     ProcRes->ProcResV10.sw_dhaz_dc_bf_h1 = int(dc_bf_h[7]);
209     ProcRes->ProcResV10.sw_dhaz_dc_bf_h2 = int(dc_bf_h[6]);
210     ProcRes->ProcResV10.sw_dhaz_dc_bf_h3 = int(dc_bf_h[2]);
211     ProcRes->ProcResV10.sw_dhaz_dc_bf_h4 = int(dc_bf_h[1]);
212     ProcRes->ProcResV10.sw_dhaz_dc_bf_h5 = int(dc_bf_h[0]);
213     ProcRes->ProcResV10.air_bf_h0        = int(air_bf_h[4]);  // h0~h2  从大到小
214     ProcRes->ProcResV10.air_bf_h1        = int(air_bf_h[1]);
215     ProcRes->ProcResV10.air_bf_h2        = int(air_bf_h[0]);
216 
217     if (ProcRes->ProcResV10.dc_en && !(ProcRes->ProcResV10.enhance_en)) {
218         LOGD_ADEHAZE(
219             "%s dc_min_th:%d dc_max_th:%d yhist_th:%d yblk_th:%d dark_th:%d bright_min:%d "
220             "bright_max:%d\n",
221             __func__, ProcRes->ProcResV10.dc_min_th, ProcRes->ProcResV10.dc_max_th,
222             ProcRes->ProcResV10.yhist_th, ProcRes->ProcResV10.yblk_th, ProcRes->ProcResV10.dark_th,
223             ProcRes->ProcResV10.bright_min, ProcRes->ProcResV10.bright_max);
224         LOGD_ADEHAZE("%s wt_max:%d air_max:%d air_min:%d tmax_base:%d tmax_off:%d tmax_max:%d\n",
225                      __func__, ProcRes->ProcResV10.wt_max, ProcRes->ProcResV10.air_max,
226                      ProcRes->ProcResV10.air_min, ProcRes->ProcResV10.tmax_base,
227                      ProcRes->ProcResV10.tmax_off, ProcRes->ProcResV10.tmax_max);
228         LOGD_ADEHAZE("%s stab_fnum:%d sigma:%d wt_sigma:%d air_sigma:%d tmax_sigma:%d\n", __func__,
229                      ProcRes->ProcResV10.stab_fnum, ProcRes->ProcResV10.iir_sigma,
230                      ProcRes->ProcResV10.iir_wt_sigma, ProcRes->ProcResV10.iir_air_sigma,
231                      ProcRes->ProcResV10.iir_tmax_sigma);
232         LOGD_ADEHAZE("%s  cfg_wt:%d cfg_air:%d cfg_tmax:%d\n", __func__, ProcRes->ProcResV10.cfg_wt,
233                      ProcRes->ProcResV10.cfg_air, ProcRes->ProcResV10.cfg_tmax);
234         LOGD_ADEHAZE("%s dc_thed:%d dc_weitcur:%d air_thed:%d air_weitcur:%d\n", __func__,
235                      ProcRes->ProcResV10.dc_thed, ProcRes->ProcResV10.dc_weitcur,
236                      ProcRes->ProcResV10.air_thed, ProcRes->ProcResV10.air_weitcur);
237     }
238 
239     LOG1_ADEHAZE("EIXT: %s \n", __func__);
240 }
241 
GetEnhanceParams(CalibDbV2_dehaze_v10_t * pCalib,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)242 void GetEnhanceParams(CalibDbV2_dehaze_v10_t* pCalib, RkAiqAdehazeProcResult_t* ProcRes,
243                       float CtrlValue) {
244     LOG1_ADEHAZE("ENTER: %s \n", __func__);
245 
246     int iso_len         = pCalib->DehazeTuningPara.enhance_setting.EnhanceData.ISO_len;
247     float enhance_value = LinearInterp(
248         pCalib->DehazeTuningPara.enhance_setting.EnhanceData.ISO,
249         pCalib->DehazeTuningPara.enhance_setting.EnhanceData.enhance_value, CtrlValue, iso_len);
250     ProcRes->ProcResV10.enhance_value =
251         int(enhance_value * 1024 + 0.5);  //       (14bit),4bit + 10bit, enhance_value
252 
253     if (ProcRes->ProcResV10.dc_en && ProcRes->ProcResV10.enhance_en)
254         LOGD_ADEHAZE("%s enhance_value:%f enhance_value:0x%x\n", __func__, enhance_value,
255                      ProcRes->ProcResV10.enhance_value);
256 
257     LOG1_ADEHAZE("EIXT: %s \n", __func__);
258 }
259 
GetHistParams(CalibDbV2_dehaze_v10_t * pCalib,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)260 void GetHistParams(CalibDbV2_dehaze_v10_t* pCalib, RkAiqAdehazeProcResult_t* ProcRes,
261                    float CtrlValue) {
262     LOG1_ADEHAZE("ENTER: %s \n", __func__);
263 
264     int iso_len       = pCalib->DehazeTuningPara.hist_setting.HistData.ISO_len;
265     bool hist_channel = pCalib->DehazeTuningPara.hist_setting.hist_channel;
266     bool hist_para_en = pCalib->DehazeTuningPara.hist_setting.hist_para_en;
267     float hist_gratio = LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
268                                      pCalib->DehazeTuningPara.hist_setting.HistData.hist_gratio,
269                                      CtrlValue, iso_len);
270     float hist_th_off = LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
271                                      pCalib->DehazeTuningPara.hist_setting.HistData.hist_th_off,
272                                      CtrlValue, iso_len);
273     float hist_k =
274         LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
275                      pCalib->DehazeTuningPara.hist_setting.HistData.hist_k, CtrlValue, iso_len);
276     float hist_min =
277         LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
278                      pCalib->DehazeTuningPara.hist_setting.HistData.hist_min, CtrlValue, iso_len);
279     float hist_scale =
280         LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
281                      pCalib->DehazeTuningPara.hist_setting.HistData.hist_scale, CtrlValue, iso_len);
282     float cfg_gratio =
283         LinearInterp(pCalib->DehazeTuningPara.hist_setting.HistData.ISO,
284                      pCalib->DehazeTuningPara.hist_setting.HistData.cfg_gratio, CtrlValue, iso_len);
285 
286     // dehaze_hist_t0[6],dehaze_hist_t1[6],dehaze_hist_t2[6]
287     float hist_conv_t0[ISP2X_DHAZ_CONV_COEFF_NUM] = {1.0000,  2.0000,  1.0000,
288                                                      -1.0000, -2.0000, -1.0000};
289     float hist_conv_t1[ISP2X_DHAZ_CONV_COEFF_NUM] = {1.0000, 0.0000, -1.0000,
290                                                      2.0000, 0.0000, -2.0000};
291     float hist_conv_t2[ISP2X_DHAZ_CONV_COEFF_NUM] = {1.0000, -2.0000, 1.0000,
292                                                      2.0000, -4.0000, 2.0000};
293 
294     ProcRes->ProcResV10.hist_chn    = hist_channel ? 1 : 0;   //  hist_para_en
295     ProcRes->ProcResV10.hpara_en    = hist_para_en ? 1 : 0;   //  hist_para_en
296     ProcRes->ProcResV10.hist_gratio = int(hist_gratio * 8);   //       (8bit) hist_gratio
297     ProcRes->ProcResV10.hist_th_off = int(hist_th_off);       //       (8bit) hist_th_off
298     ProcRes->ProcResV10.hist_k      = int(hist_k * 4 + 0.5);  // 0~7    (5bit),3bit+2bit, hist_k
299     ProcRes->ProcResV10.hist_min    = int(hist_min * 256);    //       (9bit) hist_min
300     ProcRes->ProcResV10.cfg_gratio  = int(cfg_gratio * 256);  //       (13bit),5bit+8bit, cfg_gratio
301     ProcRes->ProcResV10.hist_scale =
302         int(hist_scale * 256 + 0.5);  //       (13bit),5bit + 8bit, sw_hist_scale
303 
304     for (int i = 0; i < ISP2X_DHAZ_CONV_COEFF_NUM; i++) {
305         ProcRes->ProcResV10.conv_t0[i] = int(hist_conv_t0[i]);
306         ProcRes->ProcResV10.conv_t1[i] = int(hist_conv_t1[i]);
307         ProcRes->ProcResV10.conv_t2[i] = int(hist_conv_t2[i]);
308     }
309 
310     if (ProcRes->ProcResV10.hist_en) {
311         LOGD_ADEHAZE(
312             "%s hist_channel:%d hist_prar_en:%d hist_gratio:%f hist_th_off:%f hist_k:%f "
313             "hist_min:%f hist_scale:%f cfg_gratio:%f\n",
314             __func__, ProcRes->ProcResV10.hist_chn, ProcRes->ProcResV10.hpara_en, hist_gratio,
315             hist_th_off, hist_k, hist_min, hist_scale, cfg_gratio);
316         LOGD_ADEHAZE(
317             "%s hist_gratio_reg:0x%x hist_th_off_reg:0x%x hist_k_reg:0x%x hist_min_reg:0x%x "
318             "hist_scale_reg:0x%x cfg_gratio_reg:0x%x\n",
319             __func__, ProcRes->ProcResV10.hist_gratio, ProcRes->ProcResV10.hist_th_off,
320             ProcRes->ProcResV10.hist_k, ProcRes->ProcResV10.hist_min,
321             ProcRes->ProcResV10.hist_scale, ProcRes->ProcResV10.cfg_gratio);
322     }
323 
324     LOG1_ADEHAZE("EIXT: %s \n", __func__);
325 }
326 
AdehazeApiToolProcess(CalibDbV2_dehaze_v10_t * pStool,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)327 void AdehazeApiToolProcess(CalibDbV2_dehaze_v10_t* pStool, RkAiqAdehazeProcResult_t* ProcRes,
328                            float CtrlValue) {
329     LOG1_ADEHAZE("ENTER: %s \n", __func__);
330     LOGD_ADEHAZE("%s: Adehaze in api TOOL !!! \n", __func__);
331 
332     // cfg setting
333     ProcRes->ProcResV10.cfg_alpha =
334         (int)LIMIT_VALUE((pStool->DehazeTuningPara.cfg_alpha * 256.0), BIT_8_MAX, BIT_MIN);
335     LOGD_ADEHAZE("%s Config Alpha:%d\n", __func__, ProcRes->ProcResV10.cfg_alpha);
336 
337     // fuction enable
338     EnableSetting(pStool, ProcRes);
339 
340     // dehaze setting
341     GetDehazeParams(pStool, ProcRes, CtrlValue);
342 
343     // enhance setting
344     GetEnhanceParams(pStool, ProcRes, CtrlValue);
345 
346     // hist setting
347     GetHistParams(pStool, ProcRes, CtrlValue);
348 
349     LOG1_ADEHAZE("EXIT: %s \n", __func__);
350 }
351 
AdehazeEnhanceApiBypassProcess(CalibDbV2_dehaze_v10_t * pCalib,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)352 void AdehazeEnhanceApiBypassProcess(CalibDbV2_dehaze_v10_t* pCalib,
353                                     RkAiqAdehazeProcResult_t* ProcRes, float CtrlValue) {
354     LOG1_ADEHAZE("ENTER: %s \n", __func__);
355     LOGD_ADEHAZE(" %s: Adehaze Api off!!!\n", __func__);
356 
357     // cfg setting
358     ProcRes->ProcResV10.cfg_alpha =
359         (int)LIMIT_VALUE((pCalib->DehazeTuningPara.cfg_alpha * 256.0), BIT_8_MAX, BIT_MIN);
360     // LOGD_ADEHAZE("%s Config Alpha:%d\n", __func__, ProcRes->ProcResV10.cfg_alpha);
361 
362     // enable setting
363     EnableSetting(pCalib, ProcRes);
364 
365     // dehaze setting
366     GetDehazeParams(pCalib, ProcRes, CtrlValue);
367 
368     // enhance setting
369     GetEnhanceParams(pCalib, ProcRes, CtrlValue);
370 
371     // hist setting
372     GetHistParams(pCalib, ProcRes, CtrlValue);
373 
374     LOG1_ADEHAZE("EXIT: %s \n", __func__);
375 }
376 
AdehazeEnhanceApiOffProcess(CalibDbV2_dehaze_v10_t * pCalib,RkAiqAdehazeProcResult_t * ProcRes,float CtrlValue)377 void AdehazeEnhanceApiOffProcess(CalibDbV2_dehaze_v10_t* pCalib, RkAiqAdehazeProcResult_t* ProcRes,
378                                  float CtrlValue) {
379     LOG1_ADEHAZE("ENTER: %s \n", __func__);
380     LOGD_ADEHAZE(" %s: Adehaze Api off!!!\n", __func__);
381 
382     // enable setting
383     ProcRes->ProcResV10.enable = true;
384     if (pCalib->DehazeTuningPara.enhance_setting.en) {
385         ProcRes->ProcResV10.dc_en      = true;
386         ProcRes->ProcResV10.enhance_en = true;
387     } else {
388         ProcRes->ProcResV10.dc_en      = false;
389         ProcRes->ProcResV10.enhance_en = false;
390     }
391 
392     // cfg setting
393     ProcRes->ProcResV10.cfg_alpha =
394         (int)LIMIT_VALUE((pCalib->DehazeTuningPara.cfg_alpha * 256.0), BIT_8_MAX, BIT_MIN);
395 
396     // dehaze setting
397     GetDehazeParams(pCalib, ProcRes, CtrlValue);
398 
399     // enhance setting
400     GetEnhanceParams(pCalib, ProcRes, CtrlValue);
401 
402     // hist setting
403     GetHistParams(pCalib, ProcRes, CtrlValue);
404 
405     LOG1_ADEHAZE("EXIT: %s \n", __func__);
406 }
407 
AdehazeGetStats(AdehazeHandle_t * pAdehazeCtx,rkisp_adehaze_stats_t * ROData)408 void AdehazeGetStats(AdehazeHandle_t* pAdehazeCtx, rkisp_adehaze_stats_t* ROData) {
409     LOG1_ADEHAZE("%s:enter!\n", __FUNCTION__);
410 
411     pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_air_base =
412         ROData->dehaze_stats_v10.dhaz_adp_air_base;
413     pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_wt     = ROData->dehaze_stats_v10.dhaz_adp_wt;
414     pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_gratio = ROData->dehaze_stats_v10.dhaz_adp_gratio;
415     pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_tmax   = ROData->dehaze_stats_v10.dhaz_adp_tmax;
416     for (int i = 0; i < ISP2X_DHAZ_HIST_IIR_NUM; i++) {
417         pAdehazeCtx->stats.dehaze_stats_v10.h_b_iir[i] = ROData->dehaze_stats_v10.h_b_iir[i];
418         pAdehazeCtx->stats.dehaze_stats_v10.h_g_iir[i] = ROData->dehaze_stats_v10.h_g_iir[i];
419         pAdehazeCtx->stats.dehaze_stats_v10.h_r_iir[i] = ROData->dehaze_stats_v10.h_r_iir[i];
420     }
421 
422     LOG1_ADEHAZE("%s:  dhaz_adp_air_base:%d dhaz_adp_wt:%d dhaz_adp_gratio:%d dhaz_adp_tmax:%d\n",
423                  __FUNCTION__, pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_air_base,
424                  pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_wt,
425                  pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_gratio,
426                  pAdehazeCtx->stats.dehaze_stats_v10.dhaz_adp_tmax);
427     for (int i = 0; i < ISP2X_DHAZ_HIST_IIR_NUM; i++) {
428         LOG1_ADEHAZE("%s:  h_b_iir[%d]:%d:\n", __FUNCTION__, i,
429                      pAdehazeCtx->stats.dehaze_stats_v10.h_b_iir[i]);
430         LOG1_ADEHAZE("%s:  h_g_iir[%d]:%d:\n", __FUNCTION__, i,
431                      pAdehazeCtx->stats.dehaze_stats_v10.h_g_iir[i]);
432         LOG1_ADEHAZE("%s:  h_r_iir[%d]:%d:\n", __FUNCTION__, i,
433                      pAdehazeCtx->stats.dehaze_stats_v10.h_r_iir[i]);
434     }
435 
436     LOG1_ADEHAZE("%s:exit!\n", __FUNCTION__);
437 }
438 #ifdef RKAIQ_ENABLE_CAMGROUP
AdehazeGetCurrDataGroup(AdehazeHandle_t * pAdehazeCtx,rk_aiq_singlecam_3a_result_t * pCamgrpParams)439 XCamReturn AdehazeGetCurrDataGroup(AdehazeHandle_t* pAdehazeCtx,
440                                    rk_aiq_singlecam_3a_result_t* pCamgrpParams) {
441     LOG1_ADEHAZE("%s:enter!\n", __FUNCTION__);
442     XCamReturn ret = XCAM_RETURN_NO_ERROR;
443 
444     if (pCamgrpParams) {
445         // get EnvLv
446         if (pCamgrpParams->aec._aePreRes) {
447             RkAiqAlgoPreResAe* pAEPreRes =
448                 (RkAiqAlgoPreResAe*)pCamgrpParams->aec._aePreRes->map(pCamgrpParams->aec._aePreRes);
449 
450             if (pAEPreRes) {
451                 switch (pAdehazeCtx->FrameNumber) {
452                     case LINEAR_NUM:
453                         pAdehazeCtx->CurrDataV10.EnvLv = pAEPreRes->ae_pre_res_rk.GlobalEnvLv[0];
454                         break;
455                     case HDR_2X_NUM:
456                         pAdehazeCtx->CurrDataV10.EnvLv = pAEPreRes->ae_pre_res_rk.GlobalEnvLv[1];
457                         break;
458                     case HDR_3X_NUM:
459                         pAdehazeCtx->CurrDataV10.EnvLv = pAEPreRes->ae_pre_res_rk.GlobalEnvLv[1];
460                         break;
461                     default:
462                         LOGE_ADEHAZE("%s:  Wrong frame number in HDR mode!!!\n", __FUNCTION__);
463                         break;
464                 }
465 
466                 // Normalize the current envLv for AEC
467                 pAdehazeCtx->CurrDataV10.EnvLv =
468                     (pAdehazeCtx->CurrDataV10.EnvLv - MIN_ENV_LV) / (MAX_ENV_LV - MIN_ENV_LV);
469                 pAdehazeCtx->CurrDataV10.EnvLv =
470                     LIMIT_VALUE(pAdehazeCtx->CurrDataV10.EnvLv, ENVLVMAX, ENVLVMIN);
471             } else {
472                 pAdehazeCtx->CurrDataV10.EnvLv = ENVLVMIN;
473                 LOGW_ADEHAZE("%s:_aePreRes Res is NULL!\n", __FUNCTION__);
474             }
475         } else {
476             pAdehazeCtx->CurrDataV10.EnvLv = ENVLVMIN;
477             LOGW_ADEHAZE("%s:_aePreRes Res is NULL!\n", __FUNCTION__);
478         }
479 
480         // get iso
481         if (pAdehazeCtx->FrameNumber == LINEAR_NUM) {
482             pAdehazeCtx->CurrDataV10.ISO =
483                 pCamgrpParams->aec._effAecExpInfo.LinearExp.exp_real_params.analog_gain *
484                 pCamgrpParams->aec._effAecExpInfo.LinearExp.exp_real_params.digital_gain *
485                 pCamgrpParams->aec._effAecExpInfo.LinearExp.exp_real_params.isp_dgain * ISOMIN;
486         } else if (pAdehazeCtx->FrameNumber == HDR_2X_NUM ||
487                    pAdehazeCtx->FrameNumber == HDR_3X_NUM) {
488             pAdehazeCtx->CurrDataV10.ISO =
489                 pCamgrpParams->aec._effAecExpInfo.HdrExp[1].exp_real_params.analog_gain *
490                 pCamgrpParams->aec._effAecExpInfo.HdrExp[1].exp_real_params.digital_gain *
491                 pCamgrpParams->aec._effAecExpInfo.HdrExp[1].exp_real_params.isp_dgain * ISOMIN;
492         }
493     } else {
494         pAdehazeCtx->CurrDataV10.EnvLv = ENVLVMIN;
495         pAdehazeCtx->CurrDataV10.ISO   = ISOMIN;
496         LOGW_ADEHAZE("%s: camgroupParmasArray[0] Res is NULL!\n", __FUNCTION__);
497     }
498 
499     LOG1_ADEHAZE("%s:exit!\n", __FUNCTION__);
500     return ret;
501 }
502 #endif
AdehazeGetCurrData(AdehazeHandle_t * pAdehazeCtx,RkAiqAlgoProcAdhaz * pProcPara)503 XCamReturn AdehazeGetCurrData(AdehazeHandle_t* pAdehazeCtx, RkAiqAlgoProcAdhaz* pProcPara) {
504     LOG1_ADEHAZE("%s:enter!\n", __FUNCTION__);
505     XCamReturn ret = XCAM_RETURN_NO_ERROR;
506     int iso = 50;
507     AdehazeExpInfo_t stExpInfo;
508     memset(&stExpInfo, 0x00, sizeof(AdehazeExpInfo_t));
509 
510     stExpInfo.hdr_mode = 0;
511     for (int i = 0; i < 3; i++) {
512         stExpInfo.arIso[i]   = 50;
513         stExpInfo.arAGain[i] = 1.0;
514         stExpInfo.arDGain[i] = 1.0;
515         stExpInfo.arTime[i]  = 0.01;
516     }
517 
518     if (pAdehazeCtx->working_mode == RK_AIQ_WORKING_MODE_NORMAL) {
519         stExpInfo.hdr_mode = 0;
520     } else if (RK_AIQ_HDR_GET_WORKING_MODE(pAdehazeCtx->working_mode) ==
521                RK_AIQ_WORKING_MODE_ISP_HDR2) {
522         stExpInfo.hdr_mode = 1;
523     } else if (RK_AIQ_HDR_GET_WORKING_MODE(pAdehazeCtx->working_mode) ==
524                RK_AIQ_WORKING_MODE_ISP_HDR3) {
525         stExpInfo.hdr_mode = 2;
526     }
527 
528     XCamVideoBuffer* xCamAePreRes = pProcPara->com.u.proc.res_comb->ae_pre_res;
529     RkAiqAlgoPreResAe* pAEPreRes  = NULL;
530     if (xCamAePreRes) {
531         pAEPreRes = (RkAiqAlgoPreResAe*)xCamAePreRes->map(xCamAePreRes);
532         if (pAdehazeCtx->working_mode == RK_AIQ_WORKING_MODE_NORMAL) {
533             stExpInfo.arAGain[0] = pAEPreRes->ae_pre_res_rk.LinearExp.exp_real_params.analog_gain;
534             stExpInfo.arDGain[0] = pAEPreRes->ae_pre_res_rk.LinearExp.exp_real_params.digital_gain;
535             stExpInfo.arTime[0] =
536                 pAEPreRes->ae_pre_res_rk.LinearExp.exp_real_params.integration_time;
537             stExpInfo.arIso[0] = stExpInfo.arAGain[0] * stExpInfo.arDGain[0] * 50;
538         } else {
539             for (int i = 0; i < 3; i++) {
540                 stExpInfo.arAGain[i] =
541                     pAEPreRes->ae_pre_res_rk.HdrExp[i].exp_real_params.analog_gain;
542                 stExpInfo.arDGain[i] =
543                     pAEPreRes->ae_pre_res_rk.HdrExp[i].exp_real_params.digital_gain;
544                 stExpInfo.arTime[i] =
545                     pAEPreRes->ae_pre_res_rk.HdrExp[i].exp_real_params.integration_time;
546                 stExpInfo.arIso[i] = stExpInfo.arAGain[i] * stExpInfo.arDGain[i] * 50;
547 
548                 LOGD_ADEHAZE("index:%d again:%f dgain:%f time:%f iso:%d hdr_mode:%d\n", i,
549                              stExpInfo.arAGain[i], stExpInfo.arDGain[i], stExpInfo.arTime[i],
550                              stExpInfo.arIso[i], stExpInfo.hdr_mode);
551             }
552         }
553     } else {
554         ret = XCAM_RETURN_ERROR_PARAM;
555     }
556 
557     iso                          = stExpInfo.arIso[stExpInfo.hdr_mode];
558     pAdehazeCtx->CurrDataV10.ISO = (float)iso;
559 
560     LOG1_ADEHAZE("%s:exit!\n", __FUNCTION__);
561     return ret;
562 }
563 
AdehazeInit(AdehazeHandle_t ** pAdehazeCtx,CamCalibDbV2Context_t * pCalib)564 XCamReturn AdehazeInit(AdehazeHandle_t** pAdehazeCtx, CamCalibDbV2Context_t* pCalib) {
565     LOG1_ADEHAZE("ENTER: %s \n", __func__);
566     XCamReturn ret          = XCAM_RETURN_NO_ERROR;
567     AdehazeHandle_t* handle = (AdehazeHandle_t*)calloc(1, sizeof(AdehazeHandle_t));
568 
569     CalibDbV2_dehaze_v10_t* calibv2_adehaze_calib_V10 =
570         (CalibDbV2_dehaze_v10_t*)(CALIBDBV2_GET_MODULE_PTR(pCalib, adehaze_calib));
571     memcpy(&handle->CalibV10, calibv2_adehaze_calib_V10, sizeof(CalibDbV2_dehaze_v10_t));
572     handle->AdehazeAtrrV10.mode = DEHAZE_API_AUTO;
573     handle->ifReCalcStAuto      = true;
574     handle->ifReCalcStManual    = false;
575     handle->isCapture           = false;
576     handle->is_multi_isp_mode   = false;
577 
578     *pAdehazeCtx = handle;
579     LOG1_ADEHAZE("EXIT: %s \n", __func__);
580     return (ret);
581 }
582 
AdehazeRelease(AdehazeHandle_t * pAdehazeCtx)583 XCamReturn AdehazeRelease(AdehazeHandle_t* pAdehazeCtx) {
584     LOG1_ADEHAZE("ENTER: %s \n", __func__);
585     XCamReturn ret = XCAM_RETURN_NO_ERROR;
586     if (pAdehazeCtx) free(pAdehazeCtx);
587     LOG1_ADEHAZE("EXIT: %s \n", __func__);
588     return (ret);
589 }
590 
AdehazeProcess(AdehazeHandle_t * pAdehazeCtx,dehaze_stats_v10_t * pStats,RkAiqAdehazeProcResult_t * pAdehzeProcRes)591 XCamReturn AdehazeProcess(AdehazeHandle_t* pAdehazeCtx, dehaze_stats_v10_t* pStats,
592                           RkAiqAdehazeProcResult_t* pAdehzeProcRes) {
593     XCamReturn ret = XCAM_RETURN_NO_ERROR;
594     LOG1_ADEHAZE("ENTER: %s \n", __func__);
595 
596     LOGD_ADEHAZE(" %s: Dehaze module en:%d Dehaze en:%d, Enhance en:%d, Hist en:%d\n", __func__,
597                  pAdehzeProcRes->enable,
598                  (pAdehzeProcRes->ProcResV10.dc_en & FUNCTION_ENABLE) &&
599                      (!(pAdehzeProcRes->ProcResV10.enhance_en & FUNCTION_ENABLE)),
600                  (pAdehzeProcRes->ProcResV10.dc_en & FUNCTION_ENABLE) &&
601                      (pAdehzeProcRes->ProcResV10.enhance_en & FUNCTION_ENABLE),
602                  pAdehzeProcRes->ProcResV10.hist_en);
603 
604     float CtrlValue = 0.0;
605 
606     // todo
607 
608     // store pre data
609     pAdehazeCtx->PreDataV10.ISO = pAdehazeCtx->CurrDataV10.ISO;
610     pAdehazeCtx->PreDataV10.ApiMode = pAdehazeCtx->CurrDataV10.ApiMode;
611 
612     LOG1_ADEHAZE("EXIT: %s \n", __func__);
613     return ret;
614 }
615 
AdehazeByPassProcessing(AdehazeHandle_t * pAdehazeCtx)616 bool AdehazeByPassProcessing(AdehazeHandle_t* pAdehazeCtx) {
617     LOG1_ADEHAZE("ENTER: %s \n", __func__);
618     bool byPassProc = true;
619 
620     if (pAdehazeCtx->FrameID <= INIT_CALC_PARAMS_NUM)
621         byPassProc = false;
622     else if (pAdehazeCtx->AdehazeAtrrV10.mode != pAdehazeCtx->PreDataV10.ApiMode)
623         byPassProc = false;
624     else if (pAdehazeCtx->AdehazeAtrrV10.mode == DEHAZE_API_MANUAL)
625         byPassProc = !pAdehazeCtx->ifReCalcStManual;
626     else if (pAdehazeCtx->AdehazeAtrrV10.mode == DEHAZE_API_AUTO) {
627         float diff = (pAdehazeCtx->PreDataV10.ISO - pAdehazeCtx->CurrDataV10.ISO) /
628                      pAdehazeCtx->PreDataV10.ISO;
629         if (diff > pAdehazeCtx->CalibV10.DehazeTuningPara.ByPassThr ||
630             diff < -pAdehazeCtx->CalibV10.DehazeTuningPara.ByPassThr)
631             byPassProc = false;
632         else
633             byPassProc = true;
634 
635         byPassProc = byPassProc && !pAdehazeCtx->ifReCalcStManual;
636     }
637 
638     LOGD_ADEHAZE("%s:FrameID:%d byPassProc:%d ISO:%f\n", __func__, pAdehazeCtx->FrameID, byPassProc,
639                  pAdehazeCtx->CurrData.V30.ISO);
640 
641     LOG1_ADEHAZE("EXIT: %s \n", __func__);
642     return byPassProc;
643 }
644 /******************************************************************************
645  * DehazeEnableSetting()
646  *
647  *****************************************************************************/
DehazeEnableSetting(AdehazeHandle_t * pAdehazeCtx,RkAiqAdehazeProcResult_t * pAdehzeProcRes)648 bool DehazeEnableSetting(AdehazeHandle_t* pAdehazeCtx, RkAiqAdehazeProcResult_t* pAdehzeProcRes) {
649     LOG1_ADEHAZE("%s:enter!\n", __FUNCTION__);
650 
651     if (pAdehazeCtx->AdehazeAtrrV10.mode == DEHAZE_API_AUTO) {
652         pAdehzeProcRes->enable = pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.Enable;
653 
654         if (pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.Enable) {
655             if (pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.dehaze_setting.en &&
656                 pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.enhance_setting.en) {
657                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
658                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_ENABLE;
659             } else if (pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.dehaze_setting.en &&
660                        !pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.enhance_setting.en) {
661                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
662                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_DISABLE;
663             } else if (!pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.dehaze_setting.en &&
664                        pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.enhance_setting.en) {
665                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
666                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_ENABLE;
667             } else {
668                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_DISABLE;
669                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_DISABLE;
670             }
671 
672             if (pAdehazeCtx->AdehazeAtrrV10.stAuto.DehazeTuningPara.hist_setting.en)
673                 pAdehzeProcRes->ProcResV10.hist_en = FUNCTION_ENABLE;
674             else
675                 pAdehzeProcRes->ProcResV10.hist_en = FUNCTION_DISABLE;
676         }
677     } else if (pAdehazeCtx->AdehazeAtrrV10.mode == DEHAZE_API_MANUAL) {
678         pAdehzeProcRes->enable = pAdehazeCtx->AdehazeAtrrV10.stManual.Enable;
679 
680         if (pAdehazeCtx->AdehazeAtrrV10.stManual.Enable) {
681             if (pAdehazeCtx->AdehazeAtrrV10.stManual.dehaze_setting.en &&
682                 pAdehazeCtx->AdehazeAtrrV10.stManual.enhance_setting.en) {
683                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
684                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_ENABLE;
685             } else if (pAdehazeCtx->AdehazeAtrrV10.stManual.dehaze_setting.en &&
686                        !pAdehazeCtx->AdehazeAtrrV10.stManual.enhance_setting.en) {
687                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
688                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_DISABLE;
689             } else if (!pAdehazeCtx->AdehazeAtrrV10.stManual.dehaze_setting.en &&
690                        pAdehazeCtx->AdehazeAtrrV10.stManual.enhance_setting.en) {
691                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_ENABLE;
692                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_ENABLE;
693             } else {
694                 pAdehzeProcRes->ProcResV10.dc_en      = FUNCTION_DISABLE;
695                 pAdehzeProcRes->ProcResV10.enhance_en = FUNCTION_DISABLE;
696             }
697 
698             if (pAdehazeCtx->AdehazeAtrrV10.stManual.hist_setting.en)
699                 pAdehzeProcRes->ProcResV10.hist_en = FUNCTION_ENABLE;
700             else
701                 pAdehzeProcRes->ProcResV10.hist_en = FUNCTION_DISABLE;
702         }
703     } else {
704         LOGE_ADEHAZE("%s: Dehaze api in WRONG MODE!!!, dehaze by pass!!!\n", __FUNCTION__);
705         pAdehzeProcRes->enable = false;
706     }
707 
708     return pAdehzeProcRes->enable;
709     LOG1_ADEHAZE("%s:exit!\n", __FUNCTION__);
710 }
711