public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	linux-media@vger.kernel.org
Subject: Re: [RFC v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls
Date: Thu, 16 Jul 2015 09:38:11 +0200	[thread overview]
Message-ID: <55A75F63.1020304@xs4all.nl> (raw)
In-Reply-To: <2206042.E86xyoYRaG@avalon>

On 07/15/15 23:05, Laurent Pinchart wrote:
> Hi Ricardo,
> 
> Thank you for the patch.
> 
> On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
>> Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
>> use the controller framework.
>>
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>> ---
>>  drivers/media/usb/uvc/uvc_v4l2.c | 30 ++++++++++++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
>> b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a 100644
>> --- a/drivers/media/usb/uvc/uvc_v4l2.c
>> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
>> @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file,
>> void *fh, return uvc_ctrl_rollback(handle);
>>  }
>>
>> +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>> +				     struct v4l2_ext_controls *ctrls)
>> +{
>> +	struct uvc_fh *handle = fh;
>> +	struct uvc_video_chain *chain = handle->chain;
>> +	struct v4l2_ext_control *ctrl = ctrls->controls;
>> +	unsigned int i;
>> +	int ret;
>> +	struct v4l2_queryctrl qc;
>> +
>> +	ret = uvc_ctrl_begin(chain);
> 
> There's no need to call uvc_ctrl_begin() here (and if there was, you'd have to 
> call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
> 
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	for (i = 0; i < ctrls->count; ++ctrl, ++i) {
>> +		qc.id = ctrl->id;
>> +		ret = uvc_query_v4l2_ctrl(chain, &qc);
>> +		if (ret < 0) {
>> +			ctrls->error_idx = i;
>> +			return ret;
>> +		}
>> +		ctrl->value = qc.default_value;
>> +	}
>> +
>> +	ctrls->error_idx = 0;
>> +
>> +	return 0;
>> +}
> 
> Instead of open-coding this in multiple drivers, how about adding a helper 
> function to the core ? Something like (totally untested)

It's only open-coded in drivers that do not use the control framework. For
drivers that use the control framework it is completely transparent.

Regards,

	Hans

> 
> int v4l2_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>                                struct v4l2_ext_controls *ctrls)
> {
> 	struct video_device *vdev = video_devdata(file);
> 	unsigned int i;
> 	int ret;
> 
> 	for (i = 0; i < ctrls->count; ++i) {
> 		struct v4l2_queryctrl qc;
> 
> 		qc.id = ctrl->id;
> 		ret = vdev->ioctl_ops->vidioc_queryctrl(file, fh, &qc);
> 		if (ret < 0) {
> 			ctrls->error_idx = i;
> 			return ret;
> 		}
> 
> 		ctrls->controls[i].value = qc.default_value;
> 	}
> 
> 	ctrls->error_idx = 0;
> 
> 	return 0;
> }
> 
> The function could be called by v4l_g_def_ext_ctrls() when ops-
>> vidioc_g_def_ext_ctrls is NULL.
> 
>>  static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
>>  				     struct v4l2_ext_controls *ctrls,
>>  				     bool commit)
>> @@ -1500,6 +1529,7 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
>>  	.vidioc_g_ctrl = uvc_ioctl_g_ctrl,
>>  	.vidioc_s_ctrl = uvc_ioctl_s_ctrl,
>>  	.vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls,
>> +	.vidioc_g_def_ext_ctrls = uvc_ioctl_g_def_ext_ctrls,
>>  	.vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls,
>>  	.vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
>>  	.vidioc_querymenu = uvc_ioctl_querymenu,
> 

  reply	other threads:[~2015-07-16  7:39 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 16:46 [RFC v3 00/19] New ioct VIDIOC_G_DEF_EXT_CTRLS Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 01/19] media/v4l2-core: Add argument def_value to g_ext_ctrl Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 02/19] media/v4l2-core: add new ioctl VIDIOC_G_DEF_EXT_CTRLS Ricardo Ribalda Delgado
2015-07-17  7:13   ` Sakari Ailus
2015-07-17  7:38     ` Hans Verkuil
2015-07-17  7:44     ` Ricardo Ribalda Delgado
2015-07-20 13:37   ` Hans Verkuil
2015-07-20 13:52     ` Ricardo Ribalda Delgado
2015-07-20 14:31       ` Hans Verkuil
2015-08-10 12:04         ` Ricardo Ribalda Delgado
2015-08-19 13:24           ` Ricardo Ribalda Delgado
2015-08-19 22:19         ` Laurent Pinchart
2015-08-20 12:34           ` Hans Verkuil
2015-06-12 16:46 ` [RFC v3 03/19] videodev2.h: Fix typo in comment Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls Ricardo Ribalda Delgado
2015-07-13 12:10   ` Hans Verkuil
2015-07-15 21:05   ` Laurent Pinchart
2015-07-16  7:38     ` Hans Verkuil [this message]
2015-07-16  8:11       ` Laurent Pinchart
2015-07-16  8:23         ` Hans Verkuil
2015-07-16  8:27           ` Laurent Pinchart
2015-07-16  8:36             ` Hans Verkuil
2015-07-16  8:41             ` Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 05/19] media/pci/saa7164-encoder: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 06/19] media/pci/saa7164-vbi: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 07/19] media/usb/prusb2: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 08/19] v4l2-subdev: Add g_def_ext_ctrls to core_ops Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 09/19] media/i2c/bt819: Implement g_def_ext_ctrls core_op Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 10/19] media/i2c/cs53l32a: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 11/19] media/i2c/cx25840/cx25840-core: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 12/19] media/i2c/msp3400-driver: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 13/19] media/i2c/saa7110: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 14/19] media/i2c/saa7115: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 15/19] media/i2c/tlv320aic23b: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 16/19] media/i2c/vpx3220: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 17/19] media/i2c/wm8775: " Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 18/19] Docbook: media: new ioctl VIDIOC_G_DEF_EXT_CTRLS Ricardo Ribalda Delgado
2015-06-12 16:46 ` [RFC v3 19/19] Documentation: media: Fix code sample Ricardo Ribalda Delgado
2015-06-16  6:09 ` [RFC v3 00/19] New ioct VIDIOC_G_DEF_EXT_CTRLS Hans Verkuil
2015-06-16  8:21   ` Ricardo Ribalda Delgado

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=55A75F63.1020304@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=g.liakhovetski@gmx.de \
    --cc=hans.verkuil@cisco.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=ricardo.ribalda@gmail.com \
    --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