linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv2 1/9] v4l2-common: create v4l2_g/s_parm_cap helpers
Date: Wed, 14 Feb 2018 13:50:18 -0200	[thread overview]
Message-ID: <20180214135018.356ee06d@vento.lan> (raw)
In-Reply-To: <20180122123125.24709-2-hverkuil@xs4all.nl>

Em Mon, 22 Jan 2018 13:31:17 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Create helpers to handle VIDIOC_G/S_PARM by querying the
> g/s_frame_interval v4l2_subdev ops.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/v4l2-core/v4l2-common.c | 48 +++++++++++++++++++++++++++++++++++
>  include/media/v4l2-common.h           | 26 +++++++++++++++++++
>  2 files changed, 74 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 8650ad92b64d..96c1b31de9e3 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -392,3 +392,51 @@ void v4l2_get_timestamp(struct timeval *tv)
>  	tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
>  }
>  EXPORT_SYMBOL_GPL(v4l2_get_timestamp);
> +
> +int v4l2_g_parm_cap(struct video_device *vdev,
> +		    struct v4l2_subdev *sd, struct v4l2_streamparm *a)
> +{
> +	struct v4l2_subdev_frame_interval ival = { 0 };
> +	int ret;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
> +	    a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return -EINVAL;
> +
> +	if (vdev->device_caps & V4L2_CAP_READWRITE)
> +		a->parm.capture.readbuffers = 2;

Hmm... why don't you also initialize readbuffers otherwise?

> +	if (v4l2_subdev_has_op(sd, video, g_frame_interval))
> +		a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> +	ret = v4l2_subdev_call(sd, video, g_frame_interval, &ival);
> +	if (!ret)
> +		a->parm.capture.timeperframe = ival.interval;
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_g_parm_cap);
> +
> +int v4l2_s_parm_cap(struct video_device *vdev,
> +		    struct v4l2_subdev *sd, struct v4l2_streamparm *a)
> +{
> +	struct v4l2_subdev_frame_interval ival = {
> +		.interval = a->parm.capture.timeperframe
> +	};
> +	int ret;
> +
> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
> +	    a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return -EINVAL;
> +
> +	memset(&a->parm, 0, sizeof(a->parm));
> +	if (vdev->device_caps & V4L2_CAP_READWRITE)
> +		a->parm.capture.readbuffers = 2;
> +	else
> +		a->parm.capture.readbuffers = 0;
> +
> +	if (v4l2_subdev_has_op(sd, video, g_frame_interval))
> +		a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> +	ret = v4l2_subdev_call(sd, video, s_frame_interval, &ival);
> +	if (!ret)
> +		a->parm.capture.timeperframe = ival.interval;
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_s_parm_cap);
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index e0d95a7c5d48..f3aa1d728c0b 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -341,4 +341,30 @@ v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes,
>   */
>  void v4l2_get_timestamp(struct timeval *tv);
>  
> +/**
> + * v4l2_g_parm_cap - helper routine for vidioc_g_parm to fill this in by
> + *      calling the g_frame_interval op of the given subdev. It only works
> + *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
> + *      function name.
> + *
> + * @vdev: the struct video_device pointer. Used to determine the device caps.
> + * @sd: the sub-device pointer.
> + * @a: the VIDIOC_G_PARM argument.
> + */
> +int v4l2_g_parm_cap(struct video_device *vdev,
> +		    struct v4l2_subdev *sd, struct v4l2_streamparm *a);
> +
> +/**
> + * v4l2_s_parm_cap - helper routine for vidioc_s_parm to fill this in by
> + *      calling the s_frame_interval op of the given subdev. It only works
> + *      for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
> + *      function name.
> + *
> + * @vdev: the struct video_device pointer. Used to determine the device caps.
> + * @sd: the sub-device pointer.
> + * @a: the VIDIOC_S_PARM argument.
> + */
> +int v4l2_s_parm_cap(struct video_device *vdev,
> +		    struct v4l2_subdev *sd, struct v4l2_streamparm *a);
> +
>  #endif /* V4L2_COMMON_H_ */



Thanks,
Mauro

  reply	other threads:[~2018-02-14 15:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 12:31 [PATCHv2 0/9] media: replace g/s_parm by g/s_frame_interval Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 1/9] v4l2-common: create v4l2_g/s_parm_cap helpers Hans Verkuil
2018-02-14 15:50   ` Mauro Carvalho Chehab [this message]
2018-02-14 16:23     ` Hans Verkuil
2018-02-14 16:35       ` Mauro Carvalho Chehab
2018-02-14 16:47         ` Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 2/9] media: convert g/s_parm to g/s_frame_interval in subdevs Hans Verkuil
2018-01-23 14:47   ` jacopo mondi
2018-01-23 14:52     ` Hans Verkuil
2018-02-14 16:03   ` Mauro Carvalho Chehab
2018-02-14 16:34     ` Hans Verkuil
2018-02-14 17:02       ` Mauro Carvalho Chehab
2018-02-14 17:16         ` Hans Verkuil
2018-02-14 17:30           ` Mauro Carvalho Chehab
2018-01-22 12:31 ` [PATCHv2 3/9] staging: atomisp: Kill subdev s_parm abuse Hans Verkuil
2018-02-14 16:14   ` Mauro Carvalho Chehab
2018-02-16  9:04     ` Sakari Ailus
2018-02-16 11:58       ` Mauro Carvalho Chehab
2018-02-19 11:01         ` Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 4/9] staging: atomisp: i2c: Disable non-preview configurations Hans Verkuil
2018-02-14 16:20   ` Mauro Carvalho Chehab
2018-02-16 10:12     ` Sakari Ailus
2018-02-16 12:04       ` Mauro Carvalho Chehab
2018-02-19 12:24         ` Sakari Ailus
2018-02-19 13:27   ` [PATCH v2.1 " Sakari Ailus
2018-02-19 13:30     ` Hans Verkuil
2018-02-19 13:48       ` Sakari Ailus
2018-02-19 13:58         ` Hans Verkuil
2018-02-19 14:05           ` Sakari Ailus
2018-01-22 12:31 ` [PATCHv2 5/9] staging: atomisp: i2c: Drop g_parm support in sensor drivers Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 6/9] staging: atomisp: mt9m114: Drop empty s_parm callback Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 7/9] staging: atomisp: Drop g_parm and s_parm subdev ops use Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 8/9] v4l2-subdev.h: remove obsolete g/s_parm Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 9/9] vidioc-g-parm.rst: also allow _MPLANE buffer types Hans Verkuil
2018-01-22 12:38 ` [PATCHv2 0/9] media: replace g/s_parm by g/s_frame_interval Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214135018.356ee06d@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).