Commit | Line | Data |
---|---|---|
5377d91f MH |
1 | .. -*- coding: utf-8; mode: rst -*- |
2 | ||
af4a4d0d | 3 | .. _VIDIOC_QUERYCTRL: |
5377d91f | 4 | |
90ffc75f MCC |
5 | ******************************************************************* |
6 | ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU | |
7 | ******************************************************************* | |
5377d91f | 8 | |
15e7d615 | 9 | Name |
586027ce | 10 | ==== |
5377d91f | 11 | |
586027ce | 12 | VIDIOC_QUERYCTRL - VIDIOC_QUERY_EXT_CTRL - VIDIOC_QUERYMENU - Enumerate controls and menu control items |
5377d91f | 13 | |
15e7d615 MCC |
14 | |
15 | Synopsis | |
5377d91f MH |
16 | ======== |
17 | ||
41d80465 MCC |
18 | .. c:function:: int ioctl( int fd, int VIDIOC_QUERYCTRL, struct v4l2_queryctrl *argp ) |
19 | :name: VIDIOC_QUERYCTRL | |
5377d91f | 20 | |
41d80465 MCC |
21 | .. c:function:: int ioctl( int fd, VIDIOC_QUERY_EXT_CTRL, struct v4l2_query_ext_ctrl *argp ) |
22 | :name: VIDIOC_QUERY_EXT_CTRL | |
5377d91f | 23 | |
41d80465 MCC |
24 | .. c:function:: int ioctl( int fd, VIDIOC_QUERYMENU, struct v4l2_querymenu *argp ) |
25 | :name: VIDIOC_QUERYMENU | |
5377d91f | 26 | |
586027ce | 27 | |
15e7d615 | 28 | Arguments |
5377d91f MH |
29 | ========= |
30 | ||
31 | ``fd`` | |
32 | File descriptor returned by :ref:`open() <func-open>`. | |
33 | ||
5377d91f MH |
34 | ``argp`` |
35 | ||
36 | ||
15e7d615 | 37 | Description |
5377d91f MH |
38 | =========== |
39 | ||
40 | To query the attributes of a control applications set the ``id`` field | |
41 | of a struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` and call the | |
42 | ``VIDIOC_QUERYCTRL`` ioctl with a pointer to this structure. The driver | |
cdb4af0f | 43 | fills the rest of the structure or returns an ``EINVAL`` error code when the |
5377d91f MH |
44 | ``id`` is invalid. |
45 | ||
46 | It is possible to enumerate controls by calling ``VIDIOC_QUERYCTRL`` | |
47 | with successive ``id`` values starting from ``V4L2_CID_BASE`` up to and | |
cdb4af0f | 48 | exclusive ``V4L2_CID_LASTP1``. Drivers may return ``EINVAL`` if a control in |
5377d91f MH |
49 | this range is not supported. Further applications can enumerate private |
50 | controls, which are not defined in this specification, by starting at | |
51 | ``V4L2_CID_PRIVATE_BASE`` and incrementing ``id`` until the driver | |
cdb4af0f | 52 | returns ``EINVAL``. |
5377d91f MH |
53 | |
54 | In both cases, when the driver sets the ``V4L2_CTRL_FLAG_DISABLED`` flag | |
55 | in the ``flags`` field this control is permanently disabled and should | |
4855307b | 56 | be ignored by the application. [#f1]_ |
5377d91f MH |
57 | |
58 | When the application ORs ``id`` with ``V4L2_CTRL_FLAG_NEXT_CTRL`` the | |
cdb4af0f | 59 | driver returns the next supported non-compound control, or ``EINVAL`` if |
5377d91f MH |
60 | there is none. In addition, the ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` flag |
61 | can be specified to enumerate all compound controls (i.e. controls with | |
62 | type ≥ ``V4L2_CTRL_COMPOUND_TYPES`` and/or array control, in other words | |
63 | controls that contain more than one value). Specify both | |
64 | ``V4L2_CTRL_FLAG_NEXT_CTRL`` and ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` in | |
65 | order to enumerate all controls, compound or not. Drivers which do not | |
cdb4af0f | 66 | support these flags yet always return ``EINVAL``. |
5377d91f MH |
67 | |
68 | The ``VIDIOC_QUERY_EXT_CTRL`` ioctl was introduced in order to better | |
69 | support controls that can use compound types, and to expose additional | |
70 | control information that cannot be returned in struct | |
71 | :ref:`v4l2_queryctrl <v4l2-queryctrl>` since that structure is full. | |
72 | ||
73 | ``VIDIOC_QUERY_EXT_CTRL`` is used in the same way as | |
74 | ``VIDIOC_QUERYCTRL``, except that the ``reserved`` array must be zeroed | |
75 | as well. | |
76 | ||
77 | Additional information is required for menu controls: the names of the | |
78 | menu items. To query them applications set the ``id`` and ``index`` | |
79 | fields of struct :ref:`v4l2_querymenu <v4l2-querymenu>` and call the | |
80 | ``VIDIOC_QUERYMENU`` ioctl with a pointer to this structure. The driver | |
cdb4af0f | 81 | fills the rest of the structure or returns an ``EINVAL`` error code when the |
5377d91f MH |
82 | ``id`` or ``index`` is invalid. Menu items are enumerated by calling |
83 | ``VIDIOC_QUERYMENU`` with successive ``index`` values from struct | |
84 | :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``minimum`` to ``maximum``, | |
706f8a99 MCC |
85 | inclusive. |
86 | ||
b6b6e678 MCC |
87 | .. note:: |
88 | ||
89 | It is possible for ``VIDIOC_QUERYMENU`` to return | |
706f8a99 MCC |
90 | an ``EINVAL`` error code for some indices between ``minimum`` and |
91 | ``maximum``. In that case that particular menu item is not supported by | |
92 | this driver. Also note that the ``minimum`` value is not necessarily 0. | |
5377d91f MH |
93 | |
94 | See also the examples in :ref:`control`. | |
95 | ||
96 | ||
ef76c068 MCC |
97 | .. tabularcolumns:: |p{1.2cm}|p{3.6cm}|p{12.7cm}| |
98 | ||
fa92b04d MCC |
99 | .. _v4l2-queryctrl: |
100 | ||
ef76c068 | 101 | .. cssclass:: longtable |
5bd4bb78 | 102 | |
5377d91f MH |
103 | .. flat-table:: struct v4l2_queryctrl |
104 | :header-rows: 0 | |
105 | :stub-columns: 0 | |
106 | :widths: 1 1 2 | |
107 | ||
108 | ||
109 | - .. row 1 | |
110 | ||
111 | - __u32 | |
112 | ||
113 | - ``id`` | |
114 | ||
115 | - Identifies the control, set by the application. See | |
0579e6e3 MCC |
116 | :ref:`control-id` for predefined IDs. When the ID is ORed with |
117 | V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and | |
118 | returns the first control with a higher ID. Drivers which do not | |
119 | support this flag yet always return an ``EINVAL`` error code. | |
5377d91f MH |
120 | |
121 | - .. row 2 | |
122 | ||
123 | - __u32 | |
124 | ||
125 | - ``type`` | |
126 | ||
56683d7d | 127 | - Type of control, see :c:type:`v4l2_ctrl_type`. |
5377d91f MH |
128 | |
129 | - .. row 3 | |
130 | ||
131 | - __u8 | |
132 | ||
8968da9b | 133 | - ``name``\ [32] |
5377d91f MH |
134 | |
135 | - Name of the control, a NUL-terminated ASCII string. This | |
0579e6e3 | 136 | information is intended for the user. |
5377d91f MH |
137 | |
138 | - .. row 4 | |
139 | ||
140 | - __s32 | |
141 | ||
142 | - ``minimum`` | |
143 | ||
144 | - Minimum value, inclusive. This field gives a lower bound for the | |
ffa0441e | 145 | control. See enum :c:type:`v4l2_ctrl_type` how |
0579e6e3 MCC |
146 | the minimum value is to be used for each possible control type. |
147 | Note that this a signed 32-bit value. | |
5377d91f MH |
148 | |
149 | - .. row 5 | |
150 | ||
151 | - __s32 | |
152 | ||
153 | - ``maximum`` | |
154 | ||
155 | - Maximum value, inclusive. This field gives an upper bound for the | |
ffa0441e | 156 | control. See enum :c:type:`v4l2_ctrl_type` how |
0579e6e3 MCC |
157 | the maximum value is to be used for each possible control type. |
158 | Note that this a signed 32-bit value. | |
5377d91f MH |
159 | |
160 | - .. row 6 | |
161 | ||
162 | - __s32 | |
163 | ||
164 | - ``step`` | |
165 | ||
166 | - This field gives a step size for the control. See enum | |
ffa0441e | 167 | :c:type:`v4l2_ctrl_type` how the step value is |
0579e6e3 MCC |
168 | to be used for each possible control type. Note that this an |
169 | unsigned 32-bit value. | |
170 | ||
171 | Generally drivers should not scale hardware control values. It may | |
172 | be necessary for example when the ``name`` or ``id`` imply a | |
173 | particular unit and the hardware actually accepts only multiples | |
174 | of said unit. If so, drivers must take care values are properly | |
175 | rounded when scaling, such that errors will not accumulate on | |
176 | repeated read-write cycles. | |
177 | ||
178 | This field gives the smallest change of an integer control | |
179 | actually affecting hardware. Often the information is needed when | |
180 | the user can change controls by keyboard or GUI buttons, rather | |
181 | than a slider. When for example a hardware register accepts values | |
182 | 0-511 and the driver reports 0-65535, step should be 128. | |
183 | ||
184 | Note that although signed, the step value is supposed to be always | |
185 | positive. | |
5377d91f MH |
186 | |
187 | - .. row 7 | |
188 | ||
189 | - __s32 | |
190 | ||
191 | - ``default_value`` | |
192 | ||
193 | - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_BOOLEAN``, | |
0579e6e3 | 194 | ``_BITMASK``, ``_MENU`` or ``_INTEGER_MENU`` control. Not valid |
706f8a99 MCC |
195 | for other types of controls. |
196 | ||
b6b6e678 MCC |
197 | .. note:: |
198 | ||
199 | Drivers reset controls to their default value only when | |
706f8a99 | 200 | the driver is first loaded, never afterwards. |
5377d91f MH |
201 | |
202 | - .. row 8 | |
203 | ||
204 | - __u32 | |
205 | ||
206 | - ``flags`` | |
207 | ||
208 | - Control flags, see :ref:`control-flags`. | |
209 | ||
210 | - .. row 9 | |
211 | ||
212 | - __u32 | |
213 | ||
8968da9b | 214 | - ``reserved``\ [2] |
5377d91f MH |
215 | |
216 | - Reserved for future extensions. Drivers must set the array to | |
0579e6e3 | 217 | zero. |
5377d91f MH |
218 | |
219 | ||
220 | ||
ef76c068 MCC |
221 | .. tabularcolumns:: |p{1.2cm}|p{5.0cm}|p{11.3cm}| |
222 | ||
fa92b04d MCC |
223 | .. _v4l2-query-ext-ctrl: |
224 | ||
ef76c068 | 225 | .. cssclass:: longtable |
5bd4bb78 | 226 | |
5377d91f MH |
227 | .. flat-table:: struct v4l2_query_ext_ctrl |
228 | :header-rows: 0 | |
229 | :stub-columns: 0 | |
230 | :widths: 1 1 2 | |
231 | ||
232 | ||
233 | - .. row 1 | |
234 | ||
235 | - __u32 | |
236 | ||
237 | - ``id`` | |
238 | ||
239 | - Identifies the control, set by the application. See | |
0579e6e3 MCC |
240 | :ref:`control-id` for predefined IDs. When the ID is ORed with |
241 | ``V4L2_CTRL_FLAG_NEXT_CTRL`` the driver clears the flag and | |
242 | returns the first non-compound control with a higher ID. When the | |
243 | ID is ORed with ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` the driver clears | |
244 | the flag and returns the first compound control with a higher ID. | |
245 | Set both to get the first control (compound or not) with a higher | |
246 | ID. | |
5377d91f MH |
247 | |
248 | - .. row 2 | |
249 | ||
250 | - __u32 | |
251 | ||
252 | - ``type`` | |
253 | ||
56683d7d | 254 | - Type of control, see :c:type:`v4l2_ctrl_type`. |
5377d91f MH |
255 | |
256 | - .. row 3 | |
257 | ||
258 | - char | |
259 | ||
8968da9b | 260 | - ``name``\ [32] |
5377d91f MH |
261 | |
262 | - Name of the control, a NUL-terminated ASCII string. This | |
0579e6e3 | 263 | information is intended for the user. |
5377d91f MH |
264 | |
265 | - .. row 4 | |
266 | ||
267 | - __s64 | |
268 | ||
269 | - ``minimum`` | |
270 | ||
271 | - Minimum value, inclusive. This field gives a lower bound for the | |
ffa0441e | 272 | control. See enum :c:type:`v4l2_ctrl_type` how |
0579e6e3 MCC |
273 | the minimum value is to be used for each possible control type. |
274 | Note that this a signed 64-bit value. | |
5377d91f MH |
275 | |
276 | - .. row 5 | |
277 | ||
278 | - __s64 | |
279 | ||
280 | - ``maximum`` | |
281 | ||
282 | - Maximum value, inclusive. This field gives an upper bound for the | |
ffa0441e | 283 | control. See enum :c:type:`v4l2_ctrl_type` how |
0579e6e3 MCC |
284 | the maximum value is to be used for each possible control type. |
285 | Note that this a signed 64-bit value. | |
5377d91f MH |
286 | |
287 | - .. row 6 | |
288 | ||
289 | - __u64 | |
290 | ||
291 | - ``step`` | |
292 | ||
293 | - This field gives a step size for the control. See enum | |
ffa0441e | 294 | :c:type:`v4l2_ctrl_type` how the step value is |
0579e6e3 MCC |
295 | to be used for each possible control type. Note that this an |
296 | unsigned 64-bit value. | |
297 | ||
298 | Generally drivers should not scale hardware control values. It may | |
299 | be necessary for example when the ``name`` or ``id`` imply a | |
300 | particular unit and the hardware actually accepts only multiples | |
301 | of said unit. If so, drivers must take care values are properly | |
302 | rounded when scaling, such that errors will not accumulate on | |
303 | repeated read-write cycles. | |
304 | ||
305 | This field gives the smallest change of an integer control | |
306 | actually affecting hardware. Often the information is needed when | |
307 | the user can change controls by keyboard or GUI buttons, rather | |
308 | than a slider. When for example a hardware register accepts values | |
309 | 0-511 and the driver reports 0-65535, step should be 128. | |
5377d91f MH |
310 | |
311 | - .. row 7 | |
312 | ||
313 | - __s64 | |
314 | ||
315 | - ``default_value`` | |
316 | ||
317 | - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_INTEGER64``, | |
0579e6e3 | 318 | ``_BOOLEAN``, ``_BITMASK``, ``_MENU``, ``_INTEGER_MENU``, ``_U8`` |
706f8a99 MCC |
319 | or ``_U16`` control. Not valid for other types of controls. |
320 | ||
b6b6e678 MCC |
321 | .. note:: |
322 | ||
323 | Drivers reset controls to their default value only when | |
706f8a99 | 324 | the driver is first loaded, never afterwards. |
5377d91f MH |
325 | |
326 | - .. row 8 | |
327 | ||
328 | - __u32 | |
329 | ||
330 | - ``flags`` | |
331 | ||
332 | - Control flags, see :ref:`control-flags`. | |
333 | ||
334 | - .. row 9 | |
335 | ||
336 | - __u32 | |
337 | ||
338 | - ``elem_size`` | |
339 | ||
340 | - The size in bytes of a single element of the array. Given a char | |
0579e6e3 MCC |
341 | pointer ``p`` to a 3-dimensional array you can find the position |
342 | of cell ``(z, y, x)`` as follows: | |
8968da9b | 343 | ``p + ((z * dims[1] + y) * dims[0] + x) * elem_size``. |
0579e6e3 MCC |
344 | ``elem_size`` is always valid, also when the control isn't an |
345 | array. For string controls ``elem_size`` is equal to | |
346 | ``maximum + 1``. | |
5377d91f MH |
347 | |
348 | - .. row 10 | |
349 | ||
350 | - __u32 | |
351 | ||
352 | - ``elems`` | |
353 | ||
354 | - The number of elements in the N-dimensional array. If this control | |
0579e6e3 MCC |
355 | is not an array, then ``elems`` is 1. The ``elems`` field can |
356 | never be 0. | |
5377d91f MH |
357 | |
358 | - .. row 11 | |
359 | ||
360 | - __u32 | |
361 | ||
362 | - ``nr_of_dims`` | |
363 | ||
364 | - The number of dimension in the N-dimensional array. If this | |
0579e6e3 | 365 | control is not an array, then this field is 0. |
5377d91f MH |
366 | |
367 | - .. row 12 | |
368 | ||
369 | - __u32 | |
370 | ||
371 | - ``dims[V4L2_CTRL_MAX_DIMS]`` | |
372 | ||
373 | - The size of each dimension. The first ``nr_of_dims`` elements of | |
0579e6e3 | 374 | this array must be non-zero, all remaining elements must be zero. |
5377d91f MH |
375 | |
376 | - .. row 13 | |
377 | ||
378 | - __u32 | |
379 | ||
8968da9b | 380 | - ``reserved``\ [32] |
5377d91f MH |
381 | |
382 | - Reserved for future extensions. Applications and drivers must set | |
0579e6e3 | 383 | the array to zero. |
5377d91f MH |
384 | |
385 | ||
386 | ||
ef76c068 | 387 | .. tabularcolumns:: |p{1.2cm}|p{0.6cm}|p{1.6cm}|p{13.5cm}| |
5bd4bb78 | 388 | |
fa92b04d MCC |
389 | .. _v4l2-querymenu: |
390 | ||
5377d91f MH |
391 | .. flat-table:: struct v4l2_querymenu |
392 | :header-rows: 0 | |
393 | :stub-columns: 0 | |
394 | :widths: 1 1 2 1 | |
395 | ||
396 | ||
397 | - .. row 1 | |
398 | ||
399 | - __u32 | |
400 | ||
0579e6e3 | 401 | - |
5377d91f MH |
402 | - ``id`` |
403 | ||
404 | - Identifies the control, set by the application from the respective | |
0579e6e3 | 405 | struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id``. |
5377d91f MH |
406 | |
407 | - .. row 2 | |
408 | ||
409 | - __u32 | |
410 | ||
0579e6e3 | 411 | - |
5377d91f MH |
412 | - ``index`` |
413 | ||
414 | - Index of the menu item, starting at zero, set by the application. | |
415 | ||
416 | - .. row 3 | |
417 | ||
418 | - union | |
419 | ||
0579e6e3 MCC |
420 | - |
421 | - | |
422 | - | |
5377d91f MH |
423 | |
424 | - .. row 4 | |
425 | ||
0579e6e3 | 426 | - |
5377d91f MH |
427 | - __u8 |
428 | ||
8968da9b | 429 | - ``name``\ [32] |
5377d91f MH |
430 | |
431 | - Name of the menu item, a NUL-terminated ASCII string. This | |
0579e6e3 MCC |
432 | information is intended for the user. This field is valid for |
433 | ``V4L2_CTRL_FLAG_MENU`` type controls. | |
5377d91f MH |
434 | |
435 | - .. row 5 | |
436 | ||
0579e6e3 | 437 | - |
5377d91f MH |
438 | - __s64 |
439 | ||
440 | - ``value`` | |
441 | ||
442 | - Value of the integer menu item. This field is valid for | |
0579e6e3 | 443 | ``V4L2_CTRL_FLAG_INTEGER_MENU`` type controls. |
5377d91f MH |
444 | |
445 | - .. row 6 | |
446 | ||
447 | - __u32 | |
448 | ||
0579e6e3 | 449 | - |
5377d91f MH |
450 | - ``reserved`` |
451 | ||
452 | - Reserved for future extensions. Drivers must set the array to | |
0579e6e3 | 453 | zero. |
5377d91f MH |
454 | |
455 | ||
456 | ||
ef76c068 MCC |
457 | .. tabularcolumns:: |p{5.8cm}|p{1.4cm}|p{1.0cm}|p{1.4cm}|p{6.9cm}| |
458 | ||
ffa0441e | 459 | .. c:type:: v4l2_ctrl_type |
fa92b04d | 460 | |
ef76c068 | 461 | .. cssclass:: longtable |
5bd4bb78 | 462 | |
5377d91f MH |
463 | .. flat-table:: enum v4l2_ctrl_type |
464 | :header-rows: 1 | |
465 | :stub-columns: 0 | |
466 | :widths: 30 5 5 5 55 | |
467 | ||
468 | ||
469 | - .. row 1 | |
470 | ||
471 | - Type | |
472 | ||
473 | - ``minimum`` | |
474 | ||
475 | - ``step`` | |
476 | ||
477 | - ``maximum`` | |
478 | ||
479 | - Description | |
480 | ||
481 | - .. row 2 | |
482 | ||
483 | - ``V4L2_CTRL_TYPE_INTEGER`` | |
484 | ||
485 | - any | |
486 | ||
487 | - any | |
488 | ||
489 | - any | |
490 | ||
491 | - An integer-valued control ranging from minimum to maximum | |
0579e6e3 | 492 | inclusive. The step value indicates the increment between values. |
5377d91f MH |
493 | |
494 | - .. row 3 | |
495 | ||
496 | - ``V4L2_CTRL_TYPE_BOOLEAN`` | |
497 | ||
498 | - 0 | |
499 | ||
500 | - 1 | |
501 | ||
502 | - 1 | |
503 | ||
504 | - A boolean-valued control. Zero corresponds to "disabled", and one | |
0579e6e3 | 505 | means "enabled". |
5377d91f MH |
506 | |
507 | - .. row 4 | |
508 | ||
509 | - ``V4L2_CTRL_TYPE_MENU`` | |
510 | ||
511 | - ≥ 0 | |
512 | ||
513 | - 1 | |
514 | ||
515 | - N-1 | |
516 | ||
517 | - The control has a menu of N choices. The names of the menu items | |
0579e6e3 | 518 | can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl. |
5377d91f MH |
519 | |
520 | - .. row 5 | |
521 | ||
522 | - ``V4L2_CTRL_TYPE_INTEGER_MENU`` | |
523 | ||
524 | - ≥ 0 | |
525 | ||
526 | - 1 | |
527 | ||
528 | - N-1 | |
529 | ||
530 | - The control has a menu of N choices. The values of the menu items | |
0579e6e3 MCC |
531 | can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl. This is |
532 | similar to ``V4L2_CTRL_TYPE_MENU`` except that instead of strings, | |
533 | the menu items are signed 64-bit integers. | |
5377d91f MH |
534 | |
535 | - .. row 6 | |
536 | ||
537 | - ``V4L2_CTRL_TYPE_BITMASK`` | |
538 | ||
539 | - 0 | |
540 | ||
541 | - n/a | |
542 | ||
543 | - any | |
544 | ||
545 | - A bitmask field. The maximum value is the set of bits that can be | |
0579e6e3 MCC |
546 | used, all other bits are to be 0. The maximum value is interpreted |
547 | as a __u32, allowing the use of bit 31 in the bitmask. | |
5377d91f MH |
548 | |
549 | - .. row 7 | |
550 | ||
551 | - ``V4L2_CTRL_TYPE_BUTTON`` | |
552 | ||
553 | - 0 | |
554 | ||
555 | - 0 | |
556 | ||
557 | - 0 | |
558 | ||
559 | - A control which performs an action when set. Drivers must ignore | |
0579e6e3 MCC |
560 | the value passed with ``VIDIOC_S_CTRL`` and return an ``EINVAL`` error |
561 | code on a ``VIDIOC_G_CTRL`` attempt. | |
5377d91f MH |
562 | |
563 | - .. row 8 | |
564 | ||
565 | - ``V4L2_CTRL_TYPE_INTEGER64`` | |
566 | ||
567 | - any | |
568 | ||
569 | - any | |
570 | ||
571 | - any | |
572 | ||
573 | - A 64-bit integer valued control. Minimum, maximum and step size | |
0579e6e3 MCC |
574 | cannot be queried using ``VIDIOC_QUERYCTRL``. Only |
575 | ``VIDIOC_QUERY_EXT_CTRL`` can retrieve the 64-bit min/max/step | |
576 | values, they should be interpreted as n/a when using | |
577 | ``VIDIOC_QUERYCTRL``. | |
5377d91f MH |
578 | |
579 | - .. row 9 | |
580 | ||
581 | - ``V4L2_CTRL_TYPE_STRING`` | |
582 | ||
583 | - ≥ 0 | |
584 | ||
585 | - ≥ 1 | |
586 | ||
587 | - ≥ 0 | |
588 | ||
589 | - The minimum and maximum string lengths. The step size means that | |
0579e6e3 MCC |
590 | the string must be (minimum + N * step) characters long for N ≥ 0. |
591 | These lengths do not include the terminating zero, so in order to | |
592 | pass a string of length 8 to | |
593 | :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you need to | |
594 | set the ``size`` field of struct | |
e8be7e97 | 595 | :c:type:`v4l2_ext_control` to 9. For |
0579e6e3 MCC |
596 | :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you can set |
597 | the ``size`` field to ``maximum`` + 1. Which character encoding is | |
598 | used will depend on the string control itself and should be part | |
599 | of the control documentation. | |
5377d91f MH |
600 | |
601 | - .. row 10 | |
602 | ||
603 | - ``V4L2_CTRL_TYPE_CTRL_CLASS`` | |
604 | ||
605 | - n/a | |
606 | ||
607 | - n/a | |
608 | ||
609 | - n/a | |
610 | ||
611 | - This is not a control. When ``VIDIOC_QUERYCTRL`` is called with a | |
0579e6e3 MCC |
612 | control ID equal to a control class code (see :ref:`ctrl-class`) |
613 | + 1, the ioctl returns the name of the control class and this | |
614 | control type. Older drivers which do not support this feature | |
615 | return an ``EINVAL`` error code. | |
5377d91f MH |
616 | |
617 | - .. row 11 | |
618 | ||
619 | - ``V4L2_CTRL_TYPE_U8`` | |
620 | ||
621 | - any | |
622 | ||
623 | - any | |
624 | ||
625 | - any | |
626 | ||
627 | - An unsigned 8-bit valued control ranging from minimum to maximum | |
0579e6e3 | 628 | inclusive. The step value indicates the increment between values. |
5377d91f MH |
629 | |
630 | - .. row 12 | |
631 | ||
632 | - ``V4L2_CTRL_TYPE_U16`` | |
633 | ||
634 | - any | |
635 | ||
636 | - any | |
637 | ||
638 | - any | |
639 | ||
640 | - An unsigned 16-bit valued control ranging from minimum to maximum | |
0579e6e3 | 641 | inclusive. The step value indicates the increment between values. |
5377d91f MH |
642 | |
643 | - .. row 13 | |
644 | ||
645 | - ``V4L2_CTRL_TYPE_U32`` | |
646 | ||
647 | - any | |
648 | ||
649 | - any | |
650 | ||
651 | - any | |
652 | ||
653 | - An unsigned 32-bit valued control ranging from minimum to maximum | |
0579e6e3 | 654 | inclusive. The step value indicates the increment between values. |
5377d91f MH |
655 | |
656 | ||
657 | ||
5bd4bb78 MCC |
658 | .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| |
659 | ||
fa92b04d MCC |
660 | .. _control-flags: |
661 | ||
ef76c068 MCC |
662 | .. cssclass:: longtable |
663 | ||
5377d91f MH |
664 | .. flat-table:: Control Flags |
665 | :header-rows: 0 | |
666 | :stub-columns: 0 | |
667 | :widths: 3 1 4 | |
668 | ||
669 | ||
670 | - .. row 1 | |
671 | ||
672 | - ``V4L2_CTRL_FLAG_DISABLED`` | |
673 | ||
674 | - 0x0001 | |
675 | ||
676 | - This control is permanently disabled and should be ignored by the | |
0579e6e3 MCC |
677 | application. Any attempt to change the control will result in an |
678 | ``EINVAL`` error code. | |
5377d91f MH |
679 | |
680 | - .. row 2 | |
681 | ||
682 | - ``V4L2_CTRL_FLAG_GRABBED`` | |
683 | ||
684 | - 0x0002 | |
685 | ||
686 | - This control is temporarily unchangeable, for example because | |
0579e6e3 MCC |
687 | another application took over control of the respective resource. |
688 | Such controls may be displayed specially in a user interface. | |
689 | Attempts to change the control may result in an ``EBUSY`` error code. | |
5377d91f MH |
690 | |
691 | - .. row 3 | |
692 | ||
693 | - ``V4L2_CTRL_FLAG_READ_ONLY`` | |
694 | ||
695 | - 0x0004 | |
696 | ||
697 | - This control is permanently readable only. Any attempt to change | |
0579e6e3 | 698 | the control will result in an ``EINVAL`` error code. |
5377d91f MH |
699 | |
700 | - .. row 4 | |
701 | ||
702 | - ``V4L2_CTRL_FLAG_UPDATE`` | |
703 | ||
704 | - 0x0008 | |
705 | ||
706 | - A hint that changing this control may affect the value of other | |
0579e6e3 MCC |
707 | controls within the same control class. Applications should update |
708 | their user interface accordingly. | |
5377d91f MH |
709 | |
710 | - .. row 5 | |
711 | ||
712 | - ``V4L2_CTRL_FLAG_INACTIVE`` | |
713 | ||
714 | - 0x0010 | |
715 | ||
716 | - This control is not applicable to the current configuration and | |
0579e6e3 MCC |
717 | should be displayed accordingly in a user interface. For example |
718 | the flag may be set on a MPEG audio level 2 bitrate control when | |
719 | MPEG audio encoding level 1 was selected with another control. | |
5377d91f MH |
720 | |
721 | - .. row 6 | |
722 | ||
723 | - ``V4L2_CTRL_FLAG_SLIDER`` | |
724 | ||
725 | - 0x0020 | |
726 | ||
727 | - A hint that this control is best represented as a slider-like | |
0579e6e3 | 728 | element in a user interface. |
5377d91f MH |
729 | |
730 | - .. row 7 | |
731 | ||
732 | - ``V4L2_CTRL_FLAG_WRITE_ONLY`` | |
733 | ||
734 | - 0x0040 | |
735 | ||
736 | - This control is permanently writable only. Any attempt to read the | |
0579e6e3 MCC |
737 | control will result in an ``EACCES`` error code error code. This flag |
738 | is typically present for relative controls or action controls | |
739 | where writing a value will cause the device to carry out a given | |
740 | action (e. g. motor control) but no meaningful value can be | |
741 | returned. | |
5377d91f MH |
742 | |
743 | - .. row 8 | |
744 | ||
745 | - ``V4L2_CTRL_FLAG_VOLATILE`` | |
746 | ||
747 | - 0x0080 | |
748 | ||
749 | - This control is volatile, which means that the value of the | |
0579e6e3 MCC |
750 | control changes continuously. A typical example would be the |
751 | current gain value if the device is in auto-gain mode. In such a | |
752 | case the hardware calculates the gain value based on the lighting | |
706f8a99 MCC |
753 | conditions which can change over time. |
754 | ||
b6b6e678 MCC |
755 | .. note:: |
756 | ||
f22bede3 RR |
757 | Setting a new value for a volatile control will be ignored |
758 | unless | |
759 | :ref:`V4L2_CTRL_FLAG_EXECUTE_ON_WRITE <FLAG_EXECUTE_ON_WRITE>` | |
760 | is also set. | |
761 | Setting a new value for a volatile control will *never* trigger a | |
762 | :ref:`V4L2_EVENT_CTRL_CH_VALUE <ctrl-changes-flags>` event. | |
5377d91f MH |
763 | |
764 | - .. row 9 | |
765 | ||
766 | - ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` | |
767 | ||
768 | - 0x0100 | |
769 | ||
770 | - This control has a pointer type, so its value has to be accessed | |
0579e6e3 | 771 | using one of the pointer fields of struct |
e8be7e97 | 772 | :c:type:`v4l2_ext_control`. This flag is set |
0579e6e3 MCC |
773 | for controls that are an array, string, or have a compound type. |
774 | In all cases you have to set a pointer to memory containing the | |
775 | payload of the control. | |
5377d91f MH |
776 | |
777 | - .. row 10 | |
f22bede3 | 778 | .. _FLAG_EXECUTE_ON_WRITE: |
5377d91f MH |
779 | |
780 | - ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE`` | |
781 | ||
782 | - 0x0200 | |
783 | ||
784 | - The value provided to the control will be propagated to the driver | |
0579e6e3 MCC |
785 | even if it remains constant. This is required when the control |
786 | represents an action on the hardware. For example: clearing an | |
787 | error flag or triggering the flash. All the controls of the type | |
788 | ``V4L2_CTRL_TYPE_BUTTON`` have this flag set. | |
5377d91f MH |
789 | |
790 | ||
15e7d615 | 791 | Return Value |
5377d91f MH |
792 | ============ |
793 | ||
794 | On success 0 is returned, on error -1 and the ``errno`` variable is set | |
795 | appropriately. The generic error codes are described at the | |
796 | :ref:`Generic Error Codes <gen-errors>` chapter. | |
797 | ||
798 | EINVAL | |
799 | The struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id`` is | |
800 | invalid. The struct :ref:`v4l2_querymenu <v4l2-querymenu>` ``id`` | |
801 | is invalid or ``index`` is out of range (less than ``minimum`` or | |
802 | greater than ``maximum``) or this particular menu item is not | |
803 | supported by the driver. | |
804 | ||
805 | EACCES | |
806 | An attempt was made to read a write-only control. | |
807 | ||
4855307b | 808 | .. [#f1] |
5377d91f MH |
809 | ``V4L2_CTRL_FLAG_DISABLED`` was intended for two purposes: Drivers |
810 | can skip predefined controls not supported by the hardware (although | |
cdb4af0f | 811 | returning ``EINVAL`` would do as well), or disable predefined and private |
5377d91f | 812 | controls after hardware detection without the trouble of reordering |
cdb4af0f | 813 | control arrays and indices (``EINVAL`` cannot be used to skip private |
5377d91f | 814 | controls because it would prematurely end the enumeration). |