Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */
0002 /*
0003  * Rockchip ISP1 userspace API
0004  * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
0005  */
0006 
0007 #ifndef _UAPI_RKISP1_CONFIG_H
0008 #define _UAPI_RKISP1_CONFIG_H
0009 
0010 #include <linux/types.h>
0011 
0012 /* Defect Pixel Cluster Detection */
0013 #define RKISP1_CIF_ISP_MODULE_DPCC      (1U << 0)
0014 /* Black Level Subtraction */
0015 #define RKISP1_CIF_ISP_MODULE_BLS       (1U << 1)
0016 /* Sensor De-gamma */
0017 #define RKISP1_CIF_ISP_MODULE_SDG       (1U << 2)
0018 /* Histogram statistics configuration */
0019 #define RKISP1_CIF_ISP_MODULE_HST       (1U << 3)
0020 /* Lens Shade Control */
0021 #define RKISP1_CIF_ISP_MODULE_LSC       (1U << 4)
0022 /* Auto White Balance Gain */
0023 #define RKISP1_CIF_ISP_MODULE_AWB_GAIN      (1U << 5)
0024 /* Filter */
0025 #define RKISP1_CIF_ISP_MODULE_FLT       (1U << 6)
0026 /* Bayer Demosaic */
0027 #define RKISP1_CIF_ISP_MODULE_BDM       (1U << 7)
0028 /* Cross Talk */
0029 #define RKISP1_CIF_ISP_MODULE_CTK       (1U << 8)
0030 /* Gamma Out Curve */
0031 #define RKISP1_CIF_ISP_MODULE_GOC       (1U << 9)
0032 /* Color Processing */
0033 #define RKISP1_CIF_ISP_MODULE_CPROC     (1U << 10)
0034 /* Auto Focus Control statistics configuration */
0035 #define RKISP1_CIF_ISP_MODULE_AFC       (1U << 11)
0036 /* Auto White Balancing statistics configuration */
0037 #define RKISP1_CIF_ISP_MODULE_AWB       (1U << 12)
0038 /* Image Effect */
0039 #define RKISP1_CIF_ISP_MODULE_IE        (1U << 13)
0040 /* Auto Exposure Control statistics configuration */
0041 #define RKISP1_CIF_ISP_MODULE_AEC       (1U << 14)
0042 /* Wide Dynamic Range */
0043 #define RKISP1_CIF_ISP_MODULE_WDR       (1U << 15)
0044 /* Denoise Pre-Filter */
0045 #define RKISP1_CIF_ISP_MODULE_DPF       (1U << 16)
0046 /* Denoise Pre-Filter Strength */
0047 #define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH  (1U << 17)
0048 
0049 #define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100
0050 #define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800
0051 
0052 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V10      25
0053 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V12      81
0054 #define RKISP1_CIF_ISP_AE_MEAN_MAX      RKISP1_CIF_ISP_AE_MEAN_MAX_V12
0055 
0056 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10   16
0057 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12   32
0058 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX       RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
0059 
0060 #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3
0061 #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17
0062 
0063 #define RKISP1_CIF_ISP_BDM_MAX_TH               0xff
0064 
0065 /*
0066  * Black level compensation
0067  */
0068 /* maximum value for horizontal start address */
0069 #define RKISP1_CIF_ISP_BLS_START_H_MAX             0x00000fff
0070 /* maximum value for horizontal stop address */
0071 #define RKISP1_CIF_ISP_BLS_STOP_H_MAX              0x00000fff
0072 /* maximum value for vertical start address */
0073 #define RKISP1_CIF_ISP_BLS_START_V_MAX             0x00000fff
0074 /* maximum value for vertical stop address */
0075 #define RKISP1_CIF_ISP_BLS_STOP_V_MAX              0x00000fff
0076 /* maximum is 2^18 = 262144*/
0077 #define RKISP1_CIF_ISP_BLS_SAMPLES_MAX             0x00000012
0078 /* maximum value for fixed black level */
0079 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX             0x00000fff
0080 /* minimum value for fixed black level */
0081 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN             0xfffff000
0082 /* 13 bit range (signed)*/
0083 #define RKISP1_CIF_ISP_BLS_FIX_MASK                0x00001fff
0084 
0085 /*
0086  * Automatic white balance measurements
0087  */
0088 #define RKISP1_CIF_ISP_AWB_MAX_GRID                1
0089 #define RKISP1_CIF_ISP_AWB_MAX_FRAMES              7
0090 
0091 /*
0092  * Gamma out
0093  */
0094 /* Maximum number of color samples supported */
0095 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17
0096 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34
0097 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
0098 
0099 /*
0100  * Lens shade correction
0101  */
0102 #define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE        8
0103 
0104 /*
0105  * The following matches the tuning process,
0106  * not the max capabilities of the chip.
0107  */
0108 #define RKISP1_CIF_ISP_LSC_SAMPLES_MAX             17
0109 
0110 /*
0111  * Histogram calculation
0112  */
0113 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25
0114 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
0115 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
0116 
0117 /*
0118  * Defect Pixel Cluster Correction
0119  */
0120 #define RKISP1_CIF_ISP_DPCC_METHODS_MAX       3
0121 
0122 /*
0123  * Denoising pre filter
0124  */
0125 #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS      17
0126 #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS  6
0127 
0128 /*
0129  * Measurement types
0130  */
0131 #define RKISP1_CIF_ISP_STAT_AWB           (1U << 0)
0132 #define RKISP1_CIF_ISP_STAT_AUTOEXP       (1U << 1)
0133 #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
0134 #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
0135 
0136 /**
0137  * enum rkisp1_cif_isp_version - ISP variants
0138  *
0139  * @RKISP1_V10: used at least in rk3288 and rk3399
0140  * @RKISP1_V11: declared in the original vendor code, but not used
0141  * @RKISP1_V12: used at least in rk3326 and px30
0142  * @RKISP1_V13: used at least in rk1808
0143  */
0144 enum rkisp1_cif_isp_version {
0145     RKISP1_V10 = 10,
0146     RKISP1_V11,
0147     RKISP1_V12,
0148     RKISP1_V13,
0149 };
0150 
0151 enum rkisp1_cif_isp_histogram_mode {
0152     RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
0153     RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
0154     RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
0155     RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
0156     RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
0157     RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
0158 };
0159 
0160 enum rkisp1_cif_isp_awb_mode_type {
0161     RKISP1_CIF_ISP_AWB_MODE_MANUAL,
0162     RKISP1_CIF_ISP_AWB_MODE_RGB,
0163     RKISP1_CIF_ISP_AWB_MODE_YCBCR
0164 };
0165 
0166 enum rkisp1_cif_isp_flt_mode {
0167     RKISP1_CIF_ISP_FLT_STATIC_MODE,
0168     RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
0169 };
0170 
0171 /**
0172  * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
0173  * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
0174  * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
0175  */
0176 enum rkisp1_cif_isp_exp_ctrl_autostop {
0177     RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
0178     RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
0179 };
0180 
0181 /**
0182  * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
0183  * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
0184  * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
0185  */
0186 enum rkisp1_cif_isp_exp_meas_mode {
0187     RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
0188     RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
0189 };
0190 
0191 /*---------- PART1: Input Parameters ------------*/
0192 
0193 /**
0194  * struct rkisp1_cif_isp_window -  measurement window.
0195  *
0196  * Measurements are calculated per window inside the frame.
0197  * This struct represents a window for a measurement.
0198  *
0199  * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
0200  * @v_offs: the vertical offset of the window from the top of the frame in pixels.
0201  * @h_size: the horizontal size of the window in pixels
0202  * @v_size: the vertical size of the window in pixels.
0203  */
0204 struct rkisp1_cif_isp_window {
0205     __u16 h_offs;
0206     __u16 v_offs;
0207     __u16 h_size;
0208     __u16 v_size;
0209 };
0210 
0211 /**
0212  * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
0213  *
0214  * The values will be subtracted from the sensor
0215  * values. Therefore a negative value means addition instead of subtraction!
0216  *
0217  * @r: Fixed (signed!) subtraction value for Bayer pattern R
0218  * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
0219  * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
0220  * @b: Fixed (signed!) subtraction value for Bayer pattern B
0221  */
0222 struct rkisp1_cif_isp_bls_fixed_val {
0223     __s16 r;
0224     __s16 gr;
0225     __s16 gb;
0226     __s16 b;
0227 };
0228 
0229 /**
0230  * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
0231  *
0232  * @enable_auto: Automatic mode activated means that the measured values
0233  *       are subtracted. Otherwise the fixed subtraction
0234  *       values will be subtracted.
0235  * @en_windows: enabled window
0236  * @bls_window1: Measurement window 1 size
0237  * @bls_window2: Measurement window 2 size
0238  * @bls_samples: Set amount of measured pixels for each Bayer position
0239  *       (A, B,C and D) to 2^bls_samples.
0240  * @fixed_val: Fixed subtraction values
0241  */
0242 struct rkisp1_cif_isp_bls_config {
0243     __u8 enable_auto;
0244     __u8 en_windows;
0245     struct rkisp1_cif_isp_window bls_window1;
0246     struct rkisp1_cif_isp_window bls_window2;
0247     __u8 bls_samples;
0248     struct rkisp1_cif_isp_bls_fixed_val fixed_val;
0249 };
0250 
0251 /**
0252  * struct rkisp1_cif_isp_dpcc_methods_config - Methods Configuration used by DPCC
0253  *
0254  * Methods Configuration used by Defect Pixel Cluster Correction
0255  *
0256  * @method: Method enable bits
0257  * @line_thresh: Line threshold
0258  * @line_mad_fac: Line MAD factor
0259  * @pg_fac: Peak gradient factor
0260  * @rnd_thresh: Rank Neighbor Difference threshold
0261  * @rg_fac: Rank gradient factor
0262  */
0263 struct rkisp1_cif_isp_dpcc_methods_config {
0264     __u32 method;
0265     __u32 line_thresh;
0266     __u32 line_mad_fac;
0267     __u32 pg_fac;
0268     __u32 rnd_thresh;
0269     __u32 rg_fac;
0270 };
0271 
0272 /**
0273  * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
0274  *
0275  * Configuration used by Defect Pixel Cluster Correction
0276  *
0277  * @mode: dpcc output mode
0278  * @output_mode: whether use hard coded methods
0279  * @set_use: stage1 methods set
0280  * @methods: methods config
0281  * @ro_limits: rank order limits
0282  * @rnd_offs: differential rank offsets for rank neighbor difference
0283  */
0284 struct rkisp1_cif_isp_dpcc_config {
0285     __u32 mode;
0286     __u32 output_mode;
0287     __u32 set_use;
0288     struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
0289     __u32 ro_limits;
0290     __u32 rnd_offs;
0291 };
0292 
0293 /**
0294  * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
0295  *
0296  * The reset values define a linear curve which has the same effect as bypass. Reset values are:
0297  * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
0298  *
0299  * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
0300  */
0301 struct rkisp1_cif_isp_gamma_corr_curve {
0302     __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
0303 };
0304 
0305 /**
0306  * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
0307  *      (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
0308  *      higher samples (9-16). The reset values for both fields is 0x44444444. This means
0309  *      that each sample is 4 units away from the previous one on the x-axis.
0310  *
0311  * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
0312  *      Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
0313  * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
0314  *      Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
0315  */
0316 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
0317     __u32 gamma_dx0;
0318     __u32 gamma_dx1;
0319 };
0320 
0321 /**
0322  * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
0323  *
0324  * @curve_r: gamma curve point definition axis for red
0325  * @curve_g: gamma curve point definition axis for green
0326  * @curve_b: gamma curve point definition axis for blue
0327  * @xa_pnts: x axis increments
0328  */
0329 struct rkisp1_cif_isp_sdg_config {
0330     struct rkisp1_cif_isp_gamma_corr_curve curve_r;
0331     struct rkisp1_cif_isp_gamma_corr_curve curve_g;
0332     struct rkisp1_cif_isp_gamma_corr_curve curve_b;
0333     struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
0334 };
0335 
0336 /**
0337  * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
0338  *
0339  * @r_data_tbl: sample table red
0340  * @gr_data_tbl: sample table green (red)
0341  * @gb_data_tbl: sample table green (blue)
0342  * @b_data_tbl: sample table blue
0343  * @x_grad_tbl: gradient table x
0344  * @y_grad_tbl: gradient table y
0345  * @x_size_tbl: size table x
0346  * @y_size_tbl: size table y
0347  * @config_width: not used at the moment
0348  * @config_height: not used at the moment
0349  */
0350 struct rkisp1_cif_isp_lsc_config {
0351     __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
0352     __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
0353     __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
0354     __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
0355 
0356     __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
0357     __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
0358 
0359     __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
0360     __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
0361     __u16 config_width;
0362     __u16 config_height;
0363 };
0364 
0365 /**
0366  * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
0367  *
0368  * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
0369  *      V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
0370  *      V4L2_COLORFX_SKETCH,   V4L2_COLORFX_BW,   V4L2_COLORFX_NEGATIVE
0371  * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
0372  *      bits 8:15 - Threshold value of the RGB colors for the color selection effect.
0373  * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
0374  * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
0375  * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
0376  * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
0377  * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
0378  * @eff_tint: Chrominance increment values of tint (used for sepia effect)
0379  */
0380 struct rkisp1_cif_isp_ie_config {
0381     __u16 effect;
0382     __u16 color_sel;
0383     __u16 eff_mat_1;
0384     __u16 eff_mat_2;
0385     __u16 eff_mat_3;
0386     __u16 eff_mat_4;
0387     __u16 eff_mat_5;
0388     __u16 eff_tint;
0389 };
0390 
0391 /**
0392  * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
0393  *
0394  * @c_out_range: Chrominance pixel clipping range at output.
0395  *       (0 for limit, 1 for full)
0396  * @y_in_range: Luminance pixel clipping range at output.
0397  * @y_out_range: Luminance pixel clipping range at output.
0398  * @contrast: 00~ff, 0.0~1.992
0399  * @brightness: 80~7F, -128~+127
0400  * @sat: saturation, 00~FF, 0.0~1.992
0401  * @hue: 80~7F, -90~+87.188
0402  */
0403 struct rkisp1_cif_isp_cproc_config {
0404     __u8 c_out_range;
0405     __u8 y_in_range;
0406     __u8 y_out_range;
0407     __u8 contrast;
0408     __u8 brightness;
0409     __u8 sat;
0410     __u8 hue;
0411 };
0412 
0413 /**
0414  * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
0415  *
0416  * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
0417  * @awb_wnd: white balance measurement window (in pixels)
0418  * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
0419  *     to disable this feature
0420  * @min_y: only pixels values > min_y contribute to awb measurement
0421  * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
0422  *        smaller than threshold for awb measurements
0423  * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
0424  *     each greater than threshold value for awb measurements
0425  * @frames: number of frames - 1 used for mean value calculation
0426  *      (ucFrames=0 means 1 Frame)
0427  * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
0428  * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
0429  * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
0430  */
0431 struct rkisp1_cif_isp_awb_meas_config {
0432     /*
0433      * Note: currently the h and v offsets are mapped to grid offsets
0434      */
0435     struct rkisp1_cif_isp_window awb_wnd;
0436     __u32 awb_mode;
0437     __u8 max_y;
0438     __u8 min_y;
0439     __u8 max_csum;
0440     __u8 min_c;
0441     __u8 frames;
0442     __u8 awb_ref_cr;
0443     __u8 awb_ref_cb;
0444     __u8 enable_ymax_cmp;
0445 };
0446 
0447 /**
0448  * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
0449  *
0450  * All fields in this struct are 10 bit, where:
0451  * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
0452  *
0453  * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
0454  *
0455  * @gain_red: gain value for red component.
0456  * @gain_green_r: gain value for green component in red line.
0457  * @gain_blue: gain value for blue component.
0458  * @gain_green_b: gain value for green component in blue line.
0459  */
0460 struct rkisp1_cif_isp_awb_gain_config {
0461     __u16 gain_red;
0462     __u16 gain_green_r;
0463     __u16 gain_blue;
0464     __u16 gain_green_b;
0465 };
0466 
0467 /**
0468  * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
0469  *
0470  * All 4 threshold fields (thresh_*) are 10 bits.
0471  * All 6 factor fields (fac_*) are 6 bits.
0472  *
0473  * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
0474  * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
0475  * @chr_h_mode: Chroma filter horizontal mode
0476  * @chr_v_mode: Chroma filter vertical mode
0477  * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
0478  * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
0479  * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
0480  * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
0481  * @lum_weight: Parameters for luminance weight function.
0482  * @fac_sh1: filter factor for sharp1 level
0483  * @fac_sh0: filter factor for sharp0 level
0484  * @fac_mid: filter factor for mid level and for static filter mode
0485  * @fac_bl0: filter factor for blur 0 level
0486  * @fac_bl1: filter factor for blur 1 level (max blur)
0487  */
0488 struct rkisp1_cif_isp_flt_config {
0489     __u32 mode;
0490     __u8 grn_stage1;
0491     __u8 chr_h_mode;
0492     __u8 chr_v_mode;
0493     __u32 thresh_bl0;
0494     __u32 thresh_bl1;
0495     __u32 thresh_sh0;
0496     __u32 thresh_sh1;
0497     __u32 lum_weight;
0498     __u32 fac_sh1;
0499     __u32 fac_sh0;
0500     __u32 fac_mid;
0501     __u32 fac_bl0;
0502     __u32 fac_bl1;
0503 };
0504 
0505 /**
0506  * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
0507  *
0508  * @demosaic_th: threshold for bayer demosaicing texture detection
0509  */
0510 struct rkisp1_cif_isp_bdm_config {
0511     __u8 demosaic_th;
0512 };
0513 
0514 /**
0515  * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
0516  *
0517  * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
0518  *      and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
0519  *      represented by 0x000 and a coefficient value of 1 as 0x080.
0520  * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
0521  */
0522 struct rkisp1_cif_isp_ctk_config {
0523     __u16 coeff[3][3];
0524     __u16 ct_offset[3];
0525 };
0526 
0527 enum rkisp1_cif_isp_goc_mode {
0528     RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
0529     RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
0530 };
0531 
0532 /**
0533  * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
0534  *
0535  * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
0536  * @gamma_y: gamma out curve y-axis for all color components
0537  *
0538  * The number of entries of @gamma_y depends on the hardware revision
0539  * as is reported by the hw_revision field of the struct media_device_info
0540  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
0541  *
0542  * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
0543  * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
0544  * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
0545  * of the two.
0546  */
0547 struct rkisp1_cif_isp_goc_config {
0548     __u32 mode;
0549     __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
0550 };
0551 
0552 /**
0553  * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
0554  *
0555  * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
0556  * @histogram_predivider: process every stepsize pixel, all other pixels are
0557  *            skipped
0558  * @meas_window: coordinates of the measure window
0559  * @hist_weight: weighting factor for sub-windows
0560  *
0561  * The number of entries of @hist_weight depends on the hardware revision
0562  * as is reported by the hw_revision field of the struct media_device_info
0563  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
0564  *
0565  * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
0566  * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
0567  * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
0568  * of the two.
0569  */
0570 struct rkisp1_cif_isp_hst_config {
0571     __u32 mode;
0572     __u8 histogram_predivider;
0573     struct rkisp1_cif_isp_window meas_window;
0574     __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
0575 };
0576 
0577 /**
0578  * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
0579  *
0580  * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
0581  * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
0582  * @meas_window: coordinates of the measure window
0583  */
0584 struct rkisp1_cif_isp_aec_config {
0585     __u32 mode;
0586     __u32 autostop;
0587     struct rkisp1_cif_isp_window meas_window;
0588 };
0589 
0590 /**
0591  * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
0592  *
0593  * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
0594  * @afm_win: coordinates of the meas window
0595  * @thres: threshold used for minimizing the influence of noise
0596  * @var_shift: the number of bits for the shift operation at the end of the
0597  *         calculation chain.
0598  */
0599 struct rkisp1_cif_isp_afc_config {
0600     __u8 num_afm_win;
0601     struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
0602     __u32 thres;
0603     __u32 var_shift;
0604 };
0605 
0606 /**
0607  * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
0608  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
0609  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
0610  *                  registers DPF_NF_GAIN_R, ...
0611  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS:  use only the gains from LSC module
0612  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
0613  *                  gains from LSC module
0614  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
0615  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
0616  * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
0617  */
0618 enum rkisp1_cif_isp_dpf_gain_usage {
0619     RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
0620     RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
0621     RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
0622     RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
0623     RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
0624     RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
0625     RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
0626 };
0627 
0628 /**
0629  * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
0630  * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
0631  *                 (means 7x5 active pixel)
0632  * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
0633  *                 (means 5x5 active pixel)
0634  */
0635 enum rkisp1_cif_isp_dpf_rb_filtersize {
0636     RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
0637     RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
0638 };
0639 
0640 /**
0641  * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
0642  * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
0643  * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
0644  */
0645 enum rkisp1_cif_isp_dpf_nll_scale_mode {
0646     RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
0647     RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
0648 };
0649 
0650 /**
0651  * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
0652  *
0653  * @coeff: Noise level Lookup coefficient
0654  * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
0655  */
0656 struct rkisp1_cif_isp_dpf_nll {
0657     __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
0658     __u32 scale_mode;
0659 };
0660 
0661 /**
0662  * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
0663  *
0664  * @fltsize: The filter size for the red and blue pixels
0665  *       (from enum rkisp1_cif_isp_dpf_rb_filtersize)
0666  * @spatial_coeff: Spatial weights
0667  * @r_enable: enable filter processing for red pixels
0668  * @b_enable: enable filter processing for blue pixels
0669  */
0670 struct rkisp1_cif_isp_dpf_rb_flt {
0671     __u32 fltsize;
0672     __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
0673     __u8 r_enable;
0674     __u8 b_enable;
0675 };
0676 
0677 /**
0678  * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
0679  *
0680  * @spatial_coeff: Spatial weights
0681  * @gr_enable: enable filter processing for green pixels in green/red lines
0682  * @gb_enable: enable filter processing for green pixels in green/blue lines
0683  */
0684 struct rkisp1_cif_isp_dpf_g_flt {
0685     __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
0686     __u8 gr_enable;
0687     __u8 gb_enable;
0688 };
0689 
0690 /**
0691  * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
0692  *
0693  * @mode: dpf gain usage  (from enum rkisp1_cif_isp_dpf_gain_usage)
0694  * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
0695  * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
0696  * @nf_gr_gain: Noise function Gain that replaces the AWB gain
0697  *      for green pixels in a red line
0698  * @nf_gb_gain: Noise function Gain that replaces the AWB gain
0699  *      for green pixels in a blue line
0700  */
0701 struct rkisp1_cif_isp_dpf_gain {
0702     __u32 mode;
0703     __u16 nf_r_gain;
0704     __u16 nf_b_gain;
0705     __u16 nf_gr_gain;
0706     __u16 nf_gb_gain;
0707 };
0708 
0709 /**
0710  * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
0711  *
0712  * @gain: noise function gain
0713  * @g_flt: green filter config
0714  * @rb_flt: red blue filter config
0715  * @nll: noise level lookup
0716  */
0717 struct rkisp1_cif_isp_dpf_config {
0718     struct rkisp1_cif_isp_dpf_gain gain;
0719     struct rkisp1_cif_isp_dpf_g_flt g_flt;
0720     struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
0721     struct rkisp1_cif_isp_dpf_nll nll;
0722 };
0723 
0724 /**
0725  * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
0726  *
0727  * @r: filter strength of the RED filter
0728  * @g: filter strength of the GREEN filter
0729  * @b: filter strength of the BLUE filter
0730  */
0731 struct rkisp1_cif_isp_dpf_strength_config {
0732     __u8 r;
0733     __u8 g;
0734     __u8 b;
0735 };
0736 
0737 /**
0738  * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
0739  *
0740  * @dpcc_config: Defect Pixel Cluster Correction config
0741  * @bls_config: Black Level Subtraction config
0742  * @sdg_config: sensor degamma config
0743  * @lsc_config: Lens Shade config
0744  * @awb_gain_config: Auto White balance gain config
0745  * @flt_config: filter config
0746  * @bdm_config: demosaic config
0747  * @ctk_config: cross talk config
0748  * @goc_config: gamma out config
0749  * @bls_config: black level subtraction config
0750  * @dpf_config: De-noising pre-filter config
0751  * @dpf_strength_config: dpf strength config
0752  * @cproc_config: color process config
0753  * @ie_config: image effects config
0754  */
0755 struct rkisp1_cif_isp_isp_other_cfg {
0756     struct rkisp1_cif_isp_dpcc_config dpcc_config;
0757     struct rkisp1_cif_isp_bls_config bls_config;
0758     struct rkisp1_cif_isp_sdg_config sdg_config;
0759     struct rkisp1_cif_isp_lsc_config lsc_config;
0760     struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
0761     struct rkisp1_cif_isp_flt_config flt_config;
0762     struct rkisp1_cif_isp_bdm_config bdm_config;
0763     struct rkisp1_cif_isp_ctk_config ctk_config;
0764     struct rkisp1_cif_isp_goc_config goc_config;
0765     struct rkisp1_cif_isp_dpf_config dpf_config;
0766     struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
0767     struct rkisp1_cif_isp_cproc_config cproc_config;
0768     struct rkisp1_cif_isp_ie_config ie_config;
0769 };
0770 
0771 /**
0772  * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
0773  *
0774  * @awb_meas_config: auto white balance config
0775  * @hst_config: histogram config
0776  * @aec_config: auto exposure config
0777  * @afc_config: auto focus config
0778  */
0779 struct rkisp1_cif_isp_isp_meas_cfg {
0780     struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
0781     struct rkisp1_cif_isp_hst_config hst_config;
0782     struct rkisp1_cif_isp_aec_config aec_config;
0783     struct rkisp1_cif_isp_afc_config afc_config;
0784 };
0785 
0786 /**
0787  * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
0788  *
0789  * @module_en_update: mask the enable bits of which module should be updated
0790  * @module_ens: mask the enable value of each module, only update the module
0791  *      which correspond bit was set in module_en_update
0792  * @module_cfg_update: mask the config bits of which module should be updated
0793  * @meas: measurement config
0794  * @others: other config
0795  */
0796 struct rkisp1_params_cfg {
0797     __u32 module_en_update;
0798     __u32 module_ens;
0799     __u32 module_cfg_update;
0800 
0801     struct rkisp1_cif_isp_isp_meas_cfg meas;
0802     struct rkisp1_cif_isp_isp_other_cfg others;
0803 };
0804 
0805 /*---------- PART2: Measurement Statistics ------------*/
0806 
0807 /**
0808  * struct rkisp1_cif_isp_awb_meas - AWB measured values
0809  *
0810  * @cnt: White pixel count, number of "white pixels" found during last
0811  *   measurement
0812  * @mean_y_or_g: Mean value of Y within window and frames,
0813  *       Green if RGB is selected.
0814  * @mean_cb_or_b: Mean value of Cb within window and frames,
0815  *        Blue if RGB is selected.
0816  * @mean_cr_or_r: Mean value of Cr within window and frames,
0817  *        Red if RGB is selected.
0818  */
0819 struct rkisp1_cif_isp_awb_meas {
0820     __u32 cnt;
0821     __u8 mean_y_or_g;
0822     __u8 mean_cb_or_b;
0823     __u8 mean_cr_or_r;
0824 };
0825 
0826 /**
0827  * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
0828  *
0829  * @awb_mean: Mean measured data
0830  */
0831 struct rkisp1_cif_isp_awb_stat {
0832     struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
0833 };
0834 
0835 /**
0836  * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
0837  *
0838  * @meas_r: Mean measured value for Bayer pattern R
0839  * @meas_gr: Mean measured value for Bayer pattern Gr
0840  * @meas_gb: Mean measured value for Bayer pattern Gb
0841  * @meas_b: Mean measured value for Bayer pattern B
0842  */
0843 struct rkisp1_cif_isp_bls_meas_val {
0844     __u16 meas_r;
0845     __u16 meas_gr;
0846     __u16 meas_gb;
0847     __u16 meas_b;
0848 };
0849 
0850 /**
0851  * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
0852  *
0853  * @exp_mean: Mean luminance value of block xx
0854  * @bls_val:  BLS measured values
0855  *
0856  * The number of entries of @exp_mean depends on the hardware revision
0857  * as is reported by the hw_revision field of the struct media_device_info
0858  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
0859  *
0860  * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
0861  * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
0862  * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
0863  *
0864  * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
0865  */
0866 struct rkisp1_cif_isp_ae_stat {
0867     __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
0868     struct rkisp1_cif_isp_bls_meas_val bls_val;
0869 };
0870 
0871 /**
0872  * struct rkisp1_cif_isp_af_meas_val - AF measured values
0873  *
0874  * @sum: sharpness value
0875  * @lum: luminance value
0876  */
0877 struct rkisp1_cif_isp_af_meas_val {
0878     __u32 sum;
0879     __u32 lum;
0880 };
0881 
0882 /**
0883  * struct rkisp1_cif_isp_af_stat - statistics auto focus data
0884  *
0885  * @window: AF measured value of window x
0886  *
0887  * The module measures the sharpness in 3 windows of selectable size via
0888  * register settings(ISP_AFM_*_A/B/C)
0889  */
0890 struct rkisp1_cif_isp_af_stat {
0891     struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
0892 };
0893 
0894 /**
0895  * struct rkisp1_cif_isp_hist_stat - statistics histogram data
0896  *
0897  * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
0898  *         type. Bits 0-4 are the fractional part and bits 5-19 are the
0899  *         integer part.
0900  *
0901  * The window of the measurements area is divided to 5x5 sub-windows for
0902  * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
0903  * each sub-window independently and the final result is a weighted average of
0904  * the histogram measurements on all sub-windows. The window of the
0905  * measurements area and the weight of each sub-window are configurable using
0906  * struct @rkisp1_cif_isp_hst_config.
0907  *
0908  * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
0909  *
0910  * The number of entries of @hist_bins depends on the hardware revision
0911  * as is reported by the hw_revision field of the struct media_device_info
0912  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
0913  *
0914  * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
0915  * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
0916  * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
0917  */
0918 struct rkisp1_cif_isp_hist_stat {
0919     __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
0920 };
0921 
0922 /**
0923  * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
0924  *
0925  * @awb: statistics data for automatic white balance
0926  * @ae: statistics data for auto exposure
0927  * @af: statistics data for auto focus
0928  * @hist: statistics histogram data
0929  */
0930 struct rkisp1_cif_isp_stat {
0931     struct rkisp1_cif_isp_awb_stat awb;
0932     struct rkisp1_cif_isp_ae_stat ae;
0933     struct rkisp1_cif_isp_af_stat af;
0934     struct rkisp1_cif_isp_hist_stat hist;
0935 };
0936 
0937 /**
0938  * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
0939  *
0940  * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
0941  * @frame_id: frame ID for sync
0942  * @params: statistics data
0943  */
0944 struct rkisp1_stat_buffer {
0945     __u32 meas_type;
0946     __u32 frame_id;
0947     struct rkisp1_cif_isp_stat params;
0948 };
0949 
0950 #endif /* _UAPI_RKISP1_CONFIG_H */