xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/uAPI2/rk_aiq_user_api2_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 "uAPI2/rk_aiq_user_api2_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_api2_aynrV22_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ynr_attrib_v22_t * attr)30 rk_aiq_user_api2_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_api2_aynrV22_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_attrib_v22_t * attr)73 rk_aiq_user_api2_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_api2_aynrV22_SetStrength(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ynr_strength_v22_t * pStrength)115 rk_aiq_user_api2_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_api2_aynrV22_GetStrength(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_strength_v22_t * pStrength)160 rk_aiq_user_api2_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 XCamReturn
rk_aiq_user_api2_aynrV22_GetInfo(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ynr_info_v22_t * pInfo)204 rk_aiq_user_api2_aynrV22_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_info_v22_t* pInfo)
205 {
206     XCamReturn ret = XCAM_RETURN_NO_ERROR;
207     RKAIQ_API_SMART_LOCK(sys_ctx);
208 
209 
210     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
211 #ifdef RKAIQ_ENABLE_CAMGROUP
212 
213         RkAiqCamGroupAynrV22HandleInt* algo_handle =
214             camgroupAlgoHandle<RkAiqCamGroupAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
215 
216         if (algo_handle) {
217             LOGD_ANR("%s:%d !!!!!!!!!!!!!group!!!!!!!!\n", __FUNCTION__, __LINE__);
218             return algo_handle->getInfo(pInfo);
219         } else {
220             const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
221             for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
222                 if (!camCtx)
223                     continue;
224                 LOGD_ANR("%s:%d !!!!!!!!!!!!!multi single!!!!!!!!\n", __FUNCTION__, __LINE__);
225                 RkAiqAynrV22HandleInt* singleCam_algo_handle =
226                     algoHandle<RkAiqAynrV22HandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AYNR);
227                 if (singleCam_algo_handle)
228                     ret = singleCam_algo_handle->getInfo(pInfo);
229             }
230         }
231 #else
232         return XCAM_RETURN_ERROR_FAILED;
233 #endif
234 
235     } else {
236         RkAiqAynrV22HandleInt* algo_handle =
237             algoHandle<RkAiqAynrV22HandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AYNR);
238         LOGD_ANR("%s:%d !!!!!!!!!!!!!single!!!!!!!!\n", __FUNCTION__, __LINE__);
239         if (algo_handle) {
240             return algo_handle->getInfo(pInfo);
241         }
242     }
243 
244     return ret;
245 }
246 
247 #else
248 XCamReturn
249 rk_aiq_user_api2_aynrV22_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_attrib_v22_t* attr) {
250     return XCAM_RETURN_ERROR_UNKNOWN;
251 }
252 
253 XCamReturn
254 rk_aiq_user_api2_aynrV22_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_attrib_v22_t* attr) {
255     return XCAM_RETURN_ERROR_UNKNOWN;
256 }
257 
258 XCamReturn
259 rk_aiq_user_api2_aynrV22_SetStrength(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ynr_strength_v22_t* pStrength) {
260     return XCAM_RETURN_ERROR_UNKNOWN;
261 }
262 
263 XCamReturn
264 rk_aiq_user_api2_aynrV22_GetStrength(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_strength_v22_t* pStrength) {
265     return XCAM_RETURN_ERROR_UNKNOWN;
266 }
267 XCamReturn
268 rk_aiq_user_api2_aynrV22_GetInfo(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ynr_info_v22_t* pInfo)
269 {
270     return XCAM_RETURN_ERROR_UNKNOWN;
271 }
272 
273 #endif
274 
275 RKAIQ_END_DECLARE
276