aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2011-01-11 12:45:03 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-19 08:45:32 -0500
commit2a863793beaa0fc9ee7aeb87efe85544a6b129c0 (patch)
tree9316b12b95a707eb5541db2e24d6033d9b0e2805
parent45f6f84af3ae9db19f39bc5d0976d626b0ef626e (diff)
[media] v4l2-ctrls: v4l2_ctrl_handler_setup must set is_new to 1
Renamed has_new to is_new. Drivers can use the is_new field to determine if a new value was specified for a control. The v4l2_ctrl_handler_setup() must always set this to 1 since the setup has to force a full update of all controls. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--Documentation/video4linux/v4l2-controls.txt12
-rw-r--r--drivers/media/video/v4l2-ctrls.c24
-rw-r--r--include/media/v4l2-ctrls.h6
3 files changed, 30 insertions, 12 deletions
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index 8773778d23fc..881e7f44491b 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -285,6 +285,9 @@ implement g_volatile_ctrl like this:
285The 'new value' union is not used in g_volatile_ctrl. In general controls 285The 'new value' union is not used in g_volatile_ctrl. In general controls
286that need to implement g_volatile_ctrl are read-only controls. 286that need to implement g_volatile_ctrl are read-only controls.
287 287
288Note that if one or more controls in a control cluster are marked as volatile,
289then all the controls in the cluster are seen as volatile.
290
288To mark a control as volatile you have to set the is_volatile flag: 291To mark a control as volatile you have to set the is_volatile flag:
289 292
290 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...); 293 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
@@ -462,6 +465,15 @@ pointer to the v4l2_ctrl_ops struct that is used for that cluster.
462Obviously, all controls in the cluster array must be initialized to either 465Obviously, all controls in the cluster array must be initialized to either
463a valid control or to NULL. 466a valid control or to NULL.
464 467
468In rare cases you might want to know which controls of a cluster actually
469were set explicitly by the user. For this you can check the 'is_new' flag of
470each control. For example, in the case of a volume/mute cluster the 'is_new'
471flag of the mute control would be set if the user called VIDIOC_S_CTRL for
472mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume
473controls, then the 'is_new' flag would be 1 for both controls.
474
475The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup().
476
465 477
466VIDIOC_LOG_STATUS Support 478VIDIOC_LOG_STATUS Support
467========================= 479=========================
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 8f81efcfcf56..0d1a3d831374 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -569,7 +569,7 @@ static int user_to_new(struct v4l2_ext_control *c,
569 int ret; 569 int ret;
570 u32 size; 570 u32 size;
571 571
572 ctrl->has_new = 1; 572 ctrl->is_new = 1;
573 switch (ctrl->type) { 573 switch (ctrl->type) {
574 case V4L2_CTRL_TYPE_INTEGER64: 574 case V4L2_CTRL_TYPE_INTEGER64:
575 ctrl->val64 = c->value64; 575 ctrl->val64 = c->value64;
@@ -1280,8 +1280,12 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
1280 if (ctrl->done) 1280 if (ctrl->done)
1281 continue; 1281 continue;
1282 1282
1283 for (i = 0; i < master->ncontrols; i++) 1283 for (i = 0; i < master->ncontrols; i++) {
1284 cur_to_new(master->cluster[i]); 1284 if (master->cluster[i]) {
1285 cur_to_new(master->cluster[i]);
1286 master->cluster[i]->is_new = 1;
1287 }
1288 }
1285 1289
1286 /* Skip button controls and read-only controls. */ 1290 /* Skip button controls and read-only controls. */
1287 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON || 1291 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON ||
@@ -1645,7 +1649,7 @@ static int try_or_set_control_cluster(struct v4l2_ctrl *master, bool set)
1645 if (ctrl == NULL) 1649 if (ctrl == NULL)
1646 continue; 1650 continue;
1647 1651
1648 if (ctrl->has_new) { 1652 if (ctrl->is_new) {
1649 /* Double check this: it may have changed since the 1653 /* Double check this: it may have changed since the
1650 last check in try_or_set_ext_ctrls(). */ 1654 last check in try_or_set_ext_ctrls(). */
1651 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) 1655 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED))
@@ -1719,13 +1723,13 @@ static int try_or_set_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1719 1723
1720 v4l2_ctrl_lock(ctrl); 1724 v4l2_ctrl_lock(ctrl);
1721 1725
1722 /* Reset the 'has_new' flags of the cluster */ 1726 /* Reset the 'is_new' flags of the cluster */
1723 for (j = 0; j < master->ncontrols; j++) 1727 for (j = 0; j < master->ncontrols; j++)
1724 if (master->cluster[j]) 1728 if (master->cluster[j])
1725 master->cluster[j]->has_new = 0; 1729 master->cluster[j]->is_new = 0;
1726 1730
1727 /* Copy the new caller-supplied control values. 1731 /* Copy the new caller-supplied control values.
1728 user_to_new() sets 'has_new' to 1. */ 1732 user_to_new() sets 'is_new' to 1. */
1729 ret = cluster_walk(i, cs, helpers, user_to_new); 1733 ret = cluster_walk(i, cs, helpers, user_to_new);
1730 1734
1731 if (!ret) 1735 if (!ret)
@@ -1822,13 +1826,13 @@ static int set_ctrl(struct v4l2_ctrl *ctrl, s32 *val)
1822 1826
1823 v4l2_ctrl_lock(ctrl); 1827 v4l2_ctrl_lock(ctrl);
1824 1828
1825 /* Reset the 'has_new' flags of the cluster */ 1829 /* Reset the 'is_new' flags of the cluster */
1826 for (i = 0; i < master->ncontrols; i++) 1830 for (i = 0; i < master->ncontrols; i++)
1827 if (master->cluster[i]) 1831 if (master->cluster[i])
1828 master->cluster[i]->has_new = 0; 1832 master->cluster[i]->is_new = 0;
1829 1833
1830 ctrl->val = *val; 1834 ctrl->val = *val;
1831 ctrl->has_new = 1; 1835 ctrl->is_new = 1;
1832 ret = try_or_set_control_cluster(master, false); 1836 ret = try_or_set_control_cluster(master, false);
1833 if (!ret) 1837 if (!ret)
1834 ret = try_or_set_control_cluster(master, true); 1838 ret = try_or_set_control_cluster(master, true);
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index d69ab4aae032..fcc9a0cf8ff1 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -53,8 +53,10 @@ struct v4l2_ctrl_ops {
53 * @handler: The handler that owns the control. 53 * @handler: The handler that owns the control.
54 * @cluster: Point to start of cluster array. 54 * @cluster: Point to start of cluster array.
55 * @ncontrols: Number of controls in cluster array. 55 * @ncontrols: Number of controls in cluster array.
56 * @has_new: Internal flag: set when there is a valid new value.
57 * @done: Internal flag: set for each processed control. 56 * @done: Internal flag: set for each processed control.
57 * @is_new: Set when the user specified a new value for this control. It
58 * is also set when called from v4l2_ctrl_handler_setup. Drivers
59 * should never set this flag.
58 * @is_private: If set, then this control is private to its handler and it 60 * @is_private: If set, then this control is private to its handler and it
59 * will not be added to any other handlers. Drivers can set 61 * will not be added to any other handlers. Drivers can set
60 * this flag. 62 * this flag.
@@ -97,9 +99,9 @@ struct v4l2_ctrl {
97 struct v4l2_ctrl_handler *handler; 99 struct v4l2_ctrl_handler *handler;
98 struct v4l2_ctrl **cluster; 100 struct v4l2_ctrl **cluster;
99 unsigned ncontrols; 101 unsigned ncontrols;
100 unsigned int has_new:1;
101 unsigned int done:1; 102 unsigned int done:1;
102 103
104 unsigned int is_new:1;
103 unsigned int is_private:1; 105 unsigned int is_private:1;
104 unsigned int is_volatile:1; 106 unsigned int is_volatile:1;
105 107