media: bugfixes for mt9m111 driver
Subsystems (2)
v2 cover media: bugfixes for mt9m111 driver
This patch series contains four bugfixes for mt9m111 driver.
* v2
- Drop patch 1/4 in v1 ("fix setting pixclk polarit") since it was wrong.
- Use format->pad for the argument of v4l2_subdev_get_try_format().
Akinobu Mita (3):
media: mt9m111: make VIDIOC_SUBDEV_G_FMT ioctl work with
V4L2_SUBDEV_FORMAT_TRY
media: mt9m111: set all mbus format field when G_FMT and S_FMT ioctls
media: mt9m111: set initial frame size other than 0x0
drivers/media/i2c/mt9m111.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
Signature · 1 line
2.7.4
PATCH v2 1/3 media: mt9m111: make VIDIOC_SUBDEV_G_FMT ioctl work with V4L2_SUBDEV_FORMAT_TRY
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.
---
* v2
- Use format->pad for the argument of v4l2_subdev_get_try_format().
drivers/media/i2c/mt9m111.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/media/i2c/mt9m111.c +31 -0
@@ -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,
Signature · 1 line
2.7.4
Re: [PATCH v2 1/3] media: mt9m111: make VIDIOC_SUBDEV_G_FMT ioctl work with V4L2_SUBDEV_FORMAT_TRY
2019年1月11日(金) 0:28 Akinobu Mita <[email protected]>:
</[email protected]>
Quoted 45 lines
The
VIDIOC_SUBDEV_G_FMTioctl for this driver doesn't recognizeV4L2_SUBDEV_FORMAT_TRYand always works as ifV4L2_SUBDEV_FORMAT_ACTIVEis specified.Cc Enrico Scholz <[email protected]>Cc Michael Grzeschik <[email protected]>Cc Marco Felsch <[email protected]>Cc Sakari Ailus <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Signed-off-by Akinobu Mita <[email protected]>---
* v2
- Useformat->padfor the argument ofv4l2_subdev_get_try_format().drivers/media/i2c/mt9m111.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/media/i2c/mt9m111.c +12
-0@@ -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)
drivers/media/i2c/mt9m111.c static int mt9m111_s_stream(struct v4l2_subdev *sd, int enable) · line 1113
Quoted 10 lines
drivers/media/i2c/mt9m111.c +10
-0+{ +#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 v2 2/3 media: mt9m111: set all mbus format field when G_FMT and S_FMT ioctls
In reply to Akinobu MitaThis driver doesn't set all members of mbus format field when the VIDIOC_SUBDEV_{S,G}_FMT ioctls are called.
This is detected by v4l2-compliance.
---
* No changes from v1
drivers/media/i2c/mt9m111.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/i2c/mt9m111.c +7 -0
@@ -543,6 +543,9 @@ static int mt9m111_get_fmt(struct v4l2_subdev *sd, mf->code = mt9m111->fmt->code; mf->colorspace = mt9m111->fmt->colorspace; mf->field =V4L2_FIELD_NONE ; + mf->ycbcr_enc =V4L2_YCBCR_ENC_DEFAULT ; + mf->quantization =V4L2_QUANTIZATION_DEFAULT ; + mf->xfer_func =V4L2_XFER_FUNC_DEFAULT ;return 0 ; }
@@ -670,6 +673,10 @@ static int mt9m111_set_fmt(struct v4l2_subdev *sd, mf->code = fmt->code; mf->colorspace = fmt->colorspace; + mf->field =V4L2_FIELD_NONE ; + mf->ycbcr_enc =V4L2_YCBCR_ENC_DEFAULT ; + mf->quantization =V4L2_QUANTIZATION_DEFAULT ; + mf->xfer_func =V4L2_XFER_FUNC_DEFAULT ;if (format->which ==V4L2_SUBDEV_FORMAT_TRY ) { cfg->try_fmt = *mf;
Signature · 1 line
2.7.4
PATCH v2 3/3 media: mt9m111: set initial frame size other than 0x0
In reply to Akinobu MitaThis driver sets initial frame width and height to 0x0, which is invalid. So set it to selection rectangle bounds instead.
This is detected by v4l2-compliance detected.
---
* No changes from v1
drivers/media/i2c/mt9m111.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/mt9m111.c +2 -0
@@ -1311,6 +1311,8 @@ static int mt9m111_probe(struct i2c_client *client, mt9m111->rect.top =MT9M111_MIN_DARK_ROWS ; mt9m111->rect.width =MT9M111_MAX_WIDTH ; mt9m111->rect.height =MT9M111_MAX_HEIGHT ; + mt9m111->width = mt9m111->rect.width; + mt9m111->height = mt9m111->rect.height; mt9m111->fmt = &mt9m111_colour_fmts[0 ]; mt9m111->lastpage =-1 ;mutex_init (&mt9m111->power_lock);
Signature · 1 line
2.7.4