xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/uAPI/rk_aiq_user_api_aynr_v22.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 "rk_aiq_user_api_aynr_v22.h"
17 
18 #include "RkAiqCamGroupHandleInt.h"
19 #include "algo_handlers/RkAiqAynrV22Handle.h"
20 
21 RKAIQ_BEGIN_DECLARE
22 
23 #ifdef RK_SIMULATOR_HW
24 #define CHECK_USER_API_ENABLE
25 #endif
26 
27 #if RKAIQ_HAVE_YNR_V22
28 
29 XCamReturn
rk_aiq_user_api_aynrV22_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ynr_attrib_v22_t * attr)30 rk_aiq_user_api_aynrV22_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_attrib_v22_t* attr)
31 {
32     CHECK_USER_API_ENABLE2(sys_ctx);
33     CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_AYNR);
34     XCamReturn ret = XCAM_RETURN_NO_ERROR;
35 
36     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
37 #ifdef RKAIQ_ENABLE_CAMGROUP
38         RkAiqCamGroupAynrV22HandleInt* algo_handle =
39             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
40 
41         if (algo_handle) {
42             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
43             return algo_handle->setAttrib(attr);
44         } else {
45             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
46             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
47                 if (!camCtx)
48                     continue;
49 
50                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
51                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
52                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
53                 if (singleCam_algo_handle)
54                     ret = singleCam_algo_handle->setAttrib(attr);
55             }
56         }
57 #else
58         return XCAM_RETURN_ERROR_FAILED;
59 #endif
60     } else {
61         RkAiqAynrV22HandleInt* algo_handle =
62             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
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_api_aynrV22_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_attrib_v22_t * attr)73 rk_aiq_user_api_aynrV22_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_attrib_v22_t* attr)
74 {
75 
76     XCamReturn ret = XCAM_RETURN_NO_ERROR;
77 
78     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
79 #ifdef RKAIQ_ENABLE_CAMGROUP
80         RkAiqCamGroupAynrV22HandleInt* algo_handle =
81             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
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                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
93                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
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         RkAiqAynrV22HandleInt* algo_handle =
104             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
105         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
106         if (algo_handle) {
107             return algo_handle->getAttrib(attr);
108         }
109     }
110 
111     return XCAM_RETURN_NO_ERROR;
112 }
113 
114 XCamReturn
rk_aiq_user_api_aynrV22_SetStrength(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ynr_strength_v22_t * pStrength)115 rk_aiq_user_api_aynrV22_SetStrength(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_strength_v22_t* pStrength)
116 {
117     XCamReturn ret = XCAM_RETURN_NO_ERROR;
118     RKAIQ_API_SMART_LOCK(sys_ctx);
119 
120     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
121 #ifdef RKAIQ_ENABLE_CAMGROUP
122         RkAiqCamGroupAynrV22HandleInt* algo_handle =
123             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
124 
125         if (algo_handle) {
126             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
127             return algo_handle->setStrength(pStrength);
128         } else {
129             LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
130             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
131             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
132                 if (!camCtx)
133                     continue;
134 
135                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
136                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
137                 if (singleCam_algo_handle)
138                     ret = singleCam_algo_handle->setStrength(pStrength);
139             }
140         }
141 #else
142         return XCAM_RETURN_ERROR_FAILED;
143 #endif
144 
145     } else {
146         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
147         RkAiqAynrV22HandleInt* algo_handle =
148             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
149 
150         if (algo_handle) {
151             return algo_handle->setStrength(pStrength);
152         }
153     }
154 
155     return ret;
156 }
157 
158 
159 XCamReturn
rk_aiq_user_api_aynrV22_GetStrength(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_strength_v22_t * pStrength)160 rk_aiq_user_api_aynrV22_GetStrength(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_strength_v22_t* pStrength)
161 {
162     XCamReturn ret = XCAM_RETURN_NO_ERROR;
163     RKAIQ_API_SMART_LOCK(sys_ctx);
164 
165 
166     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
167 #ifdef RKAIQ_ENABLE_CAMGROUP
168 
169         RkAiqCamGroupAynrV22HandleInt* algo_handle =
170             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
171 
172         if (algo_handle) {
173             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
174             return algo_handle->getStrength(pStrength);
175         } else {
176             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
177             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
178                 if (!camCtx)
179                     continue;
180                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
181                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
182                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
183                 if (singleCam_algo_handle)
184                     ret = singleCam_algo_handle->getStrength(pStrength);
185             }
186         }
187 #else
188         return XCAM_RETURN_ERROR_FAILED;
189 #endif
190 
191     } else {
192         RkAiqAynrV22HandleInt* algo_handle =
193             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
194         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
195         if (algo_handle) {
196             return algo_handle->getStrength(pStrength);
197         }
198     }
199 
200     return ret;
201 }
202 
203 
204 XCamReturn
rk_aiq_user_api_aynrV22_GetInfo(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_info_v22_t * pInfo)205 rk_aiq_user_api_aynrV22_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_info_v22_t* pInfo)
206 {
207     XCamReturn ret = XCAM_RETURN_NO_ERROR;
208     RKAIQ_API_SMART_LOCK(sys_ctx);
209 
210 
211     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
212 #ifdef RKAIQ_ENABLE_CAMGROUP
213 
214         RkAiqCamGroupAynrV22HandleInt* algo_handle =
215             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
216 
217         if (algo_handle) {
218             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
219             return algo_handle->getInfo(pInfo);
220         } else {
221             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
222             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
223                 if (!camCtx)
224                     continue;
225                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
226                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
227                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
228                 if (singleCam_algo_handle)
229                     ret = singleCam_algo_handle->getInfo(pInfo);
230             }
231         }
232 #else
233         return XCAM_RETURN_ERROR_FAILED;
234 #endif
235 
236     } else {
237         RkAiqAynrV22HandleInt* algo_handle =
238             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
239         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
240         if (algo_handle) {
241             return algo_handle->getInfo(pInfo);
242         }
243     }
244 
245     return ret;
246 }
247 
248 
249 #else
250 XCamReturn
251 rk_aiq_user_api_aynrV22_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_attrib_v22_t* attr) {
252     return XCAM_RETURN_ERROR_UNKNOWN;
253 }
254 
255 XCamReturn
256 rk_aiq_user_api_aynrV22_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_attrib_v22_t* attr) {
257     return XCAM_RETURN_ERROR_UNKNOWN;
258 }
259 
260 XCamReturn
261 rk_aiq_user_api_aynrV22_SetStrength(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_strength_v22_t* pStrength) {
262     return XCAM_RETURN_ERROR_UNKNOWN;
263 }
264 
265 XCamReturn
266 rk_aiq_user_api_aynrV22_GetStrength(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_strength_v22_t* pStrength) {
267     return XCAM_RETURN_ERROR_UNKNOWN;
268 }
269 
270 XCamReturn
271 rk_aiq_user_api_aynrV22_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_info_v22_t* pInfo)
272 {
273     return XCAM_RETURN_ERROR_UNKNOWN;
274 }
275 #endif
276 
277 RKAIQ_END_DECLARE
278