From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>,
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 02/19] media/v4l2-core: add new ioctl VIDIOC_G_DEF_EXT_CTRLS
Date: Mon, 20 Jul 2015 15:37:24 +0200 [thread overview]
Message-ID: <55ACF994.3010101@xs4all.nl> (raw)
In-Reply-To: <1434127598-11719-3-git-send-email-ricardo.ribalda@gmail.com>
On 06/12/2015 06:46 PM, Ricardo Ribalda Delgado wrote:
> This ioctl returns the default value of one or more extended controls.
> It has the same interface as VIDIOC_EXT_CTRLS.
>
> It is needed due to the fact that QUERYCTRL was not enough to
> provide the initial value of pointer type controls.
This was discussed on irc, and both Sakari and Laurent didn't like having to add
a new ioctl.
After some discussion I came up with an alternative and I'd like to have some
feedback on that.
The key change is in struct v4l2_ext_controls where the __u32 ctrl_class field
is changed to:
union {
__u32 ctrl_class;
__u32 which;
};
And two new defines are added:
#define V4L2_CTRL_WHICH_CUR_VAL 0
#define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000
The 'which' field tells you which controls are get/set/tried.
V4L2_CTRL_WHICH_CUR_VAL: the current value of the controls
V4L2_CTRL_WHICH_DEF_VAL: the default value of the controls
V4L2_CTRL_CLASS_*: the current value of the controls belonging to the specified class.
Note: this is deprecated usage and is only there for backwards compatibility.
Which is also why I don't think there is a need to add V4L2_CTRL_WHICH_
aliases for these defines.
And in the future, if the 'request' patch series for per-frame configuration is
merged, we can specify the request ID here to get/set/try the controls values
of the specified request ID.
This can also be extended to things like 'WHICH_MIN_VAL/MAX_VAL' if we want to.
An attempt to set/try controls for WHICH_DEF_VAL will return -EACCES since
the default value is a read-only value that you cannot change.
Renaming 'ctrl_class' to 'which' makes this something that can be documented
without looking like a hack and it avoids having to make a new ioctl.
Comments are welcome!
Regards,
Hans
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++++
> drivers/media/v4l2-core/v4l2-ioctl.c | 21 +++++++++++++++++++++
> drivers/media/v4l2-core/v4l2-subdev.c | 3 +++
> include/media/v4l2-ioctl.h | 2 ++
> include/uapi/linux/videodev2.h | 1 +
> 5 files changed, 31 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> index af635430524e..b7ab852b642f 100644
> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> @@ -817,6 +817,7 @@ static int put_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
> #define VIDIOC_DQEVENT32 _IOR ('V', 89, struct v4l2_event32)
> #define VIDIOC_CREATE_BUFS32 _IOWR('V', 92, struct v4l2_create_buffers32)
> #define VIDIOC_PREPARE_BUF32 _IOWR('V', 93, struct v4l2_buffer32)
> +#define VIDIOC_G_DEF_EXT_CTRLS32 _IOWR('V', 104, struct v4l2_ext_controls32)
>
> #define VIDIOC_OVERLAY32 _IOW ('V', 14, s32)
> #define VIDIOC_STREAMON32 _IOW ('V', 18, s32)
> @@ -858,6 +859,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
> case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break;
> case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break;
> case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break;
> + case VIDIOC_G_DEF_EXT_CTRLS32: cmd = VIDIOC_G_DEF_EXT_CTRLS; break;
> case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break;
> case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break;
> case VIDIOC_DQEVENT32: cmd = VIDIOC_DQEVENT; break;
> @@ -935,6 +937,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
> break;
>
> case VIDIOC_G_EXT_CTRLS:
> + case VIDIOC_G_DEF_EXT_CTRLS:
> case VIDIOC_S_EXT_CTRLS:
> case VIDIOC_TRY_EXT_CTRLS:
> err = get_v4l2_ext_controls32(&karg.v2ecs, up);
> @@ -962,6 +965,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
> contain information on which control failed. */
> switch (cmd) {
> case VIDIOC_G_EXT_CTRLS:
> + case VIDIOC_G_DEF_EXT_CTRLS:
> case VIDIOC_S_EXT_CTRLS:
> case VIDIOC_TRY_EXT_CTRLS:
> if (put_v4l2_ext_controls32(&karg.v2ecs, up))
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index a675ccc8f27a..5ed03b8588ec 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1991,6 +1991,25 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
> -EINVAL;
> }
>
> +static int v4l_g_def_ext_ctrls(const struct v4l2_ioctl_ops *ops,
> + struct file *file, void *fh, void *arg)
> +{
> + struct video_device *vfd = video_devdata(file);
> + struct v4l2_ext_controls *p = arg;
> + struct v4l2_fh *vfh =
> + test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
> +
> + p->error_idx = p->count;
> + if (vfh && vfh->ctrl_handler)
> + return v4l2_g_ext_ctrls(vfh->ctrl_handler, p, true);
> + if (vfd->ctrl_handler)
> + return v4l2_g_ext_ctrls(vfd->ctrl_handler, p, true);
> + if (ops->vidioc_g_def_ext_ctrls == NULL)
> + return -ENOTTY;
> + return check_ext_ctrls(p, 0) ?
> + ops->vidioc_g_def_ext_ctrls(file, fh, p) : -EINVAL;
> +}
> +
> static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,
> struct file *file, void *fh, void *arg)
> {
> @@ -2435,6 +2454,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
> IOCTL_INFO_FNC(VIDIOC_G_SLICED_VBI_CAP, v4l_g_sliced_vbi_cap, v4l_print_sliced_vbi_cap, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)),
> IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0),
> IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL),
> + IOCTL_INFO_FNC(VIDIOC_G_DEF_EXT_CTRLS, v4l_g_def_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL),
> IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL),
> IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL),
> IOCTL_INFO_STD(VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes, v4l_print_frmsizeenum, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)),
> @@ -2643,6 +2663,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
>
> case VIDIOC_S_EXT_CTRLS:
> case VIDIOC_G_EXT_CTRLS:
> + case VIDIOC_G_DEF_EXT_CTRLS:
> case VIDIOC_TRY_EXT_CTRLS: {
> struct v4l2_ext_controls *ctrls = parg;
>
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 90ed61e6df34..8d75620e4603 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -205,6 +205,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> case VIDIOC_G_EXT_CTRLS:
> return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg, false);
>
> + case VIDIOC_G_DEF_EXT_CTRLS:
> + return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg, true);
> +
> case VIDIOC_S_EXT_CTRLS:
> return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);
>
> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
> index 8fbbd76d78e8..16d7eeec9ff6 100644
> --- a/include/media/v4l2-ioctl.h
> +++ b/include/media/v4l2-ioctl.h
> @@ -160,6 +160,8 @@ struct v4l2_ioctl_ops {
> struct v4l2_control *a);
> int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
> struct v4l2_ext_controls *a);
> + int (*vidioc_g_def_ext_ctrls) (struct file *file, void *fh,
> + struct v4l2_ext_controls *a);
> int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
> struct v4l2_ext_controls *a);
> int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 3d5fc72d53a7..b9468a3b833e 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -2269,6 +2269,7 @@ struct v4l2_create_buffers {
> #define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info)
>
> #define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl)
> +#define VIDIOC_G_DEF_EXT_CTRLS _IOWR('V', 104, struct v4l2_ext_controls)
>
> /* Reminder: when adding new ioctls please add support for them to
> drivers/media/video/v4l2-compat-ioctl32.c as well! */
>
next prev parent reply other threads:[~2015-07-20 13:38 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 [this message]
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
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=55ACF994.3010101@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=g.liakhovetski@gmx.de \
--cc=hans.verkuil@cisco.com \
--cc=laurent.pinchart+renesas@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