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