aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-06-10 04:44:36 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:18 -0400
commit72d877cac07c8d996918977c3162dd78b8097ca8 (patch)
tree03b03db2d5c44c6cca946cb7f24d61a1c15cce24 /include/media
parent78866efe8ae2862fef7ff37af36c6972651c2d0b (diff)
[media] v4l2-ctrls: add v4l2_ctrl_auto_cluster to simplify autogain/gain scenarios
It is a bit tricky to handle autogain/gain type scenerios correctly. Such controls need to be clustered and the V4L2_CTRL_FLAG_UPDATE should be set on the autofoo controls. In addition, the manual controls should be marked inactive when the automatic mode is on, and active when the manual mode is on. This also requires specialized volatile handling. The chances of drivers doing all these things correctly are pretty remote. So a new v4l2_ctrl_auto_cluster function was added that takes care of these issues. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/v4l2-ctrls.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 97d063837b61..56323e341e02 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -65,6 +65,15 @@ struct v4l2_ctrl_ops {
65 * control's current value cannot be cached and needs to be 65 * control's current value cannot be cached and needs to be
66 * retrieved through the g_volatile_ctrl op. Drivers can set 66 * retrieved through the g_volatile_ctrl op. Drivers can set
67 * this flag. 67 * this flag.
68 * @is_auto: If set, then this control selects whether the other cluster
69 * members are in 'automatic' mode or 'manual' mode. This is
70 * used for autogain/gain type clusters. Drivers should never
71 * set this flag directly.
72 * @manual_mode_value: If the is_auto flag is set, then this is the value
73 * of the auto control that determines if that control is in
74 * manual mode. So if the value of the auto control equals this
75 * value, then the whole cluster is in manual mode. Drivers should
76 * never set this flag directly.
68 * @ops: The control ops. 77 * @ops: The control ops.
69 * @id: The control ID. 78 * @id: The control ID.
70 * @name: The control name. 79 * @name: The control name.
@@ -105,6 +114,8 @@ struct v4l2_ctrl {
105 unsigned int is_new:1; 114 unsigned int is_new:1;
106 unsigned int is_private:1; 115 unsigned int is_private:1;
107 unsigned int is_volatile:1; 116 unsigned int is_volatile:1;
117 unsigned int is_auto:1;
118 unsigned int manual_mode_value:5;
108 119
109 const struct v4l2_ctrl_ops *ops; 120 const struct v4l2_ctrl_ops *ops;
110 u32 id; 121 u32 id;
@@ -363,6 +374,40 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
363void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls); 374void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
364 375
365 376
377/** v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to
378 * that cluster and set it up for autofoo/foo-type handling.
379 * @ncontrols: The number of controls in this cluster.
380 * @controls: The cluster control array of size @ncontrols. The first control
381 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
382 * @manual_val: The value for the first control in the cluster that equals the
383 * manual setting.
384 * @set_volatile: If true, then all controls except the first auto control will
385 * have is_volatile set to true. If false, then is_volatile will not
386 * be touched.
387 *
388 * Use for control groups where one control selects some automatic feature and
389 * the other controls are only active whenever the automatic feature is turned
390 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
391 * red and blue balance, etc.
392 *
393 * The behavior of such controls is as follows:
394 *
395 * When the autofoo control is set to automatic, then any manual controls
396 * are set to inactive and any reads will call g_volatile_ctrl (if the control
397 * was marked volatile).
398 *
399 * When the autofoo control is set to manual, then any manual controls will
400 * be marked active, and any reads will just return the current value without
401 * going through g_volatile_ctrl.
402 *
403 * In addition, this function will set the V4L2_CTRL_FLAG_UPDATE flag
404 * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
405 * if autofoo is in auto mode.
406 */
407void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
408 u8 manual_val, bool set_volatile);
409
410
366/** v4l2_ctrl_find() - Find a control with the given ID. 411/** v4l2_ctrl_find() - Find a control with the given ID.
367 * @hdl: The control handler. 412 * @hdl: The control handler.
368 * @id: The control ID to find. 413 * @id: The control ID to find.