xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/uAPI2/rk_aiq_user_api2_again_v2.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2019-2022 Rockchip Eletronics Co., Ltd.
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 #include "uAPI2/rk_aiq_user_api2_again_v2.h"
17 #include "RkAiqCamGroupHandleInt.h"
18 #include "algo_handlers/RkAiqAgainV2Handle.h"
19 
20 RKAIQ_BEGIN_DECLARE
21 
22 #ifdef RK_SIMULATOR_HW
23 #define CHECK_USER_API_ENABLE
24 #endif
25 
26 #if RKAIQ_HAVE_GAIN_V2
27 
28 XCamReturn
rk_aiq_user_api2_againV2_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_gain_attrib_v2_t * attr)29 rk_aiq_user_api2_againV2_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_gain_attrib_v2_t* attr)
30 {
31     XCamReturn ret = XCAM_RETURN_NO_ERROR;
32     CHECK_USER_API_ENABLE2(sys_ctx);
33     CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_AGAIN);
34     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
35 #ifdef RKAIQ_ENABLE_CAMGROUP
36 
37         RkAiqCamGroupAgainV2HandleInt* algo_handle =
38             camgroupAlgoHandle<RkAiqCamGroupAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
39 
40         if (algo_handle) {
41             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
42             return algo_handle->setAttrib(attr);
43         } else {
44             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
45             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
46                 if (!camCtx)
47                     continue;
48 
49                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
50                 RkAiqAgainV2HandleInt* singleCam_algo_handle =
51                     algoHandle<RkAiqAgainV2HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AGAIN);
52                 if (singleCam_algo_handle)
53                     ret = singleCam_algo_handle->setAttrib(attr);
54             }
55         }
56 #else
57         return XCAM_RETURN_ERROR_FAILED;
58 #endif
59 
60     } else {
61         RkAiqAgainV2HandleInt* algo_handle =
62             algoHandle<RkAiqAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
63         LOGD_ANR("%s:%d !!!!!!!!!!!!! single!!!!!!!!\n", __FUNCTION__, __LINE__);
64         if (algo_handle) {
65             return algo_handle->setAttrib(attr);
66         }
67     }
68 
69     return ret;
70 }
71 
72 XCamReturn
rk_aiq_user_api2_againV2_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_gain_attrib_v2_t * attr)73 rk_aiq_user_api2_againV2_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_gain_attrib_v2_t* attr)
74 {
75     XCamReturn ret = XCAM_RETURN_NO_ERROR;
76 
77     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
78 #ifdef RKAIQ_ENABLE_CAMGROUP
79 
80         RkAiqCamGroupAgainV2HandleInt* algo_handle =
81             camgroupAlgoHandle<RkAiqCamGroupAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
82 
83         if (algo_handle) {
84             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
85             return algo_handle->getAttrib(attr);
86         } else {
87             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
88             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
89                 if (!camCtx)
90                     continue;
91                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
92                 RkAiqAgainV2HandleInt* singleCam_algo_handle =
93                     algoHandle<RkAiqAgainV2HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AGAIN);
94                 if (singleCam_algo_handle)
95                     ret = singleCam_algo_handle->getAttrib(attr);
96             }
97         }
98 #else
99         return XCAM_RETURN_ERROR_FAILED;
100 #endif
101 
102     } else {
103         RkAiqAgainV2HandleInt* algo_handle =
104             algoHandle<RkAiqAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
105         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
106         if (algo_handle) {
107             return algo_handle->getAttrib(attr);
108         }
109     }
110 
111 
112     return ret;
113 }
114 
115 
116 XCamReturn
rk_aiq_user_api2_againV2_GetInfo(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_gain_info_v2_t * pInfo)117 rk_aiq_user_api2_againV2_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_gain_info_v2_t* pInfo)
118 {
119     XCamReturn ret = XCAM_RETURN_NO_ERROR;
120 
121     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
122 #ifdef RKAIQ_ENABLE_CAMGROUP
123 
124         RkAiqCamGroupAgainV2HandleInt* algo_handle =
125             camgroupAlgoHandle<RkAiqCamGroupAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
126 
127         if (algo_handle) {
128             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
129             return algo_handle->getInfo(pInfo);
130         } else {
131             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
132             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
133                 if (!camCtx)
134                     continue;
135                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
136                 RkAiqAgainV2HandleInt* singleCam_algo_handle =
137                     algoHandle<RkAiqAgainV2HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AGAIN);
138                 if (singleCam_algo_handle)
139                     ret = singleCam_algo_handle->getInfo(pInfo);
140             }
141         }
142 #else
143         return XCAM_RETURN_ERROR_FAILED;
144 #endif
145 
146     } else {
147         RkAiqAgainV2HandleInt* algo_handle =
148             algoHandle<RkAiqAgainV2HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AGAIN);
149         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
150         if (algo_handle) {
151             return algo_handle->getInfo(pInfo);
152         }
153     }
154 
155 
156     return ret;
157 }
158 
159 #else
160 XCamReturn
161 rk_aiq_user_api2_againV2_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_gain_attrib_v2_t* attr)
162 {
163     return XCAM_RETURN_ERROR_UNKNOWN;
164 }
165 
166 XCamReturn
167 rk_aiq_user_api2_againV2_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx,  rk_aiq_gain_attrib_v2_t* attr)
168 {
169     return XCAM_RETURN_ERROR_UNKNOWN;
170 }
171 
172 XCamReturn
173 rk_aiq_user_api2_againV2_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_gain_info_v2_t* pInfo)
174 {
175     return XCAM_RETURN_ERROR_UNKNOWN;
176 }
177 #endif
178 
179 
180 RKAIQ_END_DECLARE
181