Support getting default values from any control
v2 cover Support getting default values from any control
Integer controls provide a way to get their default/initial value, but any other control (p_u32, p_u8.....) provide no other way to get the initial value than unloading the module and loading it back.
*What is the actual problem?
I have a custom control with WIDTH integer values. Every value represents the calibrated FPN (fixed pattern noise) correction value for that column
-Application A changes the FPN correction value
-Application B wants to restore the calibrated value but it cant :(
*What is the proposed solution?
(Kudos to Hans Verkuil!!!)
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 controlsV4L2_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.
I have posted a copy of my working tree to
https://github.com/ribalda/linux/tree/which_def_v2
Changelog v2:
Suggested by Hans Verkuil <[email protected]>
Replace ctrls_class with which on all the codebase Changes in Documentation
(Thanks!)
Ricardo Ribalda Delgado (10):
videodev2.h: Fix typo in comment
videodev2.h: Extend struct v4l2_ext_controls media/v4l2-compat-ioctl32: Simple stylechecks media/core: Replace ctrl_class with which media/v4l2-core: struct struct v4l2_ext_controls param which usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL media/usb/pvrusb2: Support for V4L2_CTRL_WHICH_DEF_VAL media/pci/saa7164-encoder Support for V4L2_CTRL_WHICH_DEF_VAL media/pci/saa7164-vbi Support for V4L2_CTRL_WHICH_DEF_VAL
Docbook: media: Document changes on struct v4l2_ext_controls
Documentation/DocBook/media/v4l/v4l2.xml | 9 ++++ .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml | 28 ++++++++-- drivers/media/pci/saa7164/saa7164-encoder.c | 59 ++++++++++++--------- drivers/media/pci/saa7164/saa7164-vbi.c | 61 +++++++++++++--------- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 17 +++++- drivers/media/usb/uvc/uvc_v4l2.c | 14 ++++- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 17 +++--- drivers/media/v4l2-core/v4l2-ctrls.c | 54 +++++++++++++------ drivers/media/v4l2-core/v4l2-ioctl.c | 14 ++--- include/uapi/linux/videodev2.h | 14 ++++- 12 files changed, 200 insertions(+), 91 deletions(-)
Signature · 1 line
2.5.0
PATCH v2 1/10 videodev2.h: Fix typo in comment
Referenced file has moved
--- include/uapi/linux/videodev2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/videodev2.h +1 -1
@@ -2271,7 +2271,7 @@ struct v4l2_create_buffers {#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl)/* Reminder: when adding new ioctls please add support for them to -drivers/media/video/v4l2-compat-ioctl32.c as well! */ +drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */ #define BASE_VIDIOC_PRIVATE 192/* 192-255 are private */
Signature · 1 line
2.5.0
PATCH v2 2/10 videodev2.h: Extend struct v4l2_ext_controls
In reply to Ricardo Ribalda DelgadoSo it can be used to get the default value of a control.
Without this change it is not possible to get get the default value of array controls.
--- include/uapi/linux/videodev2.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/uapi/linux/videodev2.h +6 -1
@@ -1461,7 +1461,10 @@ struct v4l2_ext_control { } __attribute__ ((packed));struct v4l2_ext_controls { -__u32 ctrl_class; +union { +__u32 ctrl_class; +__u32 which; + };__u32 count;__u32 error_idx;__u32 reserved[2 ];
@@ -1472,6 +1475,8 @@ struct v4l2_ext_controls {#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)#define V4L2_CTRL_DRIVER_PRIV (id) (((id) & 0xffff) >= 0x1000)#define V4L2_CTRL_MAX_DIMS (4) +#define V4L2_CTRL_WHICH_CUR_VAL 0 +#define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000enum v4l2_ctrl_type {V4L2_CTRL_TYPE_INTEGER =1 ,
Signature · 1 line
2.5.0
PATCH v2 3/10 media/v4l2-compat-ioctl32: Simple stylechecks
In reply to Ricardo Ribalda DelgadoThe next patches on the serie need this modifications to pass clean checkpath.pl.
--- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +7 -6
@@ -609,11 +609,11 @@ static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __ }struct v4l2_ext_controls32 { -__u32 ctrl_class; -__u32 count; -__u32 error_idx; -__u32 reserved[2 ]; -compat_caddr_t controls;/* actually struct v4l2_ext_control32 * */ +__u32 ctrl_class; +__u32 count; +__u32 error_idx; +__u32 reserved[2 ]; +compat_caddr_t controls;/* actually struct v4l2_ext_control32 * */ };struct v4l2_ext_control32 {
@@ -655,7 +655,8 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_extget_user (kp->ctrl_class, &up->ctrl_class) ||get_user (kp->count, &up->count) ||get_user (kp->error_idx, &up->error_idx) || - copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved))) +copy_from_user (kp->reserved, up->reserved, + sizeof(kp->reserved))) return -EFAULT; n = kp->count;if (n ==0 ) {
Signature · 1 line
2.5.0
PATCH v2 4/10 media/core: Replace ctrl_class with which
In reply to Ricardo Ribalda DelgadoReplace the obsolete field ctrl_class with "which".
Make sure it not used in future modules by commenting out the field with ifndef __KERNEL_ .
The field cannot be simply removed because that would be change on the kenel API to the userspace (and we don't like that).
--- .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml | 6 +++--- drivers/media/pci/saa7164/saa7164-encoder.c | 6 +++--- drivers/media/pci/saa7164/saa7164-vbi.c | 6 +++--- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 6 +++--- drivers/media/v4l2-core/v4l2-ctrls.c | 24 +++++++++++----------- drivers/media/v4l2-core/v4l2-ioctl.c | 14 ++++++------- include/uapi/linux/videodev2.h | 5 +++++ 9 files changed, 38 insertions(+), 33 deletions(-)
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +3 -3
@@ -61,7 +61,7 @@ must belong to the same control class.</para> <para>Applications must always fill in the <structfield>count</structfield>, -<structfield>ctrl_class</structfield>, +<structfield>which</structfield>, <structfield>controls</structfield> and <structfield>reserved</structfield> fields of &v4l2-ext-controls;, and initialize the &v4l2-ext-control; array pointed to by the
@@ -109,7 +109,7 @@ the driver whether wrong values are automatically adjusted to a valid value or if an error is returned.</para> <para>When the <structfield>id</structfield> or -<structfield>ctrl_class</structfield> is invalid drivers return an +<structfield>which</structfield> is invalid drivers return an &EINVAL;. When the value is out of bounds drivers can choose to take the closest valid value or return an &ERANGE;, whatever seems more appropriate. In the first case the new value is set in
@@ -383,7 +383,7 @@ These controls are described in <xref linkend="rf-tuner-controls" />.</entry> <listitem> <para>The &v4l2-ext-control; <structfield>id</structfield> is invalid, the &v4l2-ext-controls; -<structfield>ctrl_class</structfield> is invalid, or the &v4l2-ext-control; +<structfield>which</structfield> is invalid, or the &v4l2-ext-control; <structfield>value</structfield> was inappropriate (e.g. the given menu index is not supported by the driver). This error code is also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and
drivers/media/pci/saa7164/saa7164-encoder.c +3 -3
@@ -538,7 +538,7 @@ static int vidioc_g_ext_ctrls(struct file *file, void *priv,struct saa7164_port *port = fh->port;int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
@@ -612,7 +612,7 @@ static int vidioc_try_ext_ctrls(struct file *file, void *priv, {int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
@@ -687,7 +687,7 @@ static int vidioc_s_ext_ctrls(struct file *file, void *priv,struct saa7164_port *port = fh->port;int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
drivers/media/pci/saa7164/saa7164-vbi.c +3 -3
@@ -501,7 +501,7 @@ static int vidioc_g_ext_ctrls(struct file *file, void *priv,struct saa7164_port *port = fh->port;int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
@@ -560,7 +560,7 @@ static int vidioc_try_ext_ctrls(struct file *file, void *priv, {int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
@@ -626,7 +626,7 @@ static int vidioc_s_ext_ctrls(struct file *file, void *priv,struct saa7164_port *port = fh->port;int i, err =0 ; -if (ctrls->ctrl_class ==V4L2_CTRL_CLASS_MPEG ) { +if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) {for (i =0 ; i < ctrls->count; i++) {struct v4l2_ext_control *ctrl = ctrls->controls + i;
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +1 -1
@@ -1113,7 +1113,7 @@ const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void)return &s5p_mfc_dec_ioctl_ops; } -#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \ +#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \ && V4L2_CTRL_DRIVER_PRIV(x))int s5p_mfc_dec_ctrls_setup (struct s5p_mfc_ctx *ctx)
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +1 -1
@@ -2060,7 +2060,7 @@ const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void)return &s5p_mfc_enc_ioctl_ops; } -#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \ +#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \ && V4L2_CTRL_DRIVER_PRIV(x))int s5p_mfc_enc_ctrls_setup (struct s5p_mfc_ctx *ctx)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +3 -3
@@ -609,7 +609,7 @@ static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __ }struct v4l2_ext_controls32 { -__u32 ctrl_class; +__u32 which;__u32 count;__u32 error_idx;__u32 reserved[2 ];
@@ -652,7 +652,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_extcompat_caddr_t p;if (!access_ok (VERIFY_READ , up,sizeof (struct v4l2_ext_controls32 )) || -get_user (kp->ctrl_class, &up->ctrl_class) || +get_user (kp->which, &up->which) ||get_user (kp->count, &up->count) ||get_user (kp->error_idx, &up->error_idx) || copy_from_user(kp->reserved, up->reserved,
@@ -702,7 +702,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_extcompat_caddr_t p;if (!access_ok (VERIFY_WRITE , up,sizeof (struct v4l2_ext_controls32 )) || -put_user (kp->ctrl_class, &up->ctrl_class) || +put_user (kp->which, &up->which) ||put_user (kp->count, &up->count) ||put_user (kp->error_idx, &up->error_idx) ||copy_to_user (up->reserved, kp->reserved,sizeof (up->reserved)))
drivers/media/v4l2-core/v4l2-ctrls.c +12 -12
@@ -1760,7 +1760,7 @@ static struct v4l2_ctrl_ref *find_private_ref(list_for_each_entry (ref, &hdl->ctrl_refs, node) {/* Search for private user controls that are compatible with VIDIOC_G/S_CTRL. */ -if (V4L2_CTRL_ID2CLASS (ref->ctrl->id) ==V4L2_CTRL_CLASS_USER && +if (V4L2_CTRL_ID2WHICH (ref->ctrl->id) ==V4L2_CTRL_CLASS_USER &&V4L2_CTRL_DRIVER_PRIV (ref->ctrl->id)) {if (!ref->ctrl->is_int)continue ;
@@ -1829,7 +1829,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl,struct v4l2_ctrl_ref *ref;struct v4l2_ctrl_ref *new_ref;u32 id = ctrl->id; -u32 class_ctrl =V4L2_CTRL_ID2CLASS (id) |1 ; +u32 class_ctrl =V4L2_CTRL_ID2WHICH (id) |1 ;int bucket = id % hdl->nr_of_buckets;/* which bucket to use */ /*
@@ -2251,9 +2251,9 @@ EXPORT_SYMBOL(v4l2_ctrl_add_handler);bool v4l2_ctrl_radio_filter (const struct v4l2_ctrl *ctrl) { -if (V4L2_CTRL_ID2CLASS (ctrl->id) ==V4L2_CTRL_CLASS_FM_TX ) +if (V4L2_CTRL_ID2WHICH (ctrl->id) ==V4L2_CTRL_CLASS_FM_TX )return true; -if (V4L2_CTRL_ID2CLASS (ctrl->id) ==V4L2_CTRL_CLASS_FM_RX ) +if (V4L2_CTRL_ID2WHICH (ctrl->id) ==V4L2_CTRL_CLASS_FM_RX )return true;switch (ctrl->id) {case V4L2_CID_AUDIO_MUTE :
@@ -2708,7 +2708,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, cs->error_idx = i; -if (cs->ctrl_class &&V4L2_CTRL_ID2CLASS (id) != cs->ctrl_class) +if (cs->which &&V4L2_CTRL_ID2WHICH (id) != cs->which)return -EINVAL ;/* Old-style private controls are not allowed for
@@ -2785,11 +2785,11 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,/* Handles the corner case where cs->count == 0. It checks whether the specified control class exists. If that class ID is 0, then it checks whether there are any controls at all. */ -static int class_check (struct v4l2_ctrl_handler *hdl,u32 ctrl_class) +static int class_check (struct v4l2_ctrl_handler *hdl,u32 which) { -if (ctrl_class ==0 ) +if (!which)return list_empty (&hdl->ctrl_refs) ? -EINVAL :0 ; -return find_ref_lock (hdl, ctrl_class |1 ) ?0 : -EINVAL ; +return find_ref_lock (hdl, which |1 ) ?0 : -EINVAL ; }
@@ -2803,13 +2803,13 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *csint i, j; cs->error_idx = cs->count; - cs->ctrl_class =V4L2_CTRL_ID2CLASS (cs->ctrl_class); + cs->which =V4L2_CTRL_ID2WHICH (cs->which);if (hdl ==NULL )return -EINVAL ;if (cs->count ==0 ) -return class_check (hdl, cs->ctrl_class); +return class_check (hdl, cs->which);if (cs->count >ARRAY_SIZE (helper)) { helpers = kmalloc_array(cs->count, sizeof(helper[0]),
@@ -3062,13 +3062,13 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,int ret; cs->error_idx = cs->count; - cs->ctrl_class =V4L2_CTRL_ID2CLASS (cs->ctrl_class); + cs->which =V4L2_CTRL_ID2WHICH (cs->which);if (hdl ==NULL )return -EINVAL ;if (cs->count ==0 ) -return class_check (hdl, cs->ctrl_class); +return class_check (hdl, cs->which);if (cs->count >ARRAY_SIZE (helper)) { helpers = kmalloc_array(cs->count, sizeof(helper[0]),
drivers/media/v4l2-core/v4l2-ioctl.c +7 -7
@@ -563,8 +563,8 @@ static void v4l_print_ext_controls(const void *arg, bool write_only)const struct v4l2_ext_controls *p = arg;int i; -pr_cont ("class=0x%x, count=%d, error_idx=%d" , - p->ctrl_class, p->count, p->error_idx); +pr_cont ("which=0x%x, count=%d, error_idx=%d" , + p->which, p->count, p->error_idx);for (i =0 ; i < p->count; i++) {if (!p->controls[i].size) pr_cont(", id/val=0x%x/0x%x",
@@ -900,13 +900,13 @@ static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL is it allowed for backwards compatibility. */ -if (!allow_priv && c->ctrl_class ==V4L2_CID_PRIVATE_BASE ) +if (!allow_priv && c->which ==V4L2_CID_PRIVATE_BASE )return 0 ; -if (c->ctrl_class ==0 ) +if (!c->which)return 1 ;/* Check that all controls are from the same control class. */ for (i =0 ; i < c->count; i++) { -if (V4L2_CTRL_ID2CLASS (c->controls[i].id) != c->ctrl_class) { +if (V4L2_CTRL_ID2WHICH (c->controls[i].id) != c->which) { c->error_idx = i;return 0 ; }
@@ -1928,7 +1928,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_g_ext_ctrls ==NULL )return -ENOTTY ; - ctrls.ctrl_class =V4L2_CTRL_ID2CLASS (p->id); + ctrls.which =V4L2_CTRL_ID2WHICH (p->id); ctrls.count =1 ; ctrls.controls = &ctrl; ctrl.id = p->id;
@@ -1962,7 +1962,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_s_ext_ctrls ==NULL )return -ENOTTY ; - ctrls.ctrl_class =V4L2_CTRL_ID2CLASS (p->id); + ctrls.which =V4L2_CTRL_ID2WHICH (p->id); ctrls.count =1 ; ctrls.controls = &ctrl; ctrl.id = p->id;
include/uapi/linux/videodev2.h +5 -0
@@ -1462,7 +1462,9 @@ struct v4l2_ext_control {struct v4l2_ext_controls {union { +#ifndef __KERNEL____u32 ctrl_class; +#endif __u32 which; };__u32 count;
@@ -1472,7 +1474,10 @@ struct v4l2_ext_controls { };#define V4L2_CTRL_ID_MASK (0x0fffffff) +#ifndef __KERNEL__#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL) +#endif +#define V4L2_CTRL_ID2WHICH (id) ((id) & 0x0fff0000UL)#define V4L2_CTRL_DRIVER_PRIV (id) (((id) & 0xffff) >= 0x1000)#define V4L2_CTRL_MAX_DIMS (4)#define V4L2_CTRL_WHICH_CUR_VAL 0
Signature · 1 line
2.5.0
PATCH v2 5/10 media/v4l2-core: struct struct v4l2_ext_controls param which
In reply to Ricardo Ribalda DelgadoSupport for new field which on v4l2_ext_controls, used to get the default value of one or more controls.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +29 -5
@@ -1489,6 +1489,17 @@ static int new_to_user(struct v4l2_ext_control *c,return ptr_to_user (c, ctrl, ctrl->p_new); } +/* Helper function: copy the initial control value back to the caller */ +static int def_to_user (struct v4l2_ext_control *c,struct v4l2_ctrl *ctrl) +{ +int idx; + +for (idx =0 ; idx < ctrl->elems; idx++) + ctrl->type_ops->init (ctrl, idx, ctrl->p_new); + +return ptr_to_user (c, ctrl, ctrl->p_new); +} +/* Helper function: copy the caller-provider value to the given control value */ static int user_to_ptr(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl,
@@ -2708,7 +2719,9 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, cs->error_idx = i; -if (cs->which &&V4L2_CTRL_ID2WHICH (id) != cs->which) +if (cs->which && + cs->which !=V4L2_CTRL_WHICH_DEF_VAL && +V4L2_CTRL_ID2WHICH (id) != cs->which)return -EINVAL ;/* Old-style private controls are not allowed for
@@ -2787,7 +2800,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,whether there are any controls at all. */ static int class_check (struct v4l2_ctrl_handler *hdl,u32 which) { -if (!which) +if (which ==0 || which ==V4L2_CTRL_WHICH_DEF_VAL )return list_empty (&hdl->ctrl_refs) ? -EINVAL :0 ;return find_ref_lock (hdl, which |1 ) ?0 : -EINVAL ; }
@@ -2801,6 +2814,9 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *csstruct v4l2_ctrl_helper *helpers = helper;int ret;int i, j; +bool def_value; + + def_value = (cs->which ==V4L2_CTRL_WHICH_DEF_VAL ) cs->error_idx = cs->count; cs->which =V4L2_CTRL_ID2WHICH (cs->which);
@@ -2827,9 +2843,11 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *csfor (i =0 ; !ret && i < cs->count; i++) {int (*ctrl_to_user)(struct v4l2_ext_control *c, -struct v4l2_ctrl *ctrl) = cur_to_user; +struct v4l2_ctrl *ctrl);struct v4l2_ctrl *master; + ctrl_to_user = def_value ? def_to_user : cur_to_user; +if (helpers[i].mref ==NULL )continue ;
@@ -2839,8 +2857,9 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *csv4l2_ctrl_lock (master);/* g_volatile_ctrl will update the new control values */ -if ((master->flags &V4L2_CTRL_FLAG_VOLATILE ) || - (master->has_volatiles && !is_cur_manual (master))) { +if (!def_value && + ((master->flags &V4L2_CTRL_FLAG_VOLATILE ) || + (master->has_volatiles && !is_cur_manual (master)))) {for (j =0 ; j < master->ncontrols; j++)cur_to_new (master->cluster[j]); ret =call_op (master, g_volatile_ctrl);
@@ -3062,6 +3081,11 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,int ret; cs->error_idx = cs->count; + +/* Default value cannot be changed */ +if (cs->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + cs->which =V4L2_CTRL_ID2WHICH (cs->which);if (hdl ==NULL )
Signature · 1 line
2.5.0
PATCH v2 6/10 usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
In reply to Ricardo Ribalda DelgadoThis driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controls
--- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_v4l2.c +13 -1
@@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,struct uvc_fh *handle = fh;struct uvc_video_chain *chain = handle->chain;struct v4l2_ext_control *ctrl = ctrls->controls; +struct v4l2_queryctrl qc;unsigned int i;int ret;
@@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,return ret;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_get (chain, ctrl); +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + qc.id = ctrl->id; + ret =uvc_query_v4l2_ctrl (chain, &qc); +if (!ret) + ctrl->value = qc.default_value; + }else + ret =uvc_ctrl_get (chain, ctrl); +if (ret <0 ) {uvc_ctrl_rollback (handle); ctrls->error_idx = i;
@@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,unsigned int i;int ret; +/* Default value cannot be changed */ +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Signature · 1 line
2.5.0
Re: [PATCH v2 06/10] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
Laurent, can you review this?
Regards,
Hans
Quoted 49 lines · Ricardo Ribalda Delgado
This driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controlsSigned-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/media/usb/uvc/uvc_v4l2.c +13
-1@@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,struct uvc_fh *handle = fh;struct uvc_video_chain *chain = handle->chain;struct v4l2_ext_control *ctrl = ctrls->controls; +struct v4l2_queryctrl qc;unsigned int i;int ret;@@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,return ret;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_get (chain, ctrl); +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + qc.id = ctrl->id; + ret =uvc_query_v4l2_ctrl (chain, &qc); +if (!ret) + ctrl->value = qc.default_value; + }else + ret =uvc_ctrl_get (chain, ctrl); +if (ret <0 ) {uvc_ctrl_rollback (handle); ctrls->error_idx = i;@@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,unsigned int i;int ret; +/* Default value cannot be changed */ +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Re: [PATCH v2 06/10] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
Quoted 1 line · Hans Verkuil
Laurent, can you review this?
Ping! If I have an Ack on Monday at the latest, then I can make a pull request for this series before I leave for 2 1/2 weeks.
Regards,
Hans
Quoted 56 lines
Regards,
Hans
Quoted 49 lines · Ricardo Ribalda Delgado
This driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controlsSigned-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/media/usb/uvc/uvc_v4l2.c +13
-1@@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,struct uvc_fh *handle = fh;struct uvc_video_chain *chain = handle->chain;struct v4l2_ext_control *ctrl = ctrls->controls; +struct v4l2_queryctrl qc;unsigned int i;int ret;@@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,return ret;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_get (chain, ctrl); +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + qc.id = ctrl->id; + ret =uvc_query_v4l2_ctrl (chain, &qc); +if (!ret) + ctrl->value = qc.default_value; + }else + ret =uvc_ctrl_get (chain, ctrl); +if (ret <0 ) {uvc_ctrl_rollback (handle); ctrls->error_idx = i;@@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,unsigned int i;int ret; +/* Default value cannot be changed */ +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Re: [PATCH v2 06/10] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
Hello Laurent
Could you take a look to this patch.
Thanks!
Quoted 66 lines · Hans Verkuil
Quoted 1 line · Hans Verkuil
Laurent, can you review this?
Ping! If I have an Ack on Monday at the latest, then I can make a pull request for this series before I leave for 2 1/2 weeks.
Regards,
Hans
Quoted 56 lines
Regards,
Hans
Quoted 49 lines · Ricardo Ribalda Delgado
This driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controlsSigned-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/media/usb/uvc/uvc_v4l2.c +13
-1@@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,struct uvc_fh *handle = fh;struct uvc_video_chain *chain = handle->chain;struct v4l2_ext_control *ctrl = ctrls->controls; +struct v4l2_queryctrl qc;unsigned int i;int ret;@@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,return ret;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_get (chain, ctrl); +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + qc.id = ctrl->id; + ret =uvc_query_v4l2_ctrl (chain, &qc); +if (!ret) + ctrl->value = qc.default_value; + }else + ret =uvc_ctrl_get (chain, ctrl); +if (ret <0 ) {uvc_ctrl_rollback (handle); ctrls->error_idx = i;@@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,unsigned int i;int ret; +/* Default value cannot be changed */ +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Signature · 1 line
Ricardo Ribalda
Laurent Pinchart
maintainerRe: [PATCH v2 06/10] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
In reply to Ricardo Ribalda DelgadoHi Ricardo,
Thank you for the patch.
Quoted 22 lines · On Friday 21 August 2015 15:19:25 Ricardo Ribalda Delgado wrote:
This driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controlsSigned-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/usb/uvc/uvc_v4l2.cindex2764f43607c1..e6d3a1bcfa2f100644drivers/media/usb/uvc/uvc_v4l2.c +1
-0@@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, struct uvc_fh *handle = fh;struct uvc_video_chain *chain = handle->chain;struct v4l2_ext_control *ctrl = ctrls->controls; +struct v4l2_queryctrl qc;unsigned int i;int ret;
drivers/media/usb/uvc/uvc_v4l2.c static int uvc_ioctl_g_ext_ctrls(struct file *file, · line 994
Quoted 7 lines
drivers/media/usb/uvc/uvc_v4l2.c +3
-1@@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, return ret;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_get (chain, ctrl); +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + qc.id = ctrl->id; + ret =uvc_query_v4l2_ctrl (chain, &qc);
The uvc_ctrl_begin() call above locks chain->ctrl_mutex, and uvc_query_v4l2_ctrl() will then try to acquire the same lock. That's not a good idea :-)
I propose moving the ctrls->which check before the uvc_ctrl_begin() call and implement it as
if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) {
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
struct v4l2_queryctrl 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;
}
return 0;
}Quoted 19 lines
drivers/media/usb/uvc/uvc_v4l2.c +9
-0+if (!ret) + ctrl->value = qc.default_value; + }else + ret =uvc_ctrl_get (chain, ctrl); +if (ret <0 ) {uvc_ctrl_rollback (handle); ctrls->error_idx = i;@@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle, unsigned int i;int ret; +/* Default value cannot be changed */ +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v2 7/10 media/usb/pvrusb2: Support for V4L2_CTRL_WHICH_DEF_VAL
In reply to Ricardo Ribalda DelgadoThis driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controls
--- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +16 -1
@@ -628,6 +628,7 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv,struct pvr2_v4l2_fh *fh = file->private_data;struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;struct v4l2_ext_control *ctrl; +struct pvr2_ctrl *cptr;unsigned int idx;int val;int ret;
@@ -635,8 +636,18 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv, ret =0 ;for (idx =0 ; idx < ctls->count; idx++) { ctrl = ctls->controls + idx; - ret =pvr2_ctrl_get_value ( +if (ctls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + cptr =pvr2_hdw_get_ctrl_v4l (hdw, ctrl->id); +if (cptr) +pvr2_ctrl_get_def (cptr, &val); +else + ret = -EINVAL ; + + + }else + ret =pvr2_ctrl_get_value (pvr2_hdw_get_ctrl_v4l (hdw, ctrl->id), &val); +if (ret) { ctls->error_idx = idx;return ret;
@@ -658,6 +669,10 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv,unsigned int idx;int ret; +/* Default value cannot be changed */ +if (ctls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =0 ;for (idx =0 ; idx < ctls->count; idx++) { ctrl = ctls->controls + idx;
Signature · 1 line
2.5.0
Re: [PATCH v2 07/10] media/usb/pvrusb2: Support for V4L2_CTRL_WHICH_DEF_VAL
The code you've added is carefully checking the return pointer from pvr2_hdw_get_ctrl_v4l() yet the original code did not operate this way. The result is that now there's this "unbalanced" effect where it appears that the validity of the pvr2_ctrl instance is only checked on one side of the if-statement. I would recommend instead to elevate the call to pvr2_hdw_get_ctrl_v4l() out of the if-statement - since in both cases it's being called the same way both times. Then do the validity check in that one spot and that simplifies the if-statement all the way down to choosing between pvr2_ctrl_get_value() vs pvr2_ctrl_get_def().
It's not a correctness comment; what you have should work fine. So I'm ack'ing this in any case:
But you can do the above pretty easily & safely, and simplify it a bit further.
-Mike
Quoted 53 lines · Ricardo Ribalda Delgado
This driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controlsSigned-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +16
-1@@ -628,6 +628,7 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv,struct pvr2_v4l2_fh *fh = file->private_data;struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;struct v4l2_ext_control *ctrl; +struct pvr2_ctrl *cptr;unsigned int idx;int val;int ret;@@ -635,8 +636,18 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv, ret =0 ;for (idx =0 ; idx < ctls->count; idx++) { ctrl = ctls->controls + idx; - ret =pvr2_ctrl_get_value ( +if (ctls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { + cptr =pvr2_hdw_get_ctrl_v4l (hdw, ctrl->id); +if (cptr) +pvr2_ctrl_get_def (cptr, &val); +else + ret = -EINVAL ; + + + }else + ret =pvr2_ctrl_get_value (pvr2_hdw_get_ctrl_v4l (hdw, ctrl->id), &val); +if (ret) { ctls->error_idx = idx;return ret;@@ -658,6 +669,10 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv,unsigned int idx;int ret; +/* Default value cannot be changed */ +if (ctls->which ==V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + ret =0 ;for (idx =0 ; idx < ctls->count; idx++) { ctrl = ctls->controls + idx;
Signature · 3 lines
Mike Isely isely @ isely (dot) net PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8
PATCH v2 8/10 media/pci/saa7164-encoder Support for V4L2_CTRL_WHICH_DEF_VAL
In reply to Ricardo Ribalda DelgadoThis driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controls
--- drivers/media/pci/saa7164/saa7164-encoder.c | 55 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 24 deletions(-)
drivers/media/pci/saa7164/saa7164-encoder.c +31 -24
@@ -531,30 +531,6 @@ static int saa7164_get_ctrl(struct saa7164_port *port,return 0 ; } -static int vidioc_g_ext_ctrls (struct file *file,void *priv, -struct v4l2_ext_controls *ctrls) -{ -struct saa7164_encoder_fh *fh = file->private_data; -struct saa7164_port *port = fh->port; -int i, err =0 ; - -if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) { -for (i =0 ; i < ctrls->count; i++) { -struct v4l2_ext_control *ctrl = ctrls->controls + i; - - err =saa7164_get_ctrl (port, ctrl); -if (err) { - ctrls->error_idx = i; -break ; - } - } -return err; - - } - -return -EINVAL ; -} -static int saa7164_try_ctrl (struct v4l2_ext_control *ctrl,int ac3) {int ret = -EINVAL ;
@@ -884,6 +860,37 @@ static int vidioc_queryctrl(struct file *file, void *priv,return -EINVAL ; } +static int vidioc_g_ext_ctrls (struct file *file,void *priv, +struct v4l2_ext_controls *ctrls) +{ +struct saa7164_encoder_fh *fh = file->private_data; +struct saa7164_port *port = fh->port; +int i, err =0 ; + +if (ctrls->which !=V4L2_CTRL_CLASS_MPEG && + ctrls->which !=V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + +for (i =0 ; i < ctrls->count; i++) { +struct v4l2_ext_control *ctrl = ctrls->controls + i; + +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { +struct v4l2_queryctrl q; + + err =fill_queryctrl (&port->encoder_params, &q); +if (!err) + ctrl->value = q.default_value; + }else + err =saa7164_get_ctrl (port, ctrl); + +if (err) { + ctrls->error_idx = i; +break ; + } + } +return err; +} +static int saa7164_encoder_stop_port (struct saa7164_port *port) {struct saa7164_dev *dev = port->dev;
Signature · 1 line
2.5.0
PATCH v2 9/10 media/pci/saa7164-vbi Support for V4L2_CTRL_WHICH_DEF_VAL
In reply to Ricardo Ribalda DelgadoThis driver does not use the control infrastructure. Add support for the new field which on structure
v4l2_ext_controls
--- drivers/media/pci/saa7164/saa7164-vbi.c | 57 +++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 24 deletions(-)
drivers/media/pci/saa7164/saa7164-vbi.c +33 -24
@@ -494,30 +494,6 @@ static int saa7164_get_ctrl(struct saa7164_port *port,return 0 ; } -static int vidioc_g_ext_ctrls (struct file *file,void *priv, -struct v4l2_ext_controls *ctrls) -{ -struct saa7164_vbi_fh *fh = file->private_data; -struct saa7164_port *port = fh->port; -int i, err =0 ; - -if (ctrls->which ==V4L2_CTRL_CLASS_MPEG ) { -for (i =0 ; i < ctrls->count; i++) { -struct v4l2_ext_control *ctrl = ctrls->controls + i; - - err =saa7164_get_ctrl (port, ctrl); -if (err) { - ctrls->error_idx = i; -break ; - } - } -return err; - - } - -return -EINVAL ; -} -static int saa7164_try_ctrl (struct v4l2_ext_control *ctrl,int ac3) {int ret = -EINVAL ;
@@ -810,6 +786,39 @@ static int vidioc_queryctrl(struct file *file, void *priv,return -EINVAL ; } +static int vidioc_g_ext_ctrls (struct file *file,void *priv, +struct v4l2_ext_controls *ctrls) +{ +struct saa7164_vbi_fh *fh = file->private_data; +struct saa7164_port *port = fh->port; +int i, err =0 ; + +if (ctrls->which !=V4L2_CTRL_CLASS_MPEG && + ctrls->which !=V4L2_CTRL_WHICH_DEF_VAL ) +return -EINVAL ; + +for (i =0 ; i < ctrls->count; i++) { +struct v4l2_ext_control *ctrl = ctrls->controls + i; + +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) { +struct v4l2_queryctrl q; + + err =fill_queryctrl (&port->vbi_params, &q); +if (!err) + ctrl->value = q.default_value; + }else + err =saa7164_get_ctrl (port, ctrl); + +if (err) { + ctrls->error_idx = i; +break ; + } + } + +return err; +} + +static int saa7164_vbi_stop_port (struct saa7164_port *port) {struct saa7164_dev *dev = port->dev;
Signature · 1 line
2.5.0
PATCH v2 10/10 Docbook: media: Document changes on struct v4l2_ext_controls
In reply to Ricardo Ribalda DelgadoVidioc-g-ext-ctrls can now be used to get the default value of the controls.
--- Documentation/DocBook/media/v4l/v4l2.xml | 9 +++++++++ .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+)
Documentation/DocBook/media/v4l/v4l2.xml +9 -0
@@ -153,6 +153,15 @@ structs, ioctls) must be noted in more detail in the history chapter applications. --> <revision> + <revnumber>4.4</revnumber> + <date>2015-08-20</date> + <authorinitials>rr</authorinitials> + <revremark>Extend vidioc-g-ext-ctrls;. Replace ctrl_class with a new +union with ctrl_class and which. Which is used to select the current value of +the control or the default value. + </revremark> + </revision> + <revision> <revnumber>3.21</revnumber> <date>2015-02-13</date> <authorinitials>mcc</authorinitials>
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +22 -0
@@ -216,7 +216,12 @@ Valid if <constant>V4L2_CTRL_FLAG_HAS_PAYLOAD</constant> is set for this control <tgroup cols="3"> &cs-str; <tbody valign="top"> + <row> + <entry>union</entry> + <entry>(anonymous)</entry> + </row> <row> + <entry></entry> <entry>__u32</entry> <entry><structfield>ctrl_class</structfield></entry> <entry>The control class to which all controls belong, see
@@ -228,6 +233,23 @@ with a <structfield>count</structfield> of 0. If that succeeds, then the driver supports this feature.</entry> </row> <row> + <entry></entry> + <entry>__u32</entry> + <entry><structfield>which</structfield></entry> + <entry><para>Which value of the control to get/set/try. <constant>V4L2_CTRL_WHICH_CUR_VAL</constant> +will return the current value of the control and <constant>V4L2_CTRL_WHICH_DEF_VAL</constant> will +return the default value of the control. Please note that you can only get the default value of the +control, you cannot set or try it.</para> +<para>For backwards compatibility you can also use a control class here (see +<xref linkend="ctrl-class" />). In that case all controls have to belong to that +control class. This usage is deprecated, instead just use <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>. +There are some very old drivers that do not yet support <constant>V4L2_CTRL_WHICH_CUR_VAL</constant> +and that require a control class here. You can test for such drivers by setting ctrl_class to +<constant>V4L2_CTRL_WHICH_CUR_VAL</constant> and calling VIDIOC_TRY_EXT_CTRLS with a count of 0. +If that fails, then the driver does not support <constant>V4L2_CTRL_WHICH_CUR_VAL</constant>.</para> +</entry> + </row> + <row> <entry>__u32</entry> <entry><structfield>count</structfield></entry> <entry>The number of controls in the controls array. May
Signature · 1 line
2.5.0
This patch series looks good. I'll drop the saa7164 patches since I made a patch series converting it to the control framework. Once Steve gives me the Ack for that I can merge that series.
All I need to merge your series (minus the saa7164 patches) is the Ack from Laurent for the uvc patch.
Regards,
Hans
Quoted 76 lines · Ricardo Ribalda Delgado
Integer controls provide a way to get their default/initial value, but any other control (
p_u32,p_u8.....) provide no other way to get the initial value than unloading the module and loading it back.*What is the actual problem?
I have a custom control with WIDTH integer values. Every value represents the calibrated FPN (fixed pattern noise) correction value for that column(quoted diff) +0
-2-Application A changes the FPN correction value -Application B wants to restore the calibrated value but it cant :(*What is the proposed solution?
(Kudos to Hans Verkuil!!!)
The key change is in struct
v4l2_ext_controlswhere the__u32ctrl_classfield is changed to:union { __u32 ctrl_class; __u32 which; };And two new defines are added:
#define
V4L2_CTRL_WHICH_CUR_VAL0
#defineV4L2_CTRL_WHICH_DEF_VAL0x0f000000The 'which' field tells you which controls are get/set/tried.
V4L2_CTRL_WHICH_CUR_VAL: the current value of the controlsV4L2_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 addV4L2_CTRL_WHICH_aliases for these defines.I have posted a copy of my working tree to
https://github.com/ribalda/linux/tree/which_def_v2
Changelog v2:
Suggested by Hans Verkuil <[email protected]>
Replace
ctrls_classwith which on all the codebase Changes in Documentation
(Thanks!)Ricardo Ribalda Delgado (10):
videodev2.h: Fix typo in comment
videodev2.h: Extend structv4l2_ext_controlsmedia/v4l2-compat-ioctl32: Simple stylechecks media/core: Replacectrl_classwith which media/v4l2-core: struct structv4l2_ext_controlsparam which usb/uvc: Support forV4L2_CTRL_WHICH_DEF_VALmedia/usb/pvrusb2: Support forV4L2_CTRL_WHICH_DEF_VALmedia/pci/saa7164-encoder Support forV4L2_CTRL_WHICH_DEF_VALmedia/pci/saa7164-vbi Support forV4L2_CTRL_WHICH_DEF_VAL
Docbook: media: Document changes on structv4l2_ext_controlsDocumentation/DocBook/media/v4l/v4l2.xml | 9 ++++ .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml | 28 ++++++++-- drivers/media/pci/saa7164/saa7164-encoder.c | 59 ++++++++++++--------- drivers/media/pci/saa7164/saa7164-vbi.c | 61 +++++++++++++--------- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 17 +++++- drivers/media/usb/uvc/uvc_v4l2.c | 14 ++++- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 17 +++--- drivers/media/v4l2-core/v4l2-ctrls.c | 54 +++++++++++++------ drivers/media/v4l2-core/v4l2-ioctl.c | 14 ++--- include/uapi/linux/videodev2.h | 14 ++++- 12 files changed, 200 insertions(+), 91 deletions(-)