diff options
author | Jacopo Mondi <jacopo+renesas@jmondi.org> | 2018-05-04 12:32:17 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-05-09 23:27:25 +0300 |
commit | d3a67f27471d4792caf84132228def2b18617932 (patch) | |
tree | 96298e9c99b0563810bfb4f4a6417d1c7eb78322 /drivers | |
parent | 349da8ceb7ebfd0226390faef434be0303c69c43 (diff) | |
download | linux-d3a67f27471d4792caf84132228def2b18617932.tar.xz |
media: renesas-ceu: Set mbus_fmt on subdev operations
The renesas-ceu driver intializes the desired mbus_format at 'complete'
time, inspecting the supported subdevice ones, and tuning some
parameters to produce the requested memory format from what the sensor
can produce. Although, the initially selected mbus_format was not
provided to the subdevice during set_fmt and try_fmt operations,
providing instead a '0' mbus format code.
As long as the sensor defaults to a compatible mbus_format when an
invalid code as '0' is provided, capture operations work correctly. If
the subdevice defaults to an unsupported format (eg. some RGB
permutations) capture does not work properly due to a mismatch on the
expected and received image format on the wire.
Fix that by re-using the initially selected mbus_format code during
set_fmt and try_fmt subdevice operation calls.
Tested by printing out the format selection procedure with ov7670
sensor.
Before this patch:
[ 0.866001] ov7670_try_fmt_internal -- Looking for mbus_code 0x0000
[ 0.870882] ov7670_try_fmt_internal -- Try mbus_code 0x2008
[ 0.876336] ov7670_try_fmt_internal -- Try mbus_code 0x1002
[ 0.881387] ov7670_try_fmt_internal -- Try mbus_code 0x1008
[ 0.886537] ov7670_try_fmt_internal -- Try mbus_code 0x3001
[ 0.891584] ov7670_try_fmt_internal -- mbus_code defaulted to 0x2008
With this patch applied:
[ 0.867015] ov7670_try_fmt_internal -- Looking for mbus_code 0x2008
[ 0.873205] ov7670_try_fmt_internal -- Try mbus_code 0x2008: match
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/renesas-ceu.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index 6599dba5ab84..dec1b3572e9b 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -777,8 +777,15 @@ static int ceu_try_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt) const struct ceu_fmt *ceu_fmt; int ret; + /* + * Set format on sensor sub device: bus format used to produce memory + * format is selected at initialization time. + */ struct v4l2_subdev_format sd_format = { - .which = V4L2_SUBDEV_FORMAT_TRY, + .which = V4L2_SUBDEV_FORMAT_TRY, + .format = { + .code = ceu_sd->mbus_fmt.mbus_code, + }, }; switch (pix->pixelformat) { @@ -800,10 +807,6 @@ static int ceu_try_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt) v4l_bound_align_image(&pix->width, 2, CEU_MAX_WIDTH, 4, &pix->height, 4, CEU_MAX_HEIGHT, 4, 0); - /* - * Set format on sensor sub device: bus format used to produce memory - * format is selected at initialization time. - */ v4l2_fill_mbus_format_mplane(&sd_format.format, pix); ret = v4l2_subdev_call(v4l2_sd, pad, set_fmt, &pad_cfg, &sd_format); if (ret) @@ -827,8 +830,15 @@ static int ceu_set_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt) struct v4l2_subdev *v4l2_sd = ceu_sd->v4l2_sd; int ret; + /* + * Set format on sensor sub device: bus format used to produce memory + * format is selected at initialization time. + */ struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .code = ceu_sd->mbus_fmt.mbus_code, + }, }; ret = ceu_try_fmt(ceudev, v4l2_fmt); |