Skip to content

Commit

Permalink
[media] v4l2-ctrls: replace is_volatile with V4L2_CTRL_FLAG_VOLATILE
Browse files Browse the repository at this point in the history
With the new flag there is no need anymore to have a separate is_volatile
field. Modify all users to use the new flag.

Signed-off-by: Hans Verkuil <[email protected]>
Acked-by: Hans de Goede <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Sep 21, 2011
1 parent 74a4579 commit 8836510
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 49 deletions.
13 changes: 6 additions & 7 deletions Documentation/video4linux/v4l2-controls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ implement g_volatile_ctrl like this:
Note that you use the 'new value' union as well in g_volatile_ctrl. In general
controls that need to implement g_volatile_ctrl are read-only controls.

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

ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
if (ctrl)
ctrl->is_volatile = 1;
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;

For try/s_ctrl the new values (i.e. as passed by the user) are filled in and
you can modify them in try_ctrl or set them in s_ctrl. The 'cur' union
Expand Down Expand Up @@ -367,8 +367,7 @@ Driver specific controls can be created using v4l2_ctrl_new_custom():
The last argument is the priv pointer which can be set to driver-specific
private data.

The v4l2_ctrl_config struct also has fields to set the is_private and is_volatile
flags.
The v4l2_ctrl_config struct also has a field to set the is_private flag.

If the name field is not set, then the framework will assume this is a standard
control and will fill in the name, type and flags fields accordingly.
Expand Down Expand Up @@ -506,8 +505,8 @@ operation should return the value that the hardware's automatic mode set up
automatically.

If the cluster is put in manual mode, then the manual controls should become
active again and the is_volatile flag should be ignored (so g_volatile_ctrl is
no longer called while in manual mode).
active again and V4L2_CTRL_FLAG_VOLATILE should be ignored (so g_volatile_ctrl
is no longer called while in manual mode).

Finally the V4L2_CTRL_FLAG_UPDATE should be set for the auto control since
changing that control affects the control flags of the manual controls.
Expand All @@ -520,7 +519,7 @@ void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,

The first two arguments are identical to v4l2_ctrl_cluster. The third argument
tells the framework which value switches the cluster into manual mode. The
last argument will optionally set the is_volatile flag for the non-auto controls.
last argument will optionally set V4L2_CTRL_FLAG_VOLATILE for the non-auto controls.

The first control of the cluster is assumed to be the 'auto' control.

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-wl1273.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ static int __devinit wl1273_fm_radio_probe(struct platform_device *pdev)
V4L2_CID_TUNE_ANTENNA_CAPACITOR,
0, 255, 1, 255);
if (ctrl)
ctrl->is_volatile = 1;
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;

if (radio->ctrl_handler.error) {
r = radio->ctrl_handler.error;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/wl128x/fmdrv_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
255, 1, 255);

if (ctrl)
ctrl->is_volatile = 1;
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/adp1653.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static int adp1653_init_controls(struct adp1653_flash *flash)
if (flash->ctrls.error)
return flash->ctrls.error;

fault->is_volatile = 1;
fault->flags |= V4L2_CTRL_FLAG_VOLATILE;

flash->subdev.ctrl_handler = &flash->ctrls;
return 0;
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/video/pwc/pwc-v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static int pwc_set_awb(struct pwc_device *pdev)
return ret;

/* Update val when coming from auto or going to a preset */
if (pdev->red_balance->is_volatile ||
if ((pdev->red_balance->flags & V4L2_CTRL_FLAG_VOLATILE) ||
pdev->auto_white_balance->val == awb_indoor ||
pdev->auto_white_balance->val == awb_outdoor ||
pdev->auto_white_balance->val == awb_fl) {
Expand All @@ -654,12 +654,12 @@ static int pwc_set_awb(struct pwc_device *pdev)
&pdev->blue_balance->val);
}
if (pdev->auto_white_balance->val == awb_auto) {
pdev->red_balance->is_volatile = true;
pdev->blue_balance->is_volatile = true;
pdev->red_balance->flags |= V4L2_CTRL_FLAG_VOLATILE;
pdev->blue_balance->flags |= V4L2_CTRL_FLAG_VOLATILE;
pdev->color_bal_valid = false; /* Force cache update */
} else {
pdev->red_balance->is_volatile = false;
pdev->blue_balance->is_volatile = false;
pdev->red_balance->flags &= ~V4L2_CTRL_FLAG_VOLATILE;
pdev->blue_balance->flags &= ~V4L2_CTRL_FLAG_VOLATILE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/s5p-mfc/s5p_mfc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static struct mfc_control controls[] = {
.maximum = 32,
.step = 1,
.default_value = 1,
.is_volatile = 1,
.flags = V4L2_CTRL_FLAG_VOLATILE,
},
};

Expand Down Expand Up @@ -1020,7 +1020,7 @@ int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx)
return ctx->ctrl_handler.error;
}
if (controls[i].is_volatile && ctx->ctrls[i])
ctx->ctrls[i]->is_volatile = 1;
ctx->ctrls[i]->flags |= V4L2_CTRL_FLAG_VOLATILE;
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/s5p-mfc/s5p_mfc_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)
return ctx->ctrl_handler.error;
}
if (controls[i].is_volatile && ctx->ctrls[i])
ctx->ctrls[i]->is_volatile = 1;
ctx->ctrls[i]->flags |= V4L2_CTRL_FLAG_VOLATILE;
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/saa7115.c
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ static int saa711x_probe(struct i2c_client *client,
V4L2_CID_CHROMA_AGC, 0, 1, 1, 1);
state->gain = v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops,
V4L2_CID_CHROMA_GAIN, 0, 127, 1, 40);
state->gain->is_volatile = 1;
state->gain->flags |= V4L2_CTRL_FLAG_VOLATILE;
sd->ctrl_handler = hdl;
if (hdl->error) {
int err = hdl->error;
Expand Down
36 changes: 17 additions & 19 deletions drivers/media/video/v4l2-ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct v4l2_ctrl_helper {
};

/* Small helper function to determine if the autocluster is set to manual
mode. In that case the is_volatile flag should be ignored. */
mode. */
static bool is_cur_manual(const struct v4l2_ctrl *master)
{
return master->is_auto && master->cur.val == master->manual_mode_value;
Expand Down Expand Up @@ -1394,10 +1394,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
type, min, max,
is_menu ? cfg->menu_skip_mask : step,
def, flags, qmenu, priv);
if (ctrl) {
if (ctrl)
ctrl->is_private = cfg->is_private;
ctrl->is_volatile = cfg->is_volatile;
}
return ctrl;
}
EXPORT_SYMBOL(v4l2_ctrl_new_custom);
Expand Down Expand Up @@ -1519,12 +1517,12 @@ void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
master->manual_mode_value = manual_val;
master->flags |= V4L2_CTRL_FLAG_UPDATE;
flag = is_cur_manual(master) ? 0 : V4L2_CTRL_FLAG_INACTIVE;
if (set_volatile)
flag |= V4L2_CTRL_FLAG_VOLATILE;

for (i = 1; i < ncontrols; i++)
if (controls[i]) {
controls[i]->is_volatile = set_volatile;
if (controls[i])
controls[i]->flags |= flag;
}
}
EXPORT_SYMBOL(v4l2_ctrl_auto_cluster);

Expand Down Expand Up @@ -1579,9 +1577,6 @@ EXPORT_SYMBOL(v4l2_ctrl_grab);
static void log_ctrl(const struct v4l2_ctrl *ctrl,
const char *prefix, const char *colon)
{
int fl_inact = ctrl->flags & V4L2_CTRL_FLAG_INACTIVE;
int fl_grabbed = ctrl->flags & V4L2_CTRL_FLAG_GRABBED;

if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY))
return;
if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
Expand Down Expand Up @@ -1612,14 +1607,17 @@ static void log_ctrl(const struct v4l2_ctrl *ctrl,
printk(KERN_CONT "unknown type %d", ctrl->type);
break;
}
if (fl_inact && fl_grabbed)
printk(KERN_CONT " (inactive, grabbed)\n");
else if (fl_inact)
printk(KERN_CONT " (inactive)\n");
else if (fl_grabbed)
printk(KERN_CONT " (grabbed)\n");
else
printk(KERN_CONT "\n");
if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE |
V4L2_CTRL_FLAG_GRABBED |
V4L2_CTRL_FLAG_VOLATILE)) {
if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
printk(KERN_CONT " inactive");
if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)
printk(KERN_CONT " grabbed");
if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE)
printk(KERN_CONT " volatile");
}
printk(KERN_CONT "\n");
}

/* Log all controls owned by the handler */
Expand Down Expand Up @@ -2004,7 +2002,7 @@ static int get_ctrl(struct v4l2_ctrl *ctrl, s32 *val)

v4l2_ctrl_lock(master);
/* g_volatile_ctrl will update the current control values */
if (ctrl->is_volatile && !is_cur_manual(master)) {
if ((ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) && !is_cur_manual(master)) {
for (i = 0; i < master->ncontrols; i++)
cur_to_new(master->cluster[i]);
ret = call_op(master, g_volatile_ctrl);
Expand Down
12 changes: 1 addition & 11 deletions include/media/v4l2-ctrls.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ struct v4l2_ctrl_ops {
* @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.
* @is_volatile: If set, then this control is volatile. This means that the
* control's current value cannot be cached and needs to be
* retrieved through the g_volatile_ctrl op. Drivers can set
* this flag.
* @is_auto: If set, then this control selects whether the other cluster
* members are in 'automatic' mode or 'manual' mode. This is
* used for autogain/gain type clusters. Drivers should never
Expand Down Expand Up @@ -118,7 +114,6 @@ struct v4l2_ctrl {

unsigned int is_new:1;
unsigned int is_private:1;
unsigned int is_volatile:1;
unsigned int is_auto:1;
unsigned int manual_mode_value:8;

Expand Down Expand Up @@ -208,9 +203,6 @@ struct v4l2_ctrl_handler {
* must be NULL.
* @is_private: If set, then this control is private to its handler and it
* will not be added to any other handlers.
* @is_volatile: If set, then this control is volatile. This means that the
* control's current value cannot be cached and needs to be
* retrieved through the g_volatile_ctrl op.
*/
struct v4l2_ctrl_config {
const struct v4l2_ctrl_ops *ops;
Expand All @@ -225,7 +217,6 @@ struct v4l2_ctrl_config {
u32 menu_skip_mask;
const char * const *qmenu;
unsigned int is_private:1;
unsigned int is_volatile:1;
};

/** v4l2_ctrl_fill() - Fill in the control fields based on the control ID.
Expand Down Expand Up @@ -389,8 +380,7 @@ void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
* @manual_val: The value for the first control in the cluster that equals the
* manual setting.
* @set_volatile: If true, then all controls except the first auto control will
* have is_volatile set to true. If false, then is_volatile will not
* be touched.
* be volatile.
*
* Use for control groups where one control selects some automatic feature and
* the other controls are only active whenever the automatic feature is turned
Expand Down

0 comments on commit 8836510

Please sign in to comment.