LinuxTV Patchwork [v2,1/3] media: mt9m111: make VIDIOC_SUBDEV_G_FMT ioctl work with V4L2_SUBDEV_FORMAT_TRY

login
register
mail settings
Submitter Akinobu Mita
Date Jan. 10, 2019, 3:28 p.m.
Message ID <1547134109-21449-2-git-send-email-akinobu.mita@gmail.com>
Download mbox | patch
Permalink /patch/53850/
State Changes Requested
Delegated to: Sakari Ailus
Headers show

Comments

Akinobu Mita - Jan. 10, 2019, 3:28 p.m.
The VIDIOC_SUBDEV_G_FMT ioctl for this driver doesn't recognize
V4L2_SUBDEV_FORMAT_TRY and always works as if V4L2_SUBDEV_FORMAT_ACTIVE
is specified.

Cc: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* v2
- Use format->pad for the argument of v4l2_subdev_get_try_format().

 drivers/media/i2c/mt9m111.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
Akinobu Mita - Jan. 11, 2019, 1:17 p.m.
2019?1?11?(?) 0:28 Akinobu Mita <akinobu.mita@gmail.com>:
</akinobu.mita@gmail.com>
>
> The VIDIOC_SUBDEV_G_FMT ioctl for this driver doesn't recognize
> V4L2_SUBDEV_FORMAT_TRY and always works as if V4L2_SUBDEV_FORMAT_ACTIVE
> is specified.
>
> Cc: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
> Cc: Marco Felsch <m.felsch@pengutronix.de>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
> * v2
> - Use format->pad for the argument of v4l2_subdev_get_try_format().
>
>  drivers/media/i2c/mt9m111.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>
> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> index d639b9b..eb5bf71 100644
> --- a/drivers/media/i2c/mt9m111.c
> +++ b/drivers/media/i2c/mt9m111.c
> @@ -528,6 +528,16 @@ static int mt9m111_get_fmt(struct v4l2_subdev *sd,
>         if (format->pad)
>                 return -EINVAL;
>
> +       if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
> +#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
> +               mf = v4l2_subdev_get_try_format(sd, cfg, format->pad);
> +               format->format = *mf;
> +               return 0;
> +#else
> +               return -ENOTTY;
> +#endif
> +       }
> +
>         mf->width       = mt9m111->width;
>         mf->height      = mt9m111->height;
>         mf->code        = mt9m111->fmt->code;
> @@ -1089,6 +1099,26 @@ static int mt9m111_s_stream(struct v4l2_subdev *sd, int enable)
>         return 0;
>  }
>
> +static int mt9m111_init_cfg(struct v4l2_subdev *sd,
> +                           struct v4l2_subdev_pad_config *cfg)
> +{
> +#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
> +       struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
> +       struct v4l2_mbus_framefmt *format =
> +               v4l2_subdev_get_try_format(sd, cfg, 0);
> +
> +       format->width   = mt9m111->width;
> +       format->height  = mt9m111->height;
> +       format->code    = mt9m111->fmt->code;
> +       format->colorspace      = mt9m111->fmt->colorspace;

Oops, I made the same mistake that I did for mt9m001 driver.
This should be the default configuration instead of current one.

Patch

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index d639b9b..eb5bf71 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -528,6 +528,16 @@  static int mt9m111_get_fmt(struct v4l2_subdev *sd,
 	if (format->pad)
 		return -EINVAL;
 
+	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+		mf = v4l2_subdev_get_try_format(sd, cfg, format->pad);
+		format->format = *mf;
+		return 0;
+#else
+		return -ENOTTY;
+#endif
+	}
+
 	mf->width	= mt9m111->width;
 	mf->height	= mt9m111->height;
 	mf->code	= mt9m111->fmt->code;
@@ -1089,6 +1099,26 @@  static int mt9m111_s_stream(struct v4l2_subdev *sd, int enable)
 	return 0;
 }
 
+static int mt9m111_init_cfg(struct v4l2_subdev *sd,
+			    struct v4l2_subdev_pad_config *cfg)
+{
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
+	struct v4l2_mbus_framefmt *format =
+		v4l2_subdev_get_try_format(sd, cfg, 0);
+
+	format->width	= mt9m111->width;
+	format->height	= mt9m111->height;
+	format->code	= mt9m111->fmt->code;
+	format->colorspace	= mt9m111->fmt->colorspace;
+	format->field	= V4L2_FIELD_NONE;
+	format->ycbcr_enc	= V4L2_YCBCR_ENC_DEFAULT;
+	format->quantization	= V4L2_QUANTIZATION_DEFAULT;
+	format->xfer_func	= V4L2_XFER_FUNC_DEFAULT;
+#endif
+	return 0;
+}
+
 static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
 				struct v4l2_mbus_config *cfg)
 {
@@ -1114,6 +1144,7 @@  static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
 };
 
 static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops = {
+	.init_cfg	= mt9m111_init_cfg,
 	.enum_mbus_code = mt9m111_enum_mbus_code,
 	.get_selection	= mt9m111_get_selection,
 	.set_selection	= mt9m111_set_selection,

Privacy Policy