bcm27xx: add support for linux v5.15
[openwrt/staging/hauke.git] / target / linux / bcm27xx / patches-5.15 / 950-0585-staging-bcm2835-codec-Allow-a-different-stride-align.patch
1 From 9d12ccfea8cdc6d1dbb796a3023e8c8297a4465e Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 29 Nov 2021 19:11:29 +0000
4 Subject: [PATCH] staging/bcm2835-codec: Allow a different stride
5 alignment per role
6
7 Deinterlace and decode aren't affected in the same way as encode
8 and ISP by the alignment requirement on 3 plane YUV420.
9 Decode would be affected, but it always aligns the height up to
10 a macroblock, and uses the selection API to reflect that.
11
12 Add in the facility to set the bytesperline alignment per role.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 ---
16 .../bcm2835-codec/bcm2835-v4l2-codec.c | 135 ++++++++++--------
17 1 file changed, 74 insertions(+), 61 deletions(-)
18
19 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
20 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
21 @@ -88,6 +88,7 @@ enum bcm2835_codec_role {
22 ENCODE,
23 ISP,
24 DEINTERLACE,
25 + NUM_ROLES
26 };
27
28 static const char * const roles[] = {
29 @@ -145,7 +146,7 @@ static const char * const components[] =
30 struct bcm2835_codec_fmt {
31 u32 fourcc;
32 int depth;
33 - int bytesperline_align;
34 + u8 bytesperline_align[NUM_ROLES];
35 u32 flags;
36 u32 mmal_fmt;
37 int size_multiplier_x2;
38 @@ -157,63 +158,63 @@ static const struct bcm2835_codec_fmt su
39 /* YUV formats */
40 .fourcc = V4L2_PIX_FMT_YUV420,
41 .depth = 8,
42 - .bytesperline_align = 64,
43 + .bytesperline_align = { 32, 64, 64, 32 },
44 .flags = 0,
45 .mmal_fmt = MMAL_ENCODING_I420,
46 .size_multiplier_x2 = 3,
47 }, {
48 .fourcc = V4L2_PIX_FMT_YVU420,
49 .depth = 8,
50 - .bytesperline_align = 64,
51 + .bytesperline_align = { 32, 64, 64, 32 },
52 .flags = 0,
53 .mmal_fmt = MMAL_ENCODING_YV12,
54 .size_multiplier_x2 = 3,
55 }, {
56 .fourcc = V4L2_PIX_FMT_NV12,
57 .depth = 8,
58 - .bytesperline_align = 32,
59 + .bytesperline_align = { 32, 32, 32, 32 },
60 .flags = 0,
61 .mmal_fmt = MMAL_ENCODING_NV12,
62 .size_multiplier_x2 = 3,
63 }, {
64 .fourcc = V4L2_PIX_FMT_NV21,
65 .depth = 8,
66 - .bytesperline_align = 32,
67 + .bytesperline_align = { 32, 32, 32, 32 },
68 .flags = 0,
69 .mmal_fmt = MMAL_ENCODING_NV21,
70 .size_multiplier_x2 = 3,
71 }, {
72 .fourcc = V4L2_PIX_FMT_RGB565,
73 .depth = 16,
74 - .bytesperline_align = 32,
75 + .bytesperline_align = { 32, 32, 32, 32 },
76 .flags = 0,
77 .mmal_fmt = MMAL_ENCODING_RGB16,
78 .size_multiplier_x2 = 2,
79 }, {
80 .fourcc = V4L2_PIX_FMT_YUYV,
81 .depth = 16,
82 - .bytesperline_align = 32,
83 + .bytesperline_align = { 32, 32, 32, 32 },
84 .flags = 0,
85 .mmal_fmt = MMAL_ENCODING_YUYV,
86 .size_multiplier_x2 = 2,
87 }, {
88 .fourcc = V4L2_PIX_FMT_UYVY,
89 .depth = 16,
90 - .bytesperline_align = 32,
91 + .bytesperline_align = { 32, 32, 32, 32 },
92 .flags = 0,
93 .mmal_fmt = MMAL_ENCODING_UYVY,
94 .size_multiplier_x2 = 2,
95 }, {
96 .fourcc = V4L2_PIX_FMT_YVYU,
97 .depth = 16,
98 - .bytesperline_align = 32,
99 + .bytesperline_align = { 32, 32, 32, 32 },
100 .flags = 0,
101 .mmal_fmt = MMAL_ENCODING_YVYU,
102 .size_multiplier_x2 = 2,
103 }, {
104 .fourcc = V4L2_PIX_FMT_VYUY,
105 .depth = 16,
106 - .bytesperline_align = 32,
107 + .bytesperline_align = { 32, 32, 32, 32 },
108 .flags = 0,
109 .mmal_fmt = MMAL_ENCODING_VYUY,
110 .size_multiplier_x2 = 2,
111 @@ -221,21 +222,21 @@ static const struct bcm2835_codec_fmt su
112 /* RGB formats */
113 .fourcc = V4L2_PIX_FMT_RGB24,
114 .depth = 24,
115 - .bytesperline_align = 32,
116 + .bytesperline_align = { 32, 32, 32, 32 },
117 .flags = 0,
118 .mmal_fmt = MMAL_ENCODING_RGB24,
119 .size_multiplier_x2 = 2,
120 }, {
121 .fourcc = V4L2_PIX_FMT_BGR24,
122 .depth = 24,
123 - .bytesperline_align = 32,
124 + .bytesperline_align = { 32, 32, 32, 32 },
125 .flags = 0,
126 .mmal_fmt = MMAL_ENCODING_BGR24,
127 .size_multiplier_x2 = 2,
128 }, {
129 .fourcc = V4L2_PIX_FMT_BGR32,
130 .depth = 32,
131 - .bytesperline_align = 32,
132 + .bytesperline_align = { 32, 32, 32, 32 },
133 .flags = 0,
134 .mmal_fmt = MMAL_ENCODING_BGRA,
135 .size_multiplier_x2 = 2,
136 @@ -244,7 +245,7 @@ static const struct bcm2835_codec_fmt su
137 /* 8 bit */
138 .fourcc = V4L2_PIX_FMT_SRGGB8,
139 .depth = 8,
140 - .bytesperline_align = 32,
141 + .bytesperline_align = { 32, 32, 32, 32 },
142 .flags = 0,
143 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8,
144 .size_multiplier_x2 = 2,
145 @@ -252,7 +253,7 @@ static const struct bcm2835_codec_fmt su
146 }, {
147 .fourcc = V4L2_PIX_FMT_SBGGR8,
148 .depth = 8,
149 - .bytesperline_align = 32,
150 + .bytesperline_align = { 32, 32, 32, 32 },
151 .flags = 0,
152 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8,
153 .size_multiplier_x2 = 2,
154 @@ -260,7 +261,7 @@ static const struct bcm2835_codec_fmt su
155 }, {
156 .fourcc = V4L2_PIX_FMT_SGRBG8,
157 .depth = 8,
158 - .bytesperline_align = 32,
159 + .bytesperline_align = { 32, 32, 32, 32 },
160 .flags = 0,
161 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8,
162 .size_multiplier_x2 = 2,
163 @@ -268,7 +269,7 @@ static const struct bcm2835_codec_fmt su
164 }, {
165 .fourcc = V4L2_PIX_FMT_SGBRG8,
166 .depth = 8,
167 - .bytesperline_align = 32,
168 + .bytesperline_align = { 32, 32, 32, 32 },
169 .flags = 0,
170 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8,
171 .size_multiplier_x2 = 2,
172 @@ -277,7 +278,7 @@ static const struct bcm2835_codec_fmt su
173 /* 10 bit */
174 .fourcc = V4L2_PIX_FMT_SRGGB10P,
175 .depth = 10,
176 - .bytesperline_align = 32,
177 + .bytesperline_align = { 32, 32, 32, 32 },
178 .flags = 0,
179 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P,
180 .size_multiplier_x2 = 2,
181 @@ -285,7 +286,7 @@ static const struct bcm2835_codec_fmt su
182 }, {
183 .fourcc = V4L2_PIX_FMT_SBGGR10P,
184 .depth = 10,
185 - .bytesperline_align = 32,
186 + .bytesperline_align = { 32, 32, 32, 32 },
187 .flags = 0,
188 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P,
189 .size_multiplier_x2 = 2,
190 @@ -293,7 +294,7 @@ static const struct bcm2835_codec_fmt su
191 }, {
192 .fourcc = V4L2_PIX_FMT_SGRBG10P,
193 .depth = 10,
194 - .bytesperline_align = 32,
195 + .bytesperline_align = { 32, 32, 32, 32 },
196 .flags = 0,
197 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P,
198 .size_multiplier_x2 = 2,
199 @@ -301,7 +302,7 @@ static const struct bcm2835_codec_fmt su
200 }, {
201 .fourcc = V4L2_PIX_FMT_SGBRG10P,
202 .depth = 10,
203 - .bytesperline_align = 32,
204 + .bytesperline_align = { 32, 32, 32, 32 },
205 .flags = 0,
206 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P,
207 .size_multiplier_x2 = 2,
208 @@ -310,7 +311,7 @@ static const struct bcm2835_codec_fmt su
209 /* 12 bit */
210 .fourcc = V4L2_PIX_FMT_SRGGB12P,
211 .depth = 12,
212 - .bytesperline_align = 32,
213 + .bytesperline_align = { 32, 32, 32, 32 },
214 .flags = 0,
215 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P,
216 .size_multiplier_x2 = 2,
217 @@ -318,7 +319,7 @@ static const struct bcm2835_codec_fmt su
218 }, {
219 .fourcc = V4L2_PIX_FMT_SBGGR12P,
220 .depth = 12,
221 - .bytesperline_align = 32,
222 + .bytesperline_align = { 32, 32, 32, 32 },
223 .flags = 0,
224 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P,
225 .size_multiplier_x2 = 2,
226 @@ -326,7 +327,7 @@ static const struct bcm2835_codec_fmt su
227 }, {
228 .fourcc = V4L2_PIX_FMT_SGRBG12P,
229 .depth = 12,
230 - .bytesperline_align = 32,
231 + .bytesperline_align = { 32, 32, 32, 32 },
232 .flags = 0,
233 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P,
234 .size_multiplier_x2 = 2,
235 @@ -334,7 +335,7 @@ static const struct bcm2835_codec_fmt su
236 }, {
237 .fourcc = V4L2_PIX_FMT_SGBRG12P,
238 .depth = 12,
239 - .bytesperline_align = 32,
240 + .bytesperline_align = { 32, 32, 32, 32 },
241 .flags = 0,
242 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P,
243 .size_multiplier_x2 = 2,
244 @@ -343,7 +344,7 @@ static const struct bcm2835_codec_fmt su
245 /* 14 bit */
246 .fourcc = V4L2_PIX_FMT_SRGGB14P,
247 .depth = 14,
248 - .bytesperline_align = 32,
249 + .bytesperline_align = { 32, 32, 32, 32 },
250 .flags = 0,
251 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14P,
252 .size_multiplier_x2 = 2,
253 @@ -351,7 +352,7 @@ static const struct bcm2835_codec_fmt su
254 }, {
255 .fourcc = V4L2_PIX_FMT_SBGGR14P,
256 .depth = 14,
257 - .bytesperline_align = 32,
258 + .bytesperline_align = { 32, 32, 32, 32 },
259 .flags = 0,
260 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14P,
261 .size_multiplier_x2 = 2,
262 @@ -360,7 +361,7 @@ static const struct bcm2835_codec_fmt su
263 }, {
264 .fourcc = V4L2_PIX_FMT_SGRBG14P,
265 .depth = 14,
266 - .bytesperline_align = 32,
267 + .bytesperline_align = { 32, 32, 32, 32 },
268 .flags = 0,
269 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14P,
270 .size_multiplier_x2 = 2,
271 @@ -368,7 +369,7 @@ static const struct bcm2835_codec_fmt su
272 }, {
273 .fourcc = V4L2_PIX_FMT_SGBRG14P,
274 .depth = 14,
275 - .bytesperline_align = 32,
276 + .bytesperline_align = { 32, 32, 32, 32 },
277 .flags = 0,
278 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14P,
279 .size_multiplier_x2 = 2,
280 @@ -377,7 +378,7 @@ static const struct bcm2835_codec_fmt su
281 /* 16 bit */
282 .fourcc = V4L2_PIX_FMT_SRGGB16,
283 .depth = 16,
284 - .bytesperline_align = 32,
285 + .bytesperline_align = { 32, 32, 32, 32 },
286 .flags = 0,
287 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16,
288 .size_multiplier_x2 = 2,
289 @@ -385,7 +386,7 @@ static const struct bcm2835_codec_fmt su
290 }, {
291 .fourcc = V4L2_PIX_FMT_SBGGR16,
292 .depth = 16,
293 - .bytesperline_align = 32,
294 + .bytesperline_align = { 32, 32, 32, 32 },
295 .flags = 0,
296 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16,
297 .size_multiplier_x2 = 2,
298 @@ -393,7 +394,7 @@ static const struct bcm2835_codec_fmt su
299 }, {
300 .fourcc = V4L2_PIX_FMT_SGRBG16,
301 .depth = 16,
302 - .bytesperline_align = 32,
303 + .bytesperline_align = { 32, 32, 32, 32 },
304 .flags = 0,
305 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16,
306 .size_multiplier_x2 = 2,
307 @@ -401,7 +402,7 @@ static const struct bcm2835_codec_fmt su
308 }, {
309 .fourcc = V4L2_PIX_FMT_SGBRG16,
310 .depth = 16,
311 - .bytesperline_align = 32,
312 + .bytesperline_align = { 32, 32, 32, 32 },
313 .flags = 0,
314 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16,
315 .size_multiplier_x2 = 2,
316 @@ -411,7 +412,7 @@ static const struct bcm2835_codec_fmt su
317 /* 10 bit */
318 .fourcc = V4L2_PIX_FMT_SRGGB10,
319 .depth = 16,
320 - .bytesperline_align = 32,
321 + .bytesperline_align = { 32, 32, 32, 32 },
322 .flags = 0,
323 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10,
324 .size_multiplier_x2 = 2,
325 @@ -419,7 +420,7 @@ static const struct bcm2835_codec_fmt su
326 }, {
327 .fourcc = V4L2_PIX_FMT_SBGGR10,
328 .depth = 16,
329 - .bytesperline_align = 32,
330 + .bytesperline_align = { 32, 32, 32, 32 },
331 .flags = 0,
332 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10,
333 .size_multiplier_x2 = 2,
334 @@ -427,7 +428,7 @@ static const struct bcm2835_codec_fmt su
335 }, {
336 .fourcc = V4L2_PIX_FMT_SGRBG10,
337 .depth = 16,
338 - .bytesperline_align = 32,
339 + .bytesperline_align = { 32, 32, 32, 32 },
340 .flags = 0,
341 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10,
342 .size_multiplier_x2 = 2,
343 @@ -435,7 +436,7 @@ static const struct bcm2835_codec_fmt su
344 }, {
345 .fourcc = V4L2_PIX_FMT_SGBRG10,
346 .depth = 16,
347 - .bytesperline_align = 32,
348 + .bytesperline_align = { 32, 32, 32, 32 },
349 .flags = 0,
350 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10,
351 .size_multiplier_x2 = 2,
352 @@ -444,7 +445,7 @@ static const struct bcm2835_codec_fmt su
353 /* 12 bit */
354 .fourcc = V4L2_PIX_FMT_SRGGB12,
355 .depth = 16,
356 - .bytesperline_align = 32,
357 + .bytesperline_align = { 32, 32, 32, 32 },
358 .flags = 0,
359 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12,
360 .size_multiplier_x2 = 2,
361 @@ -452,7 +453,7 @@ static const struct bcm2835_codec_fmt su
362 }, {
363 .fourcc = V4L2_PIX_FMT_SBGGR12,
364 .depth = 16,
365 - .bytesperline_align = 32,
366 + .bytesperline_align = { 32, 32, 32, 32 },
367 .flags = 0,
368 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12,
369 .size_multiplier_x2 = 2,
370 @@ -460,7 +461,7 @@ static const struct bcm2835_codec_fmt su
371 }, {
372 .fourcc = V4L2_PIX_FMT_SGRBG12,
373 .depth = 16,
374 - .bytesperline_align = 32,
375 + .bytesperline_align = { 32, 32, 32, 32 },
376 .flags = 0,
377 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12,
378 .size_multiplier_x2 = 2,
379 @@ -468,7 +469,7 @@ static const struct bcm2835_codec_fmt su
380 }, {
381 .fourcc = V4L2_PIX_FMT_SGBRG12,
382 .depth = 16,
383 - .bytesperline_align = 32,
384 + .bytesperline_align = { 32, 32, 32, 32 },
385 .flags = 0,
386 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12,
387 .size_multiplier_x2 = 2,
388 @@ -477,7 +478,7 @@ static const struct bcm2835_codec_fmt su
389 /* 14 bit */
390 .fourcc = V4L2_PIX_FMT_SRGGB14,
391 .depth = 16,
392 - .bytesperline_align = 32,
393 + .bytesperline_align = { 32, 32, 32, 32 },
394 .flags = 0,
395 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14,
396 .size_multiplier_x2 = 2,
397 @@ -485,7 +486,7 @@ static const struct bcm2835_codec_fmt su
398 }, {
399 .fourcc = V4L2_PIX_FMT_SBGGR14,
400 .depth = 16,
401 - .bytesperline_align = 32,
402 + .bytesperline_align = { 32, 32, 32, 32 },
403 .flags = 0,
404 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14,
405 .size_multiplier_x2 = 2,
406 @@ -493,7 +494,7 @@ static const struct bcm2835_codec_fmt su
407 }, {
408 .fourcc = V4L2_PIX_FMT_SGRBG14,
409 .depth = 16,
410 - .bytesperline_align = 32,
411 + .bytesperline_align = { 32, 32, 32, 32 },
412 .flags = 0,
413 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14,
414 .size_multiplier_x2 = 2,
415 @@ -501,7 +502,7 @@ static const struct bcm2835_codec_fmt su
416 }, {
417 .fourcc = V4L2_PIX_FMT_SGBRG14,
418 .depth = 16,
419 - .bytesperline_align = 32,
420 + .bytesperline_align = { 32, 32, 32, 32 },
421 .flags = 0,
422 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14,
423 .size_multiplier_x2 = 2,
424 @@ -511,7 +512,7 @@ static const struct bcm2835_codec_fmt su
425 /* 8 bit */
426 .fourcc = V4L2_PIX_FMT_GREY,
427 .depth = 8,
428 - .bytesperline_align = 32,
429 + .bytesperline_align = { 32, 32, 32, 32 },
430 .flags = 0,
431 .mmal_fmt = MMAL_ENCODING_GREY,
432 .size_multiplier_x2 = 2,
433 @@ -519,7 +520,7 @@ static const struct bcm2835_codec_fmt su
434 /* 10 bit */
435 .fourcc = V4L2_PIX_FMT_Y10P,
436 .depth = 10,
437 - .bytesperline_align = 32,
438 + .bytesperline_align = { 32, 32, 32, 32 },
439 .flags = 0,
440 .mmal_fmt = MMAL_ENCODING_Y10P,
441 .size_multiplier_x2 = 2,
442 @@ -527,7 +528,7 @@ static const struct bcm2835_codec_fmt su
443 /* 12 bit */
444 .fourcc = V4L2_PIX_FMT_Y12P,
445 .depth = 12,
446 - .bytesperline_align = 32,
447 + .bytesperline_align = { 32, 32, 32, 32 },
448 .flags = 0,
449 .mmal_fmt = MMAL_ENCODING_Y12P,
450 .size_multiplier_x2 = 2,
451 @@ -535,7 +536,7 @@ static const struct bcm2835_codec_fmt su
452 /* 14 bit */
453 .fourcc = V4L2_PIX_FMT_Y14P,
454 .depth = 14,
455 - .bytesperline_align = 32,
456 + .bytesperline_align = { 32, 32, 32, 32 },
457 .flags = 0,
458 .mmal_fmt = MMAL_ENCODING_Y14P,
459 .size_multiplier_x2 = 2,
460 @@ -543,7 +544,7 @@ static const struct bcm2835_codec_fmt su
461 /* 16 bit */
462 .fourcc = V4L2_PIX_FMT_Y16,
463 .depth = 16,
464 - .bytesperline_align = 32,
465 + .bytesperline_align = { 32, 32, 32, 32 },
466 .flags = 0,
467 .mmal_fmt = MMAL_ENCODING_Y16,
468 .size_multiplier_x2 = 2,
469 @@ -551,7 +552,7 @@ static const struct bcm2835_codec_fmt su
470 /* 10 bit as 16bpp */
471 .fourcc = V4L2_PIX_FMT_Y10,
472 .depth = 16,
473 - .bytesperline_align = 32,
474 + .bytesperline_align = { 32, 32, 32, 32 },
475 .flags = 0,
476 .mmal_fmt = MMAL_ENCODING_Y10,
477 .size_multiplier_x2 = 2,
478 @@ -559,7 +560,7 @@ static const struct bcm2835_codec_fmt su
479 /* 12 bit as 16bpp */
480 .fourcc = V4L2_PIX_FMT_Y12,
481 .depth = 16,
482 - .bytesperline_align = 32,
483 + .bytesperline_align = { 32, 32, 32, 32 },
484 .flags = 0,
485 .mmal_fmt = MMAL_ENCODING_Y12,
486 .size_multiplier_x2 = 2,
487 @@ -567,7 +568,7 @@ static const struct bcm2835_codec_fmt su
488 /* 14 bit as 16bpp */
489 .fourcc = V4L2_PIX_FMT_Y14,
490 .depth = 16,
491 - .bytesperline_align = 32,
492 + .bytesperline_align = { 32, 32, 32, 32 },
493 .flags = 0,
494 .mmal_fmt = MMAL_ENCODING_Y14,
495 .size_multiplier_x2 = 2,
496 @@ -840,9 +841,10 @@ static inline unsigned int get_sizeimage
497 }
498
499 static inline unsigned int get_bytesperline(int width,
500 - struct bcm2835_codec_fmt *fmt)
501 + struct bcm2835_codec_fmt *fmt,
502 + enum bcm2835_codec_role role)
503 {
504 - return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
505 + return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align[role]);
506 }
507
508 static void setup_mmal_port_format(struct bcm2835_codec_ctx *ctx,
509 @@ -1040,7 +1042,7 @@ static void handle_fmt_changed(struct bc
510 */
511 q_data->selection_set = true;
512 q_data->bytesperline = get_bytesperline(format->es.video.width,
513 - q_data->fmt);
514 + q_data->fmt, ctx->dev->role);
515
516 q_data->height = format->es.video.height;
517 q_data->sizeimage = format->buffer_size_min;
518 @@ -1422,11 +1424,13 @@ static int vidioc_try_fmt(struct bcm2835
519 f->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 16);
520 }
521 f->fmt.pix_mp.num_planes = 1;
522 - min_bytesperline = get_bytesperline(f->fmt.pix_mp.width, fmt);
523 + min_bytesperline = get_bytesperline(f->fmt.pix_mp.width, fmt,
524 + ctx->dev->role);
525 if (f->fmt.pix_mp.plane_fmt[0].bytesperline < min_bytesperline)
526 f->fmt.pix_mp.plane_fmt[0].bytesperline = min_bytesperline;
527 f->fmt.pix_mp.plane_fmt[0].bytesperline =
528 - ALIGN(f->fmt.pix_mp.plane_fmt[0].bytesperline, fmt->bytesperline_align);
529 + ALIGN(f->fmt.pix_mp.plane_fmt[0].bytesperline,
530 + fmt->bytesperline_align[ctx->dev->role]);
531
532 sizeimage = get_sizeimage(f->fmt.pix_mp.plane_fmt[0].bytesperline,
533 f->fmt.pix_mp.width, f->fmt.pix_mp.height,
534 @@ -1581,7 +1585,8 @@ static int vidioc_s_fmt(struct bcm2835_c
535 q_data_dst->height = ALIGN(q_data->crop_height, 16);
536
537 q_data_dst->bytesperline =
538 - get_bytesperline(f->fmt.pix_mp.width, q_data_dst->fmt);
539 + get_bytesperline(f->fmt.pix_mp.width, q_data_dst->fmt,
540 + ctx->dev->role);
541 q_data_dst->sizeimage = get_sizeimage(q_data_dst->bytesperline,
542 q_data_dst->crop_width,
543 q_data_dst->height,
544 @@ -1810,6 +1815,8 @@ static int vidioc_g_selection(struct fil
545 }
546 }
547 break;
548 + case NUM_ROLES:
549 + break;
550 }
551
552 return 0;
553 @@ -1920,6 +1927,8 @@ static int vidioc_s_selection(struct fil
554 }
555 break;
556 }
557 + case NUM_ROLES:
558 + break;
559 }
560
561 return 0;
562 @@ -3087,7 +3096,8 @@ static int bcm2835_codec_open(struct fil
563 ctx->q_data[V4L2_M2M_SRC].height = DEFAULT_HEIGHT;
564 ctx->q_data[V4L2_M2M_SRC].bytesperline =
565 get_bytesperline(DEFAULT_WIDTH,
566 - ctx->q_data[V4L2_M2M_SRC].fmt);
567 + ctx->q_data[V4L2_M2M_SRC].fmt,
568 + dev->role);
569 ctx->q_data[V4L2_M2M_SRC].sizeimage =
570 get_sizeimage(ctx->q_data[V4L2_M2M_SRC].bytesperline,
571 ctx->q_data[V4L2_M2M_SRC].crop_width,
572 @@ -3100,7 +3110,8 @@ static int bcm2835_codec_open(struct fil
573 ctx->q_data[V4L2_M2M_DST].height = DEFAULT_HEIGHT;
574 ctx->q_data[V4L2_M2M_DST].bytesperline =
575 get_bytesperline(DEFAULT_WIDTH,
576 - ctx->q_data[V4L2_M2M_DST].fmt);
577 + ctx->q_data[V4L2_M2M_DST].fmt,
578 + dev->role);
579 ctx->q_data[V4L2_M2M_DST].sizeimage =
580 get_sizeimage(ctx->q_data[V4L2_M2M_DST].bytesperline,
581 ctx->q_data[V4L2_M2M_DST].crop_width,
582 @@ -3230,6 +3241,8 @@ static int bcm2835_codec_open(struct fil
583 v4l2_ctrl_handler_init(hdl, 0);
584 }
585 break;
586 + case NUM_ROLES:
587 + break;
588 }
589
590 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);