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