]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - include/media/v4l2-ctrls.h
device.h: audit and cleanup users in main include dir
[linux-2.6.git] / include / media / v4l2-ctrls.h
index 9b7bea928a8843258877d2d4aebabb59228f6dcc..62e04dda22f22e3ef43132685bcd274f7615732b 100644 (file)
 #define _V4L2_CTRLS_H
 
 #include <linux/list.h>
-#include <linux/device.h>
+#include <linux/videodev2.h>
 
 /* forward references */
 struct v4l2_ctrl_handler;
+struct v4l2_ctrl_helper;
 struct v4l2_ctrl;
 struct video_device;
 struct v4l2_subdev;
+struct v4l2_subscribed_event;
+struct v4l2_fh;
 
 /** struct v4l2_ctrl_ops - The control operations that the driver has to provide.
   * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
@@ -50,18 +53,28 @@ struct v4l2_ctrl_ops {
 
 /** struct v4l2_ctrl - The control structure.
   * @node:     The list node.
+  * @ev_subs:  The list of control event subscriptions.
   * @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.
-  * @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
+  *            set this flag directly.
+  * @has_volatiles: If set, then one or more members of the cluster are volatile.
+  *            Drivers should never touch this flag.
+  * @manual_mode_value: If the is_auto flag is set, then this is the value
+  *            of the auto control that determines if that control is in
+  *            manual mode. So if the value of the auto control equals this
+  *            value, then the whole cluster is in manual mode. Drivers should
+  *            never set this flag directly.
   * @ops:      The control ops.
   * @id:       The control ID.
   * @name:     The control name.
@@ -94,14 +107,17 @@ struct v4l2_ctrl_ops {
 struct v4l2_ctrl {
        /* Administrative fields */
        struct list_head node;
+       struct list_head ev_subs;
        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;
+       unsigned int is_auto:1;
+       unsigned int has_volatiles:1;
+       unsigned int manual_mode_value:8;
 
        const struct v4l2_ctrl_ops *ops;
        u32 id;
@@ -112,7 +128,7 @@ struct v4l2_ctrl {
                u32 step;
                u32 menu_skip_mask;
        };
-       const char **qmenu;
+       const char * const *qmenu;
        unsigned long flags;
        union {
                s32 val;
@@ -131,6 +147,7 @@ struct v4l2_ctrl {
   * @node:     List node for the sorted list.
   * @next:     Single-link list node for the hash.
   * @ctrl:     The actual control information.
+  * @helper:   Pointer to helper struct. Used internally in prepare_ext_ctrls().
   *
   * Each control handler has a list of these refs. The list_head is used to
   * keep a sorted-by-control-ID list of all controls, while the next pointer
@@ -140,6 +157,7 @@ struct v4l2_ctrl_ref {
        struct list_head node;
        struct v4l2_ctrl_ref *next;
        struct v4l2_ctrl *ctrl;
+       struct v4l2_ctrl_helper *helper;
 };
 
 /** struct v4l2_ctrl_handler - The control handler keeps track of all the
@@ -187,9 +205,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;
@@ -202,9 +217,8 @@ struct v4l2_ctrl_config {
        s32 def;
        u32 flags;
        u32 menu_skip_mask;
-       const char **qmenu;
+       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.
@@ -360,6 +374,39 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
 void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
 
 
+/** v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to
+  * that cluster and set it up for autofoo/foo-type handling.
+  * @ncontrols:        The number of controls in this cluster.
+  * @controls: The cluster control array of size @ncontrols. The first control
+  *            must be the 'auto' control (e.g. autogain, autoexposure, etc.)
+  * @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
+  *            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
+  * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
+  * red and blue balance, etc.
+  *
+  * The behavior of such controls is as follows:
+  *
+  * When the autofoo control is set to automatic, then any manual controls
+  * are set to inactive and any reads will call g_volatile_ctrl (if the control
+  * was marked volatile).
+  *
+  * When the autofoo control is set to manual, then any manual controls will
+  * be marked active, and any reads will just return the current value without
+  * going through g_volatile_ctrl.
+  *
+  * In addition, this function will set the V4L2_CTRL_FLAG_UPDATE flag
+  * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
+  * if autofoo is in auto mode.
+  */
+void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
+                       u8 manual_val, bool set_volatile);
+
+
 /** v4l2_ctrl_find() - Find a control with the given ID.
   * @hdl:      The control handler.
   * @id:       The control ID to find.
@@ -376,9 +423,9 @@ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
   * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
   * Does nothing if @ctrl == NULL.
   * This will usually be called from within the s_ctrl op.
+  * The V4L2_EVENT_CTRL event will be generated afterwards.
   *
-  * This function can be called regardless of whether the control handler
-  * is locked or not.
+  * This function assumes that the control handler is locked.
   */
 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
 
@@ -388,11 +435,12 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
   *
   * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
   * Does nothing if @ctrl == NULL.
+  * The V4L2_EVENT_CTRL event will be generated afterwards.
   * This will usually be called when starting or stopping streaming in the
   * driver.
   *
-  * This function can be called regardless of whether the control handler
-  * is locked or not.
+  * This function assumes that the control handler is not locked and will
+  * take the lock itself.
   */
 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
 
@@ -437,15 +485,22 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
   */
 int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
 
+/* Internal helper functions that deal with control events. */
+void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl,
+               struct v4l2_subscribed_event *sev);
+void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
+               struct v4l2_subscribed_event *sev);
 
 /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
 int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
-int v4l2_s_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
+int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
+                                               struct v4l2_control *ctrl);
 int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
-int v4l2_s_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
+int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
+                                               struct v4l2_ext_controls *c);
 
 /* Helpers for subdevices. If the associated ctrl_handler == NULL then they
    will all return -EINVAL. */