aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/v4l2-ctrls.h365
1 files changed, 279 insertions, 86 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index d6f63406b885..178a88d45aea 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -1,21 +1,17 @@
1/* 1/*
2 V4L2 controls support header. 2 * V4L2 controls support header.
3 3 *
4 Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl> 4 * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
5 5 *
6 This program is free software; you can redistribute it and/or modify 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 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 8 * the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 * (at your option) any later version.
10 10 *
11 This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 * GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 15 */
20 16
21#ifndef _V4L2_CTRLS_H 17#ifndef _V4L2_CTRLS_H
@@ -58,6 +54,7 @@ union v4l2_ctrl_ptr {
58 54
59/** 55/**
60 * struct v4l2_ctrl_ops - The control operations that the driver has to provide. 56 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
57 *
61 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant 58 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
62 * for volatile (and usually read-only) controls such as a control 59 * for volatile (and usually read-only) controls such as a control
63 * that returns the current signal strength which changes 60 * that returns the current signal strength which changes
@@ -77,12 +74,13 @@ struct v4l2_ctrl_ops {
77 74
78/** 75/**
79 * struct v4l2_ctrl_type_ops - The control type operations that the driver 76 * struct v4l2_ctrl_type_ops - The control type operations that the driver
80 * has to provide. 77 * has to provide.
81 * 78 *
82 * @equal: return true if both values are equal. 79 * @equal: return true if both values are equal.
83 * @init: initialize the value. 80 * @init: initialize the value.
84 * @log: log the value. 81 * @log: log the value.
85 * @validate: validate the value. Return 0 on success and a negative value otherwise. 82 * @validate: validate the value. Return 0 on success and a negative value
83 * otherwise.
86 */ 84 */
87struct v4l2_ctrl_type_ops { 85struct v4l2_ctrl_type_ops {
88 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx, 86 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
@@ -99,6 +97,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
99 97
100/** 98/**
101 * struct v4l2_ctrl - The control structure. 99 * struct v4l2_ctrl - The control structure.
100 *
102 * @node: The list node. 101 * @node: The list node.
103 * @ev_subs: The list of control event subscriptions. 102 * @ev_subs: The list of control event subscriptions.
104 * @handler: The handler that owns the control. 103 * @handler: The handler that owns the control.
@@ -106,7 +105,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
106 * @ncontrols: Number of controls in cluster array. 105 * @ncontrols: Number of controls in cluster array.
107 * @done: Internal flag: set for each processed control. 106 * @done: Internal flag: set for each processed control.
108 * @is_new: Set when the user specified a new value for this control. It 107 * @is_new: Set when the user specified a new value for this control. It
109 * is also set when called from v4l2_ctrl_handler_setup. Drivers 108 * is also set when called from v4l2_ctrl_handler_setup(). Drivers
110 * should never set this flag. 109 * should never set this flag.
111 * @has_changed: Set when the current value differs from the new value. Drivers 110 * @has_changed: Set when the current value differs from the new value. Drivers
112 * should never use this flag. 111 * should never use this flag.
@@ -119,9 +118,10 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
119 * set this flag directly. 118 * set this flag directly.
120 * @is_int: If set, then this control has a simple integer value (i.e. it 119 * @is_int: If set, then this control has a simple integer value (i.e. it
121 * uses ctrl->val). 120 * uses ctrl->val).
122 * @is_string: If set, then this control has type V4L2_CTRL_TYPE_STRING. 121 * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
123 * @is_ptr: If set, then this control is an array and/or has type >= V4L2_CTRL_COMPOUND_TYPES 122 * @is_ptr: If set, then this control is an array and/or has type >=
124 * and/or has type V4L2_CTRL_TYPE_STRING. In other words, struct 123 * %V4L2_CTRL_COMPOUND_TYPES
124 * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
125 * v4l2_ext_control uses field p to point to the data. 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. 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. 127 * @has_volatiles: If set, then one or more members of the cluster are volatile.
@@ -177,7 +177,8 @@ struct v4l2_ctrl {
177 struct list_head ev_subs; 177 struct list_head ev_subs;
178 struct v4l2_ctrl_handler *handler; 178 struct v4l2_ctrl_handler *handler;
179 struct v4l2_ctrl **cluster; 179 struct v4l2_ctrl **cluster;
180 unsigned ncontrols; 180 unsigned int ncontrols;
181
181 unsigned int done:1; 182 unsigned int done:1;
182 183
183 unsigned int is_new:1; 184 unsigned int is_new:1;
@@ -223,10 +224,12 @@ struct v4l2_ctrl {
223 224
224/** 225/**
225 * struct v4l2_ctrl_ref - The control reference. 226 * struct v4l2_ctrl_ref - The control reference.
227 *
226 * @node: List node for the sorted list. 228 * @node: List node for the sorted list.
227 * @next: Single-link list node for the hash. 229 * @next: Single-link list node for the hash.
228 * @ctrl: The actual control information. 230 * @ctrl: The actual control information.
229 * @helper: Pointer to helper struct. Used internally in prepare_ext_ctrls(). 231 * @helper: Pointer to helper struct. Used internally in
232 * prepare_ext_ctrls().
230 * 233 *
231 * Each control handler has a list of these refs. The list_head is used to 234 * Each control handler has a list of these refs. The list_head is used to
232 * keep a sorted-by-control-ID list of all controls, while the next pointer 235 * keep a sorted-by-control-ID list of all controls, while the next pointer
@@ -241,8 +244,9 @@ struct v4l2_ctrl_ref {
241 244
242/** 245/**
243 * struct v4l2_ctrl_handler - The control handler keeps track of all the 246 * struct v4l2_ctrl_handler - The control handler keeps track of all the
244 * controls: both the controls owned by the handler and those inherited 247 * controls: both the controls owned by the handler and those inherited
245 * from other handlers. 248 * from other handlers.
249 *
246 * @_lock: Default for "lock". 250 * @_lock: Default for "lock".
247 * @lock: Lock to control access to this handler and its controls. 251 * @lock: Lock to control access to this handler and its controls.
248 * May be replaced by the user right after init. 252 * May be replaced by the user right after init.
@@ -252,7 +256,8 @@ struct v4l2_ctrl_ref {
252 * control is needed multiple times, so this is a simple 256 * control is needed multiple times, so this is a simple
253 * optimization. 257 * optimization.
254 * @buckets: Buckets for the hashing. Allows for quick control lookup. 258 * @buckets: Buckets for the hashing. Allows for quick control lookup.
255 * @notify: A notify callback that is called whenever the control changes value. 259 * @notify: A notify callback that is called whenever the control changes
260 * value.
256 * Note that the handler's lock is held when the notify function 261 * Note that the handler's lock is held when the notify function
257 * is called! 262 * is called!
258 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback. 263 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
@@ -274,6 +279,7 @@ struct v4l2_ctrl_handler {
274 279
275/** 280/**
276 * struct v4l2_ctrl_config - Control configuration structure. 281 * struct v4l2_ctrl_config - Control configuration structure.
282 *
277 * @ops: The control ops. 283 * @ops: The control ops.
278 * @type_ops: The control type ops. Only needed for compound controls. 284 * @type_ops: The control type ops. Only needed for compound controls.
279 * @id: The control ID. 285 * @id: The control ID.
@@ -282,7 +288,7 @@ struct v4l2_ctrl_handler {
282 * @min: The control's minimum value. 288 * @min: The control's minimum value.
283 * @max: The control's maximum value. 289 * @max: The control's maximum value.
284 * @step: The control's step value for non-menu controls. 290 * @step: The control's step value for non-menu controls.
285 * @def: The control's default value. 291 * @def: The control's default value.
286 * @dims: The size of each dimension. 292 * @dims: The size of each dimension.
287 * @elem_size: The size in bytes of the control. 293 * @elem_size: The size in bytes of the control.
288 * @flags: The control's flags. 294 * @flags: The control's flags.
@@ -297,7 +303,7 @@ struct v4l2_ctrl_handler {
297 * is in addition to the menu_skip_mask above). The last entry 303 * is in addition to the menu_skip_mask above). The last entry
298 * must be NULL. 304 * must be NULL.
299 * @qmenu_int: A const s64 integer array for all menu items of the type 305 * @qmenu_int: A const s64 integer array for all menu items of the type
300 * V4L2_CTRL_TYPE_INTEGER_MENU. 306 * V4L2_CTRL_TYPE_INTEGER_MENU.
301 * @is_private: If set, then this control is private to its handler and it 307 * @is_private: If set, then this control is private to its handler and it
302 * will not be added to any other handlers. 308 * will not be added to any other handlers.
303 */ 309 */
@@ -320,20 +326,31 @@ struct v4l2_ctrl_config {
320 unsigned int is_private:1; 326 unsigned int is_private:1;
321}; 327};
322 328
323/* 329/**
324 * v4l2_ctrl_fill() - Fill in the control fields based on the control ID. 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
325 * 340 *
326 * This works for all standard V4L2 controls. 341 * This works for all standard V4L2 controls.
327 * For non-standard controls it will only fill in the given arguments 342 * For non-standard controls it will only fill in the given arguments
328 * and @name will be NULL. 343 * and @name will be %NULL.
329 * 344 *
330 * This function will overwrite the contents of @name, @type and @flags. 345 * This function will overwrite the contents of @name, @type and @flags.
331 * The contents of @min, @max, @step and @def may be modified depending on 346 * The contents of @min, @max, @step and @def may be modified depending on
332 * the type. 347 * the type.
333 * 348 *
334 * Do not use in drivers! It is used internally for backwards compatibility 349 * .. note::
335 * control handling only. Once all drivers are converted to use the new 350 *
336 * control framework this function will no longer be exported. 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.
337 */ 354 */
338void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, 355void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
339 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags); 356 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
@@ -359,7 +376,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
359 * macro that hides the @key and @name arguments. 376 * macro that hides the @key and @name arguments.
360 */ 377 */
361int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, 378int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
362 unsigned nr_of_controls_hint, 379 unsigned int nr_of_controls_hint,
363 struct lock_class_key *key, const char *name); 380 struct lock_class_key *key, const char *name);
364 381
365#ifdef CONFIG_LOCKDEP 382#ifdef CONFIG_LOCKDEP
@@ -436,7 +453,8 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
436 453
437/** 454/**
438 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2 455 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
439 * control. 456 * control.
457 *
440 * @hdl: The control handler. 458 * @hdl: The control handler.
441 * @cfg: The control's configuration data. 459 * @cfg: The control's configuration data.
442 * @priv: The control's driver-specific private data. 460 * @priv: The control's driver-specific private data.
@@ -445,17 +463,20 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
445 * and @hdl->error is set to the error code (if it wasn't set already). 463 * and @hdl->error is set to the error code (if it wasn't set already).
446 */ 464 */
447struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, 465struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
448 const struct v4l2_ctrl_config *cfg, void *priv); 466 const struct v4l2_ctrl_config *cfg,
467 void *priv);
449 468
450/** 469/**
451 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu control. 470 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
471 * control.
472 *
452 * @hdl: The control handler. 473 * @hdl: The control handler.
453 * @ops: The control ops. 474 * @ops: The control ops.
454 * @id: The control ID. 475 * @id: The control ID.
455 * @min: The control's minimum value. 476 * @min: The control's minimum value.
456 * @max: The control's maximum value. 477 * @max: The control's maximum value.
457 * @step: The control's step value 478 * @step: The control's step value
458 * @def: The control's default value. 479 * @def: The control's default value.
459 * 480 *
460 * If the &v4l2_ctrl struct could not be allocated, or the control 481 * If the &v4l2_ctrl struct could not be allocated, or the control
461 * ID is not known, then NULL is returned and @hdl->error is set to the 482 * ID is not known, then NULL is returned and @hdl->error is set to the
@@ -466,22 +487,25 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
466 * Use v4l2_ctrl_new_std_menu() when adding menu controls. 487 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
467 */ 488 */
468struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, 489struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
469 const struct v4l2_ctrl_ops *ops, 490 const struct v4l2_ctrl_ops *ops,
470 u32 id, s64 min, s64 max, u64 step, s64 def); 491 u32 id, s64 min, s64 max, u64 step,
492 s64 def);
471 493
472/** 494/**
473 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control. 495 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
496 * menu control.
497 *
474 * @hdl: The control handler. 498 * @hdl: The control handler.
475 * @ops: The control ops. 499 * @ops: The control ops.
476 * @id: The control ID. 500 * @id: The control ID.
477 * @max: The control's maximum value. 501 * @max: The control's maximum value.
478 * @mask: The control's skip mask for menu controls. This makes it 502 * @mask: The control's skip mask for menu controls. This makes it
479 * easy to skip menu items that are not valid. If bit X is set, 503 * easy to skip menu items that are not valid. If bit X is set,
480 * then menu item X is skipped. Of course, this only works for 504 * then menu item X is skipped. Of course, this only works for
481 * menus with <= 64 menu items. There are no menus that come 505 * menus with <= 64 menu items. There are no menus that come
482 * close to that number, so this is OK. Should we ever need more, 506 * close to that number, so this is OK. Should we ever need more,
483 * then this will have to be extended to a bit array. 507 * then this will have to be extended to a bit array.
484 * @def: The control's default value. 508 * @def: The control's default value.
485 * 509 *
486 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value 510 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
487 * determines which menu items are to be skipped. 511 * determines which menu items are to be skipped.
@@ -489,12 +513,13 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
489 * If @id refers to a non-menu control, then this function will return NULL. 513 * If @id refers to a non-menu control, then this function will return NULL.
490 */ 514 */
491struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, 515struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
492 const struct v4l2_ctrl_ops *ops, 516 const struct v4l2_ctrl_ops *ops,
493 u32 id, u8 max, u64 mask, u8 def); 517 u32 id, u8 max, u64 mask, u8 def);
494 518
495/** 519/**
496 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control 520 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
497 * with driver specific menu. 521 * with driver specific menu.
522 *
498 * @hdl: The control handler. 523 * @hdl: The control handler.
499 * @ops: The control ops. 524 * @ops: The control ops.
500 * @id: The control ID. 525 * @id: The control ID.
@@ -513,11 +538,14 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
513 * 538 *
514 */ 539 */
515struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, 540struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
516 const struct v4l2_ctrl_ops *ops, u32 id, u8 max, 541 const struct v4l2_ctrl_ops *ops,
517 u64 mask, u8 def, const char * const *qmenu); 542 u32 id, u8 max,
543 u64 mask, u8 def,
544 const char * const *qmenu);
518 545
519/** 546/**
520 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. 547 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
548 *
521 * @hdl: The control handler. 549 * @hdl: The control handler.
522 * @ops: The control ops. 550 * @ops: The control ops.
523 * @id: The control ID. 551 * @id: The control ID.
@@ -528,17 +556,20 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
528 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly 556 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
529 * takes as an argument an array of integers determining the menu items. 557 * takes as an argument an array of integers determining the menu items.
530 * 558 *
531 * If @id refers to a non-integer-menu control, then this function will return NULL. 559 * If @id refers to a non-integer-menu control, then this function will
560 * return %NULL.
532 */ 561 */
533struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, 562struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
534 const struct v4l2_ctrl_ops *ops, 563 const struct v4l2_ctrl_ops *ops,
535 u32 id, u8 max, u8 def, const s64 *qmenu_int); 564 u32 id, u8 max, u8 def,
565 const s64 *qmenu_int);
536 566
537typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl); 567typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
538 568
539/** 569/**
540 * v4l2_ctrl_add_handler() - Add all controls from handler @add to 570 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
541 * handler @hdl. 571 * handler @hdl.
572 *
542 * @hdl: The control handler. 573 * @hdl: The control handler.
543 * @add: The control handler whose controls you want to add to 574 * @add: The control handler whose controls you want to add to
544 * the @hdl control handler. 575 * the @hdl control handler.
@@ -556,6 +587,7 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
556 587
557/** 588/**
558 * v4l2_ctrl_radio_filter() - Standard filter for radio controls. 589 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
590 *
559 * @ctrl: The control that is filtered. 591 * @ctrl: The control that is filtered.
560 * 592 *
561 * This will return true for any controls that are valid for radio device 593 * This will return true for any controls that are valid for radio device
@@ -567,16 +599,19 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
567bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl); 599bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
568 600
569/** 601/**
570 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster. 602 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
603 * to that cluster.
604 *
571 * @ncontrols: The number of controls in this cluster. 605 * @ncontrols: The number of controls in this cluster.
572 * @controls: The cluster control array of size @ncontrols. 606 * @controls: The cluster control array of size @ncontrols.
573 */ 607 */
574void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls); 608void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
575 609
576 610
577/** 611/**
578 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to 612 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
579 * that cluster and set it up for autofoo/foo-type handling. 613 * to that cluster and set it up for autofoo/foo-type handling.
614 *
580 * @ncontrols: The number of controls in this cluster. 615 * @ncontrols: The number of controls in this cluster.
581 * @controls: The cluster control array of size @ncontrols. The first control 616 * @controls: The cluster control array of size @ncontrols. The first control
582 * must be the 'auto' control (e.g. autogain, autoexposure, etc.) 617 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
@@ -604,12 +639,14 @@ void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
604 * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s) 639 * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
605 * if autofoo is in auto mode. 640 * if autofoo is in auto mode.
606 */ 641 */
607void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls, 642void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
608 u8 manual_val, bool set_volatile); 643 struct v4l2_ctrl **controls,
644 u8 manual_val, bool set_volatile);
609 645
610 646
611/** 647/**
612 * v4l2_ctrl_find() - Find a control with the given ID. 648 * v4l2_ctrl_find() - Find a control with the given ID.
649 *
613 * @hdl: The control handler. 650 * @hdl: The control handler.
614 * @id: The control ID to find. 651 * @id: The control ID to find.
615 * 652 *
@@ -634,6 +671,7 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
634 671
635/** 672/**
636 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed. 673 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
674 *
637 * @ctrl: The control to (de)activate. 675 * @ctrl: The control to (de)activate.
638 * @grabbed: True if the control should become grabbed. 676 * @grabbed: True if the control should become grabbed.
639 * 677 *
@@ -673,6 +711,7 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
673 711
674/** 712/**
675 * v4l2_ctrl_modify_range() - Update the range of a control. 713 * v4l2_ctrl_modify_range() - Update the range of a control.
714 *
676 * @ctrl: The control to update. 715 * @ctrl: The control to update.
677 * @min: The control's minimum value. 716 * @min: The control's minimum value.
678 * @max: The control's maximum value. 717 * @max: The control's maximum value.
@@ -703,6 +742,7 @@ static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
703 742
704/** 743/**
705 * v4l2_ctrl_notify() - Function to set a notify callback for a control. 744 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
745 *
706 * @ctrl: The control. 746 * @ctrl: The control.
707 * @notify: The callback function. 747 * @notify: The callback function.
708 * @priv: The callback private handle, passed as argument to the callback. 748 * @priv: The callback private handle, passed as argument to the callback.
@@ -714,10 +754,12 @@ static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
714 * There can be only one notify. If another already exists, then a WARN_ON 754 * There can be only one notify. If another already exists, then a WARN_ON
715 * will be issued and the function will do nothing. 755 * will be issued and the function will do nothing.
716 */ 756 */
717void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv); 757void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
758 void *priv);
718 759
719/** 760/**
720 * v4l2_ctrl_get_name() - Get the name of the control 761 * v4l2_ctrl_get_name() - Get the name of the control
762 *
721 * @id: The control ID. 763 * @id: The control ID.
722 * 764 *
723 * This function returns the name of the given control ID or NULL if it isn't 765 * This function returns the name of the given control ID or NULL if it isn't
@@ -727,6 +769,7 @@ const char *v4l2_ctrl_get_name(u32 id);
727 769
728/** 770/**
729 * v4l2_ctrl_get_menu() - Get the menu string array of the control 771 * v4l2_ctrl_get_menu() - Get the menu string array of the control
772 *
730 * @id: The control ID. 773 * @id: The control ID.
731 * 774 *
732 * This function returns the NULL-terminated menu string array name of the 775 * This function returns the NULL-terminated menu string array name of the
@@ -736,6 +779,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id);
736 779
737/** 780/**
738 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control 781 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
782 *
739 * @id: The control ID. 783 * @id: The control ID.
740 * @len: The size of the integer array. 784 * @len: The size of the integer array.
741 * 785 *
@@ -745,7 +789,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id);
745const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len); 789const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
746 790
747/** 791/**
748 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver. 792 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
793 * within a driver.
794 *
749 * @ctrl: The control. 795 * @ctrl: The control.
750 * 796 *
751 * This returns the control's value safely by going through the control 797 * This returns the control's value safely by going through the control
@@ -758,8 +804,9 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
758 804
759/** 805/**
760 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). 806 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
807 *
761 * @ctrl: The control. 808 * @ctrl: The control.
762 * @val: The new value. 809 * @val: TheControls name new value.
763 * 810 *
764 * This sets the control's new value safely by going through the control 811 * This sets the control's new value safely by going through the control
765 * framework. This function assumes the control's handler is already locked, 812 * framework. This function assumes the control's handler is already locked,
@@ -769,7 +816,9 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
769 */ 816 */
770int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); 817int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
771 818
772/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver. 819/**
820 * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
821 * within a driver.
773 * @ctrl: The control. 822 * @ctrl: The control.
774 * @val: The new value. 823 * @val: The new value.
775 * 824 *
@@ -793,6 +842,7 @@ static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
793/** 842/**
794 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value 843 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
795 * from within a driver. 844 * from within a driver.
845 *
796 * @ctrl: The control. 846 * @ctrl: The control.
797 * 847 *
798 * This returns the control's value safely by going through the control 848 * This returns the control's value safely by going through the control
@@ -817,7 +867,8 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
817 */ 867 */
818int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); 868int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
819 869
820/** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value 870/**
871 * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
821 * from within a driver. 872 * from within a driver.
822 * 873 *
823 * @ctrl: The control. 874 * @ctrl: The control.
@@ -840,7 +891,8 @@ static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
840 return rval; 891 return rval;
841} 892}
842 893
843/** __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string(). 894/**
895 * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
844 * 896 *
845 * @ctrl: The control. 897 * @ctrl: The control.
846 * @s: The new string. 898 * @s: The new string.
@@ -853,12 +905,13 @@ static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
853 */ 905 */
854int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s); 906int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
855 907
856/** v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value 908/**
909 * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
857 * from within a driver. 910 * from within a driver.
858 * 911 *
859 * @ctrl: The control. 912 * @ctrl: The control.
860 * @s: The new string. 913 * @s: The new string.
861 * 914 *Controls name
862 * This sets the control's new string safely by going through the control 915 * This sets the control's new string safely by going through the control
863 * framework. This function will lock the control's handler, so it cannot be 916 * framework. This function will lock the control's handler, so it cannot be
864 * used from within the &v4l2_ctrl_ops functions. 917 * used from within the &v4l2_ctrl_ops functions.
@@ -878,39 +931,179 @@ static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
878 931
879/* Internal helper functions that deal with control events. */ 932/* Internal helper functions that deal with control events. */
880extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; 933extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
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 */
881void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new); 944void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
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 */
882void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new); 955void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
883 956
884/* Can be used as a vidioc_log_status function that just dumps all controls 957/**
885 associated with the filehandle. */ 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 */
886int v4l2_ctrl_log_status(struct file *file, void *fh); 967int v4l2_ctrl_log_status(struct file *file, void *fh);
887 968
888/* Can be used as a vidioc_subscribe_event function that just subscribes 969/**
889 control events. */ 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 */
890int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, 979int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
891 const struct v4l2_event_subscription *sub); 980 const struct v4l2_event_subscription *sub);
892 981
893/* Can be used as a poll function that just polls for control events. */ 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 */
894unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); 989unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
895 990
896/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ 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 */
897int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); 1002int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
898int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctrl *qc); 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 */
1013int 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 */
899int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); 1025int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
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 */
900int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl); 1036int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
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 */
901int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, 1049int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
902 struct v4l2_control *ctrl); 1050 struct v4l2_control *ctrl);
903int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c); 1051
904int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c); 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 */
1061int 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 */
1073int 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 */
905int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, 1086int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
906 struct v4l2_ext_controls *c); 1087 struct v4l2_ext_controls *c);
907 1088
908/* Can be used as a subscribe_event function that just subscribes control 1089/**
909 events. */ 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 */
910int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, 1098int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
911 struct v4l2_event_subscription *sub); 1099 struct v4l2_event_subscription *sub);
912 1100
913/* Log all controls owned by subdev's control handler. */ 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 */
914int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd); 1107int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
915 1108
916#endif 1109#endif