1 /* 2 * rk_aiq_algo_des.h 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 #ifndef _RK_AIQ_ALGO_DES_H_ 21 #define _RK_AIQ_ALGO_DES_H_ 22 23 #include "base/xcam_common.h" 24 #include "rk_aiq_comm.h" 25 26 /* 27 * This file is used to define all the algos interfaces, eg. including ae, awb 28 * af, anr and etc. . The typical call routine by user is as follow: 29 * 1) create_context 30 * Should call this before any other interfaces, and should be called only 31 * once. 32 * 2) prepare 33 * some algos have lots of pre-condtions, these condtions may consist of 34 * sensor_descriptors, tuning params for algo. This interface may be called 35 * after |create_context| or |post_process|, and shouldn't be called 36 * after |pre_process| or |processing|. That means the configs can't be 37 * changed during the process stage, and could be repeated(re-config) until 38 * one completed process routine. 39 * 3) pre_process 40 * We separate the whole process to 3 steps: pre-process, processing and 41 * post-process. The caller will call all algos pre-process firstly, then 42 * call processing, then post-process at last. 43 * There may exist the dependancy between algos's params. pre-process aims 44 * to solve the dependancy. It collects all the dependancy before processing. 45 * 4) processing 46 * runs the algos then outputs the result. 47 * 5) post_process 48 * reserved. 49 * 6) destroy_context 50 * 51 */ 52 53 RKAIQ_BEGIN_DECLARE 54 55 typedef struct _RkAiqAlgoContext RkAiqAlgoContext; 56 #ifndef RKAIQAECEXPINFO_T 57 #define RKAIQAECEXPINFO_T 58 typedef struct RKAiqAecExpInfo_s RKAiqAecExpInfo_t; 59 #endif 60 #ifndef CAMCALIBDBCONTEXT_T 61 #define CAMCALIBDBCONTEXT_T 62 typedef void CamCalibDbContext_t; 63 #endif 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E_ACAC, 104 RK_AIQ_ALGO_TYPE_AFD, 105 RK_AIQ_ALGO_TYPE_MAX 106 } RkAiqAlgoType_t; 107 108 typedef struct _AlgoCtxInstanceCfg { 109 uint32_t isp_hw_version; 110 uint32_t module_hw_version; 111 CamCalibDbContext_t* calib; 112 CamCalibDbV2Context_t* calibv2; 113 bool isGroupMode; 114 } AlgoCtxInstanceCfg; 115 116 typedef struct _RkAiqAlgoDesComm { 117 const char* version; 118 const char* vendor; 119 const char* description; 120 RkAiqAlgoType_t type; 121 int id; 122 XCamReturn (*create_context) (RkAiqAlgoContext **context, const AlgoCtxInstanceCfg* cfg); 123 XCamReturn (*destroy_context) (RkAiqAlgoContext *context); 124 } RkAiqAlgoDesComm; 125 126 // base structs in order to abstract same interface 127 // for all algos 128 129 typedef enum RkAiqAlgoConfType_e { 130 RK_AIQ_ALGO_CONFTYPE_INIT = 0, 131 RK_AIQ_ALGO_CONFTYPE_UPDATECALIB = 0x01, 132 RK_AIQ_ALGO_CONFTYPE_CHANGEMODE = 0x02, 133 RK_AIQ_ALGO_CONFTYPE_NEEDRESET = 0x04, 134 RK_AIQ_ALGO_CONFTYPE_CHANGERES = 0x08, 135 RK_AIQ_ALGO_CONFTYPE_KEEPSTATUS = 0x10, 136 RK_AIQ_ALGO_CONFTYPE_CHANGECAMS = 0x20, 137 RK_AIQ_ALGO_CONFTYPE_MAX 138 } RkAiqAlgoConfType_t; 139 140 typedef struct _RkAiqAlgoCom { 141 RkAiqAlgoContext *ctx; 142 uint32_t frame_id; 143 union { 144 struct { 145 int working_mode; // real type is rk_aiq_working_mode_t or rk_aiq_isp_hdr_mode_t 146 int sns_op_width; 147 int sns_op_height; 148 int conf_type; 149 CamCalibDbContext_t* calib; 150 CamCalibDbV2Context_t* calibv2; 151 } prepare; //for prepare function 152 153 struct { 154 bool init; 155 int iso; 156 bool fill_light_on; 157 bool gray_mode; 158 bool is_bw_sensor; 159 RKAiqAecExpInfo_t *preExp; 160 RKAiqAecExpInfo_t *curExp; 161 RKAiqAecExpInfo_t *nxtExp; 162 RkAiqResComb* res_comb; 163 } proc; //for pre/processing/post function 164 } u; 165 void* reserverd; //transfer whatever used by prepare/pre/processing/post 166 } RkAiqAlgoCom; 167 168 // generic result type 169 typedef struct _RkAiqAlgoResCom { 170 bool cfg_update; 171 } RkAiqAlgoResCom; 172 173 typedef struct _RkAiqAlgoDescription { 174 RkAiqAlgoDesComm common; 175 XCamReturn (*prepare)(RkAiqAlgoCom* params); 176 XCamReturn (*pre_process)(const RkAiqAlgoCom* inparams, RkAiqAlgoResCom* outparams); 177 XCamReturn (*processing)(const RkAiqAlgoCom* inparams, RkAiqAlgoResCom* outparams); 178 XCamReturn (*post_process)(const RkAiqAlgoCom* inparams, RkAiqAlgoResCom* outparams); 179 } RkAiqAlgoDescription; 180 181 RKAIQ_END_DECLARE 182 183 #endif //_RK_AIQ_ALGO_DES_H_ 184