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