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