Merge tag 'hyperv-next-signed-20221009' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / include / media / v4l2-ctrls.h
CommitLineData
c942fddf 1/* SPDX-License-Identifier: GPL-2.0-or-later */
0996517c 2/*
8ec4bee7
MCC
3 * V4L2 controls support header.
4 *
5 * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
0996517c
HV
6 */
7
8#ifndef _V4L2_CTRLS_H
9#define _V4L2_CTRLS_H
10
11#include <linux/list.h>
a19dec6e 12#include <linux/mutex.h>
01c40c04 13#include <linux/videodev2.h>
52beeddb 14#include <media/media-request.h>
0996517c
HV
15
16/* forward references */
528f0f78 17struct file;
ae6ff16c
JM
18struct poll_table_struct;
19struct v4l2_ctrl;
0996517c 20struct v4l2_ctrl_handler;
eb5b16ef 21struct v4l2_ctrl_helper;
ae6ff16c 22struct v4l2_fh;
e0a36063 23struct v4l2_fwnode_device_properties;
0996517c 24struct v4l2_subdev;
77068d36 25struct v4l2_subscribed_event;
ae6ff16c 26struct video_device;
0996517c 27
8c2721d5
MCC
28/**
29 * union v4l2_ctrl_ptr - A pointer to a control value.
c27bb30e
PK
30 * @p_s32: Pointer to a 32-bit signed value.
31 * @p_s64: Pointer to a 64-bit signed value.
32 * @p_u8: Pointer to a 8-bit unsigned value.
33 * @p_u16: Pointer to a 16-bit unsigned value.
34 * @p_u32: Pointer to a 32-bit unsigned value.
35 * @p_char: Pointer to a string.
f329e21e
EG
36 * @p_mpeg2_sequence: Pointer to a MPEG2 sequence structure.
37 * @p_mpeg2_picture: Pointer to a MPEG2 picture structure.
118f3e15 38 * @p_mpeg2_quantisation: Pointer to a MPEG2 quantisation data structure.
2495f39c 39 * @p_fwht_params: Pointer to a FWHT stateless parameters structure.
1f0545d3
PO
40 * @p_h264_sps: Pointer to a struct v4l2_ctrl_h264_sps.
41 * @p_h264_pps: Pointer to a struct v4l2_ctrl_h264_pps.
42 * @p_h264_scaling_matrix: Pointer to a struct v4l2_ctrl_h264_scaling_matrix.
43 * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params.
44 * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params.
eb44c6c9 45 * @p_h264_pred_weights: Pointer to a struct v4l2_ctrl_h264_pred_weights.
d04c114e 46 * @p_vp8_frame: Pointer to a VP8 frame params structure.
b88dbe38
AP
47 * @p_vp9_compressed_hdr_probs: Pointer to a VP9 frame compressed header probs structure.
48 * @p_vp9_frame: Pointer to a VP9 frame params structure.
256fa392
PK
49 * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure.
50 * @p_hevc_pps: Pointer to an HEVC picture parameter set structure.
51 * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
1ad0de78
SV
52 * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure.
53 * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure.
d1dc4937 54 * @p_area: Pointer to an area.
c27bb30e 55 * @p: Pointer to a compound value.
f1bd5eae 56 * @p_const: Pointer to a constant compound value.
0176077a
HV
57 */
58union v4l2_ctrl_ptr {
59 s32 *p_s32;
60 s64 *p_s64;
dda4a4d5
HV
61 u8 *p_u8;
62 u16 *p_u16;
811c5081 63 u32 *p_u32;
0176077a 64 char *p_char;
f329e21e
EG
65 struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;
66 struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
118f3e15 67 struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quantisation;
2495f39c 68 struct v4l2_ctrl_fwht_params *p_fwht_params;
1f0545d3
PO
69 struct v4l2_ctrl_h264_sps *p_h264_sps;
70 struct v4l2_ctrl_h264_pps *p_h264_pps;
71 struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
72 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
73 struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
eb44c6c9 74 struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
d04c114e 75 struct v4l2_ctrl_vp8_frame *p_vp8_frame;
256fa392
PK
76 struct v4l2_ctrl_hevc_sps *p_hevc_sps;
77 struct v4l2_ctrl_hevc_pps *p_hevc_pps;
78 struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
b88dbe38
AP
79 struct v4l2_ctrl_vp9_compressed_hdr *p_vp9_compressed_hdr_probs;
80 struct v4l2_ctrl_vp9_frame *p_vp9_frame;
1ad0de78
SV
81 struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;
82 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
d1dc4937 83 struct v4l2_area *p_area;
0176077a 84 void *p;
f1bd5eae 85 const void *p_const;
0176077a
HV
86};
87
2e8db63e
RRD
88/**
89 * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a
90 * void pointer
91 * @ptr: The void pointer
92 */
93static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr)
94{
95 union v4l2_ctrl_ptr p = { .p = ptr };
96
97 return p;
98}
99
8c2721d5
MCC
100/**
101 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
8ec4bee7 102 *
8c2721d5
MCC
103 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
104 * for volatile (and usually read-only) controls such as a control
105 * that returns the current signal strength which changes
106 * continuously.
107 * If not set, then the currently cached value will be returned.
108 * @try_ctrl: Test whether the control's value is valid. Only relevant when
109 * the usual min/max/step checks are not sufficient.
110 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
111 * ctrl->handler->lock is held when these ops are called, so no
112 * one else can access controls owned by that handler.
113 */
0996517c
HV
114struct v4l2_ctrl_ops {
115 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
116 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
117 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
118};
119
8c2721d5
MCC
120/**
121 * struct v4l2_ctrl_type_ops - The control type operations that the driver
8ec4bee7 122 * has to provide.
8c2721d5
MCC
123 *
124 * @equal: return true if both values are equal.
125 * @init: initialize the value.
126 * @log: log the value.
8ec4bee7
MCC
127 * @validate: validate the value. Return 0 on success and a negative value
128 * otherwise.
8c2721d5 129 */
0176077a 130struct v4l2_ctrl_type_ops {
6b1aaa68 131 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 elems,
0176077a
HV
132 union v4l2_ctrl_ptr ptr1,
133 union v4l2_ctrl_ptr ptr2);
6b1aaa68 134 void (*init)(const struct v4l2_ctrl *ctrl, u32 from_idx, u32 tot_elems,
0176077a
HV
135 union v4l2_ctrl_ptr ptr);
136 void (*log)(const struct v4l2_ctrl *ctrl);
6b1aaa68 137 int (*validate)(const struct v4l2_ctrl *ctrl, u32 elems,
0176077a
HV
138 union v4l2_ctrl_ptr ptr);
139};
140
2257e180
MCC
141/**
142 * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
143 * that should be called when a control value has changed.
144 *
145 * @ctrl: pointer to struct &v4l2_ctrl
146 * @priv: control private data
147 *
148 * This typedef definition is used as an argument to v4l2_ctrl_notify()
149 * and as an argument at struct &v4l2_ctrl_handler.
150 */
8ac7a949
HV
151typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
152
8c2721d5
MCC
153/**
154 * struct v4l2_ctrl - The control structure.
8ec4bee7 155 *
8c2721d5
MCC
156 * @node: The list node.
157 * @ev_subs: The list of control event subscriptions.
158 * @handler: The handler that owns the control.
159 * @cluster: Point to start of cluster array.
160 * @ncontrols: Number of controls in cluster array.
161 * @done: Internal flag: set for each processed control.
162 * @is_new: Set when the user specified a new value for this control. It
8ec4bee7 163 * is also set when called from v4l2_ctrl_handler_setup(). Drivers
8c2721d5
MCC
164 * should never set this flag.
165 * @has_changed: Set when the current value differs from the new value. Drivers
166 * should never use this flag.
167 * @is_private: If set, then this control is private to its handler and it
168 * will not be added to any other handlers. Drivers can set
169 * this flag.
170 * @is_auto: If set, then this control selects whether the other cluster
171 * members are in 'automatic' mode or 'manual' mode. This is
172 * used for autogain/gain type clusters. Drivers should never
173 * set this flag directly.
174 * @is_int: If set, then this control has a simple integer value (i.e. it
175 * uses ctrl->val).
8ec4bee7
MCC
176 * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
177 * @is_ptr: If set, then this control is an array and/or has type >=
178 * %V4L2_CTRL_COMPOUND_TYPES
179 * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
8c2721d5
MCC
180 * v4l2_ext_control uses field p to point to the data.
181 * @is_array: If set, then this control contains an N-dimensional array.
fb582cba
HV
182 * @is_dyn_array: If set, then this control contains a dynamically sized 1-dimensional array.
183 * If this is set, then @is_array is also set.
8c2721d5
MCC
184 * @has_volatiles: If set, then one or more members of the cluster are volatile.
185 * Drivers should never touch this flag.
186 * @call_notify: If set, then call the handler's notify function whenever the
187 * control's value changes.
188 * @manual_mode_value: If the is_auto flag is set, then this is the value
189 * of the auto control that determines if that control is in
190 * manual mode. So if the value of the auto control equals this
191 * value, then the whole cluster is in manual mode. Drivers should
192 * never set this flag directly.
193 * @ops: The control ops.
194 * @type_ops: The control type ops.
195 * @id: The control ID.
196 * @name: The control name.
197 * @type: The control type.
198 * @minimum: The control's minimum value.
199 * @maximum: The control's maximum value.
200 * @default_value: The control's default value.
201 * @step: The control's step value for non-menu controls.
202 * @elems: The number of elements in the N-dimensional array.
203 * @elem_size: The size in bytes of the control.
fb582cba
HV
204 * @new_elems: The number of elements in p_new. This is the same as @elems,
205 * except for dynamic arrays. In that case it is in the range of
5f2c5c69 206 * 1 to @p_array_alloc_elems.
8c2721d5
MCC
207 * @dims: The size of each dimension.
208 * @nr_of_dims:The number of dimensions in @dims.
209 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
210 * easy to skip menu items that are not valid. If bit X is set,
211 * then menu item X is skipped. Of course, this only works for
212 * menus with <= 32 menu items. There are no menus that come
213 * close to that number, so this is OK. Should we ever need more,
214 * then this will have to be extended to a u64 or a bit array.
215 * @qmenu: A const char * array for all menu items. Array entries that are
216 * empty strings ("") correspond to non-existing menu items (this
217 * is in addition to the menu_skip_mask above). The last entry
218 * must be NULL.
20139f18
MCC
219 * Used only if the @type is %V4L2_CTRL_TYPE_MENU.
220 * @qmenu_int: A 64-bit integer array for with integer menu items.
221 * The size of array must be equal to the menu size, e. g.:
222 * :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
223 * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
8c2721d5 224 * @flags: The control's flags.
8c2721d5
MCC
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.
5f2c5c69
HV
230 * @p_array: Pointer to the allocated array. Only valid if @is_array is true.
231 * @p_array_alloc_elems: The number of elements in the allocated
232 * array for both the cur and new values. So @p_array is actually
233 * sized for 2 * @p_array_alloc_elems * @elem_size. Only valid if
234 * @is_array is true.
fb582cba
HV
235 * @cur: Structure to store the current value.
236 * @cur.val: The control's current value, if the @type is represented via
237 * a u32 integer (see &enum v4l2_ctrl_type).
238 * @val: The control's new s32 value.
b35d6c02
RRD
239 * @p_def: The control's default value represented via a union which
240 * provides a standard way of accessing control types
241 * through a pointer (for compound controls only).
bf7b7048 242 * @p_cur: The control's current value represented via a union which
7dc87919
MCC
243 * provides a standard way of accessing control types
244 * through a pointer.
bf7b7048 245 * @p_new: The control's new value represented via a union which provides
7dc87919
MCC
246 * a standard way of accessing control types
247 * through a pointer.
8c2721d5 248 */
0996517c
HV
249struct v4l2_ctrl {
250 /* Administrative fields */
251 struct list_head node;
77068d36 252 struct list_head ev_subs;
0996517c
HV
253 struct v4l2_ctrl_handler *handler;
254 struct v4l2_ctrl **cluster;
8ec4bee7
MCC
255 unsigned int ncontrols;
256
0996517c
HV
257 unsigned int done:1;
258
2a863793 259 unsigned int is_new:1;
9ea1b7a4 260 unsigned int has_changed:1;
0996517c 261 unsigned int is_private:1;
72d877ca 262 unsigned int is_auto:1;
d9a25471
HV
263 unsigned int is_int:1;
264 unsigned int is_string:1;
265 unsigned int is_ptr:1;
998e7659 266 unsigned int is_array:1;
fb582cba 267 unsigned int is_dyn_array:1;
5626b8c7 268 unsigned int has_volatiles:1;
8ac7a949 269 unsigned int call_notify:1;
82a7c049 270 unsigned int manual_mode_value:8;
0996517c
HV
271
272 const struct v4l2_ctrl_ops *ops;
0176077a 273 const struct v4l2_ctrl_type_ops *type_ops;
0996517c
HV
274 u32 id;
275 const char *name;
276 enum v4l2_ctrl_type type;
0ba2aeb6 277 s64 minimum, maximum, default_value;
20d88eef 278 u32 elems;
d9a25471 279 u32 elem_size;
fb582cba 280 u32 new_elems;
20d88eef
HV
281 u32 dims[V4L2_CTRL_MAX_DIMS];
282 u32 nr_of_dims;
0996517c 283 union {
0ba2aeb6
HV
284 u64 step;
285 u64 menu_skip_mask;
0996517c 286 };
ce580fe5
SA
287 union {
288 const char * const *qmenu;
289 const s64 *qmenu_int;
290 };
0996517c 291 unsigned long flags;
d9a25471 292 void *priv;
5f2c5c69
HV
293 void *p_array;
294 u32 p_array_alloc_elems;
2a9ec373
HV
295 s32 val;
296 struct {
0996517c 297 s32 val;
d9a25471 298 } cur;
0176077a 299
b35d6c02 300 union v4l2_ctrl_ptr p_def;
0176077a
HV
301 union v4l2_ctrl_ptr p_new;
302 union v4l2_ctrl_ptr p_cur;
0996517c
HV
303};
304
8c2721d5
MCC
305/**
306 * struct v4l2_ctrl_ref - The control reference.
8ec4bee7 307 *
8c2721d5
MCC
308 * @node: List node for the sorted list.
309 * @next: Single-link list node for the hash.
310 * @ctrl: The actual control information.
8ec4bee7 311 * @helper: Pointer to helper struct. Used internally in
fb91161a 312 * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
da1b1aea
HV
313 * @from_other_dev: If true, then @ctrl was defined in another
314 * device than the &struct v4l2_ctrl_handler.
6fa6f831
HV
315 * @req_done: Internal flag: if the control handler containing this control
316 * reference is bound to a media request, then this is set when
317 * the control has been applied. This prevents applying controls
318 * from a cluster with multiple controls twice (when the first
319 * control of a cluster is applied, they all are).
fb582cba 320 * @p_req_valid: If set, then p_req contains the control value for the request.
7392d87a
HV
321 * @p_req_array_enomem: If set, then p_req is invalid since allocating space for
322 * an array failed. Attempting to read this value shall
323 * result in ENOMEM. Only valid if ctrl->is_array is true.
324 * @p_req_array_alloc_elems: The number of elements allocated for the
325 * array. Only valid if @p_req_valid and ctrl->is_array are
fb582cba
HV
326 * true.
327 * @p_req_elems: The number of elements in @p_req. This is the same as
328 * ctrl->elems, except for dynamic arrays. In that case it is in
7392d87a 329 * the range of 1 to @p_req_array_alloc_elems. Only valid if
fb582cba 330 * @p_req_valid is true.
52beeddb
HV
331 * @p_req: If the control handler containing this control reference
332 * is bound to a media request, then this points to the
ac34b79d 333 * value of the control that must be applied when the request
52beeddb 334 * is executed, or to the value of the control at the time
fb582cba 335 * that the request was completed. If @p_req_valid is false,
ac34b79d
HV
336 * then this control was never set for this request and the
337 * control will not be updated when this request is applied.
8c2721d5
MCC
338 *
339 * Each control handler has a list of these refs. The list_head is used to
340 * keep a sorted-by-control-ID list of all controls, while the next pointer
341 * is used to link the control in the hash's bucket.
342 */
0996517c
HV
343struct v4l2_ctrl_ref {
344 struct list_head node;
345 struct v4l2_ctrl_ref *next;
346 struct v4l2_ctrl *ctrl;
eb5b16ef 347 struct v4l2_ctrl_helper *helper;
da1b1aea 348 bool from_other_dev;
6fa6f831 349 bool req_done;
fb582cba 350 bool p_req_valid;
7392d87a
HV
351 bool p_req_array_enomem;
352 u32 p_req_array_alloc_elems;
fb582cba 353 u32 p_req_elems;
52beeddb 354 union v4l2_ctrl_ptr p_req;
0996517c
HV
355};
356
8c2721d5
MCC
357/**
358 * struct v4l2_ctrl_handler - The control handler keeps track of all the
8ec4bee7
MCC
359 * controls: both the controls owned by the handler and those inherited
360 * from other handlers.
361 *
8c2721d5
MCC
362 * @_lock: Default for "lock".
363 * @lock: Lock to control access to this handler and its controls.
364 * May be replaced by the user right after init.
365 * @ctrls: The list of controls owned by this handler.
366 * @ctrl_refs: The list of control references.
367 * @cached: The last found control reference. It is common that the same
368 * control is needed multiple times, so this is a simple
369 * optimization.
370 * @buckets: Buckets for the hashing. Allows for quick control lookup.
8ec4bee7
MCC
371 * @notify: A notify callback that is called whenever the control changes
372 * value.
8c2721d5
MCC
373 * Note that the handler's lock is held when the notify function
374 * is called!
375 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
376 * @nr_of_buckets: Total number of buckets in the array.
377 * @error: The error code of the first failed control addition.
6fa6f831
HV
378 * @request_is_queued: True if the request was queued.
379 * @requests: List to keep track of open control handler request objects.
ac34b79d 380 * For the parent control handler (@req_obj.ops == NULL) this
6fa6f831
HV
381 * is the list header. When the parent control handler is
382 * removed, it has to unbind and put all these requests since
383 * they refer to the parent.
384 * @requests_queued: List of the queued requests. This determines the order
385 * in which these controls are applied. Once the request is
386 * completed it is removed from this list.
52beeddb
HV
387 * @req_obj: The &struct media_request_object, used to link into a
388 * &struct media_request. This request object has a refcount.
8c2721d5 389 */
0996517c 390struct v4l2_ctrl_handler {
77e7c4e6
SA
391 struct mutex _lock;
392 struct mutex *lock;
0996517c
HV
393 struct list_head ctrls;
394 struct list_head ctrl_refs;
395 struct v4l2_ctrl_ref *cached;
396 struct v4l2_ctrl_ref **buckets;
8ac7a949
HV
397 v4l2_ctrl_notify_fnc notify;
398 void *notify_priv;
0996517c
HV
399 u16 nr_of_buckets;
400 int error;
6fa6f831
HV
401 bool request_is_queued;
402 struct list_head requests;
403 struct list_head requests_queued;
52beeddb 404 struct media_request_object req_obj;
0996517c
HV
405};
406
8c2721d5
MCC
407/**
408 * struct v4l2_ctrl_config - Control configuration structure.
8ec4bee7 409 *
8c2721d5
MCC
410 * @ops: The control ops.
411 * @type_ops: The control type ops. Only needed for compound controls.
412 * @id: The control ID.
413 * @name: The control name.
414 * @type: The control type.
415 * @min: The control's minimum value.
416 * @max: The control's maximum value.
417 * @step: The control's step value for non-menu controls.
8ec4bee7 418 * @def: The control's default value.
3b98a21a 419 * @p_def: The control's default value for compound controls.
8c2721d5
MCC
420 * @dims: The size of each dimension.
421 * @elem_size: The size in bytes of the control.
422 * @flags: The control's flags.
423 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
424 * easy to skip menu items that are not valid. If bit X is set,
425 * then menu item X is skipped. Of course, this only works for
426 * menus with <= 64 menu items. There are no menus that come
427 * close to that number, so this is OK. Should we ever need more,
428 * then this will have to be extended to a bit array.
429 * @qmenu: A const char * array for all menu items. Array entries that are
430 * empty strings ("") correspond to non-existing menu items (this
431 * is in addition to the menu_skip_mask above). The last entry
432 * must be NULL.
7dc87919 433 * @qmenu_int: A const s64 integer array for all menu items of the type
8ec4bee7 434 * V4L2_CTRL_TYPE_INTEGER_MENU.
8c2721d5
MCC
435 * @is_private: If set, then this control is private to its handler and it
436 * will not be added to any other handlers.
437 */
0996517c
HV
438struct v4l2_ctrl_config {
439 const struct v4l2_ctrl_ops *ops;
0176077a 440 const struct v4l2_ctrl_type_ops *type_ops;
0996517c
HV
441 u32 id;
442 const char *name;
443 enum v4l2_ctrl_type type;
0ba2aeb6
HV
444 s64 min;
445 s64 max;
446 u64 step;
447 s64 def;
3b98a21a 448 union v4l2_ctrl_ptr p_def;
20d88eef 449 u32 dims[V4L2_CTRL_MAX_DIMS];
d9a25471 450 u32 elem_size;
0996517c 451 u32 flags;
0ba2aeb6 452 u64 menu_skip_mask;
513521ea 453 const char * const *qmenu;
ce580fe5 454 const s64 *qmenu_int;
0996517c 455 unsigned int is_private:1;
0996517c
HV
456};
457
8ec4bee7
MCC
458/**
459 * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
460 *
461 * @id: ID of the control
67c672ec
MCC
462 * @name: pointer to be filled with a string with the name of the control
463 * @type: pointer for storing the type of the control
464 * @min: pointer for storing the minimum value for the control
465 * @max: pointer for storing the maximum value for the control
466 * @step: pointer for storing the control step
467 * @def: pointer for storing the default value for the control
468 * @flags: pointer for storing the flags to be used on the control
8c2721d5
MCC
469 *
470 * This works for all standard V4L2 controls.
471 * For non-standard controls it will only fill in the given arguments
67c672ec 472 * and @name content will be set to %NULL.
8c2721d5
MCC
473 *
474 * This function will overwrite the contents of @name, @type and @flags.
475 * The contents of @min, @max, @step and @def may be modified depending on
476 * the type.
477 *
8ec4bee7
MCC
478 * .. note::
479 *
480 * Do not use in drivers! It is used internally for backwards compatibility
481 * control handling only. Once all drivers are converted to use the new
482 * control framework this function will no longer be exported.
8c2721d5 483 */
0996517c 484void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
0ba2aeb6 485 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
0996517c
HV
486
487
8c2721d5
MCC
488/**
489 * v4l2_ctrl_handler_init_class() - Initialize the control handler.
490 * @hdl: The control handler.
491 * @nr_of_controls_hint: A hint of how many controls this handler is
492 * expected to refer to. This is the total number, so including
493 * any inherited controls. It doesn't have to be precise, but if
494 * it is way off, then you either waste memory (too many buckets
495 * are allocated) or the control lookup becomes slower (not enough
496 * buckets are allocated, so there are more slow list lookups).
497 * It will always work, though.
498 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
499 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
500 *
2257e180
MCC
501 * .. attention::
502 *
503 * Never use this call directly, always use the v4l2_ctrl_handler_init()
504 * macro that hides the @key and @name arguments.
8c2721d5 505 *
2257e180
MCC
506 * Return: returns an error if the buckets could not be allocated. This
507 * error will also be stored in @hdl->error.
8c2721d5 508 */
6cd247ef 509int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
8ec4bee7 510 unsigned int nr_of_controls_hint,
6cd247ef
AW
511 struct lock_class_key *key, const char *name);
512
513#ifdef CONFIG_LOCKDEP
2257e180
MCC
514
515/**
e383ce07
MCC
516 * v4l2_ctrl_handler_init - helper function to create a static struct
517 * &lock_class_key and calls v4l2_ctrl_handler_init_class()
2257e180
MCC
518 *
519 * @hdl: The control handler.
520 * @nr_of_controls_hint: A hint of how many controls this handler is
521 * expected to refer to. This is the total number, so including
522 * any inherited controls. It doesn't have to be precise, but if
523 * it is way off, then you either waste memory (too many buckets
524 * are allocated) or the control lookup becomes slower (not enough
525 * buckets are allocated, so there are more slow list lookups).
526 * It will always work, though.
527 *
528 * This helper function creates a static struct &lock_class_key and
529 * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
530 * validador.
531 *
532 * Use this helper function to initialize a control handler.
533 */
6cd247ef
AW
534#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
535( \
536 ({ \
537 static struct lock_class_key _key; \
538 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
539 &_key, \
540 KBUILD_BASENAME ":" \
541 __stringify(__LINE__) ":" \
542 "(" #hdl ")->_lock"); \
543 }) \
544)
545#else
546#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
547 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
548#endif
0996517c 549
8c2721d5
MCC
550/**
551 * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
552 * the control list.
553 * @hdl: The control handler.
554 *
555 * Does nothing if @hdl == NULL.
556 */
0996517c
HV
557void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
558
8c2721d5
MCC
559/**
560 * v4l2_ctrl_lock() - Helper function to lock the handler
561 * associated with the control.
562 * @ctrl: The control to lock.
563 */
605b3840
SA
564static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
565{
566 mutex_lock(ctrl->handler->lock);
567}
568
8c2721d5
MCC
569/**
570 * v4l2_ctrl_unlock() - Helper function to unlock the handler
571 * associated with the control.
572 * @ctrl: The control to unlock.
573 */
605b3840
SA
574static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
575{
576 mutex_unlock(ctrl->handler->lock);
577}
578
cc0140e2
SA
579/**
580 * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
581 * to the handler to initialize the hardware to the current control values. The
582 * caller is responsible for acquiring the control handler mutex on behalf of
583 * __v4l2_ctrl_handler_setup().
584 * @hdl: The control handler.
585 *
586 * Button controls will be skipped, as are read-only controls.
587 *
588 * If @hdl == NULL, then this just returns 0.
589 */
590int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
591
8c2721d5
MCC
592/**
593 * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
594 * to the handler to initialize the hardware to the current control values.
595 * @hdl: The control handler.
596 *
597 * Button controls will be skipped, as are read-only controls.
598 *
599 * If @hdl == NULL, then this just returns 0.
600 */
0996517c
HV
601int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
602
8c2721d5
MCC
603/**
604 * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
605 * @hdl: The control handler.
606 * @prefix: The prefix to use when logging the control values. If the
607 * prefix does not end with a space, then ": " will be added
608 * after the prefix. If @prefix == NULL, then no prefix will be
609 * used.
610 *
611 * For use with VIDIOC_LOG_STATUS.
612 *
613 * Does nothing if @hdl == NULL.
614 */
0996517c
HV
615void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
616 const char *prefix);
617
8c2721d5
MCC
618/**
619 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
8ec4bee7
MCC
620 * control.
621 *
8c2721d5
MCC
622 * @hdl: The control handler.
623 * @cfg: The control's configuration data.
624 * @priv: The control's driver-specific private data.
625 *
626 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
627 * and @hdl->error is set to the error code (if it wasn't set already).
628 */
0996517c 629struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
630 const struct v4l2_ctrl_config *cfg,
631 void *priv);
0996517c 632
8c2721d5 633/**
8ec4bee7
MCC
634 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
635 * control.
636 *
8c2721d5
MCC
637 * @hdl: The control handler.
638 * @ops: The control ops.
8ec4bee7 639 * @id: The control ID.
8c2721d5
MCC
640 * @min: The control's minimum value.
641 * @max: The control's maximum value.
642 * @step: The control's step value
8ec4bee7 643 * @def: The control's default value.
8c2721d5
MCC
644 *
645 * If the &v4l2_ctrl struct could not be allocated, or the control
646 * ID is not known, then NULL is returned and @hdl->error is set to the
647 * appropriate error code (if it wasn't set already).
648 *
649 * If @id refers to a menu control, then this function will return NULL.
650 *
651 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
652 */
0996517c 653struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
654 const struct v4l2_ctrl_ops *ops,
655 u32 id, s64 min, s64 max, u64 step,
656 s64 def);
0996517c 657
8c2721d5 658/**
8ec4bee7
MCC
659 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
660 * menu control.
661 *
8c2721d5
MCC
662 * @hdl: The control handler.
663 * @ops: The control ops.
8ec4bee7 664 * @id: The control ID.
8c2721d5 665 * @max: The control's maximum value.
8ec4bee7 666 * @mask: The control's skip mask for menu controls. This makes it
8c2721d5
MCC
667 * easy to skip menu items that are not valid. If bit X is set,
668 * then menu item X is skipped. Of course, this only works for
669 * menus with <= 64 menu items. There are no menus that come
670 * close to that number, so this is OK. Should we ever need more,
671 * then this will have to be extended to a bit array.
8ec4bee7 672 * @def: The control's default value.
8c2721d5
MCC
673 *
674 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
675 * determines which menu items are to be skipped.
676 *
677 * If @id refers to a non-menu control, then this function will return NULL.
678 */
0996517c 679struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
680 const struct v4l2_ctrl_ops *ops,
681 u32 id, u8 max, u64 mask, u8 def);
0996517c 682
8c2721d5
MCC
683/**
684 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
8ec4bee7
MCC
685 * with driver specific menu.
686 *
8c2721d5
MCC
687 * @hdl: The control handler.
688 * @ops: The control ops.
689 * @id: The control ID.
690 * @max: The control's maximum value.
691 * @mask: The control's skip mask for menu controls. This makes it
692 * easy to skip menu items that are not valid. If bit X is set,
693 * then menu item X is skipped. Of course, this only works for
694 * menus with <= 64 menu items. There are no menus that come
695 * close to that number, so this is OK. Should we ever need more,
696 * then this will have to be extended to a bit array.
697 * @def: The control's default value.
698 * @qmenu: The new menu.
699 *
700 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
701 * menu of this control.
702 *
703 */
117a711a 704struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
705 const struct v4l2_ctrl_ops *ops,
706 u32 id, u8 max,
707 u64 mask, u8 def,
708 const char * const *qmenu);
117a711a 709
b35d6c02
RRD
710/**
711 * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2
712 * compound control.
713 *
714 * @hdl: The control handler.
715 * @ops: The control ops.
716 * @id: The control ID.
717 * @p_def: The control's default value.
718 *
719 * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks
e51759f5
HV
720 * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a
721 * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the
722 * compound control should be all zeroes.
b35d6c02
RRD
723 *
724 */
725struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl,
726 const struct v4l2_ctrl_ops *ops,
727 u32 id,
728 const union v4l2_ctrl_ptr p_def);
729
8c2721d5
MCC
730/**
731 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
8ec4bee7 732 *
8c2721d5
MCC
733 * @hdl: The control handler.
734 * @ops: The control ops.
735 * @id: The control ID.
736 * @max: The control's maximum value.
737 * @def: The control's default value.
738 * @qmenu_int: The control's menu entries.
739 *
e907bf3c 740 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionally
8c2721d5
MCC
741 * takes as an argument an array of integers determining the menu items.
742 *
8ec4bee7
MCC
743 * If @id refers to a non-integer-menu control, then this function will
744 * return %NULL.
8c2721d5 745 */
515f3287 746struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
747 const struct v4l2_ctrl_ops *ops,
748 u32 id, u8 max, u8 def,
749 const s64 *qmenu_int);
515f3287 750
2257e180
MCC
751/**
752 * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
753 * used when adding a control handler.
754 *
755 * @ctrl: pointer to struct &v4l2_ctrl.
756 */
757
6d85d7d7
MCC
758typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
759
8c2721d5
MCC
760/**
761 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
8ec4bee7
MCC
762 * handler @hdl.
763 *
8c2721d5
MCC
764 * @hdl: The control handler.
765 * @add: The control handler whose controls you want to add to
766 * the @hdl control handler.
767 * @filter: This function will filter which controls should be added.
da1b1aea
HV
768 * @from_other_dev: If true, then the controls in @add were defined in another
769 * device than @hdl.
8c2721d5
MCC
770 *
771 * Does nothing if either of the two handlers is a NULL pointer.
772 * If @filter is NULL, then all controls are added. Otherwise only those
773 * controls for which @filter returns true will be added.
774 * In case of an error @hdl->error will be set to the error code (if it
775 * wasn't set already).
776 */
0996517c 777int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
34a6b7d0 778 struct v4l2_ctrl_handler *add,
da1b1aea
HV
779 v4l2_ctrl_filter filter,
780 bool from_other_dev);
0996517c 781
8c2721d5
MCC
782/**
783 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
8ec4bee7 784 *
8c2721d5
MCC
785 * @ctrl: The control that is filtered.
786 *
787 * This will return true for any controls that are valid for radio device
788 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
789 * transmitter class controls.
790 *
791 * This function is to be used with v4l2_ctrl_add_handler().
792 */
34a6b7d0 793bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
0996517c 794
8c2721d5 795/**
8ec4bee7
MCC
796 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
797 * to that cluster.
798 *
8c2721d5 799 * @ncontrols: The number of controls in this cluster.
8ec4bee7 800 * @controls: The cluster control array of size @ncontrols.
8c2721d5 801 */
8ec4bee7 802void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
0996517c
HV
803
804
8c2721d5 805/**
8ec4bee7
MCC
806 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
807 * to that cluster and set it up for autofoo/foo-type handling.
808 *
8c2721d5
MCC
809 * @ncontrols: The number of controls in this cluster.
810 * @controls: The cluster control array of size @ncontrols. The first control
811 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
812 * @manual_val: The value for the first control in the cluster that equals the
813 * manual setting.
814 * @set_volatile: If true, then all controls except the first auto control will
815 * be volatile.
816 *
817 * Use for control groups where one control selects some automatic feature and
818 * the other controls are only active whenever the automatic feature is turned
819 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
820 * red and blue balance, etc.
821 *
822 * The behavior of such controls is as follows:
823 *
824 * When the autofoo control is set to automatic, then any manual controls
825 * are set to inactive and any reads will call g_volatile_ctrl (if the control
826 * was marked volatile).
827 *
828 * When the autofoo control is set to manual, then any manual controls will
829 * be marked active, and any reads will just return the current value without
830 * going through g_volatile_ctrl.
831 *
2257e180
MCC
832 * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
833 * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
8c2721d5
MCC
834 * if autofoo is in auto mode.
835 */
8ec4bee7
MCC
836void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
837 struct v4l2_ctrl **controls,
838 u8 manual_val, bool set_volatile);
72d877ca
HV
839
840
8c2721d5
MCC
841/**
842 * v4l2_ctrl_find() - Find a control with the given ID.
8ec4bee7 843 *
8c2721d5
MCC
844 * @hdl: The control handler.
845 * @id: The control ID to find.
846 *
847 * If @hdl == NULL this will return NULL as well. Will lock the handler so
848 * do not use from inside &v4l2_ctrl_ops.
849 */
0996517c
HV
850struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
851
8c2721d5
MCC
852/**
853 * v4l2_ctrl_activate() - Make the control active or inactive.
854 * @ctrl: The control to (de)activate.
855 * @active: True if the control should become active.
856 *
857 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
858 * Does nothing if @ctrl == NULL.
859 * This will usually be called from within the s_ctrl op.
860 * The V4L2_EVENT_CTRL event will be generated afterwards.
861 *
862 * This function assumes that the control handler is locked.
863 */
0996517c
HV
864void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
865
7a9b109d
SA
866/**
867 * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab.
868 *
869 * @ctrl: The control to (de)activate.
870 * @grabbed: True if the control should become grabbed.
871 *
872 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
873 * Does nothing if @ctrl == NULL.
874 * The V4L2_EVENT_CTRL event will be generated afterwards.
875 * This will usually be called when starting or stopping streaming in the
876 * driver.
877 *
878 * This function assumes that the control handler is locked by the caller.
879 */
880void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
881
8c2721d5
MCC
882/**
883 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
8ec4bee7 884 *
8c2721d5
MCC
885 * @ctrl: The control to (de)activate.
886 * @grabbed: True if the control should become grabbed.
887 *
888 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
889 * Does nothing if @ctrl == NULL.
890 * The V4L2_EVENT_CTRL event will be generated afterwards.
891 * This will usually be called when starting or stopping streaming in the
892 * driver.
893 *
894 * This function assumes that the control handler is not locked and will
895 * take the lock itself.
896 */
7a9b109d
SA
897static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
898{
899 if (!ctrl)
900 return;
901
902 v4l2_ctrl_lock(ctrl);
903 __v4l2_ctrl_grab(ctrl, grabbed);
904 v4l2_ctrl_unlock(ctrl);
905}
0996517c 906
8c2721d5
MCC
907/**
908 *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
909 *
910 * @ctrl: The control to update.
911 * @min: The control's minimum value.
912 * @max: The control's maximum value.
913 * @step: The control's step value
914 * @def: The control's default value.
915 *
916 * Update the range of a control on the fly. This works for control types
917 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
918 * @step value is interpreted as a menu_skip_mask.
919 *
920 * An error is returned if one of the range arguments is invalid for this
921 * control type.
922 *
97eee23a
HV
923 * The caller is responsible for acquiring the control handler mutex on behalf
924 * of __v4l2_ctrl_modify_range().
8c2721d5 925 */
5a573925
SA
926int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
927 s64 min, s64 max, u64 step, s64 def);
928
8c2721d5
MCC
929/**
930 * v4l2_ctrl_modify_range() - Update the range of a control.
8ec4bee7 931 *
8c2721d5
MCC
932 * @ctrl: The control to update.
933 * @min: The control's minimum value.
934 * @max: The control's maximum value.
935 * @step: The control's step value
936 * @def: The control's default value.
937 *
938 * Update the range of a control on the fly. This works for control types
939 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
940 * @step value is interpreted as a menu_skip_mask.
941 *
942 * An error is returned if one of the range arguments is invalid for this
943 * control type.
944 *
945 * This function assumes that the control handler is not locked and will
946 * take the lock itself.
947 */
5a573925
SA
948static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
949 s64 min, s64 max, u64 step, s64 def)
950{
951 int rval;
952
953 v4l2_ctrl_lock(ctrl);
954 rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
955 v4l2_ctrl_unlock(ctrl);
956
957 return rval;
958}
2ccbe779 959
09752745
HV
960/**
961 *__v4l2_ctrl_modify_dimensions() - Unlocked variant of v4l2_ctrl_modify_dimensions()
962 *
963 * @ctrl: The control to update.
964 * @dims: The control's new dimensions.
965 *
966 * Update the dimensions of an array control on the fly. The elements of the
967 * array are reset to their default value, even if the dimensions are
968 * unchanged.
969 *
970 * An error is returned if @dims is invalid for this control.
971 *
972 * The caller is responsible for acquiring the control handler mutex on behalf
973 * of __v4l2_ctrl_modify_dimensions().
974 *
975 * Note: calling this function when the same control is used in pending requests
976 * is untested. It should work (a request with the wrong size of the control
977 * will drop that control silently), but it will be very confusing.
978 */
979int __v4l2_ctrl_modify_dimensions(struct v4l2_ctrl *ctrl,
980 u32 dims[V4L2_CTRL_MAX_DIMS]);
981
982/**
983 * v4l2_ctrl_modify_dimensions() - Update the dimensions of an array control.
984 *
985 * @ctrl: The control to update.
986 * @dims: The control's new dimensions.
987 *
988 * Update the dimensions of an array control on the fly. The elements of the
989 * array are reset to their default value, even if the dimensions are
990 * unchanged.
991 *
992 * An error is returned if @dims is invalid for this control type.
993 *
994 * This function assumes that the control handler is not locked and will
995 * take the lock itself.
996 *
997 * Note: calling this function when the same control is used in pending requests
998 * is untested. It should work (a request with the wrong size of the control
999 * will drop that control silently), but it will be very confusing.
1000 */
1001static inline int v4l2_ctrl_modify_dimensions(struct v4l2_ctrl *ctrl,
1002 u32 dims[V4L2_CTRL_MAX_DIMS])
1003{
1004 int rval;
1005
1006 v4l2_ctrl_lock(ctrl);
1007 rval = __v4l2_ctrl_modify_dimensions(ctrl, dims);
1008 v4l2_ctrl_unlock(ctrl);
1009
1010 return rval;
1011}
1012
8c2721d5
MCC
1013/**
1014 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
8ec4bee7 1015 *
8c2721d5
MCC
1016 * @ctrl: The control.
1017 * @notify: The callback function.
1018 * @priv: The callback private handle, passed as argument to the callback.
1019 *
1020 * This function sets a callback function for the control. If @ctrl is NULL,
1021 * then it will do nothing. If @notify is NULL, then the notify callback will
1022 * be removed.
1023 *
1024 * There can be only one notify. If another already exists, then a WARN_ON
1025 * will be issued and the function will do nothing.
1026 */
8ec4bee7
MCC
1027void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
1028 void *priv);
8ac7a949 1029
8c2721d5
MCC
1030/**
1031 * v4l2_ctrl_get_name() - Get the name of the control
8ec4bee7 1032 *
79fbc209
HV
1033 * @id: The control ID.
1034 *
1035 * This function returns the name of the given control ID or NULL if it isn't
1036 * a known control.
1037 */
1038const char *v4l2_ctrl_get_name(u32 id);
1039
8c2721d5
MCC
1040/**
1041 * v4l2_ctrl_get_menu() - Get the menu string array of the control
8ec4bee7 1042 *
79fbc209
HV
1043 * @id: The control ID.
1044 *
1045 * This function returns the NULL-terminated menu string array name of the
1046 * given control ID or NULL if it isn't a known menu control.
1047 */
1048const char * const *v4l2_ctrl_get_menu(u32 id);
1049
8c2721d5
MCC
1050/**
1051 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
8ec4bee7 1052 *
79fbc209
HV
1053 * @id: The control ID.
1054 * @len: The size of the integer array.
1055 *
1056 * This function returns the integer array of the given control ID or NULL if it
1057 * if it isn't a known integer menu control.
1058 */
1059const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
1060
8c2721d5 1061/**
8ec4bee7
MCC
1062 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
1063 * within a driver.
1064 *
8c2721d5
MCC
1065 * @ctrl: The control.
1066 *
1067 * This returns the control's value safely by going through the control
1068 * framework. This function will lock the control's handler, so it cannot be
1069 * used from within the &v4l2_ctrl_ops functions.
1070 *
1071 * This function is for integer type controls only.
1072 */
0996517c
HV
1073s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
1074
8c2721d5
MCC
1075/**
1076 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
8ec4bee7 1077 *
8c2721d5 1078 * @ctrl: The control.
c4d1de70 1079 * @val: The new value.
8c2721d5 1080 *
904aef0f
HV
1081 * This sets the control's new value safely by going through the control
1082 * framework. This function assumes the control's handler is already locked,
1083 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
1084 *
1085 * This function is for integer type controls only.
1086 */
0c4348ad 1087int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
8c2721d5 1088
8ec4bee7
MCC
1089/**
1090 * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
1091 * within a driver.
8c2721d5
MCC
1092 * @ctrl: The control.
1093 * @val: The new value.
1094 *
904aef0f 1095 * This sets the control's new value safely by going through the control
8c2721d5
MCC
1096 * framework. This function will lock the control's handler, so it cannot be
1097 * used from within the &v4l2_ctrl_ops functions.
1098 *
1099 * This function is for integer type controls only.
1100 */
0c4348ad
SA
1101static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
1102{
1103 int rval;
1104
1105 v4l2_ctrl_lock(ctrl);
1106 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
1107 v4l2_ctrl_unlock(ctrl);
1108
1109 return rval;
1110}
0996517c 1111
8c2721d5
MCC
1112/**
1113 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
1114 * from within a driver.
8ec4bee7 1115 *
8c2721d5
MCC
1116 * @ctrl: The control.
1117 *
1118 * This returns the control's value safely by going through the control
1119 * framework. This function will lock the control's handler, so it cannot be
1120 * used from within the &v4l2_ctrl_ops functions.
1121 *
1122 * This function is for 64-bit integer type controls only.
1123 */
03d5285b
LP
1124s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
1125
8c2721d5
MCC
1126/**
1127 * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
1128 *
1129 * @ctrl: The control.
1130 * @val: The new value.
1131 *
904aef0f
HV
1132 * This sets the control's new value safely by going through the control
1133 * framework. This function assumes the control's handler is already locked,
1134 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
1135 *
1136 * This function is for 64-bit integer type controls only.
1137 */
0c4348ad
SA
1138int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
1139
8ec4bee7
MCC
1140/**
1141 * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
8c2721d5
MCC
1142 * from within a driver.
1143 *
1144 * @ctrl: The control.
1145 * @val: The new value.
1146 *
904aef0f 1147 * This sets the control's new value safely by going through the control
8c2721d5
MCC
1148 * framework. This function will lock the control's handler, so it cannot be
1149 * used from within the &v4l2_ctrl_ops functions.
1150 *
1151 * This function is for 64-bit integer type controls only.
1152 */
0c4348ad
SA
1153static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
1154{
1155 int rval;
1156
1157 v4l2_ctrl_lock(ctrl);
1158 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
1159 v4l2_ctrl_unlock(ctrl);
1160
1161 return rval;
1162}
03d5285b 1163
8ec4bee7
MCC
1164/**
1165 * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
8c2721d5
MCC
1166 *
1167 * @ctrl: The control.
1168 * @s: The new string.
1169 *
904aef0f
HV
1170 * This sets the control's new string safely by going through the control
1171 * framework. This function assumes the control's handler is already locked,
1172 * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d5
MCC
1173 *
1174 * This function is for string type controls only.
1175 */
5d0360a4
HV
1176int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
1177
8ec4bee7
MCC
1178/**
1179 * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
8c2721d5
MCC
1180 * from within a driver.
1181 *
1182 * @ctrl: The control.
1183 * @s: The new string.
c4d1de70 1184 *
904aef0f 1185 * This sets the control's new string safely by going through the control
8c2721d5
MCC
1186 * framework. This function will lock the control's handler, so it cannot be
1187 * used from within the &v4l2_ctrl_ops functions.
1188 *
1189 * This function is for string type controls only.
1190 */
5d0360a4
HV
1191static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
1192{
1193 int rval;
1194
1195 v4l2_ctrl_lock(ctrl);
1196 rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
1197 v4l2_ctrl_unlock(ctrl);
1198
1199 return rval;
1200}
1201
d1dc4937 1202/**
b2b1046f 1203 * __v4l2_ctrl_s_ctrl_compound() - Unlocked variant to set a compound control
d1dc4937 1204 *
b2b1046f
HV
1205 * @ctrl: The control.
1206 * @type: The type of the data.
1207 * @p: The new compound payload.
d1dc4937 1208 *
b2b1046f
HV
1209 * This sets the control's new compound payload safely by going through the
1210 * control framework. This function assumes the control's handler is already
1211 * locked, allowing it to be used from within the &v4l2_ctrl_ops functions.
d1dc4937 1212 *
b2b1046f 1213 * This function is for compound type controls only.
d1dc4937 1214 */
b2b1046f
HV
1215int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
1216 enum v4l2_ctrl_type type, const void *p);
d1dc4937
RRD
1217
1218/**
b2b1046f
HV
1219 * v4l2_ctrl_s_ctrl_compound() - Helper function to set a compound control
1220 * from within a driver.
d1dc4937 1221 *
b2b1046f
HV
1222 * @ctrl: The control.
1223 * @type: The type of the data.
1224 * @p: The new compound payload.
d1dc4937 1225 *
b2b1046f
HV
1226 * This sets the control's new compound payload safely by going through the
1227 * control framework. This function will lock the control's handler, so it
1228 * cannot be used from within the &v4l2_ctrl_ops functions.
d1dc4937 1229 *
b2b1046f 1230 * This function is for compound type controls only.
d1dc4937 1231 */
b2b1046f
HV
1232static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
1233 enum v4l2_ctrl_type type,
1234 const void *p)
d1dc4937
RRD
1235{
1236 int rval;
1237
1238 v4l2_ctrl_lock(ctrl);
b2b1046f 1239 rval = __v4l2_ctrl_s_ctrl_compound(ctrl, type, p);
d1dc4937
RRD
1240 v4l2_ctrl_unlock(ctrl);
1241
1242 return rval;
1243}
1244
b2b1046f
HV
1245/* Helper defines for area type controls */
1246#define __v4l2_ctrl_s_ctrl_area(ctrl, area) \
1247 __v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
1248#define v4l2_ctrl_s_ctrl_area(ctrl, area) \
1249 v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
1250
ce727574 1251/* Internal helper functions that deal with control events. */
3e366149 1252extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
8ec4bee7
MCC
1253
1254/**
1255 * v4l2_ctrl_replace - Function to be used as a callback to
1256 * &struct v4l2_subscribed_event_ops replace\(\)
1257 *
f8441a43 1258 * @old: pointer to struct &v4l2_event with the reported
8ec4bee7 1259 * event;
f8441a43 1260 * @new: pointer to struct &v4l2_event with the modified
8ec4bee7
MCC
1261 * event;
1262 */
3e366149 1263void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
8ec4bee7
MCC
1264
1265/**
1266 * v4l2_ctrl_merge - Function to be used as a callback to
1267 * &struct v4l2_subscribed_event_ops merge(\)
1268 *
f8441a43 1269 * @old: pointer to struct &v4l2_event with the reported
8ec4bee7 1270 * event;
f8441a43 1271 * @new: pointer to struct &v4l2_event with the merged
8ec4bee7
MCC
1272 * event;
1273 */
3e366149 1274void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
6e239399 1275
8ec4bee7
MCC
1276/**
1277 * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
1278 *
1279 * @file: pointer to struct file
1280 * @fh: unused. Kept just to be compatible to the arguments expected by
1281 * &struct v4l2_ioctl_ops.vidioc_log_status.
1282 *
1283 * Can be used as a vidioc_log_status function that just dumps all controls
1284 * associated with the filehandle.
1285 */
e2ecb257
HV
1286int v4l2_ctrl_log_status(struct file *file, void *fh);
1287
8ec4bee7
MCC
1288/**
1289 * v4l2_ctrl_subscribe_event - Subscribes to an event
1290 *
1291 *
1292 * @fh: pointer to struct v4l2_fh
1293 * @sub: pointer to &struct v4l2_event_subscription
1294 *
1295 * Can be used as a vidioc_subscribe_event function that just subscribes
1296 * control events.
1297 */
a26243b0 1298int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
85f5fe39 1299 const struct v4l2_event_subscription *sub);
a26243b0 1300
8ec4bee7
MCC
1301/**
1302 * v4l2_ctrl_poll - function to be used as a callback to the poll()
1303 * That just polls for control events.
1304 *
1305 * @file: pointer to struct file
1306 * @wait: pointer to struct poll_table_struct
1307 */
c23e0cb8 1308__poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
a26243b0 1309
6fa6f831
HV
1310/**
1311 * v4l2_ctrl_request_setup - helper function to apply control values in a request
1312 *
1313 * @req: The request
1314 * @parent: The parent control handler ('priv' in media_request_object_find())
1315 *
1316 * This is a helper function to call the control handler's s_ctrl callback with
1317 * the control values contained in the request. Do note that this approach of
1318 * applying control values in a request is only applicable to memory-to-memory
1319 * devices.
1320 */
09ca38a5 1321int v4l2_ctrl_request_setup(struct media_request *req,
6fa6f831
HV
1322 struct v4l2_ctrl_handler *parent);
1323
1324/**
1325 * v4l2_ctrl_request_complete - Complete a control handler request object
1326 *
1327 * @req: The request
1328 * @parent: The parent control handler ('priv' in media_request_object_find())
1329 *
1330 * This function is to be called on each control handler that may have had a
1331 * request object associated with it, i.e. control handlers of a driver that
1332 * supports requests.
1333 *
1334 * The function first obtains the values of any volatile controls in the control
1335 * handler and attach them to the request. Then, the function completes the
1336 * request object.
1337 */
1338void v4l2_ctrl_request_complete(struct media_request *req,
5f611d74
HV
1339 struct v4l2_ctrl_handler *parent);
1340
1341/**
1342 * v4l2_ctrl_request_hdl_find - Find the control handler in the request
1343 *
1344 * @req: The request
1345 * @parent: The parent control handler ('priv' in media_request_object_find())
1346 *
1347 * This function finds the control handler in the request. It may return
1348 * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl()
1349 * with the returned handler pointer.
1350 *
1351 * If the request is not in state VALIDATING or QUEUED, then this function
1352 * will always return NULL.
1353 *
1354 * Note that in state VALIDATING the req_queue_mutex is held, so
1355 * no objects can be added or deleted from the request.
1356 *
1357 * In state QUEUED it is the driver that will have to ensure this.
1358 */
1359struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
1360 struct v4l2_ctrl_handler *parent);
1361
1362/**
1363 * v4l2_ctrl_request_hdl_put - Put the control handler
1364 *
1365 * @hdl: Put this control handler
1366 *
1367 * This function released the control handler previously obtained from'
1368 * v4l2_ctrl_request_hdl_find().
1369 */
1370static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl)
1371{
1372 if (hdl)
1373 media_request_object_put(&hdl->req_obj);
1374}
1375
1376/**
b0649455 1377 * v4l2_ctrl_request_hdl_ctrl_find() - Find a control with the given ID.
5f611d74
HV
1378 *
1379 * @hdl: The control handler from the request.
1380 * @id: The ID of the control to find.
1381 *
1382 * This function returns a pointer to the control if this control is
1383 * part of the request or NULL otherwise.
1384 */
1385struct v4l2_ctrl *
1386v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
6fa6f831 1387
8ec4bee7
MCC
1388/* Helpers for ioctl_ops */
1389
1390/**
1391 * v4l2_queryctrl - Helper function to implement
1392 * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
1393 *
1394 * @hdl: pointer to &struct v4l2_ctrl_handler
1395 * @qc: pointer to &struct v4l2_queryctrl
1396 *
1397 * If hdl == NULL then they will all return -EINVAL.
1398 */
0996517c 1399int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
8ec4bee7
MCC
1400
1401/**
1402 * v4l2_query_ext_ctrl - Helper function to implement
1403 * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
1404 *
1405 * @hdl: pointer to &struct v4l2_ctrl_handler
1406 * @qc: pointer to &struct v4l2_query_ext_ctrl
1407 *
1408 * If hdl == NULL then they will all return -EINVAL.
1409 */
1410int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
1411 struct v4l2_query_ext_ctrl *qc);
1412
1413/**
1414 * v4l2_querymenu - Helper function to implement
1415 * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
1416 *
1417 * @hdl: pointer to &struct v4l2_ctrl_handler
1418 * @qm: pointer to &struct v4l2_querymenu
1419 *
1420 * If hdl == NULL then they will all return -EINVAL.
1421 */
0996517c 1422int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
8ec4bee7
MCC
1423
1424/**
1425 * v4l2_g_ctrl - Helper function to implement
1426 * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
1427 *
1428 * @hdl: pointer to &struct v4l2_ctrl_handler
1429 * @ctrl: pointer to &struct v4l2_control
1430 *
1431 * If hdl == NULL then they will all return -EINVAL.
1432 */
0996517c 1433int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
8ec4bee7
MCC
1434
1435/**
1436 * v4l2_s_ctrl - Helper function to implement
1437 * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
1438 *
1439 * @fh: pointer to &struct v4l2_fh
1440 * @hdl: pointer to &struct v4l2_ctrl_handler
1441 *
1442 * @ctrl: pointer to &struct v4l2_control
1443 *
1444 * If hdl == NULL then they will all return -EINVAL.
1445 */
ab892bac 1446int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
8ec4bee7
MCC
1447 struct v4l2_control *ctrl);
1448
1449/**
1450 * v4l2_g_ext_ctrls - Helper function to implement
1451 * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1452 *
1453 * @hdl: pointer to &struct v4l2_ctrl_handler
173f6eac 1454 * @vdev: pointer to &struct video_device
c41e9cff 1455 * @mdev: pointer to &struct media_device
8ec4bee7
MCC
1456 * @c: pointer to &struct v4l2_ext_controls
1457 *
1458 * If hdl == NULL then they will all return -EINVAL.
1459 */
173f6eac
EG
1460int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
1461 struct media_device *mdev, struct v4l2_ext_controls *c);
8ec4bee7
MCC
1462
1463/**
1464 * v4l2_try_ext_ctrls - Helper function to implement
1465 * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1466 *
1467 * @hdl: pointer to &struct v4l2_ctrl_handler
173f6eac 1468 * @vdev: pointer to &struct video_device
c41e9cff 1469 * @mdev: pointer to &struct media_device
8ec4bee7
MCC
1470 * @c: pointer to &struct v4l2_ext_controls
1471 *
1472 * If hdl == NULL then they will all return -EINVAL.
1473 */
1474int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
173f6eac 1475 struct video_device *vdev,
c41e9cff 1476 struct media_device *mdev,
8ec4bee7
MCC
1477 struct v4l2_ext_controls *c);
1478
1479/**
1480 * v4l2_s_ext_ctrls - Helper function to implement
1481 * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1482 *
1483 * @fh: pointer to &struct v4l2_fh
1484 * @hdl: pointer to &struct v4l2_ctrl_handler
173f6eac 1485 * @vdev: pointer to &struct video_device
c41e9cff 1486 * @mdev: pointer to &struct media_device
8ec4bee7
MCC
1487 * @c: pointer to &struct v4l2_ext_controls
1488 *
1489 * If hdl == NULL then they will all return -EINVAL.
1490 */
ab892bac 1491int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
173f6eac 1492 struct video_device *vdev,
c41e9cff 1493 struct media_device *mdev,
8ec4bee7 1494 struct v4l2_ext_controls *c);
0996517c 1495
8ec4bee7
MCC
1496/**
1497 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
4a3fad70 1498 * as a &struct v4l2_subdev_core_ops subscribe_event function
8ec4bee7
MCC
1499 * that just subscribes control events.
1500 *
1501 * @sd: pointer to &struct v4l2_subdev
1502 * @fh: pointer to &struct v4l2_fh
1503 * @sub: pointer to &struct v4l2_event_subscription
1504 */
22fa4279
SN
1505int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1506 struct v4l2_event_subscription *sub);
1507
8ec4bee7
MCC
1508/**
1509 * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
1510 * handler.
1511 *
1512 * @sd: pointer to &struct v4l2_subdev
1513 */
ffa9b9f0
SN
1514int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
1515
e0a36063
JM
1516/**
1517 * v4l2_ctrl_new_fwnode_properties() - Register controls for the device
1518 * properties
1519 *
1520 * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on
1521 * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with
1522 * @p: pointer to &struct v4l2_fwnode_device_properties
1523 *
1524 * This function registers controls associated to device properties, using the
1525 * property values contained in @p parameter, if the property has been set to
1526 * a value.
1527 *
1528 * Currently the following v4l2 controls are parsed and registered:
1529 * - V4L2_CID_CAMERA_ORIENTATION
1530 * - V4L2_CID_CAMERA_SENSOR_ROTATION;
1531 *
1532 * Controls already registered by the caller with the @hdl control handler are
1533 * not overwritten. Callers should register the controls they want to handle
1534 * themselves before calling this function.
1535 *
1536 * Return: 0 on success, a negative error code on failure.
1537 */
1538int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
1539 const struct v4l2_ctrl_ops *ctrl_ops,
1540 const struct v4l2_fwnode_device_properties *p);
f1739ec4
XR
1541
1542/**
1543 * v4l2_ctrl_type_op_equal - Default v4l2_ctrl_type_ops equal callback.
1544 *
1545 * @ctrl: The v4l2_ctrl pointer.
1546 * @elems: The number of elements to compare.
1547 * @ptr1: A v4l2 control value.
1548 * @ptr2: A v4l2 control value.
1549 *
1550 * Return: true if values are equal, otherwise false.
1551 */
1552bool v4l2_ctrl_type_op_equal(const struct v4l2_ctrl *ctrl, u32 elems,
1553 union v4l2_ctrl_ptr ptr1, union v4l2_ctrl_ptr ptr2);
1554
1555/**
1556 * v4l2_ctrl_type_op_init - Default v4l2_ctrl_type_ops init callback.
1557 *
1558 * @ctrl: The v4l2_ctrl pointer.
1559 * @from_idx: Starting element index.
1560 * @elems: The number of elements to initialize.
1561 * @ptr: The v4l2 control value.
1562 *
1563 * Return: void
1564 */
1565void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx,
1566 u32 elems, union v4l2_ctrl_ptr ptr);
1567
1568/**
1569 * v4l2_ctrl_type_op_log - Default v4l2_ctrl_type_ops log callback.
1570 *
1571 * @ctrl: The v4l2_ctrl pointer.
1572 *
1573 * Return: void
1574 */
1575void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl);
1576
1577/**
1578 * v4l2_ctrl_type_op_validate - Default v4l2_ctrl_type_ops validate callback.
1579 *
1580 * @ctrl: The v4l2_ctrl pointer.
1581 * @elems: The number of elements in the control.
1582 * @ptr: The v4l2 control value.
1583 *
1584 * Return: 0 on success, a negative error code on failure.
1585 */
1586int v4l2_ctrl_type_op_validate(const struct v4l2_ctrl *ctrl, u32 elems,
1587 union v4l2_ctrl_ptr ptr);
1588
0996517c 1589#endif