1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
3 * RP1 PiSP Front End Driver Configuration structures
5 * Copyright (C) 2021 - Raspberry Pi Ltd.
8 #ifndef _UAPI_PISP_FE_CONFIG_
9 #define _UAPI_PISP_FE_CONFIG_
11 #include <linux/types.h>
13 #include "pisp_common.h"
14 #include "pisp_fe_statistics.h"
16 #define PISP_FE_NUM_OUTPUTS 2
19 PISP_FE_ENABLE_INPUT
= 0x000001,
20 PISP_FE_ENABLE_DECOMPRESS
= 0x000002,
21 PISP_FE_ENABLE_DECOMPAND
= 0x000004,
22 PISP_FE_ENABLE_BLA
= 0x000008,
23 PISP_FE_ENABLE_DPC
= 0x000010,
24 PISP_FE_ENABLE_STATS_CROP
= 0x000020,
25 PISP_FE_ENABLE_DECIMATE
= 0x000040,
26 PISP_FE_ENABLE_BLC
= 0x000080,
27 PISP_FE_ENABLE_CDAF_STATS
= 0x000100,
28 PISP_FE_ENABLE_AWB_STATS
= 0x000200,
29 PISP_FE_ENABLE_RGBY
= 0x000400,
30 PISP_FE_ENABLE_LSC
= 0x000800,
31 PISP_FE_ENABLE_AGC_STATS
= 0x001000,
32 PISP_FE_ENABLE_CROP0
= 0x010000,
33 PISP_FE_ENABLE_DOWNSCALE0
= 0x020000,
34 PISP_FE_ENABLE_COMPRESS0
= 0x040000,
35 PISP_FE_ENABLE_OUTPUT0
= 0x080000,
36 PISP_FE_ENABLE_CROP1
= 0x100000,
37 PISP_FE_ENABLE_DOWNSCALE1
= 0x200000,
38 PISP_FE_ENABLE_COMPRESS1
= 0x400000,
39 PISP_FE_ENABLE_OUTPUT1
= 0x800000
42 #define PISP_FE_ENABLE_CROP(i) (PISP_FE_ENABLE_CROP0 << (4 * (i)))
43 #define PISP_FE_ENABLE_DOWNSCALE(i) (PISP_FE_ENABLE_DOWNSCALE0 << (4 * (i)))
44 #define PISP_FE_ENABLE_COMPRESS(i) (PISP_FE_ENABLE_COMPRESS0 << (4 * (i)))
45 #define PISP_FE_ENABLE_OUTPUT(i) (PISP_FE_ENABLE_OUTPUT0 << (4 * (i)))
48 * We use the enable flags to show when blocks are "dirty", but we need some
52 PISP_FE_DIRTY_GLOBAL
= 0x0001,
53 PISP_FE_DIRTY_FLOATING
= 0x0002,
54 PISP_FE_DIRTY_OUTPUT_AXI
= 0x0004
57 struct pisp_fe_global_config
{
61 } __attribute__((packed
));
63 struct pisp_fe_input_axi_config
{
64 /* burst length minus one, in the range 0..15; OR'd with flags */
66 /* { prot[2:0], cache[3:0] } fields */
68 /* QoS (only 4 LS bits are used) */
70 } __attribute__((packed
));
72 struct pisp_fe_output_axi_config
{
73 /* burst length minus one, in the range 0..15; OR'd with flags */
75 /* { prot[2:0], cache[3:0] } fields */
77 /* QoS (4 bitfields of 4 bits each for different panic levels) */
79 /* For Panic mode: Output FIFO panic threshold */
81 /* For Panic mode: Output FIFO statistics throttle threshold */
83 } __attribute__((packed
));
85 struct pisp_fe_input_config
{
88 struct pisp_image_format_config format
;
89 struct pisp_fe_input_axi_config axi
;
90 /* Extra cycles delay before issuing each burst request */
93 } __attribute__((packed
));
95 struct pisp_fe_output_config
{
96 struct pisp_image_format_config format
;
99 } __attribute__((packed
));
101 struct pisp_fe_input_buffer_config
{
106 } __attribute__((packed
));
108 #define PISP_FE_DECOMPAND_LUT_SIZE 65
110 struct pisp_fe_decompand_config
{
111 __u16 lut
[PISP_FE_DECOMPAND_LUT_SIZE
];
113 } __attribute__((packed
));
115 struct pisp_fe_dpc_config
{
119 #define PISP_FE_DPC_FLAG_FOLDBACK 1
120 #define PISP_FE_DPC_FLAG_VFLAG 2
122 } __attribute__((packed
));
124 #define PISP_FE_LSC_LUT_SIZE 16
126 struct pisp_fe_lsc_config
{
132 __u16 lut
[PISP_FE_LSC_LUT_SIZE
];
133 } __attribute__((packed
));
135 struct pisp_fe_rgby_config
{
141 } __attribute__((packed
));
143 struct pisp_fe_agc_stats_config
{
148 /* each weight only 4 bits */
149 __u8 weights
[PISP_AGC_STATS_NUM_ZONES
/ 2];
157 } __attribute__((packed
));
159 struct pisp_fe_awb_stats_config
{
172 } __attribute__((packed
));
174 struct pisp_fe_floating_stats_region
{
179 } __attribute__((packed
));
181 struct pisp_fe_floating_stats_config
{
182 struct pisp_fe_floating_stats_region
183 regions
[PISP_FLOATING_STATS_NUM_ZONES
];
184 } __attribute__((packed
));
186 #define PISP_FE_CDAF_NUM_WEIGHTS 8
188 struct pisp_fe_cdaf_stats_config
{
189 __u16 noise_constant
;
198 } __attribute__((packed
));
200 struct pisp_fe_stats_buffer_config
{
203 } __attribute__((packed
));
205 struct pisp_fe_crop_config
{
210 } __attribute__((packed
));
212 enum pisp_fe_downscale_flags
{
213 /* downscale the four Bayer components independently... */
215 /* ...without trying to preserve their spatial relationship */
219 struct pisp_fe_downscale_config
{
224 __u8 flags
; /* enum pisp_fe_downscale_flags */
228 } __attribute__((packed
));
230 struct pisp_fe_output_buffer_config
{
233 } __attribute__((packed
));
235 /* Each of the two output channels/branches: */
236 struct pisp_fe_output_branch_config
{
237 struct pisp_fe_crop_config crop
;
238 struct pisp_fe_downscale_config downscale
;
239 struct pisp_compress_config compress
;
240 struct pisp_fe_output_config output
;
242 } __attribute__((packed
));
244 /* And finally one to rule them all: */
245 struct pisp_fe_config
{
246 /* I/O configuration: */
247 struct pisp_fe_stats_buffer_config stats_buffer
;
248 struct pisp_fe_output_buffer_config output_buffer
[PISP_FE_NUM_OUTPUTS
];
249 struct pisp_fe_input_buffer_config input_buffer
;
250 /* processing configuration: */
251 struct pisp_fe_global_config global
;
252 struct pisp_fe_input_config input
;
253 struct pisp_decompress_config decompress
;
254 struct pisp_fe_decompand_config decompand
;
255 struct pisp_bla_config bla
;
256 struct pisp_fe_dpc_config dpc
;
257 struct pisp_fe_crop_config stats_crop
;
258 __u32 spare1
; /* placeholder for future decimate configuration */
259 struct pisp_bla_config blc
;
260 struct pisp_fe_rgby_config rgby
;
261 struct pisp_fe_lsc_config lsc
;
262 struct pisp_fe_agc_stats_config agc_stats
;
263 struct pisp_fe_awb_stats_config awb_stats
;
264 struct pisp_fe_cdaf_stats_config cdaf_stats
;
265 struct pisp_fe_floating_stats_config floating_stats
;
266 struct pisp_fe_output_axi_config output_axi
;
267 struct pisp_fe_output_branch_config ch
[PISP_FE_NUM_OUTPUTS
];
268 /* non-register fields: */
269 __u32 dirty_flags
; /* these use pisp_fe_enable */
270 __u32 dirty_flags_extra
; /* these use pisp_fe_dirty */
271 } __attribute__((packed
));
273 #endif /* _UAPI_PISP_FE_CONFIG_ */