1 From 8f84df14dc88580bfdce95999ab0167d3871ff7c Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Thu, 22 Nov 2018 17:31:06 +0000
4 Subject: [PATCH 226/703] media: tc358743: Return an appropriate colorspace
7 When calling tc358743_set_fmt, the code was calling tc358743_get_fmt
8 to choose a valid format. However that sets the colorspace
9 based on what was read back from the chip. When you set the format,
10 then the driver would choose and program the colorspace based
13 The result was that if you called try or set format for UYVY
14 when the current format was RGB3 then you would get told sRGB,
15 and try RGB3 when current was UYVY and you would get told
18 The value programmed into the chip is determined by this driver,
19 therefore there is no need to read back the value. Return the
20 colorspace based on the format set/tried instead.
22 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
24 drivers/media/i2c/tc358743.c | 40 +++++++++++++-----------------------
25 1 file changed, 14 insertions(+), 26 deletions(-)
27 --- a/drivers/media/i2c/tc358743.c
28 +++ b/drivers/media/i2c/tc358743.c
29 @@ -1680,12 +1680,23 @@ static int tc358743_enum_mbus_code(struc
33 +static u32 tc358743_g_colorspace(u32 code)
36 + case MEDIA_BUS_FMT_RGB888_1X24:
37 + return V4L2_COLORSPACE_SRGB;
38 + case MEDIA_BUS_FMT_UYVY8_1X16:
39 + return V4L2_COLORSPACE_SMPTE170M;
45 static int tc358743_get_fmt(struct v4l2_subdev *sd,
46 struct v4l2_subdev_pad_config *cfg,
47 struct v4l2_subdev_format *format)
49 struct tc358743_state *state = to_state(sd);
50 - u8 vi_rep = i2c_rd8(sd, VI_REP);
54 @@ -1695,23 +1706,7 @@ static int tc358743_get_fmt(struct v4l2_
55 format->format.height = state->timings.bt.height;
56 format->format.field = V4L2_FIELD_NONE;
58 - switch (vi_rep & MASK_VOUT_COLOR_SEL) {
59 - case MASK_VOUT_COLOR_RGB_FULL:
60 - case MASK_VOUT_COLOR_RGB_LIMITED:
61 - format->format.colorspace = V4L2_COLORSPACE_SRGB;
63 - case MASK_VOUT_COLOR_601_YCBCR_LIMITED:
64 - case MASK_VOUT_COLOR_601_YCBCR_FULL:
65 - format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
67 - case MASK_VOUT_COLOR_709_YCBCR_FULL:
68 - case MASK_VOUT_COLOR_709_YCBCR_LIMITED:
69 - format->format.colorspace = V4L2_COLORSPACE_REC709;
72 - format->format.colorspace = 0;
75 + format->format.colorspace = tc358743_g_colorspace(format->format.code);
79 @@ -1726,18 +1721,11 @@ static int tc358743_set_fmt(struct v4l2_
80 int ret = tc358743_get_fmt(sd, cfg, format);
82 format->format.code = code;
83 + format->format.colorspace = tc358743_g_colorspace(code);
89 - case MEDIA_BUS_FMT_RGB888_1X24:
90 - case MEDIA_BUS_FMT_UYVY8_1X16:
96 if (format->which == V4L2_SUBDEV_FORMAT_TRY)