提交 28210c29 编写于 作者: D Dave Stevenson 提交者: Zheng Zengkai

media: tc358743: Return an appropriate colorspace from tc358743_set_fmt

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

When calling tc358743_set_fmt, the code was calling tc358743_get_fmt
to choose a valid format. However that sets the colorspace
based on what was read back from the chip. When you set the format,
then the driver would choose and program the colorspace based
on the format code.

The result was that if you called try or set format for UYVY
when the current format was RGB3 then you would get told sRGB,
and try RGB3 when current was UYVY and you would get told
SMPTE170M.

The value programmed into the chip is determined by this driver,
therefore there is no need to read back the value. Return the
colorspace based on the format set/tried instead.
Signed-off-by: NDave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 04c4d2fc
...@@ -1691,12 +1691,23 @@ static int tc358743_enum_mbus_code(struct v4l2_subdev *sd, ...@@ -1691,12 +1691,23 @@ static int tc358743_enum_mbus_code(struct v4l2_subdev *sd,
return 0; return 0;
} }
static u32 tc358743_g_colorspace(u32 code)
{
switch (code) {
case MEDIA_BUS_FMT_RGB888_1X24:
return V4L2_COLORSPACE_SRGB;
case MEDIA_BUS_FMT_UYVY8_1X16:
return V4L2_COLORSPACE_SMPTE170M;
default:
return 0;
}
}
static int tc358743_get_fmt(struct v4l2_subdev *sd, static int tc358743_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *format) struct v4l2_subdev_format *format)
{ {
struct tc358743_state *state = to_state(sd); struct tc358743_state *state = to_state(sd);
u8 vi_rep = i2c_rd8(sd, VI_REP);
if (format->pad != 0) if (format->pad != 0)
return -EINVAL; return -EINVAL;
...@@ -1706,23 +1717,7 @@ static int tc358743_get_fmt(struct v4l2_subdev *sd, ...@@ -1706,23 +1717,7 @@ static int tc358743_get_fmt(struct v4l2_subdev *sd,
format->format.height = state->timings.bt.height; format->format.height = state->timings.bt.height;
format->format.field = V4L2_FIELD_NONE; format->format.field = V4L2_FIELD_NONE;
switch (vi_rep & MASK_VOUT_COLOR_SEL) { format->format.colorspace = tc358743_g_colorspace(format->format.code);
case MASK_VOUT_COLOR_RGB_FULL:
case MASK_VOUT_COLOR_RGB_LIMITED:
format->format.colorspace = V4L2_COLORSPACE_SRGB;
break;
case MASK_VOUT_COLOR_601_YCBCR_LIMITED:
case MASK_VOUT_COLOR_601_YCBCR_FULL:
format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
break;
case MASK_VOUT_COLOR_709_YCBCR_FULL:
case MASK_VOUT_COLOR_709_YCBCR_LIMITED:
format->format.colorspace = V4L2_COLORSPACE_REC709;
break;
default:
format->format.colorspace = 0;
break;
}
return 0; return 0;
} }
...@@ -1737,18 +1732,11 @@ static int tc358743_set_fmt(struct v4l2_subdev *sd, ...@@ -1737,18 +1732,11 @@ static int tc358743_set_fmt(struct v4l2_subdev *sd,
int ret = tc358743_get_fmt(sd, cfg, format); int ret = tc358743_get_fmt(sd, cfg, format);
format->format.code = code; format->format.code = code;
format->format.colorspace = tc358743_g_colorspace(code);
if (ret) if (ret)
return ret; return ret;
switch (code) {
case MEDIA_BUS_FMT_RGB888_1X24:
case MEDIA_BUS_FMT_UYVY8_1X16:
break;
default:
return -EINVAL;
}
if (format->which == V4L2_SUBDEV_FORMAT_TRY) if (format->which == V4L2_SUBDEV_FORMAT_TRY)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册