aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-ctrls.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-ctrls.h')
-rw-r--r--include/media/v4l2-ctrls.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 96509119f28f..f00d42bc01a6 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -53,6 +53,8 @@ struct v4l2_ctrl_ops {
53 int (*s_ctrl)(struct v4l2_ctrl *ctrl); 53 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
54}; 54};
55 55
56typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
57
56/** struct v4l2_ctrl - The control structure. 58/** struct v4l2_ctrl - The control structure.
57 * @node: The list node. 59 * @node: The list node.
58 * @ev_subs: The list of control event subscriptions. 60 * @ev_subs: The list of control event subscriptions.
@@ -72,6 +74,8 @@ struct v4l2_ctrl_ops {
72 * set this flag directly. 74 * set this flag directly.
73 * @has_volatiles: If set, then one or more members of the cluster are volatile. 75 * @has_volatiles: If set, then one or more members of the cluster are volatile.
74 * Drivers should never touch this flag. 76 * Drivers should never touch this flag.
77 * @call_notify: If set, then call the handler's notify function whenever the
78 * control's value changes.
75 * @manual_mode_value: If the is_auto flag is set, then this is the value 79 * @manual_mode_value: If the is_auto flag is set, then this is the value
76 * of the auto control that determines if that control is in 80 * of the auto control that determines if that control is in
77 * manual mode. So if the value of the auto control equals this 81 * manual mode. So if the value of the auto control equals this
@@ -119,6 +123,7 @@ struct v4l2_ctrl {
119 unsigned int is_private:1; 123 unsigned int is_private:1;
120 unsigned int is_auto:1; 124 unsigned int is_auto:1;
121 unsigned int has_volatiles:1; 125 unsigned int has_volatiles:1;
126 unsigned int call_notify:1;
122 unsigned int manual_mode_value:8; 127 unsigned int manual_mode_value:8;
123 128
124 const struct v4l2_ctrl_ops *ops; 129 const struct v4l2_ctrl_ops *ops;
@@ -177,6 +182,10 @@ struct v4l2_ctrl_ref {
177 * control is needed multiple times, so this is a simple 182 * control is needed multiple times, so this is a simple
178 * optimization. 183 * optimization.
179 * @buckets: Buckets for the hashing. Allows for quick control lookup. 184 * @buckets: Buckets for the hashing. Allows for quick control lookup.
185 * @notify: A notify callback that is called whenever the control changes value.
186 * Note that the handler's lock is held when the notify function
187 * is called!
188 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
180 * @nr_of_buckets: Total number of buckets in the array. 189 * @nr_of_buckets: Total number of buckets in the array.
181 * @error: The error code of the first failed control addition. 190 * @error: The error code of the first failed control addition.
182 */ 191 */
@@ -187,6 +196,8 @@ struct v4l2_ctrl_handler {
187 struct list_head ctrl_refs; 196 struct list_head ctrl_refs;
188 struct v4l2_ctrl_ref *cached; 197 struct v4l2_ctrl_ref *cached;
189 struct v4l2_ctrl_ref **buckets; 198 struct v4l2_ctrl_ref **buckets;
199 v4l2_ctrl_notify_fnc notify;
200 void *notify_priv;
190 u16 nr_of_buckets; 201 u16 nr_of_buckets;
191 int error; 202 int error;
192}; 203};
@@ -507,6 +518,26 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
507 */ 518 */
508void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); 519void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
509 520
521/** v4l2_ctrl_modify_range() - Update the range of a control.
522 * @ctrl: The control to update.
523 * @min: The control's minimum value.
524 * @max: The control's maximum value.
525 * @step: The control's step value
526 * @def: The control's default value.
527 *
528 * Update the range of a control on the fly. This works for control types
529 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
530 * @step value is interpreted as a menu_skip_mask.
531 *
532 * An error is returned if one of the range arguments is invalid for this
533 * control type.
534 *
535 * This function assumes that the control handler is not locked and will
536 * take the lock itself.
537 */
538int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
539 s32 min, s32 max, u32 step, s32 def);
540
510/** v4l2_ctrl_lock() - Helper function to lock the handler 541/** v4l2_ctrl_lock() - Helper function to lock the handler
511 * associated with the control. 542 * associated with the control.
512 * @ctrl: The control to lock. 543 * @ctrl: The control to lock.
@@ -525,6 +556,20 @@ static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
525 mutex_unlock(ctrl->handler->lock); 556 mutex_unlock(ctrl->handler->lock);
526} 557}
527 558
559/** v4l2_ctrl_notify() - Function to set a notify callback for a control.
560 * @ctrl: The control.
561 * @notify: The callback function.
562 * @priv: The callback private handle, passed as argument to the callback.
563 *
564 * This function sets a callback function for the control. If @ctrl is NULL,
565 * then it will do nothing. If @notify is NULL, then the notify callback will
566 * be removed.
567 *
568 * There can be only one notify. If another already exists, then a WARN_ON
569 * will be issued and the function will do nothing.
570 */
571void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv);
572
528/** v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver. 573/** v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver.
529 * @ctrl: The control. 574 * @ctrl: The control.
530 * 575 *
@@ -609,4 +654,12 @@ int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs
609int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 654int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
610int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 655int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
611 656
657/* Can be used as a subscribe_event function that just subscribes control
658 events. */
659int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
660 struct v4l2_event_subscription *sub);
661
662/* Log all controls owned by subdev's control handler. */
663int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
664
612#endif 665#endif