summaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook/v4l/vidioc-queryctrl.xml
blob: 8e0e055ac9349fbd3f7025df71486fa3b1054235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<refentry id="vidioc-queryctrl">
  <refmeta>
    <refentrytitle>ioctl VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU</refentrytitle>
    &manvol;
  </refmeta>

  <refnamediv>
    <refname>VIDIOC_QUERYCTRL</refname>
    <refname>VIDIOC_QUERYMENU</refname>
    <refpurpose>Enumerate controls and menu control items</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcprototype>
	<funcdef>int <function>ioctl</function></funcdef>
	<paramdef>int <parameter>fd</parameter></paramdef>
	<paramdef>int <parameter>request</parameter></paramdef>
	<paramdef>struct v4l2_queryctrl *<parameter>argp</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
    <funcsynopsis>
      <funcprototype>
	<funcdef>int <function>ioctl</function></funcdef>
	<paramdef>int <parameter>fd</parameter></paramdef>
	<paramdef>int <parameter>request</parameter></paramdef>
	<paramdef>struct v4l2_querymenu *<parameter>argp</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Arguments</title>

    <variablelist>
      <varlistentry>
	<term><parameter>fd</parameter></term>
	<listitem>
	  <para>&fd;</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>request</parameter></term>
	<listitem>
	  <para>VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>argp</parameter></term>
	<listitem>
	  <para></para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>To query the attributes of a control applications set the
<structfield>id</structfield> field of a &v4l2-queryctrl; and call the
<constant>VIDIOC_QUERYCTRL</constant> ioctl with a pointer to this
structure. The driver fills the rest of the structure or returns an
&EINVAL; when the <structfield>id</structfield> is invalid.</para>

    <para>It is possible to enumerate controls by calling
<constant>VIDIOC_QUERYCTRL</constant> with successive
<structfield>id</structfield> values starting from
<constant>V4L2_CID_BASE</constant> up to and exclusive
<constant>V4L2_CID_BASE_LASTP1</constant>. Drivers may return
<errorcode>EINVAL</errorcode> if a control in this range is not
supported. Further applications can enumerate private controls, which
are not defined in this specification, by starting at
<constant>V4L2_CID_PRIVATE_BASE</constant> and incrementing
<structfield>id</structfield> until the driver returns
<errorcode>EINVAL</errorcode>.</para>

    <para>In both cases, when the driver sets the
<constant>V4L2_CTRL_FLAG_DISABLED</constant> flag in the
<structfield>flags</structfield> field this control is permanently
disabled and should be ignored by the application.<footnote>
	<para><constant>V4L2_CTRL_FLAG_DISABLED</constant> was
intended for two purposes: Drivers can skip predefined controls not
supported by the hardware (although returning EINVAL would do as
well), or disable predefined and private controls after hardware
detection without the trouble of reordering control arrays and indices
(EINVAL cannot be used to skip private controls because it would
prematurely end the enumeration).</para></footnote></para>

    <para>When the application ORs <structfield>id</structfield> with
<constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant> the driver returns the
next supported control, or <errorcode>EINVAL</errorcode> if there is
none. Drivers which do not support this flag yet always return
<errorcode>EINVAL</errorcode>.</para>

    <para>Additional information is required for menu controls: the
names of the menu items. To query them applications set the
<structfield>id</structfield> and <structfield>index</structfield>
fields of &v4l2-querymenu; and call the
<constant>VIDIOC_QUERYMENU</constant> ioctl with a pointer to this
structure. The driver fills the rest of the structure or returns an
&EINVAL; when the <structfield>id</structfield> or
<structfield>index</structfield> is invalid. Menu items are enumerated
by calling <constant>VIDIOC_QUERYMENU</constant> with successive
<structfield>index</structfield> values from &v4l2-queryctrl;
<structfield>minimum</structfield> (0) to
<structfield>maximum</structfield>, inclusive.</para>

    <para>See also the examples in <xref linkend="control" />.</para>

    <table pgwide="1" frame="none" id="v4l2-queryctrl">
      <title>struct <structname>v4l2_queryctrl</structname></title>
      <tgroup cols="3">
	&cs-str;
	<tbody valign="top">
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>id</structfield></entry>
	    <entry>Identifies the control, set by the application. See
<xref linkend="control-id" /> for predefined IDs. When the ID is ORed
with V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and returns
the first control with a higher ID. Drivers which do not support this
flag yet always return an &EINVAL;.</entry>
	  </row>
	  <row>
	    <entry>&v4l2-ctrl-type;</entry>
	    <entry><structfield>type</structfield></entry>
	    <entry>Type of control, see <xref
		linkend="v4l2-ctrl-type" />.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>name</structfield>[32]</entry>
	    <entry>Name of the control, a NUL-terminated ASCII
string. This information is intended for the user.</entry>
	  </row>
	  <row>
	    <entry>__s32</entry>
	    <entry><structfield>minimum</structfield></entry>
	    <entry>Minimum value, inclusive. This field gives a lower
bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
lowest valid index (always 0) for <constant>V4L2_CTRL_TYPE_MENU</constant> controls.
For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the minimum value
gives the minimum length of the string. This length <emphasis>does not include the terminating
zero</emphasis>. It may not be valid for any other type of control, including
<constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
signed value.</entry>
	  </row>
	  <row>
	    <entry>__s32</entry>
	    <entry><structfield>maximum</structfield></entry>
	    <entry>Maximum value, inclusive. This field gives an upper
bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
highest valid index for <constant>V4L2_CTRL_TYPE_MENU</constant>
controls.
For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the maximum value
gives the maximum length of the string. This length <emphasis>does not include the terminating
zero</emphasis>. It may not be valid for any other type of control, including
<constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
signed value.</entry>
	  </row>
	  <row>
	    <entry>__s32</entry>
	    <entry><structfield>step</structfield></entry>
	    <entry><para>This field gives a step size for
<constant>V4L2_CTRL_TYPE_INTEGER</constant> controls. For
<constant>V4L2_CTRL_TYPE_STRING</constant> controls this field refers to
the string length that has to be a multiple of this step size.
It may not be valid for any other type of control, including
<constant>V4L2_CTRL_TYPE_INTEGER64</constant>
controls.</para><para>Generally drivers should not scale hardware
control values. It may be necessary for example when the
<structfield>name</structfield> or <structfield>id</structfield> imply
a particular unit and the hardware actually accepts only multiples of
said unit. If so, drivers must take care values are properly rounded
when scaling, such that errors will not accumulate on repeated
read-write cycles.</para><para>This field gives the smallest change of
an integer control actually affecting hardware. Often the information
is needed when the user can change controls by keyboard or GUI
buttons, rather than a slider. When for example a hardware register
accepts values 0-511 and the driver reports 0-65535, step should be
128.</para><para>Note that although signed, the step value is supposed to
be always positive.</para></entry>
	  </row>
	  <row>
	    <entry>__s32</entry>
	    <entry><structfield>default_value</structfield></entry>
	    <entry>The default value of a
<constant>V4L2_CTRL_TYPE_INTEGER</constant>,
<constant>_BOOLEAN</constant> or <constant>_MENU</constant> control.
Not valid for other types of controls. Drivers reset controls only
when the driver is loaded, not later, in particular not when the
func-open; is called.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>flags</structfield></entry>
	    <entry>Control flags, see <xref
		linkend="control-flags" />.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>reserved</structfield>[2]</entry>
	    <entry>Reserved for future extensions. Drivers must set
the array to zero.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="v4l2-querymenu">
      <title>struct <structname>v4l2_querymenu</structname></title>
      <tgroup cols="3">
	&cs-str;
	<tbody valign="top">
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>id</structfield></entry>
	    <entry>Identifies the control, set by the application
from the respective &v4l2-queryctrl;
<structfield>id</structfield>.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>index</structfield></entry>
	    <entry>Index of the menu item, starting at zero, set by
	    the application.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>name</structfield>[32]</entry>
	    <entry>Name of the menu item, a NUL-terminated ASCII
string. This information is intended for the user.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>reserved</structfield></entry>
	    <entry>Reserved for future extensions. Drivers must set
the array to zero.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="v4l2-ctrl-type">
      <title>enum v4l2_ctrl_type</title>
      <tgroup cols="5" align="left">
	<colspec colwidth="30*" />
	<colspec colwidth="5*" align="center" />
	<colspec colwidth="5*" align="center" />
	<colspec colwidth="5*" align="center" />
	<colspec colwidth="55*" />
	<thead>
	  <row>