Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2/*
3 * PiSP Back End configuration definitions.
4 *
5 * Copyright (C) 2021 - Raspberry Pi Ltd
6 *
7 */
8#ifndef _UAPI_PISP_BE_CONFIG_H_
9#define _UAPI_PISP_BE_CONFIG_H_
10
11#include <linux/types.h>
12
13#include "pisp_common.h"
14
15/* byte alignment for inputs */
16#define PISP_BACK_END_INPUT_ALIGN 4u
17/* alignment for compressed inputs */
18#define PISP_BACK_END_COMPRESSED_ALIGN 8u
19/* minimum required byte alignment for outputs */
20#define PISP_BACK_END_OUTPUT_MIN_ALIGN 16u
21/* preferred byte alignment for outputs */
22#define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u
23
24/* minimum allowed tile width anywhere in the pipeline */
25#define PISP_BACK_END_MIN_TILE_WIDTH 16u
26/* minimum allowed tile width anywhere in the pipeline */
27#define PISP_BACK_END_MIN_TILE_HEIGHT 16u
28
29#define PISP_BACK_END_NUM_OUTPUTS 2
30#define PISP_BACK_END_HOG_OUTPUT 1
31
32#define PISP_BACK_END_NUM_TILES 64
33
34enum pisp_be_bayer_enable {
35 PISP_BE_BAYER_ENABLE_INPUT = 0x000001,
36 PISP_BE_BAYER_ENABLE_DECOMPRESS = 0x000002,
37 PISP_BE_BAYER_ENABLE_DPC = 0x000004,
38 PISP_BE_BAYER_ENABLE_GEQ = 0x000008,
39 PISP_BE_BAYER_ENABLE_TDN_INPUT = 0x000010,
40 PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS = 0x000020,
41 PISP_BE_BAYER_ENABLE_TDN = 0x000040,
42 PISP_BE_BAYER_ENABLE_TDN_COMPRESS = 0x000080,
43 PISP_BE_BAYER_ENABLE_TDN_OUTPUT = 0x000100,
44 PISP_BE_BAYER_ENABLE_SDN = 0x000200,
45 PISP_BE_BAYER_ENABLE_BLC = 0x000400,
46 PISP_BE_BAYER_ENABLE_STITCH_INPUT = 0x000800,
47 PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS = 0x001000,
48 PISP_BE_BAYER_ENABLE_STITCH = 0x002000,
49 PISP_BE_BAYER_ENABLE_STITCH_COMPRESS = 0x004000,
50 PISP_BE_BAYER_ENABLE_STITCH_OUTPUT = 0x008000,
51 PISP_BE_BAYER_ENABLE_WBG = 0x010000,
52 PISP_BE_BAYER_ENABLE_CDN = 0x020000,
53 PISP_BE_BAYER_ENABLE_LSC = 0x040000,
54 PISP_BE_BAYER_ENABLE_TONEMAP = 0x080000,
55 PISP_BE_BAYER_ENABLE_CAC = 0x100000,
56 PISP_BE_BAYER_ENABLE_DEBIN = 0x200000,
57 PISP_BE_BAYER_ENABLE_DEMOSAIC = 0x400000,
58};
59
60enum pisp_be_rgb_enable {
61 PISP_BE_RGB_ENABLE_INPUT = 0x000001,
62 PISP_BE_RGB_ENABLE_CCM = 0x000002,
63 PISP_BE_RGB_ENABLE_SAT_CONTROL = 0x000004,
64 PISP_BE_RGB_ENABLE_YCBCR = 0x000008,
65 PISP_BE_RGB_ENABLE_FALSE_COLOUR = 0x000010,
66 PISP_BE_RGB_ENABLE_SHARPEN = 0x000020,
67 /* Preferred colours would occupy 0x000040 */
68 PISP_BE_RGB_ENABLE_YCBCR_INVERSE = 0x000080,
69 PISP_BE_RGB_ENABLE_GAMMA = 0x000100,
70 PISP_BE_RGB_ENABLE_CSC0 = 0x000200,
71 PISP_BE_RGB_ENABLE_CSC1 = 0x000400,
72 PISP_BE_RGB_ENABLE_DOWNSCALE0 = 0x001000,
73 PISP_BE_RGB_ENABLE_DOWNSCALE1 = 0x002000,
74 PISP_BE_RGB_ENABLE_RESAMPLE0 = 0x008000,
75 PISP_BE_RGB_ENABLE_RESAMPLE1 = 0x010000,
76 PISP_BE_RGB_ENABLE_OUTPUT0 = 0x040000,
77 PISP_BE_RGB_ENABLE_OUTPUT1 = 0x080000,
78 PISP_BE_RGB_ENABLE_HOG = 0x200000
79};
80
81#define PISP_BE_RGB_ENABLE_CSC(i) (PISP_BE_RGB_ENABLE_CSC0 << (i))
82#define PISP_BE_RGB_ENABLE_DOWNSCALE(i) (PISP_BE_RGB_ENABLE_DOWNSCALE0 << (i))
83#define PISP_BE_RGB_ENABLE_RESAMPLE(i) (PISP_BE_RGB_ENABLE_RESAMPLE0 << (i))
84#define PISP_BE_RGB_ENABLE_OUTPUT(i) (PISP_BE_RGB_ENABLE_OUTPUT0 << (i))
85
86/*
87 * We use the enable flags to show when blocks are "dirty", but we need some
88 * extra ones too.
89 */
90enum pisp_be_dirty {
91 PISP_BE_DIRTY_GLOBAL = 0x0001,
92 PISP_BE_DIRTY_SH_FC_COMBINE = 0x0002,
93 PISP_BE_DIRTY_CROP = 0x0004
94};
95
96/**
97 * struct pisp_be_global_config - PiSP global enable bitmaps
98 * @bayer_enables: Bayer input enable flags
99 * @rgb_enables: RGB output enable flags
100 * @bayer_order: Bayer input format ordering
101 * @pad: Padding bytes
102 */
103struct pisp_be_global_config {
104 __u32 bayer_enables;
105 __u32 rgb_enables;
106 __u8 bayer_order;
107 __u8 pad[3];
108} __attribute__((packed));
109
110/**
111 * struct pisp_be_input_buffer_config - PiSP Back End input buffer
112 * @addr: Input buffer address
113 */
114struct pisp_be_input_buffer_config {
115 /* low 32 bits followed by high 32 bits (for each of up to 3 planes) */
116 __u32 addr[3][2];
117} __attribute__((packed));
118
119/**
120 * struct pisp_be_dpc_config - PiSP Back End DPC config
121 *
122 * Defective Pixel Correction configuration
123 *
124 * @coeff_level: Coefficient for the darkest neighbouring pixel value
125 * @coeff_range: Coefficient for the range of pixels for this Bayer channel
126 * @pad: Padding byte
127 * @flags: DPC configuration flags
128 */
129struct pisp_be_dpc_config {
130 __u8 coeff_level;
131 __u8 coeff_range;
132 __u8 pad;
133#define PISP_BE_DPC_FLAG_FOLDBACK 1
134 __u8 flags;
135} __attribute__((packed));
136
137/**
138 * struct pisp_be_geq_config - PiSP Back End GEQ config
139 *
140 * Green Equalisation configuration
141 *
142 * @offset: Offset value for threshold calculation
143 * @slope_sharper: Slope/Sharper configuration
144 * @min: Minimum value the threshold may have
145 * @max: Maximum value the threshold may have
146 */
147struct pisp_be_geq_config {
148 __u16 offset;
149#define PISP_BE_GEQ_SHARPER (1U << 15)
150#define PISP_BE_GEQ_SLOPE ((1 << 10) - 1)
151 /* top bit is the "sharper" flag, slope value is bottom 10 bits */
152 __u16 slope_sharper;
153 __u16 min;
154 __u16 max;
155} __attribute__((packed));
156
157/**
158 * struct pisp_be_tdn_input_buffer_config - PiSP Back End TDN input buffer
159 * @addr: TDN input buffer address
160 */
161struct pisp_be_tdn_input_buffer_config {
162 /* low 32 bits followed by high 32 bits */
163 __u32 addr[2];
164} __attribute__((packed));
165
166/**
167 * struct pisp_be_tdn_config - PiSP Back End TDN config
168 *
169 * Temporal Denoise configuration
170 *
171 * @black_level: Black level value subtracted from pixels
172 * @ratio: Multiplier for the LTA input frame
173 * @noise_constant: Constant offset value used in noise estimation
174 * @noise_slope: Noise estimation multiplier
175 * @threshold: Threshold for TDN operations
176 * @reset: Disable TDN operations
177 * @pad: Padding byte
178 */
179struct pisp_be_tdn_config {
180 __u16 black_level;
181 __u16 ratio;
182 __u16 noise_constant;
183 __u16 noise_slope;
184 __u16 threshold;
185 __u8 reset;
186 __u8 pad;
187} __attribute__((packed));
188
189/**
190 * struct pisp_be_tdn_output_buffer_config - PiSP Back End TDN output buffer
191 * @addr: TDN output buffer address
192 */
193struct pisp_be_tdn_output_buffer_config {
194 /* low 32 bits followed by high 32 bits */
195 __u32 addr[2];
196} __attribute__((packed));
197
198/**
199 * struct pisp_be_sdn_config - PiSP Back End SDN config
200 *
201 * Spatial Denoise configuration
202 *
203 * @black_level: Black level subtracted from pixel for noise estimation
204 * @leakage: Proportion of the original undenoised value to mix in
205 * denoised output
206 * @pad: Padding byte
207 * @noise_constant: Noise constant used for noise estimation
208 * @noise_slope: Noise slope value used for noise estimation
209 * @noise_constant2: Second noise constant used for noise estimation
210 * @noise_slope2: Second slope value used for noise estimation
211 */
212struct pisp_be_sdn_config {
213 __u16 black_level;
214 __u8 leakage;
215 __u8 pad;
216 __u16 noise_constant;
217 __u16 noise_slope;
218 __u16 noise_constant2;
219 __u16 noise_slope2;
220} __attribute__((packed));
221
222/**
223 * struct pisp_be_stitch_input_buffer_config - PiSP Back End Stitch input
224 * @addr: Stitch input buffer address
225 */
226struct pisp_be_stitch_input_buffer_config {
227 /* low 32 bits followed by high 32 bits */
228 __u32 addr[2];
229} __attribute__((packed));
230
231#define PISP_BE_STITCH_STREAMING_LONG 0x8000
232#define PISP_BE_STITCH_EXPOSURE_RATIO_MASK 0x7fff
233
234/**
235 * struct pisp_be_stitch_config - PiSP Back End Stitch config
236 *
237 * Stitch block configuration
238 *
239 * @threshold_lo: Low threshold value
240 * @threshold_diff_power: Low and high threshold difference
241 * @pad: Padding bytes
242 * @exposure_ratio: Multiplier to convert long exposure pixels into
243 * short exposure pixels
244 * @motion_threshold_256: Motion threshold above which short exposure
245 * pixels are used
246 * @motion_threshold_recip: Reciprocal of motion_threshold_256 value
247 */
248struct pisp_be_stitch_config {
249 __u16 threshold_lo;
250 __u8 threshold_diff_power;
251 __u8 pad;
252
253 /* top bit indicates whether streaming input is the long exposure */
254 __u16 exposure_ratio;
255
256 __u8 motion_threshold_256;
257 __u8 motion_threshold_recip;
258} __attribute__((packed));
259
260/**
261 * struct pisp_be_stitch_output_buffer_config - PiSP Back End Stitch output
262 * @addr: Stitch input buffer address
263 */
264struct pisp_be_stitch_output_buffer_config {
265 /* low 32 bits followed by high 32 bits */
266 __u32 addr[2];
267} __attribute__((packed));
268
269/**
270 * struct pisp_be_cdn_config - PiSP Back End CDN config
271 *
272 * Colour Denoise configuration
273 *
274 * @thresh: Constant for noise estimation
275 * @iir_strength: Relative strength of the IIR part of the filter
276 * @g_adjust: Proportion of the change assigned to the G channel
277 */
278struct pisp_be_cdn_config {
279 __u16 thresh;
280 __u8 iir_strength;
281 __u8 g_adjust;
282} __attribute__((packed));
283
284#define PISP_BE_LSC_LOG_GRID_SIZE 5
285#define PISP_BE_LSC_GRID_SIZE (1 << PISP_BE_LSC_LOG_GRID_SIZE)
286#define PISP_BE_LSC_STEP_PRECISION 18
287
288/**
289 * struct pisp_be_lsc_config - PiSP Back End LSC config
290 *
291 * Lens Shading Correction configuration
292 *
293 * @grid_step_x: Reciprocal of cell size width
294 * @grid_step_y: Reciprocal of cell size height
295 * @lut_packed: Jointly-coded RGB gains for each LSC grid
296 */
297struct pisp_be_lsc_config {
298 /* (1<<18) / grid_cell_width */
299 __u16 grid_step_x;
300 /* (1<<18) / grid_cell_height */
301 __u16 grid_step_y;
302 /* RGB gains jointly encoded in 32 bits */
303#define PISP_BE_LSC_LUT_SIZE (PISP_BE_LSC_GRID_SIZE + 1)
304 __u32 lut_packed[PISP_BE_LSC_LUT_SIZE][PISP_BE_LSC_LUT_SIZE];
305} __attribute__((packed));
306
307/**
308 * struct pisp_be_lsc_extra - PiSP Back End LSC Extra config
309 * @offset_x: Horizontal offset into the LSC table of this tile
310 * @offset_y: Vertical offset into the LSC table of this tile
311 */
312struct pisp_be_lsc_extra {
313 __u16 offset_x;
314 __u16 offset_y;
315} __attribute__((packed));
316
317#define PISP_BE_CAC_LOG_GRID_SIZE 3
318#define PISP_BE_CAC_GRID_SIZE (1 << PISP_BE_CAC_LOG_GRID_SIZE)
319#define PISP_BE_CAC_STEP_PRECISION 20
320
321/**
322 * struct pisp_be_cac_config - PiSP Back End CAC config
323 *
324 * Chromatic Aberration Correction config
325 *
326 * @grid_step_x: Reciprocal of cell size width
327 * @grid_step_y: Reciprocal of cell size height
328 * @lut: Pixel shift for the CAC grid
329 */
330struct pisp_be_cac_config {
331 /* (1<<20) / grid_cell_width */
332 __u16 grid_step_x;
333 /* (1<<20) / grid_cell_height */
334 __u16 grid_step_y;
335 /* [gridy][gridx][rb][xy] */
336#define PISP_BE_CAC_LUT_SIZE (PISP_BE_CAC_GRID_SIZE + 1)
337 __s8 lut[PISP_BE_CAC_LUT_SIZE][PISP_BE_CAC_LUT_SIZE][2][2];
338} __attribute__((packed));
339
340/**
341 * struct pisp_be_cac_extra - PiSP Back End CAC extra config
342 * @offset_x: Horizontal offset into the CAC table of this tile
343 * @offset_y: Horizontal offset into the CAC table of this tile
344 */
345struct pisp_be_cac_extra {
346 __u16 offset_x;
347 __u16 offset_y;
348} __attribute__((packed));
349
350#define PISP_BE_DEBIN_NUM_COEFFS 4
351
352/**
353 * struct pisp_be_debin_config - PiSP Back End Debin config
354 *
355 * Debinning configuration
356 *
357 * @coeffs: Filter coefficients for debinning
358 * @h_enable: Horizontal debinning enable
359 * @v_enable: Vertical debinning enable
360 * @pad: Padding bytes
361 */
362struct pisp_be_debin_config {
363 __s8 coeffs[PISP_BE_DEBIN_NUM_COEFFS];
364 __s8 h_enable;
365 __s8 v_enable;
366 __s8 pad[2];
367} __attribute__((packed));
368
369#define PISP_BE_TONEMAP_LUT_SIZE 64
370
371/**
372 * struct pisp_be_tonemap_config - PiSP Back End Tonemap config
373 *
374 * Tonemapping configuration
375 *
376 * @detail_constant: Constant value for threshold calculation
377 * @detail_slope: Slope value for threshold calculation
378 * @iir_strength: Relative strength of the IIR fiter
379 * @strength: Strength factor
380 * @lut: Look-up table for tonemap curve
381 */
382struct pisp_be_tonemap_config {
383 __u16 detail_constant;
384 __u16 detail_slope;
385 __u16 iir_strength;
386 __u16 strength;
387 __u32 lut[PISP_BE_TONEMAP_LUT_SIZE];
388} __attribute__((packed));
389
390/**
391 * struct pisp_be_demosaic_config - PiSP Back End Demosaic config
392 *
393 * Demosaic configuration
394 *
395 * @sharper: Use other Bayer channels to increase sharpness
396 * @fc_mode: Built-in false colour suppression mode
397 * @pad: Padding bytes
398 */
399struct pisp_be_demosaic_config {
400 __u8 sharper;
401 __u8 fc_mode;
402 __u8 pad[2];
403} __attribute__((packed));
404
405/**
406 * struct pisp_be_ccm_config - PiSP Back End CCM config
407 *
408 * Colour Correction Matrix configuration
409 *
410 * @coeffs: Matrix coefficients
411 * @pad: Padding bytes
412 * @offsets: Offsets triplet
413 */
414struct pisp_be_ccm_config {
415 __s16 coeffs[9];
416 __u8 pad[2];
417 __s32 offsets[3];
418} __attribute__((packed));
419
420/**
421 * struct pisp_be_sat_control_config - PiSP Back End SAT config
422 *
423 * Saturation Control configuration
424 *
425 * @shift_r: Left shift for Red colour channel
426 * @shift_g: Left shift for Green colour channel
427 * @shift_b: Left shift for Blue colour channel
428 * @pad: Padding byte
429 */
430struct pisp_be_sat_control_config {
431 __u8 shift_r;
432 __u8 shift_g;
433 __u8 shift_b;
434 __u8 pad;
435} __attribute__((packed));
436
437/**
438 * struct pisp_be_false_colour_config - PiSP Back End False Colour config
439 *
440 * False Colour configuration
441 *
442 * @distance: Distance of neighbouring pixels, either 1 or 2
443 * @pad: Padding bytes
444 */
445struct pisp_be_false_colour_config {
446 __u8 distance;
447 __u8 pad[3];
448} __attribute__((packed));
449
450#define PISP_BE_SHARPEN_SIZE 5
451#define PISP_BE_SHARPEN_FUNC_NUM_POINTS 9
452
453/**
454 * struct pisp_be_sharpen_config - PiSP Back End Sharpening config
455 *
456 * Sharpening configuration
457 *
458 * @kernel0: Coefficient for filter 0
459 * @pad0: Padding byte
460 * @kernel1: Coefficient for filter 1
461 * @pad1: Padding byte
462 * @kernel2: Coefficient for filter 2
463 * @pad2: Padding byte
464 * @kernel3: Coefficient for filter 3
465 * @pad3: Padding byte
466 * @kernel4: Coefficient for filter 4
467 * @pad4: Padding byte
468 * @threshold_offset0: Offset for filter 0 response calculation
469 * @threshold_slope0: Slope multiplier for the filter 0 response calculation
470 * @scale0: Scale factor for filter 0 response calculation
471 * @pad5: Padding byte
472 * @threshold_offset1: Offset for filter 0 response calculation
473 * @threshold_slope1: Slope multiplier for the filter 0 response calculation
474 * @scale1: Scale factor for filter 0 response calculation
475 * @pad6: Padding byte
476 * @threshold_offset2: Offset for filter 0 response calculation
477 * @threshold_slope2: Slope multiplier for the filter 0 response calculation
478 * @scale2: Scale factor for filter 0 response calculation
479 * @pad7: Padding byte
480 * @threshold_offset3: Offset for filter 0 response calculation
481 * @threshold_slope3: Slope multiplier for the filter 0 response calculation
482 * @scale3: Scale factor for filter 0 response calculation
483 * @pad8: Padding byte
484 * @threshold_offset4: Offset for filter 0 response calculation
485 * @threshold_slope4: Slope multiplier for the filter 0 response calculation
486 * @scale4: Scale factor for filter 0 response calculation
487 * @pad9: Padding byte
488 * @positive_strength: Factor to scale the positive sharpening strength
489 * @positive_pre_limit: Maximum allowed possible positive sharpening value
490 * @positive_func: Gain factor applied to positive sharpening response
491 * @positive_limit: Final gain factor applied to positive sharpening
492 * @negative_strength: Factor to scale the negative sharpening strength
493 * @negative_pre_limit: Maximum allowed possible negative sharpening value
494 * @negative_func: Gain factor applied to negative sharpening response
495 * @negative_limit: Final gain factor applied to negative sharpening
496 * @enables: Filter enable mask
497 * @white: White output pixel filter mask
498 * @black: Black output pixel filter mask
499 * @grey: Grey output pixel filter mask
500 */
501struct pisp_be_sharpen_config {
502 __s8 kernel0[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
503 __s8 pad0[3];
504 __s8 kernel1[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
505 __s8 pad1[3];
506 __s8 kernel2[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
507 __s8 pad2[3];
508 __s8 kernel3[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
509 __s8 pad3[3];
510 __s8 kernel4[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
511 __s8 pad4[3];
512 __u16 threshold_offset0;
513 __u16 threshold_slope0;
514 __u16 scale0;
515 __u16 pad5;
516 __u16 threshold_offset1;
517 __u16 threshold_slope1;
518 __u16 scale1;
519 __u16 pad6;
520 __u16 threshold_offset2;
521 __u16 threshold_slope2;
522 __u16 scale2;
523 __u16 pad7;
524 __u16 threshold_offset3;
525 __u16 threshold_slope3;
526 __u16 scale3;
527 __u16 pad8;
528 __u16 threshold_offset4;
529 __u16 threshold_slope4;
530 __u16 scale4;
531 __u16 pad9;
532 __u16 positive_strength;
533 __u16 positive_pre_limit;
534 __u16 positive_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];
535 __u16 positive_limit;
536 __u16 negative_strength;
537 __u16 negative_pre_limit;
538 __u16 negative_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];
539 __u16 negative_limit;
540 __u8 enables;
541 __u8 white;
542 __u8 black;
543 __u8 grey;
544} __attribute__((packed));
545
546/**
547 * struct pisp_be_sh_fc_combine_config - PiSP Back End Sharpening and
548 * False Colour config
549 *
550 * Sharpening and False Colour configuration
551 *
552 * @y_factor: Control amount of desaturation of pixels being darkened
553 * @c1_factor: Control amount of brightening of a pixel for the Cb
554 * channel
555 * @c2_factor: Control amount of brightening of a pixel for the Cr
556 * channel
557 * @pad: Padding byte
558 */
559struct pisp_be_sh_fc_combine_config {
560 __u8 y_factor;
561 __u8 c1_factor;
562 __u8 c2_factor;
563 __u8 pad;
564} __attribute__((packed));
565
566#define PISP_BE_GAMMA_LUT_SIZE 64
567
568/**
569 * struct pisp_be_gamma_config - PiSP Back End Gamma configuration
570 * @lut: Gamma curve look-up table
571 */
572struct pisp_be_gamma_config {
573 __u32 lut[PISP_BE_GAMMA_LUT_SIZE];
574} __attribute__((packed));
575
576/**
577 * struct pisp_be_crop_config - PiSP Back End Crop config
578 *
579 * Crop configuration
580 *
581 * @offset_x: Number of pixels cropped from the left of the tile
582 * @offset_y: Number of pixels cropped from the top of the tile
583 * @width: Width of the cropped tile output
584 * @height: Height of the cropped tile output
585 */
586struct pisp_be_crop_config {
587 __u16 offset_x, offset_y;
588 __u16 width, height;
589} __attribute__((packed));
590
591#define PISP_BE_RESAMPLE_FILTER_SIZE 96
592
593/**
594 * struct pisp_be_resample_config - PiSP Back End Resampling config
595 *
596 * Resample configuration
597 *
598 * @scale_factor_h: Horizontal scale factor
599 * @scale_factor_v: Vertical scale factor
600 * @coef: Resample coefficients
601 */
602struct pisp_be_resample_config {
603 __u16 scale_factor_h, scale_factor_v;
604 __s16 coef[PISP_BE_RESAMPLE_FILTER_SIZE];
605} __attribute__((packed));
606
607/**
608 * struct pisp_be_resample_extra - PiSP Back End Resample config
609 *
610 * Resample configuration
611 *
612 * @scaled_width: Width in pixels of the scaled output
613 * @scaled_height: Height in pixels of the scaled output
614 * @initial_phase_h: Initial horizontal phase
615 * @initial_phase_v: Initial vertical phase
616 */
617struct pisp_be_resample_extra {
618 __u16 scaled_width;
619 __u16 scaled_height;
620 __s16 initial_phase_h[3];
621 __s16 initial_phase_v[3];
622} __attribute__((packed));
623
624/**
625 * struct pisp_be_downscale_config - PiSP Back End Downscale config
626 *
627 * Downscale configuration
628 *
629 * @scale_factor_h: Horizontal scale factor
630 * @scale_factor_v: Vertical scale factor
631 * @scale_recip_h: Horizontal reciprocal factor
632 * @scale_recip_v: Vertical reciprocal factor
633 */
634struct pisp_be_downscale_config {
635 __u16 scale_factor_h;
636 __u16 scale_factor_v;
637 __u16 scale_recip_h;
638 __u16 scale_recip_v;
639} __attribute__((packed));
640
641/**
642 * struct pisp_be_downscale_extra - PiSP Back End Downscale Extra config
643 * @scaled_width: Scaled image width
644 * @scaled_height: Scaled image height
645 */
646struct pisp_be_downscale_extra {
647 __u16 scaled_width;
648 __u16 scaled_height;
649} __attribute__((packed));
650
651/**
652 * struct pisp_be_hog_config - PiSP Back End HOG config
653 *
654 * Histogram of Oriented Gradients configuration
655 *
656 * @compute_signed: Set 0 for unsigned gradients, 1 for signed
657 * @channel_mix: Channels proportions to use
658 * @stride: Stride in bytes between blocks directly below
659 */
660struct pisp_be_hog_config {
661 __u8 compute_signed;
662 __u8 channel_mix[3];
663 __u32 stride;
664} __attribute__((packed));
665
666struct pisp_be_axi_config {
667 __u8 r_qos; /* Read QoS */
668 __u8 r_cache_prot; /* Read { prot[2:0], cache[3:0] } */
669 __u8 w_qos; /* Write QoS */
670 __u8 w_cache_prot; /* Write { prot[2:0], cache[3:0] } */
671} __attribute__((packed));
672
673/**
674 * enum pisp_be_transform - PiSP Back End Transform flags
675 * @PISP_BE_TRANSFORM_NONE: No transform
676 * @PISP_BE_TRANSFORM_HFLIP: Horizontal flip
677 * @PISP_BE_TRANSFORM_VFLIP: Vertical flip
678 * @PISP_BE_TRANSFORM_ROT180: 180 degress rotation
679 */
680enum pisp_be_transform {
681 PISP_BE_TRANSFORM_NONE = 0x0,
682 PISP_BE_TRANSFORM_HFLIP = 0x1,
683 PISP_BE_TRANSFORM_VFLIP = 0x2,
684 PISP_BE_TRANSFORM_ROT180 =
685 (PISP_BE_TRANSFORM_HFLIP | PISP_BE_TRANSFORM_VFLIP)
686};
687
688struct pisp_be_output_format_config {
689 struct pisp_image_format_config image;
690 __u8 transform;
691 __u8 pad[3];
692 __u16 lo;
693 __u16 hi;
694 __u16 lo2;
695 __u16 hi2;
696} __attribute__((packed));
697
698/**
699 * struct pisp_be_output_buffer_config - PiSP Back End Output buffer
700 * @addr: Output buffer address
701 */
702struct pisp_be_output_buffer_config {
703 /* low 32 bits followed by high 32 bits (for each of 3 planes) */
704 __u32 addr[3][2];
705} __attribute__((packed));
706
707/**
708 * struct pisp_be_hog_buffer_config - PiSP Back End HOG buffer
709 * @addr: HOG buffer address
710 */
711struct pisp_be_hog_buffer_config {
712 /* low 32 bits followed by high 32 bits */
713 __u32 addr[2];
714} __attribute__((packed));
715
716/**
717 * struct pisp_be_config - RaspberryPi PiSP Back End Processing configuration
718 *
719 * @input_buffer: Input buffer addresses
720 * @tdn_input_buffer: TDN input buffer addresses
721 * @stitch_input_buffer: Stitch input buffer addresses
722 * @tdn_output_buffer: TDN output buffer addresses
723 * @stitch_output_buffer: Stitch output buffer addresses
724 * @output_buffer: Output buffers addresses
725 * @hog_buffer: HOG buffer addresses
726 * @global: Global PiSP configuration
727 * @input_format: Input image format
728 * @decompress: Decompress configuration
729 * @dpc: Defective Pixel Correction configuration
730 * @geq: Green Equalisation configuration
731 * @tdn_input_format: Temporal Denoise input format
732 * @tdn_decompress: Temporal Denoise decompress configuration
733 * @tdn: Temporal Denoise configuration
734 * @tdn_compress: Temporal Denoise compress configuration
735 * @tdn_output_format: Temporal Denoise output format
736 * @sdn: Spatial Denoise configuration
737 * @blc: Black Level Correction configuration
738 * @stitch_compress: Stitch compress configuration
739 * @stitch_output_format: Stitch output format
740 * @stitch_input_format: Stitch input format
741 * @stitch_decompress: Stitch decompress configuration
742 * @stitch: Stitch configuration
743 * @lsc: Lens Shading Correction configuration
744 * @wbg: White Balance Gain configuration
745 * @cdn: Colour Denoise configuration
746 * @cac: Colour Aberration Correction configuration
747 * @debin: Debinning configuration
748 * @tonemap: Tonemapping configuration
749 * @demosaic: Demosaicing configuration
750 * @ccm: Colour Correction Matrix configuration
751 * @sat_control: Saturation Control configuration
752 * @ycbcr: YCbCr colour correction configuration
753 * @sharpen: Sharpening configuration
754 * @false_colour: False colour correction
755 * @sh_fc_combine: Sharpening and False Colour correction
756 * @ycbcr_inverse: Inverse YCbCr colour correction
757 * @gamma: Gamma curve configuration
758 * @csc: Color Space Conversion configuration
759 * @downscale: Downscale configuration
760 * @resample: Resampling configuration
761 * @output_format: Output format configuration
762 * @hog: HOG configuration
763 * @axi: AXI bus configuration
764 * @lsc_extra: LSC extra info
765 * @cac_extra: CAC extra info
766 * @downscale_extra: Downscaler extra info
767 * @resample_extra: Resample extra info
768 * @crop: Crop configuration
769 * @hog_format: HOG format info
770 * @dirty_flags_bayer: Bayer enable dirty flags
771 * (:c:type:`pisp_be_bayer_enable`)
772 * @dirty_flags_rgb: RGB enable dirty flags
773 * (:c:type:`pisp_be_rgb_enable`)
774 * @dirty_flags_extra: Extra dirty flags
775 */
776struct pisp_be_config {
777 /* I/O configuration: */
778 struct pisp_be_input_buffer_config input_buffer;
779 struct pisp_be_tdn_input_buffer_config tdn_input_buffer;
780 struct pisp_be_stitch_input_buffer_config stitch_input_buffer;
781 struct pisp_be_tdn_output_buffer_config tdn_output_buffer;
782 struct pisp_be_stitch_output_buffer_config stitch_output_buffer;
783 struct pisp_be_output_buffer_config
784 output_buffer[PISP_BACK_END_NUM_OUTPUTS];
785 struct pisp_be_hog_buffer_config hog_buffer;
786 /* Processing configuration: */
787 struct pisp_be_global_config global;
788 struct pisp_image_format_config input_format;
789 struct pisp_decompress_config decompress;
790 struct pisp_be_dpc_config dpc;
791 struct pisp_be_geq_config geq;
792 struct pisp_image_format_config tdn_input_format;
793 struct pisp_decompress_config tdn_decompress;
794 struct pisp_be_tdn_config tdn;
795 struct pisp_compress_config tdn_compress;
796 struct pisp_image_format_config tdn_output_format;
797 struct pisp_be_sdn_config sdn;
798 struct pisp_bla_config blc;
799 struct pisp_compress_config stitch_compress;
800 struct pisp_image_format_config stitch_output_format;
801 struct pisp_image_format_config stitch_input_format;
802 struct pisp_decompress_config stitch_decompress;
803 struct pisp_be_stitch_config stitch;
804 struct pisp_be_lsc_config lsc;
805 struct pisp_wbg_config wbg;
806 struct pisp_be_cdn_config cdn;
807 struct pisp_be_cac_config cac;
808 struct pisp_be_debin_config debin;
809 struct pisp_be_tonemap_config tonemap;
810 struct pisp_be_demosaic_config demosaic;
811 struct pisp_be_ccm_config ccm;
812 struct pisp_be_sat_control_config sat_control;
813 struct pisp_be_ccm_config ycbcr;
814 struct pisp_be_sharpen_config sharpen;
815 struct pisp_be_false_colour_config false_colour;
816 struct pisp_be_sh_fc_combine_config sh_fc_combine;
817 struct pisp_be_ccm_config ycbcr_inverse;
818 struct pisp_be_gamma_config gamma;
819 struct pisp_be_ccm_config csc[PISP_BACK_END_NUM_OUTPUTS];
820 struct pisp_be_downscale_config downscale[PISP_BACK_END_NUM_OUTPUTS];
821 struct pisp_be_resample_config resample[PISP_BACK_END_NUM_OUTPUTS];
822 struct pisp_be_output_format_config
823 output_format[PISP_BACK_END_NUM_OUTPUTS];
824 struct pisp_be_hog_config hog;
825 struct pisp_be_axi_config axi;
826 /* Non-register fields: */
827 struct pisp_be_lsc_extra lsc_extra;
828 struct pisp_be_cac_extra cac_extra;
829 struct pisp_be_downscale_extra
830 downscale_extra[PISP_BACK_END_NUM_OUTPUTS];
831 struct pisp_be_resample_extra resample_extra[PISP_BACK_END_NUM_OUTPUTS];
832 struct pisp_be_crop_config crop;
833 struct pisp_image_format_config hog_format;
834 __u32 dirty_flags_bayer; /* these use pisp_be_bayer_enable */
835 __u32 dirty_flags_rgb; /* use pisp_be_rgb_enable */
836 __u32 dirty_flags_extra; /* these use pisp_be_dirty_t */
837} __attribute__((packed));
838
839/**
840 * enum pisp_tile_edge - PiSP Back End Tile position
841 * @PISP_LEFT_EDGE: Left edge tile
842 * @PISP_RIGHT_EDGE: Right edge tile
843 * @PISP_TOP_EDGE: Top edge tile
844 * @PISP_BOTTOM_EDGE: Bottom edge tile
845 */
846enum pisp_tile_edge {
847 PISP_LEFT_EDGE = (1 << 0),
848 PISP_RIGHT_EDGE = (1 << 1),
849 PISP_TOP_EDGE = (1 << 2),
850 PISP_BOTTOM_EDGE = (1 << 3)
851};
852
853/**
854 * struct pisp_tile - Raspberry Pi PiSP Back End tile configuration
855 *
856 * Tile parameters: each set of tile parameters is a 160-bytes block of data
857 * which contains the tile processing parameters.
858 *
859 * @edge: Edge tile flag
860 * @pad0: Padding bytes
861 * @input_addr_offset: Top-left pixel offset, in bytes
862 * @input_addr_offset2: Top-left pixel offset, in bytes for the second/
863 * third image planes
864 * @input_offset_x: Horizontal offset in pixels of this tile in the
865 * input image
866 * @input_offset_y: Vertical offset in pixels of this tile in the
867 * input image
868 * @input_width: Width in pixels of this tile
869 * @input_height: Height in pixels of the this tile
870 * @tdn_input_addr_offset: TDN input image offset, in bytes
871 * @tdn_output_addr_offset: TDN output image offset, in bytes
872 * @stitch_input_addr_offset: Stitch input image offset, in bytes
873 * @stitch_output_addr_offset: Stitch output image offset, in bytes
874 * @lsc_grid_offset_x: Horizontal offset in the LSC table for this tile
875 * @lsc_grid_offset_y: Vertical offset in the LSC table for this tile
876 * @cac_grid_offset_x: Horizontal offset in the CAC table for this tile
877 * @cac_grid_offset_y: Horizontal offset in the CAC table for this tile
878 * @crop_x_start: Number of pixels cropped from the left of the
879 * tile
880 * @crop_x_end: Number of pixels cropped from the right of the
881 * tile
882 * @crop_y_start: Number of pixels cropped from the top of the
883 * tile
884 * @crop_y_end: Number of pixels cropped from the bottom of the
885 * tile
886 * @downscale_phase_x: Initial horizontal phase in pixels
887 * @downscale_phase_y: Initial vertical phase in pixels
888 * @resample_in_width: Width in pixels of the tile entering the
889 * Resample block
890 * @resample_in_height: Height in pixels of the tile entering the
891 * Resample block
892 * @resample_phase_x: Initial horizontal phase for the Resample block
893 * @resample_phase_y: Initial vertical phase for the Resample block
894 * @output_offset_x: Horizontal offset in pixels where the tile will
895 * be written into the output image
896 * @output_offset_y: Vertical offset in pixels where the tile will be
897 * written into the output image
898 * @output_width: Width in pixels in the output image of this tile
899 * @output_height: Height in pixels in the output image of this tile
900 * @output_addr_offset: Offset in bytes into the output buffer
901 * @output_addr_offset2: Offset in bytes into the output buffer for the
902 * second and third plane
903 * @output_hog_addr_offset: Offset in bytes into the HOG buffer where
904 * results of this tile are to be written
905 */
906struct pisp_tile {
907 __u8 edge; /* enum pisp_tile_edge */
908 __u8 pad0[3];
909 /* 4 bytes */
910 __u32 input_addr_offset;
911 __u32 input_addr_offset2;
912 __u16 input_offset_x;
913 __u16 input_offset_y;
914 __u16 input_width;
915 __u16 input_height;
916 /* 20 bytes */
917 __u32 tdn_input_addr_offset;
918 __u32 tdn_output_addr_offset;
919 __u32 stitch_input_addr_offset;
920 __u32 stitch_output_addr_offset;
921 /* 36 bytes */
922 __u32 lsc_grid_offset_x;
923 __u32 lsc_grid_offset_y;
924 /* 44 bytes */
925 __u32 cac_grid_offset_x;
926 __u32 cac_grid_offset_y;
927 /* 52 bytes */
928 __u16 crop_x_start[PISP_BACK_END_NUM_OUTPUTS];
929 __u16 crop_x_end[PISP_BACK_END_NUM_OUTPUTS];
930 __u16 crop_y_start[PISP_BACK_END_NUM_OUTPUTS];
931 __u16 crop_y_end[PISP_BACK_END_NUM_OUTPUTS];
932 /* 68 bytes */
933 /* Ordering is planes then branches */
934 __u16 downscale_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];
935 __u16 downscale_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];
936 /* 92 bytes */
937 __u16 resample_in_width[PISP_BACK_END_NUM_OUTPUTS];
938 __u16 resample_in_height[PISP_BACK_END_NUM_OUTPUTS];
939 /* 100 bytes */
940 /* Ordering is planes then branches */
941 __u16 resample_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];
942 __u16 resample_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];
943 /* 124 bytes */
944 __u16 output_offset_x[PISP_BACK_END_NUM_OUTPUTS];
945 __u16 output_offset_y[PISP_BACK_END_NUM_OUTPUTS];
946 __u16 output_width[PISP_BACK_END_NUM_OUTPUTS];
947 __u16 output_height[PISP_BACK_END_NUM_OUTPUTS];
948 /* 140 bytes */
949 __u32 output_addr_offset[PISP_BACK_END_NUM_OUTPUTS];
950 __u32 output_addr_offset2[PISP_BACK_END_NUM_OUTPUTS];
951 /* 156 bytes */
952 __u32 output_hog_addr_offset;
953 /* 160 bytes */
954} __attribute__((packed));
955
956/**
957 * struct pisp_be_tiles_config - Raspberry Pi PiSP Back End configuration
958 * @tiles: Tile descriptors
959 * @num_tiles: Number of tiles
960 * @config: PiSP Back End configuration
961 */
962struct pisp_be_tiles_config {
963 struct pisp_be_config config;
964 struct pisp_tile tiles[PISP_BACK_END_NUM_TILES];
965 __u32 num_tiles;
966} __attribute__((packed));
967
968#endif /* _UAPI_PISP_BE_CONFIG_H_ */