1 #include "third_party_awbV32_algo.h"
2 #include "uAPI2/rk_aiq_user_api2_camgroup.h"
3 #include "uAPI2/rk_aiq_user_api2_sysctl.h"
4
custom_awb_init(void * ctx)5 int32_t custom_awb_init(void* ctx)
6 {
7 //TO DO
8 printf("custom awb test: %s \n", __func__);
9 rk_aiq_sys_ctx_t* sys_ctx = NULL;
10 rk_aiq_camgroup_ctx_t* group_ctx = NULL;
11
12 rk_aiq_cam_type_t cam_type = (rk_aiq_cam_type_t)(*(int*)(ctx));
13
14 if (cam_type == RK_AIQ_CAM_TYPE_GROUP)
15 group_ctx = (rk_aiq_camgroup_ctx_t*)ctx;
16 else
17 sys_ctx = (rk_aiq_sys_ctx_t*)ctx;
18
19 if (group_ctx)
20 printf("%s:%d group custom awb !\n", __func__, __LINE__);
21 else
22 printf("%s:%d single custom awb !\n", __func__, __LINE__);
23 return 0;
24 }
25
26
27
custom_awb_run(void * ctx,const void * vpstAwbInfo,void * vpstAwbResult)28 int32_t custom_awb_run(void* ctx, const void* vpstAwbInfo, void* vpstAwbResult)
29 {
30 const rk_aiq_customAwb_stats_t* pstAwbInfo = (rk_aiq_customAwb_stats_t*) vpstAwbInfo;
31 rk_aiq_customeAwb_results_t* pstAwbResult = (rk_aiq_customeAwb_results_t*) vpstAwbResult;
32 rk_aiq_sys_ctx_t* sys_ctx = NULL;
33 rk_aiq_camgroup_ctx_t* group_ctx = NULL;
34
35 rk_aiq_cam_type_t cam_type = (rk_aiq_cam_type_t)(*(int*)(ctx));
36
37 if (cam_type == RK_AIQ_CAM_TYPE_GROUP)
38 group_ctx = (rk_aiq_camgroup_ctx_t*)ctx;
39 else
40 sys_ctx = (rk_aiq_sys_ctx_t*)ctx;
41
42 if (group_ctx)
43 printf("%s:%d group custom awb !\n", __func__, __LINE__);
44 else
45 printf("%s:%d single custom awb !\n", __func__, __LINE__);
46
47 printf("custom awb test: %s \n", __func__);
48 //TO DO, the following are just sample codes
49
50 if (pstAwbInfo == nullptr){
51 //1)initialize awb gain, must be initialized
52 pstAwbResult->awb_gain_algo={1.9,1.0,1.0,1.6};
53 //2) initialize pstAwbResult->awbHwConfig , must be initialized
54 // pstAwbResult->awbHwConfig has been initialized by RK
55 // the demo is in function initCustomAwbHwConfigGw(rk_aiq_customAwb_hw_cfg_t *awbHwConfig)} in rk_aiq_user_api2_custom_awb_v32.cpp
56 pstAwbResult->awbHwConfig.maxR = 230*16;;
57 pstAwbResult->awbHwConfig.maxG = 230*16;;
58 pstAwbResult->awbHwConfig.maxB = 230*16;;
59 pstAwbResult->awbHwConfig.maxY = 230*16;;
60 pstAwbResult->awbHwConfig.minR = 3*16;
61 pstAwbResult->awbHwConfig.minG = 3*16;
62 pstAwbResult->awbHwConfig.minB = 3*16;
63 pstAwbResult->awbHwConfig.minY = 3*16;
64 //to do more paras
65 }else if( pstAwbInfo != nullptr){
66 //0) run your algo to calc para in pstAwbResult based on pstAwbInfo, for example
67 float R=0,G=0,B=0;
68 for(int i=0;i<RK_AIQ_AWB_GRID_NUM_TOTAL;i++){
69 R+=pstAwbInfo->blockResult[i].Rvalue;
70 G+=pstAwbInfo->blockResult[i].Gvalue;
71 B+=pstAwbInfo->blockResult[i].Bvalue;
72 }
73 if(R>0.001&&B>0.001){
74 pstAwbResult->awb_gain_algo.bgain = G/B;
75 pstAwbResult->awb_gain_algo.gbgain = 1.0;
76 pstAwbResult->awb_gain_algo.grgain = 1.0;
77 pstAwbResult->awb_gain_algo.rgain = G/R;
78 }
79 printf("wbggain :(%f,%f,%f,%f)\n",pstAwbResult->awb_gain_algo.rgain,
80 pstAwbResult->awb_gain_algo.grgain,pstAwbResult->awb_gain_algo.gbgain,
81 pstAwbResult->awb_gain_algo.bgain);
82 //1)update awb gain, pstAwbResult->awb_gain_algo, must be updated
83 //pstAwbResult->awb_gain_algo={2.0,1.0,1.0,1.6};
84 //2)update awb converged state,pstAwbResult->IsConverged, must be updated
85 pstAwbResult->IsConverged = true;
86 //3)update pstAwbResult->awbHwConfig}, no updating is also ok
87 //pstAwbResult->awbHwConfig.maxG= 230;
88 }
89
90 return 0;
91 }
92
custom_awb_ctrl(void * ctx,uint32_t u32Cmd,void * pValue)93 int32_t custom_awb_ctrl(void* ctx, uint32_t u32Cmd, void *pValue)
94 {
95 //TO DO
96 printf("custom awb test: %s \n", __func__);
97 return 0;
98 }
99
custom_awb_exit(void * ctx)100 int32_t custom_awb_exit(void* ctx)
101 {
102 //TO DO
103 printf("custom awb test: %s \n", __func__);
104 return 0;
105 }
106