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