xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/uAPI2/rk_aiq_user_api2_aie.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_api2_aie.h"
17 #include "RkAiqCamGroupHandleInt.h"
18 #include "algo_handlers/RkAiqAieHandle.h"
19 
20 RKAIQ_BEGIN_DECLARE
21 
22 #ifdef RK_SIMULATOR_HW
23 #define CHECK_USER_API_ENABLE
24 #endif
25 #if RKAIQ_HAVE_AIE_V10
rk_aiq_user_api2_aie_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const aie_attrib_t * attr)26 XCamReturn  rk_aiq_user_api2_aie_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx,
27                                         const aie_attrib_t* attr)
28 {
29     XCamReturn ret = XCAM_RETURN_NO_ERROR;
30     CHECK_USER_API_ENABLE2(sys_ctx);
31     CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_AIE);
32     RKAIQ_API_SMART_LOCK(sys_ctx);
33 
34     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
35 #ifdef RKAIQ_ENABLE_CAMGROUP
36         const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
37         for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
38             if (!camCtx)
39                 continue;
40 
41             RkAiqAieHandleInt* singleCam_algo_handle =
42                 algoHandle<RkAiqAieHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AIE);
43 
44             if (singleCam_algo_handle) {
45                 ret = singleCam_algo_handle->setAttrib(attr);
46             }
47         }
48 #else
49         return XCAM_RETURN_ERROR_FAILED;
50 #endif
51     } else {
52         RkAiqAieHandleInt* algo_handle =
53             algoHandle<RkAiqAieHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AIE);
54 
55         if (algo_handle) {
56             return algo_handle->setAttrib(attr);
57         }
58     }
59 
60     return (ret);
61 }
62 
rk_aiq_user_api2_aie_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,aie_attrib_t * attr)63 XCamReturn  rk_aiq_user_api2_aie_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx,
64                                             aie_attrib_t *attr)
65 {
66     RKAIQ_API_SMART_LOCK(sys_ctx);
67     XCamReturn ret = XCAM_RETURN_NO_ERROR;
68 
69     if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
70 #ifdef RKAIQ_ENABLE_CAMGROUP
71         const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
72         for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
73             if (!camCtx)
74                 continue;
75             RkAiqAieHandleInt* singleCam_algo_handle =
76                 algoHandle<RkAiqAieHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_AIE);
77 
78             if (singleCam_algo_handle) {
79                 return singleCam_algo_handle->getAttrib(attr);
80             }
81         }
82 #else
83         return XCAM_RETURN_ERROR_FAILED;
84 #endif
85     } else {
86         RkAiqAieHandleInt* algo_handle =
87             algoHandle<RkAiqAieHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_AIE);
88 
89         if (algo_handle) {
90             return algo_handle->getAttrib(attr);
91         }
92     }
93 
94     return (ret);
95 }
96 #else
97 XCamReturn  rk_aiq_user_api2_aie_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx,
98                                             const aie_attrib_t* attr)
99 {
100 
101     return XCAM_RETURN_ERROR_UNKNOWN;
102 
103 }
104 
105 XCamReturn  rk_aiq_user_api2_aie_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx,
106                                             aie_attrib_t *attr)
107 {
108 
109     return XCAM_RETURN_ERROR_UNKNOWN;
110 
111 }
112 #endif
113 
114 RKAIQ_END_DECLARE
115 
116 
117 
118