xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/algos/afec/rk_aiq_uapi_afec_int.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * rk_aiq_uapi_afec_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 "afec/rk_aiq_uapi_afec_int.h"
22 #include "afec/rk_aiq_types_afec_algo_prvt.h"
23 
24 XCamReturn
rk_aiq_uapi_afec_SetAttrib(RkAiqAlgoContext * ctx,rk_aiq_fec_attrib_t attr,bool need_sync)25 rk_aiq_uapi_afec_SetAttrib(RkAiqAlgoContext *ctx,
26                            rk_aiq_fec_attrib_t attr,
27                            bool need_sync)
28 {
29     FECHandle_t fec_contex = (FECHandle_t)ctx->hFEC;;
30 
31     LOGD_AFEC("Fec setAttr en(%d), bypass(%d), correct_level(%d), direction(%d)\n",
32             attr.en, attr.bypass, attr.correct_level, attr.direction);
33 
34     if (fec_contex->fec_en != attr.en && \
35         (fec_contex->eState == FEC_STATE_INITIALIZED || \
36          fec_contex->eState == FEC_STATE_RUNNING)) {
37         LOGE_AFEC("failed, Fec en(%d-%d) don't support switch at running time!\n",
38                   fec_contex->fec_en, attr.en);
39         return XCAM_RETURN_ERROR_FAILED;
40     }
41 
42     if (fec_contex->user_config.bypass && attr.bypass) {
43         LOGE_AFEC("failed, bypass fec!\n");
44         return XCAM_RETURN_ERROR_FAILED;
45     }
46 
47     if (0 != memcmp(&fec_contex->user_config, &attr, sizeof(rk_aiq_fec_attrib_t)) ||\
48         fec_contex->eState == FEC_STATE_INVALID) {
49         memcpy(&fec_contex->user_config, &attr, sizeof(rk_aiq_fec_attrib_t));
50 
51         SmartPtr<rk_aiq_fec_attrib_t> attrPtr = new rk_aiq_fec_attrib_t;
52 
53         attrPtr->en = fec_contex->user_config.en;
54         attrPtr->mode = fec_contex->user_config.mode;
55         attrPtr->bypass = fec_contex->user_config.bypass;
56         attrPtr->correct_level = fec_contex->user_config.correct_level;
57         fec_contex->afecReadMeshThread->clear_attr();
58         fec_contex->afecReadMeshThread->push_attr(attrPtr);
59     }
60 
61     return XCAM_RETURN_NO_ERROR;
62 }
63 
64 XCamReturn
rk_aiq_uapi_afec_GetAttrib(const RkAiqAlgoContext * ctx,rk_aiq_fec_attrib_t * attr)65 rk_aiq_uapi_afec_GetAttrib(const RkAiqAlgoContext *ctx,
66                            rk_aiq_fec_attrib_t *attr)
67 {
68     FECHandle_t fec_contex = (FECHandle_t)ctx->hFEC;;
69 
70     memcpy(attr, &fec_contex->user_config, sizeof(rk_aiq_fec_attrib_t));
71 
72     LOGD_AFEC("Fec getAttr en(%d), bypass(%d), correct_level(%d), direction(%d)\n",
73             attr->en, attr->bypass, attr->correct_level, attr->direction);
74 
75     return XCAM_RETURN_NO_ERROR;
76 }
77