Commit 2a863793beaa0fc9ee7aeb87efe85544a6b129c0

Authored by Hans Verkuil
Committed by Mauro Carvalho Chehab
1 parent 45f6f84af3

[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>

Showing 3 changed files with 30 additions and 12 deletions Side-by-side Diff

Documentation/video4linux/v4l2-controls.txt
... ... @@ -285,6 +285,9 @@
285 285 The 'new value' union is not used in g_volatile_ctrl. In general controls
286 286 that need to implement g_volatile_ctrl are read-only controls.
287 287  
  288 +Note that if one or more controls in a control cluster are marked as volatile,
  289 +then all the controls in the cluster are seen as volatile.
  290 +
288 291 To mark a control as volatile you have to set the is_volatile flag:
289 292  
290 293 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
... ... @@ -461,6 +464,15 @@
461 464  
462 465 Obviously, all controls in the cluster array must be initialized to either
463 466 a valid control or to NULL.
  467 +
  468 +In rare cases you might want to know which controls of a cluster actually
  469 +were set explicitly by the user. For this you can check the 'is_new' flag of
  470 +each control. For example, in the case of a volume/mute cluster the 'is_new'
  471 +flag of the mute control would be set if the user called VIDIOC_S_CTRL for
  472 +mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume
  473 +controls, then the 'is_new' flag would be 1 for both controls.
  474 +
  475 +The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup().
464 476  
465 477  
466 478 VIDIOC_LOG_STATUS Support
drivers/media/video/v4l2-ctrls.c
... ... @@ -569,7 +569,7 @@
569 569 int ret;
570 570 u32 size;
571 571  
572   - ctrl->has_new = 1;
  572 + ctrl->is_new = 1;
573 573 switch (ctrl->type) {
574 574 case V4L2_CTRL_TYPE_INTEGER64:
575 575 ctrl->val64 = c->value64;
... ... @@ -1280,8 +1280,12 @@
1280 1280 if (ctrl->done)
1281 1281 continue;
1282 1282  
1283   - for (i = 0; i < master->ncontrols; i++)
1284   - cur_to_new(master->cluster[i]);
  1283 + for (i = 0; i < master->ncontrols; 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 1290 /* Skip button controls and read-only controls. */
1287 1291 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON ||
... ... @@ -1645,7 +1649,7 @@
1645 1649 if (ctrl == NULL)
1646 1650 continue;
1647 1651  
1648   - if (ctrl->has_new) {
  1652 + if (ctrl->is_new) {
1649 1653 /* Double check this: it may have changed since the
1650 1654 last check in try_or_set_ext_ctrls(). */
1651 1655 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED))
1652 1656  
1653 1657  
... ... @@ -1719,13 +1723,13 @@
1719 1723  
1720 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 1727 for (j = 0; j < master->ncontrols; j++)
1724 1728 if (master->cluster[j])
1725   - master->cluster[j]->has_new = 0;
  1729 + master->cluster[j]->is_new = 0;
1726 1730  
1727 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 1733 ret = cluster_walk(i, cs, helpers, user_to_new);
1730 1734  
1731 1735 if (!ret)
1732 1736  
1733 1737  
... ... @@ -1822,13 +1826,13 @@
1822 1826  
1823 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 1830 for (i = 0; i < master->ncontrols; i++)
1827 1831 if (master->cluster[i])
1828   - master->cluster[i]->has_new = 0;
  1832 + master->cluster[i]->is_new = 0;
1829 1833  
1830 1834 ctrl->val = *val;
1831   - ctrl->has_new = 1;
  1835 + ctrl->is_new = 1;
1832 1836 ret = try_or_set_control_cluster(master, false);
1833 1837 if (!ret)
1834 1838 ret = try_or_set_control_cluster(master, true);
include/media/v4l2-ctrls.h
... ... @@ -53,8 +53,10 @@
53 53 * @handler: The handler that owns the control.
54 54 * @cluster: Point to start of cluster array.
55 55 * @ncontrols: Number of controls in cluster array.
56   - * @has_new: Internal flag: set when there is a valid new value.
57 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 60 * @is_private: If set, then this control is private to its handler and it
59 61 * will not be added to any other handlers. Drivers can set
60 62 * this flag.
61 63  
... ... @@ -97,9 +99,9 @@
97 99 struct v4l2_ctrl_handler *handler;
98 100 struct v4l2_ctrl **cluster;
99 101 unsigned ncontrols;
100   - unsigned int has_new:1;
101 102 unsigned int done:1;
102 103  
  104 + unsigned int is_new:1;
103 105 unsigned int is_private:1;
104 106 unsigned int is_volatile:1;
105 107