1 /*
2 * Copyright (c) 2019 Rockchip Corporation
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
18 #include "rk_aiq_user_api2_aldch_v21.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_LDCH_V21
27 XCamReturn
rk_aiq_user_api2_aldch_v21_SetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,const rk_aiq_ldch_v21_attrib_t * attr)28 rk_aiq_user_api2_aldch_v21_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ldch_v21_attrib_t* attr)
29 {
30 CHECK_USER_API_ENABLE2(sys_ctx);
31 CHECK_USER_API_ENABLE(RK_AIQ_ALGO_TYPE_ALDCH);
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 RkAiqCamGroupAldchHandleInt* algo_handle =
37 camgroupAlgoHandle<RkAiqCamGroupAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
38
39 if (algo_handle) {
40 return algo_handle->setAttrib(attr);
41 } else {
42 XCamReturn ret = XCAM_RETURN_ERROR_FAILED;
43 const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
44 for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
45 if (!camCtx)
46 continue;
47
48 RkAiqAldchHandleInt* singleCam_algo_handle =
49 algoHandle<RkAiqAldchHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ALDCH);
50 if (singleCam_algo_handle)
51 ret = singleCam_algo_handle->setAttrib(attr);
52 }
53 return ret;
54 }
55 #else
56 return XCAM_RETURN_ERROR_FAILED;
57 #endif
58 } else {
59 if (attr->sync.sync_mode == RK_AIQ_UAPI_MODE_ASYNC && \
60 attr->lut.update_flag && \
61 attr->update_lut_mode == RK_AIQ_LDCH_UPDATE_LUT_FROM_EXTERNAL_BUFFER) {
62 LOGE_ALDCH("Unsupported update_lut_mode %d in async mode.\n", attr->update_lut_mode);
63 return XCAM_RETURN_ERROR_PARAM;
64 }
65
66 RkAiqAldchHandleInt* algo_handle =
67 algoHandle<RkAiqAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
68
69 if (algo_handle) {
70 return algo_handle->setAttrib(attr);
71 }
72 }
73
74 return XCAM_RETURN_ERROR_FAILED;
75 }
76
77 XCamReturn
rk_aiq_user_api2_aldch_v21_GetAttrib(const rk_aiq_sys_ctx_t * sys_ctx,rk_aiq_ldch_v21_attrib_t * attr)78 rk_aiq_user_api2_aldch_v21_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ldch_v21_attrib_t *attr)
79 {
80 RKAIQ_API_SMART_LOCK(sys_ctx);
81
82 if (sys_ctx->cam_type == RK_AIQ_CAM_TYPE_GROUP) {
83 #ifdef RKAIQ_ENABLE_CAMGROUP
84 RkAiqCamGroupAldchHandleInt* algo_handle =
85 camgroupAlgoHandle<RkAiqCamGroupAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
86
87 if (algo_handle) {
88 return algo_handle->getAttrib(attr);
89 } else {
90 XCamReturn ret = XCAM_RETURN_ERROR_FAILED;
91 const rk_aiq_camgroup_ctx_t* camgroup_ctx = (rk_aiq_camgroup_ctx_t *)sys_ctx;
92 for (auto camCtx : camgroup_ctx->cam_ctxs_array) {
93 if (!camCtx)
94 continue;
95
96 RkAiqAldchHandleInt* singleCam_algo_handle =
97 algoHandle<RkAiqAldchHandleInt>(camCtx, RK_AIQ_ALGO_TYPE_ALDCH);
98 if (singleCam_algo_handle)
99 ret = singleCam_algo_handle->getAttrib(attr);
100 }
101 return ret;
102 }
103 #else
104 return XCAM_RETURN_ERROR_FAILED;
105 #endif
106 } else {
107 RkAiqAldchHandleInt* algo_handle =
108 algoHandle<RkAiqAldchHandleInt>(sys_ctx, RK_AIQ_ALGO_TYPE_ALDCH);
109
110 if (algo_handle) {
111 return algo_handle->getAttrib(attr);
112 }
113 }
114
115 return XCAM_RETURN_ERROR_FAILED;
116 }
117 #else
118 XCamReturn
119 rk_aiq_user_api2_aldch_v21_SetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, const rk_aiq_ldch_v21_attrib_t* attr)
120 {
121 return XCAM_RETURN_ERROR_UNKNOWN;
122 }
123
124 XCamReturn
125 rk_aiq_user_api2_aldch_v21_GetAttrib(const rk_aiq_sys_ctx_t* sys_ctx, rk_aiq_ldch_v21_attrib_t *attr)
126 {
127 return XCAM_RETURN_ERROR_UNKNOWN;
128 }
129 #endif
130
131 RKAIQ_END_DECLARE
132