bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0234-media-bcm2835-unicam-Retain-packing-information-on-G.patch
1 From ee86fb1c9370c0397b63261e54742e0031991f96 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 19 May 2020 11:46:47 +0100
4 Subject: [PATCH] media: bcm2835-unicam: Retain packing information on
5 G_FMT
6
7 The change to retrieve the pixel format always on g_fmt didn't
8 check whether the native or unpacked version of the format
9 had been requested, and always returned the packed one.
10 Correct this so that the packing setting is retained whereever
11 possible.
12
13 Fixes "9d59e89 media: bcm2835-unicam: Re-fetch mbus code from subdev
14 on a g_fmt call"
15
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 ---
18 .../media/platform/bcm2835/bcm2835-unicam.c | 19 +++++++++++++++++--
19 1 file changed, 17 insertions(+), 2 deletions(-)
20
21 --- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
22 +++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
23 @@ -974,8 +974,23 @@ static int unicam_g_fmt_vid_cap(struct f
24 if (!fmt)
25 return -EINVAL;
26
27 - node->fmt = fmt;
28 - node->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
29 + if (node->fmt != fmt) {
30 + /*
31 + * The sensor format has changed so the pixelformat needs to
32 + * be updated. Try and retain the packed/unpacked choice if
33 + * at all possible.
34 + */
35 + if (node->fmt->repacked_fourcc ==
36 + node->v_fmt.fmt.pix.pixelformat)
37 + /* Using the repacked format */
38 + node->v_fmt.fmt.pix.pixelformat = fmt->repacked_fourcc;
39 + else
40 + /* Using the native format */
41 + node->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
42 +
43 + node->fmt = fmt;
44 + }
45 +
46 *f = node->v_fmt;
47
48 return 0;