1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /* Copyright (C) 2017 - 2018 Intel Corporation */
3 
4 #ifndef __IPU3_UAPI_H
5 #define __IPU3_UAPI_H
6 
7 #include <linux/types.h>
8 
9 /* from /drivers/staging/media/ipu3/include/videodev2.h */
10 
11 /* Vendor specific - used for IPU3 camera sub-system */
12 /* IPU3 processing parameters */
13 #define V4L2_META_FMT_IPU3_PARAMS	v4l2_fourcc('i', 'p', '3', 'p')
14 /* IPU3 3A statistics */
15 #define V4L2_META_FMT_IPU3_STAT_3A	v4l2_fourcc('i', 'p', '3', 's')
16 
17 /* from include/uapi/linux/v4l2-controls.h */
18 #define V4L2_CID_INTEL_IPU3_BASE	(V4L2_CID_USER_BASE + 0x10c0)
19 #define V4L2_CID_INTEL_IPU3_MODE	(V4L2_CID_INTEL_IPU3_BASE + 1)
20 
21 /******************* ipu3_uapi_stats_3a *******************/
22 
23 #define IPU3_UAPI_MAX_STRIPES				2
24 #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
25 
26 #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
27 #define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
28 
29 /* controls generation of meta_data (like FF enable/disable) */
30 #define IPU3_UAPI_AWB_RGBS_THR_B_EN			(1 << 14)
31 #define IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT		(1 << 15)
32 
33 /**
34  * struct ipu3_uapi_grid_config - Grid plane config
35  *
36  * @width:	Grid horizontal dimensions, in number of grid blocks(cells).
37  *		For AWB, the range is (16, 80).
38  *		For AF/AE, the range is (16, 32).
39  * @height:	Grid vertical dimensions, in number of grid cells.
40  *		For AWB, the range is (16, 60).
41  *		For AF/AE, the range is (16, 24).
42  * @block_width_log2:	Log2 of the width of each cell in pixels.
43  *			For AWB, the range is [3, 6].
44  *			For AF/AE, the range is [3, 7].
45  * @block_height_log2:	Log2 of the height of each cell in pixels.
46  *			For AWB, the range is [3, 6].
47  *			For AF/AE, the range is [3, 7].
48  * @height_per_slice:	The number of blocks in vertical axis per slice.
49  *			Default 2.
50  * @x_start: X value of top left corner of Region of Interest(ROI).
51  * @y_start: Y value of top left corner of ROI
52  * @x_end: X value of bottom right corner of ROI
53  * @y_end: Y value of bottom right corner of ROI
54  *
55  * Due to the size of total amount of collected data, most statistics
56  * create a grid-based output, and the data is then divided into "slices".
57  */
58 struct ipu3_uapi_grid_config {
59 	__u8 width;
60 	__u8 height;
61 	__u16 block_width_log2:3;
62 	__u16 block_height_log2:3;
63 	__u16 height_per_slice:8;
64 	__u16 x_start;
65 	__u16 y_start;
66 	__u16 x_end;
67 	__u16 y_end;
68 } __packed;
69 
70 /**
71  * struct ipu3_uapi_awb_set_item - Memory layout for each cell in AWB
72  *
73  * @Gr_avg:	Green average for red lines in the cell.
74  * @R_avg:	Red average in the cell.
75  * @B_avg:	Blue average in the cell.
76  * @Gb_avg:	Green average for blue lines in the cell.
77  * @sat_ratio:  Percentage of pixels over the thresholds specified in
78  *		ipu3_uapi_awb_config_s, coded from 0 to 255.
79  * @padding0:   Unused byte for padding.
80  * @padding1:   Unused byte for padding.
81  * @padding2:   Unused byte for padding.
82  */
83 struct ipu3_uapi_awb_set_item {
84 	__u8 Gr_avg;
85 	__u8 R_avg;
86 	__u8 B_avg;
87 	__u8 Gb_avg;
88 	__u8 sat_ratio;
89 	__u8 padding0;
90 	__u8 padding1;
91 	__u8 padding2;
92 } __attribute__((packed));
93 
94 /*
95  * The grid based data is divided into "slices" called set, each slice of setX
96  * refers to ipu3_uapi_grid_config width * height_per_slice.
97  */
98 #define IPU3_UAPI_AWB_MAX_SETS				60
99 /* Based on grid size 80 * 60 and cell size 16 x 16 */
100 #define IPU3_UAPI_AWB_SET_SIZE				160
101 #define IPU3_UAPI_AWB_SPARE_FOR_BUBBLES \
102 	(IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES)
103 #define IPU3_UAPI_AWB_MAX_BUFFER_SIZE \
104 	(IPU3_UAPI_AWB_MAX_SETS * \
105 	 (IPU3_UAPI_AWB_SET_SIZE + IPU3_UAPI_AWB_SPARE_FOR_BUBBLES))
106 
107 /**
108  * struct ipu3_uapi_awb_raw_buffer - AWB raw buffer
109  *
110  * @meta_data: buffer to hold auto white balance meta data which is
111  *		the average values for each color channel.
112  */
113 struct ipu3_uapi_awb_raw_buffer {
114 	struct ipu3_uapi_awb_set_item meta_data[IPU3_UAPI_AWB_MAX_BUFFER_SIZE]
115 		__attribute__((aligned(32)));
116 } __packed;
117 
118 /**
119  * struct ipu3_uapi_awb_config_s - AWB config
120  *
121  * @rgbs_thr_gr: gr threshold value.
122  * @rgbs_thr_r: Red threshold value.
123  * @rgbs_thr_gb: gb threshold value.
124  * @rgbs_thr_b: Blue threshold value.
125  * @grid: &ipu3_uapi_grid_config, the default grid resolution is 16x16 cells.
126  *
127  * The threshold is a saturation measure range [0, 8191], 8191 is default.
128  * Values over threshold may be optionally rejected for averaging.
129  */
130 struct ipu3_uapi_awb_config_s {
131 	__u16 rgbs_thr_gr;
132 	__u16 rgbs_thr_r;
133 	__u16 rgbs_thr_gb;
134 	__u16 rgbs_thr_b;
135 	struct ipu3_uapi_grid_config grid;
136 } __attribute__((aligned(32))) __packed;
137 
138 /**
139  * struct ipu3_uapi_awb_config - AWB config wrapper
140  *
141  * @config: config for auto white balance as defined by &ipu3_uapi_awb_config_s
142  */
143 struct ipu3_uapi_awb_config {
144 	struct ipu3_uapi_awb_config_s config __attribute__((aligned(32)));
145 } __packed;
146 
147 #define IPU3_UAPI_AE_COLORS				4	/* R, G, B, Y */
148 #define IPU3_UAPI_AE_BINS				256
149 #define IPU3_UAPI_AE_WEIGHTS				96
150 
151 /**
152  * struct ipu3_uapi_ae_raw_buffer - AE global weighted histogram
153  *
154  * @vals: Sum of IPU3_UAPI_AE_COLORS in cell
155  *
156  * Each histogram contains IPU3_UAPI_AE_BINS bins. Each bin has 24 bit unsigned
157  * for counting the number of the pixel.
158  */
159 struct ipu3_uapi_ae_raw_buffer {
160 	__u32 vals[IPU3_UAPI_AE_BINS * IPU3_UAPI_AE_COLORS];
161 } __packed;
162 
163 /**
164  * struct ipu3_uapi_ae_raw_buffer_aligned - AE raw buffer
165  *
166  * @buff: &ipu3_uapi_ae_raw_buffer to hold full frame meta data.
167  */
168 struct ipu3_uapi_ae_raw_buffer_aligned {
169 	struct ipu3_uapi_ae_raw_buffer buff __attribute__((aligned(32)));
170 } __packed;
171 
172 /**
173  * struct ipu3_uapi_ae_grid_config - AE weight grid
174  *
175  * @width: Grid horizontal dimensions. Value: [16, 32], default 16.
176  * @height: Grid vertical dimensions. Value: [16, 24], default 16.
177  * @block_width_log2: Log2 of the width of the grid cell, value: [3, 7].
178  * @block_height_log2: Log2 of the height of the grid cell, value: [3, 7].
179  *			default is 3 (cell size 8x8), 4 cell per grid.
180  * @reserved0: reserved
181  * @ae_en: 0: does not write to &ipu3_uapi_ae_raw_buffer_aligned array,
182  *		1: write normally.
183  * @rst_hist_array: write 1 to trigger histogram array reset.
184  * @done_rst_hist_array: flag for histogram array reset done.
185  * @x_start: X value of top left corner of ROI, default 0.
186  * @y_start: Y value of top left corner of ROI, default 0.
187  * @x_end: X value of bottom right corner of ROI
188  * @y_end: Y value of bottom right corner of ROI
189  *
190  * The AE block accumulates 4 global weighted histograms(R, G, B, Y) over
191  * a defined ROI within the frame. The contribution of each pixel into the
192  * histogram, defined by &ipu3_uapi_ae_weight_elem LUT, is indexed by a grid.
193  */
194 struct ipu3_uapi_ae_grid_config {
195 	__u8 width;
196 	__u8 height;
197 	__u8 block_width_log2:4;
198 	__u8 block_height_log2:4;
199 	__u8 reserved0:5;
200 	__u8 ae_en:1;
201 	__u8 rst_hist_array:1;
202 	__u8 done_rst_hist_array:1;
203 	__u16 x_start;
204 	__u16 y_start;
205 	__u16 x_end;
206 	__u16 y_end;
207 } __packed;
208 
209 /**
210  * struct ipu3_uapi_ae_weight_elem - AE weights LUT
211  *
212  * @cell0: weighted histogram grid value.
213  * @cell1: weighted histogram grid value.
214  * @cell2: weighted histogram grid value.
215  * @cell3: weighted histogram grid value.
216  * @cell4: weighted histogram grid value.
217  * @cell5: weighted histogram grid value.
218  * @cell6: weighted histogram grid value.
219  * @cell7: weighted histogram grid value.
220  *
221  * Use weighted grid value to give a different contribution factor to each cell.
222  * Precision u4, range [0, 15].
223  */
224 struct ipu3_uapi_ae_weight_elem {
225 	__u32 cell0:4;
226 	__u32 cell1:4;
227 	__u32 cell2:4;
228 	__u32 cell3:4;
229 	__u32 cell4:4;
230 	__u32 cell5:4;
231 	__u32 cell6:4;
232 	__u32 cell7:4;
233 } __packed;
234 
235 /**
236  * struct ipu3_uapi_ae_ccm - AE coefficients for WB and CCM
237  *
238  * @gain_gr: WB gain factor for the gr channels. Default 256.
239  * @gain_r: WB gain factor for the r channel. Default 256.
240  * @gain_b: WB gain factor for the b channel. Default 256.
241  * @gain_gb: WB gain factor for the gb channels. Default 256.
242  * @mat: 4x4 matrix that transforms Bayer quad output from WB to RGB+Y.
243  *
244  * Default:
245  *	128, 0, 0, 0,
246  *	0, 128, 0, 0,
247  *	0, 0, 128, 0,
248  *	0, 0, 0, 128,
249  *
250  * As part of the raw frame pre-process stage, the WB and color conversion need
251  * to be applied to expose the impact of these gain operations.
252  */
253 struct ipu3_uapi_ae_ccm {
254 	__u16 gain_gr;
255 	__u16 gain_r;
256 	__u16 gain_b;
257 	__u16 gain_gb;
258 	__s16 mat[16];
259 } __packed;
260 
261 /**
262  * struct ipu3_uapi_ae_config - AE config
263  *
264  * @grid_cfg:	config for auto exposure statistics grid. See struct
265  *		&ipu3_uapi_ae_grid_config, as Imgu did not support output
266  *		auto exposure statistics, so user can ignore this configuration
267  *		and use the RGB table in auto-whitebalance statistics instead.
268  * @weights:	&IPU3_UAPI_AE_WEIGHTS is based on 32x24 blocks in the grid.
269  *		Each grid cell has a corresponding value in weights LUT called
270  *		grid value, global histogram is updated based on grid value and
271  *		pixel value.
272  * @ae_ccm:	Color convert matrix pre-processing block.
273  *
274  * Calculate AE grid from image resolution, resample ae weights.
275  */
276 struct ipu3_uapi_ae_config {
277 	struct ipu3_uapi_ae_grid_config grid_cfg __attribute__((aligned(32)));
278 	struct ipu3_uapi_ae_weight_elem weights[IPU3_UAPI_AE_WEIGHTS]
279 						__attribute__((aligned(32)));
280 	struct ipu3_uapi_ae_ccm ae_ccm __attribute__((aligned(32)));
281 } __packed;
282 
283 /**
284  * struct ipu3_uapi_af_filter_config - AF 2D filter for contrast measurements
285  *
286  * @y1_coeff_0:	filter Y1, structure: 3x11, support both symmetry and
287  *		anti-symmetry type. A12 is center, A1-A11 are neighbours.
288  *		for analyzing low frequency content, used to calculate sum
289  *		of gradients in x direction.
290  * @y1_coeff_0.a1:	filter1 coefficients A1, u8, default 0.
291  * @y1_coeff_0.a2:	filter1 coefficients A2, u8, default 0.
292  * @y1_coeff_0.a3:	filter1 coefficients A3, u8, default 0.
293  * @y1_coeff_0.a4:	filter1 coefficients A4, u8, default 0.
294  * @y1_coeff_1:		Struct
295  * @y1_coeff_1.a5:	filter1 coefficients A5, u8, default 0.
296  * @y1_coeff_1.a6:	filter1 coefficients A6, u8, default 0.
297  * @y1_coeff_1.a7:	filter1 coefficients A7, u8, default 0.
298  * @y1_coeff_1.a8:	filter1 coefficients A8, u8, default 0.
299  * @y1_coeff_2:		Struct
300  * @y1_coeff_2.a9:	filter1 coefficients A9, u8, default 0.
301  * @y1_coeff_2.a10:	filter1 coefficients A10, u8, default 0.
302  * @y1_coeff_2.a11:	filter1 coefficients A11, u8, default 0.
303  * @y1_coeff_2.a12:	filter1 coefficients A12, u8, default 128.
304  * @y1_sign_vec:	Each bit corresponds to one coefficient sign bit,
305  *			0: positive, 1: negative, default 0.
306  * @y2_coeff_0:	Y2, same structure as Y1. For analyzing high frequency content.
307  * @y2_coeff_0.a1:	filter2 coefficients A1, u8, default 0.
308  * @y2_coeff_0.a2:	filter2 coefficients A2, u8, default 0.
309  * @y2_coeff_0.a3:	filter2 coefficients A3, u8, default 0.
310  * @y2_coeff_0.a4:	filter2 coefficients A4, u8, default 0.
311  * @y2_coeff_1:	Struct
312  * @y2_coeff_1.a5:	filter2 coefficients A5, u8, default 0.
313  * @y2_coeff_1.a6:	filter2 coefficients A6, u8, default 0.
314  * @y2_coeff_1.a7:	filter2 coefficients A7, u8, default 0.
315  * @y2_coeff_1.a8:	filter2 coefficients A8, u8, default 0.
316  * @y2_coeff_2:	Struct
317  * @y2_coeff_2.a9:	filter1 coefficients A9, u8, default 0.
318  * @y2_coeff_2.a10:	filter1 coefficients A10, u8, default 0.
319  * @y2_coeff_2.a11:	filter1 coefficients A11, u8, default 0.
320  * @y2_coeff_2.a12:	filter1 coefficients A12, u8, default 128.
321  * @y2_sign_vec:	Each bit corresponds to one coefficient sign bit,
322  *			0: positive, 1: negative, default 0.
323  * @y_calc:	Pre-processing that converts Bayer quad to RGB+Y values to be
324  *		used for building histogram. Range [0, 32], default 8.
325  * Rule:
326  *		y_gen_rate_gr + y_gen_rate_r + y_gen_rate_b + y_gen_rate_gb = 32
327  *		A single Y is calculated based on sum of Gr/R/B/Gb based on
328  *		their contribution ratio.
329  * @y_calc.y_gen_rate_gr:	Contribution ratio Gr for Y
330  * @y_calc.y_gen_rate_r:	Contribution ratio R for Y
331  * @y_calc.y_gen_rate_b:	Contribution ratio B for Y
332  * @y_calc.y_gen_rate_gb:	Contribution ratio Gb for Y
333  * @nf:	The shift right value that should be applied during the Y1/Y2 filter to
334  *	make sure the total memory needed is 2 bytes per grid cell.
335  * @nf.reserved0:	reserved
336  * @nf.y1_nf:	Normalization factor for the convolution coeffs of y1,
337  *		should be log2 of the sum of the abs values of the filter
338  *		coeffs, default 7 (2^7 = 128).
339  * @nf.reserved1:	reserved
340  * @nf.y2_nf:	Normalization factor for y2, should be log2 of the sum of the
341  *		abs values of the filter coeffs.
342  * @nf.reserved2:	reserved
343  */
344 struct ipu3_uapi_af_filter_config {
345 	struct {
346 		__u8 a1;
347 		__u8 a2;
348 		__u8 a3;
349 		__u8 a4;
350 	} y1_coeff_0;
351 	struct {
352 		__u8 a5;
353 		__u8 a6;
354 		__u8 a7;
355 		__u8 a8;
356 	} y1_coeff_1;
357 	struct {
358 		__u8 a9;
359 		__u8 a10;
360 		__u8 a11;
361 		__u8 a12;
362 	} y1_coeff_2;
363 
364 	__u32 y1_sign_vec;
365 
366 	struct {
367 		__u8 a1;
368 		__u8 a2;
369 		__u8 a3;
370 		__u8 a4;
371 	} y2_coeff_0;
372 	struct {
373 		__u8 a5;
374 		__u8 a6;
375 		__u8 a7;
376 		__u8 a8;
377 	} y2_coeff_1;
378 	struct {
379 		__u8 a9;
380 		__u8 a10;
381 		__u8 a11;
382 		__u8 a12;
383 	} y2_coeff_2;
384 
385 	__u32 y2_sign_vec;
386 
387 	struct {
388 		__u8 y_gen_rate_gr;
389 		__u8 y_gen_rate_r;
390 		__u8 y_gen_rate_b;
391 		__u8 y_gen_rate_gb;
392 	} y_calc;
393 
394 	struct {
395 		__u32 reserved0:8;
396 		__u32 y1_nf:4;
397 		__u32 reserved1:4;
398 		__u32 y2_nf:4;
399 		__u32 reserved2:12;
400 	} nf;
401 } __packed;
402 
403 #define IPU3_UAPI_AF_MAX_SETS				24
404 #define IPU3_UAPI_AF_MD_ITEM_SIZE			4
405 #define IPU3_UAPI_AF_SPARE_FOR_BUBBLES \
406 	(IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES * \
407 	 IPU3_UAPI_AF_MD_ITEM_SIZE)
408 #define IPU3_UAPI_AF_Y_TABLE_SET_SIZE			128
409 #define IPU3_UAPI_AF_Y_TABLE_MAX_SIZE \
410 	(IPU3_UAPI_AF_MAX_SETS * \
411 	 (IPU3_UAPI_AF_Y_TABLE_SET_SIZE + IPU3_UAPI_AF_SPARE_FOR_BUBBLES) * \
412 	 IPU3_UAPI_MAX_STRIPES)
413 
414 /**
415  * struct ipu3_uapi_af_raw_buffer - AF meta data
416  *
417  * @y_table:	Each color component will be convolved separately with filter1
418  *		and filter2 and the result will be summed out and averaged for
419  *		each cell.
420  */
421 struct ipu3_uapi_af_raw_buffer {
422 	__u8 y_table[IPU3_UAPI_AF_Y_TABLE_MAX_SIZE] __attribute__((aligned(32)));
423 } __packed;
424 
425 /**
426  * struct ipu3_uapi_af_config_s - AF config
427  *
428  * @filter_config: AF uses Y1 and Y2 filters as configured in
429  *		   &ipu3_uapi_af_filter_config
430  * @padding: paddings
431  * @grid_cfg: See &ipu3_uapi_grid_config, default resolution 16x16. Use large
432  *	      grid size for large image and vice versa.
433  */
434 struct ipu3_uapi_af_config_s {
435 	struct ipu3_uapi_af_filter_config filter_config __attribute__((aligned(32)));
436 	__u8 padding[4];
437 	struct ipu3_uapi_grid_config grid_cfg __attribute__((aligned(32)));
438 } __packed;
439 
440 #define IPU3_UAPI_AWB_FR_MAX_SETS			24
441 #define IPU3_UAPI_AWB_FR_MD_ITEM_SIZE			8
442 #define IPU3_UAPI_AWB_FR_BAYER_TBL_SIZE			256
443 #define IPU3_UAPI_AWB_FR_SPARE_FOR_BUBBLES \
444 	(IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES * \
445 	 IPU3_UAPI_AWB_FR_MD_ITEM_SIZE)
446 #define IPU3_UAPI_AWB_FR_BAYER_TABLE_MAX_SIZE \
447 	(IPU3_UAPI_AWB_FR_MAX_SETS * \
448 	(IPU3_UAPI_AWB_FR_BAYER_TBL_SIZE + \
449 	 IPU3_UAPI_AWB_FR_SPARE_FOR_BUBBLES) * IPU3_UAPI_MAX_STRIPES)
450 
451 /**
452  * struct ipu3_uapi_awb_fr_raw_buffer - AWB filter response meta data
453  *
454  * @meta_data: Statistics output on the grid after convolving with 1D filter.
455  */
456 struct ipu3_uapi_awb_fr_raw_buffer {
457 	__u8 meta_data[IPU3_UAPI_AWB_FR_BAYER_TABLE_MAX_SIZE]
458 		__attribute__((aligned(32)));
459 } __packed;
460 
461 /**
462  * struct ipu3_uapi_awb_fr_config_s - AWB filter response config
463  *
464  * @grid_cfg:	grid config, default 16x16.
465  * @bayer_coeff:	1D Filter 1x11 center symmetry/anti-symmetry.
466  *			coefficients defaults { 0, 0, 0, 0, 0, 128 }.
467  *			Applied on whole image for each Bayer channel separately
468  *			by a weighted sum of its 11x1 neighbors.
469  * @reserved1:	reserved
470  * @bayer_sign:	sign of filter coefficients, default 0.
471  * @bayer_nf:	normalization factor for the convolution coeffs, to make sure
472  *		total memory needed is within pre-determined range.
473  *		NF should be the log2 of the sum of the abs values of the
474  *		filter coeffs, range [7, 14], default 7.
475  * @reserved2:	reserved
476  */
477 struct ipu3_uapi_awb_fr_config_s {
478 	struct ipu3_uapi_grid_config grid_cfg;
479 	__u8 bayer_coeff[6];
480 	__u16 reserved1;
481 	__u32 bayer_sign;
482 	__u8 bayer_nf;
483 	__u8 reserved2[7];
484 } __packed;
485 
486 /**
487  * struct ipu3_uapi_4a_config - 4A config
488  *
489  * @awb_config: &ipu3_uapi_awb_config_s, default resolution 16x16
490  * @ae_grd_config: auto exposure statistics &ipu3_uapi_ae_grid_config
491  * @padding: paddings
492  * @af_config: auto focus config &ipu3_uapi_af_config_s
493  * @awb_fr_config: &ipu3_uapi_awb_fr_config_s, default resolution 16x16
494  */
495 struct ipu3_uapi_4a_config {
496 	struct ipu3_uapi_awb_config_s awb_config __attribute__((aligned(32)));
497 	struct ipu3_uapi_ae_grid_config ae_grd_config;
498 	__u8 padding[20];
499 	struct ipu3_uapi_af_config_s af_config;
500 	struct ipu3_uapi_awb_fr_config_s awb_fr_config
501 		__attribute__((aligned(32)));
502 } __packed;
503 
504 /**
505  * struct ipu3_uapi_bubble_info - Bubble info for host side debugging
506  *
507  * @num_of_stripes: A single frame is divided into several parts called stripes
508  *		    due to limitation on line buffer memory.
509  *		    The separation between the stripes is vertical. Each such
510  *		    stripe is processed as a single frame by the ISP pipe.
511  * @padding: padding bytes.
512  * @num_sets: number of sets.
513  * @padding1: padding bytes.
514  * @size_of_set: set size.
515  * @padding2: padding bytes.
516  * @bubble_size: is the amount of padding in the bubble expressed in "sets".
517  * @padding3: padding bytes.
518  */
519 struct ipu3_uapi_bubble_info {
520 	__u32 num_of_stripes __attribute__((aligned(32)));
521 	__u8 padding[28];
522 	__u32 num_sets;
523 	__u8 padding1[28];
524 	__u32 size_of_set;
525 	__u8 padding2[28];
526 	__u32 bubble_size;
527 	__u8 padding3[28];
528 } __packed;
529 
530 /*
531  * struct ipu3_uapi_stats_3a_bubble_info_per_stripe
532  */
533 struct ipu3_uapi_stats_3a_bubble_info_per_stripe {
534 	struct ipu3_uapi_bubble_info awb[IPU3_UAPI_MAX_STRIPES];
535 	struct ipu3_uapi_bubble_info af[IPU3_UAPI_MAX_STRIPES];
536 	struct ipu3_uapi_bubble_info awb_fr[IPU3_UAPI_MAX_STRIPES];
537 } __packed;
538 
539 /**
540  * struct ipu3_uapi_ff_status - Enable bits for each 3A fixed function
541  *
542  * @awb_en: auto white balance enable
543  * @padding: padding config
544  * @ae_en: auto exposure enable
545  * @padding1: padding config
546  * @af_en: auto focus enable
547  * @padding2: padding config
548  * @awb_fr_en: awb filter response enable bit
549  * @padding3: padding config
550  */
551 struct ipu3_uapi_ff_status {
552 	__u32 awb_en __attribute__((aligned(32)));
553 	__u8 padding[28];
554 	__u32 ae_en;
555 	__u8 padding1[28];
556 	__u32 af_en;
557 	__u8 padding2[28];
558 	__u32 awb_fr_en;
559 	__u8 padding3[28];
560 } __packed;
561 
562 /**
563  * struct ipu3_uapi_stats_3a - 3A statistics
564  *
565  * @awb_raw_buffer: auto white balance meta data &ipu3_uapi_awb_raw_buffer
566  * @ae_raw_buffer: auto exposure raw data &ipu3_uapi_ae_raw_buffer_aligned
567  *                 current Imgu does not output the auto exposure statistics
568  *                 to ae_raw_buffer, the user such as 3A algorithm can use the
569  *                 RGB table in &ipu3_uapi_awb_raw_buffer to do auto-exposure.
570  * @af_raw_buffer: &ipu3_uapi_af_raw_buffer for auto focus meta data
571  * @awb_fr_raw_buffer: value as specified by &ipu3_uapi_awb_fr_raw_buffer
572  * @stats_4a_config: 4a statistics config as defined by &ipu3_uapi_4a_config.
573  * @ae_join_buffers: 1 to use ae_raw_buffer.
574  * @padding: padding config
575  * @stats_3a_bubble_per_stripe: a &ipu3_uapi_stats_3a_bubble_info_per_stripe
576  * @stats_3a_status: 3a statistics status set in &ipu3_uapi_ff_status
577  */
578 struct ipu3_uapi_stats_3a {
579 	struct ipu3_uapi_awb_raw_buffer awb_raw_buffer;
580 	struct ipu3_uapi_ae_raw_buffer_aligned
581 			ae_raw_buffer[IPU3_UAPI_MAX_STRIPES];
582 	struct ipu3_uapi_af_raw_buffer af_raw_buffer;
583 	struct ipu3_uapi_awb_fr_raw_buffer awb_fr_raw_buffer;
584 	struct ipu3_uapi_4a_config stats_4a_config;
585 	__u32 ae_join_buffers;
586 	__u8 padding[28];
587 	struct ipu3_uapi_stats_3a_bubble_info_per_stripe
588 			stats_3a_bubble_per_stripe;
589 	struct ipu3_uapi_ff_status stats_3a_status;
590 } __packed;
591 
592 /******************* ipu3_uapi_acc_param *******************/
593 
594 #define IPU3_UAPI_ISP_VEC_ELEMS				64
595 #define IPU3_UAPI_ISP_TNR3_VMEM_LEN			9
596 
597 #define IPU3_UAPI_BNR_LUT_SIZE				32
598 
599 /* number of elements in gamma correction LUT */
600 #define IPU3_UAPI_GAMMA_CORR_LUT_ENTRIES		256
601 
602 /* largest grid is 73x56, for grid_height_per_slice of 2, 73x2 = 146 */
603 #define IPU3_UAPI_SHD_MAX_CELLS_PER_SET			146
604 #define IPU3_UAPI_SHD_MAX_CFG_SETS			28
605 /* Normalization shift aka nf */
606 #define IPU3_UAPI_SHD_BLGR_NF_SHIFT			13
607 #define IPU3_UAPI_SHD_BLGR_NF_MASK			7
608 
609 #define IPU3_UAPI_YUVP2_TCC_MACC_TABLE_ELEMENTS		16
610 #define IPU3_UAPI_YUVP2_TCC_INV_Y_LUT_ELEMENTS		14
611 #define IPU3_UAPI_YUVP2_TCC_GAIN_PCWL_LUT_ELEMENTS	258
612 #define IPU3_UAPI_YUVP2_TCC_R_SQR_LUT_ELEMENTS		24
613 
614 #define IPU3_UAPI_ANR_LUT_SIZE				26
615 #define IPU3_UAPI_ANR_PYRAMID_SIZE			22
616 
617 #define IPU3_UAPI_LIN_LUT_SIZE				64
618 
619 /* Bayer Noise Reduction related structs */
620 
621 /**
622  * struct ipu3_uapi_bnr_static_config_wb_gains_config - White balance gains
623  *
624  * @gr:	white balance gain for Gr channel.
625  * @r:	white balance gain for R channel.
626  * @b:	white balance gain for B channel.
627  * @gb:	white balance gain for Gb channel.
628  *
629  * Precision u3.13, range [0, 8). White balance correction is done by applying
630  * a multiplicative gain to each color channels prior to BNR.
631  */
632 struct ipu3_uapi_bnr_static_config_wb_gains_config {
633 	__u16 gr;
634 	__u16 r;
635 	__u16 b;
636 	__u16 gb;
637 } __packed;
638 
639 /**
640  * struct ipu3_uapi_bnr_static_config_wb_gains_thr_config - Threshold config
641  *
642  * @gr:	white balance threshold gain for Gr channel.
643  * @r:	white balance threshold gain for R channel.
644  * @b:	white balance threshold gain for B channel.
645  * @gb:	white balance threshold gain for Gb channel.
646  *
647  * Defines the threshold that specifies how different a defect pixel can be from
648  * its neighbors.(used by dynamic defect pixel correction sub block)
649  * Precision u4.4 range [0, 8].
650  */
651 struct ipu3_uapi_bnr_static_config_wb_gains_thr_config {
652 	__u8 gr;
653 	__u8 r;
654 	__u8 b;
655 	__u8 gb;
656 } __packed;
657 
658 /**
659  * struct ipu3_uapi_bnr_static_config_thr_coeffs_config - Noise model
660  *				coefficients that controls noise threshold
661  *
662  * @cf:	Free coefficient for threshold calculation, range [0, 8191], default 0.
663  * @reserved0:	reserved
664  * @cg:	Gain coefficient for threshold calculation, [0, 31], default 8.
665  * @ci:	Intensity coefficient for threshold calculation. range [0, 0x1f]
666  *	default 6.
667  *	format: u3.2 (3 most significant bits represent whole number,
668  *	2 least significant bits represent the fractional part
669  *	with each count representing 0.25)
670  *	e.g. 6 in binary format is 00110, that translates to 1.5
671  * @reserved1:	reserved
672  * @r_nf:	Normalization shift value for r^2 calculation, range [12, 20]
673  *		where r is a radius of pixel [row, col] from centor of sensor.
674  *		default 14.
675  *
676  * Threshold used to distinguish between noise and details.
677  */
678 struct ipu3_uapi_bnr_static_config_thr_coeffs_config {
679 	__u32 cf:13;
680 	__u32 reserved0:3;
681 	__u32 cg:5;
682 	__u32 ci:5;
683 	__u32 reserved1:1;
684 	__u32 r_nf:5;
685 } __packed;
686 
687 /**
688  * struct ipu3_uapi_bnr_static_config_thr_ctrl_shd_config - Shading config
689  *
690  * @gr:	Coefficient defines lens shading gain approximation for gr channel
691  * @r:	Coefficient defines lens shading gain approximation for r channel
692  * @b:	Coefficient defines lens shading gain approximation for b channel
693  * @gb:	Coefficient defines lens shading gain approximation for gb channel
694  *
695  * Parameters for noise model (NM) adaptation of BNR due to shading correction.
696  * All above have precision of u3.3, default to 0.
697  */
698 struct ipu3_uapi_bnr_static_config_thr_ctrl_shd_config {
699 	__u8 gr;
700 	__u8 r;
701 	__u8 b;
702 	__u8 gb;
703 } __packed;
704 
705 /**
706  * struct ipu3_uapi_bnr_static_config_opt_center_config - Optical center config
707  *
708  * @x_reset:	Reset value of X (col start - X center). Precision s12.0.
709  * @reserved0:	reserved
710  * @y_reset:	Reset value of Y (row start - Y center). Precision s12.0.
711  * @reserved2:	reserved
712  *
713  * Distance from corner to optical center for NM adaptation due to shading
714  * correction (should be calculated based on shading tables)
715  */
716 struct ipu3_uapi_bnr_static_config_opt_center_config {
717 	__s32 x_reset:13;
718 	__u32 reserved0:3;
719 	__s32 y_reset:13;
720 	__u32 reserved2:3;
721 } __packed;
722 
723 /**
724  * struct ipu3_uapi_bnr_static_config_lut_config - BNR square root lookup table
725  *
726  * @values: pre-calculated values of square root function.
727  *
728  * LUT implementation of square root operation.
729  */
730 struct ipu3_uapi_bnr_static_config_lut_config {
731 	__u8 values[IPU3_UAPI_BNR_LUT_SIZE];
732 } __packed;
733 
734 /**
735  * struct ipu3_uapi_bnr_static_config_bp_ctrl_config - Detect bad pixels (bp)
736  *
737  * @bp_thr_gain:	Defines the threshold that specifies how different a
738  *			defect pixel can be from its neighbors. Threshold is
739  *			dependent on de-noise threshold calculated by algorithm.
740  *			Range [4, 31], default 4.
741  * @reserved0:	reserved
742  * @defect_mode:	Mode of addressed defect pixels,
743  *			0 - single defect pixel is expected,
744  *			1 - 2 adjacent defect pixels are expected, default 1.
745  * @bp_gain:	Defines how 2nd derivation that passes through a defect pixel
746  *		is different from 2nd derivations that pass through
747  *		neighbor pixels. u4.2, range [0, 256], default 8.
748  * @reserved1:	reserved
749  * @w0_coeff:	Blending coefficient of defect pixel correction.
750  *		Precision u4, range [0, 8], default 8.
751  * @reserved2:	reserved
752  * @w1_coeff:	Enable influence of incorrect defect pixel correction to be
753  *		avoided. Precision u4, range [1, 8], default 8.
754  * @reserved3:	reserved
755  */
756 struct ipu3_uapi_bnr_static_config_bp_ctrl_config {
757 	__u32 bp_thr_gain:5;
758 	__u32 reserved0:2;
759 	__u32 defect_mode:1;
760 	__u32 bp_gain:6;
761 	__u32 reserved1:18;
762 	__u32 w0_coeff:4;
763 	__u32 reserved2:4;
764 	__u32 w1_coeff:4;
765 	__u32 reserved3:20;
766 } __packed;
767 
768 /**
769  * struct ipu3_uapi_bnr_static_config_dn_detect_ctrl_config - Denoising config
770  *
771  * @alpha:	Weight of central element of smoothing filter.
772  * @beta:	Weight of peripheral elements of smoothing filter, default 4.
773  * @gamma:	Weight of diagonal elements of smoothing filter, default 4.
774  *
775  * beta and gamma parameter define the strength of the noise removal filter.
776  *		All above has precision u0.4, range [0, 0xf]
777  *		format: u0.4 (no / zero bits represent whole number,
778  *		4 bits represent the fractional part
779  *		with each count representing 0.0625)
780  *		e.g. 0xf translates to 0.0625x15 = 0.9375
781  *
782  * @reserved0:	reserved
783  * @max_inf:	Maximum increase of peripheral or diagonal element influence
784  *		relative to the pre-defined value range: [0x5, 0xa]
785  * @reserved1:	reserved
786  * @gd_enable:	Green disparity enable control, 0 - disable, 1 - enable.
787  * @bpc_enable:	Bad pixel correction enable control, 0 - disable, 1 - enable.
788  * @bnr_enable:	Bayer noise removal enable control, 0 - disable, 1 - enable.
789  * @ff_enable:	Fixed function enable, 0 - disable, 1 - enable.
790  * @reserved2:	reserved
791  */
792 struct ipu3_uapi_bnr_static_config_dn_detect_ctrl_config {
793 	__u32 alpha:4;
794 	__u32 beta:4;
795 	__u32 gamma:4;
796 	__u32 reserved0:4;
797 	__u32 max_inf:4;
798 	__u32 reserved1:7;
799 	__u32 gd_enable:1;
800 	__u32 bpc_enable:1;
801 	__u32 bnr_enable:1;
802 	__u32 ff_enable:1;
803 	__u32 reserved2:1;
804 } __packed;
805 
806 /**
807  * struct ipu3_uapi_bnr_static_config_opt_center_sqr_config - BNR optical square
808  *
809  * @x_sqr_reset: Reset value of X^2.
810  * @y_sqr_reset: Reset value of Y^2.
811  *
812  * Please note:
813  *
814  *    #. X and Y ref to
815  *       &ipu3_uapi_bnr_static_config_opt_center_config
816  *    #. Both structs are used in threshold formula to calculate r^2, where r
817  *       is a radius of pixel [row, col] from centor of sensor.
818  */
819 struct ipu3_uapi_bnr_static_config_opt_center_sqr_config {
820 	__u32 x_sqr_reset;
821 	__u32 y_sqr_reset;
822 } __packed;
823 
824 /**
825  * struct ipu3_uapi_bnr_static_config - BNR static config
826  *
827  * @wb_gains:	white balance gains &ipu3_uapi_bnr_static_config_wb_gains_config
828  * @wb_gains_thr:	white balance gains threshold as defined by
829  *			&ipu3_uapi_bnr_static_config_wb_gains_thr_config
830  * @thr_coeffs:	coefficients of threshold
831  *		&ipu3_uapi_bnr_static_config_thr_coeffs_config
832  * @thr_ctrl_shd:	control of shading threshold
833  *			&ipu3_uapi_bnr_static_config_thr_ctrl_shd_config
834  * @opt_center:	optical center &ipu3_uapi_bnr_static_config_opt_center_config
835  *
836  * Above parameters and opt_center_sqr are used for white balance and shading.
837  *
838  * @lut:	lookup table &ipu3_uapi_bnr_static_config_lut_config
839  * @bp_ctrl:	detect and remove bad pixels as defined in struct
840  *		&ipu3_uapi_bnr_static_config_bp_ctrl_config
841  * @dn_detect_ctrl:	detect and remove noise.
842  *			&ipu3_uapi_bnr_static_config_dn_detect_ctrl_config
843  * @column_size:	The number of pixels in column.
844  * @opt_center_sqr:	Reset value of r^2 to optical center, see
845  *			&ipu3_uapi_bnr_static_config_opt_center_sqr_config.
846  */
847 struct ipu3_uapi_bnr_static_config {
848 	struct ipu3_uapi_bnr_static_config_wb_gains_config wb_gains;
849 	struct ipu3_uapi_bnr_static_config_wb_gains_thr_config wb_gains_thr;
850 	struct ipu3_uapi_bnr_static_config_thr_coeffs_config thr_coeffs;
851 	struct ipu3_uapi_bnr_static_config_thr_ctrl_shd_config thr_ctrl_shd;
852 	struct ipu3_uapi_bnr_static_config_opt_center_config opt_center;
853 	struct ipu3_uapi_bnr_static_config_lut_config lut;
854 	struct ipu3_uapi_bnr_static_config_bp_ctrl_config bp_ctrl;
855 	struct ipu3_uapi_bnr_static_config_dn_detect_ctrl_config dn_detect_ctrl;
856 	__u32 column_size;
857 	struct ipu3_uapi_bnr_static_config_opt_center_sqr_config opt_center_sqr;
858 } __packed;
859 
860 /**
861  * struct ipu3_uapi_bnr_static_config_green_disparity - Correct green disparity
862  *
863  * @gd_red:	Shading gain coeff for gr disparity level in bright red region.
864  *		Precision u0.6, default 4(0.0625).
865  * @reserved0:	reserved
866  * @gd_green:	Shading gain coeff for gr disparity level in bright green
867  *		region. Precision u0.6, default 4(0.0625).
868  * @reserved1:	reserved
869  * @gd_blue:	Shading gain coeff for gr disparity level in bright blue region.
870  *		Precision u0.6, default 4(0.0625).
871  * @reserved2:	reserved
872  * @gd_black:	Maximal green disparity level in dark region (stronger disparity
873  *		assumed to be image detail). Precision u14, default 80.
874  * @reserved3:	reserved
875  * @gd_shading:	Change maximal green disparity level according to square
876  *		distance from image center.
877  * @reserved4:	reserved
878  * @gd_support:	Lower bound for the number of second green color pixels in
879  *		current pixel neighborhood with less than threshold difference
880  *		from it.
881  *
882  * The shading gain coeff of red, green, blue and black are used to calculate
883  * threshold given a pixel's color value and its coordinates in the image.
884  *
885  * @reserved5:	reserved
886  * @gd_clip:	Turn green disparity clip on/off, [0, 1], default 1.
887  * @gd_central_weight:	Central pixel weight in 9 pixels weighted sum.
888  */
889 struct ipu3_uapi_bnr_static_config_green_disparity {
890 	__u32 gd_red:6;
891 	__u32 reserved0:2;
892 	__u32 gd_green:6;
893 	__u32 reserved1:2;
894 	__u32 gd_blue:6;
895 	__u32 reserved2:10;
896 	__u32 gd_black:14;
897 	__u32 reserved3:2;
898 	__u32 gd_shading:7;
899 	__u32 reserved4:1;
900 	__u32 gd_support:2;
901 	__u32 reserved5:1;
902 	__u32 gd_clip:1;
903 	__u32 gd_central_weight:4;
904 } __packed;
905 
906 /**
907  * struct ipu3_uapi_dm_config - De-mosaic parameters
908  *
909  * @dm_en:	de-mosaic enable.
910  * @ch_ar_en:	Checker artifacts removal enable flag. Default 0.
911  * @fcc_en:	False color correction (FCC) enable flag. Default 0.
912  * @reserved0:	reserved
913  * @frame_width:	do not care
914  * @gamma_sc:	Sharpening coefficient (coefficient of 2-d derivation of
915  *		complementary color in Hamilton-Adams interpolation).
916  *		u5, range [0, 31], default 8.
917  * @reserved1:	reserved
918  * @lc_ctrl:	Parameter that controls weights of Chroma Homogeneity metric
919  *		in calculation of final homogeneity metric.
920  *		u5, range [0, 31], default 7.
921  * @reserved2:	reserved
922  * @cr_param1:	First parameter that defines Checker artifact removal
923  *		feature gain. Precision u5, range [0, 31], default 8.
924  * @reserved3:	reserved
925  * @cr_param2:	Second parameter that defines Checker artifact removal
926  *		feature gain. Precision u5, range [0, 31], default 8.
927  * @reserved4:	reserved
928  * @coring_param:	Defines power of false color correction operation.
929  *			low for preserving edge colors, high for preserving gray
930  *			edge artifacts.
931  *			Precision u1.4, range [0, 1.9375], default 4 (0.25).
932  * @reserved5:	reserved
933  *
934  * The demosaic fixed function block is responsible to covert Bayer(mosaiced)
935  * images into color images based on demosaicing algorithm.
936  */
937 struct ipu3_uapi_dm_config {
938 	__u32 dm_en:1;
939 	__u32 ch_ar_en:1;
940 	__u32 fcc_en:1;
941 	__u32 reserved0:13;
942 	__u32 frame_width:16;
943 
944 	__u32 gamma_sc:5;
945 	__u32 reserved1:3;
946 	__u32 lc_ctrl:5;
947 	__u32 reserved2:3;
948 	__u32 cr_param1:5;
949 	__u32 reserved3:3;
950 	__u32 cr_param2:5;
951 	__u32 reserved4:3;
952 
953 	__u32 coring_param:5;
954 	__u32 reserved5:27;
955 } __packed;
956 
957 /**
958  * struct ipu3_uapi_ccm_mat_config - Color correction matrix
959  *
960  * @coeff_m11: CCM 3x3 coefficient, range [-65536, 65535]
961  * @coeff_m12: CCM 3x3 coefficient, range [-8192, 8191]
962  * @coeff_m13: CCM 3x3 coefficient, range [-32768, 32767]
963  * @coeff_o_r: Bias 3x1 coefficient, range [-8191, 8181]
964  * @coeff_m21: CCM 3x3 coefficient, range [-32767, 32767]
965  * @coeff_m22: CCM 3x3 coefficient, range [-8192, 8191]
966  * @coeff_m23: CCM 3x3 coefficient, range [-32768, 32767]
967  * @coeff_o_g: Bias 3x1 coefficient, range [-8191, 8181]
968  * @coeff_m31: CCM 3x3 coefficient, range [-32768, 32767]
969  * @coeff_m32: CCM 3x3 coefficient, range [-8192, 8191]
970  * @coeff_m33: CCM 3x3 coefficient, range [-32768, 32767]
971  * @coeff_o_b: Bias 3x1 coefficient, range [-8191, 8181]
972  *
973  * Transform sensor specific color space to standard sRGB by applying 3x3 matrix
974  * and adding a bias vector O. The transformation is basically a rotation and
975  * translation in the 3-dimensional color spaces. Here are the defaults:
976  *
977  *	9775,	-2671,	1087,	0
978  *	-1071,	8303,	815,	0
979  *	-23,	-7887,	16103,	0
980  */
981 struct ipu3_uapi_ccm_mat_config {
982 	__s16 coeff_m11;
983 	__s16 coeff_m12;
984 	__s16 coeff_m13;
985 	__s16 coeff_o_r;
986 	__s16 coeff_m21;
987 	__s16 coeff_m22;
988 	__s16 coeff_m23;
989 	__s16 coeff_o_g;
990 	__s16 coeff_m31;
991 	__s16 coeff_m32;
992 	__s16 coeff_m33;
993 	__s16 coeff_o_b;
994 } __packed;
995 
996 /**
997  * struct ipu3_uapi_gamma_corr_ctrl - Gamma correction
998  *
999  * @enable: gamma correction enable.
1000  * @reserved: reserved
1001  */
1002 struct ipu3_uapi_gamma_corr_ctrl {
1003 	__u32 enable:1;
1004 	__u32 reserved:31;
1005 } __packed;
1006 
1007 /**
1008  * struct ipu3_uapi_gamma_corr_lut - Per-pixel tone mapping implemented as LUT.
1009  *
1010  * @lut:	256 tabulated values of the gamma function. LUT[1].. LUT[256]
1011  *		format u13.0, range [0, 8191].
1012  *
1013  * The tone mapping operation is done by a Piece wise linear graph
1014  * that is implemented as a lookup table(LUT). The pixel component input
1015  * intensity is the X-axis of the graph which is the table entry.
1016  */
1017 struct ipu3_uapi_gamma_corr_lut {
1018 	__u16 lut[IPU3_UAPI_GAMMA_CORR_LUT_ENTRIES];
1019 } __packed;
1020 
1021 /**
1022  * struct ipu3_uapi_gamma_config - Gamma config
1023  *
1024  * @gc_ctrl: control of gamma correction &ipu3_uapi_gamma_corr_ctrl
1025  * @gc_lut: lookup table of gamma correction &ipu3_uapi_gamma_corr_lut
1026  */
1027 struct ipu3_uapi_gamma_config {
1028 	struct ipu3_uapi_gamma_corr_ctrl gc_ctrl __attribute__((aligned(32)));
1029 	struct ipu3_uapi_gamma_corr_lut gc_lut __attribute__((aligned(32)));
1030 } __packed;
1031 
1032 /**
1033  * struct ipu3_uapi_csc_mat_config - Color space conversion matrix config
1034  *
1035  * @coeff_c11:	Conversion matrix value, format s0.14, range [-16384, 16383].
1036  * @coeff_c12:	Conversion matrix value, format s0.14, range [-8192, 8191].
1037  * @coeff_c13:	Conversion matrix value, format s0.14, range [-16384, 16383].
1038  * @coeff_b1:	Bias 3x1 coefficient, s13.0 range [-8192, 8191].
1039  * @coeff_c21:	Conversion matrix value, format s0.14, range [-16384, 16383].
1040  * @coeff_c22:	Conversion matrix value, format s0.14, range [-8192, 8191].
1041  * @coeff_c23:	Conversion matrix value, format s0.14, range [-16384, 16383].
1042  * @coeff_b2:	Bias 3x1 coefficient, s13.0 range [-8192, 8191].
1043  * @coeff_c31:	Conversion matrix value, format s0.14, range [-16384, 16383].
1044  * @coeff_c32:	Conversion matrix value, format s0.14, range [-8192, 8191].
1045  * @coeff_c33:	Conversion matrix value, format s0.14, range [-16384, 16383].
1046  * @coeff_b3:	Bias 3x1 coefficient, s13.0 range [-8192, 8191].
1047  *
1048  * To transform each pixel from RGB to YUV (Y - brightness/luminance,
1049  * UV -chroma) by applying the pixel's values by a 3x3 matrix and adding an
1050  * optional bias 3x1 vector. Here are the default values for the matrix:
1051  *
1052  *	4898,   9617,  1867, 0,
1053  *	-2410, -4732,  7143, 0,
1054  *	10076, -8437, -1638, 0,
1055  *
1056  *	(i.e. for real number 0.299, 0.299 * 2^14 becomes 4898.)
1057  */
1058 struct ipu3_uapi_csc_mat_config {
1059 	__s16 coeff_c11;
1060 	__s16 coeff_c12;
1061 	__s16 coeff_c13;
1062 	__s16 coeff_b1;
1063 	__s16 coeff_c21;
1064 	__s16 coeff_c22;
1065 	__s16 coeff_c23;
1066 	__s16 coeff_b2;
1067 	__s16 coeff_c31;
1068 	__s16 coeff_c32;
1069 	__s16 coeff_c33;
1070 	__s16 coeff_b3;
1071 } __packed;
1072 
1073 /**
1074  * struct ipu3_uapi_cds_params - Chroma down-scaling
1075  *
1076  * @ds_c00:	range [0, 3]
1077  * @ds_c01:	range [0, 3]
1078  * @ds_c02:	range [0, 3]
1079  * @ds_c03:	range [0, 3]
1080  * @ds_c10:	range [0, 3]
1081  * @ds_c11:	range [0, 3]
1082  * @ds_c12:	range [0, 3]
1083  * @ds_c13:	range [0, 3]
1084  *
1085  * In case user does not provide, above 4x2 filter will use following defaults:
1086  *	1, 3, 3, 1,
1087  *	1, 3, 3, 1,
1088  *
1089  * @ds_nf:	Normalization factor for Chroma output downscaling filter,
1090  *		range 0,4, default 2.
1091  * @reserved0:	reserved
1092  * @csc_en:	Color space conversion enable
1093  * @uv_bin_output:	0: output YUV 4.2.0, 1: output YUV 4.2.2(default).
1094  * @reserved1:	reserved
1095  */
1096 struct ipu3_uapi_cds_params {
1097 	__u32 ds_c00:2;
1098 	__u32 ds_c01:2;
1099 	__u32 ds_c02:2;
1100 	__u32 ds_c03:2;
1101 	__u32 ds_c10:2;
1102 	__u32 ds_c11:2;
1103 	__u32 ds_c12:2;
1104 	__u32 ds_c13:2;
1105 	__u32 ds_nf:5;
1106 	__u32 reserved0:3;
1107 	__u32 csc_en:1;
1108 	__u32 uv_bin_output:1;
1109 	__u32 reserved1:6;
1110 } __packed;
1111 
1112 /**
1113  * struct ipu3_uapi_shd_grid_config - Bayer shading(darkening) correction
1114  *
1115  * @width:	Grid horizontal dimensions, u8, [8, 128], default 73
1116  * @height:	Grid vertical dimensions, u8, [8, 128], default 56
1117  * @block_width_log2:	Log2 of the width of the grid cell in pixel count
1118  *			u4, [0, 15], default value 5.
1119  * @reserved0:	reserved
1120  * @block_height_log2:	Log2 of the height of the grid cell in pixel count
1121  *			u4, [0, 15], default value 6.
1122  * @reserved1:	reserved
1123  * @grid_height_per_slice:	SHD_MAX_CELLS_PER_SET/width.
1124  *				(with SHD_MAX_CELLS_PER_SET = 146).
1125  * @x_start:	X value of top left corner of sensor relative to ROI
1126  *		s13, [-4096, 0], default 0, only negative values.
1127  * @y_start:	Y value of top left corner of sensor relative to ROI
1128  *		s13, [-4096, 0], default 0, only negative values.
1129  */
1130 struct ipu3_uapi_shd_grid_config {
1131 	/* reg 0 */
1132 	__u8 width;
1133 	__u8 height;
1134 	__u8 block_width_log2:3;
1135 	__u8 reserved0:1;
1136 	__u8 block_height_log2:3;
1137 	__u8 reserved1:1;
1138 	__u8 grid_height_per_slice;
1139 	/* reg 1 */
1140 	__s16 x_start;
1141 	__s16 y_start;
1142 } __packed;
1143 
1144 /**
1145  * struct ipu3_uapi_shd_general_config - Shading general config
1146  *
1147  * @init_set_vrt_offst_ul: set vertical offset,
1148  *			y_start >> block_height_log2 % grid_height_per_slice.
1149  * @shd_enable: shading enable.
1150  * @gain_factor: Gain factor. Shift calculated anti shading value. Precision u2.
1151  *		0x0 - gain factor [1, 5], means no shift interpolated value.
1152  *		0x1 - gain factor [1, 9], means shift interpolated by 1.
1153  *		0x2 - gain factor [1, 17], means shift interpolated by 2.
1154  * @reserved: reserved
1155  *
1156  * Correction is performed by multiplying a gain factor for each of the 4 Bayer
1157  * channels as a function of the pixel location in the sensor.
1158  */
1159 struct ipu3_uapi_shd_general_config {
1160 	__u32 init_set_vrt_offst_ul:8;
1161 	__u32 shd_enable:1;
1162 	__u32 gain_factor:2;
1163 	__u32 reserved:21;
1164 } __packed;
1165 
1166 /**
1167  * struct ipu3_uapi_shd_black_level_config - Black level correction
1168  *
1169  * @bl_r:	Bios values for green red. s11 range [-2048, 2047].
1170  * @bl_gr:	Bios values for green blue. s11 range [-2048, 2047].
1171  * @bl_gb:	Bios values for red. s11 range [-2048, 2047].
1172  * @bl_b:	Bios values for blue. s11 range [-2048, 2047].
1173  */
1174 struct ipu3_uapi_shd_black_level_config {
1175 	__s16 bl_r;
1176 	__s16 bl_gr;
1177 	__s16 bl_gb;
1178 	__s16 bl_b;
1179 } __packed;
1180 
1181 /**
1182  * struct ipu3_uapi_shd_config_static - Shading config static
1183  *
1184  * @grid:	shading grid config &ipu3_uapi_shd_grid_config
1185  * @general:	shading general config &ipu3_uapi_shd_general_config
1186  * @black_level:	black level config for shading correction as defined by
1187  *			&ipu3_uapi_shd_black_level_config
1188  */
1189 struct ipu3_uapi_shd_config_static {
1190 	struct ipu3_uapi_shd_grid_config grid;
1191 	struct ipu3_uapi_shd_general_config general;
1192 	struct ipu3_uapi_shd_black_level_config black_level;
1193 } __packed;
1194 
1195 /**
1196  * struct ipu3_uapi_shd_lut - Shading gain factor lookup table.
1197  *
1198  * @sets: array
1199  * @sets.r_and_gr: Red and GreenR Lookup table.
1200  * @sets.r_and_gr.r: Red shading factor.
1201  * @sets.r_and_gr.gr: GreenR shading factor.
1202  * @sets.reserved1: reserved
1203  * @sets.gb_and_b: GreenB and Blue Lookup table.
1204  * @sets.gb_and_b.gb: GreenB shading factor.
1205  * @sets.gb_and_b.b: Blue shading factor.
1206  * @sets.reserved2: reserved
1207  *
1208  * Map to shading correction LUT register set.
1209  */
1210 struct ipu3_uapi_shd_lut {
1211 	struct {
1212 		struct {
1213 			__u16 r;
1214 			__u16 gr;
1215 		} r_and_gr[IPU3_UAPI_SHD_MAX_CELLS_PER_SET];
1216 		__u8 reserved1[24];
1217 		struct {
1218 			__u16 gb;
1219 			__u16 b;
1220 		} gb_and_b[IPU3_UAPI_SHD_MAX_CELLS_PER_SET];
1221 		__u8 reserved2[24];
1222 	} sets[IPU3_UAPI_SHD_MAX_CFG_SETS];
1223 } __packed;
1224 
1225 /**
1226  * struct ipu3_uapi_shd_config - Shading config
1227  *
1228  * @shd:	shading static config, see &ipu3_uapi_shd_config_static
1229  * @shd_lut:	shading lookup table &ipu3_uapi_shd_lut
1230  */
1231 struct ipu3_uapi_shd_config {
1232 	struct ipu3_uapi_shd_config_static shd __attribute__((aligned(32)));
1233 	struct ipu3_uapi_shd_lut shd_lut __attribute__((aligned(32)));
1234 } __packed;
1235 
1236 /* Image Enhancement Filter directed */
1237 
1238 /**
1239  * struct ipu3_uapi_iefd_cux2 - IEFd Config Unit 2 parameters
1240  *
1241  * @x0:		X0 point of Config Unit, u9.0, default 0.
1242  * @x1:		X1 point of Config Unit, u9.0, default 0.
1243  * @a01:	Slope A of Config Unit, s4.4, default 0.
1244  * @b01:	Slope B, always 0.
1245  *
1246  * Calculate weight for blending directed and non-directed denoise elements
1247  *
1248  * Note:
1249  * Each instance of Config Unit needs X coordinate of n points and
1250  * slope A factor between points calculated by driver based on calibration
1251  * parameters.
1252  *
1253  * All CU inputs are unsigned, they will be converted to signed when written
1254  * to register, i.e. a01 will be written to 9 bit register in s4.4 format.
1255  * The data precision s4.4 means 4 bits for integer parts and 4 bits for the
1256  * fractional part, the first bit indicates positive or negative value.
1257  * For userspace software (commonly the imaging library), the computation for
1258  * the CU slope values should be based on the slope resolution 1/16 (binary
1259  * 0.0001 - the minimal interval value), the slope value range is [-256, +255].
1260  * This applies to &ipu3_uapi_iefd_cux6_ed, &ipu3_uapi_iefd_cux2_1,
1261  * &ipu3_uapi_iefd_cux2_1, &ipu3_uapi_iefd_cux4 and &ipu3_uapi_iefd_cux6_rad.
1262  */
1263 struct ipu3_uapi_iefd_cux2 {
1264 	__u32 x0:9;
1265 	__u32 x1:9;
1266 	__u32 a01:9;
1267 	__u32 b01:5;
1268 } __packed;
1269 
1270 /**
1271  * struct ipu3_uapi_iefd_cux6_ed - Calculate power of non-directed sharpening
1272  *				   element, Config Unit 6 for edge detail (ED).
1273  *
1274  * @x0:	X coordinate of point 0, u9.0, default 0.
1275  * @x1:	X coordinate of point 1, u9.0, default 0.
1276  * @x2:	X coordinate of point 2, u9.0, default 0.
1277  * @reserved0:	reserved
1278  * @x3:	X coordinate of point 3, u9.0, default 0.
1279  * @x4:	X coordinate of point 4, u9.0, default 0.
1280  * @x5:	X coordinate of point 5, u9.0, default 0.
1281  * @reserved1:	reserved
1282  * @a01:	slope A points 01, s4.4, default 0.
1283  * @a12:	slope A points 12, s4.4, default 0.
1284  * @a23:	slope A points 23, s4.4, default 0.
1285  * @reserved2:	reserved
1286  * @a34:	slope A points 34, s4.4, default 0.
1287  * @a45:	slope A points 45, s4.4, default 0.
1288  * @reserved3:	reserved
1289  * @b01:	slope B points 01, s4.4, default 0.
1290  * @b12:	slope B points 12, s4.4, default 0.
1291  * @b23:	slope B points 23, s4.4, default 0.
1292  * @reserved4:	reserved
1293  * @b34:	slope B points 34, s4.4, default 0.
1294  * @b45:	slope B points 45, s4.4, default 0.
1295  * @reserved5:	reserved.
1296  */
1297 struct ipu3_uapi_iefd_cux6_ed {
1298 	__u32 x0:9;
1299 	__u32 x1:9;
1300 	__u32 x2:9;
1301 	__u32 reserved0:5;
1302 
1303 	__u32 x3:9;
1304 	__u32 x4:9;
1305 	__u32 x5:9;
1306 	__u32 reserved1:5;
1307 
1308 	__u32 a01:9;
1309 	__u32 a12:9;
1310 	__u32 a23:9;
1311 	__u32 reserved2:5;
1312 
1313 	__u32 a34:9;
1314 	__u32 a45:9;
1315 	__u32 reserved3:14;
1316 
1317 	__u32 b01:9;
1318 	__u32 b12:9;
1319 	__u32 b23:9;
1320 	__u32 reserved4:5;
1321 
1322 	__u32 b34:9;
1323 	__u32 b45:9;
1324 	__u32 reserved5:14;
1325 } __packed;
1326 
1327 /**
1328  * struct ipu3_uapi_iefd_cux2_1 - Calculate power of non-directed denoise
1329  *				  element apply.
1330  * @x0: X0 point of Config Unit, u9.0, default 0.
1331  * @x1: X1 point of Config Unit, u9.0, default 0.
1332  * @a01: Slope A of Config Unit, s4.4, default 0.
1333  * @reserved1: reserved
1334  * @b01: offset B0 of Config Unit, u7.0, default 0.
1335  * @reserved2: reserved
1336  */
1337 struct ipu3_uapi_iefd_cux2_1 {
1338 	__u32 x0:9;
1339 	__u32 x1:9;
1340 	__u32 a01:9;
1341 	__u32 reserved1:5;
1342 
1343 	__u32 b01:8;
1344 	__u32 reserved2:24;
1345 } __packed;
1346 
1347 /**
1348  * struct ipu3_uapi_iefd_cux4 - Calculate power of non-directed sharpening
1349  *				element.
1350  *
1351  * @x0:	X0 point of Config Unit, u9.0, default 0.
1352  * @x1:	X1 point of Config Unit, u9.0, default 0.
1353  * @x2:	X2 point of Config Unit, u9.0, default 0.
1354  * @reserved0:	reserved
1355  * @x3:	X3 point of Config Unit, u9.0, default 0.
1356  * @a01:	Slope A0 of Config Unit, s4.4, default 0.
1357  * @a12:	Slope A1 of Config Unit, s4.4, default 0.
1358  * @reserved1:	reserved
1359  * @a23:	Slope A2 of Config Unit, s4.4, default 0.
1360  * @b01:	Offset B0 of Config Unit, s7.0, default 0.
1361  * @b12:	Offset B1 of Config Unit, s7.0, default 0.
1362  * @reserved2:	reserved
1363  * @b23:	Offset B2 of Config Unit, s7.0, default 0.
1364  * @reserved3: reserved
1365  */
1366 struct ipu3_uapi_iefd_cux4 {
1367 	__u32 x0:9;
1368 	__u32 x1:9;
1369 	__u32 x2:9;
1370 	__u32 reserved0:5;
1371 
1372 	__u32 x3:9;
1373 	__u32 a01:9;
1374 	__u32 a12:9;
1375 	__u32 reserved1:5;
1376 
1377 	__u32 a23:9;
1378 	__u32 b01:8;
1379 	__u32 b12:8;
1380 	__u32 reserved2:7;
1381 
1382 	__u32 b23:8;
1383 	__u32 reserved3:24;
1384 } __packed;
1385 
1386 /**
1387  * struct ipu3_uapi_iefd_cux6_rad - Radial Config Unit (CU)
1388  *
1389  * @x0:	x0 points of Config Unit radial, u8.0
1390  * @x1:	x1 points of Config Unit radial, u8.0
1391  * @x2:	x2 points of Config Unit radial, u8.0
1392  * @x3:	x3 points of Config Unit radial, u8.0
1393  * @x4:	x4 points of Config Unit radial, u8.0
1394  * @x5:	x5 points of Config Unit radial, u8.0
1395  * @reserved1: reserved
1396  * @a01:	Slope A of Config Unit radial, s7.8
1397  * @a12:	Slope A of Config Unit radial, s7.8
1398  * @a23:	Slope A of Config Unit radial, s7.8
1399  * @a34:	Slope A of Config Unit radial, s7.8
1400  * @a45:	Slope A of Config Unit radial, s7.8
1401  * @reserved2: reserved
1402  * @b01:	Slope B of Config Unit radial, s9.0
1403  * @b12:	Slope B of Config Unit radial, s9.0
1404  * @b23:	Slope B of Config Unit radial, s9.0
1405  * @reserved4: reserved
1406  * @b34:	Slope B of Config Unit radial, s9.0
1407  * @b45:	Slope B of Config Unit radial, s9.0
1408  * @reserved5: reserved
1409  */
1410 struct ipu3_uapi_iefd_cux6_rad {
1411 	__u32 x0:8;
1412 	__u32 x1:8;
1413 	__u32 x2:8;
1414 	__u32 x3:8;
1415 
1416 	__u32 x4:8;
1417 	__u32 x5:8;
1418 	__u32 reserved1:16;
1419 
1420 	__u32 a01:16;
1421 	__u32 a12:16;
1422 
1423 	__u32 a23:16;
1424 	__u32 a34:16;
1425 
1426 	__u32 a45:16;
1427 	__u32 reserved2:16;
1428 
1429 	__u32 b01:10;
1430 	__u32 b12:10;
1431 	__u32 b23:10;
1432 	__u32 reserved4:2;
1433 
1434 	__u32 b34:10;
1435 	__u32 b45:10;
1436 	__u32 reserved5:12;
1437 } __packed;
1438 
1439 /**
1440  * struct ipu3_uapi_yuvp1_iefd_cfg_units - IEFd Config Units parameters
1441  *
1442  * @cu_1: calculate weight for blending directed and
1443  *	  non-directed denoise elements. See &ipu3_uapi_iefd_cux2
1444  * @cu_ed: calculate power of non-directed sharpening element, see
1445  *	   &ipu3_uapi_iefd_cux6_ed
1446  * @cu_3: calculate weight for blending directed and
1447  *	  non-directed denoise elements. A &ipu3_uapi_iefd_cux2
1448  * @cu_5: calculate power of non-directed denoise element apply, use
1449  *	  &ipu3_uapi_iefd_cux2_1
1450  * @cu_6: calculate power of non-directed sharpening element. See
1451  *	  &ipu3_uapi_iefd_cux4
1452  * @cu_7: calculate weight for blending directed and
1453  *	  non-directed denoise elements. Use &ipu3_uapi_iefd_cux2
1454  * @cu_unsharp: Config Unit of unsharp &ipu3_uapi_iefd_cux4
1455  * @cu_radial: Config Unit of radial &ipu3_uapi_iefd_cux6_rad
1456  * @cu_vssnlm: Config Unit of vssnlm &ipu3_uapi_iefd_cux2
1457  */
1458 struct ipu3_uapi_yuvp1_iefd_cfg_units {
1459 	struct ipu3_uapi_iefd_cux2 cu_1;
1460 	struct ipu3_uapi_iefd_cux6_ed cu_ed;
1461 	struct ipu3_uapi_iefd_cux2 cu_3;
1462 	struct ipu3_uapi_iefd_cux2_1 cu_5;
1463 	struct ipu3_uapi_iefd_cux4 cu_6;
1464 	struct ipu3_uapi_iefd_cux2 cu_7;
1465 	struct ipu3_uapi_iefd_cux4 cu_unsharp;
1466 	struct ipu3_uapi_iefd_cux6_rad cu_radial;
1467 	struct ipu3_uapi_iefd_cux2 cu_vssnlm;
1468 } __packed;
1469 
1470 /**
1471  * struct ipu3_uapi_yuvp1_iefd_config_s - IEFd config
1472  *
1473  * @horver_diag_coeff: Gradient compensation. Compared with vertical /
1474  *		       horizontal (0 / 90 degree), coefficient of diagonal (45 /
1475  *		       135 degree) direction should be corrected by approx.
1476  *		       1/sqrt(2).
1477  * @reserved0: reserved
1478  * @clamp_stitch: Slope to stitch between clamped and unclamped edge values
1479  * @reserved1: reserved
1480  * @direct_metric_update: Update coeff for direction metric
1481  * @reserved2: reserved
1482  * @ed_horver_diag_coeff: Radial Coefficient that compensates for
1483  *			  different distance for vertical/horizontal and
1484  *			  diagonal gradient calculation (approx. 1/sqrt(2))
1485  * @reserved3: reserved
1486  */
1487 struct ipu3_uapi_yuvp1_iefd_config_s {
1488 	__u32 horver_diag_coeff:7;
1489 	__u32 reserved0:1;
1490 	__u32 clamp_stitch:6;
1491 	__u32 reserved1:2;
1492 	__u32 direct_metric_update:5;
1493 	__u32 reserved2:3;
1494 	__u32 ed_horver_diag_coeff:7;
1495 	__u32 reserved3:1;
1496 } __packed;
1497 
1498 /**
1499  * struct ipu3_uapi_yuvp1_iefd_control - IEFd control
1500  *
1501  * @iefd_en:	Enable IEFd
1502  * @denoise_en:	Enable denoise
1503  * @direct_smooth_en:	Enable directional smooth
1504  * @rad_en:	Enable radial update
1505  * @vssnlm_en:	Enable VSSNLM output filter
1506  * @reserved:	reserved
1507  */
1508 struct ipu3_uapi_yuvp1_iefd_control {
1509 	__u32 iefd_en:1;
1510 	__u32 denoise_en:1;
1511 	__u32 direct_smooth_en:1;
1512 	__u32 rad_en:1;
1513 	__u32 vssnlm_en:1;
1514 	__u32 reserved:27;
1515 } __packed;
1516 
1517 /**
1518  * struct ipu3_uapi_sharp_cfg - Sharpening config
1519  *
1520  * @nega_lmt_txt: Sharpening limit for negative overshoots for texture.
1521  * @reserved0: reserved
1522  * @posi_lmt_txt: Sharpening limit for positive overshoots for texture.
1523  * @reserved1: reserved
1524  * @nega_lmt_dir: Sharpening limit for negative overshoots for direction (edge).
1525  * @reserved2: reserved
1526  * @posi_lmt_dir: Sharpening limit for positive overshoots for direction (edge).
1527  * @reserved3: reserved
1528  *
1529  * Fixed point type u13.0, range [0, 8191].
1530  */
1531 struct ipu3_uapi_sharp_cfg {
1532 	__u32 nega_lmt_txt:13;
1533 	__u32 reserved0:19;
1534 	__u32 posi_lmt_txt:13;
1535 	__u32 reserved1:19;
1536 	__u32 nega_lmt_dir:13;
1537 	__u32 reserved2:19;
1538 	__u32 posi_lmt_dir:13;
1539 	__u32 reserved3:19;
1540 } __packed;
1541 
1542 /**
1543  * struct ipu3_uapi_far_w - Sharpening config for far sub-group
1544  *
1545  * @dir_shrp:	Weight of wide direct sharpening, u1.6, range [0, 64], default 64.
1546  * @reserved0:	reserved
1547  * @dir_dns:	Weight of wide direct denoising, u1.6, range [0, 64], default 0.
1548  * @reserved1:	reserved
1549  * @ndir_dns_powr:	Power of non-direct denoising,
1550  *			Precision u1.6, range [0, 64], default 64.
1551  * @reserved2:	reserved
1552  */
1553 struct ipu3_uapi_far_w {
1554 	__u32 dir_shrp:7;
1555 	__u32 reserved0:1;
1556 	__u32 dir_dns:7;
1557 	__u32 reserved1:1;
1558 	__u32 ndir_dns_powr:7;
1559 	__u32 reserved2:9;
1560 } __packed;
1561 
1562 /**
1563  * struct ipu3_uapi_unsharp_cfg - Unsharp config
1564  *
1565  * @unsharp_weight: Unsharp mask blending weight.
1566  *		    u1.6, range [0, 64], default 16.
1567  *		    0 - disabled, 64 - use only unsharp.
1568  * @reserved0: reserved
1569  * @unsharp_amount: Unsharp mask amount, u4.5, range [0, 511], default 0.
1570  * @reserved1: reserved
1571  */
1572 struct ipu3_uapi_unsharp_cfg {
1573 	__u32 unsharp_weight:7;
1574 	__u32 reserved0:1;
1575 	__u32 unsharp_amount:9;
1576 	__u32 reserved1:15;
1577 } __packed;
1578 
1579 /**
1580  * struct ipu3_uapi_yuvp1_iefd_shrp_cfg - IEFd sharpness config
1581  *
1582  * @cfg: sharpness config &ipu3_uapi_sharp_cfg
1583  * @far_w: wide range config, value as specified by &ipu3_uapi_far_w:
1584  *	The 5x5 environment is separated into 2 sub-groups, the 3x3 nearest
1585  *	neighbors (8 pixels called Near), and the second order neighborhood
1586  *	around them (16 pixels called Far).
1587  * @unshrp_cfg: unsharpness config. &ipu3_uapi_unsharp_cfg
1588  */
1589 struct ipu3_uapi_yuvp1_iefd_shrp_cfg {
1590 	struct ipu3_uapi_sharp_cfg cfg;
1591 	struct ipu3_uapi_far_w far_w;
1592 	struct ipu3_uapi_unsharp_cfg unshrp_cfg;
1593 } __packed;
1594 
1595 /**
1596  * struct ipu3_uapi_unsharp_coef0 - Unsharp mask coefficients
1597  *
1598  * @c00: Coeff11, s0.8, range [-255, 255], default 1.
1599  * @c01: Coeff12, s0.8, range [-255, 255], default 5.
1600  * @c02: Coeff13, s0.8, range [-255, 255], default 9.
1601  * @reserved: reserved
1602  *
1603  * Configurable registers for common sharpening support.
1604  */
1605 struct ipu3_uapi_unsharp_coef0 {
1606 	__u32 c00:9;
1607 	__u32 c01:9;
1608 	__u32 c02:9;
1609 	__u32 reserved:5;
1610 } __packed;
1611 
1612 /**
1613  * struct ipu3_uapi_unsharp_coef1 - Unsharp mask coefficients
1614  *
1615  * @c11: Coeff22, s0.8, range [-255, 255], default 29.
1616  * @c12: Coeff23, s0.8, range [-255, 255], default 55.
1617  * @c22: Coeff33, s0.8, range [-255, 255], default 96.
1618  * @reserved: reserved
1619  */
1620 struct ipu3_uapi_unsharp_coef1 {
1621 	__u32 c11:9;
1622 	__u32 c12:9;
1623 	__u32 c22:9;
1624 	__u32 reserved:5;
1625 } __packed;
1626 
1627 /**
1628  * struct ipu3_uapi_yuvp1_iefd_unshrp_cfg - Unsharp mask config
1629  *
1630  * @unsharp_coef0: unsharp coefficient 0 config. See &ipu3_uapi_unsharp_coef0
1631  * @unsharp_coef1: unsharp coefficient 1 config. See &ipu3_uapi_unsharp_coef1
1632  */
1633 struct ipu3_uapi_yuvp1_iefd_unshrp_cfg {
1634 	struct ipu3_uapi_unsharp_coef0 unsharp_coef0;
1635 	struct ipu3_uapi_unsharp_coef1 unsharp_coef1;
1636 } __packed;
1637 
1638 /**
1639  * struct ipu3_uapi_radial_reset_xy - Radial coordinate reset
1640  *
1641  * @x:	Radial reset of x coordinate. Precision s12, [-4095, 4095], default 0.
1642  * @reserved0:	reserved
1643  * @y:	Radial center y coordinate. Precision s12, [-4095, 4095], default 0.
1644  * @reserved1:	reserved
1645  */
1646 struct ipu3_uapi_radial_reset_xy {
1647 	__s32 x:13;
1648 	__u32 reserved0:3;
1649 	__s32 y:13;
1650 	__u32 reserved1:3;
1651 } __packed;
1652 
1653 /**
1654  * struct ipu3_uapi_radial_reset_x2 - Radial X^2 reset
1655  *
1656  * @x2:	Radial reset of x^2 coordinate. Precision u24, default 0.
1657  * @reserved:	reserved
1658  */
1659 struct ipu3_uapi_radial_reset_x2 {
1660 	__u32 x2:24;
1661 	__u32 reserved:8;
1662 } __packed;
1663 
1664 /**
1665  * struct ipu3_uapi_radial_reset_y2 - Radial Y^2 reset
1666  *
1667  * @y2:	Radial reset of y^2 coordinate. Precision u24, default 0.
1668  * @reserved:	reserved
1669  */
1670 struct ipu3_uapi_radial_reset_y2 {
1671 	__u32 y2:24;
1672 	__u32 reserved:8;
1673 } __packed;
1674 
1675 /**
1676  * struct ipu3_uapi_radial_cfg - Radial config
1677  *
1678  * @rad_nf: Radial. R^2 normalization factor is scale down by 2^ - (15 + scale)
1679  * @reserved0: reserved
1680  * @rad_inv_r2: Radial R^-2 normelized to (0.5..1).
1681  *		Precision u7, range [0, 127].
1682  * @reserved1: reserved
1683  */
1684 struct ipu3_uapi_radial_cfg {
1685 	__u32 rad_nf:4;
1686 	__u32 reserved0:4;
1687 	__u32 rad_inv_r2:7;
1688 	__u32 reserved1:17;
1689 } __packed;
1690 
1691 /**
1692  * struct ipu3_uapi_rad_far_w - Radial FAR sub-group
1693  *
1694  * @rad_dir_far_sharp_w: Weight of wide direct sharpening, u1.6, range [0, 64],
1695  *			 default 64.
1696  * @rad_dir_far_dns_w: Weight of wide direct denoising, u1.6, range [0, 64],
1697  *			 default 0.
1698  * @rad_ndir_far_dns_power: power of non-direct sharpening, u1.6, range [0, 64],
1699  *			 default 0.
1700  * @reserved: reserved
1701  */
1702 struct ipu3_uapi_rad_far_w {
1703 	__u32 rad_dir_far_sharp_w:8;
1704 	__u32 rad_dir_far_dns_w:8;
1705 	__u32 rad_ndir_far_dns_power:8;
1706 	__u32 reserved:8;
1707 } __packed;
1708 
1709 /**
1710  * struct ipu3_uapi_cu_cfg0 - Radius Config Unit cfg0 register
1711  *
1712  * @cu6_pow: Power of CU6. Power of non-direct sharpening, u3.4.
1713  * @reserved0: reserved
1714  * @cu_unsharp_pow: Power of unsharp mask, u2.4.
1715  * @reserved1: reserved
1716  * @rad_cu6_pow: Radial/corner CU6. Directed sharpening power, u3.4.
1717  * @reserved2: reserved
1718  * @rad_cu_unsharp_pow: Radial power of unsharp mask, u2.4.
1719  * @reserved3: reserved
1720  */
1721 struct ipu3_uapi_cu_cfg0 {
1722 	__u32 cu6_pow:7;
1723 	__u32 reserved0:1;
1724 	__u32 cu_unsharp_pow:7;
1725 	__u32 reserved1:1;
1726 	__u32 rad_cu6_pow:7;
1727 	__u32 reserved2:1;
1728 	__u32 rad_cu_unsharp_pow:6;
1729 	__u32 reserved3:2;
1730 } __packed;
1731 
1732 /**
1733  * struct ipu3_uapi_cu_cfg1 - Radius Config Unit cfg1 register
1734  *
1735  * @rad_cu6_x1: X1 point of Config Unit 6, precision u9.0.
1736  * @reserved0: reserved
1737  * @rad_cu_unsharp_x1: X1 point for Config Unit unsharp for radial/corner point
1738  *			precision u9.0.
1739  * @reserved1: reserved
1740  */
1741 struct ipu3_uapi_cu_cfg1 {
1742 	__u32 rad_cu6_x1:9;
1743 	__u32 reserved0:1;
1744 	__u32 rad_cu_unsharp_x1:9;
1745 	__u32 reserved1:13;
1746 } __packed;
1747 
1748 /**
1749  * struct ipu3_uapi_yuvp1_iefd_rad_cfg - IEFd parameters changed radially over
1750  *					 the picture plane.
1751  *
1752  * @reset_xy: reset xy value in radial calculation. &ipu3_uapi_radial_reset_xy
1753  * @reset_x2: reset x square value in radial calculation. See struct
1754  *	      &ipu3_uapi_radial_reset_x2
1755  * @reset_y2: reset y square value in radial calculation. See struct
1756  *	      &ipu3_uapi_radial_reset_y2
1757  * @cfg: radial config defined in &ipu3_uapi_radial_cfg
1758  * @rad_far_w: weight for wide range radial. &ipu3_uapi_rad_far_w
1759  * @cu_cfg0: configuration unit 0. See &ipu3_uapi_cu_cfg0
1760  * @cu_cfg1: configuration unit 1. See &ipu3_uapi_cu_cfg1
1761  */
1762 struct ipu3_uapi_yuvp1_iefd_rad_cfg {
1763 	struct ipu3_uapi_radial_reset_xy reset_xy;
1764 	struct ipu3_uapi_radial_reset_x2 reset_x2;
1765 	struct ipu3_uapi_radial_reset_y2 reset_y2;
1766 	struct ipu3_uapi_radial_cfg cfg;
1767 	struct ipu3_uapi_rad_far_w rad_far_w;
1768 	struct ipu3_uapi_cu_cfg0 cu_cfg0;
1769 	struct ipu3_uapi_cu_cfg1 cu_cfg1;
1770 } __packed;
1771 
1772 /* Vssnlm - Very small scale non-local mean algorithm */
1773 
1774 /**
1775  * struct ipu3_uapi_vss_lut_x - Vssnlm LUT x0/x1/x2
1776  *
1777  * @vs_x0: Vssnlm LUT x0, precision u8, range [0, 255], default 16.
1778  * @vs_x1: Vssnlm LUT x1, precision u8, range [0, 255], default 32.
1779  * @vs_x2: Vssnlm LUT x2, precision u8, range [0, 255], default 64.
1780  * @reserved2: reserved
1781  */
1782 struct ipu3_uapi_vss_lut_x {
1783 	__u32 vs_x0:8;
1784 	__u32 vs_x1:8;
1785 	__u32 vs_x2:8;
1786 	__u32 reserved2:8;
1787 } __packed;
1788 
1789 /**
1790  * struct ipu3_uapi_vss_lut_y - Vssnlm LUT y0/y1/y2
1791  *
1792  * @vs_y1: Vssnlm LUT y1, precision u4, range [0, 8], default 1.
1793  * @reserved0: reserved
1794  * @vs_y2: Vssnlm LUT y2, precision u4, range [0, 8], default 3.
1795  * @reserved1: reserved
1796  * @vs_y3: Vssnlm LUT y3, precision u4, range [0, 8], default 8.
1797  * @reserved2: reserved
1798  */
1799 struct ipu3_uapi_vss_lut_y {
1800 	__u32 vs_y1:4;
1801 	__u32 reserved0:4;
1802 	__u32 vs_y2:4;
1803 	__u32 reserved1:4;
1804 	__u32 vs_y3:4;
1805 	__u32 reserved2:12;
1806 } __packed;
1807 
1808 /**
1809  * struct ipu3_uapi_yuvp1_iefd_vssnlm_cfg - IEFd Vssnlm Lookup table
1810  *
1811  * @vss_lut_x: vss lookup table. See &ipu3_uapi_vss_lut_x description
1812  * @vss_lut_y: vss lookup table. See &ipu3_uapi_vss_lut_y description
1813  */
1814 struct ipu3_uapi_yuvp1_iefd_vssnlm_cfg {
1815 	struct ipu3_uapi_vss_lut_x vss_lut_x;
1816 	struct ipu3_uapi_vss_lut_y vss_lut_y;
1817 } __packed;
1818 
1819 /**
1820  * struct ipu3_uapi_yuvp1_iefd_config - IEFd config
1821  *
1822  * @units: configuration unit setting, &ipu3_uapi_yuvp1_iefd_cfg_units
1823  * @config: configuration, as defined by &ipu3_uapi_yuvp1_iefd_config_s
1824  * @control: control setting, as defined by &ipu3_uapi_yuvp1_iefd_control
1825  * @sharp: sharpness setting, as defined by &ipu3_uapi_yuvp1_iefd_shrp_cfg
1826  * @unsharp: unsharpness setting, as defined by &ipu3_uapi_yuvp1_iefd_unshrp_cfg
1827  * @rad: radial setting, as defined by &ipu3_uapi_yuvp1_iefd_rad_cfg
1828  * @vsslnm: vsslnm setting, as defined by &ipu3_uapi_yuvp1_iefd_vssnlm_cfg
1829  */
1830 struct ipu3_uapi_yuvp1_iefd_config {
1831 	struct ipu3_uapi_yuvp1_iefd_cfg_units units;
1832 	struct ipu3_uapi_yuvp1_iefd_config_s config;
1833 	struct ipu3_uapi_yuvp1_iefd_control control;
1834 	struct ipu3_uapi_yuvp1_iefd_shrp_cfg sharp;
1835 	struct ipu3_uapi_yuvp1_iefd_unshrp_cfg unsharp;
1836 	struct ipu3_uapi_yuvp1_iefd_rad_cfg rad;
1837 	struct ipu3_uapi_yuvp1_iefd_vssnlm_cfg vsslnm;
1838 } __packed;
1839 
1840 /**
1841  * struct ipu3_uapi_yuvp1_yds_config - Y Down-Sampling config
1842  *
1843  * @c00: range [0, 3], default 0x0
1844  * @c01: range [0, 3], default 0x1
1845  * @c02: range [0, 3], default 0x1
1846  * @c03: range [0, 3], default 0x0
1847  * @c10: range [0, 3], default 0x0
1848  * @c11: range [0, 3], default 0x1
1849  * @c12: range [0, 3], default 0x1
1850  * @c13: range [0, 3], default 0x0
1851  *
1852  * Above are 4x2 filter coefficients for chroma output downscaling.
1853  *
1854  * @norm_factor: Normalization factor, range [0, 4], default 2
1855  *		0 - divide by 1
1856  *		1 - divide by 2
1857  *		2 - divide by 4
1858  *		3 - divide by 8
1859  *		4 - divide by 16
1860  * @reserved0: reserved
1861  * @bin_output: Down sampling on Luma channel in two optional modes
1862  *		0 - Bin output 4.2.0 (default), 1 output 4.2.2.
1863  * @reserved1: reserved
1864  */
1865 struct ipu3_uapi_yuvp1_yds_config {
1866 	__u32 c00:2;
1867 	__u32 c01:2;
1868 	__u32 c02:2;
1869 	__u32 c03:2;
1870 	__u32 c10:2;
1871 	__u32 c11:2;
1872 	__u32 c12:2;
1873 	__u32 c13:2;
1874 	__u32 norm_factor:5;
1875 	__u32 reserved0:4;
1876 	__u32 bin_output:1;
1877 	__u32 reserved1:6;
1878 } __packed;
1879 
1880 /* Chroma Noise Reduction */
1881 
1882 /**
1883  * struct ipu3_uapi_yuvp1_chnr_enable_config - Chroma noise reduction enable
1884  *
1885  * @enable: enable/disable chroma noise reduction
1886  * @yuv_mode: 0 - YUV420, 1 - YUV422
1887  * @reserved0: reserved
1888  * @col_size: number of columns in the frame, max width is 2560
1889  * @reserved1: reserved
1890  */
1891 struct ipu3_uapi_yuvp1_chnr_enable_config {
1892 	__u32 enable:1;
1893 	__u32 yuv_mode:1;
1894 	__u32 reserved0:14;
1895 	__u32 col_size:12;
1896 	__u32 reserved1:4;
1897 } __packed;
1898 
1899 /**
1900  * struct ipu3_uapi_yuvp1_chnr_coring_config - Coring thresholds for UV
1901  *
1902  * @u: U coring level, u0.13, range [0.0, 1.0], default 0.0
1903  * @reserved0: reserved
1904  * @v: V coring level, u0.13, range [0.0, 1.0], default 0.0
1905  * @reserved1: reserved
1906  */
1907 struct ipu3_uapi_yuvp1_chnr_coring_config {
1908 	__u32 u:13;
1909 	__u32 reserved0:3;
1910 	__u32 v:13;
1911 	__u32 reserved1:3;
1912 } __packed;
1913 
1914 /**
1915  * struct ipu3_uapi_yuvp1_chnr_sense_gain_config - Chroma noise reduction gains
1916  *
1917  * All sensitivity gain parameters have precision u13.0, range [0, 8191].
1918  *
1919  * @vy: Sensitivity of horizontal edge of Y, default 100
1920  * @vu: Sensitivity of horizontal edge of U, default 100
1921  * @vv: Sensitivity of horizontal edge of V, default 100
1922  * @reserved0: reserved
1923  * @hy: Sensitivity of vertical edge of Y, default 50
1924  * @hu: Sensitivity of vertical edge of U, default 50
1925  * @hv: Sensitivity of vertical edge of V, default 50
1926  * @reserved1: reserved
1927  */
1928 struct ipu3_uapi_yuvp1_chnr_sense_gain_config {
1929 	__u32 vy:8;
1930 	__u32 vu:8;
1931 	__u32 vv:8;
1932 	__u32 reserved0:8;
1933 
1934 	__u32 hy:8;
1935 	__u32 hu:8;
1936 	__u32 hv:8;
1937 	__u32 reserved1:8;
1938 } __packed;
1939 
1940 /**
1941  * struct ipu3_uapi_yuvp1_chnr_iir_fir_config - Chroma IIR/FIR filter config
1942  *
1943  * @fir_0h: Value of center tap in horizontal FIR, range [0, 32], default 8.
1944  * @reserved0: reserved
1945  * @fir_1h: Value of distance 1 in horizontal FIR, range [0, 32], default 12.
1946  * @reserved1: reserved
1947  * @fir_2h: Value of distance 2 tap in horizontal FIR, range [0, 32], default 0.
1948  * @dalpha_clip_val: weight for previous row in IIR, range [1, 256], default 0.
1949  * @reserved2: reserved
1950  */
1951 struct ipu3_uapi_yuvp1_chnr_iir_fir_config {
1952 	__u32 fir_0h:6;
1953 	__u32 reserved0:2;
1954 	__u32 fir_1h:6;
1955 	__u32 reserved1:2;
1956 	__u32 fir_2h:6;
1957 	__u32 dalpha_clip_val:9;
1958 	__u32 reserved2:1;
1959 } __packed;
1960 
1961 /**
1962  * struct ipu3_uapi_yuvp1_chnr_config - Chroma noise reduction config
1963  *
1964  * @enable: chroma noise reduction enable, see
1965  *	    &ipu3_uapi_yuvp1_chnr_enable_config
1966  * @coring: coring config for chroma noise reduction, see
1967  *	    &ipu3_uapi_yuvp1_chnr_coring_config
1968  * @sense_gain: sensitivity config for chroma noise reduction, see
1969  *		ipu3_uapi_yuvp1_chnr_sense_gain_config
1970  * @iir_fir: iir and fir config for chroma noise reduction, see
1971  *	     ipu3_uapi_yuvp1_chnr_iir_fir_config
1972  */
1973 struct ipu3_uapi_yuvp1_chnr_config {
1974 	struct ipu3_uapi_yuvp1_chnr_enable_config enable;
1975 	struct ipu3_uapi_yuvp1_chnr_coring_config coring;
1976 	struct ipu3_uapi_yuvp1_chnr_sense_gain_config sense_gain;
1977 	struct ipu3_uapi_yuvp1_chnr_iir_fir_config iir_fir;
1978 } __packed;
1979 
1980 /* Edge Enhancement and Noise Reduction */
1981 
1982 /**
1983  * struct ipu3_uapi_yuvp1_y_ee_nr_lpf_config - Luma(Y) edge enhancement low-pass
1984  *					       filter coefficients
1985  *
1986  * @a_diag: Smoothing diagonal coefficient, u5.0.
1987  * @reserved0: reserved
1988  * @a_periph: Image smoothing perpherial, u5.0.
1989  * @reserved1: reserved
1990  * @a_cent: Image Smoothing center coefficient, u5.0.
1991  * @reserved2: reserved
1992  * @enable: 0: Y_EE_NR disabled, output = input; 1: Y_EE_NR enabled.
1993  */
1994 struct ipu3_uapi_yuvp1_y_ee_nr_lpf_config {
1995 	__u32 a_diag:5;
1996 	__u32 reserved0:3;
1997 	__u32 a_periph:5;
1998 	__u32 reserved1:3;
1999 	__u32 a_cent:5;
2000 	__u32 reserved2:9;
2001 	__u32 enable:1;
2002 } __packed;
2003 
2004 /**
2005  * struct ipu3_uapi_yuvp1_y_ee_nr_sense_config - Luma(Y) edge enhancement
2006  *					noise reduction sensitivity gains
2007  *
2008  * @edge_sense_0: Sensitivity of edge in dark area. u13.0, default 8191.
2009  * @reserved0: reserved
2010  * @delta_edge_sense: Difference in the sensitivity of edges between
2011  *		      the bright and dark areas. u13.0, default 0.
2012  * @reserved1: reserved
2013  * @corner_sense_0: Sensitivity of corner in dark area. u13.0, default 0.
2014  * @reserved2: reserved
2015  * @delta_corner_sense: Difference in the sensitivity of corners between
2016  *			the bright and dark areas. u13.0, default 8191.
2017  * @reserved3: reserved
2018  */
2019 struct ipu3_uapi_yuvp1_y_ee_nr_sense_config {
2020 	__u32 edge_sense_0:13;
2021 	__u32 reserved0:3;
2022 	__u32 delta_edge_sense:13;
2023 	__u32 reserved1:3;
2024 	__u32 corner_sense_0:13;
2025 	__u32 reserved2:3;
2026 	__u32 delta_corner_sense:13;
2027 	__u32 reserved3:3;
2028 } __packed;
2029 
2030 /**
2031  * struct ipu3_uapi_yuvp1_y_ee_nr_gain_config - Luma(Y) edge enhancement
2032  *						noise reduction gain config
2033  *
2034  * @gain_pos_0: Gain for positive edge in dark area. u5.0, [0, 16], default 2.
2035  * @reserved0: reserved
2036  * @delta_gain_posi: Difference in the gain of edges between the bright and
2037  *		     dark areas for positive edges. u5.0, [0, 16], default 0.
2038  * @reserved1: reserved
2039  * @gain_neg_0: Gain for negative edge in dark area. u5.0, [0, 16], default 8.
2040  * @reserved2: reserved
2041  * @delta_gain_neg: Difference in the gain of edges between the bright and
2042  *		    dark areas for negative edges. u5.0, [0, 16], default 0.
2043  * @reserved3: reserved
2044  */
2045 struct ipu3_uapi_yuvp1_y_ee_nr_gain_config {
2046 	__u32 gain_pos_0:5;
2047 	__u32 reserved0:3;
2048 	__u32 delta_gain_posi:5;
2049 	__u32 reserved1:3;
2050 	__u32 gain_neg_0:5;
2051 	__u32 reserved2:3;
2052 	__u32 delta_gain_neg:5;
2053 	__u32 reserved3:3;
2054 } __packed;
2055 
2056 /**
2057  * struct ipu3_uapi_yuvp1_y_ee_nr_clip_config - Luma(Y) edge enhancement
2058  *					noise reduction clipping config
2059  *
2060  * @clip_pos_0: Limit of positive edge in dark area
2061  *		u5, value [0, 16], default 8.
2062  * @reserved0: reserved
2063  * @delta_clip_posi: Difference in the limit of edges between the bright
2064  *		     and dark areas for positive edges.
2065  *		     u5, value [0, 16], default 8.
2066  * @reserved1: reserved
2067  * @clip_neg_0: Limit of negative edge in dark area
2068  *		u5, value [0, 16], default 8.
2069  * @reserved2: reserved
2070  * @delta_clip_neg: Difference in the limit of edges between the bright
2071  *		    and dark areas for negative edges.
2072  *		    u5, value [0, 16], default 8.
2073  * @reserved3: reserved
2074  */
2075 struct ipu3_uapi_yuvp1_y_ee_nr_clip_config {
2076 	__u32 clip_pos_0:5;
2077 	__u32 reserved0:3;
2078 	__u32 delta_clip_posi:5;
2079 	__u32 reserved1:3;
2080 	__u32 clip_neg_0:5;
2081 	__u32 reserved2:3;
2082 	__u32 delta_clip_neg:5;
2083 	__u32 reserved3:3;
2084 } __packed;
2085 
2086 /**
2087  * struct ipu3_uapi_yuvp1_y_ee_nr_frng_config - Luma(Y) edge enhancement
2088  *						noise reduction fringe config
2089  *
2090  * @gain_exp: Common exponent of gains, u4, [0, 8], default 2.
2091  * @reserved0: reserved
2092  * @min_edge: Threshold for edge and smooth stitching, u13.
2093  * @reserved1: reserved
2094  * @lin_seg_param: Power of LinSeg, u4.
2095  * @reserved2: reserved
2096  * @t1: Parameter for enabling/disabling the edge enhancement, u1.0, [0, 1],
2097  *	default 1.
2098  * @t2: Parameter for enabling/disabling the smoothing, u1.0, [0, 1],
2099  *	default 1.
2100  * @reserved3: reserved
2101  */
2102 struct ipu3_uapi_yuvp1_y_ee_nr_frng_config {
2103 	__u32 gain_exp:4;
2104 	__u32 reserved0:28;
2105 	__u32 min_edge:13;
2106 	__u32 reserved1:3;
2107 	__u32 lin_seg_param:4;
2108 	__u32 reserved2:4;
2109 	__u32 t1:1;
2110 	__u32 t2:1;
2111 	__u32 reserved3:6;
2112 } __packed;
2113 
2114 /**
2115  * struct ipu3_uapi_yuvp1_y_ee_nr_diag_config - Luma(Y) edge enhancement
2116  *					noise reduction diagonal config
2117  *
2118  * @diag_disc_g: Coefficient that prioritize diagonal edge direction on
2119  *		 horizontal or vertical for final enhancement.
2120  *		 u4.0, [1, 15], default 1.
2121  * @reserved0: reserved
2122  * @hvw_hor: Weight of horizontal/vertical edge enhancement for hv edge.
2123  *		u2.2, [1, 15], default 4.
2124  * @dw_hor: Weight of diagonal edge enhancement for hv edge.
2125  *		u2.2, [1, 15], default 1.
2126  * @hvw_diag: Weight of horizontal/vertical edge enhancement for diagonal edge.
2127  *		u2.2, [1, 15], default 1.
2128  * @dw_diag: Weight of diagonal edge enhancement for diagonal edge.
2129  *		u2.2, [1, 15], default 4.
2130  * @reserved1: reserved
2131  */
2132 struct ipu3_uapi_yuvp1_y_ee_nr_diag_config {
2133 	__u32 diag_disc_g:4;
2134 	__u32 reserved0:4;
2135 	__u32 hvw_hor:4;
2136 	__u32 dw_hor:4;
2137 	__u32 hvw_diag:4;
2138 	__u32 dw_diag:4;
2139 	__u32 reserved1:8;
2140 } __packed;
2141 
2142 /**
2143  * struct ipu3_uapi_yuvp1_y_ee_nr_fc_coring_config - Luma(Y) edge enhancement
2144  *		noise reduction false color correction (FCC) coring config
2145  *
2146  * @pos_0: Gain for positive edge in dark, u13.0, [0, 16], default 0.
2147  * @reserved0: reserved
2148  * @pos_delta: Gain for positive edge in bright, value: pos_0 + pos_delta <=16
2149  *		u13.0, default 0.
2150  * @reserved1: reserved
2151  * @neg_0: Gain for negative edge in dark area, u13.0, range [0, 16], default 0.
2152  * @reserved2: reserved
2153  * @neg_delta: Gain for negative edge in bright area. neg_0 + neg_delta <=16
2154  *		u13.0, default 0.
2155  * @reserved3: reserved
2156  *
2157  * Coring is a simple soft thresholding technique.
2158  */
2159 struct ipu3_uapi_yuvp1_y_ee_nr_fc_coring_config {
2160 	__u32 pos_0:13;
2161 	__u32 reserved0:3;
2162 	__u32 pos_delta:13;
2163 	__u32 reserved1:3;
2164 	__u32 neg_0:13;
2165 	__u32 reserved2:3;
2166 	__u32 neg_delta:13;
2167 	__u32 reserved3:3;
2168 } __packed;
2169 
2170 /**
2171  * struct ipu3_uapi_yuvp1_y_ee_nr_config - Edge enhancement and noise reduction
2172  *
2173  * @lpf: low-pass filter config. See &ipu3_uapi_yuvp1_y_ee_nr_lpf_config
2174  * @sense: sensitivity config. See &ipu3_uapi_yuvp1_y_ee_nr_sense_config
2175  * @gain: gain config as defined in &ipu3_uapi_yuvp1_y_ee_nr_gain_config
2176  * @clip: clip config as defined in &ipu3_uapi_yuvp1_y_ee_nr_clip_config
2177  * @frng: fringe config as defined in &ipu3_uapi_yuvp1_y_ee_nr_frng_config
2178  * @diag: diagonal edge config. See &ipu3_uapi_yuvp1_y_ee_nr_diag_config
2179  * @fc_coring: coring config for fringe control. See
2180  *	       &ipu3_uapi_yuvp1_y_ee_nr_fc_coring_config
2181  */
2182 struct ipu3_uapi_yuvp1_y_ee_nr_config {
2183 	struct ipu3_uapi_yuvp1_y_ee_nr_lpf_config lpf;
2184 	struct ipu3_uapi_yuvp1_y_ee_nr_sense_config sense;
2185 	struct ipu3_uapi_yuvp1_y_ee_nr_gain_config gain;
2186 	struct ipu3_uapi_yuvp1_y_ee_nr_clip_config clip;
2187 	struct ipu3_uapi_yuvp1_y_ee_nr_frng_config frng;
2188 	struct ipu3_uapi_yuvp1_y_ee_nr_diag_config diag;
2189 	struct ipu3_uapi_yuvp1_y_ee_nr_fc_coring_config fc_coring;
2190 } __packed;
2191 
2192 /* Total Color Correction */
2193 
2194 /**
2195  * struct ipu3_uapi_yuvp2_tcc_gen_control_static_config - Total color correction
2196  *				general control config
2197  *
2198  * @en:	0 - TCC disabled. Output = input 1 - TCC enabled.
2199  * @blend_shift:	blend shift, Range[3, 4], default NA.
2200  * @gain_according_to_y_only:	0: Gain is calculated according to YUV,
2201  *				1: Gain is calculated according to Y only
2202  * @reserved0: reserved
2203  * @gamma:	Final blending coefficients. Values[-16, 16], default NA.
2204  * @reserved1: reserved
2205  * @delta:	Final blending coefficients. Values[-16, 16], default NA.
2206  * @reserved2: reserved
2207  */
2208 struct ipu3_uapi_yuvp2_tcc_gen_control_static_config {
2209 	__u32 en:1;
2210 	__u32 blend_shift:3;
2211 	__u32 gain_according_to_y_only:1;
2212 	__u32 reserved0:11;
2213 	__s32 gamma:5;
2214 	__u32 reserved1:3;
2215 	__s32 delta:5;
2216 	__u32 reserved2:3;
2217 } __packed;
2218 
2219 /**
2220  * struct ipu3_uapi_yuvp2_tcc_macc_elem_static_config - Total color correction
2221  *				multi-axis color control (MACC) config
2222  *
2223  * @a: a coefficient for 2x2 MACC conversion matrix.
2224  * @reserved0: reserved
2225  * @b: b coefficient  2x2 MACC conversion matrix.
2226  * @reserved1: reserved
2227  * @c: c coefficient for 2x2 MACC conversion matrix.
2228  * @reserved2: reserved
2229  * @d: d coefficient for 2x2 MACC conversion matrix.
2230  * @reserved3: reserved
2231  */
2232 struct ipu3_uapi_yuvp2_tcc_macc_elem_static_config {
2233 	__s32 a:12;
2234 	__u32 reserved0:4;
2235 	__s32 b:12;
2236 	__u32 reserved1:4;
2237 	__s32 c:12;
2238 	__u32 reserved2:4;
2239 	__s32 d:12;
2240 	__u32 reserved3:4;
2241 } __packed;
2242 
2243 /**
2244  * struct ipu3_uapi_yuvp2_tcc_macc_table_static_config - Total color correction
2245  *				multi-axis color control (MACC) table array
2246  *
2247  * @entries: config for multi axis color correction, as specified by
2248  *	     &ipu3_uapi_yuvp2_tcc_macc_elem_static_config
2249  */
2250 struct ipu3_uapi_yuvp2_tcc_macc_table_static_config {
2251 	struct ipu3_uapi_yuvp2_tcc_macc_elem_static_config
2252 		entries[IPU3_UAPI_YUVP2_TCC_MACC_TABLE_ELEMENTS];
2253 } __packed;
2254 
2255 /**
2256  * struct ipu3_uapi_yuvp2_tcc_inv_y_lut_static_config - Total color correction
2257  *				inverse y lookup table
2258  *
2259  * @entries: lookup table for inverse y estimation, and use it to estimate the
2260  *	     ratio between luma and chroma. Chroma by approximate the absolute
2261  *	     value of the radius on the chroma plane (R = sqrt(u^2+v^2) ) and
2262  *	     luma by approximate by 1/Y.
2263  */
2264 struct ipu3_uapi_yuvp2_tcc_inv_y_lut_static_config {
2265 	__u16 entries[IPU3_UAPI_YUVP2_TCC_INV_Y_LUT_ELEMENTS];
2266 } __packed;
2267 
2268 /**
2269  * struct ipu3_uapi_yuvp2_tcc_gain_pcwl_lut_static_config - Total color
2270  *					correction lookup table for PCWL
2271  *
2272  * @entries: lookup table for gain piece wise linear transformation (PCWL)
2273  */
2274 struct ipu3_uapi_yuvp2_tcc_gain_pcwl_lut_static_config {
2275 	__u16 entries[IPU3_UAPI_YUVP2_TCC_GAIN_PCWL_LUT_ELEMENTS];
2276 } __packed;
2277 
2278 /**
2279  * struct ipu3_uapi_yuvp2_tcc_r_sqr_lut_static_config - Total color correction
2280  *				lookup table for r square root
2281  *
2282  * @entries: lookup table for r square root estimation
2283  */
2284 struct ipu3_uapi_yuvp2_tcc_r_sqr_lut_static_config {
2285 	__s16 entries[IPU3_UAPI_YUVP2_TCC_R_SQR_LUT_ELEMENTS];
2286 } __packed;
2287 
2288 /**
2289  * struct ipu3_uapi_yuvp2_tcc_static_config- Total color correction static
2290  *
2291  * @gen_control: general config for Total Color Correction
2292  * @macc_table: config for multi axis color correction
2293  * @inv_y_lut: lookup table for inverse y estimation
2294  * @gain_pcwl: lookup table for gain PCWL
2295  * @r_sqr_lut: lookup table for r square root estimation.
2296  */
2297 struct ipu3_uapi_yuvp2_tcc_static_config {
2298 	struct ipu3_uapi_yuvp2_tcc_gen_control_static_config gen_control;
2299 	struct ipu3_uapi_yuvp2_tcc_macc_table_static_config macc_table;
2300 	struct ipu3_uapi_yuvp2_tcc_inv_y_lut_static_config inv_y_lut;
2301 	struct ipu3_uapi_yuvp2_tcc_gain_pcwl_lut_static_config gain_pcwl;
2302 	struct ipu3_uapi_yuvp2_tcc_r_sqr_lut_static_config r_sqr_lut;
2303 } __packed;
2304 
2305 /* Advanced Noise Reduction related structs */
2306 
2307 /*
2308  * struct ipu3_uapi_anr_alpha - Advanced noise reduction alpha
2309  *
2310  * Tunable parameters that are subject to modification according to the
2311  * total gain used.
2312  */
2313 struct ipu3_uapi_anr_alpha {
2314 	__u16 gr;
2315 	__u16 r;
2316 	__u16 b;
2317 	__u16 gb;
2318 	__u16 dc_gr;
2319 	__u16 dc_r;
2320 	__u16 dc_b;
2321 	__u16 dc_gb;
2322 } __packed;
2323 
2324 /*
2325  * struct ipu3_uapi_anr_beta - Advanced noise reduction beta
2326  *
2327  * Tunable parameters that are subject to modification according to the
2328  * total gain used.
2329  */
2330 struct ipu3_uapi_anr_beta {
2331 	__u16 beta_gr;
2332 	__u16 beta_r;
2333 	__u16 beta_b;
2334 	__u16 beta_gb;
2335 } __packed;
2336 
2337 /*
2338  * struct ipu3_uapi_anr_plane_color - Advanced noise reduction per plane R, Gr,
2339  *				      Gb and B register settings
2340  *
2341  * Tunable parameters that are subject to modification according to the
2342  * total gain used.
2343  */
2344 struct ipu3_uapi_anr_plane_color {
2345 	__u16 reg_w_gr[16];
2346 	__u16 reg_w_r[16];
2347 	__u16 reg_w_b[16];
2348 	__u16 reg_w_gb[16];
2349 } __packed;
2350 
2351 /**
2352  * struct ipu3_uapi_anr_transform_config - Advanced noise reduction transform
2353  *
2354  * @enable: advanced noise reduction enabled.
2355  * @adaptive_treshhold_en: On IPU3, adaptive threshold is always enabled.
2356  * @reserved1: reserved
2357  * @reserved2: reserved
2358  * @alpha: using following defaults:
2359  *		13, 13, 13, 13, 0, 0, 0, 0
2360  *		11, 11, 11, 11, 0, 0, 0, 0
2361  *		14,  14, 14, 14, 0, 0, 0, 0
2362  * @beta: use following defaults:
2363  *		24, 24, 24, 24
2364  *		21, 20, 20, 21
2365  *		25, 25, 25, 25
2366  * @color: use defaults defined in driver/media/pci/intel/ipu3-tables.c
2367  * @sqrt_lut: 11 bits per element, values =
2368  *					[724 768 810 849 887
2369  *					923 958 991 1024 1056
2370  *					1116 1145 1173 1201 1086
2371  *					1228 1254 1280 1305 1330
2372  *					1355 1379 1402 1425 1448]
2373  * @xreset: Reset value of X for r^2 calculation Value: col_start-X_center
2374  *	Constraint: Xreset + FrameWdith=4095 Xreset= -4095, default -1632.
2375  * @reserved3: reserved
2376  * @yreset: Reset value of Y for r^2 calculation Value: row_start-Y_center
2377  *	 Constraint: Yreset + FrameHeight=4095 Yreset= -4095, default -1224.
2378  * @reserved4: reserved
2379  * @x_sqr_reset: Reset value of X^2 for r^2 calculation Value = (Xreset)^2
2380  * @r_normfactor: Normalization factor for R. Default 14.
2381  * @reserved5: reserved
2382  * @y_sqr_reset: Reset value of Y^2 for r^2 calculation Value = (Yreset)^2
2383  * @gain_scale: Parameter describing shading gain as a function of distance
2384  *		from the image center.
2385  *		A single value per frame, loaded by the driver. Default 115.
2386  */
2387 struct ipu3_uapi_anr_transform_config {
2388 	__u32 enable:1;			/* 0 or 1, disabled or enabled */
2389 	__u32 adaptive_treshhold_en:1;	/* On IPU3, always enabled */
2390 
2391 	__u32 reserved1:30;
2392 	__u8 reserved2[44];
2393 
2394 	struct ipu3_uapi_anr_alpha alpha[3];
2395 	struct ipu3_uapi_anr_beta beta[3];
2396 	struct ipu3_uapi_anr_plane_color color[3];
2397 
2398 	__u16 sqrt_lut[IPU3_UAPI_ANR_LUT_SIZE];	/* 11 bits per element */
2399 
2400 	__s16 xreset:13;
2401 	__u16 reserved3:3;
2402 	__s16 yreset:13;
2403 	__u16 reserved4:3;
2404 
2405 	__u32 x_sqr_reset:24;
2406 	__u32 r_normfactor:5;
2407 	__u32 reserved5:3;
2408 
2409 	__u32 y_sqr_reset:24;
2410 	__u32 gain_scale:8;
2411 } __packed;
2412 
2413 /**
2414  * struct ipu3_uapi_anr_stitch_pyramid - ANR stitch pyramid
2415  *
2416  * @entry0: pyramid LUT entry0, range [0x0, 0x3f]
2417  * @entry1: pyramid LUT entry1, range [0x0, 0x3f]
2418  * @entry2: pyramid LUT entry2, range [0x0, 0x3f]
2419  * @reserved: reserved
2420  */
2421 struct ipu3_uapi_anr_stitch_pyramid {
2422 	__u32 entry0:6;
2423 	__u32 entry1:6;
2424 	__u32 entry2:6;
2425 	__u32 reserved:14;
2426 } __packed;
2427 
2428 /**
2429  * struct ipu3_uapi_anr_stitch_config - ANR stitch config
2430  *
2431  * @anr_stitch_en: enable stitch. Enabled with 1.
2432  * @reserved: reserved
2433  * @pyramid: pyramid table as defined by &ipu3_uapi_anr_stitch_pyramid
2434  *		default values:
2435  *		{ 1, 3, 5 }, { 7, 7, 5 }, { 3, 1, 3 },
2436  *		{ 9, 15, 21 }, { 21, 15, 9 }, { 3, 5, 15 },
2437  *		{ 25, 35, 35 }, { 25, 15, 5 }, { 7, 21, 35 },
2438  *		{ 49, 49, 35 }, { 21, 7, 7 }, { 21, 35, 49 },
2439  *		{ 49, 35, 21 }, { 7, 5, 15 }, { 25, 35, 35 },
2440  *		{ 25, 15, 5 }, { 3, 9, 15 }, { 21, 21, 15 },
2441  *		{ 9, 3, 1 }, { 3, 5, 7 }, { 7, 5, 3}, { 1 }
2442  */
2443 struct ipu3_uapi_anr_stitch_config {
2444 	__u32 anr_stitch_en;
2445 	__u8 reserved[44];
2446 	struct ipu3_uapi_anr_stitch_pyramid pyramid[IPU3_UAPI_ANR_PYRAMID_SIZE];
2447 } __packed;
2448 
2449 /**
2450  * struct ipu3_uapi_anr_config - ANR config
2451  *
2452  * @transform:	advanced noise reduction transform config as specified by
2453  *		&ipu3_uapi_anr_transform_config
2454  * @stitch: create 4x4 patch from 4 surrounding 8x8 patches.
2455  */
2456 struct ipu3_uapi_anr_config {
2457 	struct ipu3_uapi_anr_transform_config transform __attribute__((aligned(32)));
2458 	struct ipu3_uapi_anr_stitch_config stitch __attribute__((aligned(32)));
2459 } __packed;
2460 
2461 /**
2462  * struct ipu3_uapi_acc_param - Accelerator cluster parameters
2463  *
2464  * ACC refers to the HW cluster containing all Fixed Functions (FFs). Each FF
2465  * implements a specific algorithm.
2466  *
2467  * @bnr:	parameters for bayer noise reduction static config. See
2468  *		&ipu3_uapi_bnr_static_config
2469  * @green_disparity:	disparity static config between gr and gb channel.
2470  *			See &ipu3_uapi_bnr_static_config_green_disparity
2471  * @dm:	de-mosaic config. See &ipu3_uapi_dm_config
2472  * @ccm:	color correction matrix. See &ipu3_uapi_ccm_mat_config
2473  * @gamma:	gamma correction config. See &ipu3_uapi_gamma_config
2474  * @csc:	color space conversion matrix. See &ipu3_uapi_csc_mat_config
2475  * @cds:	color down sample config. See &ipu3_uapi_cds_params
2476  * @shd:	lens shading correction config. See &ipu3_uapi_shd_config
2477  * @iefd:	Image enhancement filter and denoise config.
2478  *		&ipu3_uapi_yuvp1_iefd_config
2479  * @yds_c0:	y down scaler config. &ipu3_uapi_yuvp1_yds_config
2480  * @chnr_c0:	chroma noise reduction config. &ipu3_uapi_yuvp1_chnr_config
2481  * @y_ee_nr:	y edge enhancement and noise reduction config.
2482  *		&ipu3_uapi_yuvp1_y_ee_nr_config
2483  * @yds:	y down scaler config. See &ipu3_uapi_yuvp1_yds_config
2484  * @chnr:	chroma noise reduction config. See &ipu3_uapi_yuvp1_chnr_config
2485  * @reserved1: reserved
2486  * @yds2:	y channel down scaler config. See &ipu3_uapi_yuvp1_yds_config
2487  * @tcc:	total color correction config as defined in struct
2488  *		&ipu3_uapi_yuvp2_tcc_static_config
2489  * @reserved2: reserved
2490  * @anr:	advanced noise reduction config.See &ipu3_uapi_anr_config
2491  * @awb_fr:	AWB filter response config. See ipu3_uapi_awb_fr_config
2492  * @ae:	auto exposure config  As specified by &ipu3_uapi_ae_config
2493  * @af:	auto focus config. As specified by &ipu3_uapi_af_config
2494  * @awb:	auto white balance config. As specified by &ipu3_uapi_awb_config
2495  */
2496 struct ipu3_uapi_acc_param {
2497 	struct ipu3_uapi_bnr_static_config bnr;
2498 	struct ipu3_uapi_bnr_static_config_green_disparity
2499 				green_disparity __attribute__((aligned(32)));
2500 	struct ipu3_uapi_dm_config dm __attribute__((aligned(32)));
2501 	struct ipu3_uapi_ccm_mat_config ccm __attribute__((aligned(32)));
2502 	struct ipu3_uapi_gamma_config gamma __attribute__((aligned(32)));
2503 	struct ipu3_uapi_csc_mat_config csc __attribute__((aligned(32)));
2504 	struct ipu3_uapi_cds_params cds __attribute__((aligned(32)));
2505 	struct ipu3_uapi_shd_config shd __attribute__((aligned(32)));
2506 	struct ipu3_uapi_yuvp1_iefd_config iefd __attribute__((aligned(32)));
2507 	struct ipu3_uapi_yuvp1_yds_config yds_c0 __attribute__((aligned(32)));
2508 	struct ipu3_uapi_yuvp1_chnr_config chnr_c0 __attribute__((aligned(32)));
2509 	struct ipu3_uapi_yuvp1_y_ee_nr_config y_ee_nr __attribute__((aligned(32)));
2510 	struct ipu3_uapi_yuvp1_yds_config yds __attribute__((aligned(32)));
2511 	struct ipu3_uapi_yuvp1_chnr_config chnr __attribute__((aligned(32)));
2512 	struct ipu3_uapi_yuvp1_yds_config yds2 __attribute__((aligned(32)));
2513 	struct ipu3_uapi_yuvp2_tcc_static_config tcc __attribute__((aligned(32)));
2514 	struct ipu3_uapi_anr_config anr;
2515 	struct ipu3_uapi_awb_fr_config_s awb_fr;
2516 	struct ipu3_uapi_ae_config ae;
2517 	struct ipu3_uapi_af_config_s af;
2518 	struct ipu3_uapi_awb_config awb;
2519 } __packed;
2520 
2521 /**
2522  * struct ipu3_uapi_isp_lin_vmem_params - Linearization parameters
2523  *
2524  * @lin_lutlow_gr: linearization look-up table for GR channel interpolation.
2525  * @lin_lutlow_r: linearization look-up table for R channel interpolation.
2526  * @lin_lutlow_b: linearization look-up table for B channel interpolation.
2527  * @lin_lutlow_gb: linearization look-up table for GB channel interpolation.
2528  *			lin_lutlow_gr / lin_lutlow_r / lin_lutlow_b /
2529  *			lin_lutlow_gb <= LIN_MAX_VALUE - 1.
2530  * @lin_lutdif_gr:	lin_lutlow_gr[i+1] - lin_lutlow_gr[i].
2531  * @lin_lutdif_r:	lin_lutlow_r[i+1] - lin_lutlow_r[i].
2532  * @lin_lutdif_b:	lin_lutlow_b[i+1] - lin_lutlow_b[i].
2533  * @lin_lutdif_gb:	lin_lutlow_gb[i+1] - lin_lutlow_gb[i].
2534  */
2535 struct ipu3_uapi_isp_lin_vmem_params {
2536 	__s16 lin_lutlow_gr[IPU3_UAPI_LIN_LUT_SIZE];
2537 	__s16 lin_lutlow_r[IPU3_UAPI_LIN_LUT_SIZE];
2538 	__s16 lin_lutlow_b[IPU3_UAPI_LIN_LUT_SIZE];
2539 	__s16 lin_lutlow_gb[IPU3_UAPI_LIN_LUT_SIZE];
2540 	__s16 lin_lutdif_gr[IPU3_UAPI_LIN_LUT_SIZE];
2541 	__s16 lin_lutdif_r[IPU3_UAPI_LIN_LUT_SIZE];
2542 	__s16 lin_lutdif_b[IPU3_UAPI_LIN_LUT_SIZE];
2543 	__s16 lin_lutdif_gb[IPU3_UAPI_LIN_LUT_SIZE];
2544 } __packed;
2545 
2546 /* Temporal Noise Reduction */
2547 
2548 /**
2549  * struct ipu3_uapi_isp_tnr3_vmem_params - Temporal noise reduction vector
2550  *					   memory parameters
2551  *
2552  * @slope: slope setting in interpolation curve for temporal noise reduction.
2553  * @reserved1: reserved
2554  * @sigma: knee point setting in interpolation curve for temporal
2555  *	   noise reduction.
2556  * @reserved2: reserved
2557  */
2558 struct ipu3_uapi_isp_tnr3_vmem_params {
2559 	__u16 slope[IPU3_UAPI_ISP_TNR3_VMEM_LEN];
2560 	__u16 reserved1[IPU3_UAPI_ISP_VEC_ELEMS
2561 						- IPU3_UAPI_ISP_TNR3_VMEM_LEN];
2562 	__u16 sigma[IPU3_UAPI_ISP_TNR3_VMEM_LEN];
2563 	__u16 reserved2[IPU3_UAPI_ISP_VEC_ELEMS
2564 						- IPU3_UAPI_ISP_TNR3_VMEM_LEN];
2565 } __packed;
2566 
2567 /**
2568  * struct ipu3_uapi_isp_tnr3_params - Temporal noise reduction v3 parameters
2569  *
2570  * @knee_y1: Knee point TNR3 assumes standard deviation of Y,U and
2571  *	V at Y1 are TnrY1_Sigma_Y, U and V.
2572  * @knee_y2: Knee point TNR3 assumes standard deviation of Y,U and
2573  *		V at Y2 are TnrY2_Sigma_Y, U and V.
2574  * @maxfb_y: Max feedback gain for Y
2575  * @maxfb_u: Max feedback gain for U
2576  * @maxfb_v: Max feedback gain for V
2577  * @round_adj_y: rounding Adjust for Y
2578  * @round_adj_u: rounding Adjust for U
2579  * @round_adj_v: rounding Adjust for V
2580  * @ref_buf_select: selection of the reference frame buffer to be used.
2581  */
2582 struct ipu3_uapi_isp_tnr3_params {
2583 	__u32 knee_y1;
2584 	__u32 knee_y2;
2585 	__u32 maxfb_y;
2586 	__u32 maxfb_u;
2587 	__u32 maxfb_v;
2588 	__u32 round_adj_y;
2589 	__u32 round_adj_u;
2590 	__u32 round_adj_v;
2591 	__u32 ref_buf_select;
2592 } __packed;
2593 
2594 /* Extreme Noise Reduction version 3 */
2595 
2596 /**
2597  * struct ipu3_uapi_isp_xnr3_vmem_params - Extreme noise reduction v3
2598  *					   vector memory parameters
2599  *
2600  * @x: xnr3 parameters.
2601  * @a: xnr3 parameters.
2602  * @b: xnr3 parameters.
2603  * @c: xnr3 parameters.
2604  */
2605 struct ipu3_uapi_isp_xnr3_vmem_params {
2606 	__u16 x[IPU3_UAPI_ISP_VEC_ELEMS];
2607 	__u16 a[IPU3_UAPI_ISP_VEC_ELEMS];
2608 	__u16 b[IPU3_UAPI_ISP_VEC_ELEMS];
2609 	__u16 c[IPU3_UAPI_ISP_VEC_ELEMS];
2610 } __packed;
2611 
2612 /**
2613  * struct ipu3_uapi_xnr3_alpha_params - Extreme noise reduction v3
2614  *					alpha tuning parameters
2615  *
2616  * @y0: Sigma for Y range similarity in dark area.
2617  * @u0: Sigma for U range similarity in dark area.
2618  * @v0: Sigma for V range similarity in dark area.
2619  * @ydiff: Sigma difference for Y between bright area and dark area.
2620  * @udiff: Sigma difference for U between bright area and dark area.
2621  * @vdiff: Sigma difference for V between bright area and dark area.
2622  */
2623 struct ipu3_uapi_xnr3_alpha_params {
2624 	__u32 y0;
2625 	__u32 u0;
2626 	__u32 v0;
2627 	__u32 ydiff;
2628 	__u32 udiff;
2629 	__u32 vdiff;
2630 } __packed;
2631 
2632 /**
2633  * struct ipu3_uapi_xnr3_coring_params - Extreme noise reduction v3
2634  *					 coring parameters
2635  *
2636  * @u0: Coring Threshold of U channel in dark area.
2637  * @v0: Coring Threshold of V channel in dark area.
2638  * @udiff: Threshold difference of U channel between bright and dark area.
2639  * @vdiff: Threshold difference of V channel between bright and dark area.
2640  */
2641 struct ipu3_uapi_xnr3_coring_params {
2642 	__u32 u0;
2643 	__u32 v0;
2644 	__u32 udiff;
2645 	__u32 vdiff;
2646 } __packed;
2647 
2648 /**
2649  * struct ipu3_uapi_xnr3_blending_params - Blending factor
2650  *
2651  * @strength: The factor for blending output with input. This is tuning
2652  *	      parameterHigher values lead to more aggressive XNR operation.
2653  */
2654 struct ipu3_uapi_xnr3_blending_params {
2655 	__u32 strength;
2656 } __packed;
2657 
2658 /**
2659  * struct ipu3_uapi_isp_xnr3_params - Extreme noise reduction v3 parameters
2660  *
2661  * @alpha: parameters for xnr3 alpha. See &ipu3_uapi_xnr3_alpha_params
2662  * @coring: parameters for xnr3 coring. See &ipu3_uapi_xnr3_coring_params
2663  * @blending: parameters for xnr3 blending. See &ipu3_uapi_xnr3_blending_params
2664  */
2665 struct ipu3_uapi_isp_xnr3_params {
2666 	struct ipu3_uapi_xnr3_alpha_params alpha;
2667 	struct ipu3_uapi_xnr3_coring_params coring;
2668 	struct ipu3_uapi_xnr3_blending_params blending;
2669 } __packed;
2670 
2671 /***** Obgrid (optical black level compensation) table entry *****/
2672 
2673 /**
2674  * struct ipu3_uapi_obgrid_param - Optical black level compensation parameters
2675  *
2676  * @gr: Grid table values for color GR
2677  * @r: Grid table values for color R
2678  * @b: Grid table values for color B
2679  * @gb: Grid table values for color GB
2680  *
2681  * Black level is different for red, green, and blue channels. So black level
2682  * compensation is different per channel.
2683  */
2684 struct ipu3_uapi_obgrid_param {
2685 	__u16 gr;
2686 	__u16 r;
2687 	__u16 b;
2688 	__u16 gb;
2689 } __packed;
2690 
2691 /******************* V4L2_META_FMT_IPU3_PARAMS *******************/
2692 
2693 /**
2694  * struct ipu3_uapi_flags - bits to indicate which pipeline needs update
2695  *
2696  * @gdc: 0 = no update, 1 = update.
2697  * @obgrid: 0 = no update, 1 = update.
2698  * @reserved1: Not used.
2699  * @acc_bnr: 0 = no update, 1 = update.
2700  * @acc_green_disparity: 0 = no update, 1 = update.
2701  * @acc_dm: 0 = no update, 1 = update.
2702  * @acc_ccm: 0 = no update, 1 = update.
2703  * @acc_gamma: 0 = no update, 1 = update.
2704  * @acc_csc: 0 = no update, 1 = update.
2705  * @acc_cds: 0 = no update, 1 = update.
2706  * @acc_shd: 0 = no update, 1 = update.
2707  * @reserved2: Not used.
2708  * @acc_iefd: 0 = no update, 1 = update.
2709  * @acc_yds_c0: 0 = no update, 1 = update.
2710  * @acc_chnr_c0: 0 = no update, 1 = update.
2711  * @acc_y_ee_nr: 0 = no update, 1 = update.
2712  * @acc_yds: 0 = no update, 1 = update.
2713  * @acc_chnr: 0 = no update, 1 = update.
2714  * @acc_ytm: 0 = no update, 1 = update.
2715  * @acc_yds2: 0 = no update, 1 = update.
2716  * @acc_tcc: 0 = no update, 1 = update.
2717  * @acc_dpc: 0 = no update, 1 = update.
2718  * @acc_bds: 0 = no update, 1 = update.
2719  * @acc_anr: 0 = no update, 1 = update.
2720  * @acc_awb_fr: 0 = no update, 1 = update.
2721  * @acc_ae: 0 = no update, 1 = update.
2722  * @acc_af: 0 = no update, 1 = update.
2723  * @acc_awb: 0 = no update, 1 = update.
2724  * @__acc_osys: 0 = no update, 1 = update.
2725  * @reserved3: Not used.
2726  * @lin_vmem_params: 0 = no update, 1 = update.
2727  * @tnr3_vmem_params: 0 = no update, 1 = update.
2728  * @xnr3_vmem_params: 0 = no update, 1 = update.
2729  * @tnr3_dmem_params: 0 = no update, 1 = update.
2730  * @xnr3_dmem_params: 0 = no update, 1 = update.
2731  * @reserved4: Not used.
2732  * @obgrid_param: 0 = no update, 1 = update.
2733  * @reserved5: Not used.
2734  */
2735 struct ipu3_uapi_flags {
2736 	__u32 gdc:1;
2737 	__u32 obgrid:1;
2738 	__u32 reserved1:30;
2739 
2740 	__u32 acc_bnr:1;
2741 	__u32 acc_green_disparity:1;
2742 	__u32 acc_dm:1;
2743 	__u32 acc_ccm:1;
2744 	__u32 acc_gamma:1;
2745 	__u32 acc_csc:1;
2746 	__u32 acc_cds:1;
2747 	__u32 acc_shd:1;
2748 	__u32 reserved2:2;
2749 	__u32 acc_iefd:1;
2750 	__u32 acc_yds_c0:1;
2751 	__u32 acc_chnr_c0:1;
2752 	__u32 acc_y_ee_nr:1;
2753 	__u32 acc_yds:1;
2754 	__u32 acc_chnr:1;
2755 	__u32 acc_ytm:1;
2756 	__u32 acc_yds2:1;
2757 	__u32 acc_tcc:1;
2758 	__u32 acc_dpc:1;
2759 	__u32 acc_bds:1;
2760 	__u32 acc_anr:1;
2761 	__u32 acc_awb_fr:1;
2762 	__u32 acc_ae:1;
2763 	__u32 acc_af:1;
2764 	__u32 acc_awb:1;
2765 	__u32 reserved3:4;
2766 
2767 	__u32 lin_vmem_params:1;
2768 	__u32 tnr3_vmem_params:1;
2769 	__u32 xnr3_vmem_params:1;
2770 	__u32 tnr3_dmem_params:1;
2771 	__u32 xnr3_dmem_params:1;
2772 	__u32 reserved4:1;
2773 	__u32 obgrid_param:1;
2774 	__u32 reserved5:25;
2775 } __packed;
2776 
2777 /**
2778  * struct ipu3_uapi_params - V4L2_META_FMT_IPU3_PARAMS
2779  *
2780  * @use:	select which parameters to apply, see &ipu3_uapi_flags
2781  * @acc_param:	ACC parameters, as specified by &ipu3_uapi_acc_param
2782  * @lin_vmem_params:	linearization VMEM, as specified by
2783  *			&ipu3_uapi_isp_lin_vmem_params
2784  * @tnr3_vmem_params:	tnr3 VMEM as specified by
2785  *			&ipu3_uapi_isp_tnr3_vmem_params
2786  * @xnr3_vmem_params:	xnr3 VMEM as specified by
2787  *			&ipu3_uapi_isp_xnr3_vmem_params
2788  * @tnr3_dmem_params:	tnr3 DMEM as specified by &ipu3_uapi_isp_tnr3_params
2789  * @xnr3_dmem_params:	xnr3 DMEM as specified by &ipu3_uapi_isp_xnr3_params
2790  * @obgrid_param:	obgrid parameters as specified by
2791  *			&ipu3_uapi_obgrid_param
2792  *
2793  * The video queue "parameters" is of format V4L2_META_FMT_IPU3_PARAMS.
2794  * This is a "single plane" v4l2_meta_format using V4L2_BUF_TYPE_META_OUTPUT.
2795  *
2796  * struct ipu3_uapi_params as defined below contains a lot of parameters and
2797  * ipu3_uapi_flags selects which parameters to apply.
2798  */
2799 struct ipu3_uapi_params {
2800 	/* Flags which of the settings below are to be applied */
2801 	struct ipu3_uapi_flags use __attribute__((aligned(32)));
2802 
2803 	/* Accelerator cluster parameters */
2804 	struct ipu3_uapi_acc_param acc_param;
2805 
2806 	/* ISP vector address space parameters */
2807 	struct ipu3_uapi_isp_lin_vmem_params lin_vmem_params;
2808 	struct ipu3_uapi_isp_tnr3_vmem_params tnr3_vmem_params;
2809 	struct ipu3_uapi_isp_xnr3_vmem_params xnr3_vmem_params;
2810 
2811 	/* ISP data memory (DMEM) parameters */
2812 	struct ipu3_uapi_isp_tnr3_params tnr3_dmem_params;
2813 	struct ipu3_uapi_isp_xnr3_params xnr3_dmem_params;
2814 
2815 	/* Optical black level compensation */
2816 	struct ipu3_uapi_obgrid_param obgrid_param;
2817 } __packed;
2818 
2819 #endif /* __IPU3_UAPI_H */
2820