8d6e5b06e0afa8fc7c143e4d26c427fc736c5798
[openwrt/staging/dangole.git] /
1 From 22db5abf108cebb29b38d92e895b65c16df5e82f Mon Sep 17 00:00:00 2001
2 From: David Plowman <david.plowman@raspberrypi.com>
3 Date: Wed, 2 Mar 2022 16:47:37 +0000
4 Subject: [PATCH] staging: vc04_services: isp: Permit all sRGB colour
5 spaces on ISP outputs
6
7 ISP outputs actually support all colour spaces that are fundamentally
8 sRGB underneath, regardless of whether an RGB or YUV output format is
9 actually requested.
10
11 Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
12 ---
13 .../bcm2835-isp/bcm2835-isp-fmts.h | 45 ++++++++++---------
14 1 file changed, 25 insertions(+), 20 deletions(-)
15
16 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-isp-fmts.h
17 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-isp-fmts.h
18 @@ -34,14 +34,19 @@ struct bcm2835_isp_fmt {
19 #define V4L2_COLORSPACE_MASK_RAW V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_RAW)
20
21 /*
22 - * The colour spaces we support for YUV outputs. SRGB features here because,
23 - * once you assign the default transfer func and so on, it and JPEG effectively
24 - * mean the same.
25 + * All three colour spaces JPEG, SMPTE170M and REC709 are fundamentally sRGB
26 + * underneath (as near as makes no difference to us), just with different YCbCr
27 + * encodings. Therefore the ISP can generate sRGB on its main output and any of
28 + * the others on its low resolution output. Applications should, when using both
29 + * outputs, program the colour spaces on them to be the same, matching whatever
30 + * is requested for the low resolution output, even if the main output is
31 + * producing an RGB format. In turn this requires us to allow all these colour
32 + * spaces for every YUV/RGB output format.
33 */
34 -#define V4L2_COLORSPACE_MASK_YUV (V4L2_COLORSPACE_MASK_JPEG | \
35 - V4L2_COLORSPACE_MASK_SRGB | \
36 - V4L2_COLORSPACE_MASK_SMPTE170M | \
37 - V4L2_COLORSPACE_MASK_REC709)
38 +#define V4L2_COLORSPACE_MASK_ALL_SRGB (V4L2_COLORSPACE_MASK_JPEG | \
39 + V4L2_COLORSPACE_MASK_SRGB | \
40 + V4L2_COLORSPACE_MASK_SMPTE170M | \
41 + V4L2_COLORSPACE_MASK_REC709)
42
43 static const struct bcm2835_isp_fmt supported_formats[] = {
44 {
45 @@ -51,7 +56,7 @@ static const struct bcm2835_isp_fmt supp
46 .bytesperline_align = 64,
47 .mmal_fmt = MMAL_ENCODING_I420,
48 .size_multiplier_x2 = 3,
49 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
50 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
51 .colorspace_default = V4L2_COLORSPACE_JPEG,
52 .step_size = 2,
53 }, {
54 @@ -60,7 +65,7 @@ static const struct bcm2835_isp_fmt supp
55 .bytesperline_align = 64,
56 .mmal_fmt = MMAL_ENCODING_YV12,
57 .size_multiplier_x2 = 3,
58 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
59 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
60 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
61 .step_size = 2,
62 }, {
63 @@ -69,7 +74,7 @@ static const struct bcm2835_isp_fmt supp
64 .bytesperline_align = 32,
65 .mmal_fmt = MMAL_ENCODING_NV12,
66 .size_multiplier_x2 = 3,
67 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
68 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
69 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
70 .step_size = 2,
71 }, {
72 @@ -78,7 +83,7 @@ static const struct bcm2835_isp_fmt supp
73 .bytesperline_align = 32,
74 .mmal_fmt = MMAL_ENCODING_NV21,
75 .size_multiplier_x2 = 3,
76 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
77 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
78 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
79 .step_size = 2,
80 }, {
81 @@ -87,7 +92,7 @@ static const struct bcm2835_isp_fmt supp
82 .bytesperline_align = 64,
83 .mmal_fmt = MMAL_ENCODING_YUYV,
84 .size_multiplier_x2 = 2,
85 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
86 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
87 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
88 .step_size = 2,
89 }, {
90 @@ -96,7 +101,7 @@ static const struct bcm2835_isp_fmt supp
91 .bytesperline_align = 64,
92 .mmal_fmt = MMAL_ENCODING_UYVY,
93 .size_multiplier_x2 = 2,
94 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
95 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
96 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
97 .step_size = 2,
98 }, {
99 @@ -105,7 +110,7 @@ static const struct bcm2835_isp_fmt supp
100 .bytesperline_align = 64,
101 .mmal_fmt = MMAL_ENCODING_YVYU,
102 .size_multiplier_x2 = 2,
103 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
104 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
105 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
106 .step_size = 2,
107 }, {
108 @@ -114,7 +119,7 @@ static const struct bcm2835_isp_fmt supp
109 .bytesperline_align = 64,
110 .mmal_fmt = MMAL_ENCODING_VYUY,
111 .size_multiplier_x2 = 2,
112 - .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
113 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
114 .colorspace_default = V4L2_COLORSPACE_SMPTE170M,
115 .step_size = 2,
116 }, {
117 @@ -124,7 +129,7 @@ static const struct bcm2835_isp_fmt supp
118 .bytesperline_align = 32,
119 .mmal_fmt = MMAL_ENCODING_RGB24,
120 .size_multiplier_x2 = 2,
121 - .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
122 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
123 .colorspace_default = V4L2_COLORSPACE_SRGB,
124 .step_size = 1,
125 }, {
126 @@ -133,7 +138,7 @@ static const struct bcm2835_isp_fmt supp
127 .bytesperline_align = 32,
128 .mmal_fmt = MMAL_ENCODING_RGB16,
129 .size_multiplier_x2 = 2,
130 - .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
131 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
132 .colorspace_default = V4L2_COLORSPACE_SRGB,
133 .step_size = 1,
134 }, {
135 @@ -142,7 +147,7 @@ static const struct bcm2835_isp_fmt supp
136 .bytesperline_align = 32,
137 .mmal_fmt = MMAL_ENCODING_BGR24,
138 .size_multiplier_x2 = 2,
139 - .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
140 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
141 .colorspace_default = V4L2_COLORSPACE_SRGB,
142 .step_size = 1,
143 }, {
144 @@ -151,7 +156,7 @@ static const struct bcm2835_isp_fmt supp
145 .bytesperline_align = 64,
146 .mmal_fmt = MMAL_ENCODING_BGRA,
147 .size_multiplier_x2 = 2,
148 - .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
149 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
150 .colorspace_default = V4L2_COLORSPACE_SRGB,
151 .step_size = 1,
152 }, {
153 @@ -160,7 +165,7 @@ static const struct bcm2835_isp_fmt supp
154 .bytesperline_align = 64,
155 .mmal_fmt = MMAL_ENCODING_RGBA,
156 .size_multiplier_x2 = 2,
157 - .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
158 + .colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
159 .colorspace_default = V4L2_COLORSPACE_SRGB,
160 .step_size = 1,
161 }, {