1 /*
2  * Copyright (c) 2019-2021 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 "RkAiqCustomAwbHandle.h"
18 
19 namespace RkCam {
20 
21 //#define BYPASS_CUSTOM_AWB
22 
23 void
init()24 RkAiqCustomAwbHandle::init() {
25     if (mIsMulRun) {
26         // reuse parent's resources, contains:
27         // mConfig, mProcInParam, mProcOutParam
28         RkAiqAwbHandleInt* parent =  dynamic_cast<RkAiqAwbHandleInt*>(mParentHdl);
29         if (!parent)
30             LOGE_AWB("no parent awb handler in multiple handler mode !");
31         mConfig      = parent->mConfig;
32         mProcInParam = parent->mProcInParam;
33         mProcOutParam = parent->mProcOutParam;
34     } else {
35         RkAiqAwbHandleInt::init();
36     }
37 }
38 
39 void
deInit()40 RkAiqCustomAwbHandle::deInit() {
41     if (mIsMulRun) {
42         mConfig      = NULL;
43         mProcInParam = NULL;
44         mProcOutParam = NULL;
45     } else {
46         RkAiqAwbHandleInt::deInit();
47     }
48 }
49 
updateConfig(bool needSync)50 XCamReturn RkAiqCustomAwbHandle::updateConfig(bool needSync) {
51     ENTER_ANALYZER_FUNCTION();
52 
53     XCamReturn ret = XCAM_RETURN_NO_ERROR;
54     EXIT_ANALYZER_FUNCTION();
55     return ret;
56 }
57 
processing()58 XCamReturn RkAiqCustomAwbHandle::processing() {
59     ENTER_ANALYZER_FUNCTION();
60 
61     XCamReturn ret = XCAM_RETURN_NO_ERROR;
62 
63 #ifdef BYPASS_CUSTOM_AWB
64     if (0) {
65 #else
66     if (mIsMulRun) {
67 #endif
68         // use parent's mem, so child algo results can overwrite parents results
69         RkAiqAwbHandleInt* parent =  dynamic_cast<RkAiqAwbHandleInt*>(mParentHdl);
70         if (!parent)
71             LOGE_AWB("no parent awb handler in multiple handler mode !");
72         mProcResShared =  parent->mProcResShared ;
73     } else {
74         mProcResShared = new RkAiqAlgoProcResAwbIntShared();
75         if (!mProcResShared.ptr()) {
76             LOGE_AWB("new awb mProcOutParam failed, bypass!");
77             return XCAM_RETURN_BYPASS;
78         }
79     }
80 
81     return RkAiqAwbHandleInt::processing();
82 
83     EXIT_ANALYZER_FUNCTION();
84     return ret;
85 }
86 
87 XCamReturn RkAiqCustomAwbHandle::genIspResult(RkAiqFullParams* params, RkAiqFullParams* cur_params) {
88 #ifdef BYPASS_CUSTOM_AWB
89     return XCAM_RETURN_NO_ERROR;
90 #else
91     return RkAiqAwbHandleInt::genIspResult(params, cur_params);
92 #endif
93 }
94 
95 }  // namespace RkCam
96