1 /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */ 2 /* 3 * Rockchip ISP1 userspace API 4 * Copyright (C) 2017 Rockchip Electronics Co., Ltd. 5 */ 6 7 #ifndef _UAPI_RKISP1_CONFIG_H 8 #define _UAPI_RKISP1_CONFIG_H 9 10 #include <linux/types.h> 11 12 /* Defect Pixel Cluster Detection */ 13 #define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0) 14 /* Black Level Subtraction */ 15 #define RKISP1_CIF_ISP_MODULE_BLS (1U << 1) 16 /* Sensor De-gamma */ 17 #define RKISP1_CIF_ISP_MODULE_SDG (1U << 2) 18 /* Histogram statistics configuration */ 19 #define RKISP1_CIF_ISP_MODULE_HST (1U << 3) 20 /* Lens Shade Control */ 21 #define RKISP1_CIF_ISP_MODULE_LSC (1U << 4) 22 /* Auto White Balance Gain */ 23 #define RKISP1_CIF_ISP_MODULE_AWB_GAIN (1U << 5) 24 /* Filter */ 25 #define RKISP1_CIF_ISP_MODULE_FLT (1U << 6) 26 /* Bayer Demosaic */ 27 #define RKISP1_CIF_ISP_MODULE_BDM (1U << 7) 28 /* Cross Talk */ 29 #define RKISP1_CIF_ISP_MODULE_CTK (1U << 8) 30 /* Gamma Out Curve */ 31 #define RKISP1_CIF_ISP_MODULE_GOC (1U << 9) 32 /* Color Processing */ 33 #define RKISP1_CIF_ISP_MODULE_CPROC (1U << 10) 34 /* Auto Focus Control statistics configuration */ 35 #define RKISP1_CIF_ISP_MODULE_AFC (1U << 11) 36 /* Auto White Balancing statistics configuration */ 37 #define RKISP1_CIF_ISP_MODULE_AWB (1U << 12) 38 /* Image Effect */ 39 #define RKISP1_CIF_ISP_MODULE_IE (1U << 13) 40 /* Auto Exposure Control statistics configuration */ 41 #define RKISP1_CIF_ISP_MODULE_AEC (1U << 14) 42 /* Wide Dynamic Range */ 43 #define RKISP1_CIF_ISP_MODULE_WDR (1U << 15) 44 /* Denoise Pre-Filter */ 45 #define RKISP1_CIF_ISP_MODULE_DPF (1U << 16) 46 /* Denoise Pre-Filter Strength */ 47 #define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH (1U << 17) 48 49 #define RKISP1_CIF_ISP_CTK_COEFF_MAX 0x100 50 #define RKISP1_CIF_ISP_CTK_OFFSET_MAX 0x800 51 52 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V10 25 53 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V12 81 54 #define RKISP1_CIF_ISP_AE_MEAN_MAX RKISP1_CIF_ISP_AE_MEAN_MAX_V12 55 56 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 16 57 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 32 58 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 59 60 #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS 3 61 #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE 17 62 63 #define RKISP1_CIF_ISP_BDM_MAX_TH 0xff 64 65 /* 66 * Black level compensation 67 */ 68 /* maximum value for horizontal start address */ 69 #define RKISP1_CIF_ISP_BLS_START_H_MAX 0x00000fff 70 /* maximum value for horizontal stop address */ 71 #define RKISP1_CIF_ISP_BLS_STOP_H_MAX 0x00000fff 72 /* maximum value for vertical start address */ 73 #define RKISP1_CIF_ISP_BLS_START_V_MAX 0x00000fff 74 /* maximum value for vertical stop address */ 75 #define RKISP1_CIF_ISP_BLS_STOP_V_MAX 0x00000fff 76 /* maximum is 2^18 = 262144*/ 77 #define RKISP1_CIF_ISP_BLS_SAMPLES_MAX 0x00000012 78 /* maximum value for fixed black level */ 79 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX 0x00000fff 80 /* minimum value for fixed black level */ 81 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN 0xfffff000 82 /* 13 bit range (signed)*/ 83 #define RKISP1_CIF_ISP_BLS_FIX_MASK 0x00001fff 84 85 /* 86 * Automatic white balance measurements 87 */ 88 #define RKISP1_CIF_ISP_AWB_MAX_GRID 1 89 #define RKISP1_CIF_ISP_AWB_MAX_FRAMES 7 90 91 /* 92 * Gamma out 93 */ 94 /* Maximum number of color samples supported */ 95 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 17 96 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 34 97 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 98 99 /* 100 * Lens shade correction 101 */ 102 #define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE 8 103 104 /* 105 * The following matches the tuning process, 106 * not the max capabilities of the chip. 107 */ 108 #define RKISP1_CIF_ISP_LSC_SAMPLES_MAX 17 109 110 /* 111 * Histogram calculation 112 */ 113 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25 114 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81 115 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 116 117 /* 118 * Defect Pixel Cluster Correction 119 */ 120 #define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3 121 122 #define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2) 123 124 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0) 125 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1) 126 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2) 127 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3) 128 129 /* 0-2 for sets 1-3 */ 130 #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0) 131 #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3) 132 133 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0) 134 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1) 135 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2) 136 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3) 137 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4) 138 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8) 139 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9) 140 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10) 141 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11) 142 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12) 143 144 #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0) 145 #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8) 146 #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0) 147 #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8) 148 #define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0) 149 #define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8) 150 #define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0) 151 #define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8) 152 #define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0) 153 #define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8) 154 155 #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4)) 156 #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2)) 157 158 #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4)) 159 #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2)) 160 161 /* 162 * Denoising pre filter 163 */ 164 #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17 165 #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6 166 167 /* 168 * Compand 169 */ 170 #define RKISP1_CIF_ISP_COMPAND_NUM_POINTS 64 171 172 /* 173 * Wide Dynamic Range 174 */ 175 #define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV 32 176 #define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF (RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1) 177 #define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS 4 178 179 /* 180 * Measurement types 181 */ 182 #define RKISP1_CIF_ISP_STAT_AWB (1U << 0) 183 #define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1) 184 #define RKISP1_CIF_ISP_STAT_AFM (1U << 2) 185 #define RKISP1_CIF_ISP_STAT_HIST (1U << 3) 186 187 /** 188 * enum rkisp1_cif_isp_version - ISP variants 189 * 190 * @RKISP1_V10: Used at least in RK3288 and RK3399. 191 * @RKISP1_V11: Declared in the original vendor code, but not used. Same number 192 * of entries in grids and histogram as v10. 193 * @RKISP1_V12: Used at least in RK3326 and PX30. 194 * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and 195 * histogram as v12. 196 * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids 197 * and histogram as v10. 198 */ 199 enum rkisp1_cif_isp_version { 200 RKISP1_V10 = 10, 201 RKISP1_V11, 202 RKISP1_V12, 203 RKISP1_V13, 204 RKISP1_V_IMX8MP, 205 }; 206 207 enum rkisp1_cif_isp_histogram_mode { 208 RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE, 209 RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED, 210 RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM, 211 RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM, 212 RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM, 213 RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM 214 }; 215 216 enum rkisp1_cif_isp_awb_mode_type { 217 RKISP1_CIF_ISP_AWB_MODE_MANUAL, 218 RKISP1_CIF_ISP_AWB_MODE_RGB, 219 RKISP1_CIF_ISP_AWB_MODE_YCBCR 220 }; 221 222 enum rkisp1_cif_isp_flt_mode { 223 RKISP1_CIF_ISP_FLT_STATIC_MODE, 224 RKISP1_CIF_ISP_FLT_DYNAMIC_MODE 225 }; 226 227 /** 228 * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes 229 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement 230 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame 231 */ 232 enum rkisp1_cif_isp_exp_ctrl_autostop { 233 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0, 234 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1, 235 }; 236 237 /** 238 * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode 239 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B 240 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256) 241 */ 242 enum rkisp1_cif_isp_exp_meas_mode { 243 RKISP1_CIF_ISP_EXP_MEASURING_MODE_0, 244 RKISP1_CIF_ISP_EXP_MEASURING_MODE_1, 245 }; 246 247 /*---------- PART1: Input Parameters ------------*/ 248 249 /** 250 * struct rkisp1_cif_isp_window - measurement window. 251 * 252 * Measurements are calculated per window inside the frame. 253 * This struct represents a window for a measurement. 254 * 255 * @h_offs: the horizontal offset of the window from the left of the frame in pixels. 256 * @v_offs: the vertical offset of the window from the top of the frame in pixels. 257 * @h_size: the horizontal size of the window in pixels 258 * @v_size: the vertical size of the window in pixels. 259 */ 260 struct rkisp1_cif_isp_window { 261 __u16 h_offs; 262 __u16 v_offs; 263 __u16 h_size; 264 __u16 v_size; 265 }; 266 267 /** 268 * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values 269 * 270 * The values will be subtracted from the sensor 271 * values. Therefore a negative value means addition instead of subtraction! 272 * 273 * @r: Fixed (signed!) subtraction value for Bayer pattern R 274 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr 275 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb 276 * @b: Fixed (signed!) subtraction value for Bayer pattern B 277 */ 278 struct rkisp1_cif_isp_bls_fixed_val { 279 __s16 r; 280 __s16 gr; 281 __s16 gb; 282 __s16 b; 283 }; 284 285 /** 286 * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction 287 * 288 * @enable_auto: Automatic mode activated means that the measured values 289 * are subtracted. Otherwise the fixed subtraction 290 * values will be subtracted. 291 * @en_windows: enabled window 292 * @bls_window1: Measurement window 1 size 293 * @bls_window2: Measurement window 2 size 294 * @bls_samples: Set amount of measured pixels for each Bayer position 295 * (A, B,C and D) to 2^bls_samples. 296 * @fixed_val: Fixed subtraction values 297 */ 298 struct rkisp1_cif_isp_bls_config { 299 __u8 enable_auto; 300 __u8 en_windows; 301 struct rkisp1_cif_isp_window bls_window1; 302 struct rkisp1_cif_isp_window bls_window2; 303 __u8 bls_samples; 304 struct rkisp1_cif_isp_bls_fixed_val fixed_val; 305 }; 306 307 /** 308 * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration 309 * 310 * This structure stores the configuration of one set of methods for the DPCC 311 * algorithm. Multiple methods can be selected in each set (independently for 312 * the Green and Red/Blue components) through the @method field, the result is 313 * the logical AND of all enabled methods. The remaining fields set thresholds 314 * and factors for each method. 315 * 316 * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*) 317 * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*) 318 * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*) 319 * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*) 320 * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*) 321 * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*) 322 */ 323 struct rkisp1_cif_isp_dpcc_methods_config { 324 __u32 method; 325 __u32 line_thresh; 326 __u32 line_mad_fac; 327 __u32 pg_fac; 328 __u32 rnd_thresh; 329 __u32 rg_fac; 330 }; 331 332 /** 333 * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC 334 * 335 * Configuration used by Defect Pixel Cluster Correction. Three sets of methods 336 * can be configured and selected through the @set_use field. The result is the 337 * logical OR of all enabled sets. 338 * 339 * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*) 340 * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*) 341 * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*) 342 * @methods: Methods sets configuration 343 * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*) 344 * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*) 345 */ 346 struct rkisp1_cif_isp_dpcc_config { 347 __u32 mode; 348 __u32 output_mode; 349 __u32 set_use; 350 struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX]; 351 __u32 ro_limits; 352 __u32 rnd_offs; 353 }; 354 355 /** 356 * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output). 357 * 358 * The reset values define a linear curve which has the same effect as bypass. Reset values are: 359 * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff 360 * 361 * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit. 362 */ 363 struct rkisp1_cif_isp_gamma_corr_curve { 364 __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE]; 365 }; 366 367 /** 368 * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments 369 * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the 370 * higher samples (9-16). The reset values for both fields is 0x44444444. This means 371 * that each sample is 4 units away from the previous one on the x-axis. 372 * 373 * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused. 374 * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused 375 * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused. 376 * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused 377 */ 378 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts { 379 __u32 gamma_dx0; 380 __u32 gamma_dx1; 381 }; 382 383 /** 384 * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma 385 * 386 * @curve_r: gamma curve point definition axis for red 387 * @curve_g: gamma curve point definition axis for green 388 * @curve_b: gamma curve point definition axis for blue 389 * @xa_pnts: x axis increments 390 */ 391 struct rkisp1_cif_isp_sdg_config { 392 struct rkisp1_cif_isp_gamma_corr_curve curve_r; 393 struct rkisp1_cif_isp_gamma_corr_curve curve_g; 394 struct rkisp1_cif_isp_gamma_corr_curve curve_b; 395 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts; 396 }; 397 398 /** 399 * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction 400 * 401 * @r_data_tbl: sample table red 402 * @gr_data_tbl: sample table green (red) 403 * @gb_data_tbl: sample table green (blue) 404 * @b_data_tbl: sample table blue 405 * @x_grad_tbl: gradient table x 406 * @y_grad_tbl: gradient table y 407 * @x_size_tbl: size table x 408 * @y_size_tbl: size table y 409 * @config_width: not used at the moment 410 * @config_height: not used at the moment 411 */ 412 struct rkisp1_cif_isp_lsc_config { 413 __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; 414 __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; 415 __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; 416 __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; 417 418 __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; 419 __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; 420 421 __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; 422 __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; 423 __u16 config_width; 424 __u16 config_height; 425 }; 426 427 /** 428 * struct rkisp1_cif_isp_ie_config - Configuration used by image effects 429 * 430 * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA, 431 * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS, 432 * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE 433 * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red). 434 * bits 8:15 - Threshold value of the RGB colors for the color selection effect. 435 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1 436 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2 437 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1 438 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2 439 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3 440 * @eff_tint: Chrominance increment values of tint (used for sepia effect) 441 */ 442 struct rkisp1_cif_isp_ie_config { 443 __u16 effect; 444 __u16 color_sel; 445 __u16 eff_mat_1; 446 __u16 eff_mat_2; 447 __u16 eff_mat_3; 448 __u16 eff_mat_4; 449 __u16 eff_mat_5; 450 __u16 eff_tint; 451 }; 452 453 /** 454 * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing 455 * 456 * @c_out_range: Chrominance pixel clipping range at output. 457 * (0 for limit, 1 for full) 458 * @y_in_range: Luminance pixel clipping range at output. 459 * @y_out_range: Luminance pixel clipping range at output. 460 * @contrast: 00~ff, 0.0~1.992 461 * @brightness: 80~7F, -128~+127 462 * @sat: saturation, 00~FF, 0.0~1.992 463 * @hue: 80~7F, -90~+87.188 464 */ 465 struct rkisp1_cif_isp_cproc_config { 466 __u8 c_out_range; 467 __u8 y_in_range; 468 __u8 y_out_range; 469 __u8 contrast; 470 __u8 brightness; 471 __u8 sat; 472 __u8 hue; 473 }; 474 475 /** 476 * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics 477 * 478 * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type. 479 * @awb_wnd: white balance measurement window (in pixels) 480 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0 481 * to disable this feature 482 * @min_y: only pixels values > min_y contribute to awb measurement 483 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr, 484 * smaller than threshold for awb measurements 485 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr 486 * each greater than threshold value for awb measurements 487 * @frames: number of frames - 1 used for mean value calculation 488 * (ucFrames=0 means 1 Frame) 489 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB 490 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB 491 * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.) 492 */ 493 struct rkisp1_cif_isp_awb_meas_config { 494 /* 495 * Note: currently the h and v offsets are mapped to grid offsets 496 */ 497 struct rkisp1_cif_isp_window awb_wnd; 498 __u32 awb_mode; 499 __u8 max_y; 500 __u8 min_y; 501 __u8 max_csum; 502 __u8 min_c; 503 __u8 frames; 504 __u8 awb_ref_cr; 505 __u8 awb_ref_cb; 506 __u8 enable_ymax_cmp; 507 }; 508 509 /** 510 * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain 511 * 512 * All fields in this struct are 10 bit, where: 513 * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part. 514 * 515 * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8 516 * 517 * @gain_red: gain value for red component. 518 * @gain_green_r: gain value for green component in red line. 519 * @gain_blue: gain value for blue component. 520 * @gain_green_b: gain value for green component in blue line. 521 */ 522 struct rkisp1_cif_isp_awb_gain_config { 523 __u16 gain_red; 524 __u16 gain_green_r; 525 __u16 gain_blue; 526 __u16 gain_green_b; 527 }; 528 529 /** 530 * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering 531 * 532 * All 4 threshold fields (thresh_*) are 10 bits. 533 * All 6 factor fields (fac_*) are 6 bits. 534 * 535 * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode) 536 * @grn_stage1: Green filter stage 1 select (range 0x0...0x8) 537 * @chr_h_mode: Chroma filter horizontal mode 538 * @chr_v_mode: Chroma filter vertical mode 539 * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th) 540 * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th) 541 * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th) 542 * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th) 543 * @lum_weight: Parameters for luminance weight function. 544 * @fac_sh1: filter factor for sharp1 level 545 * @fac_sh0: filter factor for sharp0 level 546 * @fac_mid: filter factor for mid level and for static filter mode 547 * @fac_bl0: filter factor for blur 0 level 548 * @fac_bl1: filter factor for blur 1 level (max blur) 549 */ 550 struct rkisp1_cif_isp_flt_config { 551 __u32 mode; 552 __u8 grn_stage1; 553 __u8 chr_h_mode; 554 __u8 chr_v_mode; 555 __u32 thresh_bl0; 556 __u32 thresh_bl1; 557 __u32 thresh_sh0; 558 __u32 thresh_sh1; 559 __u32 lum_weight; 560 __u32 fac_sh1; 561 __u32 fac_sh0; 562 __u32 fac_mid; 563 __u32 fac_bl0; 564 __u32 fac_bl1; 565 }; 566 567 /** 568 * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic 569 * 570 * @demosaic_th: threshold for bayer demosaicing texture detection 571 */ 572 struct rkisp1_cif_isp_bdm_config { 573 __u8 demosaic_th; 574 }; 575 576 /** 577 * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction 578 * 579 * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer 580 * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is 581 * represented by 0x000 and a coefficient value of 1 as 0x080. 582 * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix 583 */ 584 struct rkisp1_cif_isp_ctk_config { 585 __u16 coeff[3][3]; 586 __u16 ct_offset[3]; 587 }; 588 589 enum rkisp1_cif_isp_goc_mode { 590 RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC, 591 RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT 592 }; 593 594 /** 595 * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction 596 * 597 * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode) 598 * @gamma_y: gamma out curve y-axis for all color components 599 * 600 * The number of entries of @gamma_y depends on the hardware revision 601 * as is reported by the hw_revision field of the struct media_device_info 602 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. 603 * 604 * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has 605 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries. 606 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two. 607 */ 608 struct rkisp1_cif_isp_goc_config { 609 __u32 mode; 610 __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES]; 611 }; 612 613 /** 614 * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics 615 * 616 * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode) 617 * @histogram_predivider: process every stepsize pixel, all other pixels are 618 * skipped 619 * @meas_window: coordinates of the measure window 620 * @hist_weight: weighting factor for sub-windows 621 * 622 * The number of entries of @hist_weight depends on the hardware revision 623 * as is reported by the hw_revision field of the struct media_device_info 624 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. 625 * 626 * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has 627 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries. 628 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the 629 * two. 630 */ 631 struct rkisp1_cif_isp_hst_config { 632 __u32 mode; 633 __u8 histogram_predivider; 634 struct rkisp1_cif_isp_window meas_window; 635 __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE]; 636 }; 637 638 /** 639 * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics 640 * 641 * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode) 642 * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop) 643 * @meas_window: coordinates of the measure window 644 */ 645 struct rkisp1_cif_isp_aec_config { 646 __u32 mode; 647 __u32 autostop; 648 struct rkisp1_cif_isp_window meas_window; 649 }; 650 651 /** 652 * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics 653 * 654 * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS 655 * @afm_win: coordinates of the meas window 656 * @thres: threshold used for minimizing the influence of noise 657 * @var_shift: the number of bits for the shift operation at the end of the 658 * calculation chain. 659 */ 660 struct rkisp1_cif_isp_afc_config { 661 __u8 num_afm_win; 662 struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS]; 663 __u32 thres; 664 __u32 var_shift; 665 }; 666 667 /** 668 * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage 669 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage 670 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from 671 * registers DPF_NF_GAIN_R, ... 672 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module 673 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the 674 * gains from LSC module 675 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module 676 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module 677 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation) 678 */ 679 enum rkisp1_cif_isp_dpf_gain_usage { 680 RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED, 681 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS, 682 RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS, 683 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS, 684 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS, 685 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS, 686 RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX 687 }; 688 689 /** 690 * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes 691 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9 692 * (means 7x5 active pixel) 693 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9 694 * (means 5x5 active pixel) 695 */ 696 enum rkisp1_cif_isp_dpf_rb_filtersize { 697 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9, 698 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9, 699 }; 700 701 /** 702 * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode 703 * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling 704 * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling 705 */ 706 enum rkisp1_cif_isp_dpf_nll_scale_mode { 707 RKISP1_CIF_ISP_NLL_SCALE_LINEAR, 708 RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC, 709 }; 710 711 /** 712 * struct rkisp1_cif_isp_dpf_nll - Noise level lookup 713 * 714 * @coeff: Noise level Lookup coefficient 715 * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode) 716 */ 717 struct rkisp1_cif_isp_dpf_nll { 718 __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS]; 719 __u32 scale_mode; 720 }; 721 722 /** 723 * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config 724 * 725 * @fltsize: The filter size for the red and blue pixels 726 * (from enum rkisp1_cif_isp_dpf_rb_filtersize) 727 * @spatial_coeff: Spatial weights 728 * @r_enable: enable filter processing for red pixels 729 * @b_enable: enable filter processing for blue pixels 730 */ 731 struct rkisp1_cif_isp_dpf_rb_flt { 732 __u32 fltsize; 733 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS]; 734 __u8 r_enable; 735 __u8 b_enable; 736 }; 737 738 /** 739 * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration 740 * 741 * @spatial_coeff: Spatial weights 742 * @gr_enable: enable filter processing for green pixels in green/red lines 743 * @gb_enable: enable filter processing for green pixels in green/blue lines 744 */ 745 struct rkisp1_cif_isp_dpf_g_flt { 746 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS]; 747 __u8 gr_enable; 748 __u8 gb_enable; 749 }; 750 751 /** 752 * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration 753 * 754 * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage) 755 * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels 756 * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels 757 * @nf_gr_gain: Noise function Gain that replaces the AWB gain 758 * for green pixels in a red line 759 * @nf_gb_gain: Noise function Gain that replaces the AWB gain 760 * for green pixels in a blue line 761 */ 762 struct rkisp1_cif_isp_dpf_gain { 763 __u32 mode; 764 __u16 nf_r_gain; 765 __u16 nf_b_gain; 766 __u16 nf_gr_gain; 767 __u16 nf_gb_gain; 768 }; 769 770 /** 771 * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter 772 * 773 * @gain: noise function gain 774 * @g_flt: green filter config 775 * @rb_flt: red blue filter config 776 * @nll: noise level lookup 777 */ 778 struct rkisp1_cif_isp_dpf_config { 779 struct rkisp1_cif_isp_dpf_gain gain; 780 struct rkisp1_cif_isp_dpf_g_flt g_flt; 781 struct rkisp1_cif_isp_dpf_rb_flt rb_flt; 782 struct rkisp1_cif_isp_dpf_nll nll; 783 }; 784 785 /** 786 * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter 787 * 788 * @r: filter strength of the RED filter 789 * @g: filter strength of the GREEN filter 790 * @b: filter strength of the BLUE filter 791 */ 792 struct rkisp1_cif_isp_dpf_strength_config { 793 __u8 r; 794 __u8 g; 795 __u8 b; 796 }; 797 798 /** 799 * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1 800 * 801 * @dpcc_config: Defect Pixel Cluster Correction config 802 * @bls_config: Black Level Subtraction config 803 * @sdg_config: sensor degamma config 804 * @lsc_config: Lens Shade config 805 * @awb_gain_config: Auto White balance gain config 806 * @flt_config: filter config 807 * @bdm_config: demosaic config 808 * @ctk_config: cross talk config 809 * @goc_config: gamma out config 810 * @bls_config: black level subtraction config 811 * @dpf_config: De-noising pre-filter config 812 * @dpf_strength_config: dpf strength config 813 * @cproc_config: color process config 814 * @ie_config: image effects config 815 */ 816 struct rkisp1_cif_isp_isp_other_cfg { 817 struct rkisp1_cif_isp_dpcc_config dpcc_config; 818 struct rkisp1_cif_isp_bls_config bls_config; 819 struct rkisp1_cif_isp_sdg_config sdg_config; 820 struct rkisp1_cif_isp_lsc_config lsc_config; 821 struct rkisp1_cif_isp_awb_gain_config awb_gain_config; 822 struct rkisp1_cif_isp_flt_config flt_config; 823 struct rkisp1_cif_isp_bdm_config bdm_config; 824 struct rkisp1_cif_isp_ctk_config ctk_config; 825 struct rkisp1_cif_isp_goc_config goc_config; 826 struct rkisp1_cif_isp_dpf_config dpf_config; 827 struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config; 828 struct rkisp1_cif_isp_cproc_config cproc_config; 829 struct rkisp1_cif_isp_ie_config ie_config; 830 }; 831 832 /** 833 * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters 834 * 835 * @awb_meas_config: auto white balance config 836 * @hst_config: histogram config 837 * @aec_config: auto exposure config 838 * @afc_config: auto focus config 839 */ 840 struct rkisp1_cif_isp_isp_meas_cfg { 841 struct rkisp1_cif_isp_awb_meas_config awb_meas_config; 842 struct rkisp1_cif_isp_hst_config hst_config; 843 struct rkisp1_cif_isp_aec_config aec_config; 844 struct rkisp1_cif_isp_afc_config afc_config; 845 }; 846 847 /** 848 * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data 849 * 850 * @module_en_update: mask the enable bits of which module should be updated 851 * @module_ens: mask the enable value of each module, only update the module 852 * which correspond bit was set in module_en_update 853 * @module_cfg_update: mask the config bits of which module should be updated 854 * @meas: measurement config 855 * @others: other config 856 */ 857 struct rkisp1_params_cfg { 858 __u32 module_en_update; 859 __u32 module_ens; 860 __u32 module_cfg_update; 861 862 struct rkisp1_cif_isp_isp_meas_cfg meas; 863 struct rkisp1_cif_isp_isp_other_cfg others; 864 }; 865 866 /** 867 * struct rkisp1_cif_isp_compand_bls_config - Rockchip ISP1 Companding parameters (BLS) 868 * @r: Fixed subtraction value for Bayer pattern R 869 * @gr: Fixed subtraction value for Bayer pattern Gr 870 * @gb: Fixed subtraction value for Bayer pattern Gb 871 * @b: Fixed subtraction value for Bayer pattern B 872 * 873 * The values will be subtracted from the sensor values. Note that unlike the 874 * dedicated BLS block, the BLS values in the compander are 20-bit unsigned. 875 */ 876 struct rkisp1_cif_isp_compand_bls_config { 877 __u32 r; 878 __u32 gr; 879 __u32 gb; 880 __u32 b; 881 }; 882 883 /** 884 * struct rkisp1_cif_isp_compand_curve_config - Rockchip ISP1 Companding 885 * parameters (expand and compression curves) 886 * @px: Compand curve x-values. Each value stores the distance from the 887 * previous x-value, expressed as log2 of the distance on 5 bits. 888 * @x: Compand curve x-values. The functionality of these parameters are 889 * unknown due to do a lack of hardware documentation, but these are left 890 * here for future compatibility purposes. 891 * @y: Compand curve y-values 892 */ 893 struct rkisp1_cif_isp_compand_curve_config { 894 __u8 px[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; 895 __u32 x[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; 896 __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; 897 }; 898 899 /** 900 * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR. 901 * 902 * @dY: the dYn increments for horizontal (input) axis of the tone curve. 903 * each 3-bit dY value represents an increment of 2**(value+3). 904 * dY[0] bits 0:2 is increment dY1, bit 3 unused 905 * dY[0] bits 4:6 is increment dY2, bit 7 unused 906 * ... 907 * dY[0] bits 28:30 is increment dY8, bit 31 unused 908 * ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused. 909 * @ym: the Ym values for the vertical (output) axis of the tone curve. 910 * each value is 13 bit. 911 */ 912 struct rkisp1_cif_isp_wdr_tone_curve { 913 __u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS]; 914 __u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF]; 915 }; 916 917 /** 918 * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR. 919 * 920 * Use illumination reference value as described below, instead of only the 921 * luminance (Y) value for tone mapping and gain calculations: 922 * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8 923 * 924 * @rgb_factor: defines how much influence the RGBmax approach has in 925 * comparison to Y (valid values are 0..8). 926 * @use_y9_8: use Y*9/8 for maximum value calculation along with the 927 * default of R, G, B for noise reduction. 928 * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction. 929 * @disable_transient: disable transient calculation between Y and RGBY_max. 930 */ 931 struct rkisp1_cif_isp_wdr_iref_config { 932 __u8 rgb_factor; 933 __u8 use_y9_8; 934 __u8 use_rgb7_8; 935 __u8 disable_transient; 936 }; 937 938 /** 939 * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range. 940 * 941 * @tone_curve: tone mapping curve. 942 * @iref_config: illumination reference configuration. (when use_iref is true) 943 * @rgb_offset: RGB offset value for RGB operation mode. (12 bits) 944 * @luma_offset: luminance offset value for RGB operation mode. (12 bits) 945 * @dmin_thresh: lower threshold for deltaMin value. (12 bits) 946 * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10) 947 * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace. 948 * @bypass_chroma_mapping: disable chrominance mapping (only valid if 949 * use_rgb_colorspace = 0) 950 * @use_iref: use illumination reference instead of Y for tone mapping 951 * and gain calculations. 952 */ 953 struct rkisp1_cif_isp_wdr_config { 954 struct rkisp1_cif_isp_wdr_tone_curve tone_curve; 955 struct rkisp1_cif_isp_wdr_iref_config iref_config; 956 __u16 rgb_offset; 957 __u16 luma_offset; 958 __u16 dmin_thresh; 959 __u8 dmin_strength; 960 __u8 use_rgb_colorspace; 961 __u8 bypass_chroma_mapping; 962 __u8 use_iref; 963 }; 964 965 /*---------- PART2: Measurement Statistics ------------*/ 966 967 /** 968 * struct rkisp1_cif_isp_awb_meas - AWB measured values 969 * 970 * @cnt: White pixel count, number of "white pixels" found during last 971 * measurement 972 * @mean_y_or_g: Mean value of Y within window and frames, 973 * Green if RGB is selected. 974 * @mean_cb_or_b: Mean value of Cb within window and frames, 975 * Blue if RGB is selected. 976 * @mean_cr_or_r: Mean value of Cr within window and frames, 977 * Red if RGB is selected. 978 */ 979 struct rkisp1_cif_isp_awb_meas { 980 __u32 cnt; 981 __u8 mean_y_or_g; 982 __u8 mean_cb_or_b; 983 __u8 mean_cr_or_r; 984 }; 985 986 /** 987 * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data 988 * 989 * @awb_mean: Mean measured data 990 */ 991 struct rkisp1_cif_isp_awb_stat { 992 struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID]; 993 }; 994 995 /** 996 * struct rkisp1_cif_isp_bls_meas_val - BLS measured values 997 * 998 * @meas_r: Mean measured value for Bayer pattern R 999 * @meas_gr: Mean measured value for Bayer pattern Gr 1000 * @meas_gb: Mean measured value for Bayer pattern Gb 1001 * @meas_b: Mean measured value for Bayer pattern B 1002 */ 1003 struct rkisp1_cif_isp_bls_meas_val { 1004 __u16 meas_r; 1005 __u16 meas_gr; 1006 __u16 meas_gb; 1007 __u16 meas_b; 1008 }; 1009 1010 /** 1011 * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data 1012 * 1013 * @exp_mean: Mean luminance value of block xx 1014 * @bls_val: BLS measured values 1015 * 1016 * The number of entries of @exp_mean depends on the hardware revision 1017 * as is reported by the hw_revision field of the struct media_device_info 1018 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. 1019 * 1020 * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has 1021 * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal 1022 * to the maximum of the two. 1023 * 1024 * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12. 1025 */ 1026 struct rkisp1_cif_isp_ae_stat { 1027 __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX]; 1028 struct rkisp1_cif_isp_bls_meas_val bls_val; 1029 }; 1030 1031 /** 1032 * struct rkisp1_cif_isp_af_meas_val - AF measured values 1033 * 1034 * @sum: sharpness value 1035 * @lum: luminance value 1036 */ 1037 struct rkisp1_cif_isp_af_meas_val { 1038 __u32 sum; 1039 __u32 lum; 1040 }; 1041 1042 /** 1043 * struct rkisp1_cif_isp_af_stat - statistics auto focus data 1044 * 1045 * @window: AF measured value of window x 1046 * 1047 * The module measures the sharpness in 3 windows of selectable size via 1048 * register settings(ISP_AFM_*_A/B/C) 1049 */ 1050 struct rkisp1_cif_isp_af_stat { 1051 struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS]; 1052 }; 1053 1054 /** 1055 * struct rkisp1_cif_isp_hist_stat - statistics histogram data 1056 * 1057 * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point 1058 * type. Bits 0-4 are the fractional part and bits 5-19 are the 1059 * integer part. 1060 * 1061 * The window of the measurements area is divided to 5x5 sub-windows for 1062 * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each 1063 * sub-window independently and the final result is a weighted average of the 1064 * histogram measurements on all sub-windows. The window of the measurements 1065 * area and the weight of each sub-window are configurable using 1066 * struct @rkisp1_cif_isp_hst_config. 1067 * 1068 * The histogram contains 16 bins in V10 and 32 bins in V12. 1069 * 1070 * The number of entries of @hist_bins depends on the hardware revision 1071 * as is reported by the hw_revision field of the struct media_device_info 1072 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. 1073 * 1074 * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has 1075 * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is 1076 * equal to the maximum of the two. 1077 */ 1078 struct rkisp1_cif_isp_hist_stat { 1079 __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX]; 1080 }; 1081 1082 /** 1083 * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data 1084 * 1085 * @awb: statistics data for automatic white balance 1086 * @ae: statistics data for auto exposure 1087 * @af: statistics data for auto focus 1088 * @hist: statistics histogram data 1089 */ 1090 struct rkisp1_cif_isp_stat { 1091 struct rkisp1_cif_isp_awb_stat awb; 1092 struct rkisp1_cif_isp_ae_stat ae; 1093 struct rkisp1_cif_isp_af_stat af; 1094 struct rkisp1_cif_isp_hist_stat hist; 1095 }; 1096 1097 /** 1098 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data 1099 * 1100 * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions) 1101 * @frame_id: frame ID for sync 1102 * @params: statistics data 1103 */ 1104 struct rkisp1_stat_buffer { 1105 __u32 meas_type; 1106 __u32 frame_id; 1107 struct rkisp1_cif_isp_stat params; 1108 }; 1109 1110 /*---------- PART3: Extensible Configuration Parameters ------------*/ 1111 1112 /** 1113 * enum rkisp1_ext_params_block_type - RkISP1 extensible params block type 1114 * 1115 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtraction 1116 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correction 1117 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gamma 1118 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gains 1119 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filtering 1120 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaic 1121 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correction 1122 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correction 1123 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filter 1124 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strength 1125 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processing 1126 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effects 1127 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correction 1128 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statistics 1129 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statistics 1130 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statistics 1131 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statistics 1132 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block 1133 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve 1134 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve 1135 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range 1136 */ 1137 enum rkisp1_ext_params_block_type { 1138 RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS, 1139 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC, 1140 RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG, 1141 RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN, 1142 RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT, 1143 RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM, 1144 RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK, 1145 RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC, 1146 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF, 1147 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH, 1148 RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC, 1149 RKISP1_EXT_PARAMS_BLOCK_TYPE_IE, 1150 RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC, 1151 RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS, 1152 RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS, 1153 RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS, 1154 RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS, 1155 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS, 1156 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND, 1157 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS, 1158 RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR, 1159 }; 1160 1161 #define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0) 1162 #define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1) 1163 1164 /* A bitmask of parameters blocks supported on the current hardware. */ 1165 #define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x01) 1166 1167 /** 1168 * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block 1169 * header 1170 * 1171 * This structure represents the common part of all the ISP configuration 1172 * blocks. Each parameters block shall embed an instance of this structure type 1173 * as its first member, followed by the block-specific configuration data. The 1174 * driver inspects this common header to discern the block type and its size and 1175 * properly handle the block content by casting it to the correct block-specific 1176 * type. 1177 * 1178 * The @type field is one of the values enumerated by 1179 * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be 1180 * interpreted by the driver. The @size field specifies the size of the 1181 * parameters block and is used by the driver for validation purposes. 1182 * 1183 * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*. 1184 * 1185 * When userspace wants to configure and enable an ISP block it shall fully 1186 * populate the block configuration and set the 1187 * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field. 1188 * 1189 * When userspace simply wants to disable an ISP block the 1190 * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The 1191 * driver ignores the rest of the block configuration structure in this case. 1192 * 1193 * If a new configuration of an ISP block has to be applied userspace shall 1194 * fully populate the ISP block configuration and omit setting the 1195 * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits 1196 * in the @flags field. 1197 * 1198 * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and 1199 * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed 1200 * and not accepted by the driver. 1201 * 1202 * Userspace is responsible for correctly populating the parameters block header 1203 * fields (@type, @flags and @size) and the block-specific parameters. 1204 * 1205 * For example: 1206 * 1207 * .. code-block:: c 1208 * 1209 * void populate_bls(struct rkisp1_ext_params_block_header *block) { 1210 * struct rkisp1_ext_params_bls_config *bls = 1211 * (struct rkisp1_ext_params_bls_config *)block; 1212 * 1213 * bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS; 1214 * bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; 1215 * bls->header.size = sizeof(*bls); 1216 * 1217 * bls->config.enable_auto = 0; 1218 * bls->config.fixed_val.r = blackLevelRed_; 1219 * bls->config.fixed_val.gr = blackLevelGreenR_; 1220 * bls->config.fixed_val.gb = blackLevelGreenB_; 1221 * bls->config.fixed_val.b = blackLevelBlue_; 1222 * } 1223 * 1224 * @type: The parameters block type, see 1225 * :c:type:`rkisp1_ext_params_block_type` 1226 * @flags: A bitmask of block flags 1227 * @size: Size (in bytes) of the parameters block, including this header 1228 */ 1229 struct rkisp1_ext_params_block_header { 1230 __u16 type; 1231 __u16 flags; 1232 __u32 size; 1233 }; 1234 1235 /** 1236 * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config 1237 * 1238 * RkISP1 extensible parameters Black Level Subtraction configuration block. 1239 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS`. 1240 * 1241 * @header: The RkISP1 extensible parameters header, see 1242 * :c:type:`rkisp1_ext_params_block_header` 1243 * @config: Black Level Subtraction configuration, see 1244 * :c:type:`rkisp1_cif_isp_bls_config` 1245 */ 1246 struct rkisp1_ext_params_bls_config { 1247 struct rkisp1_ext_params_block_header header; 1248 struct rkisp1_cif_isp_bls_config config; 1249 } __attribute__((aligned(8))); 1250 1251 /** 1252 * struct rkisp1_ext_params_dpcc_config - RkISP1 extensible params DPCC config 1253 * 1254 * RkISP1 extensible parameters Defective Pixel Cluster Correction configuration 1255 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC`. 1256 * 1257 * @header: The RkISP1 extensible parameters header, see 1258 * :c:type:`rkisp1_ext_params_block_header` 1259 * @config: Defective Pixel Cluster Correction configuration, see 1260 * :c:type:`rkisp1_cif_isp_dpcc_config` 1261 */ 1262 struct rkisp1_ext_params_dpcc_config { 1263 struct rkisp1_ext_params_block_header header; 1264 struct rkisp1_cif_isp_dpcc_config config; 1265 } __attribute__((aligned(8))); 1266 1267 /** 1268 * struct rkisp1_ext_params_sdg_config - RkISP1 extensible params SDG config 1269 * 1270 * RkISP1 extensible parameters Sensor Degamma configuration block. Identified 1271 * by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG`. 1272 * 1273 * @header: The RkISP1 extensible parameters header, see 1274 * :c:type:`rkisp1_ext_params_block_header` 1275 * @config: Sensor Degamma configuration, see 1276 * :c:type:`rkisp1_cif_isp_sdg_config` 1277 */ 1278 struct rkisp1_ext_params_sdg_config { 1279 struct rkisp1_ext_params_block_header header; 1280 struct rkisp1_cif_isp_sdg_config config; 1281 } __attribute__((aligned(8))); 1282 1283 /** 1284 * struct rkisp1_ext_params_lsc_config - RkISP1 extensible params LSC config 1285 * 1286 * RkISP1 extensible parameters Lens Shading Correction configuration block. 1287 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC`. 1288 * 1289 * @header: The RkISP1 extensible parameters header, see 1290 * :c:type:`rkisp1_ext_params_block_header` 1291 * @config: Lens Shading Correction configuration, see 1292 * :c:type:`rkisp1_cif_isp_lsc_config` 1293 */ 1294 struct rkisp1_ext_params_lsc_config { 1295 struct rkisp1_ext_params_block_header header; 1296 struct rkisp1_cif_isp_lsc_config config; 1297 } __attribute__((aligned(8))); 1298 1299 /** 1300 * struct rkisp1_ext_params_awb_gain_config - RkISP1 extensible params AWB 1301 * gain config 1302 * 1303 * RkISP1 extensible parameters Auto-White Balance Gains configuration block. 1304 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN`. 1305 * 1306 * @header: The RkISP1 extensible parameters header, see 1307 * :c:type:`rkisp1_ext_params_block_header` 1308 * @config: Auto-White Balance Gains configuration, see 1309 * :c:type:`rkisp1_cif_isp_awb_gain_config` 1310 */ 1311 struct rkisp1_ext_params_awb_gain_config { 1312 struct rkisp1_ext_params_block_header header; 1313 struct rkisp1_cif_isp_awb_gain_config config; 1314 } __attribute__((aligned(8))); 1315 1316 /** 1317 * struct rkisp1_ext_params_flt_config - RkISP1 extensible params FLT config 1318 * 1319 * RkISP1 extensible parameters Filter configuration block. Identified by 1320 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT`. 1321 * 1322 * @header: The RkISP1 extensible parameters header, see 1323 * :c:type:`rkisp1_ext_params_block_header` 1324 * @config: Filter configuration, see :c:type:`rkisp1_cif_isp_flt_config` 1325 */ 1326 struct rkisp1_ext_params_flt_config { 1327 struct rkisp1_ext_params_block_header header; 1328 struct rkisp1_cif_isp_flt_config config; 1329 } __attribute__((aligned(8))); 1330 1331 /** 1332 * struct rkisp1_ext_params_bdm_config - RkISP1 extensible params BDM config 1333 * 1334 * RkISP1 extensible parameters Demosaicing configuration block. Identified by 1335 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM`. 1336 * 1337 * @header: The RkISP1 extensible parameters header, see 1338 * :c:type:`rkisp1_ext_params_block_header` 1339 * @config: Demosaicing configuration, see :c:type:`rkisp1_cif_isp_bdm_config` 1340 */ 1341 struct rkisp1_ext_params_bdm_config { 1342 struct rkisp1_ext_params_block_header header; 1343 struct rkisp1_cif_isp_bdm_config config; 1344 } __attribute__((aligned(8))); 1345 1346 /** 1347 * struct rkisp1_ext_params_ctk_config - RkISP1 extensible params CTK config 1348 * 1349 * RkISP1 extensible parameters Cross-Talk configuration block. Identified by 1350 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK`. 1351 * 1352 * @header: The RkISP1 extensible parameters header, see 1353 * :c:type:`rkisp1_ext_params_block_header` 1354 * @config: Cross-Talk configuration, see :c:type:`rkisp1_cif_isp_ctk_config` 1355 */ 1356 struct rkisp1_ext_params_ctk_config { 1357 struct rkisp1_ext_params_block_header header; 1358 struct rkisp1_cif_isp_ctk_config config; 1359 } __attribute__((aligned(8))); 1360 1361 /** 1362 * struct rkisp1_ext_params_goc_config - RkISP1 extensible params GOC config 1363 * 1364 * RkISP1 extensible parameters Gamma-Out configuration block. Identified by 1365 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC`. 1366 * 1367 * @header: The RkISP1 extensible parameters header, see 1368 * :c:type:`rkisp1_ext_params_block_header` 1369 * @config: Gamma-Out configuration, see :c:type:`rkisp1_cif_isp_goc_config` 1370 */ 1371 struct rkisp1_ext_params_goc_config { 1372 struct rkisp1_ext_params_block_header header; 1373 struct rkisp1_cif_isp_goc_config config; 1374 } __attribute__((aligned(8))); 1375 1376 /** 1377 * struct rkisp1_ext_params_dpf_config - RkISP1 extensible params DPF config 1378 * 1379 * RkISP1 extensible parameters De-noise Pre-Filter configuration block. 1380 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF`. 1381 * 1382 * @header: The RkISP1 extensible parameters header, see 1383 * :c:type:`rkisp1_ext_params_block_header` 1384 * @config: De-noise Pre-Filter configuration, see 1385 * :c:type:`rkisp1_cif_isp_dpf_config` 1386 */ 1387 struct rkisp1_ext_params_dpf_config { 1388 struct rkisp1_ext_params_block_header header; 1389 struct rkisp1_cif_isp_dpf_config config; 1390 } __attribute__((aligned(8))); 1391 1392 /** 1393 * struct rkisp1_ext_params_dpf_strength_config - RkISP1 extensible params DPF 1394 * strength config 1395 * 1396 * RkISP1 extensible parameters De-noise Pre-Filter strength configuration 1397 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH`. 1398 * 1399 * @header: The RkISP1 extensible parameters header, see 1400 * :c:type:`rkisp1_ext_params_block_header` 1401 * @config: De-noise Pre-Filter strength configuration, see 1402 * :c:type:`rkisp1_cif_isp_dpf_strength_config` 1403 */ 1404 struct rkisp1_ext_params_dpf_strength_config { 1405 struct rkisp1_ext_params_block_header header; 1406 struct rkisp1_cif_isp_dpf_strength_config config; 1407 } __attribute__((aligned(8))); 1408 1409 /** 1410 * struct rkisp1_ext_params_cproc_config - RkISP1 extensible params CPROC config 1411 * 1412 * RkISP1 extensible parameters Color Processing configuration block. 1413 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC`. 1414 * 1415 * @header: The RkISP1 extensible parameters header, see 1416 * :c:type:`rkisp1_ext_params_block_header` 1417 * @config: Color processing configuration, see 1418 * :c:type:`rkisp1_cif_isp_cproc_config` 1419 */ 1420 struct rkisp1_ext_params_cproc_config { 1421 struct rkisp1_ext_params_block_header header; 1422 struct rkisp1_cif_isp_cproc_config config; 1423 } __attribute__((aligned(8))); 1424 1425 /** 1426 * struct rkisp1_ext_params_ie_config - RkISP1 extensible params IE config 1427 * 1428 * RkISP1 extensible parameters Image Effect configuration block. Identified by 1429 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_IE`. 1430 * 1431 * @header: The RkISP1 extensible parameters header, see 1432 * :c:type:`rkisp1_ext_params_block_header` 1433 * @config: Image Effect configuration, see :c:type:`rkisp1_cif_isp_ie_config` 1434 */ 1435 struct rkisp1_ext_params_ie_config { 1436 struct rkisp1_ext_params_block_header header; 1437 struct rkisp1_cif_isp_ie_config config; 1438 } __attribute__((aligned(8))); 1439 1440 /** 1441 * struct rkisp1_ext_params_awb_meas_config - RkISP1 extensible params AWB 1442 * Meas config 1443 * 1444 * RkISP1 extensible parameters Auto-White Balance Measurement configuration 1445 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS`. 1446 * 1447 * @header: The RkISP1 extensible parameters header, see 1448 * :c:type:`rkisp1_ext_params_block_header` 1449 * @config: Auto-White Balance measure configuration, see 1450 * :c:type:`rkisp1_cif_isp_awb_meas_config` 1451 */ 1452 struct rkisp1_ext_params_awb_meas_config { 1453 struct rkisp1_ext_params_block_header header; 1454 struct rkisp1_cif_isp_awb_meas_config config; 1455 } __attribute__((aligned(8))); 1456 1457 /** 1458 * struct rkisp1_ext_params_hst_config - RkISP1 extensible params Histogram config 1459 * 1460 * RkISP1 extensible parameters Histogram statistics configuration block. 1461 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS`. 1462 * 1463 * @header: The RkISP1 extensible parameters header, see 1464 * :c:type:`rkisp1_ext_params_block_header` 1465 * @config: Histogram statistics configuration, see 1466 * :c:type:`rkisp1_cif_isp_hst_config` 1467 */ 1468 struct rkisp1_ext_params_hst_config { 1469 struct rkisp1_ext_params_block_header header; 1470 struct rkisp1_cif_isp_hst_config config; 1471 } __attribute__((aligned(8))); 1472 1473 /** 1474 * struct rkisp1_ext_params_aec_config - RkISP1 extensible params AEC config 1475 * 1476 * RkISP1 extensible parameters Auto-Exposure statistics configuration block. 1477 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS`. 1478 * 1479 * @header: The RkISP1 extensible parameters header, see 1480 * :c:type:`rkisp1_ext_params_block_header` 1481 * @config: Auto-Exposure statistics configuration, see 1482 * :c:type:`rkisp1_cif_isp_aec_config` 1483 */ 1484 struct rkisp1_ext_params_aec_config { 1485 struct rkisp1_ext_params_block_header header; 1486 struct rkisp1_cif_isp_aec_config config; 1487 } __attribute__((aligned(8))); 1488 1489 /** 1490 * struct rkisp1_ext_params_afc_config - RkISP1 extensible params AFC config 1491 * 1492 * RkISP1 extensible parameters Auto-Focus statistics configuration block. 1493 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS`. 1494 * 1495 * @header: The RkISP1 extensible parameters header, see 1496 * :c:type:`rkisp1_ext_params_block_header` 1497 * @config: Auto-Focus statistics configuration, see 1498 * :c:type:`rkisp1_cif_isp_afc_config` 1499 */ 1500 struct rkisp1_ext_params_afc_config { 1501 struct rkisp1_ext_params_block_header header; 1502 struct rkisp1_cif_isp_afc_config config; 1503 } __attribute__((aligned(8))); 1504 1505 /** 1506 * struct rkisp1_ext_params_compand_bls_config - RkISP1 extensible params 1507 * Compand BLS config 1508 * 1509 * RkISP1 extensible parameters Companding configuration block (black level 1510 * subtraction). Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS`. 1511 * 1512 * @header: The RkISP1 extensible parameters header, see 1513 * :c:type:`rkisp1_ext_params_block_header` 1514 * @config: Companding BLS configuration, see 1515 * :c:type:`rkisp1_cif_isp_compand_bls_config` 1516 */ 1517 struct rkisp1_ext_params_compand_bls_config { 1518 struct rkisp1_ext_params_block_header header; 1519 struct rkisp1_cif_isp_compand_bls_config config; 1520 } __attribute__((aligned(8))); 1521 1522 /** 1523 * struct rkisp1_ext_params_compand_curve_config - RkISP1 extensible params 1524 * Compand curve config 1525 * 1526 * RkISP1 extensible parameters Companding configuration block (expand and 1527 * compression curves). Identified by 1528 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND` or 1529 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS`. 1530 * 1531 * @header: The RkISP1 extensible parameters header, see 1532 * :c:type:`rkisp1_ext_params_block_header` 1533 * @config: Companding curve configuration, see 1534 * :c:type:`rkisp1_cif_isp_compand_curve_config` 1535 */ 1536 struct rkisp1_ext_params_compand_curve_config { 1537 struct rkisp1_ext_params_block_header header; 1538 struct rkisp1_cif_isp_compand_curve_config config; 1539 } __attribute__((aligned(8))); 1540 1541 /** 1542 * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params 1543 * Wide dynamic range config 1544 * 1545 * RkISP1 extensible parameters WDR block. 1546 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR` 1547 * 1548 * @header: The RkISP1 extensible parameters header, see 1549 * :c:type:`rkisp1_ext_params_block_header` 1550 * @config: WDR configuration, see 1551 * :c:type:`rkisp1_cif_isp_wdr_config` 1552 */ 1553 struct rkisp1_ext_params_wdr_config { 1554 struct rkisp1_ext_params_block_header header; 1555 struct rkisp1_cif_isp_wdr_config config; 1556 } __attribute__((aligned(8))); 1557 1558 /* 1559 * The rkisp1_ext_params_compand_curve_config structure is counted twice as it 1560 * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types. 1561 */ 1562 #define RKISP1_EXT_PARAMS_MAX_SIZE \ 1563 (sizeof(struct rkisp1_ext_params_bls_config) +\ 1564 sizeof(struct rkisp1_ext_params_dpcc_config) +\ 1565 sizeof(struct rkisp1_ext_params_sdg_config) +\ 1566 sizeof(struct rkisp1_ext_params_lsc_config) +\ 1567 sizeof(struct rkisp1_ext_params_awb_gain_config) +\ 1568 sizeof(struct rkisp1_ext_params_flt_config) +\ 1569 sizeof(struct rkisp1_ext_params_bdm_config) +\ 1570 sizeof(struct rkisp1_ext_params_ctk_config) +\ 1571 sizeof(struct rkisp1_ext_params_goc_config) +\ 1572 sizeof(struct rkisp1_ext_params_dpf_config) +\ 1573 sizeof(struct rkisp1_ext_params_dpf_strength_config) +\ 1574 sizeof(struct rkisp1_ext_params_cproc_config) +\ 1575 sizeof(struct rkisp1_ext_params_ie_config) +\ 1576 sizeof(struct rkisp1_ext_params_awb_meas_config) +\ 1577 sizeof(struct rkisp1_ext_params_hst_config) +\ 1578 sizeof(struct rkisp1_ext_params_aec_config) +\ 1579 sizeof(struct rkisp1_ext_params_afc_config) +\ 1580 sizeof(struct rkisp1_ext_params_compand_bls_config) +\ 1581 sizeof(struct rkisp1_ext_params_compand_curve_config) +\ 1582 sizeof(struct rkisp1_ext_params_compand_curve_config) +\ 1583 sizeof(struct rkisp1_ext_params_wdr_config)) 1584 1585 /** 1586 * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version 1587 * 1588 * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters 1589 */ 1590 enum rksip1_ext_param_buffer_version { 1591 RKISP1_EXT_PARAM_BUFFER_V1 = 1, 1592 }; 1593 1594 /** 1595 * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration 1596 * 1597 * This struct contains the configuration parameters of the RkISP1 ISP 1598 * algorithms, serialized by userspace into a data buffer. Each configuration 1599 * parameter block is represented by a block-specific structure which contains a 1600 * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace 1601 * populates the @data buffer with configuration parameters for the blocks that 1602 * it intends to configure. As a consequence, the data buffer effective size 1603 * changes according to the number of ISP blocks that userspace intends to 1604 * configure and is set by userspace in the @data_size field. 1605 * 1606 * The parameters buffer is versioned by the @version field to allow modifying 1607 * and extending its definition. Userspace shall populate the @version field to 1608 * inform the driver about the version it intends to use. The driver will parse 1609 * and handle the @data buffer according to the data layout specific to the 1610 * indicated version and return an error if the desired version is not 1611 * supported. 1612 * 1613 * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported. 1614 * When a new format version will be added, a mechanism for userspace to query 1615 * the supported format versions will be implemented in the form of a read-only 1616 * V4L2 control. If such control is not available, userspace should assume only 1617 * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver. 1618 * 1619 * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used 1620 * to query the blocks supported by the device. It contains a bitmask where each 1621 * bit represents the availability of the corresponding entry from the 1622 * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values 1623 * of the control represents the blocks supported by the device instance, while 1624 * the maximum value represents the blocks supported by the kernel driver, 1625 * independently of the device instance. 1626 * 1627 * For each ISP block that userspace wants to configure, a block-specific 1628 * structure is appended to the @data buffer, one after the other without gaps 1629 * in between nor overlaps. Userspace shall populate the @data_size field with 1630 * the effective size, in bytes, of the @data buffer. 1631 * 1632 * The expected memory layout of the parameters buffer is:: 1633 * 1634 * +-------------------- struct rkisp1_ext_params_cfg -------------------+ 1635 * | version = RKISP1_EXT_PARAM_BUFFER_V1; | 1636 * | data_size = sizeof(struct rkisp1_ext_params_bls_config) | 1637 * | + sizeof(struct rkisp1_ext_params_dpcc_config); | 1638 * | +------------------------- data ---------------------------------+ | 1639 * | | +------------- struct rkisp1_ext_params_bls_config -----------+ | | 1640 * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | | 1641 * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS; | | | | 1642 * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | | 1643 * | | | | size = sizeof(struct rkisp1_ext_params_bls_config); | | | | 1644 * | | | +---------------------------------------------------------+ | | | 1645 * | | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | | 1646 * | | | | enable_auto = 0; | | | | 1647 * | | | | fixed_val.r = 256; | | | | 1648 * | | | | fixed_val.gr = 256; | | | | 1649 * | | | | fixed_val.gb = 256; | | | | 1650 * | | | | fixed_val.b = 256; | | | | 1651 * | | | +---------------------------------------------------------+ | | | 1652 * | | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | | 1653 * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | | 1654 * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC; | | | | 1655 * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | | 1656 * | | | | size = sizeof(struct rkisp1_ext_params_dpcc_config); | | | | 1657 * | | | +---------------------------------------------------------+ | | | 1658 * | | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | | 1659 * | | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE; | | | | 1660 * | | | | output_mode = | | | | 1661 * | | | | RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | | 1662 * | | | | set_use = ... ; | | | | 1663 * | | | | ... = ... ; | | | | 1664 * | | | +---------------------------------------------------------+ | | | 1665 * | | +-------------------------------------------------------------+ | | 1666 * | +-----------------------------------------------------------------+ | 1667 * +---------------------------------------------------------------------+ 1668 * 1669 * @version: The RkISP1 extensible parameters buffer version, see 1670 * :c:type:`rksip1_ext_param_buffer_version` 1671 * @data_size: The RkISP1 configuration data effective size, excluding this 1672 * header 1673 * @data: The RkISP1 extensible configuration data blocks 1674 */ 1675 struct rkisp1_ext_params_cfg { 1676 __u32 version; 1677 __u32 data_size; 1678 __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE]; 1679 }; 1680 1681 #endif /* _UAPI_RKISP1_CONFIG_H */ 1682