Skip to content

Commit

Permalink
media: ov2659: make S_FMT succeed even if requested format doesn't match
Browse files Browse the repository at this point in the history
This driver returns an error if unsupported media bus pixel code is
requested by VIDIOC_SUBDEV_S_FMT.

But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst,

Drivers must not return an error solely because the requested format
doesn't match the device capabilities. They must instead modify the
format to match what the hardware can provide.

So select default format code and return success in that case.

This is detected by v4l2-compliance.

Cc: "Lad, Prabhakar" <[email protected]>
Signed-off-by: Akinobu Mita <[email protected]>
Acked-by: Lad, Prabhakar <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mita authored and mchehab committed Apr 22, 2019
1 parent c62b960 commit bccb89c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/media/i2c/ov2659.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
if (ov2659_formats[index].code == mf->code)
break;

if (index < 0)
return -EINVAL;
if (index < 0) {
index = 0;
mf->code = ov2659_formats[index].code;
}

mf->colorspace = V4L2_COLORSPACE_SRGB;
mf->field = V4L2_FIELD_NONE;
Expand Down

0 comments on commit bccb89c

Please sign in to comment.