1 /* 2 *rk_aiq_types_asharp_algo_int.h 3 * 4 * Copyright (c) 2022 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_TYPES_ASHARP_ALOG_INT_V33_H_ 21 #define _RK_AIQ_TYPES_ASHARP_ALOG_INT_V33_H_ 22 23 #include <math.h> 24 #include <stdlib.h> 25 #include <string.h> 26 27 #include "RkAiqCalibDbTypes.h" 28 #include "asharpV33/rk_aiq_types_asharp_algo_v33.h" 29 #include "rk_aiq_comm.h" 30 #include "sharp_head_v33.h" 31 #include "sharp_uapi_head_v33.h" 32 33 34 35 #define ASHARPV33_RECALCULATE_DELTA_ISO (10) 36 #define RK_SHARP_V33_MAX_ISO_NUM CALIBDB_MAX_ISO_LEVEL 37 38 39 #define RK_SHARP_V33_SHARP_RATIO_FIX_BITS 2 40 #define RK_SHARP_V33_GAUS_RATIO_FIX_BITS 7 41 #define RK_SHARP_V33_BF_RATIO_FIX_BITS 7 42 #define RK_SHARP_V33_PBFCOEFF_FIX_BITS 7 43 #define RK_SHARP_V33_RFCOEFF_FIX_BITS 7 44 #define RK_SHARP_V33_HBFCOEFF_FIX_BITS 7 45 46 #define RK_SHARP_V33_GLOBAL_GAIN_FIX_BITS 4 47 #define RK_SHARP_V33_GLOBAL_GAIN_ALPHA_FIX_BITS 3 48 #define RK_SHARP_V33_LOCAL_GAIN_FIX_BITS 4 49 #define RK_SHARP_V33_LOCAL_GAIN_SACLE_FIX_BITS 7 50 #define RK_SHARP_V33_ADJ_GAIN_FIX_BITS 10 51 #define RK_SHARP_V33_STRENGTH_TABLE_FIX_BITS 7 52 53 #define INTERP_V4(x0, x1, ratio) ((ratio) * ((x1) - (x0)) + x0) 54 #define CLIP(a, min_v, max_v) (((a) < (min_v)) ? (min_v) : (((a) > (max_v)) ? (max_v) : (a))) 55 56 typedef enum Asharp_result_V33_e { 57 ASHARP_V33_RET_SUCCESS = 0, // this has to be 0, if clauses rely on it 58 ASHARP_V33_RET_FAILURE = 1, // process failure 59 ASHARP_V33_RET_INVALID_PARM = 2, // invalid parameter 60 ASHARP_V33_RET_WRONG_CONFIG = 3, // feature not supported 61 ASHARP_V33_RET_BUSY = 4, // there's already something going on... 62 ASHARP_V33_RET_CANCELED = 5, // operation canceled 63 ASHARP_V33_RET_OUTOFMEM = 6, // out of memory 64 ASHARP_V33_RET_OUTOFRANGE = 7, // parameter/value out of range 65 ASHARP_V33_RET_NULL_POINTER = 8, // the/one/all parameter(s) is a(are) NULL pointer(s) 66 ASHARP_V33_RET_DIVISION_BY_ZERO = 9, // a divisor equals ZERO 67 ASHARP_V33_RET_NO_INPUTIMAGE = 10 // no input image 68 } Asharp_result_V33_t; 69 70 typedef enum Asharp_State_V33_e { 71 ASHARP_V33_STATE_INVALID = 0, /**< initialization value */ 72 ASHARP_V33_STATE_INITIALIZED = 1, /**< instance is created, but not initialized */ 73 ASHARP_V33_STATE_STOPPED = 2, /**< instance is confiured (ready to start) or stopped */ 74 ASHARP_V33_STATE_RUNNING = 3, /**< instance is running (processes frames) */ 75 ASHARP_V33_STATE_LOCKED = 4, /**< instance is locked (for taking snapshots) */ 76 ASHARP_V33_STATE_MAX /**< max */ 77 } Asharp_State_V33_t; 78 79 typedef enum Asharp_OPMode_V33_e { 80 ASHARP_V33_OP_MODE_INVALID = 0, /**< initialization value */ 81 ASHARP_V33_OP_MODE_AUTO = 1, /**< instance is created, but not initialized */ 82 ASHARP_V33_OP_MODE_MANUAL = 2, /**< instance is confiured (ready to start) or stopped */ 83 ASHARP_V33_OP_MODE_REG_MANUAL = 3, 84 ASHARP_V33_OP_MODE_MAX /**< max */ 85 } Asharp_OPMode_V33_t; 86 87 typedef enum Asharp_ParamMode_V33_e { 88 ASHARP_V33_PARAM_MODE_INVALID = 0, 89 ASHARP_V33_PARAM_MODE_NORMAL = 1, /**< initialization value */ 90 ASHARP_V33_PARAM_MODE_HDR = 2, /**< instance is created, but not initialized */ 91 ASHARP_V33_PARAM_MODE_GRAY = 3, /**< instance is confiured (ready to start) or stopped */ 92 ASHARP_V33_PARAM_MODE_MAX /**< max */ 93 } Asharp_ParamMode_V33_t; 94 95 96 97 #if 0 98 // sharp params related to ISO 99 typedef struct RK_SHARP_V33_Select_ISO_s { 100 int luma_sigma[RK_SHARP_V33_LUMA_POINT_NUM]; 101 int luma_point[RK_SHARP_V33_LUMA_POINT_NUM]; 102 float pbf_gain; 103 float pbf_add; 104 float pbf_ratio; 105 float gaus_ratio; 106 float sharp_ratio; 107 int lum_clip_h[RK_SHARP_V33_LUMA_POINT_NUM]; 108 float bf_gain; 109 float bf_add; 110 float bf_ratio; 111 int global_clip_pos; 112 113 float prefilter_coeff[RK_SHARP_V33_PBF_DIAM * RK_SHARP_V33_PBF_DIAM]; 114 float GaussianFilter_coeff[RK_SHARP_V33_RF_DIAM * RK_SHARP_V33_RF_DIAM]; 115 float hfBilateralFilter_coeff[RK_SHARP_V33_BF_DIAM * RK_SHARP_V33_BF_DIAM]; 116 117 float global_gain; 118 float global_gain_alpha; 119 float local_gainscale; 120 121 float gain_adj_sharp_strength[RK_SHARP_V33_SHARP_ADJ_GAIN_TABLE_LEN]; 122 int exgain_bypass; 123 124 float dis_adj_sharp_strength[RK_SHARP_V33_STRENGTH_TABLE_LEN]; 125 126 float noiseclip_strength; 127 int enhance_bit; 128 int noiseclip_mode; 129 int noise_sigma_clip; 130 131 float prefilter_sigma; 132 float hfBilateralFilter_sigma; 133 float GaussianFilter_sigma; 134 float GaussianFilter_radius; 135 136 } RK_SHARP_V33_Select_ISO_t; 137 138 // sharp params select 139 typedef struct RK_SHARP_Params_V33_Select_s { 140 int enable; 141 int kernel_sigma_enable; 142 143 int center_mode; 144 int center_x; 145 int center_y; 146 147 RK_SHARP_V33_Select_ISO_t sharpParamsSelectISO; 148 149 } RK_SHARP_Params_V33_Select_t; 150 #endif 151 152 153 // sharp params 154 typedef struct RK_SHARP_Params_V33_s { 155 int enable; 156 int sharp_ratio_seperate_en; 157 int kernel_sigma_enable; 158 char version[64]; 159 160 161 int Center_Mode; 162 int center_x; 163 int center_y; 164 165 int iso[RK_SHARP_V33_MAX_ISO_NUM]; 166 RK_SHARP_Params_V33_Select_t sharpParamsISO[RK_SHARP_V33_MAX_ISO_NUM]; 167 168 } RK_SHARP_Params_V33_t; 169 170 typedef struct Asharp_Manual_Attr_V33_s { 171 RK_SHARP_Params_V33_Select_t stSelect; 172 173 RK_SHARP_Fix_V33_t stFix; 174 175 } Asharp_Manual_Attr_V33_t; 176 177 typedef struct Asharp_Auto_Attr_V33_s { 178 // all ISO params and select param 179 180 RK_SHARP_Params_V33_t stParams; 181 RK_SHARP_Params_V33_Select_t stSelect; 182 183 } Asharp_Auto_Attr_V33_t; 184 185 // for isp32 lite version 186 typedef struct RK_SHARP_Params_V33LT_s { 187 int enable; 188 int sharp_ratio_seperate_en; 189 int kernel_sigma_enable; 190 char version[64]; 191 192 int Center_Mode; 193 int center_x; 194 int center_y; 195 196 int iso[RK_SHARP_V33_MAX_ISO_NUM]; 197 RK_SHARP_Params_V33LT_Select_t sharpParamsISO[RK_SHARP_V33_MAX_ISO_NUM]; 198 199 } RK_SHARP_Params_V33LT_t; 200 201 typedef struct Asharp_Manual_Attr_V33LT_s { 202 RK_SHARP_Params_V33LT_Select_t stSelect; 203 204 RK_SHARP_Fix_V33_t stFix; 205 206 } Asharp_Manual_Attr_V33LT_t; 207 208 typedef struct Asharp_Auto_Attr_V33LT_s { 209 // all ISO params and select param 210 211 RK_SHARP_Params_V33LT_t stParams; 212 RK_SHARP_Params_V33LT_Select_t stSelect; 213 214 } Asharp_Auto_Attr_V33LT_t; 215 216 typedef struct Asharp_ProcResult_V33_s { 217 #if RKAIQ_HAVE_SHARP_V33 218 // for sw simultaion 219 // RK_SHARP_Params_V33_Select_t stSelect; 220 #else 221 // for isp32 lite version 222 // for sw simultaion 223 //RK_SHARP_Params_V33LT_Select_t stSelect; 224 #endif 225 226 // for hw register 227 RK_SHARP_Fix_V33_t* stFix; 228 } Asharp_ProcResult_V33_t; 229 230 typedef struct Asharp_Config_V33_s { 231 Asharp_State_V33_t eState; 232 Asharp_OPMode_V33_t eMode; 233 int rawHeight; 234 int rawWidth; 235 } Asharp_Config_V33_t; 236 237 typedef struct rk_aiq_sharp_attrib_v33_s { 238 rk_aiq_uapi_sync_t sync; 239 240 Asharp_OPMode_V33_t eMode; 241 Asharp_Auto_Attr_V33_t stAuto; 242 Asharp_Manual_Attr_V33_t stManual; 243 } rk_aiq_sharp_attrib_v33_t; 244 245 typedef struct rk_aiq_sharp_attrib_v33LT_s { 246 rk_aiq_uapi_sync_t sync; 247 248 Asharp_OPMode_V33_t eMode; 249 Asharp_Auto_Attr_V33LT_t stAuto; 250 Asharp_Manual_Attr_V33LT_t stManual; 251 } rk_aiq_sharp_attrib_v33LT_t; 252 253 typedef struct rk_aiq_sharp_strength_v33_s { 254 rk_aiq_uapi_sync_t sync; 255 256 float percent; 257 bool strength_enable; 258 } rk_aiq_sharp_strength_v33_t; 259 260 261 262 263 #endif 264