Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 232206
b: refs/heads/master
c: 2a86379
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 19, 2011
1 parent fd93cbd commit 4f70267
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 45f6f84af3ae9db19f39bc5d0976d626b0ef626e
refs/heads/master: 2a863793beaa0fc9ee7aeb87efe85544a6b129c0
12 changes: 12 additions & 0 deletions trunk/Documentation/video4linux/v4l2-controls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ implement g_volatile_ctrl like this:
The 'new value' union is not used in g_volatile_ctrl. In general controls
that need to implement g_volatile_ctrl are read-only controls.

Note that if one or more controls in a control cluster are marked as volatile,
then all the controls in the cluster are seen as volatile.

To mark a control as volatile you have to set the is_volatile flag:

ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
Expand Down Expand Up @@ -462,6 +465,15 @@ pointer to the v4l2_ctrl_ops struct that is used for that cluster.
Obviously, all controls in the cluster array must be initialized to either
a valid control or to NULL.

In rare cases you might want to know which controls of a cluster actually
were set explicitly by the user. For this you can check the 'is_new' flag of
each control. For example, in the case of a volume/mute cluster the 'is_new'
flag of the mute control would be set if the user called VIDIOC_S_CTRL for
mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume
controls, then the 'is_new' flag would be 1 for both controls.

The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup().


VIDIOC_LOG_STATUS Support
=========================
Expand Down
24 changes: 14 additions & 10 deletions trunk/drivers/media/video/v4l2-ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ static int user_to_new(struct v4l2_ext_control *c,
int ret;
u32 size;

ctrl->has_new = 1;
ctrl->is_new = 1;
switch (ctrl->type) {
case V4L2_CTRL_TYPE_INTEGER64:
ctrl->val64 = c->value64;
Expand Down Expand Up @@ -1280,8 +1280,12 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
if (ctrl->done)
continue;

for (i = 0; i < master->ncontrols; i++)
cur_to_new(master->cluster[i]);
for (i = 0; i < master->ncontrols; i++) {
if (master->cluster[i]) {
cur_to_new(master->cluster[i]);
master->cluster[i]->is_new = 1;
}
}

/* Skip button controls and read-only controls. */
if (ctrl->type == V4L2_CTRL_TYPE_BUTTON ||
Expand Down Expand Up @@ -1645,7 +1649,7 @@ static int try_or_set_control_cluster(struct v4l2_ctrl *master, bool set)
if (ctrl == NULL)
continue;

if (ctrl->has_new) {
if (ctrl->is_new) {
/* Double check this: it may have changed since the
last check in try_or_set_ext_ctrls(). */
if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED))
Expand Down Expand Up @@ -1719,13 +1723,13 @@ static int try_or_set_ext_ctrls(struct v4l2_ctrl_handler *hdl,

v4l2_ctrl_lock(ctrl);

/* Reset the 'has_new' flags of the cluster */
/* Reset the 'is_new' flags of the cluster */
for (j = 0; j < master->ncontrols; j++)
if (master->cluster[j])
master->cluster[j]->has_new = 0;
master->cluster[j]->is_new = 0;

/* Copy the new caller-supplied control values.
user_to_new() sets 'has_new' to 1. */
user_to_new() sets 'is_new' to 1. */
ret = cluster_walk(i, cs, helpers, user_to_new);

if (!ret)
Expand Down Expand Up @@ -1822,13 +1826,13 @@ static int set_ctrl(struct v4l2_ctrl *ctrl, s32 *val)

v4l2_ctrl_lock(ctrl);

/* Reset the 'has_new' flags of the cluster */
/* Reset the 'is_new' flags of the cluster */
for (i = 0; i < master->ncontrols; i++)
if (master->cluster[i])
master->cluster[i]->has_new = 0;
master->cluster[i]->is_new = 0;

ctrl->val = *val;
ctrl->has_new = 1;
ctrl->is_new = 1;
ret = try_or_set_control_cluster(master, false);
if (!ret)
ret = try_or_set_control_cluster(master, true);
Expand Down
6 changes: 4 additions & 2 deletions trunk/include/media/v4l2-ctrls.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ struct v4l2_ctrl_ops {
* @handler: The handler that owns the control.
* @cluster: Point to start of cluster array.
* @ncontrols: Number of controls in cluster array.
* @has_new: Internal flag: set when there is a valid new value.
* @done: Internal flag: set for each processed control.
* @is_new: Set when the user specified a new value for this control. It
* is also set when called from v4l2_ctrl_handler_setup. Drivers
* should never set this flag.
* @is_private: If set, then this control is private to its handler and it
* will not be added to any other handlers. Drivers can set
* this flag.
Expand Down Expand Up @@ -97,9 +99,9 @@ struct v4l2_ctrl {
struct v4l2_ctrl_handler *handler;
struct v4l2_ctrl **cluster;
unsigned ncontrols;
unsigned int has_new:1;
unsigned int done:1;

unsigned int is_new:1;
unsigned int is_private:1;
unsigned int is_volatile:1;

Expand Down

0 comments on commit 4f70267

Please sign in to comment.