Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Russell King - ARM Linux
On Mon, Mar 20, 2017 at 10:23:30AM +0100, Philippe De Muyter wrote:
> So existing gstreamer applications using /dev/video* to control framerate,
> and even gain and exposure won't work anymore :( ?
> 
> I had hoped to keep compatibility, with added robustness and functionality.
> 
> I seems like I'll stay with my NXP/Freescale old and imperfect kernel.

Thank you for saying this, this supports my views which I've already
stated about what influences which kernel people will use.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Russell King - ARM Linux
On Mon, Mar 20, 2017 at 10:23:30AM +0100, Philippe De Muyter wrote:
> So existing gstreamer applications using /dev/video* to control framerate,
> and even gain and exposure won't work anymore :( ?
> 
> I had hoped to keep compatibility, with added robustness and functionality.
> 
> I seems like I'll stay with my NXP/Freescale old and imperfect kernel.

Thank you for saying this, this supports my views which I've already
stated about what influences which kernel people will use.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Philippe De Muyter
On Mon, Mar 20, 2017 at 09:05:25AM +, Russell King - ARM Linux wrote:
> On Mon, Mar 20, 2017 at 09:55:12AM +0100, Philippe De Muyter wrote:
> > Hi Russel,
> > 
> > On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> > > Add support for enumerating frame sizes and frame intervals from the
> > > first subdev via the V4L2 interfaces.
> > > 
> > > Signed-off-by: Russell King 
> > > ---
> > >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > > +++
> > >  1 file changed, 62 insertions(+)
> > > 
> > ...
> > > +static int capture_enum_frameintervals(struct file *file, void *fh,
> > > +struct v4l2_frmivalenum *fival)
> > > +{
> > > + struct capture_priv *priv = video_drvdata(file);
> > > + const struct imx_media_pixfmt *cc;
> > > + struct v4l2_subdev_frame_interval_enum fie = {
> > > + .index = fival->index,
> > > + .pad = priv->src_sd_pad,
> > > + .width = fival->width,
> > > + .height = fival->height,
> > > + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> > > + };
> > > + int ret;
> > > +
> > > + cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> > > + if (!cc)
> > > + return -EINVAL;
> > > +
> > > + fie.code = cc->codes[0];
> > > +
> > > + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> > > );
> > > + if (ret)
> > > + return ret;
> > > +
> > > + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> > > + fival->discrete = fie.interval;
> > 
> > For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
> > possible,
> > and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.
> 
> For my sensor, any frame interval is also possible, but that isn't the
> point here.
> 
> /dev/video* only talks to the CSI source pad, not it's sink pad.  The
> sink pad gets configured with the sensor frame rate via the media
> controller API.  /dev/video* itself has no control over the sensor
> frame rate.
> 
> The media controller stuff completely changes the way the established
> /dev/video* functionality works - the ability to select arbitary frame
> sizes and frame rates supported by the ultimate sensor is gone.  All
> that needs to be setup through the media controller pipeline, one
> subdev at a time.
> 
So existing gstreamer applications using /dev/video* to control framerate,
and even gain and exposure won't work anymore :( ?

I had hoped to keep compatibility, with added robustness and functionality.

I seems like I'll stay with my NXP/Freescale old and imperfect kernel.

Best regards

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Philippe De Muyter
On Mon, Mar 20, 2017 at 09:05:25AM +, Russell King - ARM Linux wrote:
> On Mon, Mar 20, 2017 at 09:55:12AM +0100, Philippe De Muyter wrote:
> > Hi Russel,
> > 
> > On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> > > Add support for enumerating frame sizes and frame intervals from the
> > > first subdev via the V4L2 interfaces.
> > > 
> > > Signed-off-by: Russell King 
> > > ---
> > >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > > +++
> > >  1 file changed, 62 insertions(+)
> > > 
> > ...
> > > +static int capture_enum_frameintervals(struct file *file, void *fh,
> > > +struct v4l2_frmivalenum *fival)
> > > +{
> > > + struct capture_priv *priv = video_drvdata(file);
> > > + const struct imx_media_pixfmt *cc;
> > > + struct v4l2_subdev_frame_interval_enum fie = {
> > > + .index = fival->index,
> > > + .pad = priv->src_sd_pad,
> > > + .width = fival->width,
> > > + .height = fival->height,
> > > + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> > > + };
> > > + int ret;
> > > +
> > > + cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> > > + if (!cc)
> > > + return -EINVAL;
> > > +
> > > + fie.code = cc->codes[0];
> > > +
> > > + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> > > );
> > > + if (ret)
> > > + return ret;
> > > +
> > > + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> > > + fival->discrete = fie.interval;
> > 
> > For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
> > possible,
> > and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.
> 
> For my sensor, any frame interval is also possible, but that isn't the
> point here.
> 
> /dev/video* only talks to the CSI source pad, not it's sink pad.  The
> sink pad gets configured with the sensor frame rate via the media
> controller API.  /dev/video* itself has no control over the sensor
> frame rate.
> 
> The media controller stuff completely changes the way the established
> /dev/video* functionality works - the ability to select arbitary frame
> sizes and frame rates supported by the ultimate sensor is gone.  All
> that needs to be setup through the media controller pipeline, one
> subdev at a time.
> 
So existing gstreamer applications using /dev/video* to control framerate,
and even gain and exposure won't work anymore :( ?

I had hoped to keep compatibility, with added robustness and functionality.

I seems like I'll stay with my NXP/Freescale old and imperfect kernel.

Best regards

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Russell King - ARM Linux
On Mon, Mar 20, 2017 at 09:55:12AM +0100, Philippe De Muyter wrote:
> Hi Russel,
> 
> On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> > Add support for enumerating frame sizes and frame intervals from the
> > first subdev via the V4L2 interfaces.
> > 
> > Signed-off-by: Russell King 
> > ---
> >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > +++
> >  1 file changed, 62 insertions(+)
> > 
> ...
> > +static int capture_enum_frameintervals(struct file *file, void *fh,
> > +  struct v4l2_frmivalenum *fival)
> > +{
> > +   struct capture_priv *priv = video_drvdata(file);
> > +   const struct imx_media_pixfmt *cc;
> > +   struct v4l2_subdev_frame_interval_enum fie = {
> > +   .index = fival->index,
> > +   .pad = priv->src_sd_pad,
> > +   .width = fival->width,
> > +   .height = fival->height,
> > +   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> > +   };
> > +   int ret;
> > +
> > +   cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> > +   if (!cc)
> > +   return -EINVAL;
> > +
> > +   fie.code = cc->codes[0];
> > +
> > +   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> > );
> > +   if (ret)
> > +   return ret;
> > +
> > +   fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> > +   fival->discrete = fie.interval;
> 
> For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
> possible,
> and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.

For my sensor, any frame interval is also possible, but that isn't the
point here.

/dev/video* only talks to the CSI source pad, not it's sink pad.  The
sink pad gets configured with the sensor frame rate via the media
controller API.  /dev/video* itself has no control over the sensor
frame rate.

The media controller stuff completely changes the way the established
/dev/video* functionality works - the ability to select arbitary frame
sizes and frame rates supported by the ultimate sensor is gone.  All
that needs to be setup through the media controller pipeline, one
subdev at a time.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Russell King - ARM Linux
On Mon, Mar 20, 2017 at 09:55:12AM +0100, Philippe De Muyter wrote:
> Hi Russel,
> 
> On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> > Add support for enumerating frame sizes and frame intervals from the
> > first subdev via the V4L2 interfaces.
> > 
> > Signed-off-by: Russell King 
> > ---
> >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > +++
> >  1 file changed, 62 insertions(+)
> > 
> ...
> > +static int capture_enum_frameintervals(struct file *file, void *fh,
> > +  struct v4l2_frmivalenum *fival)
> > +{
> > +   struct capture_priv *priv = video_drvdata(file);
> > +   const struct imx_media_pixfmt *cc;
> > +   struct v4l2_subdev_frame_interval_enum fie = {
> > +   .index = fival->index,
> > +   .pad = priv->src_sd_pad,
> > +   .width = fival->width,
> > +   .height = fival->height,
> > +   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> > +   };
> > +   int ret;
> > +
> > +   cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> > +   if (!cc)
> > +   return -EINVAL;
> > +
> > +   fie.code = cc->codes[0];
> > +
> > +   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> > );
> > +   if (ret)
> > +   return ret;
> > +
> > +   fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> > +   fival->discrete = fie.interval;
> 
> For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
> possible,
> and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.

For my sensor, any frame interval is also possible, but that isn't the
point here.

/dev/video* only talks to the CSI source pad, not it's sink pad.  The
sink pad gets configured with the sensor frame rate via the media
controller API.  /dev/video* itself has no control over the sensor
frame rate.

The media controller stuff completely changes the way the established
/dev/video* functionality works - the ability to select arbitary frame
sizes and frame rates supported by the ultimate sensor is gone.  All
that needs to be setup through the media controller pipeline, one
subdev at a time.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Philippe De Muyter
Hi Russel,

On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> Add support for enumerating frame sizes and frame intervals from the
> first subdev via the V4L2 interfaces.
> 
> Signed-off-by: Russell King 
> ---
>  drivers/staging/media/imx/imx-media-capture.c | 62 
> +++
>  1 file changed, 62 insertions(+)
> 
...
> +static int capture_enum_frameintervals(struct file *file, void *fh,
> +struct v4l2_frmivalenum *fival)
> +{
> + struct capture_priv *priv = video_drvdata(file);
> + const struct imx_media_pixfmt *cc;
> + struct v4l2_subdev_frame_interval_enum fie = {
> + .index = fival->index,
> + .pad = priv->src_sd_pad,
> + .width = fival->width,
> + .height = fival->height,
> + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> + };
> + int ret;
> +
> + cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> + if (!cc)
> + return -EINVAL;
> +
> + fie.code = cc->codes[0];
> +
> + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> );
> + if (ret)
> + return ret;
> +
> + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> + fival->discrete = fie.interval;

For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
possible,
and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.

see also https://www.spinics.net/lists/linux-media/msg98622.html,
https://patchwork.kernel.org/patch/9171201/ and
https://patchwork.kernel.org/patch/9171199/

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-20 Thread Philippe De Muyter
Hi Russel,

On Sun, Mar 19, 2017 at 10:49:08AM +, Russell King wrote:
> Add support for enumerating frame sizes and frame intervals from the
> first subdev via the V4L2 interfaces.
> 
> Signed-off-by: Russell King 
> ---
>  drivers/staging/media/imx/imx-media-capture.c | 62 
> +++
>  1 file changed, 62 insertions(+)
> 
...
> +static int capture_enum_frameintervals(struct file *file, void *fh,
> +struct v4l2_frmivalenum *fival)
> +{
> + struct capture_priv *priv = video_drvdata(file);
> + const struct imx_media_pixfmt *cc;
> + struct v4l2_subdev_frame_interval_enum fie = {
> + .index = fival->index,
> + .pad = priv->src_sd_pad,
> + .width = fival->width,
> + .height = fival->height,
> + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> + };
> + int ret;
> +
> + cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
> + if (!cc)
> + return -EINVAL;
> +
> + fie.code = cc->codes[0];
> +
> + ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
> );
> + if (ret)
> + return ret;
> +
> + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> + fival->discrete = fie.interval;

For some parallel sensors (mine is a E2V ev76c560) "any" frame interval is 
possible,
and hence type should be V4L2_FRMIVAL_TYPE_CONTINUOUS.

see also https://www.spinics.net/lists/linux-media/msg98622.html,
https://patchwork.kernel.org/patch/9171201/ and
https://patchwork.kernel.org/patch/9171199/

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-19 Thread Russell King - ARM Linux
On Sun, Mar 19, 2017 at 03:21:37PM -0700, Steve Longerbeam wrote:
> 
> 
> On 03/19/2017 03:49 AM, Russell King wrote:
> >Add support for enumerating frame sizes and frame intervals from the
> >first subdev via the V4L2 interfaces.
> >
> >Signed-off-by: Russell King 
> >---
> >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > +++
> >  1 file changed, 62 insertions(+)
> >
> >diff --git a/drivers/staging/media/imx/imx-media-capture.c 
> >b/drivers/staging/media/imx/imx-media-capture.c
> >index cdeb2cd8b1d7..bc99d9310e36 100644
> >--- a/drivers/staging/media/imx/imx-media-capture.c
> >+++ b/drivers/staging/media/imx/imx-media-capture.c
> >@@ -82,6 +82,65 @@ static int vidioc_querycap(struct file *file, void *fh,
> > return 0;
> >  }
> >+static int capture_enum_framesizes(struct file *file, void *fh,
> >+   struct v4l2_frmsizeenum *fsize)
> >+{
> >+struct capture_priv *priv = video_drvdata(file);
> >+const struct imx_media_pixfmt *cc;
> >+struct v4l2_subdev_frame_size_enum fse = {
> >+.index = fsize->index,
> >+.pad = priv->src_sd_pad,
> >+.which = V4L2_SUBDEV_FORMAT_ACTIVE,
> >+};
> >+int ret;
> >+
> >+cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true);
> >+if (!cc)
> >+return -EINVAL;
> >+
> >+fse.code = cc->codes[0];
> >+
> >+ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_size, NULL, );
> >+if (ret)
> >+return ret;
> >+
> >+fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
> >+fsize->discrete.width = fse.min_width;
> >+fsize->discrete.height = fse.max_height;
> >+
> >+return 0;
> >+}
> 
> 
> The PRP ENC/VF subdevices will return a continuous range of
> supported frame sizes at their source pad, so this should be
> modified to:
> 
> ...
> if (fse.min_width == fse.max_width &&
> fse.min_height == fse.max_height) {
> fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
> fsize->discrete.width = fse.min_width;
> fsize->discrete.height = fse.min_height;
> } else {
> fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
> fsize->stepwise.min_width = fse.min_width;
> fsize->stepwise.max_width = fse.max_width;
> fsize->stepwise.min_height = fse.min_height;
> fsize->stepwise.max_height = fse.max_height;
> fsize->stepwise.step_width = 1;
> fsize->stepwise.step_height = 1;
> }
> ...

Fine by me - I don't have any experience of those subdevices as they're
unusable for me.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-19 Thread Russell King - ARM Linux
On Sun, Mar 19, 2017 at 03:21:37PM -0700, Steve Longerbeam wrote:
> 
> 
> On 03/19/2017 03:49 AM, Russell King wrote:
> >Add support for enumerating frame sizes and frame intervals from the
> >first subdev via the V4L2 interfaces.
> >
> >Signed-off-by: Russell King 
> >---
> >  drivers/staging/media/imx/imx-media-capture.c | 62 
> > +++
> >  1 file changed, 62 insertions(+)
> >
> >diff --git a/drivers/staging/media/imx/imx-media-capture.c 
> >b/drivers/staging/media/imx/imx-media-capture.c
> >index cdeb2cd8b1d7..bc99d9310e36 100644
> >--- a/drivers/staging/media/imx/imx-media-capture.c
> >+++ b/drivers/staging/media/imx/imx-media-capture.c
> >@@ -82,6 +82,65 @@ static int vidioc_querycap(struct file *file, void *fh,
> > return 0;
> >  }
> >+static int capture_enum_framesizes(struct file *file, void *fh,
> >+   struct v4l2_frmsizeenum *fsize)
> >+{
> >+struct capture_priv *priv = video_drvdata(file);
> >+const struct imx_media_pixfmt *cc;
> >+struct v4l2_subdev_frame_size_enum fse = {
> >+.index = fsize->index,
> >+.pad = priv->src_sd_pad,
> >+.which = V4L2_SUBDEV_FORMAT_ACTIVE,
> >+};
> >+int ret;
> >+
> >+cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true);
> >+if (!cc)
> >+return -EINVAL;
> >+
> >+fse.code = cc->codes[0];
> >+
> >+ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_size, NULL, );
> >+if (ret)
> >+return ret;
> >+
> >+fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
> >+fsize->discrete.width = fse.min_width;
> >+fsize->discrete.height = fse.max_height;
> >+
> >+return 0;
> >+}
> 
> 
> The PRP ENC/VF subdevices will return a continuous range of
> supported frame sizes at their source pad, so this should be
> modified to:
> 
> ...
> if (fse.min_width == fse.max_width &&
> fse.min_height == fse.max_height) {
> fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
> fsize->discrete.width = fse.min_width;
> fsize->discrete.height = fse.min_height;
> } else {
> fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
> fsize->stepwise.min_width = fse.min_width;
> fsize->stepwise.max_width = fse.max_width;
> fsize->stepwise.min_height = fse.min_height;
> fsize->stepwise.max_height = fse.max_height;
> fsize->stepwise.step_width = 1;
> fsize->stepwise.step_height = 1;
> }
> ...

Fine by me - I don't have any experience of those subdevices as they're
unusable for me.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-19 Thread Steve Longerbeam



On 03/19/2017 03:49 AM, Russell King wrote:

Add support for enumerating frame sizes and frame intervals from the
first subdev via the V4L2 interfaces.

Signed-off-by: Russell King 
---
  drivers/staging/media/imx/imx-media-capture.c | 62 +++
  1 file changed, 62 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index cdeb2cd8b1d7..bc99d9310e36 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -82,6 +82,65 @@ static int vidioc_querycap(struct file *file, void *fh,
return 0;
  }
  
+static int capture_enum_framesizes(struct file *file, void *fh,

+  struct v4l2_frmsizeenum *fsize)
+{
+   struct capture_priv *priv = video_drvdata(file);
+   const struct imx_media_pixfmt *cc;
+   struct v4l2_subdev_frame_size_enum fse = {
+   .index = fsize->index,
+   .pad = priv->src_sd_pad,
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   };
+   int ret;
+
+   cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true);
+   if (!cc)
+   return -EINVAL;
+
+   fse.code = cc->codes[0];
+
+   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_size, NULL, );
+   if (ret)
+   return ret;
+
+   fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = fse.min_width;
+   fsize->discrete.height = fse.max_height;
+
+   return 0;
+}



The PRP ENC/VF subdevices will return a continuous range of
supported frame sizes at their source pad, so this should be
modified to:

...
if (fse.min_width == fse.max_width &&
fse.min_height == fse.max_height) {
fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
fsize->discrete.width = fse.min_width;
fsize->discrete.height = fse.min_height;
} else {
fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
fsize->stepwise.min_width = fse.min_width;
fsize->stepwise.max_width = fse.max_width;
fsize->stepwise.min_height = fse.min_height;
fsize->stepwise.max_height = fse.max_height;
fsize->stepwise.step_width = 1;
fsize->stepwise.step_height = 1;
}
...

Steve



+
+static int capture_enum_frameintervals(struct file *file, void *fh,
+  struct v4l2_frmivalenum *fival)
+{
+   struct capture_priv *priv = video_drvdata(file);
+   const struct imx_media_pixfmt *cc;
+   struct v4l2_subdev_frame_interval_enum fie = {
+   .index = fival->index,
+   .pad = priv->src_sd_pad,
+   .width = fival->width,
+   .height = fival->height,
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   };
+   int ret;
+
+   cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
+   if (!cc)
+   return -EINVAL;
+
+   fie.code = cc->codes[0];
+
+   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
);
+   if (ret)
+   return ret;
+
+   fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete = fie.interval;
+
+   return 0;
+}
+
  static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
  {
@@ -270,6 +329,9 @@ static int capture_s_parm(struct file *file, void *fh,
  static const struct v4l2_ioctl_ops capture_ioctl_ops = {
.vidioc_querycap= vidioc_querycap,
  
+	.vidioc_enum_framesizes = capture_enum_framesizes,

+   .vidioc_enum_frameintervals = capture_enum_frameintervals,
+
.vidioc_enum_fmt_vid_cap= capture_enum_fmt_vid_cap,
.vidioc_g_fmt_vid_cap   = capture_g_fmt_vid_cap,
.vidioc_try_fmt_vid_cap = capture_try_fmt_vid_cap,




Re: [PATCH 4/4] media: imx-media-capture: add frame sizes/interval enumeration

2017-03-19 Thread Steve Longerbeam



On 03/19/2017 03:49 AM, Russell King wrote:

Add support for enumerating frame sizes and frame intervals from the
first subdev via the V4L2 interfaces.

Signed-off-by: Russell King 
---
  drivers/staging/media/imx/imx-media-capture.c | 62 +++
  1 file changed, 62 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index cdeb2cd8b1d7..bc99d9310e36 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -82,6 +82,65 @@ static int vidioc_querycap(struct file *file, void *fh,
return 0;
  }
  
+static int capture_enum_framesizes(struct file *file, void *fh,

+  struct v4l2_frmsizeenum *fsize)
+{
+   struct capture_priv *priv = video_drvdata(file);
+   const struct imx_media_pixfmt *cc;
+   struct v4l2_subdev_frame_size_enum fse = {
+   .index = fsize->index,
+   .pad = priv->src_sd_pad,
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   };
+   int ret;
+
+   cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true);
+   if (!cc)
+   return -EINVAL;
+
+   fse.code = cc->codes[0];
+
+   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_size, NULL, );
+   if (ret)
+   return ret;
+
+   fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = fse.min_width;
+   fsize->discrete.height = fse.max_height;
+
+   return 0;
+}



The PRP ENC/VF subdevices will return a continuous range of
supported frame sizes at their source pad, so this should be
modified to:

...
if (fse.min_width == fse.max_width &&
fse.min_height == fse.max_height) {
fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
fsize->discrete.width = fse.min_width;
fsize->discrete.height = fse.min_height;
} else {
fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
fsize->stepwise.min_width = fse.min_width;
fsize->stepwise.max_width = fse.max_width;
fsize->stepwise.min_height = fse.min_height;
fsize->stepwise.max_height = fse.max_height;
fsize->stepwise.step_width = 1;
fsize->stepwise.step_height = 1;
}
...

Steve



+
+static int capture_enum_frameintervals(struct file *file, void *fh,
+  struct v4l2_frmivalenum *fival)
+{
+   struct capture_priv *priv = video_drvdata(file);
+   const struct imx_media_pixfmt *cc;
+   struct v4l2_subdev_frame_interval_enum fie = {
+   .index = fival->index,
+   .pad = priv->src_sd_pad,
+   .width = fival->width,
+   .height = fival->height,
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   };
+   int ret;
+
+   cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
+   if (!cc)
+   return -EINVAL;
+
+   fie.code = cc->codes[0];
+
+   ret = v4l2_subdev_call(priv->src_sd, pad, enum_frame_interval, NULL, 
);
+   if (ret)
+   return ret;
+
+   fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete = fie.interval;
+
+   return 0;
+}
+
  static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
  {
@@ -270,6 +329,9 @@ static int capture_s_parm(struct file *file, void *fh,
  static const struct v4l2_ioctl_ops capture_ioctl_ops = {
.vidioc_querycap= vidioc_querycap,
  
+	.vidioc_enum_framesizes = capture_enum_framesizes,

+   .vidioc_enum_frameintervals = capture_enum_frameintervals,
+
.vidioc_enum_fmt_vid_cap= capture_enum_fmt_vid_cap,
.vidioc_g_fmt_vid_cap   = capture_g_fmt_vid_cap,
.vidioc_try_fmt_vid_cap = capture_try_fmt_vid_cap,