Merge remote-tracking branch 'regmap/for-next'
[deliverable/linux.git] / include / media / v4l2-ctrls.h
CommitLineData
0996517c 1/*
8ec4bee7
MCC
2 * V4L2 controls support header.
3 *
4 * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
5 *
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.
10 *
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.
0996517c
HV
15 */
16
17#ifndef _V4L2_CTRLS_H
18#define _V4L2_CTRLS_H
19
20#include <linux/list.h>
a19dec6e 21#include <linux/mutex.h>
01c40c04 22#include <linux/videodev2.h>
0996517c
HV
23
24/* forward references */
528f0f78 25struct file;
0996517c 26struct v4l2_ctrl_handler;
eb5b16ef 27struct v4l2_ctrl_helper;
0996517c
HV
28struct v4l2_ctrl;
29struct video_device;
30struct v4l2_subdev;
77068d36 31struct v4l2_subscribed_event;
6e239399 32struct v4l2_fh;
a26243b0 33struct poll_table_struct;
0996517c 34
8c2721d5
MCC
35/**
36 * union v4l2_ctrl_ptr - A pointer to a control value.
0176077a
HV
37 * @p_s32: Pointer to a 32-bit signed value.
38 * @p_s64: Pointer to a 64-bit signed value.
dda4a4d5
HV
39 * @p_u8: Pointer to a 8-bit unsigned value.
40 * @p_u16: Pointer to a 16-bit unsigned value.
811c5081 41 * @p_u32: Pointer to a 32-bit unsigned value.
0176077a
HV
42 * @p_char: Pointer to a string.
43 * @p: Pointer to a compound value.
44 */
45union v4l2_ctrl_ptr {
46 s32 *p_s32;
47 s64 *p_s64;
dda4a4d5
HV
48 u8 *p_u8;
49 u16 *p_u16;
811c5081 50 u32 *p_u32;
0176077a
HV
51 char *p_char;
52 void *p;
53};
54
8c2721d5
MCC
55/**
56 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
8ec4bee7 57 *
8c2721d5
MCC
58 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
59 * for volatile (and usually read-only) controls such as a control
60 * that returns the current signal strength which changes
61 * continuously.
62 * If not set, then the currently cached value will be returned.
63 * @try_ctrl: Test whether the control's value is valid. Only relevant when
64 * the usual min/max/step checks are not sufficient.
65 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
66 * ctrl->handler->lock is held when these ops are called, so no
67 * one else can access controls owned by that handler.
68 */
0996517c
HV
69struct v4l2_ctrl_ops {
70 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
71 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
72 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
73};
74
8c2721d5
MCC
75/**
76 * struct v4l2_ctrl_type_ops - The control type operations that the driver
8ec4bee7 77 * has to provide.
8c2721d5
MCC
78 *
79 * @equal: return true if both values are equal.
80 * @init: initialize the value.
81 * @log: log the value.
8ec4bee7
MCC
82 * @validate: validate the value. Return 0 on success and a negative value
83 * otherwise.
8c2721d5 84 */
0176077a 85struct v4l2_ctrl_type_ops {
998e7659 86 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a
HV
87 union v4l2_ctrl_ptr ptr1,
88 union v4l2_ctrl_ptr ptr2);
998e7659 89 void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a
HV
90 union v4l2_ctrl_ptr ptr);
91 void (*log)(const struct v4l2_ctrl *ctrl);
998e7659 92 int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a
HV
93 union v4l2_ctrl_ptr ptr);
94};
95
2257e180
MCC
96/**
97 * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
98 * that should be called when a control value has changed.
99 *
100 * @ctrl: pointer to struct &v4l2_ctrl
101 * @priv: control private data
102 *
103 * This typedef definition is used as an argument to v4l2_ctrl_notify()
104 * and as an argument at struct &v4l2_ctrl_handler.
105 */
8ac7a949
HV
106typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
107
8c2721d5
MCC
108/**
109 * struct v4l2_ctrl - The control structure.
8ec4bee7 110 *
8c2721d5
MCC
111 * @node: The list node.
112 * @ev_subs: The list of control event subscriptions.
113 * @handler: The handler that owns the control.
114 * @cluster: Point to start of cluster array.
115 * @ncontrols: Number of controls in cluster array.
116 * @done: Internal flag: set for each processed control.
117 * @is_new: Set when the user specified a new value for this control. It
8ec4bee7 118 * is also set when called from v4l2_ctrl_handler_setup(). Drivers
8c2721d5
MCC
119 * should never set this flag.
120 * @has_changed: Set when the current value differs from the new value. Drivers
121 * should never use this flag.
122 * @is_private: If set, then this control is private to its handler and it
123 * will not be added to any other handlers. Drivers can set
124 * this flag.
125 * @is_auto: If set, then this control selects whether the other cluster
126 * members are in 'automatic' mode or 'manual' mode. This is
127 * used for autogain/gain type clusters. Drivers should never
128 * set this flag directly.
129 * @is_int: If set, then this control has a simple integer value (i.e. it
130 * uses ctrl->val).
8ec4bee7
MCC
131 * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
132 * @is_ptr: If set, then this control is an array and/or has type >=
133 * %V4L2_CTRL_COMPOUND_TYPES
134 * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
8c2721d5
MCC
135 * v4l2_ext_control uses field p to point to the data.
136 * @is_array: If set, then this control contains an N-dimensional array.
137 * @has_volatiles: If set, then one or more members of the cluster are volatile.
138 * Drivers should never touch this flag.
139 * @call_notify: If set, then call the handler's notify function whenever the
140 * control's value changes.
141 * @manual_mode_value: If the is_auto flag is set, then this is the value
142 * of the auto control that determines if that control is in
143 * manual mode. So if the value of the auto control equals this
144 * value, then the whole cluster is in manual mode. Drivers should
145 * never set this flag directly.
146 * @ops: The control ops.
147 * @type_ops: The control type ops.
148 * @id: The control ID.
149 * @name: The control name.
150 * @type: The control type.
151 * @minimum: The control's minimum value.
152 * @maximum: The control's maximum value.
153 * @default_value: The control's default value.
154 * @step: The control's step value for non-menu controls.
155 * @elems: The number of elements in the N-dimensional array.
156 * @elem_size: The size in bytes of the control.
157 * @dims: The size of each dimension.
158 * @nr_of_dims:The number of dimensions in @dims.
159 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
160 * easy to skip menu items that are not valid. If bit X is set,
161 * then menu item X is skipped. Of course, this only works for
162 * menus with <= 32 menu items. There are no menus that come
163 * close to that number, so this is OK. Should we ever need more,
164 * then this will have to be extended to a u64 or a bit array.
165 * @qmenu: A const char * array for all menu items. Array entries that are
166 * empty strings ("") correspond to non-existing menu items (this
167 * is in addition to the menu_skip_mask above). The last entry
168 * must be NULL.
169 * @flags: The control's flags.
170 * @cur: The control's current value.
171 * @val: The control's new s32 value.
8c2721d5
MCC
172 * @priv: The control's private pointer. For use by the driver. It is
173 * untouched by the control framework. Note that this pointer is
174 * not freed when the control is deleted. Should this be needed
175 * then a new internal bitfield can be added to tell the framework
176 * to free this pointer.
7dc87919
MCC
177 * @p_cur: The control's current value represented via an union with
178 * provides a standard way of accessing control types
179 * through a pointer.
180 * @p_new: The control's new value represented via an union with provides
181 * a standard way of accessing control types
182 * through a pointer.
8c2721d5 183 */
0996517c
HV
184struct v4l2_ctrl {
185 /* Administrative fields */
186 struct list_head node;
77068d36 187 struct list_head ev_subs;
0996517c
HV
188 struct v4l2_ctrl_handler *handler;
189 struct v4l2_ctrl **cluster;
8ec4bee7
MCC
190 unsigned int ncontrols;
191
0996517c
HV
192 unsigned int done:1;
193
2a863793 194 unsigned int is_new:1;
9ea1b7a4 195 unsigned int has_changed:1;
0996517c 196 unsigned int is_private:1;
72d877ca 197 unsigned int is_auto:1;
d9a25471
HV
198 unsigned int is_int:1;
199 unsigned int is_string:1;
200 unsigned int is_ptr:1;
998e7659 201 unsigned int is_array:1;
5626b8c7 202 unsigned int has_volatiles:1;
8ac7a949 203 unsigned int call_notify:1;
82a7c049 204 unsigned int manual_mode_value:8;
0996517c
HV
205
206 const struct v4l2_ctrl_ops *ops;
0176077a 207 const struct v4l2_ctrl_type_ops *type_ops;
0996517c
HV
208 u32 id;
209 const char *name;
210 enum v4l2_ctrl_type type;
0ba2aeb6 211 s64 minimum, maximum, default_value;
20d88eef 212 u32 elems;
d9a25471 213 u32 elem_size;
20d88eef
HV
214 u32 dims[V4L2_CTRL_MAX_DIMS];
215 u32 nr_of_dims;
0996517c 216 union {
0ba2aeb6
HV
217 u64 step;
218 u64 menu_skip_mask;
0996517c 219 };
ce580fe5
SA
220 union {
221 const char * const *qmenu;
222 const s64 *qmenu_int;
223 };
0996517c 224 unsigned long flags;
d9a25471 225 void *priv;
2a9ec373
HV
226 s32 val;
227 struct {
0996517c 228 s32 val;
d9a25471 229 } cur;
0176077a
HV
230
231 union v4l2_ctrl_ptr p_new;
232 union v4l2_ctrl_ptr p_cur;
0996517c
HV
233};
234
8c2721d5
MCC
235/**
236 * struct v4l2_ctrl_ref - The control reference.
8ec4bee7 237 *
8c2721d5
MCC
238 * @node: List node for the sorted list.
239 * @next: Single-link list node for the hash.
240 * @ctrl: The actual control information.
8ec4bee7 241 * @helper: Pointer to helper struct. Used internally in
fb91161a 242 * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
8c2721d5
MCC
243 *
244 * Each control handler has a list of these refs. The list_head is used to
245 * keep a sorted-by-control-ID list of all controls, while the next pointer
246 * is used to link the control in the hash's bucket.
247 */
0996517c
HV
248struct v4l2_ctrl_ref {
249 struct list_head node;
250 struct v4l2_ctrl_ref *next;
251 struct v4l2_ctrl *ctrl;
eb5b16ef 252 struct v4l2_ctrl_helper *helper;
0996517c
HV
253};
254
8c2721d5
MCC
255/**
256 * struct v4l2_ctrl_handler - The control handler keeps track of all the
8ec4bee7
MCC
257 * controls: both the controls owned by the handler and those inherited
258 * from other handlers.
259 *
8c2721d5
MCC
260 * @_lock: Default for "lock".
261 * @lock: Lock to control access to this handler and its controls.
262 * May be replaced by the user right after init.
263 * @ctrls: The list of controls owned by this handler.
264 * @ctrl_refs: The list of control references.
265 * @cached: The last found control reference. It is common that the same
266 * control is needed multiple times, so this is a simple
267 * optimization.
268 * @buckets: Buckets for the hashing. Allows for quick control lookup.
8ec4bee7
MCC
269 * @notify: A notify callback that is called whenever the control changes
270 * value.
8c2721d5
MCC
271 * Note that the handler's lock is held when the notify function
272 * is called!
273 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
274 * @nr_of_buckets: Total number of buckets in the array.
275 * @error: The error code of the first failed control addition.
276 */
0996517c 277struct v4l2_ctrl_handler {
77e7c4e6
SA
278 struct mutex _lock;
279 struct mutex *lock;
0996517c
HV
280 struct list_head ctrls;
281 struct list_head ctrl_refs;
282 struct v4l2_ctrl_ref *cached;
283 struct v4l2_ctrl_ref **buckets;
8ac7a949
HV
284 v4l2_ctrl_notify_fnc notify;
285 void *notify_priv;
0996517c
HV
286 u16 nr_of_buckets;
287 int error;
288};
289
8c2721d5
MCC
290/**
291 * struct v4l2_ctrl_config - Control configuration structure.
8ec4bee7 292 *
8c2721d5
MCC
293 * @ops: The control ops.
294 * @type_ops: The control type ops. Only needed for compound controls.
295 * @id: The control ID.
296 * @name: The control name.
297 * @type: The control type.
298 * @min: The control's minimum value.
299 * @max: The control's maximum value.
300 * @step: The control's step value for non-menu controls.
8ec4bee7 301 * @def: The control's default value.
8c2721d5
MCC
302 * @dims: The size of each dimension.
303 * @elem_size: The size in bytes of the control.
304 * @flags: The control's flags.
305 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
306 * easy to skip menu items that are not valid. If bit X is set,
307 * then menu item X is skipped. Of course, this only works for
308 * menus with <= 64 menu items. There are no menus that come
309 * close to that number, so this is OK. Should we ever need more,
310 * then this will have to be extended to a bit array.
311 * @qmenu: A const char * array for all menu items. Array entries that are
312 * empty strings ("") correspond to non-existing menu items (this
313 * is in addition to the menu_skip_mask above). The last entry
314 * must be NULL.
7dc87919 315 * @qmenu_int: A const s64 integer array for all menu items of the type
8ec4bee7 316 * V4L2_CTRL_TYPE_INTEGER_MENU.
8c2721d5
MCC
317 * @is_private: If set, then this control is private to its handler and it
318 * will not be added to any other handlers.
319 */
0996517c
HV
320struct v4l2_ctrl_config {
321 const struct v4l2_ctrl_ops *ops;
0176077a 322 const struct v4l2_ctrl_type_ops *type_ops;
0996517c
HV
323 u32 id;
324 const char *name;
325 enum v4l2_ctrl_type type;
0ba2aeb6
HV
326 s64 min;
327 s64 max;
328 u64 step;
329 s64 def;
20d88eef 330 u32 dims[V4L2_CTRL_MAX_DIMS];
d9a25471 331 u32 elem_size;
0996517c 332 u32 flags;
0ba2aeb6 333 u64 menu_skip_mask;
513521ea 334 const char * const *qmenu;
ce580fe5 335 const s64 *qmenu_int;
0996517c 336 unsigned int is_private:1;
0996517c
HV
337};
338
8ec4bee7
MCC
339/**
340 * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
341 *
342 * @id: ID of the control
343 * @name: name of the control
344 * @type: type of the control
345 * @min: minimum value for the control
346 * @max: maximum value for the control
347 * @step: control step
348 * @def: default value for the control
349 * @flags: flags to be used on the control
8c2721d5
MCC
350 *
351 * This works for all standard V4L2 controls.
352 * For non-standard controls it will only fill in the given arguments
8ec4bee7 353 * and @name will be %NULL.
8c2721d5
MCC
354 *
355 * This function will overwrite the contents of @name, @type and @flags.
356 * The contents of @min, @max, @step and @def may be modified depending on
357 * the type.
358 *
8ec4bee7
MCC
359 * .. note::
360 *
361 * Do not use in drivers! It is used internally for backwards compatibility
362 * control handling only. Once all drivers are converted to use the new
363 * control framework this function will no longer be exported.
8c2721d5 364 */
0996517c 365void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
0ba2aeb6 366 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
0996517c
HV
367
368
8c2721d5
MCC
369/**
370 * v4l2_ctrl_handler_init_class() - Initialize the control handler.
371 * @hdl: The control handler.
372 * @nr_of_controls_hint: A hint of how many controls this handler is
373 * expected to refer to. This is the total number, so including
374 * any inherited controls. It doesn't have to be precise, but if
375 * it is way off, then you either waste memory (too many buckets
376 * are allocated) or the control lookup becomes slower (not enough
377 * buckets are allocated, so there are more slow list lookups).
378 * It will always work, though.
379 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
380 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
381 *
2257e180
MCC
382 * .. attention::
383 *
384 * Never use this call directly, always use the v4l2_ctrl_handler_init()
385 * macro that hides the @key and @name arguments.
8c2721d5 386 *
2257e180
MCC
387 * Return: returns an error if the buckets could not be allocated. This
388 * error will also be stored in @hdl->error.
8c2721d5 389 */
6cd247ef 390int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
8ec4bee7 391 unsigned int nr_of_controls_hint,
6cd247ef
AW
392 struct lock_class_key *key, const char *name);
393
394#ifdef CONFIG_LOCKDEP
2257e180
MCC
395
396/**
397 * v4l2_ctrl_handler_init -
398 *
399 * @hdl: The control handler.
400 * @nr_of_controls_hint: A hint of how many controls this handler is
401 * expected to refer to. This is the total number, so including
402 * any inherited controls. It doesn't have to be precise, but if
403 * it is way off, then you either waste memory (too many buckets
404 * are allocated) or the control lookup becomes slower (not enough
405 * buckets are allocated, so there are more slow list lookups).
406 * It will always work, though.
407 *
408 * This helper function creates a static struct &lock_class_key and
409 * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
410 * validador.
411 *
412 * Use this helper function to initialize a control handler.
413 */
6cd247ef
AW
414#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
415( \
416 ({ \
417 static struct lock_class_key _key; \
418 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
419 &_key, \
420 KBUILD_BASENAME ":" \
421 __stringify(__LINE__) ":" \
422 "(" #hdl ")->_lock"); \
423 }) \
424)
425#else
426#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
427 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
428#endif
0996517c 429
8c2721d5
MCC
430/**
431 * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
432 * the control list.
433 * @hdl: The control handler.
434 *
435 * Does nothing if @hdl == NULL.
436 */
0996517c
HV
437void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
438
8c2721d5
MCC
439/**
440 * v4l2_ctrl_lock() - Helper function to lock the handler
441 * associated with the control.
442 * @ctrl: The control to lock.
443 */
605b3840
SA
444static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
445{
446 mutex_lock(ctrl->handler->lock);
447}
448
8c2721d5
MCC
449/**
450 * v4l2_ctrl_unlock() - Helper function to unlock the handler
451 * associated with the control.
452 * @ctrl: The control to unlock.
453 */
605b3840
SA
454static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
455{
456 mutex_unlock(ctrl->handler->lock);
457}
458
8c2721d5
MCC
459/**
460 * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
461 * to the handler to initialize the hardware to the current control values.
462 * @hdl: The control handler.
463 *
464 * Button controls will be skipped, as are read-only controls.
465 *
466 * If @hdl == NULL, then this just returns 0.
467 */
0996517c
HV
468int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
469
8c2721d5
MCC
470/**
471 * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
472 * @hdl: The control handler.
473 * @prefix: The prefix to use when logging the control values. If the
474 * prefix does not end with a space, then ": " will be added
475 * after the prefix. If @prefix == NULL, then no prefix will be
476 * used.
477 *
478 * For use with VIDIOC_LOG_STATUS.
479 *
480 * Does nothing if @hdl == NULL.
481 */
0996517c
HV
482void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
483 const char *prefix);
484
8c2721d5
MCC
485/**
486 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
8ec4bee7
MCC
487 * control.
488 *
8c2721d5
MCC
489 * @hdl: The control handler.
490 * @cfg: The control's configuration data.
491 * @priv: The control's driver-specific private data.
492 *
493 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
494 * and @hdl->error is set to the error code (if it wasn't set already).
495 */
0996517c 496struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
497 const struct v4l2_ctrl_config *cfg,
498 void *priv);
0996517c 499
8c2721d5 500/**
8ec4bee7
MCC
501 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
502 * control.
503 *
8c2721d5
MCC
504 * @hdl: The control handler.
505 * @ops: The control ops.
8ec4bee7 506 * @id: The control ID.
8c2721d5
MCC
507 * @min: The control's minimum value.
508 * @max: The control's maximum value.
509 * @step: The control's step value
8ec4bee7 510 * @def: The control's default value.
8c2721d5
MCC
511 *
512 * If the &v4l2_ctrl struct could not be allocated, or the control
513 * ID is not known, then NULL is returned and @hdl->error is set to the
514 * appropriate error code (if it wasn't set already).
515 *
516 * If @id refers to a menu control, then this function will return NULL.
517 *
518 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
519 */
0996517c 520struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
521 const struct v4l2_ctrl_ops *ops,
522 u32 id, s64 min, s64 max, u64 step,
523 s64 def);
0996517c 524
8c2721d5 525/**
8ec4bee7
MCC
526 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
527 * menu control.
528 *
8c2721d5
MCC
529 * @hdl: The control handler.
530 * @ops: The control ops.
8ec4bee7 531 * @id: The control ID.
8c2721d5 532 * @max: The control's maximum value.
8ec4bee7 533 * @mask: The control's skip mask for menu controls. This makes it
8c2721d5
MCC
534 * easy to skip menu items that are not valid. If bit X is set,
535 * then menu item X is skipped. Of course, this only works for
536 * menus with <= 64 menu items. There are no menus that come
537 * close to that number, so this is OK. Should we ever need more,
538 * then this will have to be extended to a bit array.
8ec4bee7 539 * @def: The control's default value.
8c2721d5
MCC
540 *
541 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
542 * determines which menu items are to be skipped.
543 *
544 * If @id refers to a non-menu control, then this function will return NULL.
545 */
0996517c 546struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
547 const struct v4l2_ctrl_ops *ops,
548 u32 id, u8 max, u64 mask, u8 def);
0996517c 549
8c2721d5
MCC
550/**
551 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
8ec4bee7
MCC
552 * with driver specific menu.
553 *
8c2721d5
MCC
554 * @hdl: The control handler.
555 * @ops: The control ops.
556 * @id: The control ID.
557 * @max: The control's maximum value.
558 * @mask: The control's skip mask for menu controls. This makes it
559 * easy to skip menu items that are not valid. If bit X is set,
560 * then menu item X is skipped. Of course, this only works for
561 * menus with <= 64 menu items. There are no menus that come
562 * close to that number, so this is OK. Should we ever need more,
563 * then this will have to be extended to a bit array.
564 * @def: The control's default value.
565 * @qmenu: The new menu.
566 *
567 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
568 * menu of this control.
569 *
570 */
117a711a 571struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
572 const struct v4l2_ctrl_ops *ops,
573 u32 id, u8 max,
574 u64 mask, u8 def,
575 const char * const *qmenu);
117a711a 576
8c2721d5
MCC
577/**
578 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
8ec4bee7 579 *
8c2721d5
MCC
580 * @hdl: The control handler.
581 * @ops: The control ops.
582 * @id: The control ID.
583 * @max: The control's maximum value.
584 * @def: The control's default value.
585 * @qmenu_int: The control's menu entries.
586 *
587 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
588 * takes as an argument an array of integers determining the menu items.
589 *
8ec4bee7
MCC
590 * If @id refers to a non-integer-menu control, then this function will
591 * return %NULL.
8c2721d5 592 */
515f3287 593struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
594 const struct v4l2_ctrl_ops *ops,
595 u32 id, u8 max, u8 def,
596 const s64 *qmenu_int);
515f3287 597
2257e180
MCC
598/**
599 * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
600 * used when adding a control handler.
601 *
602 * @ctrl: pointer to struct &v4l2_ctrl.
603 */
604
6d85d7d7
MCC
605typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
606
8c2721d5
MCC
607/**
608 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
8ec4bee7
MCC
609 * handler @hdl.
610 *
8c2721d5
MCC
611 * @hdl: The control handler.
612 * @add: The control handler whose controls you want to add to
613 * the @hdl control handler.
614 * @filter: This function will filter which controls should be added.
615 *
616 * Does nothing if either of the two handlers is a NULL pointer.
617 * If @filter is NULL, then all controls are added. Otherwise only those
618 * controls for which @filter returns true will be added.
619 * In case of an error @hdl->error will be set to the error code (if it
620 * wasn't set already).
621 */
0996517c 622int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
34a6b7d0 623 struct v4l2_ctrl_handler *add,
6d85d7d7 624 v4l2_ctrl_filter filter);
0996517c 625
8c2721d5
MCC
626/**
627 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
8ec4bee7 628 *
8c2721d5
MCC
629 * @ctrl: The control that is filtered.
630 *
631 * This will return true for any controls that are valid for radio device
632 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
633 * transmitter class controls.
634 *
635 * This function is to be used with v4l2_ctrl_add_handler().
636 */
34a6b7d0 637bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
0996517c 638
8c2721d5 639/**
8ec4bee7
MCC
640 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
641 * to that cluster.
642 *
8c2721d5 643 * @ncontrols: The number of controls in this cluster.
8ec4bee7 644 * @controls: The cluster control array of size @ncontrols.
8c2721d5 645 */
8ec4bee7 646void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
0996517c
HV
647
648
8c2721d5 649/**
8ec4bee7
MCC
650 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
651 * to that cluster and set it up for autofoo/foo-type handling.
652 *
8c2721d5
MCC
653 * @ncontrols: The number of controls in this cluster.
654 * @controls: The cluster control array of size @ncontrols. The first control
655 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
656 * @manual_val: The value for the first control in the cluster that equals the
657 * manual setting.
658 * @set_volatile: If true, then all controls except the first auto control will
659 * be volatile.
660 *
661 * Use for control groups where one control selects some automatic feature and
662 * the other controls are only active whenever the automatic feature is turned
663 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
664 * red and blue balance, etc.
665 *
666 * The behavior of such controls is as follows:
667 *
668 * When the autofoo control is set to automatic, then any manual controls
669 * are set to inactive and any reads will call g_volatile_ctrl (if the control
670 * was marked volatile).
671 *
672 * When the autofoo control is set to manual, then any manual controls will
673 * be marked active, and any reads will just return the current value without
674 * going through g_volatile_ctrl.
675 *
2257e180
MCC
676 * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
677 * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
8c2721d5
MCC
678 * if autofoo is in auto mode.
679 */
8ec4bee7
MCC
680void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
681 struct v4l2_ctrl **controls,
682 u8 manual_val, bool set_volatile);
72d877ca
HV
683
684
8c2721d5
MCC
685/**
686 * v4l2_ctrl_find() - Find a control with the given ID.
8ec4bee7 687 *
8c2721d5
MCC
688 * @hdl: The control handler.
689 * @id: The control ID to find.
690 *
691 * If @hdl == NULL this will return NULL as well. Will lock the handler so
692 * do not use from inside &v4l2_ctrl_ops.
693 */
0996517c
HV
694struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
695
8c2721d5
MCC
696/**
697 * v4l2_ctrl_activate() - Make the control active or inactive.
698 * @ctrl: The control to (de)activate.
699 * @active: True if the control should become active.
700 *
701 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
702 * Does nothing if @ctrl == NULL.
703 * This will usually be called from within the s_ctrl op.
704 * The V4L2_EVENT_CTRL event will be generated afterwards.
705 *
706 * This function assumes that the control handler is locked.
707 */
0996517c
HV
708void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
709
8c2721d5
MCC
710/**
711 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
8ec4bee7 712 *
8c2721d5
MCC
713 * @ctrl: The control to (de)activate.
714 * @grabbed: True if the control should become grabbed.
715 *
716 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
717 * Does nothing if @ctrl == NULL.
718 * The V4L2_EVENT_CTRL event will be generated afterwards.
719 * This will usually be called when starting or stopping streaming in the
720 * driver.
721 *
722 * This function assumes that the control handler is not locked and will
723 * take the lock itself.
724 */
0996517c
HV
725void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
726
8c2721d5
MCC
727/**
728 *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
729 *
730 * @ctrl: The control to update.
731 * @min: The control's minimum value.
732 * @max: The control's maximum value.
733 * @step: The control's step value
734 * @def: The control's default value.
735 *
736 * Update the range of a control on the fly. This works for control types
737 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
738 * @step value is interpreted as a menu_skip_mask.
739 *
740 * An error is returned if one of the range arguments is invalid for this
741 * control type.
742 *
743 * This function assumes that the control handler is not locked and will
744 * take the lock itself.
745 */
5a573925
SA
746int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
747 s64 min, s64 max, u64 step, s64 def);
748
8c2721d5
MCC
749/**
750 * v4l2_ctrl_modify_range() - Update the range of a control.
8ec4bee7 751 *
8c2721d5
MCC
752 * @ctrl: The control to update.
753 * @min: The control's minimum value.
754 * @max: The control's maximum value.
755 * @step: The control's step value
756 * @def: The control's default value.
757 *
758 * Update the range of a control on the fly. This works for control types
759 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
760 * @step value is interpreted as a menu_skip_mask.
761 *
762 * An error is returned if one of the range arguments is invalid for this
763 * control type.
764 *
765 * This function assumes that the control handler is not locked and will
766 * take the lock itself.
767 */
5a573925
SA
768static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
769 s64 min, s64 max, u64 step, s64 def)
770{
771 int rval;
772
773 v4l2_ctrl_lock(ctrl);
774 rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
775 v4l2_ctrl_unlock(ctrl);
776
777 return rval;
778}
2ccbe779 779
8c2721d5
MCC
780/**
781 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
8ec4bee7 782 *
8c2721d5
MCC
783 * @ctrl: The control.
784 * @notify: The callback function.
785 * @priv: The callback private handle, passed as argument to the callback.
786 *
787 * This function sets a callback function for the control. If @ctrl is NULL,
788 * then it will do nothing. If @notify is NULL, then the notify callback will
789 * be removed.
790 *
791 * There can be only one notify. If another already exists, then a WARN_ON
792 * will be issued and the function will do nothing.
793 */
8ec4bee7
MCC
794void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
795 void *priv);
8ac7a949 796
8c2721d5
MCC
797/**
798 * v4l2_ctrl_get_name() - Get the name of the control
8ec4bee7 799 *
79fbc209
HV
800 * @id: The control ID.
801 *
802 * This function returns the name of the given control ID or NULL if it isn't
803 * a known control.
804 */
805const char *v4l2_ctrl_get_name(u32 id);
806
8c2721d5
MCC
807/**
808 * v4l2_ctrl_get_menu() - Get the menu string array of the control
8ec4bee7 809 *
79fbc209
HV
810 * @id: The control ID.
811 *
812 * This function returns the NULL-terminated menu string array name of the
813 * given control ID or NULL if it isn't a known menu control.
814 */
815const char * const *v4l2_ctrl_get_menu(u32 id);
816
8c2721d5
MCC
817/**
818 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
8ec4bee7 819 *
79fbc209
HV
820 * @id: The control ID.
821 * @len: The size of the integer array.
822 *
823 * This function returns the integer array of the given control ID or NULL if it
824 * if it isn't a known integer menu control.
825 */
826const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
827
8c2721d5 828/**
8ec4bee7
MCC
829 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
830 * within a driver.
831 *
8c2721d5
MCC
832 * @ctrl: The control.
833 *
834 * This returns the control's value safely by going through the control
835 * framework. This function will lock the control's handler, so it cannot be
836 * used from within the &v4l2_ctrl_ops functions.
837 *
838 * This function is for integer type controls only.
839 */
0996517c
HV
840s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
841
8c2721d5
MCC
842/**
843 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
8ec4bee7 844 *
8c2721d5 845 * @ctrl: The control.
8ec4bee7 846 * @val: TheControls name new value.
8c2721d5 847 *
904aef0f
HV
848 * This sets the control's new value safely by going through the control
849 * framework. This function assumes the control's handler is already locked,
850 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
851 *
852 * This function is for integer type controls only.
853 */
0c4348ad 854int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
8c2721d5 855
8ec4bee7
MCC
856/**
857 * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
858 * within a driver.
8c2721d5
MCC
859 * @ctrl: The control.
860 * @val: The new value.
861 *
904aef0f 862 * This sets the control's new value safely by going through the control
8c2721d5
MCC
863 * framework. This function will lock the control's handler, so it cannot be
864 * used from within the &v4l2_ctrl_ops functions.
865 *
866 * This function is for integer type controls only.
867 */
0c4348ad
SA
868static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
869{
870 int rval;
871
872 v4l2_ctrl_lock(ctrl);
873 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
874 v4l2_ctrl_unlock(ctrl);
875
876 return rval;
877}
0996517c 878
8c2721d5
MCC
879/**
880 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
881 * from within a driver.
8ec4bee7 882 *
8c2721d5
MCC
883 * @ctrl: The control.
884 *
885 * This returns the control's value safely by going through the control
886 * framework. This function will lock the control's handler, so it cannot be
887 * used from within the &v4l2_ctrl_ops functions.
888 *
889 * This function is for 64-bit integer type controls only.
890 */
03d5285b
LP
891s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
892
8c2721d5
MCC
893/**
894 * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
895 *
896 * @ctrl: The control.
897 * @val: The new value.
898 *
904aef0f
HV
899 * This sets the control's new value safely by going through the control
900 * framework. This function assumes the control's handler is already locked,
901 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
902 *
903 * This function is for 64-bit integer type controls only.
904 */
0c4348ad
SA
905int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
906
8ec4bee7
MCC
907/**
908 * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
8c2721d5
MCC
909 * from within a driver.
910 *
911 * @ctrl: The control.
912 * @val: The new value.
913 *
904aef0f 914 * This sets the control's new value safely by going through the control
8c2721d5
MCC
915 * framework. This function will lock the control's handler, so it cannot be
916 * used from within the &v4l2_ctrl_ops functions.
917 *
918 * This function is for 64-bit integer type controls only.
919 */
0c4348ad
SA
920static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
921{
922 int rval;
923
924 v4l2_ctrl_lock(ctrl);
925 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
926 v4l2_ctrl_unlock(ctrl);
927
928 return rval;
929}
03d5285b 930
8ec4bee7
MCC
931/**
932 * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
8c2721d5
MCC
933 *
934 * @ctrl: The control.
935 * @s: The new string.
936 *
904aef0f
HV
937 * This sets the control's new string safely by going through the control
938 * framework. This function assumes the control's handler is already locked,
939 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
940 *
941 * This function is for string type controls only.
942 */
5d0360a4
HV
943int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
944
8ec4bee7
MCC
945/**
946 * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
8c2721d5
MCC
947 * from within a driver.
948 *
949 * @ctrl: The control.
950 * @s: The new string.
8ec4bee7 951 *Controls name
904aef0f 952 * This sets the control's new string safely by going through the control
8c2721d5
MCC
953 * framework. This function will lock the control's handler, so it cannot be
954 * used from within the &v4l2_ctrl_ops functions.
955 *
956 * This function is for string type controls only.
957 */
5d0360a4
HV
958static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
959{
960 int rval;
961
962 v4l2_ctrl_lock(ctrl);
963 rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
964 v4l2_ctrl_unlock(ctrl);
965
966 return rval;
967}
968
ce727574 969/* Internal helper functions that deal with control events. */
3e366149 970extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
8ec4bee7
MCC
971
972/**
973 * v4l2_ctrl_replace - Function to be used as a callback to
974 * &struct v4l2_subscribed_event_ops replace\(\)
975 *
f8441a43 976 * @old: pointer to struct &v4l2_event with the reported
8ec4bee7 977 * event;
f8441a43 978 * @new: pointer to struct &v4l2_event with the modified
8ec4bee7
MCC
979 * event;
980 */
3e366149 981void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
8ec4bee7
MCC
982
983/**
984 * v4l2_ctrl_merge - Function to be used as a callback to
985 * &struct v4l2_subscribed_event_ops merge(\)
986 *
f8441a43 987 * @old: pointer to struct &v4l2_event with the reported
8ec4bee7 988 * event;
f8441a43 989 * @new: pointer to struct &v4l2_event with the merged
8ec4bee7
MCC
990 * event;
991 */
3e366149 992void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
6e239399 993
8ec4bee7
MCC
994/**
995 * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
996 *
997 * @file: pointer to struct file
998 * @fh: unused. Kept just to be compatible to the arguments expected by
999 * &struct v4l2_ioctl_ops.vidioc_log_status.
1000 *
1001 * Can be used as a vidioc_log_status function that just dumps all controls
1002 * associated with the filehandle.
1003 */
e2ecb257
HV
1004int v4l2_ctrl_log_status(struct file *file, void *fh);
1005
8ec4bee7
MCC
1006/**
1007 * v4l2_ctrl_subscribe_event - Subscribes to an event
1008 *
1009 *
1010 * @fh: pointer to struct v4l2_fh
1011 * @sub: pointer to &struct v4l2_event_subscription
1012 *
1013 * Can be used as a vidioc_subscribe_event function that just subscribes
1014 * control events.
1015 */
a26243b0 1016int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
85f5fe39 1017 const struct v4l2_event_subscription *sub);
a26243b0 1018
8ec4bee7
MCC
1019/**
1020 * v4l2_ctrl_poll - function to be used as a callback to the poll()
1021 * That just polls for control events.
1022 *
1023 * @file: pointer to struct file
1024 * @wait: pointer to struct poll_table_struct
1025 */
a26243b0
HV
1026unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
1027
8ec4bee7
MCC
1028/* Helpers for ioctl_ops */
1029
1030/**
1031 * v4l2_queryctrl - Helper function to implement
1032 * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
1033 *
1034 * @hdl: pointer to &struct v4l2_ctrl_handler
1035 * @qc: pointer to &struct v4l2_queryctrl
1036 *
1037 * If hdl == NULL then they will all return -EINVAL.
1038 */
0996517c 1039int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
8ec4bee7
MCC
1040
1041/**
1042 * v4l2_query_ext_ctrl - Helper function to implement
1043 * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
1044 *
1045 * @hdl: pointer to &struct v4l2_ctrl_handler
1046 * @qc: pointer to &struct v4l2_query_ext_ctrl
1047 *
1048 * If hdl == NULL then they will all return -EINVAL.
1049 */
1050int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
1051 struct v4l2_query_ext_ctrl *qc);
1052
1053/**
1054 * v4l2_querymenu - Helper function to implement
1055 * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
1056 *
1057 * @hdl: pointer to &struct v4l2_ctrl_handler
1058 * @qm: pointer to &struct v4l2_querymenu
1059 *
1060 * If hdl == NULL then they will all return -EINVAL.
1061 */
0996517c 1062int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
8ec4bee7
MCC
1063
1064/**
1065 * v4l2_g_ctrl - Helper function to implement
1066 * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
1067 *
1068 * @hdl: pointer to &struct v4l2_ctrl_handler
1069 * @ctrl: pointer to &struct v4l2_control
1070 *
1071 * If hdl == NULL then they will all return -EINVAL.
1072 */
0996517c 1073int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
8ec4bee7
MCC
1074
1075/**
1076 * v4l2_s_ctrl - Helper function to implement
1077 * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
1078 *
1079 * @fh: pointer to &struct v4l2_fh
1080 * @hdl: pointer to &struct v4l2_ctrl_handler
1081 *
1082 * @ctrl: pointer to &struct v4l2_control
1083 *
1084 * If hdl == NULL then they will all return -EINVAL.
1085 */
ab892bac 1086int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
1087 struct v4l2_control *ctrl);
1088
1089/**
1090 * v4l2_g_ext_ctrls - Helper function to implement
1091 * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1092 *
1093 * @hdl: pointer to &struct v4l2_ctrl_handler
1094 * @c: pointer to &struct v4l2_ext_controls
1095 *
1096 * If hdl == NULL then they will all return -EINVAL.
1097 */
1098int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1099 struct v4l2_ext_controls *c);
1100
1101/**
1102 * v4l2_try_ext_ctrls - Helper function to implement
1103 * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1104 *
1105 * @hdl: pointer to &struct v4l2_ctrl_handler
1106 * @c: pointer to &struct v4l2_ext_controls
1107 *
1108 * If hdl == NULL then they will all return -EINVAL.
1109 */
1110int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1111 struct v4l2_ext_controls *c);
1112
1113/**
1114 * v4l2_s_ext_ctrls - Helper function to implement
1115 * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1116 *
1117 * @fh: pointer to &struct v4l2_fh
1118 * @hdl: pointer to &struct v4l2_ctrl_handler
1119 * @c: pointer to &struct v4l2_ext_controls
1120 *
1121 * If hdl == NULL then they will all return -EINVAL.
1122 */
ab892bac 1123int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
8ec4bee7 1124 struct v4l2_ext_controls *c);
0996517c 1125
8ec4bee7
MCC
1126/**
1127 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
1128 * as a &struct v4l2_subdev_core_ops subscribe_event function
1129 * that just subscribes control events.
1130 *
1131 * @sd: pointer to &struct v4l2_subdev
1132 * @fh: pointer to &struct v4l2_fh
1133 * @sub: pointer to &struct v4l2_event_subscription
1134 */
22fa4279
SN
1135int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1136 struct v4l2_event_subscription *sub);
1137
8ec4bee7
MCC
1138/**
1139 * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
1140 * handler.
1141 *
1142 * @sd: pointer to &struct v4l2_subdev
1143 */
ffa9b9f0
SN
1144int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
1145
0996517c 1146#endif
This page took 0.536982 seconds and 5 git commands to generate.