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