bfe91581a21e5d4f9a4b343fe393e81ee5424308
[openwrt/staging/hauke.git] /
1 From 34bed428fea0d0da58a22365588f7511b491a497 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Fri, 19 Feb 2021 10:30:49 +0000
4 Subject: [PATCH] media: i2c: imx477: Remove internal
5 v4l2_mbus_framefmt from the state
6
7 The only field in this struct that is used is the format code, so
8 replace the struct with this single field.
9
10 Save the format code in imx477_set_pad_format() when setting up a new
11 mode so that imx477_get_pad_format() performs the right lookup.
12 Otherwise, this caused a bug where the mode lookup occurred on the
13 12-bit table rather than the 10-bit table.
14
15 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
16 ---
17 drivers/media/i2c/imx477.c | 19 ++++---------------
18 1 file changed, 4 insertions(+), 15 deletions(-)
19
20 --- a/drivers/media/i2c/imx477.c
21 +++ b/drivers/media/i2c/imx477.c
22 @@ -1073,7 +1073,7 @@ struct imx477 {
23 struct v4l2_subdev sd;
24 struct media_pad pad[NUM_PADS];
25
26 - struct v4l2_mbus_framefmt fmt;
27 + unsigned int fmt_code;
28
29 struct clk *xclk;
30 u32 xclk_freq;
31 @@ -1235,21 +1235,9 @@ static u32 imx477_get_format_code(struct
32
33 static void imx477_set_default_format(struct imx477 *imx477)
34 {
35 - struct v4l2_mbus_framefmt *fmt = &imx477->fmt;
36 -
37 /* Set default mode to max resolution */
38 imx477->mode = &supported_modes_12bit[0];
39 -
40 - fmt->code = MEDIA_BUS_FMT_SRGGB12_1X12;
41 - fmt->colorspace = V4L2_COLORSPACE_SRGB;
42 - fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace);
43 - fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true,
44 - fmt->colorspace,
45 - fmt->ycbcr_enc);
46 - fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
47 - fmt->width = imx477->mode->width;
48 - fmt->height = imx477->mode->height;
49 - fmt->field = V4L2_FIELD_NONE;
50 + imx477->fmt_code = MEDIA_BUS_FMT_SRGGB12_1X12;
51 }
52
53 static int imx477_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
54 @@ -1520,7 +1508,7 @@ static int imx477_get_pad_format(struct
55 imx477_update_image_pad_format(imx477, imx477->mode,
56 fmt);
57 fmt->format.code =
58 - imx477_get_format_code(imx477, imx477->fmt.code);
59 + imx477_get_format_code(imx477, imx477->fmt_code);
60 } else {
61 imx477_update_metadata_pad_format(fmt);
62 }
63 @@ -1611,6 +1599,7 @@ static int imx477_set_pad_format(struct
64 *framefmt = fmt->format;
65 } else {
66 imx477->mode = mode;
67 + imx477->fmt_code = fmt->format.code;
68 imx477_set_framing_limits(imx477);
69 }
70 } else {