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