1 /* SPDX-License-Identifier: GPL-2.0 */
3 * PiSP Back End driver image format definitions.
5 * Copyright (c) 2021-2024 Raspberry Pi Ltd
8 #ifndef _PISP_BE_FORMATS_
9 #define _PISP_BE_FORMATS_
11 #include <linux/bits.h>
12 #include <linux/videodev2.h>
14 #define PISPBE_MAX_PLANES 3
15 #define P3(x) ((x) * 8)
17 struct pisp_be_format {
20 unsigned int bit_depth;
21 /* 0P3 factor for plane sizing */
22 unsigned int plane_factor[PISPBE_MAX_PLANES];
23 unsigned int num_planes;
24 unsigned int colorspace_mask;
25 enum v4l2_colorspace colorspace_default;
28 #define V4L2_COLORSPACE_MASK(colorspace) BIT(colorspace)
30 #define V4L2_COLORSPACE_MASK_JPEG \
31 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_JPEG)
32 #define V4L2_COLORSPACE_MASK_SMPTE170M \
33 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SMPTE170M)
34 #define V4L2_COLORSPACE_MASK_REC709 \
35 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_REC709)
36 #define V4L2_COLORSPACE_MASK_SRGB \
37 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SRGB)
38 #define V4L2_COLORSPACE_MASK_RAW \
39 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_RAW)
42 * All three colour spaces SRGB, SMPTE170M and REC709 are fundamentally sRGB
43 * underneath (as near as makes no difference to us), just with different YCbCr
44 * encodings. Therefore the ISP can generate sRGB on its main output and any of
45 * the others on its low resolution output. Applications should, when using both
46 * outputs, program the colour spaces on them to be the same, matching whatever
47 * is requested for the low resolution output, even if the main output is
48 * producing an RGB format. In turn this requires us to allow all these colour
49 * spaces for every YUV/RGB output format.
51 #define V4L2_COLORSPACE_MASK_ALL_SRGB (V4L2_COLORSPACE_MASK_JPEG | \
52 V4L2_COLORSPACE_MASK_SRGB | \
53 V4L2_COLORSPACE_MASK_SMPTE170M | \
54 V4L2_COLORSPACE_MASK_REC709)
56 static const struct pisp_be_format supported_formats[] = {
57 /* Single plane YUV formats */
59 .fourcc = V4L2_PIX_FMT_YUV420,
60 /* 128 alignment to ensure U/V planes are 64 byte aligned. */
63 .plane_factor = { P3(1), P3(0.25), P3(0.25) },
65 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
66 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
69 .fourcc = V4L2_PIX_FMT_YVU420,
70 /* 128 alignment to ensure U/V planes are 64 byte aligned. */
73 .plane_factor = { P3(1), P3(0.25), P3(0.25) },
75 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
76 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
79 .fourcc = V4L2_PIX_FMT_NV12,
82 .plane_factor = { P3(1), P3(0.5) },
84 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
85 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
88 .fourcc = V4L2_PIX_FMT_NV21,
91 .plane_factor = { P3(1), P3(0.5) },
93 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
94 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
97 .fourcc = V4L2_PIX_FMT_YUYV,
100 .plane_factor = { P3(1) },
102 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
103 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
106 .fourcc = V4L2_PIX_FMT_UYVY,
109 .plane_factor = { P3(1) },
111 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
112 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
115 .fourcc = V4L2_PIX_FMT_YVYU,
118 .plane_factor = { P3(1) },
120 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
121 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
124 .fourcc = V4L2_PIX_FMT_VYUY,
127 .plane_factor = { P3(1) },
129 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
130 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
132 /* Multiplane YUV formats */
134 .fourcc = V4L2_PIX_FMT_YUV420M,
137 .plane_factor = { P3(1), P3(0.25), P3(0.25) },
139 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
140 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
143 .fourcc = V4L2_PIX_FMT_NV12M,
146 .plane_factor = { P3(1), P3(0.5) },
148 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
149 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
152 .fourcc = V4L2_PIX_FMT_NV21M,
155 .plane_factor = { P3(1), P3(0.5) },
157 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
158 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
161 .fourcc = V4L2_PIX_FMT_YVU420M,
164 .plane_factor = { P3(1), P3(0.25), P3(0.25) },
166 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
167 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
170 .fourcc = V4L2_PIX_FMT_YUV422M,
173 .plane_factor = { P3(1), P3(0.5), P3(0.5) },
175 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
176 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
179 .fourcc = V4L2_PIX_FMT_YVU422M,
182 .plane_factor = { P3(1), P3(0.5), P3(0.5) },
184 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
185 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
188 .fourcc = V4L2_PIX_FMT_YUV444M,
191 .plane_factor = { P3(1), P3(1), P3(1) },
193 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
194 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
197 .fourcc = V4L2_PIX_FMT_YVU444M,
200 .plane_factor = { P3(1), P3(1), P3(1) },
202 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
203 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
207 .fourcc = V4L2_PIX_FMT_RGB24,
210 .plane_factor = { P3(1.0) },
212 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
213 .colorspace_default = V4L2_COLORSPACE_SRGB,
216 .fourcc = V4L2_PIX_FMT_BGR24,
219 .plane_factor = { P3(1.0) },
221 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
222 .colorspace_default = V4L2_COLORSPACE_SRGB,
225 .fourcc = V4L2_PIX_FMT_XBGR32,
228 .plane_factor = { P3(1.0) },
230 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
231 .colorspace_default = V4L2_COLORSPACE_SRGB,
234 .fourcc = V4L2_PIX_FMT_RGBX32,
237 .plane_factor = { P3(1.0) },
239 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
240 .colorspace_default = V4L2_COLORSPACE_SRGB,
243 .fourcc = V4L2_PIX_FMT_RGB48,
246 .plane_factor = { P3(1.0) },
248 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
249 .colorspace_default = V4L2_COLORSPACE_SRGB,
252 .fourcc = V4L2_PIX_FMT_BGR48,
255 .plane_factor = { P3(1.0) },
257 .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
258 .colorspace_default = V4L2_COLORSPACE_SRGB,
260 /* Bayer formats - 8-bit */
262 .fourcc = V4L2_PIX_FMT_SRGGB8,
265 .plane_factor = { P3(1.0) },
267 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
268 .colorspace_default = V4L2_COLORSPACE_RAW,
271 .fourcc = V4L2_PIX_FMT_SBGGR8,
274 .plane_factor = { P3(1.0) },
276 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
277 .colorspace_default = V4L2_COLORSPACE_RAW,
280 .fourcc = V4L2_PIX_FMT_SGRBG8,
283 .plane_factor = { P3(1.0) },
285 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
286 .colorspace_default = V4L2_COLORSPACE_RAW,
289 .fourcc = V4L2_PIX_FMT_SGBRG8,
292 .plane_factor = { P3(1.0) },
294 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
295 .colorspace_default = V4L2_COLORSPACE_RAW,
297 /* Bayer formats - 16-bit */
299 .fourcc = V4L2_PIX_FMT_SRGGB16,
302 .plane_factor = { P3(1.0) },
304 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
305 .colorspace_default = V4L2_COLORSPACE_RAW,
308 .fourcc = V4L2_PIX_FMT_SBGGR16,
311 .plane_factor = { P3(1.0) },
313 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
314 .colorspace_default = V4L2_COLORSPACE_RAW,
317 .fourcc = V4L2_PIX_FMT_SGRBG16,
320 .plane_factor = { P3(1.0) },
322 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
323 .colorspace_default = V4L2_COLORSPACE_RAW,
326 .fourcc = V4L2_PIX_FMT_SGBRG16,
329 .plane_factor = { P3(1.0) },
331 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
332 .colorspace_default = V4L2_COLORSPACE_RAW,
335 /* Bayer formats unpacked to 16bpp */
337 .fourcc = V4L2_PIX_FMT_SRGGB10,
340 .plane_factor = { P3(1.0) },
342 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
343 .colorspace_default = V4L2_COLORSPACE_RAW,
346 .fourcc = V4L2_PIX_FMT_SBGGR10,
349 .plane_factor = { P3(1.0) },
351 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
352 .colorspace_default = V4L2_COLORSPACE_RAW,
355 .fourcc = V4L2_PIX_FMT_SGRBG10,
358 .plane_factor = { P3(1.0) },
360 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
361 .colorspace_default = V4L2_COLORSPACE_RAW,
364 .fourcc = V4L2_PIX_FMT_SGBRG10,
367 .plane_factor = { P3(1.0) },
369 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
370 .colorspace_default = V4L2_COLORSPACE_RAW,
374 .fourcc = V4L2_PIX_FMT_SRGGB12,
377 .plane_factor = { P3(1.0) },
379 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
380 .colorspace_default = V4L2_COLORSPACE_RAW,
383 .fourcc = V4L2_PIX_FMT_SBGGR12,
386 .plane_factor = { P3(1.0) },
388 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
389 .colorspace_default = V4L2_COLORSPACE_RAW,
392 .fourcc = V4L2_PIX_FMT_SGRBG12,
395 .plane_factor = { P3(1.0) },
397 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
398 .colorspace_default = V4L2_COLORSPACE_RAW,
401 .fourcc = V4L2_PIX_FMT_SGBRG12,
404 .plane_factor = { P3(1.0) },
406 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
407 .colorspace_default = V4L2_COLORSPACE_RAW,
411 .fourcc = V4L2_PIX_FMT_SRGGB14,
414 .plane_factor = { P3(1.0) },
416 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
417 .colorspace_default = V4L2_COLORSPACE_RAW,
420 .fourcc = V4L2_PIX_FMT_SBGGR14,
423 .plane_factor = { P3(1.0) },
425 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
426 .colorspace_default = V4L2_COLORSPACE_RAW,
429 .fourcc = V4L2_PIX_FMT_SGRBG14,
432 .plane_factor = { P3(1.0) },
434 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
435 .colorspace_default = V4L2_COLORSPACE_RAW,
438 .fourcc = V4L2_PIX_FMT_SGBRG14,
441 .plane_factor = { P3(1.0) },
443 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
444 .colorspace_default = V4L2_COLORSPACE_RAW,
446 /* Bayer formats - 16-bit PiSP Compressed */
448 .fourcc = V4L2_PIX_FMT_PISP_COMP1_BGGR,
451 .plane_factor = { P3(1.0) },
453 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
454 .colorspace_default = V4L2_COLORSPACE_RAW,
457 .fourcc = V4L2_PIX_FMT_PISP_COMP1_RGGB,
460 .plane_factor = { P3(1.0) },
462 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
463 .colorspace_default = V4L2_COLORSPACE_RAW,
466 .fourcc = V4L2_PIX_FMT_PISP_COMP1_GRBG,
469 .plane_factor = { P3(1.0) },
471 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
472 .colorspace_default = V4L2_COLORSPACE_RAW,
475 .fourcc = V4L2_PIX_FMT_PISP_COMP1_GBRG,
478 .plane_factor = { P3(1.0) },
480 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
481 .colorspace_default = V4L2_COLORSPACE_RAW,
483 /* Greyscale Formats */
485 .fourcc = V4L2_PIX_FMT_GREY,
489 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
490 .colorspace_default = V4L2_COLORSPACE_RAW,
493 .fourcc = V4L2_PIX_FMT_Y16,
496 .plane_factor = { P3(1.0) },
498 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
499 .colorspace_default = V4L2_COLORSPACE_RAW,
502 .fourcc = V4L2_PIX_FMT_PISP_COMP1_MONO,
505 .plane_factor = { P3(1.0) },
507 .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
508 .colorspace_default = V4L2_COLORSPACE_RAW,
512 static const struct pisp_be_format meta_out_supported_formats[] = {
513 /* Configuration buffer format. */
515 .fourcc = V4L2_META_FMT_RPI_BE_CFG,
519 #endif /* _PISP_BE_FORMATS_ */