1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * V4L2 controls support header.
5 * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
11 #include <linux/list.h>
12 #include <linux/mutex.h>
13 #include <linux/videodev2.h>
14 #include <media/media-request.h>
17 * Include the stateless codec compound control definitions.
18 * This will move to the public headers once this API is fully stable.
20 #include <media/mpeg2-ctrls.h>
21 #include <media/hevc-ctrls.h>
23 /* forward references */
25 struct poll_table_struct;
27 struct v4l2_ctrl_handler;
28 struct v4l2_ctrl_helper;
30 struct v4l2_fwnode_device_properties;
32 struct v4l2_subscribed_event;
36 * union v4l2_ctrl_ptr - A pointer to a control value.
37 * @p_s32: Pointer to a 32-bit signed value.
38 * @p_s64: Pointer to a 64-bit signed value.
39 * @p_u8: Pointer to a 8-bit unsigned value.
40 * @p_u16: Pointer to a 16-bit unsigned value.
41 * @p_u32: Pointer to a 32-bit unsigned value.
42 * @p_char: Pointer to a string.
43 * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure.
44 * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure.
45 * @p_fwht_params: Pointer to a FWHT stateless parameters structure.
46 * @p_h264_sps: Pointer to a struct v4l2_ctrl_h264_sps.
47 * @p_h264_pps: Pointer to a struct v4l2_ctrl_h264_pps.
48 * @p_h264_scaling_matrix: Pointer to a struct v4l2_ctrl_h264_scaling_matrix.
49 * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params.
50 * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params.
51 * @p_h264_pred_weights: Pointer to a struct v4l2_ctrl_h264_pred_weights.
52 * @p_vp8_frame: Pointer to a VP8 frame params structure.
53 * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure.
54 * @p_hevc_pps: Pointer to an HEVC picture parameter set structure.
55 * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
56 * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure.
57 * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure.
58 * @p_area: Pointer to an area.
59 * @p: Pointer to a compound value.
60 * @p_const: Pointer to a constant compound value.
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 struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
78 struct v4l2_ctrl_vp8_frame *p_vp8_frame;
79 struct v4l2_ctrl_hevc_sps *p_hevc_sps;
80 struct v4l2_ctrl_hevc_pps *p_hevc_pps;
81 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
82 struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;
83 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
84 struct v4l2_area *p_area;
90 * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a
92 * @ptr: The void pointer
94 static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr)
96 union v4l2_ctrl_ptr p = { .p = ptr };
102 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
104 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
105 * for volatile (and usually read-only) controls such as a control
106 * that returns the current signal strength which changes
108 * If not set, then the currently cached value will be returned.
109 * @try_ctrl: Test whether the control's value is valid. Only relevant when
110 * the usual min/max/step checks are not sufficient.
111 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
112 * ctrl->handler->lock is held when these ops are called, so no
113 * one else can access controls owned by that handler.
115 struct v4l2_ctrl_ops {
116 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
117 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
118 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
122 * struct v4l2_ctrl_type_ops - The control type operations that the driver
125 * @equal: return true if both values are equal.
126 * @init: initialize the value.
127 * @log: log the value.
128 * @validate: validate the value. Return 0 on success and a negative value
131 struct v4l2_ctrl_type_ops {
132 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
133 union v4l2_ctrl_ptr ptr1,
134 union v4l2_ctrl_ptr ptr2);
135 void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
136 union v4l2_ctrl_ptr ptr);
137 void (*log)(const struct v4l2_ctrl *ctrl);
138 int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
139 union v4l2_ctrl_ptr ptr);
143 * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
144 * that should be called when a control value has changed.
146 * @ctrl: pointer to struct &v4l2_ctrl
147 * @priv: control private data
149 * This typedef definition is used as an argument to v4l2_ctrl_notify()
150 * and as an argument at struct &v4l2_ctrl_handler.
152 typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
155 * struct v4l2_ctrl - The control structure.
157 * @node: The list node.
158 * @ev_subs: The list of control event subscriptions.
159 * @handler: The handler that owns the control.
160 * @cluster: Point to start of cluster array.
161 * @ncontrols: Number of controls in cluster array.
162 * @done: Internal flag: set for each processed control.
163 * @is_new: Set when the user specified a new value for this control. It
164 * is also set when called from v4l2_ctrl_handler_setup(). Drivers
165 * should never set this flag.
166 * @has_changed: Set when the current value differs from the new value. Drivers
167 * should never use this flag.
168 * @is_private: If set, then this control is private to its handler and it
169 * will not be added to any other handlers. Drivers can set
171 * @is_auto: If set, then this control selects whether the other cluster
172 * members are in 'automatic' mode or 'manual' mode. This is
173 * used for autogain/gain type clusters. Drivers should never
174 * set this flag directly.
175 * @is_int: If set, then this control has a simple integer value (i.e. it
177 * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
178 * @is_ptr: If set, then this control is an array and/or has type >=
179 * %V4L2_CTRL_COMPOUND_TYPES
180 * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
181 * v4l2_ext_control uses field p to point to the data.
182 * @is_array: If set, then this control contains an N-dimensional array.
183 * @has_volatiles: If set, then one or more members of the cluster are volatile.
184 * Drivers should never touch this flag.
185 * @call_notify: If set, then call the handler's notify function whenever the
186 * control's value changes.
187 * @manual_mode_value: If the is_auto flag is set, then this is the value
188 * of the auto control that determines if that control is in
189 * manual mode. So if the value of the auto control equals this
190 * value, then the whole cluster is in manual mode. Drivers should
191 * never set this flag directly.
192 * @ops: The control ops.
193 * @type_ops: The control type ops.
194 * @id: The control ID.
195 * @name: The control name.
196 * @type: The control type.
197 * @minimum: The control's minimum value.
198 * @maximum: The control's maximum value.
199 * @default_value: The control's default value.
200 * @step: The control's step value for non-menu controls.
201 * @elems: The number of elements in the N-dimensional array.
202 * @elem_size: The size in bytes of the control.
203 * @dims: The size of each dimension.
204 * @nr_of_dims:The number of dimensions in @dims.
205 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
206 * easy to skip menu items that are not valid. If bit X is set,
207 * then menu item X is skipped. Of course, this only works for
208 * menus with <= 32 menu items. There are no menus that come
209 * close to that number, so this is OK. Should we ever need more,
210 * then this will have to be extended to a u64 or a bit array.
211 * @qmenu: A const char * array for all menu items. Array entries that are
212 * empty strings ("") correspond to non-existing menu items (this
213 * is in addition to the menu_skip_mask above). The last entry
215 * Used only if the @type is %V4L2_CTRL_TYPE_MENU.
216 * @qmenu_int: A 64-bit integer array for with integer menu items.
217 * The size of array must be equal to the menu size, e. g.:
218 * :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
219 * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
220 * @flags: The control's flags.
221 * @cur: Structure to store the current value.
222 * @cur.val: The control's current value, if the @type is represented via
223 * a u32 integer (see &enum v4l2_ctrl_type).
224 * @val: The control's new s32 value.
225 * @priv: The control's private pointer. For use by the driver. It is
226 * untouched by the control framework. Note that this pointer is
227 * not freed when the control is deleted. Should this be needed
228 * then a new internal bitfield can be added to tell the framework
229 * to free this pointer.
230 * @p_def: The control's default value represented via a union which
231 * provides a standard way of accessing control types
232 * through a pointer (for compound controls only).
233 * @p_cur: The control's current value represented via a union which
234 * provides a standard way of accessing control types
236 * @p_new: The control's new value represented via a union which provides
237 * a standard way of accessing control types
241 /* Administrative fields */
242 struct list_head node;
243 struct list_head ev_subs;
244 struct v4l2_ctrl_handler *handler;
245 struct v4l2_ctrl **cluster;
246 unsigned int ncontrols;
250 unsigned int is_new:1;
251 unsigned int has_changed:1;
252 unsigned int is_private:1;
253 unsigned int is_auto:1;
254 unsigned int is_int:1;
255 unsigned int is_string:1;
256 unsigned int is_ptr:1;
257 unsigned int is_array:1;
258 unsigned int has_volatiles:1;
259 unsigned int call_notify:1;
260 unsigned int manual_mode_value:8;
262 const struct v4l2_ctrl_ops *ops;
263 const struct v4l2_ctrl_type_ops *type_ops;
266 enum v4l2_ctrl_type type;
267 s64 minimum, maximum, default_value;
270 u32 dims[V4L2_CTRL_MAX_DIMS];
277 const char * const *qmenu;
278 const s64 *qmenu_int;
287 union v4l2_ctrl_ptr p_def;
288 union v4l2_ctrl_ptr p_new;
289 union v4l2_ctrl_ptr p_cur;
293 * struct v4l2_ctrl_ref - The control reference.
295 * @node: List node for the sorted list.
296 * @next: Single-link list node for the hash.
297 * @ctrl: The actual control information.
298 * @helper: Pointer to helper struct. Used internally in
299 * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
300 * @from_other_dev: If true, then @ctrl was defined in another
301 * device than the &struct v4l2_ctrl_handler.
302 * @req_done: Internal flag: if the control handler containing this control
303 * reference is bound to a media request, then this is set when
304 * the control has been applied. This prevents applying controls
305 * from a cluster with multiple controls twice (when the first
306 * control of a cluster is applied, they all are).
307 * @valid_p_req: If set, then p_req contains the control value for the request.
308 * @p_req: If the control handler containing this control reference
309 * is bound to a media request, then this points to the
310 * value of the control that must be applied when the request
311 * is executed, or to the value of the control at the time
312 * that the request was completed. If @valid_p_req is false,
313 * then this control was never set for this request and the
314 * control will not be updated when this request is applied.
316 * Each control handler has a list of these refs. The list_head is used to
317 * keep a sorted-by-control-ID list of all controls, while the next pointer
318 * is used to link the control in the hash's bucket.
320 struct v4l2_ctrl_ref {
321 struct list_head node;
322 struct v4l2_ctrl_ref *next;
323 struct v4l2_ctrl *ctrl;
324 struct v4l2_ctrl_helper *helper;
328 union v4l2_ctrl_ptr p_req;
332 * struct v4l2_ctrl_handler - The control handler keeps track of all the
333 * controls: both the controls owned by the handler and those inherited
334 * from other handlers.
336 * @_lock: Default for "lock".
337 * @lock: Lock to control access to this handler and its controls.
338 * May be replaced by the user right after init.
339 * @ctrls: The list of controls owned by this handler.
340 * @ctrl_refs: The list of control references.
341 * @cached: The last found control reference. It is common that the same
342 * control is needed multiple times, so this is a simple
344 * @buckets: Buckets for the hashing. Allows for quick control lookup.
345 * @notify: A notify callback that is called whenever the control changes
347 * Note that the handler's lock is held when the notify function
349 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
350 * @nr_of_buckets: Total number of buckets in the array.
351 * @error: The error code of the first failed control addition.
352 * @request_is_queued: True if the request was queued.
353 * @requests: List to keep track of open control handler request objects.
354 * For the parent control handler (@req_obj.ops == NULL) this
355 * is the list header. When the parent control handler is
356 * removed, it has to unbind and put all these requests since
357 * they refer to the parent.
358 * @requests_queued: List of the queued requests. This determines the order
359 * in which these controls are applied. Once the request is
360 * completed it is removed from this list.
361 * @req_obj: The &struct media_request_object, used to link into a
362 * &struct media_request. This request object has a refcount.
364 struct v4l2_ctrl_handler {
367 struct list_head ctrls;
368 struct list_head ctrl_refs;
369 struct v4l2_ctrl_ref *cached;
370 struct v4l2_ctrl_ref **buckets;
371 v4l2_ctrl_notify_fnc notify;
375 bool request_is_queued;
376 struct list_head requests;
377 struct list_head requests_queued;
378 struct media_request_object req_obj;
382 * struct v4l2_ctrl_config - Control configuration structure.
384 * @ops: The control ops.
385 * @type_ops: The control type ops. Only needed for compound controls.
386 * @id: The control ID.
387 * @name: The control name.
388 * @type: The control type.
389 * @min: The control's minimum value.
390 * @max: The control's maximum value.
391 * @step: The control's step value for non-menu controls.
392 * @def: The control's default value.
393 * @p_def: The control's default value for compound controls.
394 * @dims: The size of each dimension.
395 * @elem_size: The size in bytes of the control.
396 * @flags: The control's flags.
397 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
398 * easy to skip menu items that are not valid. If bit X is set,
399 * then menu item X is skipped. Of course, this only works for
400 * menus with <= 64 menu items. There are no menus that come
401 * close to that number, so this is OK. Should we ever need more,
402 * then this will have to be extended to a bit array.
403 * @qmenu: A const char * array for all menu items. Array entries that are
404 * empty strings ("") correspond to non-existing menu items (this
405 * is in addition to the menu_skip_mask above). The last entry
407 * @qmenu_int: A const s64 integer array for all menu items of the type
408 * V4L2_CTRL_TYPE_INTEGER_MENU.
409 * @is_private: If set, then this control is private to its handler and it
410 * will not be added to any other handlers.
412 struct v4l2_ctrl_config {
413 const struct v4l2_ctrl_ops *ops;
414 const struct v4l2_ctrl_type_ops *type_ops;
417 enum v4l2_ctrl_type type;
422 union v4l2_ctrl_ptr p_def;
423 u32 dims[V4L2_CTRL_MAX_DIMS];
427 const char * const *qmenu;
428 const s64 *qmenu_int;
429 unsigned int is_private:1;
433 * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
435 * @id: ID of the control
436 * @name: pointer to be filled with a string with the name of the control
437 * @type: pointer for storing the type of the control
438 * @min: pointer for storing the minimum value for the control
439 * @max: pointer for storing the maximum value for the control
440 * @step: pointer for storing the control step
441 * @def: pointer for storing the default value for the control
442 * @flags: pointer for storing the flags to be used on the control
444 * This works for all standard V4L2 controls.
445 * For non-standard controls it will only fill in the given arguments
446 * and @name content will be set to %NULL.
448 * This function will overwrite the contents of @name, @type and @flags.
449 * The contents of @min, @max, @step and @def may be modified depending on
454 * Do not use in drivers! It is used internally for backwards compatibility
455 * control handling only. Once all drivers are converted to use the new
456 * control framework this function will no longer be exported.
458 void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
459 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
463 * v4l2_ctrl_handler_init_class() - Initialize the control handler.
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 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
473 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
477 * Never use this call directly, always use the v4l2_ctrl_handler_init()
478 * macro that hides the @key and @name arguments.
480 * Return: returns an error if the buckets could not be allocated. This
481 * error will also be stored in @hdl->error.
483 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
484 unsigned int nr_of_controls_hint,
485 struct lock_class_key *key, const char *name);
487 #ifdef CONFIG_LOCKDEP
490 * v4l2_ctrl_handler_init - helper function to create a static struct
491 * &lock_class_key and calls v4l2_ctrl_handler_init_class()
493 * @hdl: The control handler.
494 * @nr_of_controls_hint: A hint of how many controls this handler is
495 * expected to refer to. This is the total number, so including
496 * any inherited controls. It doesn't have to be precise, but if
497 * it is way off, then you either waste memory (too many buckets
498 * are allocated) or the control lookup becomes slower (not enough
499 * buckets are allocated, so there are more slow list lookups).
500 * It will always work, though.
502 * This helper function creates a static struct &lock_class_key and
503 * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
506 * Use this helper function to initialize a control handler.
508 #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
511 static struct lock_class_key _key; \
512 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
514 KBUILD_BASENAME ":" \
515 __stringify(__LINE__) ":" \
516 "(" #hdl ")->_lock"); \
520 #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
521 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
525 * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
527 * @hdl: The control handler.
529 * Does nothing if @hdl == NULL.
531 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
534 * v4l2_ctrl_lock() - Helper function to lock the handler
535 * associated with the control.
536 * @ctrl: The control to lock.
538 static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
540 mutex_lock(ctrl->handler->lock);
544 * v4l2_ctrl_unlock() - Helper function to unlock the handler
545 * associated with the control.
546 * @ctrl: The control to unlock.
548 static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
550 mutex_unlock(ctrl->handler->lock);
554 * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
555 * to the handler to initialize the hardware to the current control values. The
556 * caller is responsible for acquiring the control handler mutex on behalf of
557 * __v4l2_ctrl_handler_setup().
558 * @hdl: The control handler.
560 * Button controls will be skipped, as are read-only controls.
562 * If @hdl == NULL, then this just returns 0.
564 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
567 * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
568 * to the handler to initialize the hardware to the current control values.
569 * @hdl: The control handler.
571 * Button controls will be skipped, as are read-only controls.
573 * If @hdl == NULL, then this just returns 0.
575 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
578 * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
579 * @hdl: The control handler.
580 * @prefix: The prefix to use when logging the control values. If the
581 * prefix does not end with a space, then ": " will be added
582 * after the prefix. If @prefix == NULL, then no prefix will be
585 * For use with VIDIOC_LOG_STATUS.
587 * Does nothing if @hdl == NULL.
589 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
593 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
596 * @hdl: The control handler.
597 * @cfg: The control's configuration data.
598 * @priv: The control's driver-specific private data.
600 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
601 * and @hdl->error is set to the error code (if it wasn't set already).
603 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
604 const struct v4l2_ctrl_config *cfg,
608 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
611 * @hdl: The control handler.
612 * @ops: The control ops.
613 * @id: The control ID.
614 * @min: The control's minimum value.
615 * @max: The control's maximum value.
616 * @step: The control's step value
617 * @def: The control's default value.
619 * If the &v4l2_ctrl struct could not be allocated, or the control
620 * ID is not known, then NULL is returned and @hdl->error is set to the
621 * appropriate error code (if it wasn't set already).
623 * If @id refers to a menu control, then this function will return NULL.
625 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
627 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
628 const struct v4l2_ctrl_ops *ops,
629 u32 id, s64 min, s64 max, u64 step,
633 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
636 * @hdl: The control handler.
637 * @ops: The control ops.
638 * @id: The control ID.
639 * @max: The control's maximum value.
640 * @mask: The control's skip mask for menu controls. This makes it
641 * easy to skip menu items that are not valid. If bit X is set,
642 * then menu item X is skipped. Of course, this only works for
643 * menus with <= 64 menu items. There are no menus that come
644 * close to that number, so this is OK. Should we ever need more,
645 * then this will have to be extended to a bit array.
646 * @def: The control's default value.
648 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
649 * determines which menu items are to be skipped.
651 * If @id refers to a non-menu control, then this function will return NULL.
653 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
654 const struct v4l2_ctrl_ops *ops,
655 u32 id, u8 max, u64 mask, u8 def);
658 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
659 * with driver specific menu.
661 * @hdl: The control handler.
662 * @ops: The control ops.
663 * @id: The control ID.
664 * @max: The control's maximum value.
665 * @mask: The control's skip mask for menu controls. This makes it
666 * easy to skip menu items that are not valid. If bit X is set,
667 * then menu item X is skipped. Of course, this only works for
668 * menus with <= 64 menu items. There are no menus that come
669 * close to that number, so this is OK. Should we ever need more,
670 * then this will have to be extended to a bit array.
671 * @def: The control's default value.
672 * @qmenu: The new menu.
674 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
675 * menu of this control.
678 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
679 const struct v4l2_ctrl_ops *ops,
682 const char * const *qmenu);
685 * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2
688 * @hdl: The control handler.
689 * @ops: The control ops.
690 * @id: The control ID.
691 * @p_def: The control's default value.
693 * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks
694 * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a
695 * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the
696 * compound control should be all zeroes.
699 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl,
700 const struct v4l2_ctrl_ops *ops,
702 const union v4l2_ctrl_ptr p_def);
705 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
707 * @hdl: The control handler.
708 * @ops: The control ops.
709 * @id: The control ID.
710 * @max: The control's maximum value.
711 * @def: The control's default value.
712 * @qmenu_int: The control's menu entries.
714 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionally
715 * takes as an argument an array of integers determining the menu items.
717 * If @id refers to a non-integer-menu control, then this function will
720 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
721 const struct v4l2_ctrl_ops *ops,
722 u32 id, u8 max, u8 def,
723 const s64 *qmenu_int);
726 * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
727 * used when adding a control handler.
729 * @ctrl: pointer to struct &v4l2_ctrl.
732 typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
735 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
738 * @hdl: The control handler.
739 * @add: The control handler whose controls you want to add to
740 * the @hdl control handler.
741 * @filter: This function will filter which controls should be added.
742 * @from_other_dev: If true, then the controls in @add were defined in another
745 * Does nothing if either of the two handlers is a NULL pointer.
746 * If @filter is NULL, then all controls are added. Otherwise only those
747 * controls for which @filter returns true will be added.
748 * In case of an error @hdl->error will be set to the error code (if it
749 * wasn't set already).
751 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
752 struct v4l2_ctrl_handler *add,
753 v4l2_ctrl_filter filter,
754 bool from_other_dev);
757 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
759 * @ctrl: The control that is filtered.
761 * This will return true for any controls that are valid for radio device
762 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
763 * transmitter class controls.
765 * This function is to be used with v4l2_ctrl_add_handler().
767 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
770 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
773 * @ncontrols: The number of controls in this cluster.
774 * @controls: The cluster control array of size @ncontrols.
776 void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
780 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
781 * to that cluster and set it up for autofoo/foo-type handling.
783 * @ncontrols: The number of controls in this cluster.
784 * @controls: The cluster control array of size @ncontrols. The first control
785 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
786 * @manual_val: The value for the first control in the cluster that equals the
788 * @set_volatile: If true, then all controls except the first auto control will
791 * Use for control groups where one control selects some automatic feature and
792 * the other controls are only active whenever the automatic feature is turned
793 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
794 * red and blue balance, etc.
796 * The behavior of such controls is as follows:
798 * When the autofoo control is set to automatic, then any manual controls
799 * are set to inactive and any reads will call g_volatile_ctrl (if the control
800 * was marked volatile).
802 * When the autofoo control is set to manual, then any manual controls will
803 * be marked active, and any reads will just return the current value without
804 * going through g_volatile_ctrl.
806 * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
807 * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
808 * if autofoo is in auto mode.
810 void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
811 struct v4l2_ctrl **controls,
812 u8 manual_val, bool set_volatile);
816 * v4l2_ctrl_find() - Find a control with the given ID.
818 * @hdl: The control handler.
819 * @id: The control ID to find.
821 * If @hdl == NULL this will return NULL as well. Will lock the handler so
822 * do not use from inside &v4l2_ctrl_ops.
824 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
827 * v4l2_ctrl_activate() - Make the control active or inactive.
828 * @ctrl: The control to (de)activate.
829 * @active: True if the control should become active.
831 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
832 * Does nothing if @ctrl == NULL.
833 * This will usually be called from within the s_ctrl op.
834 * The V4L2_EVENT_CTRL event will be generated afterwards.
836 * This function assumes that the control handler is locked.
838 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
841 * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab.
843 * @ctrl: The control to (de)activate.
844 * @grabbed: True if the control should become grabbed.
846 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
847 * Does nothing if @ctrl == NULL.
848 * The V4L2_EVENT_CTRL event will be generated afterwards.
849 * This will usually be called when starting or stopping streaming in the
852 * This function assumes that the control handler is locked by the caller.
854 void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
857 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
859 * @ctrl: The control to (de)activate.
860 * @grabbed: True if the control should become grabbed.
862 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
863 * Does nothing if @ctrl == NULL.
864 * The V4L2_EVENT_CTRL event will be generated afterwards.
865 * This will usually be called when starting or stopping streaming in the
868 * This function assumes that the control handler is not locked and will
869 * take the lock itself.
871 static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
876 v4l2_ctrl_lock(ctrl);
877 __v4l2_ctrl_grab(ctrl, grabbed);
878 v4l2_ctrl_unlock(ctrl);
882 *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
884 * @ctrl: The control to update.
885 * @min: The control's minimum value.
886 * @max: The control's maximum value.
887 * @step: The control's step value
888 * @def: The control's default value.
890 * Update the range of a control on the fly. This works for control types
891 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
892 * @step value is interpreted as a menu_skip_mask.
894 * An error is returned if one of the range arguments is invalid for this
897 * The caller is responsible for acquiring the control handler mutex on behalf
898 * of __v4l2_ctrl_modify_range().
900 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
901 s64 min, s64 max, u64 step, s64 def);
904 * v4l2_ctrl_modify_range() - Update the range of a control.
906 * @ctrl: The control to update.
907 * @min: The control's minimum value.
908 * @max: The control's maximum value.
909 * @step: The control's step value
910 * @def: The control's default value.
912 * Update the range of a control on the fly. This works for control types
913 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
914 * @step value is interpreted as a menu_skip_mask.
916 * An error is returned if one of the range arguments is invalid for this
919 * This function assumes that the control handler is not locked and will
920 * take the lock itself.
922 static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
923 s64 min, s64 max, u64 step, s64 def)
927 v4l2_ctrl_lock(ctrl);
928 rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
929 v4l2_ctrl_unlock(ctrl);
935 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
937 * @ctrl: The control.
938 * @notify: The callback function.
939 * @priv: The callback private handle, passed as argument to the callback.
941 * This function sets a callback function for the control. If @ctrl is NULL,
942 * then it will do nothing. If @notify is NULL, then the notify callback will
945 * There can be only one notify. If another already exists, then a WARN_ON
946 * will be issued and the function will do nothing.
948 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
952 * v4l2_ctrl_get_name() - Get the name of the control
954 * @id: The control ID.
956 * This function returns the name of the given control ID or NULL if it isn't
959 const char *v4l2_ctrl_get_name(u32 id);
962 * v4l2_ctrl_get_menu() - Get the menu string array of the control
964 * @id: The control ID.
966 * This function returns the NULL-terminated menu string array name of the
967 * given control ID or NULL if it isn't a known menu control.
969 const char * const *v4l2_ctrl_get_menu(u32 id);
972 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
974 * @id: The control ID.
975 * @len: The size of the integer array.
977 * This function returns the integer array of the given control ID or NULL if it
978 * if it isn't a known integer menu control.
980 const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
983 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
986 * @ctrl: The control.
988 * This returns the control's value safely by going through the control
989 * framework. This function will lock the control's handler, so it cannot be
990 * used from within the &v4l2_ctrl_ops functions.
992 * This function is for integer type controls only.
994 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
997 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
999 * @ctrl: The control.
1000 * @val: The new value.
1002 * This sets the control's new value safely by going through the control
1003 * framework. This function assumes the control's handler is already locked,
1004 * allowing it to be used from within the &v4l2_ctrl_ops functions.
1006 * This function is for integer type controls only.
1008 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
1011 * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
1013 * @ctrl: The control.
1014 * @val: The new value.
1016 * This sets the control's new value safely by going through the control
1017 * framework. This function will lock the control's handler, so it cannot be
1018 * used from within the &v4l2_ctrl_ops functions.
1020 * This function is for integer type controls only.
1022 static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
1026 v4l2_ctrl_lock(ctrl);
1027 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
1028 v4l2_ctrl_unlock(ctrl);
1034 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
1035 * from within a driver.
1037 * @ctrl: The control.
1039 * This returns the control's value safely by going through the control
1040 * framework. This function will lock the control's handler, so it cannot be
1041 * used from within the &v4l2_ctrl_ops functions.
1043 * This function is for 64-bit integer type controls only.
1045 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
1048 * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
1050 * @ctrl: The control.
1051 * @val: The new value.
1053 * This sets the control's new value safely by going through the control
1054 * framework. This function assumes the control's handler is already locked,
1055 * allowing it to be used from within the &v4l2_ctrl_ops functions.
1057 * This function is for 64-bit integer type controls only.
1059 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
1062 * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
1063 * from within a driver.
1065 * @ctrl: The control.
1066 * @val: The new value.
1068 * This sets the control's new value safely by going through the control
1069 * framework. This function will lock the control's handler, so it cannot be
1070 * used from within the &v4l2_ctrl_ops functions.
1072 * This function is for 64-bit integer type controls only.
1074 static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
1078 v4l2_ctrl_lock(ctrl);
1079 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
1080 v4l2_ctrl_unlock(ctrl);
1086 * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
1088 * @ctrl: The control.
1089 * @s: The new string.
1091 * This sets the control's new string safely by going through the control
1092 * framework. This function assumes the control's handler is already locked,
1093 * allowing it to be used from within the &v4l2_ctrl_ops functions.
1095 * This function is for string type controls only.
1097 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
1100 * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
1101 * from within a driver.
1103 * @ctrl: The control.
1104 * @s: The new string.
1106 * This sets the control's new string safely by going through the control
1107 * framework. This function will lock the control's handler, so it cannot be
1108 * used from within the &v4l2_ctrl_ops functions.
1110 * This function is for string type controls only.
1112 static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
1116 v4l2_ctrl_lock(ctrl);
1117 rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
1118 v4l2_ctrl_unlock(ctrl);
1124 * __v4l2_ctrl_s_ctrl_compound() - Unlocked variant to set a compound control
1126 * @ctrl: The control.
1127 * @type: The type of the data.
1128 * @p: The new compound payload.
1130 * This sets the control's new compound payload safely by going through the
1131 * control framework. This function assumes the control's handler is already
1132 * locked, allowing it to be used from within the &v4l2_ctrl_ops functions.
1134 * This function is for compound type controls only.
1136 int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
1137 enum v4l2_ctrl_type type, const void *p);
1140 * v4l2_ctrl_s_ctrl_compound() - Helper function to set a compound control
1141 * from within a driver.
1143 * @ctrl: The control.
1144 * @type: The type of the data.
1145 * @p: The new compound payload.
1147 * This sets the control's new compound payload safely by going through the
1148 * control framework. This function will lock the control's handler, so it
1149 * cannot be used from within the &v4l2_ctrl_ops functions.
1151 * This function is for compound type controls only.
1153 static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
1154 enum v4l2_ctrl_type type,
1159 v4l2_ctrl_lock(ctrl);
1160 rval = __v4l2_ctrl_s_ctrl_compound(ctrl, type, p);
1161 v4l2_ctrl_unlock(ctrl);
1166 /* Helper defines for area type controls */
1167 #define __v4l2_ctrl_s_ctrl_area(ctrl, area) \
1168 __v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
1169 #define v4l2_ctrl_s_ctrl_area(ctrl, area) \
1170 v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
1172 /* Internal helper functions that deal with control events. */
1173 extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
1176 * v4l2_ctrl_replace - Function to be used as a callback to
1177 * &struct v4l2_subscribed_event_ops replace\(\)
1179 * @old: pointer to struct &v4l2_event with the reported
1181 * @new: pointer to struct &v4l2_event with the modified
1184 void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
1187 * v4l2_ctrl_merge - Function to be used as a callback to
1188 * &struct v4l2_subscribed_event_ops merge(\)
1190 * @old: pointer to struct &v4l2_event with the reported
1192 * @new: pointer to struct &v4l2_event with the merged
1195 void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
1198 * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
1200 * @file: pointer to struct file
1201 * @fh: unused. Kept just to be compatible to the arguments expected by
1202 * &struct v4l2_ioctl_ops.vidioc_log_status.
1204 * Can be used as a vidioc_log_status function that just dumps all controls
1205 * associated with the filehandle.
1207 int v4l2_ctrl_log_status(struct file *file, void *fh);
1210 * v4l2_ctrl_subscribe_event - Subscribes to an event
1213 * @fh: pointer to struct v4l2_fh
1214 * @sub: pointer to &struct v4l2_event_subscription
1216 * Can be used as a vidioc_subscribe_event function that just subscribes
1219 int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
1220 const struct v4l2_event_subscription *sub);
1223 * v4l2_ctrl_poll - function to be used as a callback to the poll()
1224 * That just polls for control events.
1226 * @file: pointer to struct file
1227 * @wait: pointer to struct poll_table_struct
1229 __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
1232 * v4l2_ctrl_request_setup - helper function to apply control values in a request
1235 * @parent: The parent control handler ('priv' in media_request_object_find())
1237 * This is a helper function to call the control handler's s_ctrl callback with
1238 * the control values contained in the request. Do note that this approach of
1239 * applying control values in a request is only applicable to memory-to-memory
1242 int v4l2_ctrl_request_setup(struct media_request *req,
1243 struct v4l2_ctrl_handler *parent);
1246 * v4l2_ctrl_request_complete - Complete a control handler request object
1249 * @parent: The parent control handler ('priv' in media_request_object_find())
1251 * This function is to be called on each control handler that may have had a
1252 * request object associated with it, i.e. control handlers of a driver that
1253 * supports requests.
1255 * The function first obtains the values of any volatile controls in the control
1256 * handler and attach them to the request. Then, the function completes the
1259 void v4l2_ctrl_request_complete(struct media_request *req,
1260 struct v4l2_ctrl_handler *parent);
1263 * v4l2_ctrl_request_hdl_find - Find the control handler in the request
1266 * @parent: The parent control handler ('priv' in media_request_object_find())
1268 * This function finds the control handler in the request. It may return
1269 * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl()
1270 * with the returned handler pointer.
1272 * If the request is not in state VALIDATING or QUEUED, then this function
1273 * will always return NULL.
1275 * Note that in state VALIDATING the req_queue_mutex is held, so
1276 * no objects can be added or deleted from the request.
1278 * In state QUEUED it is the driver that will have to ensure this.
1280 struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
1281 struct v4l2_ctrl_handler *parent);
1284 * v4l2_ctrl_request_hdl_put - Put the control handler
1286 * @hdl: Put this control handler
1288 * This function released the control handler previously obtained from'
1289 * v4l2_ctrl_request_hdl_find().
1291 static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl)
1294 media_request_object_put(&hdl->req_obj);
1298 * v4l2_ctrl_request_hdl_ctrl_find() - Find a control with the given ID.
1300 * @hdl: The control handler from the request.
1301 * @id: The ID of the control to find.
1303 * This function returns a pointer to the control if this control is
1304 * part of the request or NULL otherwise.
1307 v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
1309 /* Helpers for ioctl_ops */
1312 * v4l2_queryctrl - Helper function to implement
1313 * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
1315 * @hdl: pointer to &struct v4l2_ctrl_handler
1316 * @qc: pointer to &struct v4l2_queryctrl
1318 * If hdl == NULL then they will all return -EINVAL.
1320 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
1323 * v4l2_query_ext_ctrl - Helper function to implement
1324 * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
1326 * @hdl: pointer to &struct v4l2_ctrl_handler
1327 * @qc: pointer to &struct v4l2_query_ext_ctrl
1329 * If hdl == NULL then they will all return -EINVAL.
1331 int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
1332 struct v4l2_query_ext_ctrl *qc);
1335 * v4l2_querymenu - Helper function to implement
1336 * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
1338 * @hdl: pointer to &struct v4l2_ctrl_handler
1339 * @qm: pointer to &struct v4l2_querymenu
1341 * If hdl == NULL then they will all return -EINVAL.
1343 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
1346 * v4l2_g_ctrl - Helper function to implement
1347 * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
1349 * @hdl: pointer to &struct v4l2_ctrl_handler
1350 * @ctrl: pointer to &struct v4l2_control
1352 * If hdl == NULL then they will all return -EINVAL.
1354 int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
1357 * v4l2_s_ctrl - Helper function to implement
1358 * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
1360 * @fh: pointer to &struct v4l2_fh
1361 * @hdl: pointer to &struct v4l2_ctrl_handler
1363 * @ctrl: pointer to &struct v4l2_control
1365 * If hdl == NULL then they will all return -EINVAL.
1367 int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
1368 struct v4l2_control *ctrl);
1371 * v4l2_g_ext_ctrls - Helper function to implement
1372 * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1374 * @hdl: pointer to &struct v4l2_ctrl_handler
1375 * @vdev: pointer to &struct video_device
1376 * @mdev: pointer to &struct media_device
1377 * @c: pointer to &struct v4l2_ext_controls
1379 * If hdl == NULL then they will all return -EINVAL.
1381 int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
1382 struct media_device *mdev, struct v4l2_ext_controls *c);
1385 * v4l2_try_ext_ctrls - Helper function to implement
1386 * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1388 * @hdl: pointer to &struct v4l2_ctrl_handler
1389 * @vdev: pointer to &struct video_device
1390 * @mdev: pointer to &struct media_device
1391 * @c: pointer to &struct v4l2_ext_controls
1393 * If hdl == NULL then they will all return -EINVAL.
1395 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1396 struct video_device *vdev,
1397 struct media_device *mdev,
1398 struct v4l2_ext_controls *c);
1401 * v4l2_s_ext_ctrls - Helper function to implement
1402 * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1404 * @fh: pointer to &struct v4l2_fh
1405 * @hdl: pointer to &struct v4l2_ctrl_handler
1406 * @vdev: pointer to &struct video_device
1407 * @mdev: pointer to &struct media_device
1408 * @c: pointer to &struct v4l2_ext_controls
1410 * If hdl == NULL then they will all return -EINVAL.
1412 int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
1413 struct video_device *vdev,
1414 struct media_device *mdev,
1415 struct v4l2_ext_controls *c);
1418 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
1419 * as a &struct v4l2_subdev_core_ops subscribe_event function
1420 * that just subscribes control events.
1422 * @sd: pointer to &struct v4l2_subdev
1423 * @fh: pointer to &struct v4l2_fh
1424 * @sub: pointer to &struct v4l2_event_subscription
1426 int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1427 struct v4l2_event_subscription *sub);
1430 * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
1433 * @sd: pointer to &struct v4l2_subdev
1435 int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
1438 * v4l2_ctrl_new_fwnode_properties() - Register controls for the device
1441 * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on
1442 * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with
1443 * @p: pointer to &struct v4l2_fwnode_device_properties
1445 * This function registers controls associated to device properties, using the
1446 * property values contained in @p parameter, if the property has been set to
1449 * Currently the following v4l2 controls are parsed and registered:
1450 * - V4L2_CID_CAMERA_ORIENTATION
1451 * - V4L2_CID_CAMERA_SENSOR_ROTATION;
1453 * Controls already registered by the caller with the @hdl control handler are
1454 * not overwritten. Callers should register the controls they want to handle
1455 * themselves before calling this function.
1457 * Return: 0 on success, a negative error code on failure.
1459 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
1460 const struct v4l2_ctrl_ops *ctrl_ops,
1461 const struct v4l2_fwnode_device_properties *p);