hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
/*
 *  Copyright (c) 2019 Rockchip Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
 
#include "sample_comm.h"
 
typedef enum {
    AWB_CHANNEL_R = 0,
    AWB_CHANNEL_GR,
    AWB_CHANNEL_GB,
    AWB_CHANNEL_B,
    AWB_CHANNEL_MAX
} awb_channel_t;
 
#define safe_free(x) if(NULL!=(x))\
                           free(x); x=NULL;
static void sample_awb_usage()
{
    printf("Usage : \n");
    printf("  ImgProc API: \n");
    printf("\t 0) AWB: setWBMode-OP_MANUAL.\n");
    printf("\t 1) AWB: setWBMode-OP_AUTO.\n");
    printf("\t 2) AWB: getWBMode.\n");
    printf("\t 3) AWB: lockAWB.\n");
    printf("\t 4) AWB: unlockAWB.\n");
    printf("\t 5) AWB: setMWBScene.\n");
    printf("\t 6) AWB: getMWBScene.\n");
    printf("\t 7) AWB: setMWBGain.\n");
    printf("\t 8) AWB: getWBGain.\n");
    printf("\t 9) AWB: setMWBCT.\n");
    printf("\t a) AWB: getWBCT.\n");
    printf("\t b) AWB: setWbGainOffset.\n");
    printf("\t c) AWB: getWbGainOffset.\n");
    printf("\t d) AWB: setAwbGainAdjust.\n");
    printf("\t e) AWB: getAwbGainAdjust.\n");
    printf("\t f) AWB: setAllAttrib.\n");
    printf("\n");
    printf("  Module API: \n");
    printf("\t A) AWB: set Awbv21 AllAttr & Sync.\n");
    printf("\t B) AWB: set Awbv21 AllAttr & Async.\n");
    printf("\t C) AWB: set Awbv30 AllAttr & Sync.\n");
    printf("\t D) AWB: set Awbv30 AllAttr & Async.\n");
   printf("\t E) AWB: get CCT.\n");
    printf("\t F) AWB: Query Awb Info.\n");
    printf("\t G) AWB: Lock.\n");
    printf("\t I) AWB: Unlock.\n");
    printf("\t J) AWB: set Mode Manual & Sync.\n");
    printf("\t K) AWB: set Mode Manual & Async.\n");
    printf("\t L) AWB: set Mode Auto & Sync.\n");
    printf("\t M) AWB: set Mode Auto & Async.\n");
    printf("\t N) AWB: set Manual attr & Sync.\n");
    printf("\t O) AWB: set Manual attr & Async.\n");
    printf("\t P) AWB: set AwbGainAdjust & Sync.\n");
    printf("\t R) AWB: set AwbGainAdjust & Async.\n");
    printf("\t S) AWB: set WbGainOffset & Sync.\n");
    printf("\t T) AWB: set WbGainOffset & Async.\n");
    printf("\n");
    printf("\t h) AWB: help.\n");
    printf("\t q) AWB: return to main sample screen.\n");
 
    return;
}
 
void sample_print_awb_info(const void *arg)
{
    printf ("enter AWB modult test!\n");
}
 
/*
******************************
*
* ImgProc level API Sample Func
*
******************************
*/
 
static int sample_set_wbmode_manual(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapi2_setWBMode(ctx, OP_MANUAL);
    return 0;
}
 
static int sample_set_wbmode_auto(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapi2_setWBMode(ctx, OP_AUTO);
    return 0;
}
 
static int sample_get_wbmode(const rk_aiq_sys_ctx_t* ctx)
{
    opMode_t mode;
    rk_aiq_uapi2_getWBMode(ctx, &mode);
    printf("get WBMode=%d\n\n", mode);
    return 0;
}
 
static int sample_lock_awb(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapi2_lockAWB(ctx);
    return 0;
}
 
static int sample_unlock_awb(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapi2_unlockAWB(ctx);
    return 0;
}
 
static int sample_set_mwb_scene(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapi2_setMWBScene(ctx, RK_AIQ_WBCT_TWILIGHT);
    return 0;
}
 
static int sample_get_mwb_scene(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_scene_t scene;
    rk_aiq_uapi2_getMWBScene(ctx, &scene);
    printf("get MWBScene=%d\n\n", scene);
    return 0;
}
 
static int sample_set_mwb_gain(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_gain_t gain;
    gain.rgain = 0.5f;
    gain.grgain = 0.5f;
    gain.gbgain = 0.5f;
    gain.bgain = 0.5f;
    rk_aiq_uapi2_setMWBGain(ctx, &gain);
    return 0;
}
 
static int sample_get_mwb_gain(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_gain_t gain;
    rk_aiq_uapi2_getWBGain(ctx, &gain);
    printf("get WBGain=[%f %f %f %f]\n", gain.rgain, gain.grgain, gain.gbgain, gain.bgain);
    return 0;
}
 
static int sample_set_mwb_ct(const rk_aiq_sys_ctx_t* ctx)
{
    unsigned int cct;
    cct = 6000;
    rk_aiq_uapi2_setMWBCT(ctx, cct);
    return 0;
}
 
static int sample_get_mwb_ct(const rk_aiq_sys_ctx_t* ctx)
{
    unsigned int cct;
    rk_aiq_uapi2_getWBCT(ctx, &cct);
    printf("get cct=%d\n\n", cct);
    return 0;
}
 
static int sample_set_awb_gainoffset(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainOffset_t offset2 = {{RK_AIQ_UAPI_MODE_DEFAULT,false}, {true,{0.5,0,0,0.5}}};
    rk_aiq_uapi2_setAwbGainOffsetAttrib(ctx,offset2 );
    return 0;
}
 
static int sample_get_awb_gainoffset(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainOffset_t offset ;
    rk_aiq_uapi2_getAwbGainOffsetAttrib(ctx, &offset);
    printf("get WbGainOffset{%d,[%f,%f,%f,%f]}\n\n",
        offset.gainOffset.enable,
        offset.gainOffset.offset[0],
        offset.gainOffset.offset[1],
        offset.gainOffset.offset[2],
        offset.gainOffset.offset[3]);
    return 0;
}
 
static int sample_set_awb_gain_adjust(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainAdjust_t adjust ;
    memset(&adjust,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainAdjust_t));
    //get
    rk_aiq_uapi2_getAwbGainAdjustAttrib(ctx, &adjust);
    //modfiy
    adjust.sync.sync_mode = RK_AIQ_UAPI_MODE_DEFAULT;
    adjust.enable = true;
    //set
    rk_aiq_uapi2_setAwbGainAdjustAttrib(ctx, adjust);
    printf("set AwbGainAdjust\n\n");
    //free
    for(int i = 0; i < adjust.lutAll_len; i++) {
        safe_free(adjust.lutAll[i].cri_lut_out);
        safe_free(adjust.lutAll[i].ct_lut_out);
    }
    safe_free(adjust.lutAll);
    return 0;
}
 
static int sample_get_awb_gain_adjust(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainAdjust_t adjust ;
    memset(&adjust,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainAdjust_t));
    //get
    rk_aiq_uapi2_getAwbGainAdjustAttrib(ctx,&adjust );
    printf("get AwbGainAdjust {%d}\n\n",adjust.enable);
    //free
    for(int i = 0; i < adjust.lutAll_len; i++) {
        safe_free(adjust.lutAll[i].cri_lut_out);
        safe_free(adjust.lutAll[i].ct_lut_out);
    }
    safe_free(adjust.lutAll);
    return 0;
}
 
static int sample_set_awbv30_atrr(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wbV30_attrib_t attr ;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wbV30_attrib_t));
    //get
    rk_aiq_uapi2_getAwbV30AllAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = RK_AIQ_UAPI_MODE_DEFAULT;
    attr.stAuto.wbGainAdjust.enable = true;
    //set
    rk_aiq_uapi2_setAwbV30AllAttrib(ctx, attr);
    printf("set rk_aiq_uapiV2_wbV30_attrib\n\n");
    //free
    for(int i = 0; i < attr.stAuto.wbGainAdjust.lutAll_len; i++) {
        safe_free(attr.stAuto.wbGainAdjust.lutAll[i].cri_lut_out);
        safe_free(attr.stAuto.wbGainAdjust.lutAll[i].ct_lut_out);
    }
    safe_free(attr.stAuto.wbGainAdjust.lutAll);
    return 0;
}
 
/*
******************************
*
* Module level API Sample Func
*
******************************
*/
 
static int sample_awb_awbv21_setAllAttr(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wbV21_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wbV21_attrib_t));
    //get
    rk_aiq_user_api2_awbV21_GetAllAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.stAuto.wbGainAdjust.enable = !attr.stAuto.wbGainAdjust.enable;
    //set
    rk_aiq_user_api2_awbV21_SetAllAttrib(ctx, attr);
    printf("set Awbv21 AllAttr\n\n");
    return 0;
}
 
static int sample_awb_awbv21_getAllAttr(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wbV21_attrib_t attr ;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wbV21_attrib_t));
    //get
    rk_aiq_user_api2_awbV21_GetAllAttrib(ctx, &attr);
    printf("get Awbv21 AllAttr:\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    printf("\t bypass = %d\n", attr.byPass);
    printf("\t mode = %s\n", (attr.mode > 0 ? "auto" : "manual"));
    if (attr.mode > 0) {
        printf("\t wbGainAdjustEn = %s\n",
                            (attr.stAuto.wbGainAdjust.enable > 0 ? "true" : "false"));
        printf("\t wbGainOffset = {%s,[%f,%f,%f,%f]}\n\n",
                            (attr.stAuto.wbGainOffset.enable > 0 ? "true" : "false"),
                            attr.stAuto.wbGainOffset.offset[0],
                            attr.stAuto.wbGainOffset.offset[1],
                            attr.stAuto.wbGainOffset.offset[2],
                            attr.stAuto.wbGainOffset.offset[3]);
    } else {
        switch (attr.stManual.mode)
        {
            case RK_AIQ_MWB_MODE_CCT:
                printf("\t manual mode = RK_AIQ_MWB_MODE_CCT\n");
                printf("\t manual cct = %f, ccri = %f\n",
                                attr.stManual.para.cct.CCT,
                                attr.stManual.para.cct.CCRI);
                break;
            case RK_AIQ_MWB_MODE_WBGAIN:
                printf("\t manual mode = RK_AIQ_MWB_MODE_WBGAIN\n");
                printf("\t manual wbgain = [%f, %f, %f, %f]\n",
                                attr.stManual.para.gain.rgain,
                                attr.stManual.para.gain.grgain,
                                attr.stManual.para.gain.gbgain,
                                attr.stManual.para.gain.bgain);
                break;
            case RK_AIQ_MWB_MODE_SCENE:
                printf("\t manual mode = RK_AIQ_MWB_MODE_SCENE\n");
                printf("\t manual scene = %d\n",
                                attr.stManual.para.scene);
                break;
            default:
                printf("\t manual mode is invalid!\n");
                break;
        }
    }
    return 0;
}
 
static int sample_awb_awbv30_setAllAttr(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wbV30_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wbV21_attrib_t));
    //get
    rk_aiq_user_api2_awbV30_GetAllAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.stAuto.wbGainAdjust.enable = !attr.stAuto.wbGainAdjust.enable;
    //set
    rk_aiq_user_api2_awbV30_SetAllAttrib(ctx, attr);
    printf("set Awbv30 AllAttr\n\n");
    return 0;
}
 
static int sample_awb_awbv30_getAllAttr(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wbV30_attrib_t attr ;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wbV30_attrib_t));
    //get
    rk_aiq_user_api2_awbV30_GetAllAttrib(ctx, &attr);
    printf("get Awbv30 AllAttr:\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    printf("\t bypass = %d\n", attr.byPass);
    printf("\t mode = %s\n", (attr.mode > 0 ? "auto" : "manual"));
    if (attr.mode > 0) {
        printf("\t wbGainAdjustEn = %s\n",
                            (attr.stAuto.wbGainAdjust.enable > 0 ? "true" : "false"));
        printf("\t wbGainOffset = {%s,[%f,%f,%f,%f]}\n\n",
                            (attr.stAuto.wbGainOffset.enable > 0 ? "true" : "false"),
                            attr.stAuto.wbGainOffset.offset[0],
                            attr.stAuto.wbGainOffset.offset[1],
                            attr.stAuto.wbGainOffset.offset[2],
                            attr.stAuto.wbGainOffset.offset[3]);
    } else {
        switch (attr.stManual.mode)
        {
            case RK_AIQ_MWB_MODE_CCT:
                printf("\t manual mode = RK_AIQ_MWB_MODE_CCT\n");
                printf("\t manual cct = %f, ccri = %f\n",
                                attr.stManual.para.cct.CCT,
                                attr.stManual.para.cct.CCRI);
                break;
            case RK_AIQ_MWB_MODE_WBGAIN:
                printf("\t manual mode = RK_AIQ_MWB_MODE_WBGAIN\n");
                printf("\t manual wbgain = [%f, %f, %f, %f]\n",
                                attr.stManual.para.gain.rgain,
                                attr.stManual.para.gain.grgain,
                                attr.stManual.para.gain.gbgain,
                                attr.stManual.para.gain.bgain);
                break;
            case RK_AIQ_MWB_MODE_SCENE:
                printf("\t manual mode = RK_AIQ_MWB_MODE_SCENE\n");
                printf("\t manual scene = %d\n",
                                attr.stManual.para.scene);
                break;
            default:
                printf("\t manual mode is invalid!\n");
                break;
        }
    }
    return 0;
}
 
static int sample_awb_getCct(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_cct_t cct;
    memset(&cct,0,sizeof(rk_aiq_wb_cct_t));
    //get
    rk_aiq_user_api2_awb_GetCCT(ctx, &cct);
    printf("get rk_aiq_user_api2_awb_CCT:\n");
    printf("\t CCRI = %f, CCT = %f\n\n", cct.CCRI, cct.CCT);
 
    return 0;
}
 
static int sample_query_wb_info(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_querry_info_t wb_querry_info;
    rk_aiq_user_api2_awb_QueryWBInfo(ctx, &wb_querry_info);
    printf("Query AWB Info\n\n");
    printf("\t AWBGain = [%f %f %f %f]\n", wb_querry_info.gain.rgain,
                                            wb_querry_info.gain.grgain,
                                            wb_querry_info.gain.gbgain,
                                            wb_querry_info.gain.bgain);
    printf("\t cctGloabl: CCT = %f, CCRI = %f \n", wb_querry_info.cctGloabl.CCT, wb_querry_info.cctGloabl.CCRI);
    printf("\t awbConverged: %s \n", (wb_querry_info.awbConverged ? "true" : "false"));
    printf("\t LVValue: %d \n", wb_querry_info.LVValue);
    return 0;
}
 
static int sample_awb_lock(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_user_api2_awb_Lock(ctx);
    printf("AWB Lock\n");
 
    return 0;
}
 
static int sample_awb_unlock(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_user_api2_awb_Unlock(ctx);
    printf("AWB Unlock\n");
 
    return 0;
}
 
static int sample_awb_setModeManual(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wb_opMode_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_opMode_t));
    //get
    rk_aiq_user_api2_awb_GetWpModeAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.mode = RK_AIQ_WB_MODE_MANUAL;
    //set
    rk_aiq_user_api2_awb_SetWpModeAttrib(ctx, attr);
    printf("set Mode Manual\n\n");
 
    return 0;
}
 
static int sample_awb_setModeAuto(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wb_opMode_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_opMode_t));
    //get
    rk_aiq_user_api2_awb_GetWpModeAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.mode = RK_AIQ_WB_MODE_AUTO;
    //set
    rk_aiq_user_api2_awb_SetWpModeAttrib(ctx, attr);
    printf("set Mode Auto\n\n");
 
    return 0;
}
 
static int sample_awb_getMode(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_opMode_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_opMode_t));
    //get
    rk_aiq_user_api2_awb_GetWpModeAttrib(ctx, &attr);
    printf("get AWB Mode: %s\n\n", (attr.mode > 0 ? "Auto" : "Manual"));
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
 
    return 0;
}
 
static int sample_awb_setMwb(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_wb_mwb_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_wb_mwb_attrib_t));
    //set mode MANUAL
    sample_awb_setModeManual(ctx, sync);
    //get
    rk_aiq_user_api2_awb_GetMwbAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.mode = RK_AIQ_MWB_MODE_WBGAIN;
    if (attr.para.gain.rgain == 1.0) {
        attr.para.gain.rgain = 0.5f;
        attr.para.gain.grgain = 0.5f;
        attr.para.gain.gbgain = 0.5f;
        attr.para.gain.bgain = 0.5f;
    } else {
        attr.para.gain.rgain = 1.0f;
        attr.para.gain.grgain = 0.5f;
        attr.para.gain.gbgain = 0.5f;
        attr.para.gain.bgain = 1.0f;
    }
 
    //set
    rk_aiq_user_api2_awb_SetMwbAttrib(ctx, attr);
    printf("set Manual attr\n\n");
 
    return 0;
}
 
static int sample_awb_setMwb1(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_wb_mwb_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_wb_mwb_attrib_t));
    //set mode MANUAL
    sample_awb_setModeManual(ctx, sync);
    //get
    rk_aiq_user_api2_awb_GetMwbAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.mode = RK_AIQ_MWB_MODE_SCENE;
 
    //set
    rk_aiq_user_api2_awb_SetMwbAttrib(ctx, attr);
    printf("set Manual attr\n\n");
 
    return 0;
}
 
static int sample_awb_setMwb2(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_wb_mwb_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_wb_mwb_attrib_t));
    //get
    rk_aiq_user_api2_awb_GetMwbAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.mode = RK_AIQ_MWB_MODE_WBGAIN;
    if (attr.para.gain.rgain == 1.0) {
        attr.para.gain.rgain = 0.5f;
        attr.para.gain.grgain = 0.5f;
        attr.para.gain.gbgain = 0.5f;
        attr.para.gain.bgain = 0.5f;
    } else {
        attr.para.gain.rgain = 1.0f;
        attr.para.gain.grgain = 0.5f;
        attr.para.gain.gbgain = 0.5f;
        attr.para.gain.bgain = 1.0f;
    }
 
    //set
    rk_aiq_user_api2_awb_SetMwbAttrib(ctx, attr);
    printf("set Manual attr\n\n");
 
    return 0;
}
 
static int sample_awb_getMwbAttr(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_wb_mwb_attrib_t attr;
    memset(&attr,0,sizeof(rk_aiq_wb_mwb_attrib_t));
    //get
    rk_aiq_user_api2_awb_GetMwbAttrib(ctx, &attr);
    printf("get Manual attr:\n\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    switch (attr.mode)
    {
        case RK_AIQ_MWB_MODE_CCT:
            printf("\t manual mode = RK_AIQ_MWB_MODE_CCT\n");
            printf("\t manual cct = %f, ccri = %f\n",
                            attr.para.cct.CCT,
                            attr.para.cct.CCRI);
            break;
        case RK_AIQ_MWB_MODE_WBGAIN:
            printf("\t manual mode = RK_AIQ_MWB_MODE_WBGAIN\n");
            printf("\t manual wbgain = [%f, %f, %f, %f]\n",
                            attr.para.gain.rgain,
                            attr.para.gain.grgain,
                            attr.para.gain.gbgain,
                            attr.para.gain.bgain);
            break;
        case RK_AIQ_MWB_MODE_SCENE:
            printf("\t manual mode = RK_AIQ_MWB_MODE_SCENE\n");
            printf("\t manual scene = %d\n", attr.para.scene);
            break;
        default:
            printf("\t manual mode is invalid!\n");
            break;
    }
 
    return 0;
}
 
static int sample_awb_setWbGainAdjust(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wb_awb_wbGainAdjust_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainAdjust_t));
    //set mode AUTO
    sample_awb_setModeAuto(ctx, sync);
    //get
    rk_aiq_user_api2_awb_GetWbGainAdjustAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.enable = !attr.enable;
    //set
    rk_aiq_user_api2_awb_SetWbGainAdjustAttrib(ctx, attr);
    printf("set AWbGainAdjust\n\n");
 
    return 0;
}
 
static int sample_awb_getWbGainAdjust(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainAdjust_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainAdjust_t));
    //get
    rk_aiq_user_api2_awb_GetWbGainAdjustAttrib(ctx, &attr);
    printf("get AWbGainAdjust:\n\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    printf("\t enable = %s\n", (attr.enable ? "true" : "false"));
    return 0;
}
 
static int sample_awb_setWbGainOffset(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wb_awb_wbGainOffset_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainOffset_t));
    //set mode AUTO
    sample_awb_setModeAuto(ctx, sync);
    //get
    rk_aiq_user_api2_awb_GetWbGainOffsetAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.gainOffset.enable = !attr.gainOffset.enable;
    attr.gainOffset.offset[0] = 1.0f;
    attr.gainOffset.offset[1] = 0;
    attr.gainOffset.offset[2] = 0;
    attr.gainOffset.offset[3] = 0;
    //set
    rk_aiq_user_api2_awb_SetWbGainOffsetAttrib(ctx, attr);
    printf("set WbGainOffset\n\n");
 
    return 0;
}
 
static int sample_awb_getWbGainOffset(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_wbGainOffset_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_wbGainOffset_t));
    //get
    rk_aiq_user_api2_awb_GetWbGainOffsetAttrib(ctx, &attr);
    printf("get WbGainOffset:\n\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    printf("WbGainOffset = {%d,[%f,%f,%f,%f]}\n\n",
        attr.gainOffset.enable,
        attr.gainOffset.offset[0],
        attr.gainOffset.offset[1],
        attr.gainOffset.offset[2],
        attr.gainOffset.offset[3]);
    return 0;
}
 
static int sample_awb_setWbAwbMultiWindow(const rk_aiq_sys_ctx_t* ctx, rk_aiq_uapi_mode_sync_e sync)
{
    rk_aiq_uapiV2_wb_awb_mulWindow_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_mulWindow_t));
    //get
    rk_aiq_user_api2_awb_GetMultiWindowAttrib(ctx, &attr);
    //modify
    attr.sync.sync_mode = sync;
    attr.multiWindw.enable = !attr.multiWindw.enable;
    attr.multiWindw.multiwindowMode = CALIB_AWB_WIN_USELESS;
    //set
    rk_aiq_user_api2_awb_SetMultiWindowAttrib(ctx, attr);
    printf("set Awb MultiWindow\n\n");
 
    return 0;
}
 
static int sample_awb_getWbAwbMultiWindow(const rk_aiq_sys_ctx_t* ctx)
{
    rk_aiq_uapiV2_wb_awb_mulWindow_t attr;
    memset(&attr,0,sizeof(rk_aiq_uapiV2_wb_awb_mulWindow_t));
    //get
    rk_aiq_user_api2_awb_GetMultiWindowAttrib(ctx, &attr);
    printf("get Awb MultiWindow:\n\n");
    printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
    printf("\t enable = %s\n\n", (attr.multiWindw.enable ? "true" : "false"));
    return 0;
}
#if 0
static int sample_awb_printflog(const rk_aiq_sys_ctx_t* ctx)
{
    rk_tool_awb_stat_res_full_t awb_measure_result;
    rk_tool_awb_strategy_result_t strategy_result;
 
    //for(int i=0;i<100;i++)
    {
        memset(&awb_measure_result,0,sizeof(awb_measure_result));
        rk_aiq_user_api2_awbV30_getAlgoSta(ctx, &awb_measure_result);
        memset(&strategy_result,0,sizeof(strategy_result));
        rk_aiq_user_api2_awbV30_getStrategyResult(ctx, &strategy_result);
        printf("------------%d---------------\n",strategy_result.count);
        printf("Global CCT:%f,CCRI:%f,valid:%d\n",strategy_result.cctGloabl.CCT,strategy_result.cctGloabl.CCRI,
            strategy_result.cctGloabl.valid);
        printf("wbgain_s6(after damping)(rggb):(%f,%f,%f,%f), awbConverged(%d)  ,LVValue(%d), WPType(%d),df(%1.2f)\n",strategy_result.stat3aAwbGainOut[AWB_CHANNEL_R],
                strategy_result.stat3aAwbGainOut[AWB_CHANNEL_GR], strategy_result.stat3aAwbGainOut[AWB_CHANNEL_GB],
                strategy_result.stat3aAwbGainOut[AWB_CHANNEL_B], strategy_result.awbConverged, strategy_result.LVValue,strategy_result.WPType,
                strategy_result.wbGainDampFactor);
        printf("WPNo(normal,big):(%d,%d),vaild wp number in standard light(%d), vaild wp number in extra light(%d),xy_area_type %d \n",
            awb_measure_result.WpNo[0], awb_measure_result.WpNo[1],
            strategy_result.WPTotalNUM, awb_measure_result.extraLightResult.WpNo,strategy_result.xy_area_type);
        printf("select white point range type (0-normal xy range,1-big xy range, 3-extra light) : %d, runInterval(%d),tolerance(%f) \n",strategy_result.xy_area_type,
            strategy_result.runInterval, strategy_result.tolerance);
        //printf("the effective light source slecetion to 3dyuv is :[%d,%d,%d,%d]\n", para->awb_cfg_effect_v201->threeDyuvIllu[0], para->awb_cfg_effect_v201->threeDyuvIllu[1],
        //         para->awb_cfg_effect_v201->threeDyuvIllu[2], para->awb_cfg_effect_v201->threeDyuvIllu[3]);
        printf("LVLevel(%d),LVType(%d)\n", strategy_result.LVLevel, strategy_result.LVType);
        printf("wbGainSgc for WPType1(rggb):(%f,%f,%f,%f) ,wbWeightSgc(%f),sgcGainEqu2Tem(%d)\n", strategy_result.wbGainSgc[0], strategy_result.wbGainSgc[1],
                 strategy_result.wbGainSgc[2], strategy_result.wbGainSgc[3], strategy_result.wbWeightSgc, strategy_result.sgcGainEqu2Tem);
        printf("wbGainSpa  for WPType1 (rggb):(%f,%f,%f,%f) ,wbWeightSpa(%f), spaGainEqu2Tem(%d) \n", strategy_result.wbGainSpa[AWB_CHANNEL_R], strategy_result.wbGainSpa[AWB_CHANNEL_GR],
                 strategy_result.wbGainSpa[AWB_CHANNEL_GB], strategy_result.wbGainSpa[AWB_CHANNEL_B], strategy_result.wbWeightSpa, strategy_result.spaGainEqu2Tem);
        printf("wbGainTep for WPType1 (rggb):(%f,%f,%f,%f)\n", strategy_result.wbGainTep[AWB_CHANNEL_R], strategy_result.wbGainTep[AWB_CHANNEL_GR],
                 strategy_result.wbGainTep[AWB_CHANNEL_GB], strategy_result.wbGainTep[AWB_CHANNEL_B]);
        printf("wbGainType1 (rggb):(%f,%f,%f,%f)\n", strategy_result.wbGainType1[AWB_CHANNEL_R], strategy_result.wbGainType1[AWB_CHANNEL_GR],
                 strategy_result.wbGainType1[AWB_CHANNEL_GB], strategy_result.wbGainType1[AWB_CHANNEL_B]);
        printf("wbGainType3(rggb):(%f,%f,%f,%f)\n", strategy_result.wbGainType3[AWB_CHANNEL_R], strategy_result.wbGainType3[AWB_CHANNEL_GR],
                 strategy_result.wbGainType3[AWB_CHANNEL_GB], strategy_result.wbGainType3[AWB_CHANNEL_B]);
        printf("wbgain_s1 (mix wbGainType1 and wbGainType3 ) :(%f,%f,%f,%f) is updated (%d), weight of wbGainType3 %f\n", strategy_result.wbGainIntpStrategy[AWB_CHANNEL_R],
            strategy_result.wbGainIntpStrategy[AWB_CHANNEL_GR], strategy_result.wbGainIntpStrategy[AWB_CHANNEL_GB],
            strategy_result.wbGainIntpStrategy[AWB_CHANNEL_B], strategy_result.updateFlag, strategy_result.wbWeightType3);
        printf("wbgain_s2 (caga) :(%f,%f,%f,%f) \n", strategy_result.wbGainCaga[AWB_CHANNEL_R],
            strategy_result.wbGainCaga[AWB_CHANNEL_GR], strategy_result.wbGainCaga[AWB_CHANNEL_GB],
            strategy_result.wbGainCaga[AWB_CHANNEL_B]);
        printf("wbgain_s3 (wbgainclip) :(%f,%f,%f,%f) \n", strategy_result.wbGainClip[AWB_CHANNEL_R],
            strategy_result.wbGainClip[AWB_CHANNEL_GR], strategy_result.wbGainClip[AWB_CHANNEL_GB],
            strategy_result.wbGainClip[AWB_CHANNEL_B]);
        printf("wbgain_s4 (wbgainAdjust) :(%f,%f,%f,%f) \n", strategy_result.wbGainAdjust[AWB_CHANNEL_R],
            strategy_result.wbGainAdjust[AWB_CHANNEL_GR], strategy_result.wbGainAdjust[AWB_CHANNEL_GB],
            strategy_result.wbGainAdjust[AWB_CHANNEL_B]);
        printf("wbgain_s5 (wbgainOffest) :(%f,%f,%f,%f) \n", strategy_result.wbGainOffset[AWB_CHANNEL_R],
            strategy_result.wbGainOffset[AWB_CHANNEL_GR], strategy_result.wbGainOffset[AWB_CHANNEL_GB],
            strategy_result.wbGainOffset[AWB_CHANNEL_B]);
        printf("hdrFrameChoose %d\n",awb_measure_result.effectHwPara.hdrFrameChoose);
        printf("select algorithm method based on stat_mode 0 (0-wp,1-gw) %d\n",strategy_result.algMethod);
        char str1[500];
        sprintf(str1, "%s", "WpNoHist:       ");
        for (int p = 0; p < RK_AIQ_AWBWP_WEIGHT_CURVE_DOT_NUM - 1; p++) {
            char str2[100];
            sprintf(str2, "%6d,",  awb_measure_result.WpNoHist[p]);
            strcat(str1,str2);
        }
        printf("%s\n",str1);
        if (fabs(strategy_result.wbWeightSgc - 1) < 0.001 && strategy_result.wbWeightType3 < 0.02)
        {
            //printf("current light source : %d  (%d,%d,%d)\n", para->sinColorResult.illEst,
            //         para->sinColorResult.voteResult[0], para->sinColorResult.voteResult[1], para->sinColorResult.voteResult[2]);
           // printf("current color : %d\n", para->sinColorResult.colorEst);
            for (int i = 0; i < strategy_result.lightNum; i++)
            {
                printf(" %s:\n", strategy_result.illInf[i].illName);
                //printf(" %s:\n", strategy_result.illConf[i].illName);
                //type0
                for (int m = 0; m < 2; m++) {
                    printf("     type%d: gain (rg,bg):(%f,%f) WPNo(%d)\n", m, awb_measure_result.light[i].xYType[m].gain[0],
                             awb_measure_result.light[i].xYType[m].gain[3], awb_measure_result.light[i].xYType[m].WpNo);
                }
            }
 
            printf("blockresult[15][15]:");
            for (int i = 0; i < RK_AIQ_AWB_GRID_NUM_VERHOR * RK_AIQ_AWB_GRID_NUM_VERHOR; i++)
            {
                if (i % 15 == 0)
                {
                    printf("     ");
                }
                printf("%d (%.7f,%.7f,%.7f), \n", i, awb_measure_result.blkSgcResult[i].R, awb_measure_result.blkSgcResult[i].G,
                         awb_measure_result.blkSgcResult[i].B);
            }
            printf("\n");
        }
        else
        {
            if (strategy_result.wbWeightSgc > 0.001) {
                //printf("current light source : %s  (%d,%d,%d)\n", strategy_result.illConf[para->sinColorResult.illEst].illName,
                //         para->sinColorResult.voteResult[0], para->sinColorResult.voteResult[1], para->sinColorResult.voteResult[2]);
                //printf("current color : %d\n", para->sinColorResult.colorEst);
            }
 
            for (int i = 0; i < strategy_result.lightNum; i++)
            {
                //printf("%s:\n", strategy_result.illConf[i].illName);
                printf(" %s:\n", strategy_result.illInf[i].illName);
                printf("     strategy_result.gain (rggb):(%f,%f,%f,%f) \n",
                         strategy_result.illInf[i].gainValue[0], strategy_result.illInf[i].gainValue[1],
                         strategy_result.illInf[i].gainValue[2], strategy_result.illInf[i].gainValue[3]
                        );
                printf("     prob_total(%f),prob_dis(%f),prob_LV(%f),prob_WPNO(%f)\n", strategy_result.illInf[i].prob_total, strategy_result.illInf[i].prob_dis,
                         strategy_result.illInf[i].prob_LV, strategy_result.illInf[i].prob_WPNO);
                printf("     spatial gain(rggb):(%f,%f,%f,%f),statistics gain weight(%f)\n", strategy_result.illInf[i].spatialGainValue[0], strategy_result.illInf[i].spatialGainValue[1],
                         strategy_result.illInf[i].spatialGainValue[2], strategy_result.illInf[i].spatialGainValue[3], strategy_result.illInf[i].staWeight);
 
                for (int m = 0; m < 2; m++) {
 
                    if (m == 2) {
                        printf("     type%d: gain (rg,bg):(%f,%f) WPNo(%d)  Weight(%f)\n", m,
                                 awb_measure_result.light[i].xYType[m].gain[0],
                                 awb_measure_result.light[i].xYType[m].gain[3],
                                 awb_measure_result.light[i].xYType[m].WpNo,
                                 strategy_result.illInf[i].xyType2Weight);
 
                    }
                    else {
                        printf("     type%d: gain (rg,bg):(%f,%f) WPNo(%d)\n", m,
                                 awb_measure_result.light[i].xYType[m].gain[0],
                                 awb_measure_result.light[i].xYType[m].gain[3],
                                 awb_measure_result.light[i].xYType[m].WpNo);
 
                    }
                }
 
            }
 
        }
 
        printf("\n");
    }
 
 
 
    return 0;
}
#endif
 
static int sample_awb_getStrategyResult(const rk_aiq_sys_ctx_t* ctx)
{
    rk_tool_awb_strategy_result_t attr;
    memset(&attr,0,sizeof(attr));
    rk_aiq_user_api2_awbV30_getStrategyResult(ctx, &attr);
    return 0;
}
 
 
XCamReturn sample_awb_module(const void *arg)
{
    int key = -1;
    CLEAR();
    rk_aiq_wb_scene_t scene;
    rk_aiq_wb_gain_t gain;
    rk_aiq_wb_cct_t ct;
    opMode_t mode;
    const demo_context_t *demo_ctx = (demo_context_t *)arg;
    const rk_aiq_sys_ctx_t* ctx;
    if (demo_ctx->camGroup){
        ctx = (rk_aiq_sys_ctx_t*)(demo_ctx->camgroup_ctx);
    } else {
        ctx = (rk_aiq_sys_ctx_t*)(demo_ctx->aiq_ctx);
    }
    if (ctx == nullptr) {
        ERR ("%s, ctx is nullptr\n", __FUNCTION__);
        return XCAM_RETURN_ERROR_PARAM;
    }
    unsigned int cct;
 
    sample_awb_usage ();
    do {
        printf("\t please press the key: ");
        key = getchar ();
        while (key == '\n' || key == '\r')
            key = getchar();
        printf ("\n");
 
        switch (key)
        {
            case 'h':
                CLEAR();
                sample_awb_usage ();
                break;
            case '0':
                sample_set_wbmode_manual(ctx);
                printf("setWBMode manual\n\n");
                break;
            case '1':
                sample_set_wbmode_auto(ctx);
                printf("setWBMode auto\n\n");
                break;
            case '2':
                sample_get_wbmode(ctx);
                break;
            case '3':
                sample_lock_awb(ctx);
                printf("lockAWB\n\n");
                break;
            case '4':
                sample_unlock_awb(ctx);
                printf("unlockAWB\n\n");
                break;
            case '5':
                sample_set_mwb_scene(ctx);
                printf("setMWBScene\n\n");
                break;
            case '6':
                sample_get_mwb_scene(ctx);
                break;
            case '7':
                sample_set_mwb_gain(ctx);
                printf("setMWBGain\n\n");
                break;
            case '8':
                sample_get_mwb_gain(ctx);
                break;
            case '9':
                sample_set_mwb_ct(ctx);
                break;
            case 'a':
                sample_get_mwb_ct(ctx);
                break;
            case 'b':
                sample_set_awb_gainoffset(ctx);
                printf("setAWBGainOffset\n\n");
                break;
            case 'c':
                sample_get_awb_gainoffset(ctx);
                break;
            case 'd':
                sample_set_awb_gain_adjust(ctx);
                break;
            case 'e':
                sample_get_awb_gain_adjust(ctx);
                break;
            case 'f':
                sample_set_awbv30_atrr(ctx);
                break;
            case 'A':
                sample_awb_awbv21_setAllAttr(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_awbv21_getAllAttr(ctx);
                break;
            case 'B':
                sample_awb_awbv21_setAllAttr(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_awbv21_getAllAttr(ctx);
                usleep(40 * 1000);
                sample_awb_awbv21_getAllAttr(ctx);
                break;
            case 'C':
                sample_awb_awbv30_setAllAttr(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_awbv30_getAllAttr(ctx);
                break;
            case 'D':
                sample_awb_awbv30_setAllAttr(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_awbv30_getAllAttr(ctx);
                usleep(40 * 1000);
                sample_awb_awbv30_getAllAttr(ctx);
                break;
            case 'E':
                sample_awb_getCct(ctx);
                break;
            case 'F':
                sample_query_wb_info(ctx);
                break;
            case 'G':
                sample_awb_lock(ctx);
                break;
            case 'I':
                sample_awb_unlock(ctx);
                break;
            case 'J':
                sample_awb_setModeManual(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getMode(ctx);
                break;
            case 'K':
                sample_awb_setModeManual(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getMode(ctx);
                usleep(40 * 1000);
                sample_awb_getMode(ctx);
                break;
            case 'L':
                sample_awb_setModeAuto(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getMode(ctx);
                break;
            case 'M':
                sample_awb_setModeAuto(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getMode(ctx);
                usleep(40 * 1000);
                sample_awb_getMode(ctx);
                break;
            case 'N':
                sample_awb_setMwb(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getMwbAttr(ctx);
                break;
            case 'O':
                sample_awb_setMwb(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getMwbAttr(ctx);
                usleep(40 * 1000);
                sample_awb_getMwbAttr(ctx);
                break;
            case 'P':
                sample_awb_setWbGainAdjust(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getWbGainAdjust(ctx);
                break;
            case 'R':
                sample_awb_setWbGainAdjust(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getWbGainAdjust(ctx);
                usleep(40 * 1000);
                sample_awb_getWbGainAdjust(ctx);
                break;
            case 'S':
                sample_awb_setWbGainOffset(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getWbGainOffset(ctx);
                break;
            case 'T':
                sample_awb_setWbGainOffset(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getWbGainOffset(ctx);
                usleep(40 * 1000);
                sample_awb_getWbGainOffset(ctx);
                break;
            // NOT Support MultiWindow
            case 'U':
                sample_awb_setWbAwbMultiWindow(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
                sample_awb_getWbAwbMultiWindow(ctx);
                break;
            case 'V':
                sample_awb_setWbAwbMultiWindow(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getWbAwbMultiWindow(ctx);
                usleep(40 * 1000);
                sample_awb_getWbAwbMultiWindow(ctx);
                break;
            case 'X':
                sample_awb_setMwb1(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getMwbAttr(ctx);
                sample_awb_setMwb2(ctx, RK_AIQ_UAPI_MODE_ASYNC);
                sample_awb_getMwbAttr(ctx);
 
                usleep(40 * 1000);
                sample_awb_getMwbAttr(ctx);
                break;
#if 0
            case 'Y':
                sample_awb_printflog(ctx);
                break;
#endif
            default:
                break;
        }
    } while (key != 'q' && key != 'Q');
 
    return XCAM_RETURN_NO_ERROR;
}