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 */
17 #include "rk_aiq_user_api_aldch.h"
18
19 #include "algo_handlers/RkAiqAldchHandle.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_LDCH_V10
28 XCamReturn
rk_aiq_user_api_aldch_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ldch_attrib_t * attr)29 rk_aiq_user_api_aldch_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ldch_attrib_t* attr)
30 {
31 CHECK_USER_API_ENABLE2(sys_ctx);
32 CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_ALDCH);
33 RKAIQ_API_SMART_LOCK(sys_ctx);
34
35 if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
36 #ifdef RKAIQ_ENABLE_CAMGROUP
37 RkAiqCamGroupAldchHandleInt* algo_handle =
38 camgroupAlgoHandle<RkAiqCamGroupAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
39
40 if (algo_handle) {
41 return algo_handle->setAttrib(attr);
42 } else {
43 XCamReturn ret = XCAM_RETURN_ERROR_FAILED;
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 RkAiqAldchHandleInt* singleCam_algo_handle =
50 algoHandle<RkAiqAldchHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ALDCH);
51 if (singleCam_algo_handle)
52 ret = singleCam_algo_handle->setAttrib(attr);
53 }
54 return ret;
55 }
56 #else
57 return XCAM_RETURN_ERROR_FAILED;
58 #endif
59 } else {
60 RkAiqAldchHandleInt* algo_handle =
61 algoHandle<RkAiqAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
62
63 if (algo_handle) {
64 return algo_handle->setAttrib(attr);
65 }
66 }
67
68 return XCAM_RETURN_ERROR_FAILED;
69 }
70
71 XCamReturn
rk_aiq_user_api_aldch_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ldch_attrib_t * attr)72 rk_aiq_user_api_aldch_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ldch_attrib_t *attr)
73 {
74 RKAIQ_API_SMART_LOCK(sys_ctx);
75
76 if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
77 #ifdef RKAIQ_ENABLE_CAMGROUP
78 RkAiqCamGroupAldchHandleInt* algo_handle =
79 camgroupAlgoHandle<RkAiqCamGroupAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
80
81 if (algo_handle) {
82 return algo_handle->getAttrib(attr);
83 } else {
84 XCamReturn ret = XCAM_RETURN_ERROR_FAILED;
85 const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
86 for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
87 if (!camCtx)
88 continue;
89
90 RkAiqAldchHandleInt* singleCam_algo_handle =
91 algoHandle<RkAiqAldchHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ALDCH);
92 if (singleCam_algo_handle)
93 ret = singleCam_algo_handle->getAttrib(attr);
94 }
95 return ret;
96 }
97 #else
98 return XCAM_RETURN_ERROR_FAILED;
99 #endif
100 } else {
101 RkAiqAldchHandleInt* algo_handle =
102 algoHandle<RkAiqAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
103
104 if (algo_handle) {
105 return algo_handle->getAttrib(attr);
106 }
107 }
108
109 return XCAM_RETURN_ERROR_FAILED;
110 }
111 #else
112 XCamReturn
113 rk_aiq_user_api_aldch_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ldch_attrib_t* attr)
114 {
115 return XCAM_RETURN_ERROR_UNKNOWN;
116 }
117
118 XCamReturn
119 rk_aiq_user_api_aldch_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ldch_attrib_t *attr)
120 {
121 return XCAM_RETURN_ERROR_UNKNOWN;
122 }
123 #endif
124
125 RKAIQ_END_DECLARE
126