Linux 3.12.5
[linux/fpc-iii.git] / include / media / v4l2-ctrls.h
blob47ada23345a195973c3942681566244d50c7f34d
1 /*
2 V4L2 controls support header.
4 Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _V4L2_CTRLS_H
22 #define _V4L2_CTRLS_H
24 #include <linux/list.h>
25 #include <linux/mutex.h>
26 #include <linux/videodev2.h>
28 /* forward references */
29 struct file;
30 struct v4l2_ctrl_handler;
31 struct v4l2_ctrl_helper;
32 struct v4l2_ctrl;
33 struct video_device;
34 struct v4l2_subdev;
35 struct v4l2_subscribed_event;
36 struct v4l2_fh;
37 struct poll_table_struct;
39 /** struct v4l2_ctrl_ops - The control operations that the driver has to provide.
40 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
41 * for volatile (and usually read-only) controls such as a control
42 * that returns the current signal strength which changes
43 * continuously.
44 * If not set, then the currently cached value will be returned.
45 * @try_ctrl: Test whether the control's value is valid. Only relevant when
46 * the usual min/max/step checks are not sufficient.
47 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
48 * ctrl->handler->lock is held when these ops are called, so no
49 * one else can access controls owned by that handler.
51 struct v4l2_ctrl_ops {
52 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
53 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
54 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
57 typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
59 /** struct v4l2_ctrl - The control structure.
60 * @node: The list node.
61 * @ev_subs: The list of control event subscriptions.
62 * @handler: The handler that owns the control.
63 * @cluster: Point to start of cluster array.
64 * @ncontrols: Number of controls in cluster array.
65 * @done: Internal flag: set for each processed control.
66 * @is_new: Set when the user specified a new value for this control. It
67 * is also set when called from v4l2_ctrl_handler_setup. Drivers
68 * should never set this flag.
69 * @is_private: If set, then this control is private to its handler and it
70 * will not be added to any other handlers. Drivers can set
71 * this flag.
72 * @is_auto: If set, then this control selects whether the other cluster
73 * members are in 'automatic' mode or 'manual' mode. This is
74 * used for autogain/gain type clusters. Drivers should never
75 * set this flag directly.
76 * @has_volatiles: If set, then one or more members of the cluster are volatile.
77 * Drivers should never touch this flag.
78 * @call_notify: If set, then call the handler's notify function whenever the
79 * control's value changes.
80 * @manual_mode_value: If the is_auto flag is set, then this is the value
81 * of the auto control that determines if that control is in
82 * manual mode. So if the value of the auto control equals this
83 * value, then the whole cluster is in manual mode. Drivers should
84 * never set this flag directly.
85 * @ops: The control ops.
86 * @id: The control ID.
87 * @name: The control name.
88 * @type: The control type.
89 * @minimum: The control's minimum value.
90 * @maximum: The control's maximum value.
91 * @default_value: The control's default value.
92 * @step: The control's step value for non-menu controls.
93 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
94 * easy to skip menu items that are not valid. If bit X is set,
95 * then menu item X is skipped. Of course, this only works for
96 * menus with <= 32 menu items. There are no menus that come
97 * close to that number, so this is OK. Should we ever need more,
98 * then this will have to be extended to a u64 or a bit array.
99 * @qmenu: A const char * array for all menu items. Array entries that are
100 * empty strings ("") correspond to non-existing menu items (this
101 * is in addition to the menu_skip_mask above). The last entry
102 * must be NULL.
103 * @flags: The control's flags.
104 * @cur: The control's current value.
105 * @val: The control's new s32 value.
106 * @val64: The control's new s64 value.
107 * @string: The control's new string value.
108 * @priv: The control's private pointer. For use by the driver. It is
109 * untouched by the control framework. Note that this pointer is
110 * not freed when the control is deleted. Should this be needed
111 * then a new internal bitfield can be added to tell the framework
112 * to free this pointer.
114 struct v4l2_ctrl {
115 /* Administrative fields */
116 struct list_head node;
117 struct list_head ev_subs;
118 struct v4l2_ctrl_handler *handler;
119 struct v4l2_ctrl **cluster;
120 unsigned ncontrols;
121 unsigned int done:1;
123 unsigned int is_new:1;
124 unsigned int is_private:1;
125 unsigned int is_auto:1;
126 unsigned int has_volatiles:1;
127 unsigned int call_notify:1;
128 unsigned int manual_mode_value:8;
130 const struct v4l2_ctrl_ops *ops;
131 u32 id;
132 const char *name;
133 enum v4l2_ctrl_type type;
134 s32 minimum, maximum, default_value;
135 union {
136 u32 step;
137 u32 menu_skip_mask;
139 union {
140 const char * const *qmenu;
141 const s64 *qmenu_int;
143 unsigned long flags;
144 union {
145 s32 val;
146 s64 val64;
147 char *string;
148 } cur;
149 union {
150 s32 val;
151 s64 val64;
152 char *string;
154 void *priv;
157 /** struct v4l2_ctrl_ref - The control reference.
158 * @node: List node for the sorted list.
159 * @next: Single-link list node for the hash.
160 * @ctrl: The actual control information.
161 * @helper: Pointer to helper struct. Used internally in prepare_ext_ctrls().
163 * Each control handler has a list of these refs. The list_head is used to
164 * keep a sorted-by-control-ID list of all controls, while the next pointer
165 * is used to link the control in the hash's bucket.
167 struct v4l2_ctrl_ref {
168 struct list_head node;
169 struct v4l2_ctrl_ref *next;
170 struct v4l2_ctrl *ctrl;
171 struct v4l2_ctrl_helper *helper;
174 /** struct v4l2_ctrl_handler - The control handler keeps track of all the
175 * controls: both the controls owned by the handler and those inherited
176 * from other handlers.
177 * @_lock: Default for "lock".
178 * @lock: Lock to control access to this handler and its controls.
179 * May be replaced by the user right after init.
180 * @ctrls: The list of controls owned by this handler.
181 * @ctrl_refs: The list of control references.
182 * @cached: The last found control reference. It is common that the same
183 * control is needed multiple times, so this is a simple
184 * optimization.
185 * @buckets: Buckets for the hashing. Allows for quick control lookup.
186 * @notify: A notify callback that is called whenever the control changes value.
187 * Note that the handler's lock is held when the notify function
188 * is called!
189 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
190 * @nr_of_buckets: Total number of buckets in the array.
191 * @error: The error code of the first failed control addition.
193 struct v4l2_ctrl_handler {
194 struct mutex _lock;
195 struct mutex *lock;
196 struct list_head ctrls;
197 struct list_head ctrl_refs;
198 struct v4l2_ctrl_ref *cached;
199 struct v4l2_ctrl_ref **buckets;
200 v4l2_ctrl_notify_fnc notify;
201 void *notify_priv;
202 u16 nr_of_buckets;
203 int error;
206 /** struct v4l2_ctrl_config - Control configuration structure.
207 * @ops: The control ops.
208 * @id: The control ID.
209 * @name: The control name.
210 * @type: The control type.
211 * @min: The control's minimum value.
212 * @max: The control's maximum value.
213 * @step: The control's step value for non-menu controls.
214 * @def: The control's default value.
215 * @flags: The control's flags.
216 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
217 * easy to skip menu items that are not valid. If bit X is set,
218 * then menu item X is skipped. Of course, this only works for
219 * menus with <= 32 menu items. There are no menus that come
220 * close to that number, so this is OK. Should we ever need more,
221 * then this will have to be extended to a u64 or a bit array.
222 * @qmenu: A const char * array for all menu items. Array entries that are
223 * empty strings ("") correspond to non-existing menu items (this
224 * is in addition to the menu_skip_mask above). The last entry
225 * must be NULL.
226 * @is_private: If set, then this control is private to its handler and it
227 * will not be added to any other handlers.
229 struct v4l2_ctrl_config {
230 const struct v4l2_ctrl_ops *ops;
231 u32 id;
232 const char *name;
233 enum v4l2_ctrl_type type;
234 s32 min;
235 s32 max;
236 u32 step;
237 s32 def;
238 u32 flags;
239 u32 menu_skip_mask;
240 const char * const *qmenu;
241 const s64 *qmenu_int;
242 unsigned int is_private:1;
245 /** v4l2_ctrl_fill() - Fill in the control fields based on the control ID.
247 * This works for all standard V4L2 controls.
248 * For non-standard controls it will only fill in the given arguments
249 * and @name will be NULL.
251 * This function will overwrite the contents of @name, @type and @flags.
252 * The contents of @min, @max, @step and @def may be modified depending on
253 * the type.
255 * Do not use in drivers! It is used internally for backwards compatibility
256 * control handling only. Once all drivers are converted to use the new
257 * control framework this function will no longer be exported.
259 void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
260 s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags);
263 /** v4l2_ctrl_handler_init_class() - Initialize the control handler.
264 * @hdl: The control handler.
265 * @nr_of_controls_hint: A hint of how many controls this handler is
266 * expected to refer to. This is the total number, so including
267 * any inherited controls. It doesn't have to be precise, but if
268 * it is way off, then you either waste memory (too many buckets
269 * are allocated) or the control lookup becomes slower (not enough
270 * buckets are allocated, so there are more slow list lookups).
271 * It will always work, though.
272 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
273 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
275 * Returns an error if the buckets could not be allocated. This error will
276 * also be stored in @hdl->error.
278 * Never use this call directly, always use the v4l2_ctrl_handler_init
279 * macro that hides the @key and @name arguments.
281 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
282 unsigned nr_of_controls_hint,
283 struct lock_class_key *key, const char *name);
285 #ifdef CONFIG_LOCKDEP
286 #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
288 ({ \
289 static struct lock_class_key _key; \
290 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
291 &_key, \
292 KBUILD_BASENAME ":" \
293 __stringify(__LINE__) ":" \
294 "(" #hdl ")->_lock"); \
295 }) \
297 #else
298 #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
299 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
300 #endif
302 /** v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
303 * the control list.
304 * @hdl: The control handler.
306 * Does nothing if @hdl == NULL.
308 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
310 /** v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
311 * to the handler to initialize the hardware to the current control values.
312 * @hdl: The control handler.
314 * Button controls will be skipped, as are read-only controls.
316 * If @hdl == NULL, then this just returns 0.
318 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
320 /** v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
321 * @hdl: The control handler.
322 * @prefix: The prefix to use when logging the control values. If the
323 * prefix does not end with a space, then ": " will be added
324 * after the prefix. If @prefix == NULL, then no prefix will be
325 * used.
327 * For use with VIDIOC_LOG_STATUS.
329 * Does nothing if @hdl == NULL.
331 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
332 const char *prefix);
334 /** v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
335 * control.
336 * @hdl: The control handler.
337 * @cfg: The control's configuration data.
338 * @priv: The control's driver-specific private data.
340 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
341 * and @hdl->error is set to the error code (if it wasn't set already).
343 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
344 const struct v4l2_ctrl_config *cfg, void *priv);
346 /** v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu control.
347 * @hdl: The control handler.
348 * @ops: The control ops.
349 * @id: The control ID.
350 * @min: The control's minimum value.
351 * @max: The control's maximum value.
352 * @step: The control's step value
353 * @def: The control's default value.
355 * If the &v4l2_ctrl struct could not be allocated, or the control
356 * ID is not known, then NULL is returned and @hdl->error is set to the
357 * appropriate error code (if it wasn't set already).
359 * If @id refers to a menu control, then this function will return NULL.
361 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
363 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
364 const struct v4l2_ctrl_ops *ops,
365 u32 id, s32 min, s32 max, u32 step, s32 def);
367 /** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control.
368 * @hdl: The control handler.
369 * @ops: The control ops.
370 * @id: The control ID.
371 * @max: The control's maximum value.
372 * @mask: The control's skip mask for menu controls. This makes it
373 * easy to skip menu items that are not valid. If bit X is set,
374 * then menu item X is skipped. Of course, this only works for
375 * menus with <= 32 menu items. There are no menus that come
376 * close to that number, so this is OK. Should we ever need more,
377 * then this will have to be extended to a u64 or a bit array.
378 * @def: The control's default value.
380 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
381 * determines which menu items are to be skipped.
383 * If @id refers to a non-menu control, then this function will return NULL.
385 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
386 const struct v4l2_ctrl_ops *ops,
387 u32 id, s32 max, s32 mask, s32 def);
389 /** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
390 * with driver specific menu.
391 * @hdl: The control handler.
392 * @ops: The control ops.
393 * @id: The control ID.
394 * @max: The control's maximum value.
395 * @mask: The control's skip mask for menu controls. This makes it
396 * easy to skip menu items that are not valid. If bit X is set,
397 * then menu item X is skipped. Of course, this only works for
398 * menus with <= 32 menu items. There are no menus that come
399 * close to that number, so this is OK. Should we ever need more,
400 * then this will have to be extended to a u64 or a bit array.
401 * @def: The control's default value.
402 * @qmenu: The new menu.
404 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
405 * menu of this control.
408 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
409 const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
410 s32 mask, s32 def, const char * const *qmenu);
412 /** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
413 * @hdl: The control handler.
414 * @ops: The control ops.
415 * @id: The control ID.
416 * @max: The control's maximum value.
417 * @def: The control's default value.
418 * @qmenu_int: The control's menu entries.
420 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
421 * takes as an argument an array of integers determining the menu items.
423 * If @id refers to a non-integer-menu control, then this function will return NULL.
425 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
426 const struct v4l2_ctrl_ops *ops,
427 u32 id, s32 max, s32 def, const s64 *qmenu_int);
429 /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
430 * @hdl: The control handler.
431 * @ctrl: The control to add.
433 * It will return NULL if it was unable to add the control reference.
434 * If the control already belonged to the handler, then it will do
435 * nothing and just return @ctrl.
437 struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
438 struct v4l2_ctrl *ctrl);
440 /** v4l2_ctrl_add_handler() - Add all controls from handler @add to
441 * handler @hdl.
442 * @hdl: The control handler.
443 * @add: The control handler whose controls you want to add to
444 * the @hdl control handler.
445 * @filter: This function will filter which controls should be added.
447 * Does nothing if either of the two handlers is a NULL pointer.
448 * If @filter is NULL, then all controls are added. Otherwise only those
449 * controls for which @filter returns true will be added.
450 * In case of an error @hdl->error will be set to the error code (if it
451 * wasn't set already).
453 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
454 struct v4l2_ctrl_handler *add,
455 bool (*filter)(const struct v4l2_ctrl *ctrl));
457 /** v4l2_ctrl_radio_filter() - Standard filter for radio controls.
458 * @ctrl: The control that is filtered.
460 * This will return true for any controls that are valid for radio device
461 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
462 * transmitter class controls.
464 * This function is to be used with v4l2_ctrl_add_handler().
466 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
468 /** v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster.
469 * @ncontrols: The number of controls in this cluster.
470 * @controls: The cluster control array of size @ncontrols.
472 void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
475 /** v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to
476 * that cluster and set it up for autofoo/foo-type handling.
477 * @ncontrols: The number of controls in this cluster.
478 * @controls: The cluster control array of size @ncontrols. The first control
479 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
480 * @manual_val: The value for the first control in the cluster that equals the
481 * manual setting.
482 * @set_volatile: If true, then all controls except the first auto control will
483 * be volatile.
485 * Use for control groups where one control selects some automatic feature and
486 * the other controls are only active whenever the automatic feature is turned
487 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
488 * red and blue balance, etc.
490 * The behavior of such controls is as follows:
492 * When the autofoo control is set to automatic, then any manual controls
493 * are set to inactive and any reads will call g_volatile_ctrl (if the control
494 * was marked volatile).
496 * When the autofoo control is set to manual, then any manual controls will
497 * be marked active, and any reads will just return the current value without
498 * going through g_volatile_ctrl.
500 * In addition, this function will set the V4L2_CTRL_FLAG_UPDATE flag
501 * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
502 * if autofoo is in auto mode.
504 void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
505 u8 manual_val, bool set_volatile);
508 /** v4l2_ctrl_find() - Find a control with the given ID.
509 * @hdl: The control handler.
510 * @id: The control ID to find.
512 * If @hdl == NULL this will return NULL as well. Will lock the handler so
513 * do not use from inside &v4l2_ctrl_ops.
515 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
517 /** v4l2_ctrl_activate() - Make the control active or inactive.
518 * @ctrl: The control to (de)activate.
519 * @active: True if the control should become active.
521 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
522 * Does nothing if @ctrl == NULL.
523 * This will usually be called from within the s_ctrl op.
524 * The V4L2_EVENT_CTRL event will be generated afterwards.
526 * This function assumes that the control handler is locked.
528 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
530 /** v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
531 * @ctrl: The control to (de)activate.
532 * @grabbed: True if the control should become grabbed.
534 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
535 * Does nothing if @ctrl == NULL.
536 * The V4L2_EVENT_CTRL event will be generated afterwards.
537 * This will usually be called when starting or stopping streaming in the
538 * driver.
540 * This function assumes that the control handler is not locked and will
541 * take the lock itself.
543 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
545 /** v4l2_ctrl_modify_range() - Update the range of a control.
546 * @ctrl: The control to update.
547 * @min: The control's minimum value.
548 * @max: The control's maximum value.
549 * @step: The control's step value
550 * @def: The control's default value.
552 * Update the range of a control on the fly. This works for control types
553 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
554 * @step value is interpreted as a menu_skip_mask.
556 * An error is returned if one of the range arguments is invalid for this
557 * control type.
559 * This function assumes that the control handler is not locked and will
560 * take the lock itself.
562 int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
563 s32 min, s32 max, u32 step, s32 def);
565 /** v4l2_ctrl_lock() - Helper function to lock the handler
566 * associated with the control.
567 * @ctrl: The control to lock.
569 static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
571 mutex_lock(ctrl->handler->lock);
574 /** v4l2_ctrl_lock() - Helper function to unlock the handler
575 * associated with the control.
576 * @ctrl: The control to unlock.
578 static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
580 mutex_unlock(ctrl->handler->lock);
583 /** v4l2_ctrl_notify() - Function to set a notify callback for a control.
584 * @ctrl: The control.
585 * @notify: The callback function.
586 * @priv: The callback private handle, passed as argument to the callback.
588 * This function sets a callback function for the control. If @ctrl is NULL,
589 * then it will do nothing. If @notify is NULL, then the notify callback will
590 * be removed.
592 * There can be only one notify. If another already exists, then a WARN_ON
593 * will be issued and the function will do nothing.
595 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv);
597 /** v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver.
598 * @ctrl: The control.
600 * This returns the control's value safely by going through the control
601 * framework. This function will lock the control's handler, so it cannot be
602 * used from within the &v4l2_ctrl_ops functions.
604 * This function is for integer type controls only.
606 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
608 /** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver.
609 * @ctrl: The control.
610 * @val: The new value.
612 * This set the control's new value safely by going through the control
613 * framework. This function will lock the control's handler, so it cannot be
614 * used from within the &v4l2_ctrl_ops functions.
616 * This function is for integer type controls only.
618 int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
620 /** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver.
621 * @ctrl: The control.
623 * This returns the control's value safely by going through the control
624 * framework. This function will lock the control's handler, so it cannot be
625 * used from within the &v4l2_ctrl_ops functions.
627 * This function is for 64-bit integer type controls only.
629 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
631 /** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver.
632 * @ctrl: The control.
633 * @val: The new value.
635 * This set the control's new value safely by going through the control
636 * framework. This function will lock the control's handler, so it cannot be
637 * used from within the &v4l2_ctrl_ops functions.
639 * This function is for 64-bit integer type controls only.
641 int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
643 /* Internal helper functions that deal with control events. */
644 extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
645 void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
646 void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
648 /* Can be used as a vidioc_log_status function that just dumps all controls
649 associated with the filehandle. */
650 int v4l2_ctrl_log_status(struct file *file, void *fh);
652 /* Can be used as a vidioc_subscribe_event function that just subscribes
653 control events. */
654 int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
655 const struct v4l2_event_subscription *sub);
657 /* Can be used as a poll function that just polls for control events. */
658 unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
660 /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
661 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
662 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
663 int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
664 int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
665 struct v4l2_control *ctrl);
666 int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
667 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
668 int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
669 struct v4l2_ext_controls *c);
671 /* Helpers for subdevices. If the associated ctrl_handler == NULL then they
672 will all return -EINVAL. */
673 int v4l2_subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
674 int v4l2_subdev_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
675 int v4l2_subdev_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
676 int v4l2_subdev_try_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
677 int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
678 int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
679 int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
681 /* Can be used as a subscribe_event function that just subscribes control
682 events. */
683 int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
684 struct v4l2_event_subscription *sub);
686 /* Log all controls owned by subdev's control handler. */
687 int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
689 #endif