Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
2a863793 45f6f84a

+30 -12
+12
Documentation/video4linux/v4l2-controls.txt
··· 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, ...); ··· 464 461 465 462 Obviously, all controls in the cluster array must be initialized to either 466 463 a valid control or to NULL. 464 + 465 + In rare cases you might want to know which controls of a cluster actually 466 + were set explicitly by the user. For this you can check the 'is_new' flag of 467 + each control. For example, in the case of a volume/mute cluster the 'is_new' 468 + flag of the mute control would be set if the user called VIDIOC_S_CTRL for 469 + mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume 470 + controls, then the 'is_new' flag would be 1 for both controls. 471 + 472 + The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup(). 467 473 468 474 469 475 VIDIOC_LOG_STATUS Support
+14 -10
drivers/media/video/v4l2-ctrls.c
··· 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 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 || ··· 1649 1645 if (ctrl == NULL) 1650 1646 continue; 1651 1647 1652 - if (ctrl->has_new) { 1648 + if (ctrl->is_new) { 1653 1649 /* Double check this: it may have changed since the 1654 1650 last check in try_or_set_ext_ctrls(). */ 1655 1651 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) ··· 1723 1719 1724 1720 v4l2_ctrl_lock(ctrl); 1725 1721 1726 - /* Reset the 'has_new' flags of the cluster */ 1722 + /* Reset the 'is_new' flags of the cluster */ 1727 1723 for (j = 0; j < master->ncontrols; j++) 1728 1724 if (master->cluster[j]) 1729 - master->cluster[j]->has_new = 0; 1725 + master->cluster[j]->is_new = 0; 1730 1726 1731 1727 /* Copy the new caller-supplied control values. 1732 - user_to_new() sets 'has_new' to 1. */ 1728 + user_to_new() sets 'is_new' to 1. */ 1733 1729 ret = cluster_walk(i, cs, helpers, user_to_new); 1734 1730 1735 1731 if (!ret) ··· 1826 1822 1827 1823 v4l2_ctrl_lock(ctrl); 1828 1824 1829 - /* Reset the 'has_new' flags of the cluster */ 1825 + /* Reset the 'is_new' flags of the cluster */ 1830 1826 for (i = 0; i < master->ncontrols; i++) 1831 1827 if (master->cluster[i]) 1832 - master->cluster[i]->has_new = 0; 1828 + master->cluster[i]->is_new = 0; 1833 1829 1834 1830 ctrl->val = *val; 1835 - ctrl->has_new = 1; 1831 + ctrl->is_new = 1; 1836 1832 ret = try_or_set_control_cluster(master, false); 1837 1833 if (!ret) 1838 1834 ret = try_or_set_control_cluster(master, true);
+4 -2
include/media/v4l2-ctrls.h
··· 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. ··· 99 97 struct v4l2_ctrl_handler *handler; 100 98 struct v4l2_ctrl **cluster; 101 99 unsigned ncontrols; 102 - unsigned int has_new:1; 103 100 unsigned int done:1; 104 101 102 + unsigned int is_new:1; 105 103 unsigned int is_private:1; 106 104 unsigned int is_volatile:1; 107 105