vidioc-g-ext-ctrls.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _VIDIOC_G_EXT_CTRLS:
  4. ******************************************************************
  5. ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS
  6. ******************************************************************
  7. Name
  8. ====
  9. VIDIOC_G_EXT_CTRLS - VIDIOC_S_EXT_CTRLS - VIDIOC_TRY_EXT_CTRLS - Get or set the value of several controls, try control values
  10. Synopsis
  11. ========
  12. .. c:macro:: VIDIOC_G_EXT_CTRLS
  13. ``int ioctl(int fd, VIDIOC_G_EXT_CTRLS, struct v4l2_ext_controls *argp)``
  14. .. c:macro:: VIDIOC_S_EXT_CTRLS
  15. ``int ioctl(int fd, VIDIOC_S_EXT_CTRLS, struct v4l2_ext_controls *argp)``
  16. .. c:macro:: VIDIOC_TRY_EXT_CTRLS
  17. ``int ioctl(int fd, VIDIOC_TRY_EXT_CTRLS, struct v4l2_ext_controls *argp)``
  18. Arguments
  19. =========
  20. ``fd``
  21. File descriptor returned by :c:func:`open()`.
  22. ``argp``
  23. Pointer to struct :c:type:`v4l2_ext_controls`.
  24. Description
  25. ===========
  26. These ioctls allow the caller to get or set multiple controls
  27. atomically. Control IDs are grouped into control classes (see
  28. :ref:`ctrl-class`) and all controls in the control array must belong
  29. to the same control class.
  30. Applications must always fill in the ``count``, ``which``, ``controls``
  31. and ``reserved`` fields of struct
  32. :c:type:`v4l2_ext_controls`, and initialize the
  33. struct :c:type:`v4l2_ext_control` array pointed to
  34. by the ``controls`` fields.
  35. To get the current value of a set of controls applications initialize
  36. the ``id``, ``size`` and ``reserved2`` fields of each struct
  37. :c:type:`v4l2_ext_control` and call the
  38. :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. String controls must also set the
  39. ``string`` field. Controls of compound types
  40. (``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set) must set the ``ptr`` field.
  41. If the ``size`` is too small to receive the control result (only
  42. relevant for pointer-type controls like strings), then the driver will
  43. set ``size`` to a valid value and return an ``ENOSPC`` error code. You
  44. should re-allocate the memory to this new size and try again. For the
  45. string type it is possible that the same issue occurs again if the
  46. string has grown in the meantime. It is recommended to call
  47. :ref:`VIDIOC_QUERYCTRL` first and use
  48. ``maximum``\ +1 as the new ``size`` value. It is guaranteed that that is
  49. sufficient memory.
  50. N-dimensional arrays are set and retrieved row-by-row. You cannot set a
  51. partial array, all elements have to be set or retrieved. The total size
  52. is calculated as ``elems`` * ``elem_size``. These values can be obtained
  53. by calling :ref:`VIDIOC_QUERY_EXT_CTRL <VIDIOC_QUERYCTRL>`.
  54. To change the value of a set of controls applications initialize the
  55. ``id``, ``size``, ``reserved2`` and ``value/value64/string/ptr`` fields
  56. of each struct :c:type:`v4l2_ext_control` and call
  57. the :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. The controls will only be set if *all*
  58. control values are valid.
  59. To check if a set of controls have correct values applications
  60. initialize the ``id``, ``size``, ``reserved2`` and
  61. ``value/value64/string/ptr`` fields of each struct
  62. :c:type:`v4l2_ext_control` and call the
  63. :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. It is up to the driver whether wrong
  64. values are automatically adjusted to a valid value or if an error is
  65. returned.
  66. When the ``id`` or ``which`` is invalid drivers return an ``EINVAL`` error
  67. code. When the value is out of bounds drivers can choose to take the
  68. closest valid value or return an ``ERANGE`` error code, whatever seems more
  69. appropriate. In the first case the new value is set in struct
  70. :c:type:`v4l2_ext_control`. If the new control value
  71. is inappropriate (e.g. the given menu index is not supported by the menu
  72. control), then this will also result in an ``EINVAL`` error code error.
  73. If ``request_fd`` is set to a not-yet-queued :ref:`request <media-request-api>`
  74. file descriptor and ``which`` is set to ``V4L2_CTRL_WHICH_REQUEST_VAL``,
  75. then the controls are not applied immediately when calling
  76. :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, but instead are applied by
  77. the driver for the buffer associated with the same request.
  78. If the device does not support requests, then ``EACCES`` will be returned.
  79. If requests are supported but an invalid request file descriptor is given,
  80. then ``EINVAL`` will be returned.
  81. An attempt to call :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` for a
  82. request that has already been queued will result in an ``EBUSY`` error.
  83. If ``request_fd`` is specified and ``which`` is set to
  84. ``V4L2_CTRL_WHICH_REQUEST_VAL`` during a call to
  85. :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then it will return the
  86. values of the controls at the time of request completion.
  87. If the request is not yet completed, then this will result in an
  88. ``EACCES`` error.
  89. The driver will only set/get these controls if all control values are
  90. correct. This prevents the situation where only some of the controls
  91. were set/get. Only low-level errors (e. g. a failed i2c command) can
  92. still cause this situation.
  93. .. tabularcolumns:: |p{6.8cm}|p{4.0cm}|p{6.5cm}|
  94. .. c:type:: v4l2_ext_control
  95. .. raw:: latex
  96. \footnotesize
  97. .. cssclass:: longtable
  98. .. flat-table:: struct v4l2_ext_control
  99. :header-rows: 0
  100. :stub-columns: 0
  101. :widths: 1 1 2
  102. * - __u32
  103. - ``id``
  104. - Identifies the control, set by the application.
  105. * - __u32
  106. - ``size``
  107. - The total size in bytes of the payload of this control.
  108. * - :cspan:`2` The ``size`` field is normally 0, but for pointer
  109. controls this should be set to the size of the memory that contains
  110. the payload or that will receive the payload.
  111. If :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` finds that this value
  112. is less than is required to store the payload result, then it is set
  113. to a value large enough to store the payload result and ``ENOSPC`` is
  114. returned.
  115. .. note::
  116. For string controls, this ``size`` field should
  117. not be confused with the length of the string. This field refers
  118. to the size of the memory that contains the string. The actual
  119. *length* of the string may well be much smaller.
  120. * - __u32
  121. - ``reserved2``\ [1]
  122. - Reserved for future extensions. Drivers and applications must set
  123. the array to zero.
  124. * - union {
  125. - (anonymous)
  126. * - __s32
  127. - ``value``
  128. - New value or current value. Valid if this control is not of type
  129. ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is
  130. not set.
  131. * - __s64
  132. - ``value64``
  133. - New value or current value. Valid if this control is of type
  134. ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is
  135. not set.
  136. * - char *
  137. - ``string``
  138. - A pointer to a string. Valid if this control is of type
  139. ``V4L2_CTRL_TYPE_STRING``.
  140. * - __u8 *
  141. - ``p_u8``
  142. - A pointer to a matrix control of unsigned 8-bit values. Valid if
  143. this control is of type ``V4L2_CTRL_TYPE_U8``.
  144. * - __u16 *
  145. - ``p_u16``
  146. - A pointer to a matrix control of unsigned 16-bit values. Valid if
  147. this control is of type ``V4L2_CTRL_TYPE_U16``.
  148. * - __u32 *
  149. - ``p_u32``
  150. - A pointer to a matrix control of unsigned 32-bit values. Valid if
  151. this control is of type ``V4L2_CTRL_TYPE_U32``.
  152. * - __s32 *
  153. - ``p_s32``
  154. - A pointer to a matrix control of signed 32-bit values. Valid if
  155. this control is of type ``V4L2_CTRL_TYPE_INTEGER`` and
  156. ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set.
  157. * - __s64 *
  158. - ``p_s64``
  159. - A pointer to a matrix control of signed 64-bit values. Valid if
  160. this control is of type ``V4L2_CTRL_TYPE_INTEGER64`` and
  161. ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set.
  162. * - struct :c:type:`v4l2_area` *
  163. - ``p_area``
  164. - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is
  165. of type ``V4L2_CTRL_TYPE_AREA``.
  166. * - struct :c:type:`v4l2_rect` *
  167. - ``p_rect``
  168. - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is
  169. of type ``V4L2_CTRL_TYPE_RECT``.
  170. * - struct :c:type:`v4l2_ctrl_h264_sps` *
  171. - ``p_h264_sps``
  172. - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is
  173. of type ``V4L2_CTRL_TYPE_H264_SPS``.
  174. * - struct :c:type:`v4l2_ctrl_h264_pps` *
  175. - ``p_h264_pps``
  176. - A pointer to a struct :c:type:`v4l2_ctrl_h264_pps`. Valid if this control is
  177. of type ``V4L2_CTRL_TYPE_H264_PPS``.
  178. * - struct :c:type:`v4l2_ctrl_h264_scaling_matrix` *
  179. - ``p_h264_scaling_matrix``
  180. - A pointer to a struct :c:type:`v4l2_ctrl_h264_scaling_matrix`. Valid if this control is
  181. of type ``V4L2_CTRL_TYPE_H264_SCALING_MATRIX``.
  182. * - struct :c:type:`v4l2_ctrl_h264_pred_weights` *
  183. - ``p_h264_pred_weights``
  184. - A pointer to a struct :c:type:`v4l2_ctrl_h264_pred_weights`. Valid if this control is
  185. of type ``V4L2_CTRL_TYPE_H264_PRED_WEIGHTS``.
  186. * - struct :c:type:`v4l2_ctrl_h264_slice_params` *
  187. - ``p_h264_slice_params``
  188. - A pointer to a struct :c:type:`v4l2_ctrl_h264_slice_params`. Valid if this control is
  189. of type ``V4L2_CTRL_TYPE_H264_SLICE_PARAMS``.
  190. * - struct :c:type:`v4l2_ctrl_h264_decode_params` *
  191. - ``p_h264_decode_params``
  192. - A pointer to a struct :c:type:`v4l2_ctrl_h264_decode_params`. Valid if this control is
  193. of type ``V4L2_CTRL_TYPE_H264_DECODE_PARAMS``.
  194. * - struct :c:type:`v4l2_ctrl_fwht_params` *
  195. - ``p_fwht_params``
  196. - A pointer to a struct :c:type:`v4l2_ctrl_fwht_params`. Valid if this control is
  197. of type ``V4L2_CTRL_TYPE_FWHT_PARAMS``.
  198. * - struct :c:type:`v4l2_ctrl_vp8_frame` *
  199. - ``p_vp8_frame``
  200. - A pointer to a struct :c:type:`v4l2_ctrl_vp8_frame`. Valid if this control is
  201. of type ``V4L2_CTRL_TYPE_VP8_FRAME``.
  202. * - struct :c:type:`v4l2_ctrl_mpeg2_sequence` *
  203. - ``p_mpeg2_sequence``
  204. - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_sequence`. Valid if this control is
  205. of type ``V4L2_CTRL_TYPE_MPEG2_SEQUENCE``.
  206. * - struct :c:type:`v4l2_ctrl_mpeg2_picture` *
  207. - ``p_mpeg2_picture``
  208. - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_picture`. Valid if this control is
  209. of type ``V4L2_CTRL_TYPE_MPEG2_PICTURE``.
  210. * - struct :c:type:`v4l2_ctrl_mpeg2_quantisation` *
  211. - ``p_mpeg2_quantisation``
  212. - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_quantisation`. Valid if this control is
  213. of type ``V4L2_CTRL_TYPE_MPEG2_QUANTISATION``.
  214. * - struct :c:type:`v4l2_ctrl_vp9_compressed_hdr` *
  215. - ``p_vp9_compressed_hdr_probs``
  216. - A pointer to a struct :c:type:`v4l2_ctrl_vp9_compressed_hdr`. Valid if this
  217. control is of type ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR``.
  218. * - struct :c:type:`v4l2_ctrl_vp9_frame` *
  219. - ``p_vp9_frame``
  220. - A pointer to a struct :c:type:`v4l2_ctrl_vp9_frame`. Valid if this
  221. control is of type ``V4L2_CTRL_TYPE_VP9_FRAME``.
  222. * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` *
  223. - ``p_hdr10_cll``
  224. - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is
  225. of type ``V4L2_CTRL_TYPE_HDR10_CLL_INFO``.
  226. * - struct :c:type:`v4l2_ctrl_hdr10_mastering_display` *
  227. - ``p_hdr10_mastering``
  228. - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_mastering_display`. Valid if this control is
  229. of type ``V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY``.
  230. * - struct :c:type:`v4l2_ctrl_hevc_sps` *
  231. - ``p_hevc_sps``
  232. - A pointer to a struct :c:type:`v4l2_ctrl_hevc_sps`. Valid if this
  233. control is of type ``V4L2_CTRL_TYPE_HEVC_SPS``.
  234. * - struct :c:type:`v4l2_ctrl_hevc_pps` *
  235. - ``p_hevc_pps``
  236. - A pointer to a struct :c:type:`v4l2_ctrl_hevc_pps`. Valid if this
  237. control is of type ``V4L2_CTRL_TYPE_HEVC_PPS``.
  238. * - struct :c:type:`v4l2_ctrl_hevc_slice_params` *
  239. - ``p_hevc_slice_params``
  240. - A pointer to a struct :c:type:`v4l2_ctrl_hevc_slice_params`. Valid if this
  241. control is of type ``V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS``.
  242. * - struct :c:type:`v4l2_ctrl_hevc_scaling_matrix` *
  243. - ``p_hevc_scaling_matrix``
  244. - A pointer to a struct :c:type:`v4l2_ctrl_hevc_scaling_matrix`. Valid if this
  245. control is of type ``V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX``.
  246. * - struct :c:type:`v4l2_ctrl_hevc_decode_params` *
  247. - ``p_hevc_decode_params``
  248. - A pointer to a struct :c:type:`v4l2_ctrl_hevc_decode_params`. Valid if this
  249. control is of type ``V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS``.
  250. * - struct :c:type:`v4l2_ctrl_av1_sequence` *
  251. - ``p_av1_sequence``
  252. - A pointer to a struct :c:type:`v4l2_ctrl_av1_sequence`. Valid if this control is
  253. of type ``V4L2_CTRL_TYPE_AV1_SEQUENCE``.
  254. * - struct :c:type:`v4l2_ctrl_av1_tile_group_entry` *
  255. - ``p_av1_tile_group_entry``
  256. - A pointer to a struct :c:type:`v4l2_ctrl_av1_tile_group_entry`. Valid if this control is
  257. of type ``V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY``.
  258. * - struct :c:type:`v4l2_ctrl_av1_frame` *
  259. - ``p_av1_frame``
  260. - A pointer to a struct :c:type:`v4l2_ctrl_av1_frame`. Valid if this control is
  261. of type ``V4L2_CTRL_TYPE_AV1_FRAME``.
  262. * - struct :c:type:`v4l2_ctrl_av1_film_grain` *
  263. - ``p_av1_film_grain``
  264. - A pointer to a struct :c:type:`v4l2_ctrl_av1_film_grain`. Valid if this control is
  265. of type ``V4L2_CTRL_TYPE_AV1_FILM_GRAIN``.
  266. * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` *
  267. - ``p_hdr10_cll_info``
  268. - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is
  269. of type ``V4L2_CTRL_TYPE_HDR10_CLL_INFO``.
  270. * - struct :c:type:`v4l2_ctrl_hdr10_mastering_display` *
  271. - ``p_hdr10_mastering_display``
  272. - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_mastering_display`. Valid if this control is
  273. of type ``V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY``.
  274. * - void *
  275. - ``ptr``
  276. - A pointer to a compound type which can be an N-dimensional array
  277. and/or a compound type (the control's type is >=
  278. ``V4L2_CTRL_COMPOUND_TYPES``). Valid if
  279. ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set for this control.
  280. * - }
  281. -
  282. .. raw:: latex
  283. \normalsize
  284. .. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{10.8cm}|
  285. .. c:type:: v4l2_ext_controls
  286. .. cssclass:: longtable
  287. .. flat-table:: struct v4l2_ext_controls
  288. :header-rows: 0
  289. :stub-columns: 0
  290. :widths: 1 1 2
  291. * - union {
  292. - (anonymous)
  293. * - __u32
  294. - ``which``
  295. - Which value of the control to get/set/try.
  296. * - :cspan:`2` ``V4L2_CTRL_WHICH_CUR_VAL`` will return the current value of
  297. the control, ``V4L2_CTRL_WHICH_DEF_VAL`` will return the default
  298. value of the control, ``V4L2_CTRL_WHICH_MIN_VAL`` will return the minimum
  299. value of the control, and ``V4L2_CTRL_WHICH_MAX_VAL`` will return the maximum
  300. value of the control. ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that
  301. the control value has to be retrieved from a request or tried/set for
  302. a request. In that case the ``request_fd`` field contains the
  303. file descriptor of the request that should be used. If the device
  304. does not support requests, then ``EACCES`` will be returned.
  305. When using ``V4L2_CTRL_WHICH_DEF_VAL``, ``V4L2_CTRL_WHICH_MIN_VAL``
  306. or ``V4L2_CTRL_WHICH_MAX_VAL`` be aware that you can only get the
  307. default/minimum/maximum value of the control, you cannot set or try it.
  308. Whether a control supports querying the minimum and maximum values using
  309. ``V4L2_CTRL_WHICH_MIN_VAL`` and ``V4L2_CTRL_WHICH_MAX_VAL`` is indicated
  310. by the ``V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX`` flag. Most non-compound
  311. control types support this. For controls with compound types, the
  312. definition of minimum/maximum values are provided by
  313. the control documentation. If a compound control does not document the
  314. meaning of minimum/maximum value, then querying the minimum or maximum
  315. value will result in the error code -EINVAL.
  316. For backwards compatibility you can also use a control class here
  317. (see :ref:`ctrl-class`). In that case all controls have to
  318. belong to that control class. This usage is deprecated, instead
  319. just use ``V4L2_CTRL_WHICH_CUR_VAL``. There are some very old
  320. drivers that do not yet support ``V4L2_CTRL_WHICH_CUR_VAL`` and
  321. that require a control class here. You can test for such drivers
  322. by setting ``which`` to ``V4L2_CTRL_WHICH_CUR_VAL`` and calling
  323. :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` with a count of 0.
  324. If that fails, then the driver does not support ``V4L2_CTRL_WHICH_CUR_VAL``.
  325. * - __u32
  326. - ``ctrl_class``
  327. - Deprecated name kept for backwards compatibility. Use ``which`` instead.
  328. * - }
  329. -
  330. * - __u32
  331. - ``count``
  332. - The number of controls in the controls array. May also be zero.
  333. * - __u32
  334. - ``error_idx``
  335. - Index of the failing control. Set by the driver in case of an error.
  336. * - :cspan:`2` If the error is associated
  337. with a particular control, then ``error_idx`` is set to the index
  338. of that control. If the error is not related to a specific
  339. control, or the validation step failed (see below), then
  340. ``error_idx`` is set to ``count``. The value is undefined if the
  341. ioctl returned 0 (success).
  342. Before controls are read from/written to hardware a validation
  343. step takes place: this checks if all controls in the list are
  344. valid controls, if no attempt is made to write to a read-only
  345. control or read from a write-only control, and any other up-front
  346. checks that can be done without accessing the hardware. The exact
  347. validations done during this step are driver dependent since some
  348. checks might require hardware access for some devices, thus making
  349. it impossible to do those checks up-front. However, drivers should
  350. make a best-effort to do as many up-front checks as possible.
  351. This check is done to avoid leaving the hardware in an
  352. inconsistent state due to easy-to-avoid problems. But it leads to
  353. another problem: the application needs to know whether an error
  354. came from the validation step (meaning that the hardware was not
  355. touched) or from an error during the actual reading from/writing
  356. to hardware.
  357. The, in hindsight quite poor, solution for that is to set
  358. ``error_idx`` to ``count`` if the validation failed. This has the
  359. unfortunate side-effect that it is not possible to see which
  360. control failed the validation. If the validation was successful
  361. and the error happened while accessing the hardware, then
  362. ``error_idx`` is less than ``count`` and only the controls up to
  363. ``error_idx-1`` were read or written correctly, and the state of
  364. the remaining controls is undefined.
  365. Since :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` does not access hardware there is
  366. also no need to handle the validation step in this special way, so
  367. ``error_idx`` will just be set to the control that failed the
  368. validation step instead of to ``count``. This means that if
  369. :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` fails with ``error_idx`` set to ``count``,
  370. then you can call :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` to try to discover the
  371. actual control that failed the validation step. Unfortunately,
  372. there is no ``TRY`` equivalent for :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`.
  373. * - __s32
  374. - ``request_fd``
  375. - File descriptor of the request to be used by this operation. Only
  376. valid if ``which`` is set to ``V4L2_CTRL_WHICH_REQUEST_VAL``.
  377. If the device does not support requests, then ``EACCES`` will be returned.
  378. If requests are supported but an invalid request file descriptor is
  379. given, then ``EINVAL`` will be returned.
  380. * - __u32
  381. - ``reserved``\ [1]
  382. - Reserved for future extensions.
  383. Drivers and applications must set the array to zero.
  384. * - struct :c:type:`v4l2_ext_control` *
  385. - ``controls``
  386. - Pointer to an array of ``count`` v4l2_ext_control structures.
  387. Ignored if ``count`` equals zero.
  388. .. tabularcolumns:: |p{7.3cm}|p{2.0cm}|p{8.0cm}|
  389. .. cssclass:: longtable
  390. .. _ctrl-class:
  391. .. flat-table:: Control classes
  392. :header-rows: 0
  393. :stub-columns: 0
  394. :widths: 3 1 4
  395. * - ``V4L2_CTRL_CLASS_USER``
  396. - 0x980000
  397. - The class containing user controls. These controls are described
  398. in :ref:`control`. All controls that can be set using the
  399. :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` and
  400. :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl belong to this
  401. class.
  402. * - ``V4L2_CTRL_CLASS_CODEC``
  403. - 0x990000
  404. - The class containing stateful codec controls. These controls are
  405. described in :ref:`codec-controls`.
  406. * - ``V4L2_CTRL_CLASS_CAMERA``
  407. - 0x9a0000
  408. - The class containing camera controls. These controls are described
  409. in :ref:`camera-controls`.
  410. * - ``V4L2_CTRL_CLASS_FM_TX``
  411. - 0x9b0000
  412. - The class containing FM Transmitter (FM TX) controls. These
  413. controls are described in :ref:`fm-tx-controls`.
  414. * - ``V4L2_CTRL_CLASS_FLASH``
  415. - 0x9c0000
  416. - The class containing flash device controls. These controls are
  417. described in :ref:`flash-controls`.
  418. * - ``V4L2_CTRL_CLASS_JPEG``
  419. - 0x9d0000
  420. - The class containing JPEG compression controls. These controls are
  421. described in :ref:`jpeg-controls`.
  422. * - ``V4L2_CTRL_CLASS_IMAGE_SOURCE``
  423. - 0x9e0000
  424. - The class containing image source controls. These controls are
  425. described in :ref:`image-source-controls`.
  426. * - ``V4L2_CTRL_CLASS_IMAGE_PROC``
  427. - 0x9f0000
  428. - The class containing image processing controls. These controls are
  429. described in :ref:`image-process-controls`.
  430. * - ``V4L2_CTRL_CLASS_FM_RX``
  431. - 0xa10000
  432. - The class containing FM Receiver (FM RX) controls. These controls
  433. are described in :ref:`fm-rx-controls`.
  434. * - ``V4L2_CTRL_CLASS_RF_TUNER``
  435. - 0xa20000
  436. - The class containing RF tuner controls. These controls are
  437. described in :ref:`rf-tuner-controls`.
  438. * - ``V4L2_CTRL_CLASS_DETECT``
  439. - 0xa30000
  440. - The class containing motion or object detection controls. These controls
  441. are described in :ref:`detect-controls`.
  442. * - ``V4L2_CTRL_CLASS_CODEC_STATELESS``
  443. - 0xa40000
  444. - The class containing stateless codec controls. These controls are
  445. described in :ref:`codec-stateless-controls`.
  446. * - ``V4L2_CTRL_CLASS_COLORIMETRY``
  447. - 0xa50000
  448. - The class containing colorimetry controls. These controls are
  449. described in :ref:`colorimetry-controls`.
  450. Return Value
  451. ============
  452. On success 0 is returned, on error -1 and the ``errno`` variable is set
  453. appropriately. The generic error codes are described at the
  454. :ref:`Generic Error Codes <gen-errors>` chapter.
  455. EINVAL
  456. The struct :c:type:`v4l2_ext_control` ``id`` is
  457. invalid, or the struct :c:type:`v4l2_ext_controls`
  458. ``which`` is invalid, or the struct
  459. :c:type:`v4l2_ext_control` ``value`` was
  460. inappropriate (e.g. the given menu index is not supported by the
  461. driver), or the ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL``
  462. but the given ``request_fd`` was invalid or ``V4L2_CTRL_WHICH_REQUEST_VAL``
  463. is not supported by the kernel.
  464. This error code is also returned by the
  465. :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` and :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctls if two or
  466. more control values are in conflict.
  467. ERANGE
  468. The struct :c:type:`v4l2_ext_control` ``value``
  469. is out of bounds.
  470. EBUSY
  471. The control is temporarily not changeable, possibly because another
  472. applications took over control of the device function this control
  473. belongs to, or (if the ``which`` field was set to
  474. ``V4L2_CTRL_WHICH_REQUEST_VAL``) the request was queued but not yet
  475. completed.
  476. ENOSPC
  477. The space reserved for the control's payload is insufficient. The
  478. field ``size`` is set to a value that is enough to store the payload
  479. and this error code is returned.
  480. EACCES
  481. Attempt to try or set a read-only control, or to get a write-only
  482. control, or to get a control from a request that has not yet been
  483. completed.
  484. Or the ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL`` but the
  485. device does not support requests.
  486. Or if there is an attempt to set an inactive control and the driver is
  487. not capable of caching the new value until the control is active again.