linux/drivers/staging/media/rkisp1/uapi/rkisp1-config.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
   2/*
   3 * Rockchip ISP1 userspace API
   4 * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
   5 */
   6
   7/*
   8 * TODO: Improve documentation, mostly regarding abbreviation and hardware
   9 * specificities. Reference: "REF_01 - ISP_user_manual, Rev 2.57" (not public)
  10 */
  11
  12#ifndef _UAPI_RKISP1_CONFIG_H
  13#define _UAPI_RKISP1_CONFIG_H
  14
  15#include <linux/types.h>
  16
  17/* Vendor specific - used for RK_ISP1 camera sub-system */
  18#define V4L2_META_FMT_RK_ISP1_PARAMS   v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 params */
  19#define V4L2_META_FMT_RK_ISP1_STAT_3A  v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A statistics */
  20
  21#define RKISP1_CIF_ISP_MODULE_DPCC              BIT(0)
  22#define RKISP1_CIF_ISP_MODULE_BLS               BIT(1)
  23#define RKISP1_CIF_ISP_MODULE_SDG               BIT(2)
  24#define RKISP1_CIF_ISP_MODULE_HST               BIT(3)
  25#define RKISP1_CIF_ISP_MODULE_LSC               BIT(4)
  26#define RKISP1_CIF_ISP_MODULE_AWB_GAIN          BIT(5)
  27#define RKISP1_CIF_ISP_MODULE_FLT               BIT(6)
  28#define RKISP1_CIF_ISP_MODULE_BDM               BIT(7)
  29#define RKISP1_CIF_ISP_MODULE_CTK               BIT(8)
  30#define RKISP1_CIF_ISP_MODULE_GOC               BIT(9)
  31#define RKISP1_CIF_ISP_MODULE_CPROC             BIT(10)
  32#define RKISP1_CIF_ISP_MODULE_AFC               BIT(11)
  33#define RKISP1_CIF_ISP_MODULE_AWB               BIT(12)
  34#define RKISP1_CIF_ISP_MODULE_IE                BIT(13)
  35#define RKISP1_CIF_ISP_MODULE_AEC               BIT(14)
  36#define RKISP1_CIF_ISP_MODULE_WDR               BIT(15)
  37#define RKISP1_CIF_ISP_MODULE_DPF               BIT(16)
  38#define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH      BIT(17)
  39
  40#define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100
  41#define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800
  42
  43#define RKISP1_CIF_ISP_AE_MEAN_MAX              25
  44#define RKISP1_CIF_ISP_HIST_BIN_N_MAX           16
  45#define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3
  46#define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17
  47
  48#define RKISP1_CIF_ISP_BDM_MAX_TH               0xff
  49
  50/*
  51 * Black level compensation
  52 */
  53/* maximum value for horizontal start address */
  54#define RKISP1_CIF_ISP_BLS_START_H_MAX             0x00000fff
  55/* maximum value for horizontal stop address */
  56#define RKISP1_CIF_ISP_BLS_STOP_H_MAX              0x00000fff
  57/* maximum value for vertical start address */
  58#define RKISP1_CIF_ISP_BLS_START_V_MAX             0x00000fff
  59/* maximum value for vertical stop address */
  60#define RKISP1_CIF_ISP_BLS_STOP_V_MAX              0x00000fff
  61/* maximum is 2^18 = 262144*/
  62#define RKISP1_CIF_ISP_BLS_SAMPLES_MAX             0x00000012
  63/* maximum value for fixed black level */
  64#define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX             0x00000fff
  65/* minimum value for fixed black level */
  66#define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN             0xfffff000
  67/* 13 bit range (signed)*/
  68#define RKISP1_CIF_ISP_BLS_FIX_MASK                0x00001fff
  69
  70/*
  71 * Automatic white balance measurements
  72 */
  73#define RKISP1_CIF_ISP_AWB_MAX_GRID                1
  74#define RKISP1_CIF_ISP_AWB_MAX_FRAMES              7
  75
  76/*
  77 * Gamma out
  78 */
  79/* Maximum number of color samples supported */
  80#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17
  81
  82/*
  83 * Lens shade correction
  84 */
  85#define RKISP1_CIF_ISP_LSC_GRAD_TBL_SIZE           8
  86#define RKISP1_CIF_ISP_LSC_SIZE_TBL_SIZE           8
  87/*
  88 * The following matches the tuning process,
  89 * not the max capabilities of the chip.
  90 * Last value unused.
  91 */
  92#define RKISP1_CIF_ISP_LSC_DATA_TBL_SIZE           290
  93
  94/*
  95 * Histogram calculation
  96 */
  97/* Last 3 values unused. */
  98#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28
  99
 100/*
 101 * Defect Pixel Cluster Correction
 102 */
 103#define RKISP1_CIF_ISP_DPCC_METHODS_MAX       3
 104
 105/*
 106 * Denoising pre filter
 107 */
 108#define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS      17
 109#define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS  6
 110
 111/*
 112 * Measurement types
 113 */
 114#define RKISP1_CIF_ISP_STAT_AWB           BIT(0)
 115#define RKISP1_CIF_ISP_STAT_AUTOEXP       BIT(1)
 116#define RKISP1_CIF_ISP_STAT_AFM_FIN       BIT(2)
 117#define RKISP1_CIF_ISP_STAT_HIST          BIT(3)
 118
 119enum rkisp1_cif_isp_histogram_mode {
 120        RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
 121        RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
 122        RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
 123        RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
 124        RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
 125        RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
 126};
 127
 128enum rkisp1_cif_isp_awb_mode_type {
 129        RKISP1_CIF_ISP_AWB_MODE_MANUAL,
 130        RKISP1_CIF_ISP_AWB_MODE_RGB,
 131        RKISP1_CIF_ISP_AWB_MODE_YCBCR
 132};
 133
 134enum rkisp1_cif_isp_flt_mode {
 135        RKISP1_CIF_ISP_FLT_STATIC_MODE,
 136        RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
 137};
 138
 139/**
 140 * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
 141 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
 142 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
 143 */
 144enum rkisp1_cif_isp_exp_ctrl_autostop {
 145        RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
 146        RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
 147};
 148
 149/**
 150 * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
 151 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
 152 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
 153 */
 154enum rkisp1_cif_isp_exp_meas_mode {
 155        RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
 156        RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
 157};
 158
 159/*---------- PART1: Input Parameters ------------*/
 160
 161struct rkisp1_cif_isp_window {
 162        __u16 h_offs;
 163        __u16 v_offs;
 164        __u16 h_size;
 165        __u16 v_size;
 166} __packed;
 167
 168/**
 169 * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
 170 *
 171 * The values will be subtracted from the sensor
 172 * values. Therefore a negative value means addition instead of subtraction!
 173 *
 174 * @r: Fixed (signed!) subtraction value for Bayer pattern R
 175 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
 176 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
 177 * @b: Fixed (signed!) subtraction value for Bayer pattern B
 178 */
 179struct rkisp1_cif_isp_bls_fixed_val {
 180        __s16 r;
 181        __s16 gr;
 182        __s16 gb;
 183        __s16 b;
 184} __packed;
 185
 186/**
 187 * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
 188 *
 189 * @enable_auto: Automatic mode activated means that the measured values
 190 *               are subtracted. Otherwise the fixed subtraction
 191 *               values will be subtracted.
 192 * @en_windows: enabled window
 193 * @bls_window1: Measurement window 1 size
 194 * @bls_window2: Measurement window 2 size
 195 * @bls_samples: Set amount of measured pixels for each Bayer position
 196 *               (A, B,C and D) to 2^bls_samples.
 197 * @fixed_val: Fixed subtraction values
 198 */
 199struct rkisp1_cif_isp_bls_config {
 200        __u8 enable_auto;
 201        __u8 en_windows;
 202        struct rkisp1_cif_isp_window bls_window1;
 203        struct rkisp1_cif_isp_window bls_window2;
 204        __u8 bls_samples;
 205        struct rkisp1_cif_isp_bls_fixed_val fixed_val;
 206} __packed;
 207
 208/**
 209 * struct rkisp1_cif_isp_dpcc_methods_config - Methods Configuration used by DPCC
 210 *
 211 * Methods Configuration used by Defect Pixel Cluster Correction
 212 *
 213 * @method: Method enable bits
 214 * @line_thresh: Line threshold
 215 * @line_mad_fac: Line MAD factor
 216 * @pg_fac: Peak gradient factor
 217 * @rnd_thresh: Rank Neighbor Difference threshold
 218 * @rg_fac: Rank gradient factor
 219 */
 220struct rkisp1_cif_isp_dpcc_methods_config {
 221        __u32 method;
 222        __u32 line_thresh;
 223        __u32 line_mad_fac;
 224        __u32 pg_fac;
 225        __u32 rnd_thresh;
 226        __u32 rg_fac;
 227} __packed;
 228
 229/**
 230 * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
 231 *
 232 * Configuration used by Defect Pixel Cluster Correction
 233 *
 234 * @mode: dpcc output mode
 235 * @output_mode: whether use hard coded methods
 236 * @set_use: stage1 methods set
 237 * @methods: methods config
 238 * @ro_limits: rank order limits
 239 * @rnd_offs: differential rank offsets for rank neighbor difference
 240 */
 241struct rkisp1_cif_isp_dpcc_config {
 242        __u32 mode;
 243        __u32 output_mode;
 244        __u32 set_use;
 245        struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
 246        __u32 ro_limits;
 247        __u32 rnd_offs;
 248} __packed;
 249
 250struct rkisp1_cif_isp_gamma_corr_curve {
 251        __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
 252} __packed;
 253
 254struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
 255        __u32 gamma_dx0;
 256        __u32 gamma_dx1;
 257} __packed;
 258
 259/**
 260 * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
 261 *
 262 * @curve_x: gamma curve point definition axis for x
 263 * @xa_pnts: x increments
 264 */
 265struct rkisp1_cif_isp_sdg_config {
 266        struct rkisp1_cif_isp_gamma_corr_curve curve_r;
 267        struct rkisp1_cif_isp_gamma_corr_curve curve_g;
 268        struct rkisp1_cif_isp_gamma_corr_curve curve_b;
 269        struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
 270} __packed;
 271
 272/**
 273 * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
 274 *
 275 * refer to REF_01 for details
 276 */
 277struct rkisp1_cif_isp_lsc_config {
 278        __u32 r_data_tbl[RKISP1_CIF_ISP_LSC_DATA_TBL_SIZE];
 279        __u32 gr_data_tbl[RKISP1_CIF_ISP_LSC_DATA_TBL_SIZE];
 280        __u32 gb_data_tbl[RKISP1_CIF_ISP_LSC_DATA_TBL_SIZE];
 281        __u32 b_data_tbl[RKISP1_CIF_ISP_LSC_DATA_TBL_SIZE];
 282
 283        __u32 x_grad_tbl[RKISP1_CIF_ISP_LSC_GRAD_TBL_SIZE];
 284        __u32 y_grad_tbl[RKISP1_CIF_ISP_LSC_GRAD_TBL_SIZE];
 285
 286        __u32 x_size_tbl[RKISP1_CIF_ISP_LSC_SIZE_TBL_SIZE];
 287        __u32 y_size_tbl[RKISP1_CIF_ISP_LSC_SIZE_TBL_SIZE];
 288        __u16 config_width;
 289        __u16 config_height;
 290} __packed;
 291
 292/**
 293 * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
 294 *
 295 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
 296 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
 297 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
 298 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
 299 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
 300 * @eff_tint: Chrominance increment values of tint (used for sepia effect)
 301 */
 302struct rkisp1_cif_isp_ie_config {
 303        __u16 effect;
 304        __u16 color_sel;
 305        __u16 eff_mat_1;
 306        __u16 eff_mat_2;
 307        __u16 eff_mat_3;
 308        __u16 eff_mat_4;
 309        __u16 eff_mat_5;
 310        __u16 eff_tint;
 311} __packed;
 312
 313/**
 314 * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
 315 *
 316 * @c_out_range: Chrominance pixel clipping range at output.
 317 *               (0 for limit, 1 for full)
 318 * @y_in_range: Luminance pixel clipping range at output.
 319 * @y_out_range: Luminance pixel clipping range at output.
 320 * @contrast: 00~ff, 0.0~1.992
 321 * @brightness: 80~7F, -128~+127
 322 * @sat: saturation, 00~FF, 0.0~1.992
 323 * @hue: 80~7F, -90~+87.188
 324 */
 325struct rkisp1_cif_isp_cproc_config {
 326        __u8 c_out_range;
 327        __u8 y_in_range;
 328        __u8 y_out_range;
 329        __u8 contrast;
 330        __u8 brightness;
 331        __u8 sat;
 332        __u8 hue;
 333} __packed;
 334
 335/**
 336 * struct rkisp1_cif_isp_awb_meas_config - Configuration used by auto white balance
 337 *
 338 * @awb_wnd: white balance measurement window (in pixels)
 339 *           (from enum rkisp1_cif_isp_awb_mode_type)
 340 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
 341 *         to disable this feature
 342 * @min_y: only pixels values > min_y contribute to awb measurement
 343 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
 344 *            smaller than threshold for awb measurements
 345 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
 346 *         each greater than threshold value for awb measurements
 347 * @frames: number of frames - 1 used for mean value calculation
 348 *          (ucFrames=0 means 1 Frame)
 349 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
 350 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
 351 */
 352struct rkisp1_cif_isp_awb_meas_config {
 353        /*
 354         * Note: currently the h and v offsets are mapped to grid offsets
 355         */
 356        struct rkisp1_cif_isp_window awb_wnd;
 357        __u32 awb_mode;
 358        __u8 max_y;
 359        __u8 min_y;
 360        __u8 max_csum;
 361        __u8 min_c;
 362        __u8 frames;
 363        __u8 awb_ref_cr;
 364        __u8 awb_ref_cb;
 365        __u8 enable_ymax_cmp;
 366} __packed;
 367
 368/**
 369 * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
 370 *
 371 * out_data_x = ( AWB_GEAIN_X * in_data + 128) >> 8
 372 */
 373struct rkisp1_cif_isp_awb_gain_config {
 374        __u16 gain_red;
 375        __u16 gain_green_r;
 376        __u16 gain_blue;
 377        __u16 gain_green_b;
 378} __packed;
 379
 380/**
 381 * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
 382 *
 383 * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
 384 * @grn_stage1: ISP_FILT_MODE register fields
 385 * @chr_h_mode: ISP_FILT_MODE register fields
 386 * @chr_v_mode: ISP_FILT_MODE register fields
 387 *
 388 * refer to REF_01 for details.
 389 */
 390
 391struct rkisp1_cif_isp_flt_config {
 392        __u32 mode;
 393        __u8 grn_stage1;
 394        __u8 chr_h_mode;
 395        __u8 chr_v_mode;
 396        __u32 thresh_bl0;
 397        __u32 thresh_bl1;
 398        __u32 thresh_sh0;
 399        __u32 thresh_sh1;
 400        __u32 lum_weight;
 401        __u32 fac_sh1;
 402        __u32 fac_sh0;
 403        __u32 fac_mid;
 404        __u32 fac_bl0;
 405        __u32 fac_bl1;
 406} __packed;
 407
 408/**
 409 * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
 410 *
 411 * @demosaic_th: threshold for bayer demosaicing texture detection
 412 */
 413struct rkisp1_cif_isp_bdm_config {
 414        __u8 demosaic_th;
 415} __packed;
 416
 417/**
 418 * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
 419 *
 420 * @coeff: color correction matrix
 421 * @ct_offset_b: offset for the crosstalk correction matrix
 422 */
 423struct rkisp1_cif_isp_ctk_config {
 424        __u16 coeff0;
 425        __u16 coeff1;
 426        __u16 coeff2;
 427        __u16 coeff3;
 428        __u16 coeff4;
 429        __u16 coeff5;
 430        __u16 coeff6;
 431        __u16 coeff7;
 432        __u16 coeff8;
 433        __u16 ct_offset_r;
 434        __u16 ct_offset_g;
 435        __u16 ct_offset_b;
 436} __packed;
 437
 438enum rkisp1_cif_isp_goc_mode {
 439        RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
 440        RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
 441};
 442
 443/**
 444 * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
 445 *
 446 * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
 447 * @gamma_y: gamma out curve y-axis for all color components
 448 */
 449struct rkisp1_cif_isp_goc_config {
 450        __u32 mode;
 451        __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
 452} __packed;
 453
 454/**
 455 * struct rkisp1_cif_isp_hst_config - Configuration used by Histogram
 456 *
 457 * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
 458 * @histogram_predivider: process every stepsize pixel, all other pixels are
 459 *                        skipped
 460 * @meas_window: coordinates of the measure window
 461 * @hist_weight: weighting factor for sub-windows
 462 */
 463struct rkisp1_cif_isp_hst_config {
 464        __u32 mode;
 465        __u8 histogram_predivider;
 466        struct rkisp1_cif_isp_window meas_window;
 467        __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
 468} __packed;
 469
 470/**
 471 * struct rkisp1_cif_isp_aec_config - Configuration used by Auto Exposure Control
 472 *
 473 * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
 474 * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
 475 * @meas_window: coordinates of the measure window
 476 */
 477struct rkisp1_cif_isp_aec_config {
 478        __u32 mode;
 479        __u32 autostop;
 480        struct rkisp1_cif_isp_window meas_window;
 481} __packed;
 482
 483/**
 484 * struct rkisp1_cif_isp_afc_config - Configuration used by Auto Focus Control
 485 *
 486 * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
 487 * @afm_win: coordinates of the meas window
 488 * @thres: threshold used for minimizing the influence of noise
 489 * @var_shift: the number of bits for the shift operation at the end of the
 490 *             calculation chain.
 491 */
 492struct rkisp1_cif_isp_afc_config {
 493        __u8 num_afm_win;
 494        struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
 495        __u32 thres;
 496        __u32 var_shift;
 497} __packed;
 498
 499/**
 500 * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
 501 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
 502 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
 503 *                                  registers DPF_NF_GAIN_R, ...
 504 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS:  use only the gains from LSC module
 505 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
 506 *                                      gains from LSC module
 507 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
 508 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
 509 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
 510 */
 511enum rkisp1_cif_isp_dpf_gain_usage {
 512        RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
 513        RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
 514        RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
 515        RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
 516        RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
 517        RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
 518        RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
 519};
 520
 521/**
 522 * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
 523 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
 524 *                                 (means 7x5 active pixel)
 525 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
 526 *                                 (means 5x5 active pixel)
 527 */
 528enum rkisp1_cif_isp_dpf_rb_filtersize {
 529        RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
 530        RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
 531};
 532
 533/**
 534 * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
 535 * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
 536 * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
 537 */
 538enum rkisp1_cif_isp_dpf_nll_scale_mode {
 539        RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
 540        RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
 541};
 542
 543/**
 544 * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
 545 *
 546 * @coeff: Noise level Lookup coefficient
 547 * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
 548 */
 549struct rkisp1_cif_isp_dpf_nll {
 550        __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
 551        __u32 scale_mode;
 552} __packed;
 553
 554/**
 555 * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
 556 *
 557 * @fltsize: The filter size for the red and blue pixels
 558 *           (from enum rkisp1_cif_isp_dpf_rb_filtersize)
 559 * @spatial_coeff: Spatial weights
 560 * @r_enable: enable filter processing for red pixels
 561 * @b_enable: enable filter processing for blue pixels
 562 */
 563struct rkisp1_cif_isp_dpf_rb_flt {
 564        __u32 fltsize;
 565        __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
 566        __u8 r_enable;
 567        __u8 b_enable;
 568} __packed;
 569
 570/**
 571 * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
 572 *
 573 * @spatial_coeff: Spatial weights
 574 * @gr_enable: enable filter processing for green pixels in green/red lines
 575 * @gb_enable: enable filter processing for green pixels in green/blue lines
 576 */
 577struct rkisp1_cif_isp_dpf_g_flt {
 578        __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
 579        __u8 gr_enable;
 580        __u8 gb_enable;
 581} __packed;
 582
 583/**
 584 * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
 585 *
 586 * @mode: dpf gain usage  (from enum rkisp1_cif_isp_dpf_gain_usage)
 587 * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
 588 * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
 589 * @nf_gr_gain: Noise function Gain that replaces the AWB gain
 590 *              for green pixels in a red line
 591 * @nf_gb_gain: Noise function Gain that replaces the AWB gain
 592 *              for green pixels in a blue line
 593 */
 594struct rkisp1_cif_isp_dpf_gain {
 595        __u32 mode;
 596        __u16 nf_r_gain;
 597        __u16 nf_b_gain;
 598        __u16 nf_gr_gain;
 599        __u16 nf_gb_gain;
 600} __packed;
 601
 602/**
 603 * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
 604 *
 605 * @gain: noise function gain
 606 * @g_flt: green filter config
 607 * @rb_flt: red blue filter config
 608 * @nll: noise level lookup
 609 */
 610struct rkisp1_cif_isp_dpf_config {
 611        struct rkisp1_cif_isp_dpf_gain gain;
 612        struct rkisp1_cif_isp_dpf_g_flt g_flt;
 613        struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
 614        struct rkisp1_cif_isp_dpf_nll nll;
 615} __packed;
 616
 617/**
 618 * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
 619 *
 620 * @r: filter strength of the RED filter
 621 * @g: filter strength of the GREEN filter
 622 * @b: filter strength of the BLUE filter
 623 */
 624struct rkisp1_cif_isp_dpf_strength_config {
 625        __u8 r;
 626        __u8 g;
 627        __u8 b;
 628} __packed;
 629
 630/**
 631 * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
 632 *
 633 * @dpcc_config: Defect Pixel Cluster Correction config
 634 * @bls_config: Black Level Subtraction config
 635 * @sdg_config: sensor degamma config
 636 * @lsc_config: Lens Shade config
 637 * @awb_gain_config: Auto White balance gain config
 638 * @flt_config: filter config
 639 * @bdm_config: demosaic config
 640 * @ctk_config: cross talk config
 641 * @goc_config: gamma out config
 642 * @bls_config: black level subtraction config
 643 * @dpf_config: De-noising pre-filter config
 644 * @dpf_strength_config: dpf strength config
 645 * @cproc_config: color process config
 646 * @ie_config: image effects config
 647 */
 648struct rkisp1_cif_isp_isp_other_cfg {
 649        struct rkisp1_cif_isp_dpcc_config dpcc_config;
 650        struct rkisp1_cif_isp_bls_config bls_config;
 651        struct rkisp1_cif_isp_sdg_config sdg_config;
 652        struct rkisp1_cif_isp_lsc_config lsc_config;
 653        struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
 654        struct rkisp1_cif_isp_flt_config flt_config;
 655        struct rkisp1_cif_isp_bdm_config bdm_config;
 656        struct rkisp1_cif_isp_ctk_config ctk_config;
 657        struct rkisp1_cif_isp_goc_config goc_config;
 658        struct rkisp1_cif_isp_dpf_config dpf_config;
 659        struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
 660        struct rkisp1_cif_isp_cproc_config cproc_config;
 661        struct rkisp1_cif_isp_ie_config ie_config;
 662} __packed;
 663
 664/**
 665 * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
 666 *
 667 * @awb_meas_config: auto white balance config
 668 * @hst_config: histogram config
 669 * @aec_config: auto exposure config
 670 * @afc_config: auto focus config
 671 */
 672struct rkisp1_cif_isp_isp_meas_cfg {
 673        struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
 674        struct rkisp1_cif_isp_hst_config hst_config;
 675        struct rkisp1_cif_isp_aec_config aec_config;
 676        struct rkisp1_cif_isp_afc_config afc_config;
 677} __packed;
 678
 679/**
 680 * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
 681 *
 682 * @module_en_update: mask the enable bits of which module should be updated
 683 * @module_ens: mask the enable value of each module, only update the module
 684 *              which correspond bit was set in module_en_update
 685 * @module_cfg_update: mask the config bits of which module should be updated
 686 * @meas: measurement config
 687 * @others: other config
 688 */
 689struct rkisp1_params_cfg {
 690        __u32 module_en_update;
 691        __u32 module_ens;
 692        __u32 module_cfg_update;
 693
 694        struct rkisp1_cif_isp_isp_meas_cfg meas;
 695        struct rkisp1_cif_isp_isp_other_cfg others;
 696} __packed;
 697
 698/*---------- PART2: Measurement Statistics ------------*/
 699
 700/**
 701 * struct rkisp1_cif_isp_awb_meas - AWB measured values
 702 *
 703 * @cnt: White pixel count, number of "white pixels" found during last
 704 *       measurement
 705 * @mean_y_or_g: Mean value of Y within window and frames,
 706 *               Green if RGB is selected.
 707 * @mean_cb_or_b: Mean value of Cb within window and frames,
 708 *                Blue if RGB is selected.
 709 * @mean_cr_or_r: Mean value of Cr within window and frames,
 710 *                Red if RGB is selected.
 711 */
 712struct rkisp1_cif_isp_awb_meas {
 713        __u32 cnt;
 714        __u8 mean_y_or_g;
 715        __u8 mean_cb_or_b;
 716        __u8 mean_cr_or_r;
 717} __packed;
 718
 719/**
 720 * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
 721 *
 722 * @awb_mean: Mean measured data
 723 */
 724struct rkisp1_cif_isp_awb_stat {
 725        struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
 726} __packed;
 727
 728/**
 729 * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
 730 *
 731 * @meas_r: Mean measured value for Bayer pattern R
 732 * @meas_gr: Mean measured value for Bayer pattern Gr
 733 * @meas_gb: Mean measured value for Bayer pattern Gb
 734 * @meas_b: Mean measured value for Bayer pattern B
 735 */
 736struct rkisp1_cif_isp_bls_meas_val {
 737        __u16 meas_r;
 738        __u16 meas_gr;
 739        __u16 meas_gb;
 740        __u16 meas_b;
 741} __packed;
 742
 743/**
 744 * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
 745 *
 746 * @exp_mean: Mean luminance value of block xx
 747 * @bls_val:  BLS measured values
 748 *
 749 * Image is divided into 5x5 blocks.
 750 */
 751struct rkisp1_cif_isp_ae_stat {
 752        __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
 753        struct rkisp1_cif_isp_bls_meas_val bls_val;
 754} __packed;
 755
 756/**
 757 * struct rkisp1_cif_isp_af_meas_val - AF measured values
 758 *
 759 * @sum: sharpness, refer to REF_01 for definition
 760 * @lum: luminance, refer to REF_01 for definition
 761 */
 762struct rkisp1_cif_isp_af_meas_val {
 763        __u32 sum;
 764        __u32 lum;
 765} __packed;
 766
 767/**
 768 * struct rkisp1_cif_isp_af_stat - statistics auto focus data
 769 *
 770 * @window: AF measured value of window x
 771 *
 772 * The module measures the sharpness in 3 windows of selectable size via
 773 * register settings(ISP_AFM_*_A/B/C)
 774 */
 775struct rkisp1_cif_isp_af_stat {
 776        struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
 777} __packed;
 778
 779/**
 780 * struct rkisp1_cif_isp_hist_stat - statistics histogram data
 781 *
 782 * @hist_bins: measured bin counters
 783 *
 784 * Measurement window divided into 25 sub-windows, set
 785 * with ISP_HIST_XXX
 786 */
 787struct rkisp1_cif_isp_hist_stat {
 788        __u16 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
 789} __packed;
 790
 791/**
 792 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Data
 793 *
 794 * @rkisp1_cif_isp_awb_stat: statistics data for automatic white balance
 795 * @rkisp1_cif_isp_ae_stat: statistics data for auto exposure
 796 * @rkisp1_cif_isp_af_stat: statistics data for auto focus
 797 * @rkisp1_cif_isp_hist_stat: statistics histogram data
 798 */
 799struct rkisp1_cif_isp_stat {
 800        struct rkisp1_cif_isp_awb_stat awb;
 801        struct rkisp1_cif_isp_ae_stat ae;
 802        struct rkisp1_cif_isp_af_stat af;
 803        struct rkisp1_cif_isp_hist_stat hist;
 804} __packed;
 805
 806/**
 807 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
 808 *
 809 * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_ definitions)
 810 * @frame_id: frame ID for sync
 811 * @params: statistics data
 812 */
 813struct rkisp1_stat_buffer {
 814        __u32 meas_type;
 815        __u32 frame_id;
 816        struct rkisp1_cif_isp_stat params;
 817} __packed;
 818
 819#endif /* _UAPI_RKISP1_CONFIG_H */
 820