Blame view

include/media/v4l2-ctrls.h 38.1 KB
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1
  /*
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
2
3
4
5
6
7
8
9
10
11
12
13
14
   *  V4L2 controls support header.
   *
   *  Copyright (C) 2010  Hans Verkuil <hverkuil@xs4all.nl>
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or
   *  (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
15
16
17
18
19
20
   */
  
  #ifndef _V4L2_CTRLS_H
  #define _V4L2_CTRLS_H
  
  #include <linux/list.h>
a19dec6ea   Andrzej Hajda   [media] v4l2: add...
21
  #include <linux/mutex.h>
01c40c048   Laurent Pinchart   [media] v4l: Incl...
22
  #include <linux/videodev2.h>
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
23
24
  
  /* forward references */
528f0f785   Laurent Pinchart   [media] v4l: v4l2...
25
  struct file;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
26
  struct v4l2_ctrl_handler;
eb5b16efb   Hans Verkuil   [media] v4l2-ctrl...
27
  struct v4l2_ctrl_helper;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
28
29
30
  struct v4l2_ctrl;
  struct video_device;
  struct v4l2_subdev;
77068d36d   Hans Verkuil   [media] v4l2-ctrl...
31
  struct v4l2_subscribed_event;
6e239399e   Hans Verkuil   [media] v4l2-ctrl...
32
  struct v4l2_fh;
a26243b0e   Hans Verkuil   [media] v4l2-ctrl...
33
  struct poll_table_struct;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
34

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
35
36
  /**
   * union v4l2_ctrl_ptr - A pointer to a control value.
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
37
38
   * @p_s32:	Pointer to a 32-bit signed value.
   * @p_s64:	Pointer to a 64-bit signed value.
dda4a4d5e   Hans Verkuil   [media] v4l2-ctrl...
39
40
   * @p_u8:	Pointer to a 8-bit unsigned value.
   * @p_u16:	Pointer to a 16-bit unsigned value.
811c50810   Hans Verkuil   [media] v4l2-ctrl...
41
   * @p_u32:	Pointer to a 32-bit unsigned value.
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
42
43
44
45
46
47
   * @p_char:	Pointer to a string.
   * @p:		Pointer to a compound value.
   */
  union v4l2_ctrl_ptr {
  	s32 *p_s32;
  	s64 *p_s64;
dda4a4d5e   Hans Verkuil   [media] v4l2-ctrl...
48
49
  	u8 *p_u8;
  	u16 *p_u16;
811c50810   Hans Verkuil   [media] v4l2-ctrl...
50
  	u32 *p_u32;
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
51
52
53
  	char *p_char;
  	void *p;
  };
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
54
55
  /**
   * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
56
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
57
58
59
60
61
62
63
64
65
66
67
   * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
   *		for volatile (and usually read-only) controls such as a control
   *		that returns the current signal strength which changes
   *		continuously.
   *		If not set, then the currently cached value will be returned.
   * @try_ctrl:	Test whether the control's value is valid. Only relevant when
   *		the usual min/max/step checks are not sufficient.
   * @s_ctrl:	Actually set the new control value. s_ctrl is compulsory. The
   *		ctrl->handler->lock is held when these ops are called, so no
   *		one else can access controls owned by that handler.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
68
69
70
71
72
  struct v4l2_ctrl_ops {
  	int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
  	int (*try_ctrl)(struct v4l2_ctrl *ctrl);
  	int (*s_ctrl)(struct v4l2_ctrl *ctrl);
  };
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
73
74
  /**
   * struct v4l2_ctrl_type_ops - The control type operations that the driver
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
75
   *			       has to provide.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
76
77
78
79
   *
   * @equal: return true if both values are equal.
   * @init: initialize the value.
   * @log: log the value.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
80
81
   * @validate: validate the value. Return 0 on success and a negative value
   *	otherwise.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
82
   */
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
83
  struct v4l2_ctrl_type_ops {
998e76591   Hans Verkuil   [media] v4l2-ctrl...
84
  	bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
85
86
  		      union v4l2_ctrl_ptr ptr1,
  		      union v4l2_ctrl_ptr ptr2);
998e76591   Hans Verkuil   [media] v4l2-ctrl...
87
  	void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
88
89
  		     union v4l2_ctrl_ptr ptr);
  	void (*log)(const struct v4l2_ctrl *ctrl);
998e76591   Hans Verkuil   [media] v4l2-ctrl...
90
  	int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
91
92
  			union v4l2_ctrl_ptr ptr);
  };
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
93
94
95
96
97
98
99
100
101
102
  /**
   * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
   *	that should be called when a control value has changed.
   *
   * @ctrl: pointer to struct &v4l2_ctrl
   * @priv: control private data
   *
   * This typedef definition is used as an argument to v4l2_ctrl_notify()
   * and as an argument at struct &v4l2_ctrl_handler.
   */
8ac7a9493   Hans Verkuil   [media] v4l2-ctrl...
103
  typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
104
105
  /**
   * struct v4l2_ctrl - The control structure.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
106
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
107
108
109
110
111
112
113
   * @node:	The list node.
   * @ev_subs:	The list of control event subscriptions.
   * @handler:	The handler that owns the control.
   * @cluster:	Point to start of cluster array.
   * @ncontrols:	Number of controls in cluster array.
   * @done:	Internal flag: set for each processed control.
   * @is_new:	Set when the user specified a new value for this control. It
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
114
   *		is also set when called from v4l2_ctrl_handler_setup(). Drivers
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
115
116
117
118
119
120
121
122
123
124
125
126
   *		should never set this flag.
   * @has_changed: Set when the current value differs from the new value. Drivers
   *		should never use this flag.
   * @is_private: If set, then this control is private to its handler and it
   *		will not be added to any other handlers. Drivers can set
   *		this flag.
   * @is_auto:   If set, then this control selects whether the other cluster
   *		members are in 'automatic' mode or 'manual' mode. This is
   *		used for autogain/gain type clusters. Drivers should never
   *		set this flag directly.
   * @is_int:    If set, then this control has a simple integer value (i.e. it
   *		uses ctrl->val).
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
127
128
129
130
   * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
   * @is_ptr:	If set, then this control is an array and/or has type >=
   *		%V4L2_CTRL_COMPOUND_TYPES
   *		and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
   *		v4l2_ext_control uses field p to point to the data.
   * @is_array: If set, then this control contains an N-dimensional array.
   * @has_volatiles: If set, then one or more members of the cluster are volatile.
   *		Drivers should never touch this flag.
   * @call_notify: If set, then call the handler's notify function whenever the
   *		control's value changes.
   * @manual_mode_value: If the is_auto flag is set, then this is the value
   *		of the auto control that determines if that control is in
   *		manual mode. So if the value of the auto control equals this
   *		value, then the whole cluster is in manual mode. Drivers should
   *		never set this flag directly.
   * @ops:	The control ops.
   * @type_ops:	The control type ops.
   * @id:	The control ID.
   * @name:	The control name.
   * @type:	The control type.
   * @minimum:	The control's minimum value.
   * @maximum:	The control's maximum value.
   * @default_value: The control's default value.
   * @step:	The control's step value for non-menu controls.
   * @elems:	The number of elements in the N-dimensional array.
   * @elem_size:	The size in bytes of the control.
   * @dims:	The size of each dimension.
   * @nr_of_dims:The number of dimensions in @dims.
   * @menu_skip_mask: The control's skip mask for menu controls. This makes it
   *		easy to skip menu items that are not valid. If bit X is set,
   *		then menu item X is skipped. Of course, this only works for
   *		menus with <= 32 menu items. There are no menus that come
   *		close to that number, so this is OK. Should we ever need more,
   *		then this will have to be extended to a u64 or a bit array.
   * @qmenu:	A const char * array for all menu items. Array entries that are
   *		empty strings ("") correspond to non-existing menu items (this
   *		is in addition to the menu_skip_mask above). The last entry
   *		must be NULL.
   * @flags:	The control's flags.
   * @cur:	The control's current value.
   * @val:	The control's new s32 value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
168
169
170
171
172
   * @priv:	The control's private pointer. For use by the driver. It is
   *		untouched by the control framework. Note that this pointer is
   *		not freed when the control is deleted. Should this be needed
   *		then a new internal bitfield can be added to tell the framework
   *		to free this pointer.
03440c4e5   Masahiro Yamada   scripts/spelling....
173
   * @p_cur:	The control's current value represented via a union with
7dc879190   Mauro Carvalho Chehab   [media] v4l2-ctrl...
174
175
   *		provides a standard way of accessing control types
   *		through a pointer.
03440c4e5   Masahiro Yamada   scripts/spelling....
176
   * @p_new:	The control's new value represented via a union with provides
7dc879190   Mauro Carvalho Chehab   [media] v4l2-ctrl...
177
178
   *		a standard way of accessing control types
   *		through a pointer.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
179
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
180
181
182
  struct v4l2_ctrl {
  	/* Administrative fields */
  	struct list_head node;
77068d36d   Hans Verkuil   [media] v4l2-ctrl...
183
  	struct list_head ev_subs;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
184
185
  	struct v4l2_ctrl_handler *handler;
  	struct v4l2_ctrl **cluster;
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
186
  	unsigned int ncontrols;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
187
  	unsigned int done:1;
2a863793b   Hans Verkuil   [media] v4l2-ctrl...
188
  	unsigned int is_new:1;
9ea1b7a4b   Hans Verkuil   [media] v4l2-ctrl...
189
  	unsigned int has_changed:1;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
190
  	unsigned int is_private:1;
72d877cac   Hans Verkuil   [media] v4l2-ctrl...
191
  	unsigned int is_auto:1;
d9a254715   Hans Verkuil   [media] v4l2-ctrl...
192
193
194
  	unsigned int is_int:1;
  	unsigned int is_string:1;
  	unsigned int is_ptr:1;
998e76591   Hans Verkuil   [media] v4l2-ctrl...
195
  	unsigned int is_array:1;
5626b8c75   Hans Verkuil   [media] v4l2-ctrl...
196
  	unsigned int has_volatiles:1;
8ac7a9493   Hans Verkuil   [media] v4l2-ctrl...
197
  	unsigned int call_notify:1;
82a7c0494   Hans Verkuil   [media] v4l2-ctrl...
198
  	unsigned int manual_mode_value:8;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
199
200
  
  	const struct v4l2_ctrl_ops *ops;
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
201
  	const struct v4l2_ctrl_type_ops *type_ops;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
202
203
204
  	u32 id;
  	const char *name;
  	enum v4l2_ctrl_type type;
0ba2aeb6d   Hans Verkuil   [media] v4l2-ctrl...
205
  	s64 minimum, maximum, default_value;
20d88eef6   Hans Verkuil   [media] v4l2-ctrl...
206
  	u32 elems;
d9a254715   Hans Verkuil   [media] v4l2-ctrl...
207
  	u32 elem_size;
20d88eef6   Hans Verkuil   [media] v4l2-ctrl...
208
209
  	u32 dims[V4L2_CTRL_MAX_DIMS];
  	u32 nr_of_dims;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
210
  	union {
0ba2aeb6d   Hans Verkuil   [media] v4l2-ctrl...
211
212
  		u64 step;
  		u64 menu_skip_mask;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
213
  	};
ce580fe51   Sakari Ailus   [media] v4l: Intr...
214
215
216
217
  	union {
  		const char * const *qmenu;
  		const s64 *qmenu_int;
  	};
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
218
  	unsigned long flags;
d9a254715   Hans Verkuil   [media] v4l2-ctrl...
219
  	void *priv;
2a9ec3731   Hans Verkuil   [media] v4l2-ctrl...
220
221
  	s32 val;
  	struct {
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
222
  		s32 val;
d9a254715   Hans Verkuil   [media] v4l2-ctrl...
223
  	} cur;
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
224
225
226
  
  	union v4l2_ctrl_ptr p_new;
  	union v4l2_ctrl_ptr p_cur;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
227
  };
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
228
229
  /**
   * struct v4l2_ctrl_ref - The control reference.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
230
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
231
232
233
   * @node:	List node for the sorted list.
   * @next:	Single-link list node for the hash.
   * @ctrl:	The actual control information.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
234
   * @helper:	Pointer to helper struct. Used internally in
fb91161a3   Mauro Carvalho Chehab   [media] v4l2-ctrl...
235
   *		``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
236
237
238
239
240
   *
   * Each control handler has a list of these refs. The list_head is used to
   * keep a sorted-by-control-ID list of all controls, while the next pointer
   * is used to link the control in the hash's bucket.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
241
242
243
244
  struct v4l2_ctrl_ref {
  	struct list_head node;
  	struct v4l2_ctrl_ref *next;
  	struct v4l2_ctrl *ctrl;
eb5b16efb   Hans Verkuil   [media] v4l2-ctrl...
245
  	struct v4l2_ctrl_helper *helper;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
246
  };
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
247
248
  /**
   * struct v4l2_ctrl_handler - The control handler keeps track of all the
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
249
250
251
   *	controls: both the controls owned by the handler and those inherited
   *	from other handlers.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
252
253
254
255
256
257
258
259
260
   * @_lock:	Default for "lock".
   * @lock:	Lock to control access to this handler and its controls.
   *		May be replaced by the user right after init.
   * @ctrls:	The list of controls owned by this handler.
   * @ctrl_refs:	The list of control references.
   * @cached:	The last found control reference. It is common that the same
   *		control is needed multiple times, so this is a simple
   *		optimization.
   * @buckets:	Buckets for the hashing. Allows for quick control lookup.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
261
262
   * @notify:	A notify callback that is called whenever the control changes
   *		value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
263
264
265
266
267
268
   *		Note that the handler's lock is held when the notify function
   *		is called!
   * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
   * @nr_of_buckets: Total number of buckets in the array.
   * @error:	The error code of the first failed control addition.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
269
  struct v4l2_ctrl_handler {
77e7c4e62   Sakari Ailus   [media] v4l: Allo...
270
271
  	struct mutex _lock;
  	struct mutex *lock;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
272
273
274
275
  	struct list_head ctrls;
  	struct list_head ctrl_refs;
  	struct v4l2_ctrl_ref *cached;
  	struct v4l2_ctrl_ref **buckets;
8ac7a9493   Hans Verkuil   [media] v4l2-ctrl...
276
277
  	v4l2_ctrl_notify_fnc notify;
  	void *notify_priv;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
278
279
280
  	u16 nr_of_buckets;
  	int error;
  };
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
281
282
  /**
   * struct v4l2_ctrl_config - Control configuration structure.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
283
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
284
285
286
287
288
289
290
291
   * @ops:	The control ops.
   * @type_ops:	The control type ops. Only needed for compound controls.
   * @id:	The control ID.
   * @name:	The control name.
   * @type:	The control type.
   * @min:	The control's minimum value.
   * @max:	The control's maximum value.
   * @step:	The control's step value for non-menu controls.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
292
   * @def:	The control's default value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
293
294
295
296
297
298
299
300
301
302
303
304
305
   * @dims:	The size of each dimension.
   * @elem_size:	The size in bytes of the control.
   * @flags:	The control's flags.
   * @menu_skip_mask: The control's skip mask for menu controls. This makes it
   *		easy to skip menu items that are not valid. If bit X is set,
   *		then menu item X is skipped. Of course, this only works for
   *		menus with <= 64 menu items. There are no menus that come
   *		close to that number, so this is OK. Should we ever need more,
   *		then this will have to be extended to a bit array.
   * @qmenu:	A const char * array for all menu items. Array entries that are
   *		empty strings ("") correspond to non-existing menu items (this
   *		is in addition to the menu_skip_mask above). The last entry
   *		must be NULL.
7dc879190   Mauro Carvalho Chehab   [media] v4l2-ctrl...
306
   * @qmenu_int:	A const s64 integer array for all menu items of the type
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
307
   *		V4L2_CTRL_TYPE_INTEGER_MENU.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
308
309
310
   * @is_private: If set, then this control is private to its handler and it
   *		will not be added to any other handlers.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
311
312
  struct v4l2_ctrl_config {
  	const struct v4l2_ctrl_ops *ops;
0176077a8   Hans Verkuil   [media] v4l2-ctrl...
313
  	const struct v4l2_ctrl_type_ops *type_ops;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
314
315
316
  	u32 id;
  	const char *name;
  	enum v4l2_ctrl_type type;
0ba2aeb6d   Hans Verkuil   [media] v4l2-ctrl...
317
318
319
320
  	s64 min;
  	s64 max;
  	u64 step;
  	s64 def;
20d88eef6   Hans Verkuil   [media] v4l2-ctrl...
321
  	u32 dims[V4L2_CTRL_MAX_DIMS];
d9a254715   Hans Verkuil   [media] v4l2-ctrl...
322
  	u32 elem_size;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
323
  	u32 flags;
0ba2aeb6d   Hans Verkuil   [media] v4l2-ctrl...
324
  	u64 menu_skip_mask;
513521eae   Hans Verkuil   [media] v4l2-ctrl...
325
  	const char * const *qmenu;
ce580fe51   Sakari Ailus   [media] v4l: Intr...
326
  	const s64 *qmenu_int;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
327
  	unsigned int is_private:1;
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
328
  };
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
329
330
331
332
  /**
   * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
   *
   * @id: ID of the control
67c672ecd   Mauro Carvalho Chehab   media: v4l2-ctrls...
333
334
335
336
337
338
339
   * @name: pointer to be filled with a string with the name of the control
   * @type: pointer for storing the type of the control
   * @min: pointer for storing the minimum value for the control
   * @max: pointer for storing the maximum value for the control
   * @step: pointer for storing the control step
   * @def: pointer for storing the default value for the control
   * @flags: pointer for storing the flags to be used on the control
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
340
341
342
   *
   * This works for all standard V4L2 controls.
   * For non-standard controls it will only fill in the given arguments
67c672ecd   Mauro Carvalho Chehab   media: v4l2-ctrls...
343
   * and @name content will be set to %NULL.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
344
345
346
347
348
   *
   * This function will overwrite the contents of @name, @type and @flags.
   * The contents of @min, @max, @step and @def may be modified depending on
   * the type.
   *
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
349
350
351
352
353
   * .. note::
   *
   *    Do not use in drivers! It is used internally for backwards compatibility
   *    control handling only. Once all drivers are converted to use the new
   *    control framework this function will no longer be exported.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
354
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
355
  void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
0ba2aeb6d   Hans Verkuil   [media] v4l2-ctrl...
356
  		    s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
357

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
358
359
360
361
362
363
364
365
366
367
368
369
370
  /**
   * v4l2_ctrl_handler_init_class() - Initialize the control handler.
   * @hdl:	The control handler.
   * @nr_of_controls_hint: A hint of how many controls this handler is
   *		expected to refer to. This is the total number, so including
   *		any inherited controls. It doesn't have to be precise, but if
   *		it is way off, then you either waste memory (too many buckets
   *		are allocated) or the control lookup becomes slower (not enough
   *		buckets are allocated, so there are more slow list lookups).
   *		It will always work, though.
   * @key:	Used by the lock validator if CONFIG_LOCKDEP is set.
   * @name:	Used by the lock validator if CONFIG_LOCKDEP is set.
   *
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
371
372
373
374
   * .. attention::
   *
   *    Never use this call directly, always use the v4l2_ctrl_handler_init()
   *    macro that hides the @key and @name arguments.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
375
   *
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
376
377
   * Return: returns an error if the buckets could not be allocated. This
   * error will also be stored in @hdl->error.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
378
   */
6cd247ef2   Andy Walls   [media] v4l2-ctrl...
379
  int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
380
  				 unsigned int nr_of_controls_hint,
6cd247ef2   Andy Walls   [media] v4l2-ctrl...
381
382
383
  				 struct lock_class_key *key, const char *name);
  
  #ifdef CONFIG_LOCKDEP
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
384
385
  
  /**
e383ce073   Mauro Carvalho Chehab   [media] get rid o...
386
387
   * v4l2_ctrl_handler_init - helper function to create a static struct
   *	 &lock_class_key and calls v4l2_ctrl_handler_init_class()
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
   *
   * @hdl:	The control handler.
   * @nr_of_controls_hint: A hint of how many controls this handler is
   *		expected to refer to. This is the total number, so including
   *		any inherited controls. It doesn't have to be precise, but if
   *		it is way off, then you either waste memory (too many buckets
   *		are allocated) or the control lookup becomes slower (not enough
   *		buckets are allocated, so there are more slow list lookups).
   *		It will always work, though.
   *
   * This helper function creates a static struct &lock_class_key and
   * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
   * validador.
   *
   * Use this helper function to initialize a control handler.
   */
6cd247ef2   Andy Walls   [media] v4l2-ctrl...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
  #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint)		\
  (									\
  	({								\
  		static struct lock_class_key _key;			\
  		v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint,	\
  					&_key,				\
  					KBUILD_BASENAME ":"		\
  					__stringify(__LINE__) ":"	\
  					"(" #hdl ")->_lock");		\
  	})								\
  )
  #else
  #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint)		\
  	v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
  #endif
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
419

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
420
421
422
423
424
425
426
  /**
   * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
   * the control list.
   * @hdl:	The control handler.
   *
   * Does nothing if @hdl == NULL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
427
  void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
428
429
430
431
432
  /**
   * v4l2_ctrl_lock() - Helper function to lock the handler
   * associated with the control.
   * @ctrl:	The control to lock.
   */
605b38403   Sakari Ailus   [media] v4l: ctrl...
433
434
435
436
  static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
  {
  	mutex_lock(ctrl->handler->lock);
  }
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
437
438
439
440
441
  /**
   * v4l2_ctrl_unlock() - Helper function to unlock the handler
   * associated with the control.
   * @ctrl:	The control to unlock.
   */
605b38403   Sakari Ailus   [media] v4l: ctrl...
442
443
444
445
  static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
  {
  	mutex_unlock(ctrl->handler->lock);
  }
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
446
  /**
cc0140e2a   Sakari Ailus   [media] v4l2-ctrl...
447
448
449
450
451
452
453
454
455
456
457
458
459
   * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
   * to the handler to initialize the hardware to the current control values. The
   * caller is responsible for acquiring the control handler mutex on behalf of
   * __v4l2_ctrl_handler_setup().
   * @hdl:	The control handler.
   *
   * Button controls will be skipped, as are read-only controls.
   *
   * If @hdl == NULL, then this just returns 0.
   */
  int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
  
  /**
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
460
461
462
463
464
465
466
467
   * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
   * to the handler to initialize the hardware to the current control values.
   * @hdl:	The control handler.
   *
   * Button controls will be skipped, as are read-only controls.
   *
   * If @hdl == NULL, then this just returns 0.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
468
  int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
469
470
471
472
473
474
475
476
477
478
479
480
  /**
   * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
   * @hdl:	The control handler.
   * @prefix:	The prefix to use when logging the control values. If the
   *		prefix does not end with a space, then ": " will be added
   *		after the prefix. If @prefix == NULL, then no prefix will be
   *		used.
   *
   * For use with VIDIOC_LOG_STATUS.
   *
   * Does nothing if @hdl == NULL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
481
482
  void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
  				  const char *prefix);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
483
484
  /**
   * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
485
486
   *	control.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
487
488
489
490
491
492
493
   * @hdl:	The control handler.
   * @cfg:	The control's configuration data.
   * @priv:	The control's driver-specific private data.
   *
   * If the &v4l2_ctrl struct could not be allocated then NULL is returned
   * and @hdl->error is set to the error code (if it wasn't set already).
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
494
  struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
495
496
  				       const struct v4l2_ctrl_config *cfg,
  				       void *priv);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
497

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
498
  /**
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
499
500
501
   * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
   *	control.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
502
503
   * @hdl:	The control handler.
   * @ops:	The control ops.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
504
   * @id:		The control ID.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
505
506
507
   * @min:	The control's minimum value.
   * @max:	The control's maximum value.
   * @step:	The control's step value
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
508
   * @def:	The control's default value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
509
510
511
512
513
514
515
516
517
   *
   * If the &v4l2_ctrl struct could not be allocated, or the control
   * ID is not known, then NULL is returned and @hdl->error is set to the
   * appropriate error code (if it wasn't set already).
   *
   * If @id refers to a menu control, then this function will return NULL.
   *
   * Use v4l2_ctrl_new_std_menu() when adding menu controls.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
518
  struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
519
520
521
  				    const struct v4l2_ctrl_ops *ops,
  				    u32 id, s64 min, s64 max, u64 step,
  				    s64 def);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
522

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
523
  /**
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
524
525
526
   * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
   *	menu control.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
527
528
   * @hdl:	The control handler.
   * @ops:	The control ops.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
529
   * @id:		The control ID.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
530
   * @max:	The control's maximum value.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
531
   * @mask:	The control's skip mask for menu controls. This makes it
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
532
533
534
535
536
   *		easy to skip menu items that are not valid. If bit X is set,
   *		then menu item X is skipped. Of course, this only works for
   *		menus with <= 64 menu items. There are no menus that come
   *		close to that number, so this is OK. Should we ever need more,
   *		then this will have to be extended to a bit array.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
537
   * @def:	The control's default value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
538
539
540
541
542
543
   *
   * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
   * determines which menu items are to be skipped.
   *
   * If @id refers to a non-menu control, then this function will return NULL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
544
  struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
545
546
  					 const struct v4l2_ctrl_ops *ops,
  					 u32 id, u8 max, u64 mask, u8 def);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
547

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
548
549
  /**
   * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
550
551
   *	with driver specific menu.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
   * @hdl:	The control handler.
   * @ops:	The control ops.
   * @id:	The control ID.
   * @max:	The control's maximum value.
   * @mask:	The control's skip mask for menu controls. This makes it
   *		easy to skip menu items that are not valid. If bit X is set,
   *		then menu item X is skipped. Of course, this only works for
   *		menus with <= 64 menu items. There are no menus that come
   *		close to that number, so this is OK. Should we ever need more,
   *		then this will have to be extended to a bit array.
   * @def:	The control's default value.
   * @qmenu:	The new menu.
   *
   * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
   * menu of this control.
   *
   */
117a711a2   Lad, Prabhakar   [media] media: v4...
569
  struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
570
571
572
573
  					       const struct v4l2_ctrl_ops *ops,
  					       u32 id, u8 max,
  					       u64 mask, u8 def,
  					       const char * const *qmenu);
117a711a2   Lad, Prabhakar   [media] media: v4...
574

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
575
576
  /**
   * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
577
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
578
579
580
581
582
583
584
585
586
587
   * @hdl:	The control handler.
   * @ops:	The control ops.
   * @id:	The control ID.
   * @max:	The control's maximum value.
   * @def:	The control's default value.
   * @qmenu_int:	The control's menu entries.
   *
   * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
   * takes as an argument an array of integers determining the menu items.
   *
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
588
589
   * If @id refers to a non-integer-menu control, then this function will
   * return %NULL.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
590
   */
515f32879   Sylwester Nawrocki   [media] V4L: Add ...
591
  struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
592
593
594
  					 const struct v4l2_ctrl_ops *ops,
  					 u32 id, u8 max, u8 def,
  					 const s64 *qmenu_int);
515f32879   Sylwester Nawrocki   [media] V4L: Add ...
595

2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
596
597
598
599
600
601
  /**
   * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
   *	used when adding a control handler.
   *
   * @ctrl: pointer to struct &v4l2_ctrl.
   */
6d85d7d7e   Mauro Carvalho Chehab   [media] doc-rst: ...
602
  typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
603
  /**
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
604
   * v4l2_ctrl_add_handler() - Add all controls from handler @add to
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
605
606
   *	handler @hdl.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
607
608
609
610
611
612
613
614
615
616
617
   * @hdl:	The control handler.
   * @add:	The control handler whose controls you want to add to
   *		the @hdl control handler.
   * @filter:	This function will filter which controls should be added.
   *
   * Does nothing if either of the two handlers is a NULL pointer.
   * If @filter is NULL, then all controls are added. Otherwise only those
   * controls for which @filter returns true will be added.
   * In case of an error @hdl->error will be set to the error code (if it
   * wasn't set already).
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
618
  int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
34a6b7d09   Hans Verkuil   [media] v4l2-ctrl...
619
  			  struct v4l2_ctrl_handler *add,
6d85d7d7e   Mauro Carvalho Chehab   [media] doc-rst: ...
620
  			  v4l2_ctrl_filter filter);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
621

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
622
623
  /**
   * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
624
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
625
626
627
628
629
630
631
632
   * @ctrl:	The control that is filtered.
   *
   * This will return true for any controls that are valid for radio device
   * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
   * transmitter class controls.
   *
   * This function is to be used with v4l2_ctrl_add_handler().
   */
34a6b7d09   Hans Verkuil   [media] v4l2-ctrl...
633
  bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
634

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
635
  /**
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
636
637
638
   * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
   *	to that cluster.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
639
   * @ncontrols:	The number of controls in this cluster.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
640
   * @controls:	The cluster control array of size @ncontrols.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
641
   */
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
642
  void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
643

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
644
  /**
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
645
646
647
   * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
   *	to that cluster and set it up for autofoo/foo-type handling.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
   * @ncontrols:	The number of controls in this cluster.
   * @controls:	The cluster control array of size @ncontrols. The first control
   *		must be the 'auto' control (e.g. autogain, autoexposure, etc.)
   * @manual_val: The value for the first control in the cluster that equals the
   *		manual setting.
   * @set_volatile: If true, then all controls except the first auto control will
   *		be volatile.
   *
   * Use for control groups where one control selects some automatic feature and
   * the other controls are only active whenever the automatic feature is turned
   * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
   * red and blue balance, etc.
   *
   * The behavior of such controls is as follows:
   *
   * When the autofoo control is set to automatic, then any manual controls
   * are set to inactive and any reads will call g_volatile_ctrl (if the control
   * was marked volatile).
   *
   * When the autofoo control is set to manual, then any manual controls will
   * be marked active, and any reads will just return the current value without
   * going through g_volatile_ctrl.
   *
2257e1801   Mauro Carvalho Chehab   [media] v4l2-ctrl...
671
672
   * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
   * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
673
674
   * if autofoo is in auto mode.
   */
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
675
676
677
  void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
  			    struct v4l2_ctrl **controls,
  			    u8 manual_val, bool set_volatile);
72d877cac   Hans Verkuil   [media] v4l2-ctrl...
678

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
679
680
  /**
   * v4l2_ctrl_find() - Find a control with the given ID.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
681
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
682
683
684
685
686
687
   * @hdl:	The control handler.
   * @id:	The control ID to find.
   *
   * If @hdl == NULL this will return NULL as well. Will lock the handler so
   * do not use from inside &v4l2_ctrl_ops.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
688
  struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
689
690
691
692
693
694
695
696
697
698
699
700
  /**
   * v4l2_ctrl_activate() - Make the control active or inactive.
   * @ctrl:	The control to (de)activate.
   * @active:	True if the control should become active.
   *
   * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
   * Does nothing if @ctrl == NULL.
   * This will usually be called from within the s_ctrl op.
   * The V4L2_EVENT_CTRL event will be generated afterwards.
   *
   * This function assumes that the control handler is locked.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
701
  void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
702
703
  /**
   * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
704
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
705
706
707
708
709
710
711
712
713
714
715
716
   * @ctrl:	The control to (de)activate.
   * @grabbed:	True if the control should become grabbed.
   *
   * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
   * Does nothing if @ctrl == NULL.
   * The V4L2_EVENT_CTRL event will be generated afterwards.
   * This will usually be called when starting or stopping streaming in the
   * driver.
   *
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
717
  void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
  /**
   *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
   *
   * @ctrl:	The control to update.
   * @min:	The control's minimum value.
   * @max:	The control's maximum value.
   * @step:	The control's step value
   * @def:	The control's default value.
   *
   * Update the range of a control on the fly. This works for control types
   * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
   * @step value is interpreted as a menu_skip_mask.
   *
   * An error is returned if one of the range arguments is invalid for this
   * control type.
   *
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
5a5739251   Sakari Ailus   [media] v4l: ctrl...
737
738
  int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
  			     s64 min, s64 max, u64 step, s64 def);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
739
740
  /**
   * v4l2_ctrl_modify_range() - Update the range of a control.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
741
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
   * @ctrl:	The control to update.
   * @min:	The control's minimum value.
   * @max:	The control's maximum value.
   * @step:	The control's step value
   * @def:	The control's default value.
   *
   * Update the range of a control on the fly. This works for control types
   * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
   * @step value is interpreted as a menu_skip_mask.
   *
   * An error is returned if one of the range arguments is invalid for this
   * control type.
   *
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
5a5739251   Sakari Ailus   [media] v4l: ctrl...
758
759
760
761
762
763
764
765
766
767
768
  static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
  					 s64 min, s64 max, u64 step, s64 def)
  {
  	int rval;
  
  	v4l2_ctrl_lock(ctrl);
  	rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
  	v4l2_ctrl_unlock(ctrl);
  
  	return rval;
  }
2ccbe779b   Sylwester Nawrocki   [media] v4l2-ctrl...
769

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
770
771
  /**
   * v4l2_ctrl_notify() - Function to set a notify callback for a control.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
772
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
773
774
775
776
777
778
779
780
781
782
783
   * @ctrl:	The control.
   * @notify:	The callback function.
   * @priv:	The callback private handle, passed as argument to the callback.
   *
   * This function sets a callback function for the control. If @ctrl is NULL,
   * then it will do nothing. If @notify is NULL, then the notify callback will
   * be removed.
   *
   * There can be only one notify. If another already exists, then a WARN_ON
   * will be issued and the function will do nothing.
   */
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
784
785
  void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
  		      void *priv);
8ac7a9493   Hans Verkuil   [media] v4l2-ctrl...
786

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
787
788
  /**
   * v4l2_ctrl_get_name() - Get the name of the control
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
789
   *
79fbc209f   Hans Verkuil   [media] v4l2-ctrl...
790
791
792
793
794
795
   * @id:		The control ID.
   *
   * This function returns the name of the given control ID or NULL if it isn't
   * a known control.
   */
  const char *v4l2_ctrl_get_name(u32 id);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
796
797
  /**
   * v4l2_ctrl_get_menu() - Get the menu string array of the control
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
798
   *
79fbc209f   Hans Verkuil   [media] v4l2-ctrl...
799
800
801
802
803
804
   * @id:		The control ID.
   *
   * This function returns the NULL-terminated menu string array name of the
   * given control ID or NULL if it isn't a known menu control.
   */
  const char * const *v4l2_ctrl_get_menu(u32 id);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
805
806
  /**
   * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
807
   *
79fbc209f   Hans Verkuil   [media] v4l2-ctrl...
808
809
810
811
812
813
814
   * @id:		The control ID.
   * @len:	The size of the integer array.
   *
   * This function returns the integer array of the given control ID or NULL if it
   * if it isn't a known integer menu control.
   */
  const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
815
  /**
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
816
817
818
   * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
   *	within a driver.
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
819
820
821
822
823
824
825
826
   * @ctrl:	The control.
   *
   * This returns the control's value safely by going through the control
   * framework. This function will lock the control's handler, so it cannot be
   * used from within the &v4l2_ctrl_ops functions.
   *
   * This function is for integer type controls only.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
827
  s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
828
829
  /**
   * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
830
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
831
   * @ctrl:	The control.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
832
   * @val:	TheControls name new value.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
833
   *
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
834
835
836
   * This sets the control's new value safely by going through the control
   * framework. This function assumes the control's handler is already locked,
   * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
837
838
839
   *
   * This function is for integer type controls only.
   */
0c4348ada   Sakari Ailus   [media] v4l: ctrl...
840
  int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
841

8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
842
843
844
  /**
   * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
   *	within a driver.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
845
846
847
   * @ctrl:	The control.
   * @val:	The new value.
   *
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
848
   * This sets the control's new value safely by going through the control
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
849
850
851
852
853
   * framework. This function will lock the control's handler, so it cannot be
   * used from within the &v4l2_ctrl_ops functions.
   *
   * This function is for integer type controls only.
   */
0c4348ada   Sakari Ailus   [media] v4l: ctrl...
854
855
856
857
858
859
860
861
862
863
  static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
  {
  	int rval;
  
  	v4l2_ctrl_lock(ctrl);
  	rval = __v4l2_ctrl_s_ctrl(ctrl, val);
  	v4l2_ctrl_unlock(ctrl);
  
  	return rval;
  }
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
864

8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
865
866
867
  /**
   * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
   *	from within a driver.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
868
   *
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
869
870
871
872
873
874
875
876
   * @ctrl:	The control.
   *
   * This returns the control's value safely by going through the control
   * framework. This function will lock the control's handler, so it cannot be
   * used from within the &v4l2_ctrl_ops functions.
   *
   * This function is for 64-bit integer type controls only.
   */
03d5285b8   Laurent Pinchart   [media] v4l2-ctrl...
877
  s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
878
879
880
881
882
883
  /**
   * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
   *
   * @ctrl:	The control.
   * @val:	The new value.
   *
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
884
885
886
   * This sets the control's new value safely by going through the control
   * framework. This function assumes the control's handler is already locked,
   * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
887
888
889
   *
   * This function is for 64-bit integer type controls only.
   */
0c4348ada   Sakari Ailus   [media] v4l: ctrl...
890
  int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
891
892
  /**
   * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
893
894
895
896
897
   *	from within a driver.
   *
   * @ctrl:	The control.
   * @val:	The new value.
   *
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
898
   * This sets the control's new value safely by going through the control
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
899
900
901
902
903
   * framework. This function will lock the control's handler, so it cannot be
   * used from within the &v4l2_ctrl_ops functions.
   *
   * This function is for 64-bit integer type controls only.
   */
0c4348ada   Sakari Ailus   [media] v4l: ctrl...
904
905
906
907
908
909
910
911
912
913
  static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
  {
  	int rval;
  
  	v4l2_ctrl_lock(ctrl);
  	rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
  	v4l2_ctrl_unlock(ctrl);
  
  	return rval;
  }
03d5285b8   Laurent Pinchart   [media] v4l2-ctrl...
914

8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
915
916
  /**
   * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
917
918
919
920
   *
   * @ctrl:	The control.
   * @s:		The new string.
   *
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
921
922
923
   * This sets the control's new string safely by going through the control
   * framework. This function assumes the control's handler is already locked,
   * allowing it to be used from within the &v4l2_ctrl_ops functions.
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
924
925
926
   *
   * This function is for string type controls only.
   */
5d0360a4f   Hans Verkuil   [media] v4l2-ctrl...
927
  int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
928
929
  /**
   * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
930
931
932
933
   *	 from within a driver.
   *
   * @ctrl:	The control.
   * @s:		The new string.
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
934
   *Controls name
904aef0f9   Hans Verkuil   [media] v4l2-ctrl...
935
   * This sets the control's new string safely by going through the control
8c2721d57   Mauro Carvalho Chehab   [media] v4l2-ctrl...
936
937
938
939
940
   * framework. This function will lock the control's handler, so it cannot be
   * used from within the &v4l2_ctrl_ops functions.
   *
   * This function is for string type controls only.
   */
5d0360a4f   Hans Verkuil   [media] v4l2-ctrl...
941
942
943
944
945
946
947
948
949
950
  static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
  {
  	int rval;
  
  	v4l2_ctrl_lock(ctrl);
  	rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
  	v4l2_ctrl_unlock(ctrl);
  
  	return rval;
  }
ce7275747   Hans Verkuil   [media] v4l2-ctrl...
951
  /* Internal helper functions that deal with control events. */
3e366149b   Hans de Goede   [media] v4l2-ctrl...
952
  extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
953
954
955
956
957
  
  /**
   * v4l2_ctrl_replace - Function to be used as a callback to
   *	&struct v4l2_subscribed_event_ops replace\(\)
   *
f8441a433   Mauro Carvalho Chehab   [media] v4l2-ctrl...
958
   * @old: pointer to struct &v4l2_event with the reported
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
959
   *	 event;
f8441a433   Mauro Carvalho Chehab   [media] v4l2-ctrl...
960
   * @new: pointer to struct &v4l2_event with the modified
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
961
962
   *	 event;
   */
3e366149b   Hans de Goede   [media] v4l2-ctrl...
963
  void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
964
965
966
967
968
  
  /**
   * v4l2_ctrl_merge - Function to be used as a callback to
   *	&struct v4l2_subscribed_event_ops merge(\)
   *
f8441a433   Mauro Carvalho Chehab   [media] v4l2-ctrl...
969
   * @old: pointer to struct &v4l2_event with the reported
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
970
   *	 event;
f8441a433   Mauro Carvalho Chehab   [media] v4l2-ctrl...
971
   * @new: pointer to struct &v4l2_event with the merged
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
972
973
   *	 event;
   */
3e366149b   Hans de Goede   [media] v4l2-ctrl...
974
  void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
6e239399e   Hans Verkuil   [media] v4l2-ctrl...
975

8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
976
977
978
979
980
981
982
983
984
985
  /**
   * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
   *
   * @file: pointer to struct file
   * @fh: unused. Kept just to be compatible to the arguments expected by
   *	&struct v4l2_ioctl_ops.vidioc_log_status.
   *
   * Can be used as a vidioc_log_status function that just dumps all controls
   * associated with the filehandle.
   */
e2ecb257e   Hans Verkuil   [media] v4l2: sta...
986
  int v4l2_ctrl_log_status(struct file *file, void *fh);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
987
988
989
990
991
992
993
994
995
996
  /**
   * v4l2_ctrl_subscribe_event - Subscribes to an event
   *
   *
   * @fh: pointer to struct v4l2_fh
   * @sub: pointer to &struct v4l2_event_subscription
   *
   * Can be used as a vidioc_subscribe_event function that just subscribes
   * control events.
   */
a26243b0e   Hans Verkuil   [media] v4l2-ctrl...
997
  int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
85f5fe396   Hans Verkuil   [media] v4l2: mak...
998
  				const struct v4l2_event_subscription *sub);
a26243b0e   Hans Verkuil   [media] v4l2-ctrl...
999

8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1000
1001
1002
1003
1004
1005
1006
  /**
   * v4l2_ctrl_poll - function to be used as a callback to the poll()
   *	That just polls for control events.
   *
   * @file: pointer to struct file
   * @wait: pointer to struct poll_table_struct
   */
a26243b0e   Hans Verkuil   [media] v4l2-ctrl...
1007
  unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
  /* Helpers for ioctl_ops */
  
  /**
   * v4l2_queryctrl - Helper function to implement
   *	:ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @qc: pointer to &struct v4l2_queryctrl
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1019
  int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
  
  /**
   * v4l2_query_ext_ctrl - Helper function to implement
   *	 :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @qc: pointer to &struct v4l2_query_ext_ctrl
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
  int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
  			struct v4l2_query_ext_ctrl *qc);
  
  /**
   * v4l2_querymenu - Helper function to implement
   *	:ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @qm: pointer to &struct v4l2_querymenu
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1042
  int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
  
  /**
   * v4l2_g_ctrl - Helper function to implement
   *	:ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @ctrl: pointer to &struct v4l2_control
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1053
  int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
  
  /**
   * v4l2_s_ctrl - Helper function to implement
   *	:ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
   *
   * @fh: pointer to &struct v4l2_fh
   * @hdl: pointer to &struct v4l2_ctrl_handler
   *
   * @ctrl: pointer to &struct v4l2_control
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
ab892bac8   Hans Verkuil   [media] v4l2-ctrl...
1066
  int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
  		struct v4l2_control *ctrl);
  
  /**
   * v4l2_g_ext_ctrls - Helper function to implement
   *	:ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @c: pointer to &struct v4l2_ext_controls
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
  int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl,
  		     struct v4l2_ext_controls *c);
  
  /**
   * v4l2_try_ext_ctrls - Helper function to implement
   *	:ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
   *
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @c: pointer to &struct v4l2_ext_controls
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
  int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
  		       struct v4l2_ext_controls *c);
  
  /**
   * v4l2_s_ext_ctrls - Helper function to implement
   *	:ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
   *
   * @fh: pointer to &struct v4l2_fh
   * @hdl: pointer to &struct v4l2_ctrl_handler
   * @c: pointer to &struct v4l2_ext_controls
   *
   * If hdl == NULL then they will all return -EINVAL.
   */
ab892bac8   Hans Verkuil   [media] v4l2-ctrl...
1103
  int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1104
  		     struct v4l2_ext_controls *c);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1105

8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1106
1107
1108
1109
1110
1111
1112
1113
1114
  /**
   * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
   * 	as a &struct v4l2_subdev_core_ops subscribe_event function
   *	that just subscribes control events.
   *
   * @sd: pointer to &struct v4l2_subdev
   * @fh: pointer to &struct v4l2_fh
   * @sub: pointer to &struct v4l2_event_subscription
   */
22fa4279e   Sylwester Nawrocki   [media] V4L: Add ...
1115
1116
  int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
  				     struct v4l2_event_subscription *sub);
8ec4bee7c   Mauro Carvalho Chehab   [media] v4l2-ctrl...
1117
1118
1119
1120
1121
1122
  /**
   * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
   *	 handler.
   *
   * @sd: pointer to &struct v4l2_subdev
   */
ffa9b9f01   Sylwester Nawrocki   [media] V4L: Add ...
1123
  int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
0996517cf   Hans Verkuil   V4L/DVB: v4l2: Ad...
1124
  #endif