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