Merge tag 'Smack-for-5.11-io_uring-fix' of git://github.com/cschaufler/smack-next
[linux-2.6-microblaze.git] / Documentation / userspace-api / media / v4l / vidioc-queryctrl.rst
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_QUERYCTRL:
5
6 *******************************************************************
7 ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU
8 *******************************************************************
9
10 Name
11 ====
12
13 VIDIOC_QUERYCTRL - VIDIOC_QUERY_EXT_CTRL - VIDIOC_QUERYMENU - Enumerate controls and menu control items
14
15 Synopsis
16 ========
17
18 ``int ioctl(int fd, int VIDIOC_QUERYCTRL, struct v4l2_queryctrl *argp)``
19
20 .. c:macro:: VIDIOC_QUERY_EXT_CTRL
21
22 ``int ioctl(int fd, VIDIOC_QUERY_EXT_CTRL, struct v4l2_query_ext_ctrl *argp)``
23
24 .. c:macro:: VIDIOC_QUERYMENU
25
26 ``int ioctl(int fd, VIDIOC_QUERYMENU, struct v4l2_querymenu *argp)``
27
28 Arguments
29 =========
30
31 ``fd``
32     File descriptor returned by :c:func:`open()`.
33
34 ``argp``
35     Pointer to struct :c:type:`v4l2_queryctrl`, :c:type:`v4l2_query_ext_ctrl`
36     or :c:type:`v4l2_querymenu` (depending on the ioctl).
37
38 Description
39 ===========
40
41 To query the attributes of a control applications set the ``id`` field
42 of a struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` and call the
43 ``VIDIOC_QUERYCTRL`` ioctl with a pointer to this structure. The driver
44 fills the rest of the structure or returns an ``EINVAL`` error code when the
45 ``id`` is invalid.
46
47 It is possible to enumerate controls by calling ``VIDIOC_QUERYCTRL``
48 with successive ``id`` values starting from ``V4L2_CID_BASE`` up to and
49 exclusive ``V4L2_CID_LASTP1``. Drivers may return ``EINVAL`` if a control in
50 this range is not supported. Further applications can enumerate private
51 controls, which are not defined in this specification, by starting at
52 ``V4L2_CID_PRIVATE_BASE`` and incrementing ``id`` until the driver
53 returns ``EINVAL``.
54
55 In both cases, when the driver sets the ``V4L2_CTRL_FLAG_DISABLED`` flag
56 in the ``flags`` field this control is permanently disabled and should
57 be ignored by the application. [#f1]_
58
59 When the application ORs ``id`` with ``V4L2_CTRL_FLAG_NEXT_CTRL`` the
60 driver returns the next supported non-compound control, or ``EINVAL`` if
61 there is none. In addition, the ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` flag
62 can be specified to enumerate all compound controls (i.e. controls with
63 type ≥ ``V4L2_CTRL_COMPOUND_TYPES`` and/or array control, in other words
64 controls that contain more than one value). Specify both
65 ``V4L2_CTRL_FLAG_NEXT_CTRL`` and ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` in
66 order to enumerate all controls, compound or not. Drivers which do not
67 support these flags yet always return ``EINVAL``.
68
69 The ``VIDIOC_QUERY_EXT_CTRL`` ioctl was introduced in order to better
70 support controls that can use compound types, and to expose additional
71 control information that cannot be returned in struct
72 :ref:`v4l2_queryctrl <v4l2-queryctrl>` since that structure is full.
73
74 ``VIDIOC_QUERY_EXT_CTRL`` is used in the same way as
75 ``VIDIOC_QUERYCTRL``, except that the ``reserved`` array must be zeroed
76 as well.
77
78 Additional information is required for menu controls: the names of the
79 menu items. To query them applications set the ``id`` and ``index``
80 fields of struct :ref:`v4l2_querymenu <v4l2-querymenu>` and call the
81 ``VIDIOC_QUERYMENU`` ioctl with a pointer to this structure. The driver
82 fills the rest of the structure or returns an ``EINVAL`` error code when the
83 ``id`` or ``index`` is invalid. Menu items are enumerated by calling
84 ``VIDIOC_QUERYMENU`` with successive ``index`` values from struct
85 :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``minimum`` to ``maximum``,
86 inclusive.
87
88 .. note::
89
90    It is possible for ``VIDIOC_QUERYMENU`` to return
91    an ``EINVAL`` error code for some indices between ``minimum`` and
92    ``maximum``. In that case that particular menu item is not supported by
93    this driver. Also note that the ``minimum`` value is not necessarily 0.
94
95 See also the examples in :ref:`control`.
96
97 .. tabularcolumns:: |p{1.2cm}|p{3.6cm}|p{12.7cm}|
98
99 .. _v4l2-queryctrl:
100
101 .. cssclass:: longtable
102
103 .. flat-table:: struct v4l2_queryctrl
104     :header-rows:  0
105     :stub-columns: 0
106     :widths:       1 1 2
107
108     * - __u32
109       - ``id``
110       - Identifies the control, set by the application. See
111         :ref:`control-id` for predefined IDs. When the ID is ORed with
112         V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and
113         returns the first control with a higher ID. Drivers which do not
114         support this flag yet always return an ``EINVAL`` error code.
115     * - __u32
116       - ``type``
117       - Type of control, see :c:type:`v4l2_ctrl_type`.
118     * - __u8
119       - ``name``\ [32]
120       - Name of the control, a NUL-terminated ASCII string. This
121         information is intended for the user.
122     * - __s32
123       - ``minimum``
124       - Minimum value, inclusive. This field gives a lower bound for the
125         control. See enum :c:type:`v4l2_ctrl_type` how
126         the minimum value is to be used for each possible control type.
127         Note that this a signed 32-bit value.
128     * - __s32
129       - ``maximum``
130       - Maximum value, inclusive. This field gives an upper bound for the
131         control. See enum :c:type:`v4l2_ctrl_type` how
132         the maximum value is to be used for each possible control type.
133         Note that this a signed 32-bit value.
134     * - __s32
135       - ``step``
136       - This field gives a step size for the control. See enum
137         :c:type:`v4l2_ctrl_type` how the step value is
138         to be used for each possible control type. Note that this an
139         unsigned 32-bit value.
140
141         Generally drivers should not scale hardware control values. It may
142         be necessary for example when the ``name`` or ``id`` imply a
143         particular unit and the hardware actually accepts only multiples
144         of said unit. If so, drivers must take care values are properly
145         rounded when scaling, such that errors will not accumulate on
146         repeated read-write cycles.
147
148         This field gives the smallest change of an integer control
149         actually affecting hardware. Often the information is needed when
150         the user can change controls by keyboard or GUI buttons, rather
151         than a slider. When for example a hardware register accepts values
152         0-511 and the driver reports 0-65535, step should be 128.
153
154         Note that although signed, the step value is supposed to be always
155         positive.
156     * - __s32
157       - ``default_value``
158       - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_BOOLEAN``,
159         ``_BITMASK``, ``_MENU`` or ``_INTEGER_MENU`` control. Not valid
160         for other types of controls.
161
162         .. note::
163
164            Drivers reset controls to their default value only when
165            the driver is first loaded, never afterwards.
166     * - __u32
167       - ``flags``
168       - Control flags, see :ref:`control-flags`.
169     * - __u32
170       - ``reserved``\ [2]
171       - Reserved for future extensions. Drivers must set the array to
172         zero.
173
174
175 .. tabularcolumns:: |p{1.2cm}|p{5.0cm}|p{11.3cm}|
176
177 .. _v4l2-query-ext-ctrl:
178
179 .. cssclass:: longtable
180
181 .. flat-table:: struct v4l2_query_ext_ctrl
182     :header-rows:  0
183     :stub-columns: 0
184     :widths:       1 1 2
185
186     * - __u32
187       - ``id``
188       - Identifies the control, set by the application. See
189         :ref:`control-id` for predefined IDs. When the ID is ORed with
190         ``V4L2_CTRL_FLAG_NEXT_CTRL`` the driver clears the flag and
191         returns the first non-compound control with a higher ID. When the
192         ID is ORed with ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` the driver clears
193         the flag and returns the first compound control with a higher ID.
194         Set both to get the first control (compound or not) with a higher
195         ID.
196     * - __u32
197       - ``type``
198       - Type of control, see :c:type:`v4l2_ctrl_type`.
199     * - char
200       - ``name``\ [32]
201       - Name of the control, a NUL-terminated ASCII string. This
202         information is intended for the user.
203     * - __s64
204       - ``minimum``
205       - Minimum value, inclusive. This field gives a lower bound for the
206         control. See enum :c:type:`v4l2_ctrl_type` how
207         the minimum value is to be used for each possible control type.
208         Note that this a signed 64-bit value.
209     * - __s64
210       - ``maximum``
211       - Maximum value, inclusive. This field gives an upper bound for the
212         control. See enum :c:type:`v4l2_ctrl_type` how
213         the maximum value is to be used for each possible control type.
214         Note that this a signed 64-bit value.
215     * - __u64
216       - ``step``
217       - This field gives a step size for the control. See enum
218         :c:type:`v4l2_ctrl_type` how the step value is
219         to be used for each possible control type. Note that this an
220         unsigned 64-bit value.
221
222         Generally drivers should not scale hardware control values. It may
223         be necessary for example when the ``name`` or ``id`` imply a
224         particular unit and the hardware actually accepts only multiples
225         of said unit. If so, drivers must take care values are properly
226         rounded when scaling, such that errors will not accumulate on
227         repeated read-write cycles.
228
229         This field gives the smallest change of an integer control
230         actually affecting hardware. Often the information is needed when
231         the user can change controls by keyboard or GUI buttons, rather
232         than a slider. When for example a hardware register accepts values
233         0-511 and the driver reports 0-65535, step should be 128.
234     * - __s64
235       - ``default_value``
236       - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_INTEGER64``,
237         ``_BOOLEAN``, ``_BITMASK``, ``_MENU``, ``_INTEGER_MENU``, ``_U8``
238         or ``_U16`` control. Not valid for other types of controls.
239
240         .. note::
241
242            Drivers reset controls to their default value only when
243            the driver is first loaded, never afterwards.
244     * - __u32
245       - ``flags``
246       - Control flags, see :ref:`control-flags`.
247     * - __u32
248       - ``elem_size``
249       - The size in bytes of a single element of the array. Given a char
250         pointer ``p`` to a 3-dimensional array you can find the position
251         of cell ``(z, y, x)`` as follows:
252         ``p + ((z * dims[1] + y) * dims[0] + x) * elem_size``.
253         ``elem_size`` is always valid, also when the control isn't an
254         array. For string controls ``elem_size`` is equal to
255         ``maximum + 1``.
256     * - __u32
257       - ``elems``
258       - The number of elements in the N-dimensional array. If this control
259         is not an array, then ``elems`` is 1. The ``elems`` field can
260         never be 0.
261     * - __u32
262       - ``nr_of_dims``
263       - The number of dimension in the N-dimensional array. If this
264         control is not an array, then this field is 0.
265     * - __u32
266       - ``dims[V4L2_CTRL_MAX_DIMS]``
267       - The size of each dimension. The first ``nr_of_dims`` elements of
268         this array must be non-zero, all remaining elements must be zero.
269     * - __u32
270       - ``reserved``\ [32]
271       - Reserved for future extensions. Applications and drivers must set
272         the array to zero.
273
274
275 .. tabularcolumns:: |p{1.2cm}|p{1.0cm}|p{1.7cm}|p{13.0cm}|
276
277 .. _v4l2-querymenu:
278
279 .. flat-table:: struct v4l2_querymenu
280     :header-rows:  0
281     :stub-columns: 0
282     :widths:       1 1 2
283
284     * - __u32
285       - ``id``
286       - Identifies the control, set by the application from the respective
287         struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id``.
288     * - __u32
289       - ``index``
290       - Index of the menu item, starting at zero, set by the application.
291     * - union {
292       - (anonymous)
293     * - __u8
294       - ``name``\ [32]
295       - Name of the menu item, a NUL-terminated ASCII string. This
296         information is intended for the user. This field is valid for
297         ``V4L2_CTRL_TYPE_MENU`` type controls.
298     * - __s64
299       - ``value``
300       - Value of the integer menu item. This field is valid for
301         ``V4L2_CTRL_TYPE_INTEGER_MENU`` type controls.
302     * - }
303       -
304     * - __u32
305       - ``reserved``
306       - Reserved for future extensions. Drivers must set the array to
307         zero.
308
309
310 .. tabularcolumns:: |p{5.8cm}|p{1.4cm}|p{1.0cm}|p{1.4cm}|p{6.9cm}|
311
312 .. c:type:: v4l2_ctrl_type
313
314 .. cssclass:: longtable
315
316 .. flat-table:: enum v4l2_ctrl_type
317     :header-rows:  1
318     :stub-columns: 0
319     :widths:       30 5 5 5 55
320
321     * - Type
322       - ``minimum``
323       - ``step``
324       - ``maximum``
325       - Description
326     * - ``V4L2_CTRL_TYPE_INTEGER``
327       - any
328       - any
329       - any
330       - An integer-valued control ranging from minimum to maximum
331         inclusive. The step value indicates the increment between values.
332     * - ``V4L2_CTRL_TYPE_BOOLEAN``
333       - 0
334       - 1
335       - 1
336       - A boolean-valued control. Zero corresponds to "disabled", and one
337         means "enabled".
338     * - ``V4L2_CTRL_TYPE_MENU``
339       - ≥ 0
340       - 1
341       - N-1
342       - The control has a menu of N choices. The names of the menu items
343         can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl.
344     * - ``V4L2_CTRL_TYPE_INTEGER_MENU``
345       - ≥ 0
346       - 1
347       - N-1
348       - The control has a menu of N choices. The values of the menu items
349         can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl. This is
350         similar to ``V4L2_CTRL_TYPE_MENU`` except that instead of strings,
351         the menu items are signed 64-bit integers.
352     * - ``V4L2_CTRL_TYPE_BITMASK``
353       - 0
354       - n/a
355       - any
356       - A bitmask field. The maximum value is the set of bits that can be
357         used, all other bits are to be 0. The maximum value is interpreted
358         as a __u32, allowing the use of bit 31 in the bitmask.
359     * - ``V4L2_CTRL_TYPE_BUTTON``
360       - 0
361       - 0
362       - 0
363       - A control which performs an action when set. Drivers must ignore
364         the value passed with ``VIDIOC_S_CTRL`` and return an ``EACCES`` error
365         code on a ``VIDIOC_G_CTRL`` attempt.
366     * - ``V4L2_CTRL_TYPE_INTEGER64``
367       - any
368       - any
369       - any
370       - A 64-bit integer valued control. Minimum, maximum and step size
371         cannot be queried using ``VIDIOC_QUERYCTRL``. Only
372         ``VIDIOC_QUERY_EXT_CTRL`` can retrieve the 64-bit min/max/step
373         values, they should be interpreted as n/a when using
374         ``VIDIOC_QUERYCTRL``.
375     * - ``V4L2_CTRL_TYPE_STRING``
376       - ≥ 0
377       - ≥ 1
378       - ≥ 0
379       - The minimum and maximum string lengths. The step size means that
380         the string must be (minimum + N * step) characters long for N ≥ 0.
381         These lengths do not include the terminating zero, so in order to
382         pass a string of length 8 to
383         :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you need to
384         set the ``size`` field of struct
385         :c:type:`v4l2_ext_control` to 9. For
386         :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you can set
387         the ``size`` field to ``maximum`` + 1. Which character encoding is
388         used will depend on the string control itself and should be part
389         of the control documentation.
390     * - ``V4L2_CTRL_TYPE_CTRL_CLASS``
391       - n/a
392       - n/a
393       - n/a
394       - This is not a control. When ``VIDIOC_QUERYCTRL`` is called with a
395         control ID equal to a control class code (see :ref:`ctrl-class`)
396         + 1, the ioctl returns the name of the control class and this
397         control type. Older drivers which do not support this feature
398         return an ``EINVAL`` error code.
399     * - ``V4L2_CTRL_TYPE_U8``
400       - any
401       - any
402       - any
403       - An unsigned 8-bit valued control ranging from minimum to maximum
404         inclusive. The step value indicates the increment between values.
405     * - ``V4L2_CTRL_TYPE_U16``
406       - any
407       - any
408       - any
409       - An unsigned 16-bit valued control ranging from minimum to maximum
410         inclusive. The step value indicates the increment between values.
411     * - ``V4L2_CTRL_TYPE_U32``
412       - any
413       - any
414       - any
415       - An unsigned 32-bit valued control ranging from minimum to maximum
416         inclusive. The step value indicates the increment between values.
417     * - ``V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS``
418       - n/a
419       - n/a
420       - n/a
421       - A struct :c:type:`v4l2_ctrl_mpeg2_slice_params`, containing MPEG-2
422         slice parameters for stateless video decoders.
423     * - ``V4L2_CTRL_TYPE_MPEG2_QUANTIZATION``
424       - n/a
425       - n/a
426       - n/a
427       - A struct :c:type:`v4l2_ctrl_mpeg2_quantization`, containing MPEG-2
428         quantization matrices for stateless video decoders.
429     * - ``V4L2_CTRL_TYPE_AREA``
430       - n/a
431       - n/a
432       - n/a
433       - A struct :c:type:`v4l2_area`, containing the width and the height
434         of a rectangular area. Units depend on the use case.
435     * - ``V4L2_CTRL_TYPE_H264_SPS``
436       - n/a
437       - n/a
438       - n/a
439       - A struct :c:type:`v4l2_ctrl_h264_sps`, containing H264
440         sequence parameters for stateless video decoders.
441     * - ``V4L2_CTRL_TYPE_H264_PPS``
442       - n/a
443       - n/a
444       - n/a
445       - A struct :c:type:`v4l2_ctrl_h264_pps`, containing H264
446         picture parameters for stateless video decoders.
447     * - ``V4L2_CTRL_TYPE_H264_SCALING_MATRIX``
448       - n/a
449       - n/a
450       - n/a
451       - A struct :c:type:`v4l2_ctrl_h264_scaling_matrix`, containing H264
452         scaling matrices for stateless video decoders.
453     * - ``V4L2_CTRL_TYPE_H264_SLICE_PARAMS``
454       - n/a
455       - n/a
456       - n/a
457       - A struct :c:type:`v4l2_ctrl_h264_slice_params`, containing H264
458         slice parameters for stateless video decoders.
459     * - ``V4L2_CTRL_TYPE_H264_DECODE_PARAMS``
460       - n/a
461       - n/a
462       - n/a
463       - A struct :c:type:`v4l2_ctrl_h264_decode_params`, containing H264
464         decode parameters for stateless video decoders.
465     * - ``V4L2_CTRL_TYPE_FWHT_PARAMS``
466       - n/a
467       - n/a
468       - n/a
469       - A struct :c:type:`v4l2_ctrl_fwht_params`, containing FWHT
470         parameters for stateless video decoders.
471     * - ``V4L2_CTRL_TYPE_HEVC_SPS``
472       - n/a
473       - n/a
474       - n/a
475       - A struct :c:type:`v4l2_ctrl_hevc_sps`, containing HEVC Sequence
476         Parameter Set for stateless video decoders.
477     * - ``V4L2_CTRL_TYPE_HEVC_PPS``
478       - n/a
479       - n/a
480       - n/a
481       - A struct :c:type:`v4l2_ctrl_hevc_pps`, containing HEVC Picture
482         Parameter Set for stateless video decoders.
483     * - ``V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS``
484       - n/a
485       - n/a
486       - n/a
487       - A struct :c:type:`v4l2_ctrl_hevc_slice_params`, containing HEVC
488         slice parameters for stateless video decoders.
489
490 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
491
492 .. _control-flags:
493
494 .. cssclass:: longtable
495
496 .. flat-table:: Control Flags
497     :header-rows:  0
498     :stub-columns: 0
499     :widths:       3 1 4
500
501     * - ``V4L2_CTRL_FLAG_DISABLED``
502       - 0x0001
503       - This control is permanently disabled and should be ignored by the
504         application. Any attempt to change the control will result in an
505         ``EINVAL`` error code.
506     * - ``V4L2_CTRL_FLAG_GRABBED``
507       - 0x0002
508       - This control is temporarily unchangeable, for example because
509         another application took over control of the respective resource.
510         Such controls may be displayed specially in a user interface.
511         Attempts to change the control may result in an ``EBUSY`` error code.
512     * - ``V4L2_CTRL_FLAG_READ_ONLY``
513       - 0x0004
514       - This control is permanently readable only. Any attempt to change
515         the control will result in an ``EINVAL`` error code.
516     * - ``V4L2_CTRL_FLAG_UPDATE``
517       - 0x0008
518       - A hint that changing this control may affect the value of other
519         controls within the same control class. Applications should update
520         their user interface accordingly.
521     * - ``V4L2_CTRL_FLAG_INACTIVE``
522       - 0x0010
523       - This control is not applicable to the current configuration and
524         should be displayed accordingly in a user interface. For example
525         the flag may be set on a MPEG audio level 2 bitrate control when
526         MPEG audio encoding level 1 was selected with another control.
527     * - ``V4L2_CTRL_FLAG_SLIDER``
528       - 0x0020
529       - A hint that this control is best represented as a slider-like
530         element in a user interface.
531     * - ``V4L2_CTRL_FLAG_WRITE_ONLY``
532       - 0x0040
533       - This control is permanently writable only. Any attempt to read the
534         control will result in an ``EACCES`` error code error code. This flag
535         is typically present for relative controls or action controls
536         where writing a value will cause the device to carry out a given
537         action (e. g. motor control) but no meaningful value can be
538         returned.
539     * - ``V4L2_CTRL_FLAG_VOLATILE``
540       - 0x0080
541       - This control is volatile, which means that the value of the
542         control changes continuously. A typical example would be the
543         current gain value if the device is in auto-gain mode. In such a
544         case the hardware calculates the gain value based on the lighting
545         conditions which can change over time.
546
547         .. note::
548
549            Setting a new value for a volatile control will be ignored
550            unless
551            :ref:`V4L2_CTRL_FLAG_EXECUTE_ON_WRITE <FLAG_EXECUTE_ON_WRITE>`
552            is also set.
553            Setting a new value for a volatile control will *never* trigger a
554            :ref:`V4L2_EVENT_CTRL_CH_VALUE <ctrl-changes-flags>` event.
555     * - ``V4L2_CTRL_FLAG_HAS_PAYLOAD``
556       - 0x0100
557       - This control has a pointer type, so its value has to be accessed
558         using one of the pointer fields of struct
559         :c:type:`v4l2_ext_control`. This flag is set
560         for controls that are an array, string, or have a compound type.
561         In all cases you have to set a pointer to memory containing the
562         payload of the control.
563     * .. _FLAG_EXECUTE_ON_WRITE:
564
565       - ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
566       - 0x0200
567       - The value provided to the control will be propagated to the driver
568         even if it remains constant. This is required when the control
569         represents an action on the hardware. For example: clearing an
570         error flag or triggering the flash. All the controls of the type
571         ``V4L2_CTRL_TYPE_BUTTON`` have this flag set.
572     * .. _FLAG_MODIFY_LAYOUT:
573
574       - ``V4L2_CTRL_FLAG_MODIFY_LAYOUT``
575       - 0x0400
576       - Changing this control value may modify the layout of the
577         buffer (for video devices) or the media bus format (for sub-devices).
578
579         A typical example would be the ``V4L2_CID_ROTATE`` control.
580
581         Note that typically controls with this flag will also set the
582         ``V4L2_CTRL_FLAG_GRABBED`` flag when buffers are allocated or
583         streaming is in progress since most drivers do not support changing
584         the format in that case.
585
586 Return Value
587 ============
588
589 On success 0 is returned, on error -1 and the ``errno`` variable is set
590 appropriately. The generic error codes are described at the
591 :ref:`Generic Error Codes <gen-errors>` chapter.
592
593 EINVAL
594     The struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id`` is
595     invalid. The struct :ref:`v4l2_querymenu <v4l2-querymenu>` ``id``
596     is invalid or ``index`` is out of range (less than ``minimum`` or
597     greater than ``maximum``) or this particular menu item is not
598     supported by the driver.
599
600 EACCES
601     An attempt was made to read a write-only control.
602
603 .. [#f1]
604    ``V4L2_CTRL_FLAG_DISABLED`` was intended for two purposes: Drivers
605    can skip predefined controls not supported by the hardware (although
606    returning ``EINVAL`` would do as well), or disable predefined and private
607    controls after hardware detection without the trouble of reordering
608    control arrays and indices (``EINVAL`` cannot be used to skip private
609    controls because it would prematurely end the enumeration).