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>
This commit is contained in:
parent
349da8ceb7
commit
d3a67f2747
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user