1 /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */ 2 /* 3 * Rockchip isp1 driver 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 #include <linux/v4l2-controls.h> 12 #include "rkisp21-config.h" 13 14 #define CIFISP_MODULE_DPCC (1 << 0) 15 #define CIFISP_MODULE_BLS (1 << 1) 16 #define CIFISP_MODULE_SDG (1 << 2) 17 #define CIFISP_MODULE_HST (1 << 3) 18 #define CIFISP_MODULE_LSC (1 << 4) 19 #define CIFISP_MODULE_AWB_GAIN (1 << 5) 20 #define CIFISP_MODULE_FLT (1 << 6) 21 #define CIFISP_MODULE_BDM (1 << 7) 22 #define CIFISP_MODULE_CTK (1 << 8) 23 #define CIFISP_MODULE_GOC (1 << 9) 24 #define CIFISP_MODULE_CPROC (1 << 10) 25 #define CIFISP_MODULE_AFC (1 << 11) 26 #define CIFISP_MODULE_AWB (1 << 12) 27 #define CIFISP_MODULE_IE (1 << 13) 28 #define CIFISP_MODULE_AEC (1 << 14) 29 #define CIFISP_MODULE_WDR (1 << 15) 30 #define CIFISP_MODULE_DPF (1 << 16) 31 #define CIFISP_MODULE_DPF_STRENGTH (1 << 17) 32 #define CIFISP_MODULE_DEMOSAICLP (1 << 18) 33 #define CIFISP_MODULE_RK_IESHARP (1 << 19) 34 35 #define CIFISP_CTK_COEFF_MAX 0x100 36 #define CIFISP_CTK_OFFSET_MAX 0x800 37 38 #define CIFISP_AE_MEAN_MAX 81 39 #define CIFISP_HIST_BIN_N_MAX 32 40 #define CIFISP_AFM_MAX_WINDOWS 3 41 #define CIFISP_DEGAMMA_CURVE_SIZE 17 42 43 #define CIFISP_BDM_MAX_TH 0xFF 44 45 /* 46 * Black level compensation 47 */ 48 /* maximum value for horizontal start address */ 49 #define CIFISP_BLS_START_H_MAX 0x00000FFF 50 /* maximum value for horizontal stop address */ 51 #define CIFISP_BLS_STOP_H_MAX 0x00000FFF 52 /* maximum value for vertical start address */ 53 #define CIFISP_BLS_START_V_MAX 0x00000FFF 54 /* maximum value for vertical stop address */ 55 #define CIFISP_BLS_STOP_V_MAX 0x00000FFF 56 /* maximum is 2^18 = 262144*/ 57 #define CIFISP_BLS_SAMPLES_MAX 0x00000012 58 /* maximum value for fixed black level */ 59 #define CIFISP_BLS_FIX_SUB_MAX 0x00000FFF 60 /* minimum value for fixed black level */ 61 #define CIFISP_BLS_FIX_SUB_MIN 0xFFFFF000 62 /* 13 bit range (signed)*/ 63 #define CIFISP_BLS_FIX_MASK 0x00001FFF 64 65 /* 66 * Automatic white balance measurments 67 */ 68 #define CIFISP_AWB_MAX_GRID 1 69 #define CIFISP_AWB_MAX_FRAMES 7 70 71 /* 72 * Gamma out 73 */ 74 /* Maximum number of color samples supported */ 75 #define CIFISP_GAMMA_OUT_MAX_SAMPLES 34 76 77 /* 78 * Lens shade correction 79 */ 80 #define CIFISP_LSC_GRAD_TBL_SIZE 8 81 #define CIFISP_LSC_SIZE_TBL_SIZE 8 82 /* 83 * The following matches the tuning process, 84 * not the max capabilities of the chip. 85 * Last value unused. 86 */ 87 #define CIFISP_LSC_DATA_TBL_SIZE 290 88 89 /* 90 * Histogram calculation 91 */ 92 /* Last 3 values unused. */ 93 #define CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 81 94 95 /* 96 * Defect Pixel Cluster Correction 97 */ 98 #define CIFISP_DPCC_METHODS_MAX 3 99 100 /* 101 * Denoising pre filter 102 */ 103 #define CIFISP_DPF_MAX_NLF_COEFFS 17 104 #define CIFISP_DPF_MAX_SPATIAL_COEFFS 6 105 106 /* WDR */ 107 #define CIFISP_WDR_SIZE 48 108 109 /* 110 * Measurement types 111 */ 112 #define CIFISP_STAT_AWB (1 << 0) 113 #define CIFISP_STAT_AUTOEXP (1 << 1) 114 #define CIFISP_STAT_AFM_FIN (1 << 2) 115 #define CIFISP_STAT_HIST (1 << 3) 116 #define CIFISP_STAT_EMB_DATA (1 << 4) 117 118 /* ADD DATA */ 119 #define CIFISP_ADD_DATA_FIFO_SIZE (2048 * 4) 120 121 /* Private v4l2 event */ 122 #define CIFISP_V4L2_EVENT_STREAM_START \ 123 (V4L2_EVENT_PRIVATE_START + 1) 124 #define CIFISP_V4L2_EVENT_STREAM_STOP \ 125 (V4L2_EVENT_PRIVATE_START + 2) 126 127 /* 128 * private control id 129 */ 130 enum cifisp_ctrl_id { 131 CIFISP_CID_EMB_VC = (V4L2_CTRL_CLASS_CAMERA | 0x1001), 132 CIFISP_CID_EMB_DT, 133 CIFISP_CID_LAST 134 }; 135 136 enum cifisp_histogram_mode { 137 CIFISP_HISTOGRAM_MODE_DISABLE, 138 CIFISP_HISTOGRAM_MODE_RGB_COMBINED, 139 CIFISP_HISTOGRAM_MODE_R_HISTOGRAM, 140 CIFISP_HISTOGRAM_MODE_G_HISTOGRAM, 141 CIFISP_HISTOGRAM_MODE_B_HISTOGRAM, 142 CIFISP_HISTOGRAM_MODE_Y_HISTOGRAM 143 }; 144 145 enum cifisp_awb_mode_type { 146 CIFISP_AWB_MODE_MANUAL, 147 CIFISP_AWB_MODE_RGB, 148 CIFISP_AWB_MODE_YCBCR 149 }; 150 151 enum cifisp_flt_mode { 152 CIFISP_FLT_STATIC_MODE, 153 CIFISP_FLT_DYNAMIC_MODE 154 }; 155 156 /** 157 * enum cifisp_exp_ctrl_auotostop - stop modes 158 * @CIFISP_EXP_CTRL_AUTOSTOP_0: continuous measurement 159 * @CIFISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame 160 */ 161 enum cifisp_exp_ctrl_auotostop { 162 CIFISP_EXP_CTRL_AUTOSTOP_0 = 0, 163 CIFISP_EXP_CTRL_AUTOSTOP_1 = 1, 164 }; 165 166 /** 167 * enum cifisp_exp_meas_mode - Exposure measure mode 168 * @CIFISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B 169 * @CIFISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256) 170 */ 171 enum cifisp_exp_meas_mode { 172 CIFISP_EXP_MEASURING_MODE_0, 173 CIFISP_EXP_MEASURING_MODE_1, 174 }; 175 176 /*---------- PART1: Input Parameters ------------*/ 177 178 struct cifisp_window { 179 unsigned short h_offs; 180 unsigned short v_offs; 181 unsigned short h_size; 182 unsigned short v_size; 183 } __attribute__ ((packed)); 184 185 /** 186 * struct cifisp_bls_fixed_val - BLS fixed subtraction values 187 * 188 * The values will be subtracted from the sensor 189 * values. Therefore a negative value means addition instead of subtraction! 190 * 191 * @r: Fixed (signed!) subtraction value for Bayer pattern R 192 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr 193 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb 194 * @b: Fixed (signed!) subtraction value for Bayer pattern B 195 */ 196 struct cifisp_bls_fixed_val { 197 signed short r; 198 signed short gr; 199 signed short gb; 200 signed short b; 201 } __attribute__ ((packed)); 202 203 /** 204 * struct cifisp_bls_config - Configuration used by black level subtraction 205 * 206 * @enable_auto: Automatic mode activated means that the measured values 207 * are subtracted.Otherwise the fixed subtraction 208 * values will be subtracted. 209 * @en_windows: enabled window 210 * @bls_window1: Measurement window 1 size 211 * @bls_window2: Measurement window 2 size 212 * @bls_samples: Set amount of measured pixels for each Bayer position 213 * (A, B,C and D) to 2^bls_samples. 214 * @cifisp_bls_fixed_val: Fixed subtraction values 215 */ 216 struct cifisp_bls_config { 217 unsigned char enable_auto; 218 unsigned char en_windows; 219 struct cifisp_window bls_window1; 220 struct cifisp_window bls_window2; 221 unsigned char bls_samples; 222 struct cifisp_bls_fixed_val fixed_val; 223 } __attribute__ ((packed)); 224 225 /** 226 * struct cifisp_dpcc_methods_config - Methods Configuration used by Defect Pixel Cluster Correction 227 * 228 * @method: 229 * @line_thresh: 230 * @line_mad_fac: 231 * @pg_fac: 232 * @rnd_thresh: 233 * @rg_fac: 234 */ 235 struct cifisp_dpcc_methods_config { 236 unsigned int method; 237 unsigned int line_thresh; 238 unsigned int line_mad_fac; 239 unsigned int pg_fac; 240 unsigned int rnd_thresh; 241 unsigned int rg_fac; 242 } __attribute__ ((packed)); 243 244 /** 245 * struct cifisp_dpcc_methods_config - Configuration used by Defect Pixel Cluster Correction 246 * 247 * @mode: dpcc output mode 248 * @output_mode: whether use hard coded methods 249 * @set_use: stage1 methods set 250 * @methods: methods config 251 * @ro_limits: rank order limits 252 * @rnd_offs: differential rank offsets for rank neighbor difference 253 */ 254 struct cifisp_dpcc_config { 255 unsigned int mode; 256 unsigned int output_mode; 257 unsigned int set_use; 258 struct cifisp_dpcc_methods_config methods[CIFISP_DPCC_METHODS_MAX]; 259 unsigned int ro_limits; 260 unsigned int rnd_offs; 261 } __attribute__ ((packed)); 262 263 struct cifisp_gamma_corr_curve { 264 unsigned short gamma_y[CIFISP_DEGAMMA_CURVE_SIZE]; 265 } __attribute__ ((packed)); 266 267 struct cifisp_gamma_curve_x_axis_pnts { 268 unsigned int gamma_dx0; 269 unsigned int gamma_dx1; 270 } __attribute__ ((packed)); 271 272 /** 273 * struct cifisp_gamma_corr_curve - Configuration used by sensor degamma 274 * 275 * @curve_x: gamma curve point definition axis for x 276 * @xa_pnts: x increments 277 */ 278 struct cifisp_sdg_config { 279 struct cifisp_gamma_corr_curve curve_r; 280 struct cifisp_gamma_corr_curve curve_g; 281 struct cifisp_gamma_corr_curve curve_b; 282 struct cifisp_gamma_curve_x_axis_pnts xa_pnts; 283 } __attribute__ ((packed)); 284 285 /** 286 * struct cifisp_lsc_config - Configuration used by Lens shading correction 287 * 288 * refer to datasheet for details 289 */ 290 struct cifisp_lsc_config { 291 unsigned int r_data_tbl[CIFISP_LSC_DATA_TBL_SIZE]; 292 unsigned int gr_data_tbl[CIFISP_LSC_DATA_TBL_SIZE]; 293 unsigned int gb_data_tbl[CIFISP_LSC_DATA_TBL_SIZE]; 294 unsigned int b_data_tbl[CIFISP_LSC_DATA_TBL_SIZE]; 295 296 unsigned int x_grad_tbl[CIFISP_LSC_GRAD_TBL_SIZE]; 297 unsigned int y_grad_tbl[CIFISP_LSC_GRAD_TBL_SIZE]; 298 299 unsigned int x_size_tbl[CIFISP_LSC_SIZE_TBL_SIZE]; 300 unsigned int y_size_tbl[CIFISP_LSC_SIZE_TBL_SIZE]; 301 unsigned short config_width; 302 unsigned short config_height; 303 } __attribute__ ((packed)); 304 305 /** 306 * struct cifisp_ie_config - Configuration used by image effects 307 * 308 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1 309 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2 310 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1 311 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2 312 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3 313 * @eff_tint: Chrominance increment values of tint (used for sepia effect) 314 */ 315 struct cifisp_ie_config { 316 unsigned short effect; 317 unsigned short color_sel; 318 unsigned short eff_mat_1; 319 unsigned short eff_mat_2; 320 unsigned short eff_mat_3; 321 unsigned short eff_mat_4; 322 unsigned short eff_mat_5; 323 unsigned short eff_tint; 324 } __attribute__ ((packed)); 325 326 /** 327 * struct cifisp_cproc_config - Configuration used by Color Processing 328 * 329 * @c_out_range: Chrominance pixel clipping range at output. (0 for limit, 1 for full) 330 * @y_in_range: Luminance pixel clipping range at output. 331 * @y_out_range: Luminance pixel clipping range at output. 332 * @contrast: 00~ff, 0.0~1.992 333 * @brightness: 80~7F, -128~+127 334 * @sat: saturation, 00~FF, 0.0~1.992 335 * @hue: 80~7F, -90~+87.188 336 */ 337 struct cifisp_cproc_config { 338 unsigned char c_out_range; 339 unsigned char y_in_range; 340 unsigned char y_out_range; 341 unsigned char contrast; 342 unsigned char brightness; 343 unsigned char sat; 344 unsigned char hue; 345 } __attribute__ ((packed)); 346 347 /** 348 * struct cifisp_awb_meas_config - Configuration used by auto white balance 349 * 350 * @awb_wnd: white balance measurement window (in pixels) 351 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0 to disable this feature 352 * @min_y: only pixels values > min_y contribute to awb measurement 353 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr, smaller than threshold for awb measurements 354 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr each greater than threshold value for awb measurements 355 * @frames: number of frames - 1 used for mean value calculation(ucFrames=0 means 1 Frame) 356 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB 357 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB 358 */ 359 struct cifisp_awb_meas_config { 360 /* 361 * Note: currently the h and v offsets are mapped to grid offsets 362 */ 363 struct cifisp_window awb_wnd; 364 enum cifisp_awb_mode_type awb_mode; 365 unsigned char max_y; 366 unsigned char min_y; 367 unsigned char max_csum; 368 unsigned char min_c; 369 unsigned char frames; 370 unsigned char awb_ref_cr; 371 unsigned char awb_ref_cb; 372 bool enable_ymax_cmp; 373 } __attribute__ ((packed)); 374 375 /** 376 * struct cifisp_awb_gain_config - Configuration used by auto white balance gain 377 * 378 * out_data_x = ( AWB_GEAIN_X * in_data + 128) >> 8 379 */ 380 struct cifisp_awb_gain_config { 381 unsigned short gain_red; 382 unsigned short gain_green_r; 383 unsigned short gain_blue; 384 unsigned short gain_green_b; 385 } __attribute__ ((packed)); 386 387 /** 388 * struct cifisp_flt_config - Configuration used by ISP filtering 389 * 390 * @mode: ISP_FILT_MODE register fields 391 * @grn_stage1: ISP_FILT_MODE register fields 392 * @chr_h_mode: ISP_FILT_MODE register fields 393 * @chr_v_mode: ISP_FILT_MODE register fields 394 * 395 * refer to datasheet for details. 396 */ 397 struct cifisp_flt_config { 398 enum cifisp_flt_mode mode; 399 unsigned char grn_stage1; 400 unsigned char chr_h_mode; 401 unsigned char chr_v_mode; 402 unsigned int thresh_bl0; 403 unsigned int thresh_bl1; 404 unsigned int thresh_sh0; 405 unsigned int thresh_sh1; 406 unsigned int lum_weight; 407 unsigned int fac_sh1; 408 unsigned int fac_sh0; 409 unsigned int fac_mid; 410 unsigned int fac_bl0; 411 unsigned int fac_bl1; 412 } __attribute__ ((packed)); 413 414 /** 415 * struct cifisp_bdm_config - Configuration used by Bayer DeMosaic 416 * 417 * @demosaic_th: threshod for bayer demosaicing texture detection 418 */ 419 struct cifisp_bdm_config { 420 unsigned char demosaic_th; 421 } __attribute__ ((packed)); 422 423 /** 424 * struct cifisp_ctk_config - Configuration used by Cross Talk correction 425 * 426 * @coeff: color correction matrix 427 * @ct_offset_b: offset for the crosstalk correction matrix 428 */ 429 struct cifisp_ctk_config { 430 unsigned short coeff0; 431 unsigned short coeff1; 432 unsigned short coeff2; 433 unsigned short coeff3; 434 unsigned short coeff4; 435 unsigned short coeff5; 436 unsigned short coeff6; 437 unsigned short coeff7; 438 unsigned short coeff8; 439 unsigned short ct_offset_r; 440 unsigned short ct_offset_g; 441 unsigned short ct_offset_b; 442 } __attribute__ ((packed)); 443 444 enum cifisp_goc_mode { 445 CIFISP_GOC_MODE_LOGARITHMIC, 446 CIFISP_GOC_MODE_EQUIDISTANT 447 }; 448 449 /** 450 * struct cifisp_goc_config - Configuration used by Gamma Out correction 451 * 452 * @mode: goc mode 453 * @gamma_y: gamma out curve y-axis for all color components 454 */ 455 struct cifisp_goc_config { 456 enum cifisp_goc_mode mode; 457 unsigned short gamma_y[CIFISP_GAMMA_OUT_MAX_SAMPLES]; 458 } __attribute__ ((packed)); 459 460 /** 461 * struct cifisp_hst_config - Configuration used by Histogram 462 * 463 * @mode: histogram mode 464 * @histogram_predivider: process every stepsize pixel, all other pixels are skipped 465 * @meas_window: coordinates of the meas window 466 * @hist_weight: weighting factor for sub-windows 467 */ 468 struct cifisp_hst_config { 469 enum cifisp_histogram_mode mode; 470 unsigned char histogram_predivider; 471 struct cifisp_window meas_window; 472 unsigned char hist_weight[CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE]; 473 } __attribute__ ((packed)); 474 475 /** 476 * struct cifisp_aec_config - Configuration used by Auto Exposure Control 477 * 478 * @mode: Exposure measure mode 479 * @autostop: stop mode (from enum cifisp_exp_ctrl_auotostop) 480 * @meas_window: coordinates of the meas window 481 */ 482 struct cifisp_aec_config { 483 enum cifisp_exp_meas_mode mode; 484 __u32 autostop; 485 struct cifisp_window meas_window; 486 } __attribute__ ((packed)); 487 488 /** 489 * struct cifisp_afc_config - Configuration used by Auto Focus Control 490 * 491 * @num_afm_win: max CIFISP_AFM_MAX_WINDOWS 492 * @afm_win: coordinates of the meas window 493 * @thres: threshold used for minimizing the influence of noise 494 * @var_shift: the number of bits for the shift operation at the end of the calculation chain. 495 */ 496 struct cifisp_afc_config { 497 unsigned char num_afm_win; 498 struct cifisp_window afm_win[CIFISP_AFM_MAX_WINDOWS]; 499 unsigned int thres; 500 unsigned int var_shift; 501 } __attribute__ ((packed)); 502 503 /** 504 * enum cifisp_dpf_gain_usage - dpf gain usage 505 * @CIFISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage 506 * @CIFISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from registers DPF_NF_GAIN_R, ... 507 * @CIFISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module 508 * @CIFISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the gains from LSC module 509 * @CIFISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module 510 * @CIFISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module 511 * @CIFISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation) 512 */ 513 enum cifisp_dpf_gain_usage { 514 CIFISP_DPF_GAIN_USAGE_DISABLED, 515 CIFISP_DPF_GAIN_USAGE_NF_GAINS, 516 CIFISP_DPF_GAIN_USAGE_LSC_GAINS, 517 CIFISP_DPF_GAIN_USAGE_NF_LSC_GAINS, 518 CIFISP_DPF_GAIN_USAGE_AWB_GAINS, 519 CIFISP_DPF_GAIN_USAGE_AWB_LSC_GAINS, 520 CIFISP_DPF_GAIN_USAGE_MAX 521 }; 522 523 /** 524 * enum cifisp_dpf_gain_usage - dpf gain usage 525 * @CIFISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9 (means 7x5 active pixel) 526 * @CIFISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9 (means 5x5 active pixel) 527 */ 528 enum cifisp_dpf_rb_filtersize { 529 CIFISP_DPF_RB_FILTERSIZE_13x9, 530 CIFISP_DPF_RB_FILTERSIZE_9x9, 531 }; 532 533 /** 534 * enum cifisp_dpf_nll_scale_mode - dpf noise level scale mode 535 * @CIFISP_NLL_SCALE_LINEAR: use a linear scaling 536 * @CIFISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling 537 */ 538 enum cifisp_dpf_nll_scale_mode { 539 CIFISP_NLL_SCALE_LINEAR, 540 CIFISP_NLL_SCALE_LOGARITHMIC, 541 }; 542 543 struct cifisp_dpf_nll { 544 unsigned short coeff[CIFISP_DPF_MAX_NLF_COEFFS]; 545 enum cifisp_dpf_nll_scale_mode scale_mode; 546 } __attribute__ ((packed)); 547 548 struct cifisp_dpf_rb_flt { 549 enum cifisp_dpf_rb_filtersize fltsize; 550 unsigned char spatial_coeff[CIFISP_DPF_MAX_SPATIAL_COEFFS]; 551 bool r_enable; 552 bool b_enable; 553 } __attribute__ ((packed)); 554 555 struct cifisp_dpf_g_flt { 556 unsigned char spatial_coeff[CIFISP_DPF_MAX_SPATIAL_COEFFS]; 557 bool gr_enable; 558 bool gb_enable; 559 } __attribute__ ((packed)); 560 561 struct cifisp_dpf_gain { 562 enum cifisp_dpf_gain_usage mode; 563 unsigned short nf_r_gain; 564 unsigned short nf_b_gain; 565 unsigned short nf_gr_gain; 566 unsigned short nf_gb_gain; 567 } __attribute__ ((packed)); 568 569 /** 570 * struct cifisp_dpf_config - Configuration used by De-noising pre-filter 571 * 572 * @gain: noise function gain 573 * @g_flt: green filter config 574 * @rb_flt: red blue filter config 575 * @nll: noise level lookup 576 */ 577 struct cifisp_dpf_config { 578 struct cifisp_dpf_gain gain; 579 struct cifisp_dpf_g_flt g_flt; 580 struct cifisp_dpf_rb_flt rb_flt; 581 struct cifisp_dpf_nll nll; 582 } __attribute__ ((packed)); 583 584 /** 585 * struct cifisp_dpf_strength_config - strength of the filter 586 * 587 * @r: filter strength of the RED filter 588 * @g: filter strength of the GREEN filter 589 * @b: filter strength of the BLUE filter 590 */ 591 struct cifisp_dpf_strength_config { 592 unsigned char r; 593 unsigned char g; 594 unsigned char b; 595 } __attribute__ ((packed)); 596 597 /** 598 * enum cifisp_wdr_mode - wdr mode 599 * @CIFISP_WDR_MODE_BLOCK: use a linear scaling 600 * @CIFISP_WDR_MODE_GLOBAL: use a logarithmic scaling 601 */ 602 enum cifisp_wdr_mode { 603 CIFISP_WDR_MODE_BLOCK, 604 CIFISP_WDR_MODE_GLOBAL 605 }; 606 607 /** 608 * struct cifisp_wdr_config - Gamma Out correction 609 */ 610 struct cifisp_wdr_config { 611 enum cifisp_wdr_mode mode; 612 unsigned int c_wdr[CIFISP_WDR_SIZE]; 613 } __attribute__ ((packed)); 614 615 /** 616 * struct cifisp_demosaiclp_config - rk demosiac low pass 617 */ 618 struct cifisp_demosaiclp_config { 619 unsigned char rb_filter_en; 620 unsigned char hp_filter_en; 621 unsigned char lu_divided[4]; 622 unsigned char thgrad_divided[5]; 623 unsigned char thdiff_divided[5]; 624 unsigned char thcsc_divided[5]; 625 unsigned short thvar_divided[5]; 626 unsigned char th_grad; 627 unsigned char th_diff; 628 unsigned char th_csc; 629 unsigned short th_var; 630 unsigned char th_var_en; 631 unsigned char th_csc_en; 632 unsigned char th_diff_en; 633 unsigned char th_grad_en; 634 unsigned char use_old_lp; 635 unsigned char similarity_th; 636 unsigned char flat_level_sel; 637 unsigned char pattern_level_sel; 638 unsigned char edge_level_sel; 639 unsigned char thgrad_r_fct; 640 unsigned char thdiff_r_fct; 641 unsigned char thvar_r_fct; 642 unsigned char thgrad_b_fct; 643 unsigned char thdiff_b_fct; 644 unsigned char thvar_b_fct; 645 } __attribute__ ((packed)); 646 647 /** 648 * struct cifisp_rkiesharp_config - rk ie sharp 649 */ 650 struct cifisp_rkiesharp_config { 651 unsigned char coring_thr; 652 unsigned char full_range; 653 unsigned char switch_avg; 654 unsigned char yavg_thr[4]; 655 unsigned char delta1[5]; 656 unsigned char delta2[5]; 657 unsigned char maxnumber[5]; 658 unsigned char minnumber[5]; 659 unsigned char gauss_flat_coe[9]; 660 unsigned char gauss_noise_coe[9]; 661 unsigned char gauss_other_coe[9]; 662 unsigned char line1_filter_coe[6]; 663 unsigned char line2_filter_coe[9]; 664 unsigned char line3_filter_coe[6]; 665 unsigned short grad_seq[4]; 666 unsigned char sharp_factor[5]; 667 unsigned char uv_gauss_flat_coe[15]; 668 unsigned char uv_gauss_noise_coe[15]; 669 unsigned char uv_gauss_other_coe[15]; 670 unsigned char lap_mat_coe[9]; 671 } __attribute__ ((packed)); 672 673 /** 674 * struct cifisp_isp_other_cfg - Parameters for some blocks in rockchip isp1 675 * 676 * @dpcc_config: Defect Pixel Cluster Correction config 677 * @bls_config: Black Level Subtraction config 678 * @sdg_config: sensor degamma config 679 * @lsc_config: Lens Shade config 680 * @awb_gain_config: Auto White balance gain config 681 * @flt_config: filter config 682 * @bdm_config: demosaic config 683 * @ctk_config: cross talk config 684 * @goc_config: gamma out config 685 * @bls_config: black level suntraction config 686 * @dpf_config: De-noising pre-filter config 687 * @dpf_strength_config: dpf strength config 688 * @cproc_config: color process config 689 * @ie_config: image effects config 690 */ 691 struct cifisp_isp_other_cfg { 692 struct cifisp_dpcc_config dpcc_config; 693 struct cifisp_bls_config bls_config; 694 struct cifisp_sdg_config sdg_config; 695 struct cifisp_lsc_config lsc_config; 696 struct cifisp_awb_gain_config awb_gain_config; 697 struct cifisp_flt_config flt_config; 698 struct cifisp_bdm_config bdm_config; 699 struct cifisp_ctk_config ctk_config; 700 struct cifisp_goc_config goc_config; 701 struct cifisp_dpf_config dpf_config; 702 struct cifisp_dpf_strength_config dpf_strength_config; 703 struct cifisp_cproc_config cproc_config; 704 struct cifisp_ie_config ie_config; 705 struct cifisp_wdr_config wdr_config; 706 struct cifisp_demosaiclp_config demosaiclp_config; 707 struct cifisp_rkiesharp_config rkiesharp_config; 708 } __attribute__ ((packed)); 709 710 /** 711 * struct cifisp_isp_meas_cfg - Rockchip ISP1 Measure Parameters 712 * 713 * @awb_meas_config: auto white balance config 714 * @hst_config: histogram config 715 * @aec_config: auto exposure config 716 * @afc_config: auto focus config 717 */ 718 struct cifisp_isp_meas_cfg { 719 struct cifisp_awb_meas_config awb_meas_config; 720 struct cifisp_hst_config hst_config; 721 struct cifisp_aec_config aec_config; 722 struct cifisp_afc_config afc_config; 723 } __attribute__ ((packed)); 724 725 /** 726 * struct rkisp1_isp_params_cfg - Rockchip ISP1 Input Parameters Meta Data 727 * 728 * @module_en_update: mask the enable bits of which module should be updated 729 * @module_ens: mask the enable value of each module, only update the module 730 * which correspond bit was set in module_en_update 731 * @module_cfg_update: mask the config bits of which module should be updated 732 * @meas: measurement config 733 * @others: other config 734 */ 735 struct rkisp1_isp_params_cfg { 736 unsigned int module_en_update; 737 unsigned int module_ens; 738 unsigned int module_cfg_update; 739 740 struct cifisp_isp_meas_cfg meas; 741 struct cifisp_isp_other_cfg others; 742 } __attribute__ ((packed)); 743 744 /*---------- PART2: Measurement Statistics ------------*/ 745 746 /** 747 * struct cifisp_bls_meas_val - AWB measured values 748 * 749 * @cnt: White pixel count, number of "white pixels" found during laster measurement 750 * @mean_y_or_g: Mean value of Y within window and frames, Green if RGB is selected. 751 * @mean_cb_or_b: Mean value of Cb within window and frames, Blue if RGB is selected. 752 * @mean_cr_or_r: Mean value of Cr within window and frames, Red if RGB is selected. 753 */ 754 struct cifisp_awb_meas { 755 unsigned int cnt; 756 unsigned char mean_y_or_g; 757 unsigned char mean_cb_or_b; 758 unsigned char mean_cr_or_r; 759 } __attribute__ ((packed)); 760 761 /** 762 * struct cifisp_awb_stat - statistics automatic white balance data 763 * 764 * @awb_mean: Mean measured data 765 */ 766 struct cifisp_awb_stat { 767 struct cifisp_awb_meas awb_mean[CIFISP_AWB_MAX_GRID]; 768 } __attribute__ ((packed)); 769 770 /** 771 * struct cifisp_bls_meas_val - BLS measured values 772 * 773 * @meas_r: Mean measured value for Bayer pattern R 774 * @meas_gr: Mean measured value for Bayer pattern Gr 775 * @meas_gb: Mean measured value for Bayer pattern Gb 776 * @meas_b: Mean measured value for Bayer pattern B 777 */ 778 struct cifisp_bls_meas_val { 779 unsigned short meas_r; 780 unsigned short meas_gr; 781 unsigned short meas_gb; 782 unsigned short meas_b; 783 } __attribute__ ((packed)); 784 785 /** 786 * struct cifisp_ae_stat - statistics auto exposure data 787 * 788 * @exp_mean: Mean luminance value of block xx 789 * @bls_val: available wit exposure results 790 * 791 * Image is divided into 5x5 blocks. 792 */ 793 struct cifisp_ae_stat { 794 unsigned char exp_mean[CIFISP_AE_MEAN_MAX]; 795 struct cifisp_bls_meas_val bls_val; 796 } __attribute__ ((packed)); 797 798 /** 799 * struct cifisp_af_meas_val - AF measured values 800 * 801 * @sum: sharpness, refer to datasheet for definition 802 * @lum: luminance, refer to datasheet for definition 803 */ 804 struct cifisp_af_meas_val { 805 unsigned int sum; 806 unsigned int lum; 807 } __attribute__ ((packed)); 808 809 /** 810 * struct cifisp_af_stat - statistics auto focus data 811 * 812 * @window: AF measured value of window x 813 * 814 * The module measures the sharpness in 3 windows of selectable size via 815 * register settings(ISP_AFM_*_A/B/C) 816 */ 817 struct cifisp_af_stat { 818 struct cifisp_af_meas_val window[CIFISP_AFM_MAX_WINDOWS]; 819 } __attribute__ ((packed)); 820 821 /** 822 * struct cifisp_hist_stat - statistics histogram data 823 * 824 * @hist_bins: measured bin counters 825 * 826 * Measurement window divided into 25 sub-windows, set 827 * with ISP_HIST_XXX 828 */ 829 struct cifisp_hist_stat { 830 unsigned int hist_bins[CIFISP_HIST_BIN_N_MAX]; 831 } __attribute__ ((packed)); 832 833 /** 834 * struct cifisp_embedded_data - embedded data 835 * 836 * @data: embedded data 837 * 838 */ 839 struct cifisp_embedded_data { 840 unsigned char data[CIFISP_ADD_DATA_FIFO_SIZE]; 841 } __attribute__ ((packed)); 842 843 /** 844 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Data 845 * 846 * @cifisp_awb_stat: statistics data for automatic white balance 847 * @cifisp_ae_stat: statistics data for auto exposure 848 * @cifisp_af_stat: statistics data for auto focus 849 * @cifisp_hist_stat: statistics histogram data 850 */ 851 struct cifisp_stat { 852 struct cifisp_awb_stat awb; 853 struct cifisp_ae_stat ae; 854 struct cifisp_af_stat af; 855 struct cifisp_hist_stat hist; 856 struct cifisp_embedded_data emd; 857 } __attribute__ ((packed)); 858 859 /** 860 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data 861 * 862 * @meas_type: measurement types (CIFISP_STAT_ definitions) 863 * @frame_id: frame ID for sync 864 * @params: statistics data 865 */ 866 struct rkisp1_stat_buffer { 867 unsigned int meas_type; 868 unsigned int frame_id; 869 struct cifisp_stat params; 870 } __attribute__ ((packed)); 871 872 #endif /* _UAPI_RKISP1_CONFIG_H */ 873