f58d071a2f1ce345f37dd2e42b7c05a225690411
[openwrt/staging/linusw.git] /
1 From 7d43b7faa9c0a64eb6a8057b7a02fa853ba9ad10 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 15 Feb 2019 11:36:14 +0000
4 Subject: [PATCH 357/782] staging: bcm2835_codec: Add an option for ignoring
5 Bayer formats.
6
7 This is a workaround for GStreamer currently not identifying Bayer
8 as a raw format, therefore any device that supports it does not
9 match the criteria for v4l2convert.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 ---
13 .../bcm2835-codec/bcm2835-v4l2-codec.c | 29 ++++++++++++++++++-
14 1 file changed, 28 insertions(+), 1 deletion(-)
15
16 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
17 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
18 @@ -58,6 +58,15 @@ static int isp_video_nr = 12;
19 module_param(isp_video_nr, int, 0644);
20 MODULE_PARM_DESC(isp_video_nr, "isp video device number");
21
22 +/*
23 + * Workaround for GStreamer v4l2convert component not considering Bayer formats
24 + * as raw, and therefore not considering a V4L2 device that supports them as
25 + * as a suitable candidate.
26 + */
27 +static bool disable_bayer;
28 +module_param(disable_bayer, bool, 0644);
29 +MODULE_PARM_DESC(disable_bayer, "Disable support for Bayer formats");
30 +
31 static unsigned int debug;
32 module_param(debug, uint, 0644);
33 MODULE_PARM_DESC(debug, "activates debug info (0-3)");
34 @@ -105,6 +114,7 @@ struct bcm2835_codec_fmt {
35 u32 flags;
36 u32 mmal_fmt;
37 int size_multiplier_x2;
38 + bool is_bayer;
39 };
40
41 static const struct bcm2835_codec_fmt supported_formats[] = {
42 @@ -203,6 +213,7 @@ static const struct bcm2835_codec_fmt su
43 .flags = 0,
44 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8,
45 .size_multiplier_x2 = 2,
46 + .is_bayer = true,
47 }, {
48 .fourcc = V4L2_PIX_FMT_SBGGR8,
49 .depth = 8,
50 @@ -210,6 +221,7 @@ static const struct bcm2835_codec_fmt su
51 .flags = 0,
52 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8,
53 .size_multiplier_x2 = 2,
54 + .is_bayer = true,
55 }, {
56 .fourcc = V4L2_PIX_FMT_SGRBG8,
57 .depth = 8,
58 @@ -217,6 +229,7 @@ static const struct bcm2835_codec_fmt su
59 .flags = 0,
60 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8,
61 .size_multiplier_x2 = 2,
62 + .is_bayer = true,
63 }, {
64 .fourcc = V4L2_PIX_FMT_SGBRG8,
65 .depth = 8,
66 @@ -224,6 +237,7 @@ static const struct bcm2835_codec_fmt su
67 .flags = 0,
68 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8,
69 .size_multiplier_x2 = 2,
70 + .is_bayer = true,
71 }, {
72 /* 10 bit */
73 .fourcc = V4L2_PIX_FMT_SRGGB10P,
74 @@ -232,6 +246,7 @@ static const struct bcm2835_codec_fmt su
75 .flags = 0,
76 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P,
77 .size_multiplier_x2 = 2,
78 + .is_bayer = true,
79 }, {
80 .fourcc = V4L2_PIX_FMT_SBGGR10P,
81 .depth = 10,
82 @@ -239,6 +254,7 @@ static const struct bcm2835_codec_fmt su
83 .flags = 0,
84 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P,
85 .size_multiplier_x2 = 2,
86 + .is_bayer = true,
87 }, {
88 .fourcc = V4L2_PIX_FMT_SGRBG10P,
89 .depth = 10,
90 @@ -246,6 +262,7 @@ static const struct bcm2835_codec_fmt su
91 .flags = 0,
92 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P,
93 .size_multiplier_x2 = 2,
94 + .is_bayer = true,
95 }, {
96 .fourcc = V4L2_PIX_FMT_SGBRG10P,
97 .depth = 10,
98 @@ -253,6 +270,7 @@ static const struct bcm2835_codec_fmt su
99 .flags = 0,
100 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P,
101 .size_multiplier_x2 = 2,
102 + .is_bayer = true,
103 }, {
104 /* 12 bit */
105 .fourcc = V4L2_PIX_FMT_SRGGB12P,
106 @@ -261,6 +279,7 @@ static const struct bcm2835_codec_fmt su
107 .flags = 0,
108 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P,
109 .size_multiplier_x2 = 2,
110 + .is_bayer = true,
111 }, {
112 .fourcc = V4L2_PIX_FMT_SBGGR12P,
113 .depth = 12,
114 @@ -268,6 +287,7 @@ static const struct bcm2835_codec_fmt su
115 .flags = 0,
116 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P,
117 .size_multiplier_x2 = 2,
118 + .is_bayer = true,
119 }, {
120 .fourcc = V4L2_PIX_FMT_SGRBG12P,
121 .depth = 12,
122 @@ -275,6 +295,7 @@ static const struct bcm2835_codec_fmt su
123 .flags = 0,
124 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P,
125 .size_multiplier_x2 = 2,
126 + .is_bayer = true,
127 }, {
128 .fourcc = V4L2_PIX_FMT_SGBRG12P,
129 .depth = 12,
130 @@ -282,6 +303,7 @@ static const struct bcm2835_codec_fmt su
131 .flags = 0,
132 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P,
133 .size_multiplier_x2 = 2,
134 + .is_bayer = true,
135 }, {
136 /* 16 bit */
137 .fourcc = V4L2_PIX_FMT_SRGGB16,
138 @@ -290,6 +312,7 @@ static const struct bcm2835_codec_fmt su
139 .flags = 0,
140 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16,
141 .size_multiplier_x2 = 2,
142 + .is_bayer = true,
143 }, {
144 .fourcc = V4L2_PIX_FMT_SBGGR16,
145 .depth = 16,
146 @@ -297,6 +320,7 @@ static const struct bcm2835_codec_fmt su
147 .flags = 0,
148 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16,
149 .size_multiplier_x2 = 2,
150 + .is_bayer = true,
151 }, {
152 .fourcc = V4L2_PIX_FMT_SGRBG16,
153 .depth = 16,
154 @@ -304,6 +328,7 @@ static const struct bcm2835_codec_fmt su
155 .flags = 0,
156 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16,
157 .size_multiplier_x2 = 2,
158 + .is_bayer = true,
159 }, {
160 .fourcc = V4L2_PIX_FMT_SGBRG16,
161 .depth = 16,
162 @@ -311,6 +336,7 @@ static const struct bcm2835_codec_fmt su
163 .flags = 0,
164 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16,
165 .size_multiplier_x2 = 2,
166 + .is_bayer = true,
167 }, {
168 /* Compressed formats */
169 .fourcc = V4L2_PIX_FMT_H264,
170 @@ -438,7 +464,8 @@ static const struct bcm2835_codec_fmt *g
171 unsigned int i;
172
173 for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
174 - if (supported_formats[i].mmal_fmt == mmal_fmt)
175 + if (supported_formats[i].mmal_fmt == mmal_fmt &&
176 + (!disable_bayer || !supported_formats[i].is_bayer))
177 return &supported_formats[i];
178 }
179 return NULL;