c0c86bd8cd5af13d1946428e8a60accd5a10ffb2
[openwrt/staging/robimarko.git] /
1 From 9eaafa9f93c9a97498b73583a70b9e238cbe4536 Mon Sep 17 00:00:00 2001
2 From: jc-kynesim <jc@kynesim.co.uk>
3 Date: Fri, 11 Jun 2021 15:14:31 +0100
4 Subject: [PATCH] bcm2835: Allow compressed frames to set sizeimage
5 (#4386)
6
7 Allow the user to set sizeimage in TRY_FMT and S_FMT if the format
8 flags have V4L2_FMT_FLAG_COMPRESSED set
9
10 Signed-off-by: John Cox <jc@kynesim.co.uk>
11 ---
12 .../bcm2835-codec/bcm2835-v4l2-codec.c | 17 ++++++++++++++---
13 1 file changed, 14 insertions(+), 3 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 @@ -1291,6 +1291,8 @@ 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 +
23 /*
24 * The V4L2 specification requires the driver to correct the format
25 * struct if any of the dimensions is unsupported
26 @@ -1319,9 +1321,18 @@ static int vidioc_try_fmt(struct bcm2835
27 f->fmt.pix_mp.num_planes = 1;
28 f->fmt.pix_mp.plane_fmt[0].bytesperline =
29 get_bytesperline(f->fmt.pix_mp.width, fmt);
30 - f->fmt.pix_mp.plane_fmt[0].sizeimage =
31 - get_sizeimage(f->fmt.pix_mp.plane_fmt[0].bytesperline,
32 - f->fmt.pix_mp.width, f->fmt.pix_mp.height, fmt);
33 + sizeimage = get_sizeimage(f->fmt.pix_mp.plane_fmt[0].bytesperline,
34 + f->fmt.pix_mp.width, f->fmt.pix_mp.height,
35 + fmt);
36 + /*
37 + * Drivers must set sizeimage for uncompressed formats
38 + * Compressed formats allow the client to request an alternate
39 + * size for the buffer.
40 + */
41 + if (!(fmt->flags & V4L2_FMT_FLAG_COMPRESSED) ||
42 + f->fmt.pix_mp.plane_fmt[0].sizeimage < sizeimage)
43 + f->fmt.pix_mp.plane_fmt[0].sizeimage = sizeimage;
44 +
45 memset(f->fmt.pix_mp.plane_fmt[0].reserved, 0,
46 sizeof(f->fmt.pix_mp.plane_fmt[0].reserved));
47