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