1 /*
2 * rk_aiq_uapi_aldch_int.cpp
3 *
4 * Copyright (c) 2019 Rockchip Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #include "xcam_log.h"
21 #include "aldch/rk_aiq_uapi_aldch_int.h"
22 #include "aldch/rk_aiq_types_aldch_algo_prvt.h"
23
24 XCamReturn
rk_aiq_uapi_aldch_SetAttrib(RkAiqAlgoContext * ctx,rk_aiq_ldch_attrib_t attr,bool need_sync)25 rk_aiq_uapi_aldch_SetAttrib(RkAiqAlgoContext *ctx,
26 rk_aiq_ldch_attrib_t attr,
27 bool need_sync)
28 {
29 LDCHHandle_t ldch_contex = (LDCHHandle_t)ctx->hLDCH;
30
31 if (!ldch_contex->ldch_en && !attr.en) {
32 LOGE_AFEC("failed, ldch is disalbed!");
33 return XCAM_RETURN_ERROR_FAILED;
34 }
35
36 if (0 != memcmp(&ldch_contex->user_config, &attr, sizeof(rk_aiq_ldch_attrib_t))) {
37 memcpy(&ldch_contex->user_config, &attr, sizeof(rk_aiq_ldch_attrib_t));
38
39 SmartPtr<rk_aiq_ldch_attrib_t> attrPtr = new rk_aiq_ldch_attrib_t;
40
41 attrPtr->en = ldch_contex->user_config.en;
42 attrPtr->correct_level = ldch_contex->user_config.correct_level;
43 ldch_contex->aldchReadMeshThread->clear_attr();
44 ldch_contex->aldchReadMeshThread->push_attr(attrPtr);
45 LOGV_ALDCH("ldch en(%d-%d), level(%d)\n",
46 ldch_contex->ldch_en, attrPtr->en, attrPtr->correct_level);
47 }
48
49 return XCAM_RETURN_NO_ERROR;
50 }
51
52 XCamReturn
rk_aiq_uapi_aldch_GetAttrib(const RkAiqAlgoContext * ctx,rk_aiq_ldch_attrib_t * attr)53 rk_aiq_uapi_aldch_GetAttrib(const RkAiqAlgoContext *ctx,
54 rk_aiq_ldch_attrib_t *attr)
55 {
56 LDCHHandle_t ldch_contex = (LDCHHandle_t)ctx->hLDCH;
57
58 memcpy(attr, &ldch_contex->user_config, sizeof(rk_aiq_ldch_attrib_t));
59
60 return XCAM_RETURN_NO_ERROR;
61 }
62