1 /*
2 * Copyright (c) 2019 Rockchip Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 #include "sample_comm.h"
19
sample_ae_usage()20 static void sample_ae_usage()
21 {
22 printf("Usage : \n");
23 printf("\t 0) AE: set ae speed.\n");
24 printf("\t 1) AE: set ae delay.\n\n");
25 printf("\t 2) AE: set exp manual.\n");
26 printf("\t 3) AE: set exp auto.\n");
27 printf("\t 4) AE: set manual time & auto gain.\n");
28 printf("\t 5) AE: set auto time & manual gain.\n");
29 printf("\t 6) AE: set time range.\n");
30 printf("\t 7) AE: get time range.\n");
31 printf("\t 8) AE: set gain range.\n");
32 printf("\t 9) AE: get gain range.\n");
33 printf("\t a) AE: set fix fps.\n");
34 printf("\t b) AE: set auto fps.\n");
35 printf("\t c) AE: set anti_flicker frequency 50HZ.\n");
36 printf("\t d) AE: set anti_flicker frequency 60HZ.\n");
37 printf("\t e) AE: set anti_flicker disable.\n");
38 printf("\t f) AE: set grid_weight directly.\n");
39 printf("\t g) AE: set grid_weight by advanced.\n");
40 printf("\t h) AE: set ae on(= unlock ae).\n");
41 printf("\t i) AE: set ae off(= lock ae).\n");
42 printf("\t j) AE: set exp windows.\n");
43 printf("\t k) AE: set back_light_ctrl.\n");
44 printf("\t l) AE: set over_exp_ctrl.\n");
45 printf("\t m) AE: set hdr exp ratio.\n");
46 printf("\t n) AE: set linear route.\n");
47 printf("\t o) AE: set hdr mframe params.\n");
48 printf("\t p) AE: get fps.\n");
49
50 printf("\t W) AE: test default mode.\n");
51 printf("\t X) AE: test sync mode.\n");
52 printf("\t Y) AE: test async mode.\n");
53 printf("\t Z) AE: test async mode, twice set.\n\n");
54
55 printf("\t C) AE: enter hall dc-iris calib.\n");
56
57 printf("\t q/Q) AE: return to main sample screen.\n");
58 printf("\n");
59 printf("\t please press the key: \n\n");
60
61 return;
62 }
63
sample_print_ae_info(const void * arg)64 void sample_print_ae_info(const void *arg)
65 {
66 printf ("enter AE modult test!\n");
67 }
68
sample_hall_dciris_calib(const rk_aiq_sys_ctx_t * ctx)69 static int sample_hall_dciris_calib(const rk_aiq_sys_ctx_t* ctx) {
70 XCamReturn ret = XCAM_RETURN_NO_ERROR;
71
72 /* PARAMS CONFIG:
73 fix_time: manual time
74 fix_gain: manual gain
75 iris_val_open: target value when iris is fully open
76 iris_val_close: target value when iris is fully closed
77 iris_val_step: iris target calib step
78 iris_max_diam: equivalent diameter when iris is fully open
79 iris_diam: iris diameter need to be calibrated
80 */
81 float fix_time = 0.04f, fix_gain = 1.0f;
82 int iris_val_open = 0, iris_val_close = 500, iris_val_step = 10;
83 float iris_max_diam = 10.0f;
84 float iris_diam[] = { 10.0, 9.9, 9.8, 9.7, 9.6, 9.5, 9.4, 9.3, 9.2, 9.1, 9.0 };
85
86 Uapi_ExpSwAttrV2_t expSwAttr;
87 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
88 // fix aec
89 expSwAttr.AecOpType = RK_AIQ_OP_MODE_MANUAL;
90 expSwAttr.stManual.LinearAE.ManualGainEn = true;
91 expSwAttr.stManual.LinearAE.ManualTimeEn = true;
92 expSwAttr.stManual.LinearAE.GainValue = fix_gain;
93 expSwAttr.stManual.LinearAE.TimeValue = fix_time;
94 // fix ae grid weight
95 uint8_t GridWeights[225] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
96 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
97 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
98 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
99 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
100 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
102 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
103 };
104 memcpy(expSwAttr.GridWeights.uCoeff, GridWeights, sizeof(expSwAttr.GridWeights.uCoeff));
105 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
106 // config iris
107 Uapi_IrisAttrV2_t irisAttr;
108 ret = rk_aiq_user_api2_ae_getIrisAttr(ctx, &irisAttr);
109 irisAttr.Params.Enable = true;
110 irisAttr.Params.IrisType = IRISV2_HDC_TYPE;
111 irisAttr.Params.ManualEn = true;
112 irisAttr.Params.ManualAttr.HDCIrisTargetValue = iris_val_open;
113 ret = rk_aiq_user_api2_ae_setIrisAttr(ctx, irisAttr);
114 // TODO: fix af zoom and focus
115
116 printf("HDC IRIS Calib start ...... \n");
117 printf("Calib between IrisTargetValue and IrisGain:\n");
118 int count = -1, cur_iris_val = iris_val_open, cur_iris_gain = 512, iris_val[1024] = { 0 }, iris_gain[1024] = { 0 };
119 float mean_luma_max, cur_mean_luma;
120 Uapi_ExpQueryInfo_t ExpResInfo;
121 sleep(5);
122 ret = rk_aiq_user_api2_ae_queryExpResInfo(ctx, &ExpResInfo);
123 mean_luma_max = ExpResInfo.LinAeInfo.MeanLuma;
124
125 while (count++ < 1024) {
126 ret = rk_aiq_user_api2_ae_getIrisAttr(ctx, &irisAttr);
127 irisAttr.Params.ManualAttr.HDCIrisTargetValue = cur_iris_val;
128 ret = rk_aiq_user_api2_ae_setIrisAttr(ctx, irisAttr);
129 sleep(3);
130 rk_aiq_user_api2_ae_queryExpResInfo(ctx, &ExpResInfo);
131 cur_mean_luma = ExpResInfo.LinAeInfo.MeanLuma;
132 cur_iris_gain = MIN(int(cur_mean_luma / mean_luma_max * 512 + 0.5f), 512);
133 iris_val[count] = cur_iris_val;
134 iris_gain[count] = cur_iris_gain;
135 printf("step id=%d, cur iris val=%d, gain=%d, luma=%f\n", count, cur_iris_val, cur_iris_gain, cur_mean_luma);
136
137 if (iris_val_open - iris_val_close > 0) {
138 if (cur_iris_val <= iris_val_close)
139 break;
140 else
141 cur_iris_val -= iris_val_step;
142 } else {
143 if (cur_iris_val >= iris_val_close)
144 break;
145 else
146 cur_iris_val += iris_val_step;
147 }
148 }
149
150 printf("Calib between IrisDiameter and IrisTargetValue:\n");
151 int iris_diam_count = sizeof(iris_diam) / sizeof(iris_diam[0]);
152 int zoom_target_val, i, dot;
153 float tmp_iris_gain;
154 for (i = 0; i < iris_diam_count; i++) {
155 tmp_iris_gain = (iris_diam[i] * iris_diam[i]) / (iris_max_diam * iris_max_diam) * 512;
156 for (dot = 0; dot < count; dot++) {
157 if (tmp_iris_gain < iris_gain[dot] && tmp_iris_gain > iris_gain[dot + 1])
158 break;
159 }
160 zoom_target_val = int(1.0 * (tmp_iris_gain - iris_gain[dot]) / (iris_gain[dot + 1] - iris_gain[dot]) *
161 (iris_val[dot + 1] - iris_val[dot]) +
162 iris_val[dot] + 0.5f);
163 printf("num=%d, iris diameter=%f, val=%d, gain=%d\n", i, iris_diam[i], zoom_target_val, int(tmp_iris_gain));
164 }
165
166 printf("HDC IRIS Calib Done ...... \n");
167
168 return 0;
169 }
170
sample_set_ae_onoff(const rk_aiq_sys_ctx_t * ctx,bool on)171 static int sample_set_ae_onoff(const rk_aiq_sys_ctx_t* ctx, bool on)
172 {
173 XCamReturn ret = XCAM_RETURN_NO_ERROR;
174 Uapi_ExpSwAttrV2_t expSwAttr;
175
176 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
177 expSwAttr.Enable = on;
178 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
179
180 return 0;
181 }
182
sample_set_exp_manual(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)183 static int sample_set_exp_manual(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
184 {
185 XCamReturn ret = XCAM_RETURN_NO_ERROR;
186 Uapi_ExpSwAttrV2_t expSwAttr;
187
188 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
189 expSwAttr.sync.sync_mode = sync;
190 expSwAttr.sync.done = false;
191 expSwAttr.AecOpType = RK_AIQ_OP_MODE_MANUAL;
192 //LinearAE
193 expSwAttr.stManual.LinearAE.ManualGainEn = true;
194 expSwAttr.stManual.LinearAE.ManualTimeEn = true;
195 expSwAttr.stManual.LinearAE.GainValue = 1.0f; /*gain = 1x*/
196 expSwAttr.stManual.LinearAE.TimeValue = 0.02f; /*time = 1/50s*/
197 //HdrAE (should set all frames)
198 expSwAttr.stManual.HdrAE.ManualGainEn = true;
199 expSwAttr.stManual.HdrAE.ManualTimeEn = true;
200 expSwAttr.stManual.HdrAE.GainValue[0] = 1.0f; /*sframe gain = 1x*/
201 expSwAttr.stManual.HdrAE.TimeValue[0] = 0.002f; /*sframe time = 1/500s*/
202 expSwAttr.stManual.HdrAE.GainValue[1] = 2.0f; /*mframe gain = 2x*/
203 expSwAttr.stManual.HdrAE.TimeValue[1] = 0.01f; /*mframe time = 1/100s*/
204 expSwAttr.stManual.HdrAE.GainValue[2] = 4.0f; /*lframe gain = 4x*/
205 expSwAttr.stManual.HdrAE.TimeValue[2] = 0.02f; /*lframe time = 1/50s*/
206 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
207
208 return 0;
209 }
210
sample_set_exp_manual_test(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)211 static int sample_set_exp_manual_test(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
212 {
213 XCamReturn ret = XCAM_RETURN_NO_ERROR;
214 Uapi_ExpSwAttrV2_t expSwAttr;
215
216 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
217 expSwAttr.sync.sync_mode = sync;
218 expSwAttr.sync.done = false;
219 expSwAttr.AecOpType = RK_AIQ_OP_MODE_MANUAL;
220 //LinearAE
221 expSwAttr.stManual.LinearAE.ManualGainEn = true;
222 expSwAttr.stManual.LinearAE.ManualTimeEn = true;
223 expSwAttr.stManual.LinearAE.GainValue = 1.3f; /*gain = 1.3x*/
224 expSwAttr.stManual.LinearAE.TimeValue = 0.03f; /*time =0.030s*/
225 //HdrAE (should set all frames)
226 expSwAttr.stManual.HdrAE.ManualGainEn = true;
227 expSwAttr.stManual.HdrAE.ManualTimeEn = true;
228 expSwAttr.stManual.HdrAE.GainValue[0] = 1.1f; /*sframe gain = 1x*/
229 expSwAttr.stManual.HdrAE.TimeValue[0] = 0.003f; /*sframe time = 1/500s*/
230 expSwAttr.stManual.HdrAE.GainValue[1] = 2.1f; /*mframe gain = 2x*/
231 expSwAttr.stManual.HdrAE.TimeValue[1] = 0.02f; /*mframe time = 1/100s*/
232 expSwAttr.stManual.HdrAE.GainValue[2] = 4.1f; /*lframe gain = 4x*/
233 expSwAttr.stManual.HdrAE.TimeValue[2] = 0.03f; /*lframe time = 1/50s*/
234 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
235
236 return 0;
237 }
238
sample_set_exp_auto(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)239 static int sample_set_exp_auto(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
240 {
241 XCamReturn ret = XCAM_RETURN_NO_ERROR;
242 Uapi_ExpSwAttrV2_t expSwAttr;
243
244 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
245 expSwAttr.sync.sync_mode = sync;
246 expSwAttr.sync.done = false;
247 expSwAttr.AecOpType = RK_AIQ_OP_MODE_AUTO;
248 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
249
250 return 0;
251 }
252
sample_set_time_manual_and_gain_auto(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)253 static int sample_set_time_manual_and_gain_auto(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
254 {
255 XCamReturn ret = XCAM_RETURN_NO_ERROR;
256 Uapi_ExpSwAttrV2_t expSwAttr;
257
258 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
259 expSwAttr.sync.sync_mode = sync;
260 expSwAttr.sync.done = false;
261 expSwAttr.AecOpType = RK_AIQ_OP_MODE_MANUAL;
262 //LinearAE
263 expSwAttr.stManual.LinearAE.ManualGainEn = false;
264 expSwAttr.stManual.LinearAE.ManualTimeEn = true;
265 expSwAttr.stManual.LinearAE.ManualIspDgainEn = false;
266 expSwAttr.stManual.LinearAE.TimeValue = 0.01f; /*time = 0.01 s*/
267 //HdrAE (NOTE: hdr total int time should < 1/fps)
268 expSwAttr.stManual.HdrAE.ManualGainEn = false;
269 expSwAttr.stManual.HdrAE.ManualTimeEn = true;
270 expSwAttr.stManual.HdrAE.ManualIspDgainEn = false;
271 expSwAttr.stManual.HdrAE.TimeValue[0] = 0.008f; /*sframe time = 0.008s*/
272 expSwAttr.stManual.HdrAE.TimeValue[1] = 0.01f; /*mframe time = 0.01s*/
273 expSwAttr.stManual.HdrAE.TimeValue[2] = 0.01f; /*lframe time = 0.01s*/
274 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
275
276
277 return 0;
278 }
279
280
sample_set_time_auto_and_gain_manual(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)281 static int sample_set_time_auto_and_gain_manual(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
282 {
283 XCamReturn ret = XCAM_RETURN_NO_ERROR;
284 Uapi_ExpSwAttrV2_t expSwAttr;
285
286 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
287 expSwAttr.sync.sync_mode = sync;
288 expSwAttr.sync.done = false;
289 expSwAttr.AecOpType = RK_AIQ_OP_MODE_MANUAL;
290 //LinearAE
291 expSwAttr.stManual.LinearAE.ManualGainEn = true;
292 expSwAttr.stManual.LinearAE.ManualTimeEn = false;
293 expSwAttr.stManual.LinearAE.ManualIspDgainEn = false;
294 expSwAttr.stManual.LinearAE.GainValue = 2.0f; /*gain = 2x*/
295 //HdrAE (can only set one frame)
296 expSwAttr.stManual.HdrAE.ManualGainEn = true;
297 expSwAttr.stManual.HdrAE.ManualTimeEn = false;
298 expSwAttr.stManual.HdrAE.ManualIspDgainEn = false;
299 expSwAttr.stManual.HdrAE.GainValue[0] = 1.0f; /*sframe gain = 1x*/
300 expSwAttr.stManual.HdrAE.GainValue[1] = 2.0f; /*mframe gain = 2x*/
301 expSwAttr.stManual.HdrAE.GainValue[2] = 4.0f; /*lframe gain = 4x*/
302 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
303
304 return 0;
305 }
306
sample_set_time_range(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)307 static int sample_set_time_range(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
308 {
309 XCamReturn ret = XCAM_RETURN_NO_ERROR;
310 Uapi_ExpSwAttrV2_t expSwAttr;
311
312 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
313 expSwAttr.sync.sync_mode = sync;
314 expSwAttr.sync.done = false;
315 //set time range in struct "stAdvanced"
316 expSwAttr.stAdvanced.SetAeRangeEn = true;/*must enable*/
317 //LinAE
318 expSwAttr.stAdvanced.SetLinAeRange.stExpTimeRange.Max = 0.04f; /*time_max = 0.04*/
319 expSwAttr.stAdvanced.SetLinAeRange.stExpTimeRange.Min = 0.001f; /*time_min = 0.001*/
320 //HdrAE
321 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[0].Max = 0.002f; /*sframe time_max = 0.02*/
322 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[0].Min = 0.001f; /*sframe time_min = 0.01*/
323 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[1].Max = 0.003f; /*mframe time_max = 0.03*/
324 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[1].Min = 0.002f; /*mframe time_min = 0.02*/
325 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[2].Max = 0.04f; /*lframe time_max = 0.03*/
326 expSwAttr.stAdvanced.SetHdrAeRange.stExpTimeRange[2].Min = 0.03f; /*lframe time_min = 0.02*/
327 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
328
329 return 0;
330 }
331
sample_get_time_range(const rk_aiq_sys_ctx_t * ctx)332 static int sample_get_time_range(const rk_aiq_sys_ctx_t* ctx)
333 {
334 XCamReturn ret = XCAM_RETURN_NO_ERROR;
335 Uapi_ExpSwAttrV2_t expSwAttr;
336
337 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
338 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
339 //get time range in struct "stAuto"
340 printf("linear time range=[%f,%f]\n",
341 expSwAttr.stAuto.LinAeRange.stExpTimeRange.Min, expSwAttr.stAuto.LinAeRange.stExpTimeRange.Max);
342 printf("hdr stime range=[%f,%f], mtime range=[%f,%f], ltime range=[%f,%f]\n",
343 expSwAttr.stAuto.HdrAeRange.stExpTimeRange[0].Min, expSwAttr.stAuto.HdrAeRange.stExpTimeRange[0].Max,
344 expSwAttr.stAuto.HdrAeRange.stExpTimeRange[1].Min, expSwAttr.stAuto.HdrAeRange.stExpTimeRange[1].Max,
345 expSwAttr.stAuto.HdrAeRange.stExpTimeRange[2].Min, expSwAttr.stAuto.HdrAeRange.stExpTimeRange[2].Max);
346
347 return 0;
348 }
349
sample_set_gain_range(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)350 static int sample_set_gain_range(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
351 {
352 XCamReturn ret = XCAM_RETURN_NO_ERROR;
353 Uapi_ExpSwAttrV2_t expSwAttr;
354
355 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
356 expSwAttr.sync.sync_mode = sync;
357 expSwAttr.sync.done = false;
358 //set gain range in struct "stAdvanced"
359 expSwAttr.stAdvanced.SetAeRangeEn = true;/*must enable*/
360 //LinAE
361 expSwAttr.stAdvanced.SetLinAeRange.stGainRange.Max = 32.0f; /*gain_max = 32x*/
362 expSwAttr.stAdvanced.SetLinAeRange.stGainRange.Min = 1.0f; /*gain_min = 1x*/
363 //HdrAE
364 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[0].Max = 32.0f; /*sframe gain_max = 2x*/
365 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[0].Min = 1.0f; /*sframe gain_min = 1x*/
366 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[1].Max = 64.0f; /*mframe gain_max = 64x*/
367 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[1].Min = 1.0f; /*mframe gian_min = 1x*/
368 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[2].Max = 64.0f; /*lframe gain_max = 64x*/
369 expSwAttr.stAdvanced.SetHdrAeRange.stGainRange[2].Min = 1.0f; /*lframe gain_min = 1x*/
370 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
371
372 return 0;
373 }
374
sample_get_gain_range(const rk_aiq_sys_ctx_t * ctx)375 static int sample_get_gain_range(const rk_aiq_sys_ctx_t* ctx)
376 {
377 XCamReturn ret = XCAM_RETURN_NO_ERROR;
378 Uapi_ExpSwAttrV2_t expSwAttr;
379
380 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
381 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
382 //get gain range in struct "stAuto"
383 printf("linear gain range=[%f,%f]\n",
384 expSwAttr.stAuto.LinAeRange.stGainRange.Min, expSwAttr.stAuto.LinAeRange.stGainRange.Max);
385 printf("hdr sgain range=[%f,%f], mgain range=[%f,%f], lgain range=[%f,%f]\n",
386 expSwAttr.stAuto.HdrAeRange.stGainRange[0].Min, expSwAttr.stAuto.HdrAeRange.stGainRange[0].Max,
387 expSwAttr.stAuto.HdrAeRange.stGainRange[1].Min, expSwAttr.stAuto.HdrAeRange.stGainRange[1].Max,
388 expSwAttr.stAuto.HdrAeRange.stGainRange[2].Min, expSwAttr.stAuto.HdrAeRange.stGainRange[2].Max);
389
390 return 0;
391 }
392
sample_is_fps_fix(const rk_aiq_sys_ctx_t * ctx,bool on,rk_aiq_uapi_mode_sync_e sync)393 static int sample_is_fps_fix(const rk_aiq_sys_ctx_t* ctx, bool on, rk_aiq_uapi_mode_sync_e sync)
394 {
395 XCamReturn ret = XCAM_RETURN_NO_ERROR;
396 Uapi_ExpSwAttrV2_t expSwAttr;
397
398 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
399 expSwAttr.sync.sync_mode = sync;
400 expSwAttr.sync.done = false;
401 expSwAttr.stAuto.stFrmRate.isFpsFix = on;
402 if(expSwAttr.stAuto.stFrmRate.isFpsFix)
403 expSwAttr.stAuto.stFrmRate.FpsValue = 20; /*Fix fps = 20*/
404 else
405 expSwAttr.stAuto.stFrmRate.FpsValue = 25; /*Auto fps max = 25*/
406 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
407
408 return 0;
409 }
sample_get_fps(const rk_aiq_sys_ctx_t * ctx,float * fps,rk_aiq_uapi_mode_sync_e sync)410 static int sample_get_fps(const rk_aiq_sys_ctx_t* ctx, float* fps, rk_aiq_uapi_mode_sync_e sync)
411 {
412 XCamReturn ret = XCAM_RETURN_NO_ERROR;
413 Uapi_ExpQueryInfo_t ExpResInfo;
414 ret = rk_aiq_user_api2_ae_queryExpResInfo(ctx, &ExpResInfo);
415 *fps = ExpResInfo.Fps;
416
417 return 0;
418 }
419
sample_set_anti_flicker(const rk_aiq_sys_ctx_t * ctx,bool on,CalibDb_FlickerFreqV2_t frequency,CalibDb_AntiFlickerModeV2_t mode,rk_aiq_uapi_mode_sync_e sync)420 static int sample_set_anti_flicker(const rk_aiq_sys_ctx_t* ctx,
421 bool on,
422 CalibDb_FlickerFreqV2_t frequency,
423 CalibDb_AntiFlickerModeV2_t mode,
424 rk_aiq_uapi_mode_sync_e sync)
425 {
426 XCamReturn ret = XCAM_RETURN_NO_ERROR;
427 Uapi_ExpSwAttrV2_t expSwAttr;
428
429 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
430 expSwAttr.sync.sync_mode = sync;
431 expSwAttr.sync.done = false;
432 //set antifilicker mode
433 expSwAttr.stAuto.stAntiFlicker.enable = on;
434 expSwAttr.stAuto.stAntiFlicker.Frequency = frequency;
435 expSwAttr.stAuto.stAntiFlicker.Mode = mode;
436 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
437
438 return 0;
439 }
440
sample_set_gridweight(const rk_aiq_sys_ctx_t * ctx,int type,rk_aiq_uapi_mode_sync_e sync)441 static int sample_set_gridweight(const rk_aiq_sys_ctx_t* ctx, int type, rk_aiq_uapi_mode_sync_e sync)
442 {
443 XCamReturn ret = XCAM_RETURN_NO_ERROR;
444 Uapi_ExpSwAttrV2_t expSwAttr;
445 uint8_t GridWeights[225] = {
446 0, 0, 1, 2, 2, 3, 4, 5, 4, 3, 2, 2, 1, 0, 0,
447 0, 1, 2, 3, 3, 4, 5, 6, 5, 4, 3, 3, 2, 1, 0,
448 1, 2, 3, 5, 5, 6, 7, 8, 7, 6, 5, 5, 3, 2, 1,
449 2, 3, 5, 7, 7, 8, 9, 10, 9, 8, 7, 7, 5, 3, 2,
450 2, 3, 5, 7, 8, 9, 10, 11, 10, 9, 8, 7, 5, 3, 2,
451 2, 4, 6, 8, 9, 10, 11, 12, 11, 10, 9, 8, 6, 4, 2,
452 2, 4, 6, 9, 10, 11, 12, 13, 12, 11, 10, 9, 6, 4, 2,
453 3, 5, 7, 10, 11, 12, 13, 14, 13, 12, 11, 10, 7, 5, 3,
454 2, 4, 6, 9, 10, 11, 12, 13, 12, 11, 10, 9, 6, 4, 2,
455 2, 4, 6, 8, 9, 10, 11, 12, 11, 10, 9, 8, 6, 4, 2,
456 2, 3, 5, 7, 8, 9, 10, 11, 10, 9, 8, 7, 5, 3, 2,
457 2, 3, 5, 7, 7, 8, 9, 10, 9, 8, 7, 7, 5, 3, 2,
458 1, 2, 4, 6, 6, 7, 8, 9, 8, 7, 6, 6, 4, 2, 1,
459 0, 1, 3, 5, 5, 6, 7, 8, 7, 6, 5, 5, 3, 1, 0,
460 0, 1, 3, 5, 5, 6, 7, 8, 7, 6, 5, 5, 3, 1, 0
461 };
462
463 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
464 expSwAttr.sync.sync_mode = sync;
465 expSwAttr.sync.done = false;
466 if (type == 0)
467 memcpy(expSwAttr.GridWeights.uCoeff, GridWeights, sizeof(expSwAttr.GridWeights.uCoeff));
468 else if (type == 1) {
469 expSwAttr.stAdvanced.enable = true; //important! true means preferring to use these parameters
470 memcpy(expSwAttr.stAdvanced.GridWeights, GridWeights, sizeof(expSwAttr.stAdvanced.GridWeights));
471 }
472 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
473
474 return 0;
475 }
476
sample_set_BackLightCtrl(const rk_aiq_sys_ctx_t * ctx,bool on,float bias,rk_aiq_uapi_mode_sync_e sync)477 static int sample_set_BackLightCtrl(const rk_aiq_sys_ctx_t* ctx, bool on, float bias, rk_aiq_uapi_mode_sync_e sync)
478 {
479 XCamReturn ret = XCAM_RETURN_NO_ERROR;
480 Uapi_LinExpAttrV2_t LinExpAttr;
481
482 memset(&LinExpAttr, 0, sizeof(Uapi_LinExpAttrV2_t));
483 ret = rk_aiq_user_api2_ae_getLinExpAttr(ctx, &LinExpAttr);
484 LinExpAttr.sync.sync_mode = sync;
485 LinExpAttr.sync.done = false;
486 //set BackLightCtrl
487 LinExpAttr.Params.BackLightCtrl.Enable = on;
488 LinExpAttr.Params.BackLightCtrl.StrBias = bias;
489 ret = rk_aiq_user_api2_ae_setLinExpAttr(ctx, LinExpAttr);
490
491 return 0;
492 }
493
sample_set_OverExpCtrl(const rk_aiq_sys_ctx_t * ctx,bool on,float bias,rk_aiq_uapi_mode_sync_e sync)494 static int sample_set_OverExpCtrl(const rk_aiq_sys_ctx_t* ctx, bool on, float bias, rk_aiq_uapi_mode_sync_e sync)
495 {
496 XCamReturn ret = XCAM_RETURN_NO_ERROR;
497 Uapi_LinExpAttrV2_t LinExpAttr;
498
499 memset(&LinExpAttr, 0, sizeof(Uapi_LinExpAttrV2_t));
500 ret = rk_aiq_user_api2_ae_getLinExpAttr(ctx, &LinExpAttr);
501 LinExpAttr.sync.sync_mode = sync;
502 LinExpAttr.sync.done = false;
503 //set OverExpCtrl
504 LinExpAttr.Params.OverExpCtrl.Enable = on;
505 LinExpAttr.Params.OverExpCtrl.StrBias = bias;
506 ret = rk_aiq_user_api2_ae_setLinExpAttr(ctx, LinExpAttr);
507
508 return 0;
509 }
510
sample_set_exp_ratio_type(const rk_aiq_sys_ctx_t * ctx,CalibDb_HdrAeRatioTypeV2_t type,float bias,rk_aiq_uapi_mode_sync_e sync)511 static int sample_set_exp_ratio_type(const rk_aiq_sys_ctx_t* ctx, CalibDb_HdrAeRatioTypeV2_t type, float bias, rk_aiq_uapi_mode_sync_e sync)
512 {
513 XCamReturn ret = XCAM_RETURN_NO_ERROR;
514 Uapi_HdrExpAttrV2_t HdrExpAttr;
515
516 memset(&HdrExpAttr, 0, sizeof(Uapi_HdrExpAttrV2_t));
517 ret = rk_aiq_user_api2_ae_getHdrExpAttr(ctx, &HdrExpAttr);
518 HdrExpAttr.sync.sync_mode = sync;
519 HdrExpAttr.sync.done = false;
520 //set ExpRatioType (AUTO/FIX)
521 HdrExpAttr.Params.ExpRatioCtrl.ExpRatioType = type;
522 //set Evbias
523 HdrExpAttr.Params.Evbias = bias;
524 ret = rk_aiq_user_api2_ae_setHdrExpAttr(ctx, HdrExpAttr);
525
526 return 0;
527 }
528
sample_set_linear_route(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)529 static int sample_set_linear_route(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
530 {
531 XCamReturn ret = XCAM_RETURN_NO_ERROR;
532 Uapi_LinAeRouteAttr_t LinExpRouteAttr;
533
534 memset(&LinExpRouteAttr, 0x00, sizeof(Uapi_LinAeRouteAttr_t));
535 ret = rk_aiq_user_api2_ae_getLinAeRouteAttr(ctx, &LinExpRouteAttr);
536 LinExpRouteAttr.sync.sync_mode = sync;
537 LinExpRouteAttr.sync.done = false;
538
539 int len = 8;
540 float TimeDot[8] = {0, 0.01, 0.01, 0.02, 0.02, 0.03, 0.03, 0.04};
541 float GainDot[8] = {1, 1, 4, 4, 8, 8, 16, 32};
542 float IspGainDot[8] = {1, 1, 1, 1, 1, 1, 1, 1};
543 int PirisDot[8] = {512, 512, 512, 512, 512, 512, 512, 512};
544
545 LinExpRouteAttr.Params.TimeDot_len = len;
546 LinExpRouteAttr.Params.GainDot_len = len;
547 LinExpRouteAttr.Params.IspDGainDot_len = len;
548 LinExpRouteAttr.Params.PIrisDot_len = len;
549
550 LinExpRouteAttr.Params.GainDot = GainDot;
551 LinExpRouteAttr.Params.IspDGainDot = IspGainDot;
552 LinExpRouteAttr.Params.TimeDot = TimeDot;
553 LinExpRouteAttr.Params.PIrisDot = PirisDot;
554 ret = rk_aiq_user_api2_ae_setLinAeRouteAttr(ctx, LinExpRouteAttr);
555
556 return 0;
557 }
558
sample_set_hdr_mframe_params(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)559 static int sample_set_hdr_mframe_params(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
560 {
561 XCamReturn ret = XCAM_RETURN_NO_ERROR;
562 Uapi_HdrExpAttrV2_t HdrExpAttr;
563
564 memset(&HdrExpAttr, 0, sizeof(Uapi_HdrExpAttrV2_t));
565 ret = rk_aiq_user_api2_ae_getHdrExpAttr(ctx, &HdrExpAttr);
566 HdrExpAttr.sync.sync_mode = sync;
567 HdrExpAttr.sync.done = false;
568 int len = 8;
569 float explevel[8] = {0, 0.096, 0.192, 0.384, 0.96, 1.344, 1.92, 3};
570 float setpoint[8] = {50, 45, 40, 35, 30, 25, 20, 15};
571
572 HdrExpAttr.Params.MframeCtrl.MExpLevel_len = len;
573 HdrExpAttr.Params.MframeCtrl.MSetPoint_len = len;
574 HdrExpAttr.Params.MframeCtrl.MExpLevel = explevel;
575 HdrExpAttr.Params.MframeCtrl.MSetPoint = setpoint;
576
577 ret = rk_aiq_user_api2_ae_setHdrExpAttr(ctx, HdrExpAttr);
578
579 return 0;
580 }
581
sample_set_ae_speed(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)582 static int sample_set_ae_speed(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
583 {
584 XCamReturn ret = XCAM_RETURN_NO_ERROR;
585
586 Uapi_ExpSwAttrV2_t expSwAttr;
587 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
588 expSwAttr.sync.sync_mode = sync;
589 expSwAttr.sync.done = false;
590 //set ae speed
591 expSwAttr.stAuto.stAeSpeed.DampOver = 0.8f;
592 expSwAttr.stAuto.stAeSpeed.DampDark2Bright = 0.8f;
593
594 expSwAttr.stAuto.stAeSpeed.DampUnder = 0.8f;
595 expSwAttr.stAuto.stAeSpeed.DampBright2Dark = 0.8f;
596
597 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
598
599 return 0;
600
601 }
602
sample_set_ae_delay(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)603 static int sample_set_ae_delay(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
604 {
605 XCamReturn ret = XCAM_RETURN_NO_ERROR;
606
607 Uapi_ExpSwAttrV2_t expSwAttr;
608 ret = rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
609 expSwAttr.sync.sync_mode = sync;
610 expSwAttr.sync.done = false;
611 //set ae delay
612
613 expSwAttr.stAuto.DelayType = DELAY_TYPE_FRAME;
614 expSwAttr.stAuto.BlackDelay = 10;
615 expSwAttr.stAuto.WhiteDelay = 15;
616
617 ret = rk_aiq_user_api2_ae_setExpSwAttr(ctx, expSwAttr);
618
619 return 0;
620
621 }
622
sample_ae_module(const void * arg)623 XCamReturn sample_ae_module (const void *arg)
624 {
625 int key = -1;
626 CLEAR();
627
628 const demo_context_t *demo_ctx = (demo_context_t *)arg;
629 const rk_aiq_sys_ctx_t* ctx;
630 if (demo_ctx->camGroup) {
631 ctx = (rk_aiq_sys_ctx_t*)(demo_ctx->camgroup_ctx);
632 } else {
633 ctx = (rk_aiq_sys_ctx_t*)(demo_ctx->aiq_ctx);
634 }
635
636 if (ctx == nullptr) {
637 ERR ("%s, ctx is nullptr\n", __FUNCTION__);
638 return XCAM_RETURN_ERROR_PARAM;
639 }
640
641 Uapi_ExpWin_t ExpWin;
642 Uapi_ExpSwAttrV2_t expSwAttr;
643 float fps = 0.0f;
644
645 do {
646 sample_ae_usage ();
647
648 key = getchar ();
649 while (key == '\n' || key == '\r')
650 key = getchar ();
651 printf ("\n");
652
653 switch (key)
654 {
655 case '0':
656 sample_set_ae_speed(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
657 printf("set ae speed\n\n");
658 break;
659 case '1':
660 sample_set_ae_delay(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
661 printf("set ae delay\n\n");
662 break;
663 case '2':
664 sample_set_exp_manual(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
665 printf("set exp manual\n\n");
666 break;
667 case '3':
668 sample_set_exp_auto(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
669 printf("set exp auto\n\n");
670 break;
671 case '4':
672 sample_set_time_manual_and_gain_auto(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
673 printf("set manual time & auto gain\n\n");
674 break;
675 case '5':
676 sample_set_time_auto_and_gain_manual(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
677 printf("set auto time & manual gain\n\n");
678 break;
679 case '6':
680 sample_set_time_range(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
681 printf("set time range\n\n");
682 break;
683 case '7':
684 sample_get_time_range(ctx);
685 printf("get time range\n\n");
686 break;
687 case '8':
688 sample_set_gain_range(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
689 printf("set gain range\n\n");
690 break;
691 case '9':
692 sample_get_gain_range(ctx);
693 printf("get gain range\n\n");
694 break;
695 case 'a':
696 sample_is_fps_fix(ctx, true, RK_AIQ_UAPI_MODE_DEFAULT);
697 printf("set fix fps\n\n");
698 break;
699 case 'b':
700 sample_is_fps_fix(ctx, false, RK_AIQ_UAPI_MODE_DEFAULT);
701 printf("set auto fps\n\n");
702 break;
703 case 'c':
704 sample_set_anti_flicker(ctx, true, AECV2_FLICKER_FREQUENCY_50HZ, AECV2_ANTIFLICKER_AUTO_MODE, RK_AIQ_UAPI_MODE_DEFAULT);
705 printf("set anti_flicker frequency 50HZ\n\n");
706 break;
707 case 'd':
708 sample_set_anti_flicker(ctx, true, AECV2_FLICKER_FREQUENCY_60HZ, AECV2_ANTIFLICKER_NORMAL_MODE, RK_AIQ_UAPI_MODE_DEFAULT);
709 printf("set anti_flicker frequency 60HZ\n\n");
710 break;
711 case 'e':
712 sample_set_anti_flicker(ctx, false, AECV2_FLICKER_FREQUENCY_50HZ, AECV2_ANTIFLICKER_AUTO_MODE, RK_AIQ_UAPI_MODE_DEFAULT);
713 printf("set anti_flicker disable\n\n");
714 break;
715 case 'f':
716 sample_set_gridweight(ctx, 0, RK_AIQ_UAPI_MODE_DEFAULT);
717 printf("set grid weight directly\n\n");
718 break;
719 case 'g':
720 sample_set_gridweight(ctx, 1, RK_AIQ_UAPI_MODE_DEFAULT);
721 printf("set grid weight using stadvanced\n\n");
722 break;
723 case 'h':
724 sample_set_ae_onoff(ctx, true);
725 printf("set ae on\n\n");
726 break;
727 case 'i':
728 sample_set_ae_onoff(ctx, false);
729 printf("set ae off\n\n");
730 break;
731 case 'j':
732 ExpWin.Params.h_offs = 0;
733 ExpWin.Params.v_offs = 0;
734 ExpWin.Params.h_size = 240;
735 ExpWin.Params.v_size = 100;
736 ExpWin.sync.sync_mode = RK_AIQ_UAPI_MODE_DEFAULT;
737 rk_aiq_user_api2_ae_setExpWinAttr(ctx, ExpWin);
738 printf("set exp windows[0,0,240,100]\n\n");
739 break;
740 case 'k':
741 sample_set_BackLightCtrl(ctx, true, 100.0f, RK_AIQ_UAPI_MODE_DEFAULT);
742 printf("set back_light_ctrl\n\n");
743 break;
744 case 'l':
745 sample_set_OverExpCtrl(ctx, true, -100.0f, RK_AIQ_UAPI_MODE_DEFAULT);
746 printf("set over_exp_ctrl\n\n");
747 break;
748 case 'm':
749 sample_set_exp_ratio_type(ctx, AECV2_HDR_RATIOTYPE_MODE_AUTO, 50.0f, RK_AIQ_UAPI_MODE_DEFAULT);
750 printf("set hdr exp ratio\n\n");
751 break;
752 case 'n':
753 sample_set_linear_route(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
754 printf("set linear route\n\n");
755 break;
756 case 'o':
757 sample_set_hdr_mframe_params(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
758 printf("set hdr mframe params\n\n");
759 break;
760 case 'p':
761 sample_get_fps(ctx, &fps, RK_AIQ_UAPI_MODE_DEFAULT);
762 printf("cur fps = %f\n\n", fps);
763 break;
764 // TEST SYNC MODE
765 case 'W':
766 sample_set_exp_manual(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
767 printf("set exp manual, sync mode.\n\n");
768 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
769 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
770 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
771
772 usleep(40 * 1000);
773 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
774 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
775 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
776 break;
777 case 'X':
778 sample_set_exp_manual(ctx, RK_AIQ_UAPI_MODE_SYNC);
779 printf("set exp manual, sync mode.\n\n");
780 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
781 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
782 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
783
784 usleep(40 * 1000);
785 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
786 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
787 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
788 break;
789 case 'Y':
790 sample_set_exp_manual(ctx, RK_AIQ_UAPI_MODE_ASYNC);
791 printf("set exp manual, async mode.\n\n");
792 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
793 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
794 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
795
796 usleep(40 * 1000);
797 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
798 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
799 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
800 break;
801 case 'Z':
802 sample_set_exp_manual(ctx, RK_AIQ_UAPI_MODE_ASYNC);
803 printf("set exp manual, async mode(two groups).\n\n");
804 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
805 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
806 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
807 printf("\t get time = %f gain = %f\n", expSwAttr.stManual.LinearAE.TimeValue, expSwAttr.stManual.LinearAE.GainValue);
808
809 sample_set_exp_manual_test(ctx, RK_AIQ_UAPI_MODE_ASYNC);
810 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
811 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
812 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
813 printf("\t get time = %f gain = %f\n", expSwAttr.stManual.LinearAE.TimeValue, expSwAttr.stManual.LinearAE.GainValue);
814
815 usleep(40 * 1000);
816 memset(&expSwAttr, 0, sizeof(Uapi_ExpSwAttrV2_t));
817 rk_aiq_user_api2_ae_getExpSwAttr(ctx, &expSwAttr);
818 printf("\t sync = %d, done = %d\n", expSwAttr.sync.sync_mode, expSwAttr.sync.done);
819 printf("\t get time = %f gain = %f\n", expSwAttr.stManual.LinearAE.TimeValue, expSwAttr.stManual.LinearAE.GainValue);
820 break;
821 case 'C':
822 sample_hall_dciris_calib(ctx);
823 printf("enter hall dc-iris calib\n\n");
824 break;
825 default:
826 break;
827 }
828 } while (key != 'q' && key != 'Q');
829
830 return XCAM_RETURN_NO_ERROR;
831 }
832