73242cbcf7f46c7032f3e9070a1ce281be07d35b
[openwrt/staging/pepe2k.git] /
1 From 3684d32820cdf7f9ca10a1cfd6236bfcaaf1c6bd 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 @@ -982,8 +982,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;