e262d61b8565418fb08b562ce7c1c76cb7c897b9
[openwrt/staging/rmilecki.git] /
1 From f4d34546637944b30ef09e96aa84802d7d69e72c Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Sat, 11 Sep 2021 17:21:07 +0100
4 Subject: [PATCH] staging: bcm2835-codec: Allow custom specified
5 strides/bytesperline.
6
7 If the client provides a bytesperline value in try_fmt/s_fmt then
8 validate it and correct if necessary.
9
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
11 ---
12 .../vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c | 8 ++++++--
13 1 file changed, 6 insertions(+), 2 deletions(-)
14
15 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
16 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
17 @@ -1347,7 +1347,7 @@ static int vidioc_g_fmt_vid_cap(struct f
18 static int vidioc_try_fmt(struct bcm2835_codec_ctx *ctx, struct v4l2_format *f,
19 struct bcm2835_codec_fmt *fmt)
20 {
21 - unsigned int sizeimage;
22 + unsigned int sizeimage, min_bytesperline;
23
24 /*
25 * The V4L2 specification requires the driver to correct the format
26 @@ -1375,8 +1375,12 @@ static int vidioc_try_fmt(struct bcm2835
27 f->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 16);
28 }
29 f->fmt.pix_mp.num_planes = 1;
30 + min_bytesperline = get_bytesperline(f->fmt.pix_mp.width, fmt);
31 + if (f->fmt.pix_mp.plane_fmt[0].bytesperline < min_bytesperline)
32 + f->fmt.pix_mp.plane_fmt[0].bytesperline = min_bytesperline;
33 f->fmt.pix_mp.plane_fmt[0].bytesperline =
34 - get_bytesperline(f->fmt.pix_mp.width, fmt);
35 + ALIGN(f->fmt.pix_mp.plane_fmt[0].bytesperline, fmt->bytesperline_align);
36 +
37 sizeimage = get_sizeimage(f->fmt.pix_mp.plane_fmt[0].bytesperline,
38 f->fmt.pix_mp.width, f->fmt.pix_mp.height,
39 fmt);