diff mbox series

[1/2] media: ov2659: make S_FMT ioctl succeed even if requested format doesn't match

Message ID 1553954492-24982-2-git-send-email-akinobu.mita@gmail.com (mailing list archive)
State New, archived
Headers show
Series media: ov2659: two fixes for ov2659 driver | expand

Commit Message

Akinobu Mita March 30, 2019, 2:01 p.m. UTC
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" <prabhakar.csengg@gmail.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 drivers/media/i2c/ov2659.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Lad, Prabhakar April 4, 2019, 3:18 p.m. UTC | #1
Hi Akinobu,

Thanks for the patch.

On Sat, Mar 30, 2019 at 2:01 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> 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" <prabhakar.csengg@gmail.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>  drivers/media/i2c/ov2659.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

> diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
> index 799acce..a1e9a98 100644
> --- a/drivers/media/i2c/ov2659.c
> +++ b/drivers/media/i2c/ov2659.c
> @@ -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;
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 799acce..a1e9a98 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -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;