blob: da6fe9802feeab18df01dba3bd606dd12daaa552 [file] [log] [blame]
Hans Verkuil09965172010-08-01 14:32:42 -03001/*
2 V4L2 controls support header.
3
4 Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _V4L2_CTRLS_H
22#define _V4L2_CTRLS_H
23
24#include <linux/list.h>
Andrzej Hajdaa19dec62013-06-28 05:44:22 -030025#include <linux/mutex.h>
Laurent Pinchart01c40c02010-11-19 11:20:06 -030026#include <linux/videodev2.h>
Hans Verkuil09965172010-08-01 14:32:42 -030027
28/* forward references */
Laurent Pinchart528f0f72012-04-23 08:20:35 -030029struct file;
Hans Verkuil09965172010-08-01 14:32:42 -030030struct v4l2_ctrl_handler;
Hans Verkuileb5b16e2011-06-14 10:04:06 -030031struct v4l2_ctrl_helper;
Hans Verkuil09965172010-08-01 14:32:42 -030032struct v4l2_ctrl;
33struct video_device;
34struct v4l2_subdev;
Hans Verkuil77068d32011-06-13 18:55:58 -030035struct v4l2_subscribed_event;
Hans Verkuil6e239392011-06-07 11:13:44 -030036struct v4l2_fh;
Hans Verkuila26243b2012-01-27 16:18:42 -030037struct poll_table_struct;
Hans Verkuil09965172010-08-01 14:32:42 -030038
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030039/**
40 * union v4l2_ctrl_ptr - A pointer to a control value.
Hans Verkuil01760772014-04-27 03:22:17 -030041 * @p_s32: Pointer to a 32-bit signed value.
42 * @p_s64: Pointer to a 64-bit signed value.
Hans Verkuildda4a4d2014-06-10 07:30:04 -030043 * @p_u8: Pointer to a 8-bit unsigned value.
44 * @p_u16: Pointer to a 16-bit unsigned value.
Hans Verkuil811c5082014-07-21 10:45:37 -030045 * @p_u32: Pointer to a 32-bit unsigned value.
Hans Verkuil01760772014-04-27 03:22:17 -030046 * @p_char: Pointer to a string.
47 * @p: Pointer to a compound value.
48 */
49union v4l2_ctrl_ptr {
50 s32 *p_s32;
51 s64 *p_s64;
Hans Verkuildda4a4d2014-06-10 07:30:04 -030052 u8 *p_u8;
53 u16 *p_u16;
Hans Verkuil811c5082014-07-21 10:45:37 -030054 u32 *p_u32;
Hans Verkuil01760772014-04-27 03:22:17 -030055 char *p_char;
56 void *p;
57};
58
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030059/**
60 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
61 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
62 * for volatile (and usually read-only) controls such as a control
63 * that returns the current signal strength which changes
64 * continuously.
65 * If not set, then the currently cached value will be returned.
66 * @try_ctrl: Test whether the control's value is valid. Only relevant when
67 * the usual min/max/step checks are not sufficient.
68 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
69 * ctrl->handler->lock is held when these ops are called, so no
70 * one else can access controls owned by that handler.
71 */
Hans Verkuil09965172010-08-01 14:32:42 -030072struct v4l2_ctrl_ops {
73 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
74 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
75 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
76};
77
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030078/**
79 * struct v4l2_ctrl_type_ops - The control type operations that the driver
80 * has to provide.
81 *
82 * @equal: return true if both values are equal.
83 * @init: initialize the value.
84 * @log: log the value.
85 * @validate: validate the value. Return 0 on success and a negative value otherwise.
86 */
Hans Verkuil01760772014-04-27 03:22:17 -030087struct v4l2_ctrl_type_ops {
Hans Verkuil998e7652014-06-10 07:55:00 -030088 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030089 union v4l2_ctrl_ptr ptr1,
90 union v4l2_ctrl_ptr ptr2);
Hans Verkuil998e7652014-06-10 07:55:00 -030091 void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030092 union v4l2_ctrl_ptr ptr);
93 void (*log)(const struct v4l2_ctrl *ctrl);
Hans Verkuil998e7652014-06-10 07:55:00 -030094 int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030095 union v4l2_ctrl_ptr ptr);
96};
97
Hans Verkuil8ac7a942012-09-07 04:46:39 -030098typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
99
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300100/**
101 * struct v4l2_ctrl - The control structure.
102 * @node: The list node.
103 * @ev_subs: The list of control event subscriptions.
104 * @handler: The handler that owns the control.
105 * @cluster: Point to start of cluster array.
106 * @ncontrols: Number of controls in cluster array.
107 * @done: Internal flag: set for each processed control.
108 * @is_new: Set when the user specified a new value for this control. It
109 * is also set when called from v4l2_ctrl_handler_setup. Drivers
110 * should never set this flag.
111 * @has_changed: Set when the current value differs from the new value. Drivers
112 * should never use this flag.
113 * @is_private: If set, then this control is private to its handler and it
114 * will not be added to any other handlers. Drivers can set
115 * this flag.
116 * @is_auto: If set, then this control selects whether the other cluster
117 * members are in 'automatic' mode or 'manual' mode. This is
118 * used for autogain/gain type clusters. Drivers should never
119 * set this flag directly.
120 * @is_int: If set, then this control has a simple integer value (i.e. it
121 * uses ctrl->val).
122 * @is_string: If set, then this control has type V4L2_CTRL_TYPE_STRING.
123 * @is_ptr: If set, then this control is an array and/or has type >= V4L2_CTRL_COMPOUND_TYPES
124 * and/or has type V4L2_CTRL_TYPE_STRING. In other words, struct
125 * v4l2_ext_control uses field p to point to the data.
126 * @is_array: If set, then this control contains an N-dimensional array.
127 * @has_volatiles: If set, then one or more members of the cluster are volatile.
128 * Drivers should never touch this flag.
129 * @call_notify: If set, then call the handler's notify function whenever the
130 * control's value changes.
131 * @manual_mode_value: If the is_auto flag is set, then this is the value
132 * of the auto control that determines if that control is in
133 * manual mode. So if the value of the auto control equals this
134 * value, then the whole cluster is in manual mode. Drivers should
135 * never set this flag directly.
136 * @ops: The control ops.
137 * @type_ops: The control type ops.
138 * @id: The control ID.
139 * @name: The control name.
140 * @type: The control type.
141 * @minimum: The control's minimum value.
142 * @maximum: The control's maximum value.
143 * @default_value: The control's default value.
144 * @step: The control's step value for non-menu controls.
145 * @elems: The number of elements in the N-dimensional array.
146 * @elem_size: The size in bytes of the control.
147 * @dims: The size of each dimension.
148 * @nr_of_dims:The number of dimensions in @dims.
149 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
150 * easy to skip menu items that are not valid. If bit X is set,
151 * then menu item X is skipped. Of course, this only works for
152 * menus with <= 32 menu items. There are no menus that come
153 * close to that number, so this is OK. Should we ever need more,
154 * then this will have to be extended to a u64 or a bit array.
155 * @qmenu: A const char * array for all menu items. Array entries that are
156 * empty strings ("") correspond to non-existing menu items (this
157 * is in addition to the menu_skip_mask above). The last entry
158 * must be NULL.
159 * @flags: The control's flags.
160 * @cur: The control's current value.
161 * @val: The control's new s32 value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300162 * @priv: The control's private pointer. For use by the driver. It is
163 * untouched by the control framework. Note that this pointer is
164 * not freed when the control is deleted. Should this be needed
165 * then a new internal bitfield can be added to tell the framework
166 * to free this pointer.
Mauro Carvalho Chehab7dc87912015-08-22 08:22:03 -0300167 * @p_cur: The control's current value represented via an union with
168 * provides a standard way of accessing control types
169 * through a pointer.
170 * @p_new: The control's new value represented via an union with provides
171 * a standard way of accessing control types
172 * through a pointer.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300173 */
Hans Verkuil09965172010-08-01 14:32:42 -0300174struct v4l2_ctrl {
175 /* Administrative fields */
176 struct list_head node;
Hans Verkuil77068d32011-06-13 18:55:58 -0300177 struct list_head ev_subs;
Hans Verkuil09965172010-08-01 14:32:42 -0300178 struct v4l2_ctrl_handler *handler;
179 struct v4l2_ctrl **cluster;
180 unsigned ncontrols;
Hans Verkuil09965172010-08-01 14:32:42 -0300181 unsigned int done:1;
182
Hans Verkuil2a863792011-01-11 14:45:03 -0300183 unsigned int is_new:1;
Hans Verkuil9ea1b7a2014-01-17 08:25:26 -0300184 unsigned int has_changed:1;
Hans Verkuil09965172010-08-01 14:32:42 -0300185 unsigned int is_private:1;
Hans Verkuil72d877c2011-06-10 05:44:36 -0300186 unsigned int is_auto:1;
Hans Verkuild9a25472014-06-12 07:54:16 -0300187 unsigned int is_int:1;
188 unsigned int is_string:1;
189 unsigned int is_ptr:1;
Hans Verkuil998e7652014-06-10 07:55:00 -0300190 unsigned int is_array:1;
Hans Verkuil5626b8c2011-08-26 07:53:53 -0300191 unsigned int has_volatiles:1;
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300192 unsigned int call_notify:1;
Hans Verkuil82a7c042011-06-28 10:43:13 -0300193 unsigned int manual_mode_value:8;
Hans Verkuil09965172010-08-01 14:32:42 -0300194
195 const struct v4l2_ctrl_ops *ops;
Hans Verkuil01760772014-04-27 03:22:17 -0300196 const struct v4l2_ctrl_type_ops *type_ops;
Hans Verkuil09965172010-08-01 14:32:42 -0300197 u32 id;
198 const char *name;
199 enum v4l2_ctrl_type type;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300200 s64 minimum, maximum, default_value;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300201 u32 elems;
Hans Verkuild9a25472014-06-12 07:54:16 -0300202 u32 elem_size;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300203 u32 dims[V4L2_CTRL_MAX_DIMS];
204 u32 nr_of_dims;
Hans Verkuil09965172010-08-01 14:32:42 -0300205 union {
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300206 u64 step;
207 u64 menu_skip_mask;
Hans Verkuil09965172010-08-01 14:32:42 -0300208 };
Sakari Ailusce580fe2011-08-04 13:51:11 -0300209 union {
210 const char * const *qmenu;
211 const s64 *qmenu_int;
212 };
Hans Verkuil09965172010-08-01 14:32:42 -0300213 unsigned long flags;
Hans Verkuil09965172010-08-01 14:32:42 -0300214 void *priv;
Hans Verkuil2a9ec372014-04-27 03:38:13 -0300215 s32 val;
216 struct {
Hans Verkuild9a25472014-06-12 07:54:16 -0300217 s32 val;
Hans Verkuild9a25472014-06-12 07:54:16 -0300218 } cur;
Hans Verkuil01760772014-04-27 03:22:17 -0300219
220 union v4l2_ctrl_ptr p_new;
221 union v4l2_ctrl_ptr p_cur;
Hans Verkuil09965172010-08-01 14:32:42 -0300222};
223
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300224/**
225 * struct v4l2_ctrl_ref - The control reference.
226 * @node: List node for the sorted list.
227 * @next: Single-link list node for the hash.
228 * @ctrl: The actual control information.
229 * @helper: Pointer to helper struct. Used internally in prepare_ext_ctrls().
230 *
231 * Each control handler has a list of these refs. The list_head is used to
232 * keep a sorted-by-control-ID list of all controls, while the next pointer
233 * is used to link the control in the hash's bucket.
234 */
Hans Verkuil09965172010-08-01 14:32:42 -0300235struct v4l2_ctrl_ref {
236 struct list_head node;
237 struct v4l2_ctrl_ref *next;
238 struct v4l2_ctrl *ctrl;
Hans Verkuileb5b16e2011-06-14 10:04:06 -0300239 struct v4l2_ctrl_helper *helper;
Hans Verkuil09965172010-08-01 14:32:42 -0300240};
241
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300242/**
243 * struct v4l2_ctrl_handler - The control handler keeps track of all the
244 * controls: both the controls owned by the handler and those inherited
245 * from other handlers.
246 * @_lock: Default for "lock".
247 * @lock: Lock to control access to this handler and its controls.
248 * May be replaced by the user right after init.
249 * @ctrls: The list of controls owned by this handler.
250 * @ctrl_refs: The list of control references.
251 * @cached: The last found control reference. It is common that the same
252 * control is needed multiple times, so this is a simple
253 * optimization.
254 * @buckets: Buckets for the hashing. Allows for quick control lookup.
255 * @notify: A notify callback that is called whenever the control changes value.
256 * Note that the handler's lock is held when the notify function
257 * is called!
258 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
259 * @nr_of_buckets: Total number of buckets in the array.
260 * @error: The error code of the first failed control addition.
261 */
Hans Verkuil09965172010-08-01 14:32:42 -0300262struct v4l2_ctrl_handler {
Sakari Ailus77e7c4e2012-01-24 21:05:34 -0300263 struct mutex _lock;
264 struct mutex *lock;
Hans Verkuil09965172010-08-01 14:32:42 -0300265 struct list_head ctrls;
266 struct list_head ctrl_refs;
267 struct v4l2_ctrl_ref *cached;
268 struct v4l2_ctrl_ref **buckets;
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300269 v4l2_ctrl_notify_fnc notify;
270 void *notify_priv;
Hans Verkuil09965172010-08-01 14:32:42 -0300271 u16 nr_of_buckets;
272 int error;
273};
274
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300275/**
276 * struct v4l2_ctrl_config - Control configuration structure.
277 * @ops: The control ops.
278 * @type_ops: The control type ops. Only needed for compound controls.
279 * @id: The control ID.
280 * @name: The control name.
281 * @type: The control type.
282 * @min: The control's minimum value.
283 * @max: The control's maximum value.
284 * @step: The control's step value for non-menu controls.
285 * @def: The control's default value.
286 * @dims: The size of each dimension.
287 * @elem_size: The size in bytes of the control.
288 * @flags: The control's flags.
289 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
290 * easy to skip menu items that are not valid. If bit X is set,
291 * then menu item X is skipped. Of course, this only works for
292 * menus with <= 64 menu items. There are no menus that come
293 * close to that number, so this is OK. Should we ever need more,
294 * then this will have to be extended to a bit array.
295 * @qmenu: A const char * array for all menu items. Array entries that are
296 * empty strings ("") correspond to non-existing menu items (this
297 * is in addition to the menu_skip_mask above). The last entry
298 * must be NULL.
Mauro Carvalho Chehab7dc87912015-08-22 08:22:03 -0300299 * @qmenu_int: A const s64 integer array for all menu items of the type
300 * V4L2_CTRL_TYPE_INTEGER_MENU.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300301 * @is_private: If set, then this control is private to its handler and it
302 * will not be added to any other handlers.
303 */
Hans Verkuil09965172010-08-01 14:32:42 -0300304struct v4l2_ctrl_config {
305 const struct v4l2_ctrl_ops *ops;
Hans Verkuil01760772014-04-27 03:22:17 -0300306 const struct v4l2_ctrl_type_ops *type_ops;
Hans Verkuil09965172010-08-01 14:32:42 -0300307 u32 id;
308 const char *name;
309 enum v4l2_ctrl_type type;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300310 s64 min;
311 s64 max;
312 u64 step;
313 s64 def;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300314 u32 dims[V4L2_CTRL_MAX_DIMS];
Hans Verkuild9a25472014-06-12 07:54:16 -0300315 u32 elem_size;
Hans Verkuil09965172010-08-01 14:32:42 -0300316 u32 flags;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300317 u64 menu_skip_mask;
Hans Verkuil513521e2010-12-29 14:25:52 -0300318 const char * const *qmenu;
Sakari Ailusce580fe2011-08-04 13:51:11 -0300319 const s64 *qmenu_int;
Hans Verkuil09965172010-08-01 14:32:42 -0300320 unsigned int is_private:1;
Hans Verkuil09965172010-08-01 14:32:42 -0300321};
322
Mauro Carvalho Chehab276ce3a2015-08-22 08:21:10 -0300323/*
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300324 * v4l2_ctrl_fill() - Fill in the control fields based on the control ID.
325 *
326 * This works for all standard V4L2 controls.
327 * For non-standard controls it will only fill in the given arguments
328 * and @name will be NULL.
329 *
330 * This function will overwrite the contents of @name, @type and @flags.
331 * The contents of @min, @max, @step and @def may be modified depending on
332 * the type.
333 *
334 * Do not use in drivers! It is used internally for backwards compatibility
335 * control handling only. Once all drivers are converted to use the new
336 * control framework this function will no longer be exported.
337 */
Hans Verkuil09965172010-08-01 14:32:42 -0300338void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300339 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
Hans Verkuil09965172010-08-01 14:32:42 -0300340
341
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300342/**
343 * v4l2_ctrl_handler_init_class() - Initialize the control handler.
344 * @hdl: The control handler.
345 * @nr_of_controls_hint: A hint of how many controls this handler is
346 * expected to refer to. This is the total number, so including
347 * any inherited controls. It doesn't have to be precise, but if
348 * it is way off, then you either waste memory (too many buckets
349 * are allocated) or the control lookup becomes slower (not enough
350 * buckets are allocated, so there are more slow list lookups).
351 * It will always work, though.
352 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
353 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
354 *
355 * Returns an error if the buckets could not be allocated. This error will
356 * also be stored in @hdl->error.
357 *
358 * Never use this call directly, always use the v4l2_ctrl_handler_init
359 * macro that hides the @key and @name arguments.
360 */
Andy Walls6cd247e2013-03-09 05:55:11 -0300361int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
362 unsigned nr_of_controls_hint,
363 struct lock_class_key *key, const char *name);
364
365#ifdef CONFIG_LOCKDEP
366#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
367( \
368 ({ \
369 static struct lock_class_key _key; \
370 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
371 &_key, \
372 KBUILD_BASENAME ":" \
373 __stringify(__LINE__) ":" \
374 "(" #hdl ")->_lock"); \
375 }) \
376)
377#else
378#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
379 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
380#endif
Hans Verkuil09965172010-08-01 14:32:42 -0300381
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300382/**
383 * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
384 * the control list.
385 * @hdl: The control handler.
386 *
387 * Does nothing if @hdl == NULL.
388 */
Hans Verkuil09965172010-08-01 14:32:42 -0300389void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
390
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300391/**
392 * v4l2_ctrl_lock() - Helper function to lock the handler
393 * associated with the control.
394 * @ctrl: The control to lock.
395 */
Sakari Ailus605b3842014-06-12 13:09:39 -0300396static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
397{
398 mutex_lock(ctrl->handler->lock);
399}
400
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300401/**
402 * v4l2_ctrl_unlock() - Helper function to unlock the handler
403 * associated with the control.
404 * @ctrl: The control to unlock.
405 */
Sakari Ailus605b3842014-06-12 13:09:39 -0300406static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
407{
408 mutex_unlock(ctrl->handler->lock);
409}
410
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300411/**
412 * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
413 * to the handler to initialize the hardware to the current control values.
414 * @hdl: The control handler.
415 *
416 * Button controls will be skipped, as are read-only controls.
417 *
418 * If @hdl == NULL, then this just returns 0.
419 */
Hans Verkuil09965172010-08-01 14:32:42 -0300420int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
421
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300422/**
423 * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
424 * @hdl: The control handler.
425 * @prefix: The prefix to use when logging the control values. If the
426 * prefix does not end with a space, then ": " will be added
427 * after the prefix. If @prefix == NULL, then no prefix will be
428 * used.
429 *
430 * For use with VIDIOC_LOG_STATUS.
431 *
432 * Does nothing if @hdl == NULL.
433 */
Hans Verkuil09965172010-08-01 14:32:42 -0300434void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
435 const char *prefix);
436
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300437/**
438 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
439 * control.
440 * @hdl: The control handler.
441 * @cfg: The control's configuration data.
442 * @priv: The control's driver-specific private data.
443 *
444 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
445 * and @hdl->error is set to the error code (if it wasn't set already).
446 */
Hans Verkuil09965172010-08-01 14:32:42 -0300447struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
448 const struct v4l2_ctrl_config *cfg, void *priv);
449
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300450/**
451 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu control.
452 * @hdl: The control handler.
453 * @ops: The control ops.
454 * @id: The control ID.
455 * @min: The control's minimum value.
456 * @max: The control's maximum value.
457 * @step: The control's step value
458 * @def: The control's default value.
459 *
460 * If the &v4l2_ctrl struct could not be allocated, or the control
461 * ID is not known, then NULL is returned and @hdl->error is set to the
462 * appropriate error code (if it wasn't set already).
463 *
464 * If @id refers to a menu control, then this function will return NULL.
465 *
466 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
467 */
Hans Verkuil09965172010-08-01 14:32:42 -0300468struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
469 const struct v4l2_ctrl_ops *ops,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300470 u32 id, s64 min, s64 max, u64 step, s64 def);
Hans Verkuil09965172010-08-01 14:32:42 -0300471
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300472/**
473 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control.
474 * @hdl: The control handler.
475 * @ops: The control ops.
476 * @id: The control ID.
477 * @max: The control's maximum value.
478 * @mask: The control's skip mask for menu controls. This makes it
479 * easy to skip menu items that are not valid. If bit X is set,
480 * then menu item X is skipped. Of course, this only works for
481 * menus with <= 64 menu items. There are no menus that come
482 * close to that number, so this is OK. Should we ever need more,
483 * then this will have to be extended to a bit array.
484 * @def: The control's default value.
485 *
486 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
487 * determines which menu items are to be skipped.
488 *
489 * If @id refers to a non-menu control, then this function will return NULL.
490 */
Hans Verkuil09965172010-08-01 14:32:42 -0300491struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
492 const struct v4l2_ctrl_ops *ops,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300493 u32 id, u8 max, u64 mask, u8 def);
Hans Verkuil09965172010-08-01 14:32:42 -0300494
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300495/**
496 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
497 * with driver specific menu.
498 * @hdl: The control handler.
499 * @ops: The control ops.
500 * @id: The control ID.
501 * @max: The control's maximum value.
502 * @mask: The control's skip mask for menu controls. This makes it
503 * easy to skip menu items that are not valid. If bit X is set,
504 * then menu item X is skipped. Of course, this only works for
505 * menus with <= 64 menu items. There are no menus that come
506 * close to that number, so this is OK. Should we ever need more,
507 * then this will have to be extended to a bit array.
508 * @def: The control's default value.
509 * @qmenu: The new menu.
510 *
511 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
512 * menu of this control.
513 *
514 */
Lad, Prabhakar117a7112012-09-18 15:54:38 -0300515struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300516 const struct v4l2_ctrl_ops *ops, u32 id, u8 max,
517 u64 mask, u8 def, const char * const *qmenu);
Lad, Prabhakar117a7112012-09-18 15:54:38 -0300518
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300519/**
520 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
521 * @hdl: The control handler.
522 * @ops: The control ops.
523 * @id: The control ID.
524 * @max: The control's maximum value.
525 * @def: The control's default value.
526 * @qmenu_int: The control's menu entries.
527 *
528 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
529 * takes as an argument an array of integers determining the menu items.
530 *
531 * If @id refers to a non-integer-menu control, then this function will return NULL.
532 */
Sylwester Nawrocki515f3282012-05-06 15:30:44 -0300533struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
534 const struct v4l2_ctrl_ops *ops,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300535 u32 id, u8 max, u8 def, const s64 *qmenu_int);
Sylwester Nawrocki515f3282012-05-06 15:30:44 -0300536
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300537/**
538 * v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
539 * @hdl: The control handler.
540 * @ctrl: The control to add.
541 *
542 * It will return NULL if it was unable to add the control reference.
543 * If the control already belonged to the handler, then it will do
544 * nothing and just return @ctrl.
545 */
Hans Verkuil09965172010-08-01 14:32:42 -0300546struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
547 struct v4l2_ctrl *ctrl);
548
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300549/**
550 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
551 * handler @hdl.
552 * @hdl: The control handler.
553 * @add: The control handler whose controls you want to add to
554 * the @hdl control handler.
555 * @filter: This function will filter which controls should be added.
556 *
557 * Does nothing if either of the two handlers is a NULL pointer.
558 * If @filter is NULL, then all controls are added. Otherwise only those
559 * controls for which @filter returns true will be added.
560 * In case of an error @hdl->error will be set to the error code (if it
561 * wasn't set already).
562 */
Hans Verkuil09965172010-08-01 14:32:42 -0300563int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
Hans Verkuil34a6b7d2012-09-14 07:15:03 -0300564 struct v4l2_ctrl_handler *add,
565 bool (*filter)(const struct v4l2_ctrl *ctrl));
Hans Verkuil09965172010-08-01 14:32:42 -0300566
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300567/**
568 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
569 * @ctrl: The control that is filtered.
570 *
571 * This will return true for any controls that are valid for radio device
572 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
573 * transmitter class controls.
574 *
575 * This function is to be used with v4l2_ctrl_add_handler().
576 */
Hans Verkuil34a6b7d2012-09-14 07:15:03 -0300577bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
Hans Verkuil09965172010-08-01 14:32:42 -0300578
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300579/**
580 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster.
581 * @ncontrols: The number of controls in this cluster.
582 * @controls: The cluster control array of size @ncontrols.
583 */
Hans Verkuil09965172010-08-01 14:32:42 -0300584void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
585
586
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300587/**
588 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to
589 * that cluster and set it up for autofoo/foo-type handling.
590 * @ncontrols: The number of controls in this cluster.
591 * @controls: The cluster control array of size @ncontrols. The first control
592 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
593 * @manual_val: The value for the first control in the cluster that equals the
594 * manual setting.
595 * @set_volatile: If true, then all controls except the first auto control will
596 * be volatile.
597 *
598 * Use for control groups where one control selects some automatic feature and
599 * the other controls are only active whenever the automatic feature is turned
600 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
601 * red and blue balance, etc.
602 *
603 * The behavior of such controls is as follows:
604 *
605 * When the autofoo control is set to automatic, then any manual controls
606 * are set to inactive and any reads will call g_volatile_ctrl (if the control
607 * was marked volatile).
608 *
609 * When the autofoo control is set to manual, then any manual controls will
610 * be marked active, and any reads will just return the current value without
611 * going through g_volatile_ctrl.
612 *
613 * In addition, this function will set the V4L2_CTRL_FLAG_UPDATE flag
614 * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
615 * if autofoo is in auto mode.
616 */
Hans Verkuil72d877c2011-06-10 05:44:36 -0300617void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
618 u8 manual_val, bool set_volatile);
619
620
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300621/**
622 * v4l2_ctrl_find() - Find a control with the given ID.
623 * @hdl: The control handler.
624 * @id: The control ID to find.
625 *
626 * If @hdl == NULL this will return NULL as well. Will lock the handler so
627 * do not use from inside &v4l2_ctrl_ops.
628 */
Hans Verkuil09965172010-08-01 14:32:42 -0300629struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
630
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300631/**
632 * v4l2_ctrl_activate() - Make the control active or inactive.
633 * @ctrl: The control to (de)activate.
634 * @active: True if the control should become active.
635 *
636 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
637 * Does nothing if @ctrl == NULL.
638 * This will usually be called from within the s_ctrl op.
639 * The V4L2_EVENT_CTRL event will be generated afterwards.
640 *
641 * This function assumes that the control handler is locked.
642 */
Hans Verkuil09965172010-08-01 14:32:42 -0300643void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
644
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300645/**
646 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
647 * @ctrl: The control to (de)activate.
648 * @grabbed: True if the control should become grabbed.
649 *
650 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
651 * Does nothing if @ctrl == NULL.
652 * The V4L2_EVENT_CTRL event will be generated afterwards.
653 * This will usually be called when starting or stopping streaming in the
654 * driver.
655 *
656 * This function assumes that the control handler is not locked and will
657 * take the lock itself.
658 */
Hans Verkuil09965172010-08-01 14:32:42 -0300659void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
660
Sakari Ailus5a573922014-06-12 13:09:40 -0300661
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300662/**
663 *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
664 *
665 * @ctrl: The control to update.
666 * @min: The control's minimum value.
667 * @max: The control's maximum value.
668 * @step: The control's step value
669 * @def: The control's default value.
670 *
671 * Update the range of a control on the fly. This works for control types
672 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
673 * @step value is interpreted as a menu_skip_mask.
674 *
675 * An error is returned if one of the range arguments is invalid for this
676 * control type.
677 *
678 * This function assumes that the control handler is not locked and will
679 * take the lock itself.
680 */
Sakari Ailus5a573922014-06-12 13:09:40 -0300681int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
682 s64 min, s64 max, u64 step, s64 def);
683
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300684/**
685 * v4l2_ctrl_modify_range() - Update the range of a control.
686 * @ctrl: The control to update.
687 * @min: The control's minimum value.
688 * @max: The control's maximum value.
689 * @step: The control's step value
690 * @def: The control's default value.
691 *
692 * Update the range of a control on the fly. This works for control types
693 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
694 * @step value is interpreted as a menu_skip_mask.
695 *
696 * An error is returned if one of the range arguments is invalid for this
697 * control type.
698 *
699 * This function assumes that the control handler is not locked and will
700 * take the lock itself.
701 */
Sakari Ailus5a573922014-06-12 13:09:40 -0300702static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
703 s64 min, s64 max, u64 step, s64 def)
704{
705 int rval;
706
707 v4l2_ctrl_lock(ctrl);
708 rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
709 v4l2_ctrl_unlock(ctrl);
710
711 return rval;
712}
Sylwester Nawrocki2ccbe772013-01-19 15:51:55 -0300713
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300714/**
715 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
716 * @ctrl: The control.
717 * @notify: The callback function.
718 * @priv: The callback private handle, passed as argument to the callback.
719 *
720 * This function sets a callback function for the control. If @ctrl is NULL,
721 * then it will do nothing. If @notify is NULL, then the notify callback will
722 * be removed.
723 *
724 * There can be only one notify. If another already exists, then a WARN_ON
725 * will be issued and the function will do nothing.
726 */
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300727void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv);
728
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300729/**
730 * v4l2_ctrl_get_name() - Get the name of the control
Hans Verkuil79fbc202014-11-23 09:39:54 -0300731 * @id: The control ID.
732 *
733 * This function returns the name of the given control ID or NULL if it isn't
734 * a known control.
735 */
736const char *v4l2_ctrl_get_name(u32 id);
737
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300738/**
739 * v4l2_ctrl_get_menu() - Get the menu string array of the control
Hans Verkuil79fbc202014-11-23 09:39:54 -0300740 * @id: The control ID.
741 *
742 * This function returns the NULL-terminated menu string array name of the
743 * given control ID or NULL if it isn't a known menu control.
744 */
745const char * const *v4l2_ctrl_get_menu(u32 id);
746
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300747/**
748 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
Hans Verkuil79fbc202014-11-23 09:39:54 -0300749 * @id: The control ID.
750 * @len: The size of the integer array.
751 *
752 * This function returns the integer array of the given control ID or NULL if it
753 * if it isn't a known integer menu control.
754 */
755const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
756
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300757/**
758 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver.
759 * @ctrl: The control.
760 *
761 * This returns the control's value safely by going through the control
762 * framework. This function will lock the control's handler, so it cannot be
763 * used from within the &v4l2_ctrl_ops functions.
764 *
765 * This function is for integer type controls only.
766 */
Hans Verkuil09965172010-08-01 14:32:42 -0300767s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
768
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300769/**
770 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
771 * @ctrl: The control.
772 * @val: The new value.
773 *
774 * This set the control's new value safely by going through the control
775 * framework. This function will lock the control's handler, so it cannot be
776 * used from within the &v4l2_ctrl_ops functions.
777 *
778 * This function is for integer type controls only.
779 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300780int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300781
Hans Verkuil09965172010-08-01 14:32:42 -0300782/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300783 * @ctrl: The control.
784 * @val: The new value.
785 *
786 * This set the control's new value safely by going through the control
787 * framework. This function will lock the control's handler, so it cannot be
788 * used from within the &v4l2_ctrl_ops functions.
789 *
790 * This function is for integer type controls only.
791 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300792static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
793{
794 int rval;
795
796 v4l2_ctrl_lock(ctrl);
797 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
798 v4l2_ctrl_unlock(ctrl);
799
800 return rval;
801}
Hans Verkuil09965172010-08-01 14:32:42 -0300802
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300803/**
804 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
805 * from within a driver.
806 * @ctrl: The control.
807 *
808 * This returns the control's value safely by going through the control
809 * framework. This function will lock the control's handler, so it cannot be
810 * used from within the &v4l2_ctrl_ops functions.
811 *
812 * This function is for 64-bit integer type controls only.
813 */
Laurent Pinchart03d52852012-07-23 09:15:21 -0300814s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
815
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300816/**
817 * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
818 *
819 * @ctrl: The control.
820 * @val: The new value.
821 *
822 * This set the control's new value safely by going through the control
823 * framework. This function will lock the control's handler, so it cannot be
824 * used from within the &v4l2_ctrl_ops functions.
825 *
826 * This function is for 64-bit integer type controls only.
827 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300828int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
829
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300830/** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
831 * from within a driver.
832 *
833 * @ctrl: The control.
834 * @val: The new value.
835 *
836 * This set the control's new value safely by going through the control
837 * framework. This function will lock the control's handler, so it cannot be
838 * used from within the &v4l2_ctrl_ops functions.
839 *
840 * This function is for 64-bit integer type controls only.
841 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300842static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
843{
844 int rval;
845
846 v4l2_ctrl_lock(ctrl);
847 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
848 v4l2_ctrl_unlock(ctrl);
849
850 return rval;
851}
Laurent Pinchart03d52852012-07-23 09:15:21 -0300852
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300853/** __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
854 *
855 * @ctrl: The control.
856 * @s: The new string.
857 *
858 * This set the control's new string safely by going through the control
859 * framework. This function will lock the control's handler, so it cannot be
860 * used from within the &v4l2_ctrl_ops functions.
861 *
862 * This function is for string type controls only.
863 */
Hans Verkuil5d0360a2014-07-21 10:45:42 -0300864int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
865
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300866/** v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
867 * from within a driver.
868 *
869 * @ctrl: The control.
870 * @s: The new string.
871 *
872 * This set the control's new string safely by going through the control
873 * framework. This function will lock the control's handler, so it cannot be
874 * used from within the &v4l2_ctrl_ops functions.
875 *
876 * This function is for string type controls only.
877 */
Hans Verkuil5d0360a2014-07-21 10:45:42 -0300878static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
879{
880 int rval;
881
882 v4l2_ctrl_lock(ctrl);
883 rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
884 v4l2_ctrl_unlock(ctrl);
885
886 return rval;
887}
888
Hans Verkuilce727572011-06-10 05:56:39 -0300889/* Internal helper functions that deal with control events. */
Hans de Goede3e3661492012-04-08 12:59:47 -0300890extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
891void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
892void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
Hans Verkuil6e239392011-06-07 11:13:44 -0300893
Hans Verkuile2ecb252012-02-02 08:20:53 -0300894/* Can be used as a vidioc_log_status function that just dumps all controls
895 associated with the filehandle. */
896int v4l2_ctrl_log_status(struct file *file, void *fh);
897
Hans Verkuila26243b2012-01-27 16:18:42 -0300898/* Can be used as a vidioc_subscribe_event function that just subscribes
899 control events. */
900int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
Hans Verkuil85f5fe32012-09-04 11:46:09 -0300901 const struct v4l2_event_subscription *sub);
Hans Verkuila26243b2012-01-27 16:18:42 -0300902
903/* Can be used as a poll function that just polls for control events. */
904unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
905
Hans Verkuil09965172010-08-01 14:32:42 -0300906/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
907int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
Hans Verkuild9a25472014-06-12 07:54:16 -0300908int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctrl *qc);
Hans Verkuil09965172010-08-01 14:32:42 -0300909int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
910int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
Hans Verkuilab892ba2011-06-07 06:47:18 -0300911int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
912 struct v4l2_control *ctrl);
Hans Verkuil09965172010-08-01 14:32:42 -0300913int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
914int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
Hans Verkuilab892ba2011-06-07 06:47:18 -0300915int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
916 struct v4l2_ext_controls *c);
Hans Verkuil09965172010-08-01 14:32:42 -0300917
918/* Helpers for subdevices. If the associated ctrl_handler == NULL then they
919 will all return -EINVAL. */
920int v4l2_subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
921int v4l2_subdev_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
922int v4l2_subdev_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
923int v4l2_subdev_try_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
924int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
925int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
926int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
927
Sylwester Nawrocki22fa4272013-01-22 19:00:23 -0300928/* Can be used as a subscribe_event function that just subscribes control
929 events. */
930int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
931 struct v4l2_event_subscription *sub);
932
Sylwester Nawrockiffa9b9f2013-01-22 19:01:02 -0300933/* Log all controls owned by subdev's control handler. */
934int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
935
Hans Verkuil09965172010-08-01 14:32:42 -0300936#endif