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_adpcc.h"
17
18 #include "algo_handlers/RkAiqAdpccHandle.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_DPCC_V1
rk_aiq_user_api2_adpcc_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_dpcc_attrib_V20_t * attr)27 XCamReturn rk_aiq_user_api2_adpcc_SetAttrib(const rk_aiq_sys_ctx_t *sys_ctx,
28 rk_aiq_dpcc_attrib_V20_t *attr) {
29 XCamReturn ret = XCAM_RETURN_NO_ERROR;
30 CHECK_USER_API_ENABLE2(sys_ctx);
31 CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_ADPCC);
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 RkAiqCamGroupAdpccHandleInt *algo_handle =
37 camgroupAlgoHandle<RkAiqCamGroupAdpccHandleInt>(sys_ctx,
38 RK_AIQ_ALGO_TYPE_ADPCC);
39
40 if (algo_handle) {
41 return algo_handle->setAttrib(*attr);
42 } else {
43 XCamReturn ret = XCAM_RETURN_NO_ERROR;
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) continue;
47
48 RkAiqAdpccHandleInt* singleCam_algo_handle =
49 algoHandle<RkAiqAdpccHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ADPCC);
50 if (singleCam_algo_handle) {
51 ret = singleCam_algo_handle->setAttrib(attr);
52 if (ret != XCAM_RETURN_NO_ERROR) LOGE("%s returned: %d", __FUNCTION__, ret);
53 }
54 }
55 return ret;
56 }
57 #else
58 return XCAM_RETURN_ERROR_FAILED;
59 #endif
60 } else {
61 RkAiqAdpccHandleInt *algo_handle =
62 algoHandle<RkAiqAdpccHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ADPCC);
63
64 if (algo_handle) {
65 return algo_handle->setAttrib(attr);
66 }
67 }
68
69 return XCAM_RETURN_ERROR_FAILED;
70 }
71
rk_aiq_user_api2_adpcc_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_dpcc_attrib_V20_t * attr)72 XCamReturn rk_aiq_user_api2_adpcc_GetAttrib(const rk_aiq_sys_ctx_t *sys_ctx,
73 rk_aiq_dpcc_attrib_V20_t *attr) {
74 RKAIQ_API_SMART_LOCK(sys_ctx);
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 RkAiqCamGroupAdpccHandleInt *algo_handle =
80 camgroupAlgoHandle<RkAiqCamGroupAdpccHandleInt>(sys_ctx,
81 RK_AIQ_ALGO_TYPE_ADPCC);
82
83 if (algo_handle) {
84 return algo_handle->getAttrib(attr);
85 } else {
86 const rk_aiq_camgroup_ctx_t *camgroup_ctx =
87 (rk_aiq_camgroup_ctx_t *)sys_ctx;
88 for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
89 if (!camCtx)
90 continue;
91
92 RkAiqAdpccHandleInt *singleCam_algo_handle =
93 algoHandle<RkAiqAdpccHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ADPCC);
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 } else {
102 RkAiqAdpccHandleInt *algo_handle =
103 algoHandle<RkAiqAdpccHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ADPCC);
104
105 if (algo_handle) {
106 return algo_handle->getAttrib(attr);
107 }
108 }
109
110 return (ret);
111 }
112 #else
113
114 XCamReturn rk_aiq_user_api2_adpcc_SetAttrib(const rk_aiq_sys_ctx_t *sys_ctx,
115 rk_aiq_dpcc_attrib_V20_t *attr) {
116 return XCAM_RETURN_ERROR_FAILED;
117 }
118
119 XCamReturn rk_aiq_user_api2_adpcc_GetAttrib(const rk_aiq_sys_ctx_t *sys_ctx,
120 rk_aiq_dpcc_attrib_V20_t *attr) {
121 return XCAM_RETURN_ERROR_FAILED;
122 }
123
124 #endif // RKAIQ_HAVE_DPCC_V1
125
126 RKAIQ_END_DECLARE
127