2019-05-26 20:51:02

by Janusz Krzysztofik

[permalink] [raw]
Subject: [RFC PATCH 0/5] media: ov6650: V4L2 subdev compliance fixes

An attepmt to make the driver more compliant with V4L2 subdevice
interface specification.

Non-compliant frame half scaling is kept in .set_fmt() until composing
is implemented.

Janusz Krzysztofik (5):
media: ov6650: Fix V4L2_SEL_FLAG_KEEP_CONFIG handling
media: ov6650: Refactor ov6650_s_fmt() helper
media: ov6650: Fix active crop rectangle affected by .set_fmt()
media: ov6650: Fix frame scaling not reset on crop
media: ov6650: Add .init_cfg() pad operation callback

drivers/media/i2c/ov6650.c | 71 +++++++++++++++++++++++---------------
1 file changed, 43 insertions(+), 28 deletions(-)

--
2.21.0


2019-05-26 20:56:20

by Janusz Krzysztofik

[permalink] [raw]
Subject: [RFC PATCH 5/5] media: ov6650: Add .init_cfg() pad operation callback

The driver now supports V4L2_SUBDEV_FORMAT_TRY operation mode only in
.get/set_fmt() pad operation callbacks. That means only .try_format
member of pad config is maintained. As a consequence, active crop
rectangle is used as a referece while V4L2_SUBDEV_FORMAT_TRY requests
are processed. In order to fix that, a method for initialization of
.try_crop pad config member is needed.

Implement .init_cfg() pad operation callback which initializes the pad
config from current active format and selection settings. From now on,
and before the driver V4L2_SUBDEV_FORMAT_TRY support is further
modified, host interface drivers should call .init_cfg() on a pad
config before passing it to V4L2_SUBDEV_FORMAT_TRY operations.

Signed-off-by: Janusz Krzysztofik <[email protected]>
---
drivers/media/i2c/ov6650.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index cc70d8952999..c3d4c1f598b2 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -447,6 +447,26 @@ static int ov6650_s_power(struct v4l2_subdev *sd, int on)
return ret;
}

+static int ov6650_init_cfg(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+ struct ov6650 *priv = to_ov6650(client);
+ struct v4l2_mbus_framefmt *mf;
+ struct v4l2_rect *rect;
+
+ mf = &cfg->try_fmt;
+ *mf = ov6650_def_fmt;
+ mf->width = priv->rect.width >> priv->half_scale;
+ mf->height = priv->rect.height >> priv->half_scale;
+ mf->code = priv->code;
+
+ rect = &cfg->try_crop;
+ *rect = priv->rect;
+
+ return 0;
+}
+
static int ov6650_get_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_selection *sel)
@@ -959,6 +979,7 @@ static const struct v4l2_subdev_video_ops ov6650_video_ops = {
};

static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
+ .init_cfg = ov6650_init_cfg,
.enum_mbus_code = ov6650_enum_mbus_code,
.get_selection = ov6650_get_selection,
.set_selection = ov6650_set_selection,
--
2.21.0

2019-06-01 22:33:13

by Sakari Ailus

[permalink] [raw]
Subject: Re: [RFC PATCH 5/5] media: ov6650: Add .init_cfg() pad operation callback

Hi Janusz,

On Sun, May 26, 2019 at 10:47:58PM +0200, Janusz Krzysztofik wrote:
> The driver now supports V4L2_SUBDEV_FORMAT_TRY operation mode only in
> .get/set_fmt() pad operation callbacks. That means only .try_format
> member of pad config is maintained. As a consequence, active crop
> rectangle is used as a referece while V4L2_SUBDEV_FORMAT_TRY requests
> are processed. In order to fix that, a method for initialization of
> .try_crop pad config member is needed.
>
> Implement .init_cfg() pad operation callback which initializes the pad
> config from current active format and selection settings. From now on,

The values set by init_cfg should be the defaults and not reflect the
current configuration. Apart from that the patch seems fine.

> and before the driver V4L2_SUBDEV_FORMAT_TRY support is further
> modified, host interface drivers should call .init_cfg() on a pad
> config before passing it to V4L2_SUBDEV_FORMAT_TRY operations.
>
> Signed-off-by: Janusz Krzysztofik <[email protected]>
> ---
> drivers/media/i2c/ov6650.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> index cc70d8952999..c3d4c1f598b2 100644
> --- a/drivers/media/i2c/ov6650.c
> +++ b/drivers/media/i2c/ov6650.c
> @@ -447,6 +447,26 @@ static int ov6650_s_power(struct v4l2_subdev *sd, int on)
> return ret;
> }
>
> +static int ov6650_init_cfg(struct v4l2_subdev *sd,
> + struct v4l2_subdev_pad_config *cfg)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(sd);
> + struct ov6650 *priv = to_ov6650(client);
> + struct v4l2_mbus_framefmt *mf;
> + struct v4l2_rect *rect;
> +
> + mf = &cfg->try_fmt;
> + *mf = ov6650_def_fmt;
> + mf->width = priv->rect.width >> priv->half_scale;
> + mf->height = priv->rect.height >> priv->half_scale;
> + mf->code = priv->code;
> +
> + rect = &cfg->try_crop;
> + *rect = priv->rect;
> +
> + return 0;
> +}
> +
> static int ov6650_get_selection(struct v4l2_subdev *sd,
> struct v4l2_subdev_pad_config *cfg,
> struct v4l2_subdev_selection *sel)
> @@ -959,6 +979,7 @@ static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> };
>
> static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
> + .init_cfg = ov6650_init_cfg,
> .enum_mbus_code = ov6650_enum_mbus_code,
> .get_selection = ov6650_get_selection,
> .set_selection = ov6650_set_selection,
> --
> 2.21.0
>

--
Sakari Ailus
[email protected]