1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L 354f38fcaSMauro Carvalho Chehab 454f38fcaSMauro Carvalho Chehab.. _VIDIOC_G_EXT_CTRLS: 554f38fcaSMauro Carvalho Chehab 654f38fcaSMauro Carvalho Chehab****************************************************************** 754f38fcaSMauro Carvalho Chehabioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS 854f38fcaSMauro Carvalho Chehab****************************************************************** 954f38fcaSMauro Carvalho Chehab 1054f38fcaSMauro Carvalho ChehabName 1154f38fcaSMauro Carvalho Chehab==== 1254f38fcaSMauro Carvalho Chehab 1354f38fcaSMauro Carvalho ChehabVIDIOC_G_EXT_CTRLS - VIDIOC_S_EXT_CTRLS - VIDIOC_TRY_EXT_CTRLS - Get or set the value of several controls, try control values 1454f38fcaSMauro Carvalho Chehab 1554f38fcaSMauro Carvalho ChehabSynopsis 1654f38fcaSMauro Carvalho Chehab======== 1754f38fcaSMauro Carvalho Chehab 18407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_G_EXT_CTRLS 1954f38fcaSMauro Carvalho Chehab 20407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_G_EXT_CTRLS, struct v4l2_ext_controls *argp)`` 2154f38fcaSMauro Carvalho Chehab 22407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_S_EXT_CTRLS 2354f38fcaSMauro Carvalho Chehab 24407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_S_EXT_CTRLS, struct v4l2_ext_controls *argp)`` 2554f38fcaSMauro Carvalho Chehab 26407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_TRY_EXT_CTRLS 2754f38fcaSMauro Carvalho Chehab 28407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_TRY_EXT_CTRLS, struct v4l2_ext_controls *argp)`` 2954f38fcaSMauro Carvalho Chehab 3054f38fcaSMauro Carvalho ChehabArguments 3154f38fcaSMauro Carvalho Chehab========= 3254f38fcaSMauro Carvalho Chehab 3354f38fcaSMauro Carvalho Chehab``fd`` 34407e84cdSMauro Carvalho Chehab File descriptor returned by :c:func:`open()`. 3554f38fcaSMauro Carvalho Chehab 3654f38fcaSMauro Carvalho Chehab``argp`` 3754f38fcaSMauro Carvalho Chehab Pointer to struct :c:type:`v4l2_ext_controls`. 3854f38fcaSMauro Carvalho Chehab 3954f38fcaSMauro Carvalho ChehabDescription 4054f38fcaSMauro Carvalho Chehab=========== 4154f38fcaSMauro Carvalho Chehab 4254f38fcaSMauro Carvalho ChehabThese ioctls allow the caller to get or set multiple controls 4354f38fcaSMauro Carvalho Chehabatomically. Control IDs are grouped into control classes (see 4454f38fcaSMauro Carvalho Chehab:ref:`ctrl-class`) and all controls in the control array must belong 4554f38fcaSMauro Carvalho Chehabto the same control class. 4654f38fcaSMauro Carvalho Chehab 4754f38fcaSMauro Carvalho ChehabApplications must always fill in the ``count``, ``which``, ``controls`` 4854f38fcaSMauro Carvalho Chehaband ``reserved`` fields of struct 4954f38fcaSMauro Carvalho Chehab:c:type:`v4l2_ext_controls`, and initialize the 5054f38fcaSMauro Carvalho Chehabstruct :c:type:`v4l2_ext_control` array pointed to 5154f38fcaSMauro Carvalho Chehabby the ``controls`` fields. 5254f38fcaSMauro Carvalho Chehab 5354f38fcaSMauro Carvalho ChehabTo get the current value of a set of controls applications initialize 5454f38fcaSMauro Carvalho Chehabthe ``id``, ``size`` and ``reserved2`` fields of each struct 5554f38fcaSMauro Carvalho Chehab:c:type:`v4l2_ext_control` and call the 56c5c91a1dSRandy Dunlap:ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. String controls must also set the 5754f38fcaSMauro Carvalho Chehab``string`` field. Controls of compound types 5854f38fcaSMauro Carvalho Chehab(``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set) must set the ``ptr`` field. 5954f38fcaSMauro Carvalho Chehab 6054f38fcaSMauro Carvalho ChehabIf the ``size`` is too small to receive the control result (only 6154f38fcaSMauro Carvalho Chehabrelevant for pointer-type controls like strings), then the driver will 6254f38fcaSMauro Carvalho Chehabset ``size`` to a valid value and return an ``ENOSPC`` error code. You 6354f38fcaSMauro Carvalho Chehabshould re-allocate the memory to this new size and try again. For the 6454f38fcaSMauro Carvalho Chehabstring type it is possible that the same issue occurs again if the 6554f38fcaSMauro Carvalho Chehabstring has grown in the meantime. It is recommended to call 6654f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_QUERYCTRL` first and use 6754f38fcaSMauro Carvalho Chehab``maximum``\ +1 as the new ``size`` value. It is guaranteed that that is 6854f38fcaSMauro Carvalho Chehabsufficient memory. 6954f38fcaSMauro Carvalho Chehab 7054f38fcaSMauro Carvalho ChehabN-dimensional arrays are set and retrieved row-by-row. You cannot set a 7154f38fcaSMauro Carvalho Chehabpartial array, all elements have to be set or retrieved. The total size 7254f38fcaSMauro Carvalho Chehabis calculated as ``elems`` * ``elem_size``. These values can be obtained 7354f38fcaSMauro Carvalho Chehabby calling :ref:`VIDIOC_QUERY_EXT_CTRL <VIDIOC_QUERYCTRL>`. 7454f38fcaSMauro Carvalho Chehab 7554f38fcaSMauro Carvalho ChehabTo change the value of a set of controls applications initialize the 7654f38fcaSMauro Carvalho Chehab``id``, ``size``, ``reserved2`` and ``value/value64/string/ptr`` fields 7754f38fcaSMauro Carvalho Chehabof each struct :c:type:`v4l2_ext_control` and call 7854f38fcaSMauro Carvalho Chehabthe :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. The controls will only be set if *all* 7954f38fcaSMauro Carvalho Chehabcontrol values are valid. 8054f38fcaSMauro Carvalho Chehab 8154f38fcaSMauro Carvalho ChehabTo check if a set of controls have correct values applications 8254f38fcaSMauro Carvalho Chehabinitialize the ``id``, ``size``, ``reserved2`` and 8354f38fcaSMauro Carvalho Chehab``value/value64/string/ptr`` fields of each struct 8454f38fcaSMauro Carvalho Chehab:c:type:`v4l2_ext_control` and call the 8554f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctl. It is up to the driver whether wrong 8654f38fcaSMauro Carvalho Chehabvalues are automatically adjusted to a valid value or if an error is 8754f38fcaSMauro Carvalho Chehabreturned. 8854f38fcaSMauro Carvalho Chehab 8954f38fcaSMauro Carvalho ChehabWhen the ``id`` or ``which`` is invalid drivers return an ``EINVAL`` error 9054f38fcaSMauro Carvalho Chehabcode. When the value is out of bounds drivers can choose to take the 9154f38fcaSMauro Carvalho Chehabclosest valid value or return an ``ERANGE`` error code, whatever seems more 9254f38fcaSMauro Carvalho Chehabappropriate. In the first case the new value is set in struct 9354f38fcaSMauro Carvalho Chehab:c:type:`v4l2_ext_control`. If the new control value 9454f38fcaSMauro Carvalho Chehabis inappropriate (e.g. the given menu index is not supported by the menu 9554f38fcaSMauro Carvalho Chehabcontrol), then this will also result in an ``EINVAL`` error code error. 9654f38fcaSMauro Carvalho Chehab 9754f38fcaSMauro Carvalho ChehabIf ``request_fd`` is set to a not-yet-queued :ref:`request <media-request-api>` 9854f38fcaSMauro Carvalho Chehabfile descriptor and ``which`` is set to ``V4L2_CTRL_WHICH_REQUEST_VAL``, 9954f38fcaSMauro Carvalho Chehabthen the controls are not applied immediately when calling 10054f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, but instead are applied by 10154f38fcaSMauro Carvalho Chehabthe driver for the buffer associated with the same request. 10254f38fcaSMauro Carvalho ChehabIf the device does not support requests, then ``EACCES`` will be returned. 10354f38fcaSMauro Carvalho ChehabIf requests are supported but an invalid request file descriptor is given, 10454f38fcaSMauro Carvalho Chehabthen ``EINVAL`` will be returned. 10554f38fcaSMauro Carvalho Chehab 10654f38fcaSMauro Carvalho ChehabAn attempt to call :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` for a 10754f38fcaSMauro Carvalho Chehabrequest that has already been queued will result in an ``EBUSY`` error. 10854f38fcaSMauro Carvalho Chehab 10954f38fcaSMauro Carvalho ChehabIf ``request_fd`` is specified and ``which`` is set to 11054f38fcaSMauro Carvalho Chehab``V4L2_CTRL_WHICH_REQUEST_VAL`` during a call to 11154f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then it will return the 11254f38fcaSMauro Carvalho Chehabvalues of the controls at the time of request completion. 11354f38fcaSMauro Carvalho ChehabIf the request is not yet completed, then this will result in an 11454f38fcaSMauro Carvalho Chehab``EACCES`` error. 11554f38fcaSMauro Carvalho Chehab 11654f38fcaSMauro Carvalho ChehabThe driver will only set/get these controls if all control values are 11754f38fcaSMauro Carvalho Chehabcorrect. This prevents the situation where only some of the controls 11854f38fcaSMauro Carvalho Chehabwere set/get. Only low-level errors (e. g. a failed i2c command) can 11954f38fcaSMauro Carvalho Chehabstill cause this situation. 12054f38fcaSMauro Carvalho Chehab 121fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{6.8cm}|p{4.0cm}|p{6.5cm}| 12254f38fcaSMauro Carvalho Chehab 12354f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_ext_control 12454f38fcaSMauro Carvalho Chehab 125fea13a69SMauro Carvalho Chehab.. raw:: latex 126fea13a69SMauro Carvalho Chehab 127fea13a69SMauro Carvalho Chehab \footnotesize 128fea13a69SMauro Carvalho Chehab 129fea13a69SMauro Carvalho Chehab.. cssclass:: longtable 13054f38fcaSMauro Carvalho Chehab 13154f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_ext_control 13254f38fcaSMauro Carvalho Chehab :header-rows: 0 13354f38fcaSMauro Carvalho Chehab :stub-columns: 0 13454f38fcaSMauro Carvalho Chehab :widths: 1 1 2 13554f38fcaSMauro Carvalho Chehab 13654f38fcaSMauro Carvalho Chehab * - __u32 13754f38fcaSMauro Carvalho Chehab - ``id`` 13854f38fcaSMauro Carvalho Chehab - Identifies the control, set by the application. 13954f38fcaSMauro Carvalho Chehab * - __u32 14054f38fcaSMauro Carvalho Chehab - ``size`` 141a611be75SHans Verkuil - The total size in bytes of the payload of this control. 142a611be75SHans Verkuil * - :cspan:`2` The ``size`` field is normally 0, but for pointer 143a611be75SHans Verkuil controls this should be set to the size of the memory that contains 144a611be75SHans Verkuil the payload or that will receive the payload. 145a611be75SHans Verkuil If :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` finds that this value 146a611be75SHans Verkuil is less than is required to store the payload result, then it is set 14754f38fcaSMauro Carvalho Chehab to a value large enough to store the payload result and ``ENOSPC`` is 14854f38fcaSMauro Carvalho Chehab returned. 14954f38fcaSMauro Carvalho Chehab 15054f38fcaSMauro Carvalho Chehab .. note:: 15154f38fcaSMauro Carvalho Chehab 15254f38fcaSMauro Carvalho Chehab For string controls, this ``size`` field should 15354f38fcaSMauro Carvalho Chehab not be confused with the length of the string. This field refers 15454f38fcaSMauro Carvalho Chehab to the size of the memory that contains the string. The actual 15554f38fcaSMauro Carvalho Chehab *length* of the string may well be much smaller. 15654f38fcaSMauro Carvalho Chehab * - __u32 15754f38fcaSMauro Carvalho Chehab - ``reserved2``\ [1] 15854f38fcaSMauro Carvalho Chehab - Reserved for future extensions. Drivers and applications must set 15954f38fcaSMauro Carvalho Chehab the array to zero. 16054f38fcaSMauro Carvalho Chehab * - union { 16154f38fcaSMauro Carvalho Chehab - (anonymous) 16254f38fcaSMauro Carvalho Chehab * - __s32 16354f38fcaSMauro Carvalho Chehab - ``value`` 16454f38fcaSMauro Carvalho Chehab - New value or current value. Valid if this control is not of type 16554f38fcaSMauro Carvalho Chehab ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is 16654f38fcaSMauro Carvalho Chehab not set. 16754f38fcaSMauro Carvalho Chehab * - __s64 16854f38fcaSMauro Carvalho Chehab - ``value64`` 16954f38fcaSMauro Carvalho Chehab - New value or current value. Valid if this control is of type 17054f38fcaSMauro Carvalho Chehab ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is 17154f38fcaSMauro Carvalho Chehab not set. 17254f38fcaSMauro Carvalho Chehab * - char * 17354f38fcaSMauro Carvalho Chehab - ``string`` 17454f38fcaSMauro Carvalho Chehab - A pointer to a string. Valid if this control is of type 17554f38fcaSMauro Carvalho Chehab ``V4L2_CTRL_TYPE_STRING``. 17654f38fcaSMauro Carvalho Chehab * - __u8 * 17754f38fcaSMauro Carvalho Chehab - ``p_u8`` 17854f38fcaSMauro Carvalho Chehab - A pointer to a matrix control of unsigned 8-bit values. Valid if 17954f38fcaSMauro Carvalho Chehab this control is of type ``V4L2_CTRL_TYPE_U8``. 18054f38fcaSMauro Carvalho Chehab * - __u16 * 18154f38fcaSMauro Carvalho Chehab - ``p_u16`` 18254f38fcaSMauro Carvalho Chehab - A pointer to a matrix control of unsigned 16-bit values. Valid if 18354f38fcaSMauro Carvalho Chehab this control is of type ``V4L2_CTRL_TYPE_U16``. 18454f38fcaSMauro Carvalho Chehab * - __u32 * 18554f38fcaSMauro Carvalho Chehab - ``p_u32`` 18654f38fcaSMauro Carvalho Chehab - A pointer to a matrix control of unsigned 32-bit values. Valid if 18754f38fcaSMauro Carvalho Chehab this control is of type ``V4L2_CTRL_TYPE_U32``. 188*5a84798eSDaniel Lundberg Pedersen * - __s32 * 189*5a84798eSDaniel Lundberg Pedersen - ``p_s32`` 190*5a84798eSDaniel Lundberg Pedersen - A pointer to a matrix control of signed 32-bit values. Valid if 191*5a84798eSDaniel Lundberg Pedersen this control is of type ``V4L2_CTRL_TYPE_INTEGER`` and 192*5a84798eSDaniel Lundberg Pedersen ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set. 193*5a84798eSDaniel Lundberg Pedersen * - __s64 * 194*5a84798eSDaniel Lundberg Pedersen - ``p_s64`` 195*5a84798eSDaniel Lundberg Pedersen - A pointer to a matrix control of signed 64-bit values. Valid if 196*5a84798eSDaniel Lundberg Pedersen this control is of type ``V4L2_CTRL_TYPE_INTEGER64`` and 197*5a84798eSDaniel Lundberg Pedersen ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set. 19863e799b9SHans Verkuil * - struct :c:type:`v4l2_area` * 19954f38fcaSMauro Carvalho Chehab - ``p_area`` 20054f38fcaSMauro Carvalho Chehab - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is 20154f38fcaSMauro Carvalho Chehab of type ``V4L2_CTRL_TYPE_AREA``. 20263e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_sps` * 20381c6892dSEzequiel Garcia - ``p_h264_sps`` 20481c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is 20581c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_SPS``. 20663e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_pps` * 20781c6892dSEzequiel Garcia - ``p_h264_pps`` 20881c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_pps`. Valid if this control is 20981c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_PPS``. 21063e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_scaling_matrix` * 21181c6892dSEzequiel Garcia - ``p_h264_scaling_matrix`` 21281c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_scaling_matrix`. Valid if this control is 21381c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_SCALING_MATRIX``. 21463e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_pred_weights` * 21581c6892dSEzequiel Garcia - ``p_h264_pred_weights`` 21681c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_pred_weights`. Valid if this control is 21781c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_PRED_WEIGHTS``. 21863e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_slice_params` * 21981c6892dSEzequiel Garcia - ``p_h264_slice_params`` 22081c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_slice_params`. Valid if this control is 22181c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_SLICE_PARAMS``. 22263e799b9SHans Verkuil * - struct :c:type:`v4l2_ctrl_h264_decode_params` * 22381c6892dSEzequiel Garcia - ``p_h264_decode_params`` 22481c6892dSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_h264_decode_params`. Valid if this control is 22581c6892dSEzequiel Garcia of type ``V4L2_CTRL_TYPE_H264_DECODE_PARAMS``. 2264a85d1cbSHans Verkuil * - struct :c:type:`v4l2_ctrl_fwht_params` * 2274a85d1cbSHans Verkuil - ``p_fwht_params`` 2284a85d1cbSHans Verkuil - A pointer to a struct :c:type:`v4l2_ctrl_fwht_params`. Valid if this control is 2294a85d1cbSHans Verkuil of type ``V4L2_CTRL_TYPE_FWHT_PARAMS``. 230363240ceSEzequiel Garcia * - struct :c:type:`v4l2_ctrl_vp8_frame` * 231363240ceSEzequiel Garcia - ``p_vp8_frame`` 232363240ceSEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_vp8_frame`. Valid if this control is 233363240ceSEzequiel Garcia of type ``V4L2_CTRL_TYPE_VP8_FRAME``. 234f4815b39SEzequiel Garcia * - struct :c:type:`v4l2_ctrl_mpeg2_sequence` * 235f4815b39SEzequiel Garcia - ``p_mpeg2_sequence`` 236f4815b39SEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_sequence`. Valid if this control is 237f4815b39SEzequiel Garcia of type ``V4L2_CTRL_TYPE_MPEG2_SEQUENCE``. 238f4815b39SEzequiel Garcia * - struct :c:type:`v4l2_ctrl_mpeg2_picture` * 239f4815b39SEzequiel Garcia - ``p_mpeg2_picture`` 240f4815b39SEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_picture`. Valid if this control is 241f4815b39SEzequiel Garcia of type ``V4L2_CTRL_TYPE_MPEG2_PICTURE``. 242f4815b39SEzequiel Garcia * - struct :c:type:`v4l2_ctrl_mpeg2_quantisation` * 243f4815b39SEzequiel Garcia - ``p_mpeg2_quantisation`` 244f4815b39SEzequiel Garcia - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_quantisation`. Valid if this control is 245f4815b39SEzequiel Garcia of type ``V4L2_CTRL_TYPE_MPEG2_QUANTISATION``. 246b88dbe38SAndrzej Pietrasiewicz * - struct :c:type:`v4l2_ctrl_vp9_compressed_hdr` * 247b88dbe38SAndrzej Pietrasiewicz - ``p_vp9_compressed_hdr_probs`` 248b88dbe38SAndrzej Pietrasiewicz - A pointer to a struct :c:type:`v4l2_ctrl_vp9_compressed_hdr`. Valid if this 249b88dbe38SAndrzej Pietrasiewicz control is of type ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR``. 250b88dbe38SAndrzej Pietrasiewicz * - struct :c:type:`v4l2_ctrl_vp9_frame` * 251b88dbe38SAndrzej Pietrasiewicz - ``p_vp9_frame`` 252b88dbe38SAndrzej Pietrasiewicz - A pointer to a struct :c:type:`v4l2_ctrl_vp9_frame`. Valid if this 253b88dbe38SAndrzej Pietrasiewicz control is of type ``V4L2_CTRL_TYPE_VP9_FRAME``. 2545f8beb7dSStanimir Varbanov * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` * 2555f8beb7dSStanimir Varbanov - ``p_hdr10_cll`` 2565f8beb7dSStanimir Varbanov - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is 2575f8beb7dSStanimir Varbanov of type ``V4L2_CTRL_TYPE_HDR10_CLL_INFO``. 2585f8beb7dSStanimir Varbanov * - struct :c:type:`v4l2_ctrl_hdr10_mastering_display` * 2595f8beb7dSStanimir Varbanov - ``p_hdr10_mastering`` 2605f8beb7dSStanimir Varbanov - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_mastering_display`. Valid if this control is 2615f8beb7dSStanimir Varbanov of type ``V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY``. 262ca24fef0SBenjamin Gaignard * - struct :c:type:`v4l2_ctrl_hevc_sps` * 263ca24fef0SBenjamin Gaignard - ``p_hevc_sps`` 264ca24fef0SBenjamin Gaignard - A pointer to a struct :c:type:`v4l2_ctrl_hevc_sps`. Valid if this 265ca24fef0SBenjamin Gaignard control is of type ``V4L2_CTRL_TYPE_HEVC_SPS``. 266ca24fef0SBenjamin Gaignard * - struct :c:type:`v4l2_ctrl_hevc_pps` * 267ca24fef0SBenjamin Gaignard - ``p_hevc_pps`` 268ca24fef0SBenjamin Gaignard - A pointer to a struct :c:type:`v4l2_ctrl_hevc_pps`. Valid if this 269ca24fef0SBenjamin Gaignard control is of type ``V4L2_CTRL_TYPE_HEVC_PPS``. 270ca24fef0SBenjamin Gaignard * - struct :c:type:`v4l2_ctrl_hevc_slice_params` * 271ca24fef0SBenjamin Gaignard - ``p_hevc_slice_params`` 272ca24fef0SBenjamin Gaignard - A pointer to a struct :c:type:`v4l2_ctrl_hevc_slice_params`. Valid if this 273ca24fef0SBenjamin Gaignard control is of type ``V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS``. 274ca24fef0SBenjamin Gaignard * - struct :c:type:`v4l2_ctrl_hevc_scaling_matrix` * 275ca24fef0SBenjamin Gaignard - ``p_hevc_scaling_matrix`` 276ca24fef0SBenjamin Gaignard - A pointer to a struct :c:type:`v4l2_ctrl_hevc_scaling_matrix`. Valid if this 277ca24fef0SBenjamin Gaignard control is of type ``V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX``. 278ca24fef0SBenjamin Gaignard * - struct :c:type:`v4l2_ctrl_hevc_decode_params` * 279ca24fef0SBenjamin Gaignard - ``p_hevc_decode_params`` 280ca24fef0SBenjamin Gaignard - A pointer to a struct :c:type:`v4l2_ctrl_hevc_decode_params`. Valid if this 281ca24fef0SBenjamin Gaignard control is of type ``V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS``. 28254f38fcaSMauro Carvalho Chehab * - struct :c:type:`v4l2_ctrl_av1_sequence` * 28354f38fcaSMauro Carvalho Chehab - ``p_av1_sequence`` 28454f38fcaSMauro Carvalho Chehab - A pointer to a struct :c:type:`v4l2_ctrl_av1_sequence`. Valid if this control is 28554f38fcaSMauro Carvalho Chehab of type ``V4L2_CTRL_TYPE_AV1_SEQUENCE``. 28654f38fcaSMauro Carvalho Chehab * - struct :c:type:`v4l2_ctrl_av1_tile_group_entry` * 28754f38fcaSMauro Carvalho Chehab - ``p_av1_tile_group_entry`` 28854f38fcaSMauro Carvalho Chehab - A pointer to a struct :c:type:`v4l2_ctrl_av1_tile_group_entry`. Valid if this control is 28954f38fcaSMauro Carvalho Chehab of type ``V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY``. 29054f38fcaSMauro Carvalho Chehab * - struct :c:type:`v4l2_ctrl_av1_frame` * 291fea13a69SMauro Carvalho Chehab - ``p_av1_frame`` 292fea13a69SMauro Carvalho Chehab - A pointer to a struct :c:type:`v4l2_ctrl_av1_frame`. Valid if this control is 293fea13a69SMauro Carvalho Chehab of type ``V4L2_CTRL_TYPE_AV1_FRAME``. 294fea13a69SMauro Carvalho Chehab * - struct :c:type:`v4l2_ctrl_av1_film_grain` * 295fea13a69SMauro Carvalho Chehab - ``p_av1_film_grain`` 29654f38fcaSMauro Carvalho Chehab - A pointer to a struct :c:type:`v4l2_ctrl_av1_film_grain`. Valid if this control is 29754f38fcaSMauro Carvalho Chehab of type ``V4L2_CTRL_TYPE_AV1_FILM_GRAIN``. 29854f38fcaSMauro Carvalho Chehab * - void * 29954f38fcaSMauro Carvalho Chehab - ``ptr`` 30054f38fcaSMauro Carvalho Chehab - A pointer to a compound type which can be an N-dimensional array 30154f38fcaSMauro Carvalho Chehab and/or a compound type (the control's type is >= 30254f38fcaSMauro Carvalho Chehab ``V4L2_CTRL_COMPOUND_TYPES``). Valid if 30354f38fcaSMauro Carvalho Chehab ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set for this control. 30454f38fcaSMauro Carvalho Chehab * - } 30554f38fcaSMauro Carvalho Chehab - 30654f38fcaSMauro Carvalho Chehab 30754f38fcaSMauro Carvalho Chehab.. raw:: latex 30854f38fcaSMauro Carvalho Chehab 30954f38fcaSMauro Carvalho Chehab \normalsize 31054f38fcaSMauro Carvalho Chehab 311a611be75SHans Verkuil.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{10.8cm}| 312a611be75SHans Verkuil 31354f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_ext_controls 31454f38fcaSMauro Carvalho Chehab 31554f38fcaSMauro Carvalho Chehab.. cssclass:: longtable 31654f38fcaSMauro Carvalho Chehab 31754f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_ext_controls 31854f38fcaSMauro Carvalho Chehab :header-rows: 0 31954f38fcaSMauro Carvalho Chehab :stub-columns: 0 32054f38fcaSMauro Carvalho Chehab :widths: 1 1 2 32154f38fcaSMauro Carvalho Chehab 32254f38fcaSMauro Carvalho Chehab * - union { 32354f38fcaSMauro Carvalho Chehab - (anonymous) 32454f38fcaSMauro Carvalho Chehab * - __u32 32554f38fcaSMauro Carvalho Chehab - ``which`` 32654f38fcaSMauro Carvalho Chehab - Which value of the control to get/set/try. 32754f38fcaSMauro Carvalho Chehab * - :cspan:`2` ``V4L2_CTRL_WHICH_CUR_VAL`` will return the current value of 328a611be75SHans Verkuil the control, ``V4L2_CTRL_WHICH_DEF_VAL`` will return the default 329a611be75SHans Verkuil value of the control and ``V4L2_CTRL_WHICH_REQUEST_VAL`` indicates that 330a611be75SHans Verkuil these controls have to be retrieved from a request or tried/set for 331a611be75SHans Verkuil a request. In the latter case the ``request_fd`` field contains the 332a611be75SHans Verkuil file descriptor of the request that should be used. If the device 333a611be75SHans Verkuil does not support requests, then ``EACCES`` will be returned. 33454f38fcaSMauro Carvalho Chehab 33554f38fcaSMauro Carvalho Chehab When using ``V4L2_CTRL_WHICH_DEF_VAL`` be aware that you can only 33654f38fcaSMauro Carvalho Chehab get the default value of the control, you cannot set or try it. 33754f38fcaSMauro Carvalho Chehab 33854f38fcaSMauro Carvalho Chehab For backwards compatibility you can also use a control class here 33954f38fcaSMauro Carvalho Chehab (see :ref:`ctrl-class`). In that case all controls have to 34054f38fcaSMauro Carvalho Chehab belong to that control class. This usage is deprecated, instead 341a611be75SHans Verkuil just use ``V4L2_CTRL_WHICH_CUR_VAL``. There are some very old 342a611be75SHans Verkuil drivers that do not yet support ``V4L2_CTRL_WHICH_CUR_VAL`` and 34354f38fcaSMauro Carvalho Chehab that require a control class here. You can test for such drivers 34454f38fcaSMauro Carvalho Chehab by setting ``which`` to ``V4L2_CTRL_WHICH_CUR_VAL`` and calling 34554f38fcaSMauro Carvalho Chehab :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` with a count of 0. 34654f38fcaSMauro Carvalho Chehab If that fails, then the driver does not support ``V4L2_CTRL_WHICH_CUR_VAL``. 34754f38fcaSMauro Carvalho Chehab * - __u32 34854f38fcaSMauro Carvalho Chehab - ``ctrl_class`` 34954f38fcaSMauro Carvalho Chehab - Deprecated name kept for backwards compatibility. Use ``which`` instead. 35054f38fcaSMauro Carvalho Chehab * - } 35154f38fcaSMauro Carvalho Chehab - 35254f38fcaSMauro Carvalho Chehab * - __u32 35354f38fcaSMauro Carvalho Chehab - ``count`` 35454f38fcaSMauro Carvalho Chehab - The number of controls in the controls array. May also be zero. 35554f38fcaSMauro Carvalho Chehab * - __u32 35654f38fcaSMauro Carvalho Chehab - ``error_idx`` 35754f38fcaSMauro Carvalho Chehab - Index of the failing control. Set by the driver in case of an error. 35854f38fcaSMauro Carvalho Chehab * - :cspan:`2` If the error is associated 35954f38fcaSMauro Carvalho Chehab with a particular control, then ``error_idx`` is set to the index 36054f38fcaSMauro Carvalho Chehab of that control. If the error is not related to a specific 36154f38fcaSMauro Carvalho Chehab control, or the validation step failed (see below), then 36254f38fcaSMauro Carvalho Chehab ``error_idx`` is set to ``count``. The value is undefined if the 36354f38fcaSMauro Carvalho Chehab ioctl returned 0 (success). 36454f38fcaSMauro Carvalho Chehab 36554f38fcaSMauro Carvalho Chehab Before controls are read from/written to hardware a validation 36654f38fcaSMauro Carvalho Chehab step takes place: this checks if all controls in the list are 36754f38fcaSMauro Carvalho Chehab valid controls, if no attempt is made to write to a read-only 36854f38fcaSMauro Carvalho Chehab control or read from a write-only control, and any other up-front 36954f38fcaSMauro Carvalho Chehab checks that can be done without accessing the hardware. The exact 37054f38fcaSMauro Carvalho Chehab validations done during this step are driver dependent since some 37154f38fcaSMauro Carvalho Chehab checks might require hardware access for some devices, thus making 37254f38fcaSMauro Carvalho Chehab it impossible to do those checks up-front. However, drivers should 37354f38fcaSMauro Carvalho Chehab make a best-effort to do as many up-front checks as possible. 37454f38fcaSMauro Carvalho Chehab 37554f38fcaSMauro Carvalho Chehab This check is done to avoid leaving the hardware in an 37654f38fcaSMauro Carvalho Chehab inconsistent state due to easy-to-avoid problems. But it leads to 37754f38fcaSMauro Carvalho Chehab another problem: the application needs to know whether an error 37854f38fcaSMauro Carvalho Chehab came from the validation step (meaning that the hardware was not 37954f38fcaSMauro Carvalho Chehab touched) or from an error during the actual reading from/writing 38054f38fcaSMauro Carvalho Chehab to hardware. 38154f38fcaSMauro Carvalho Chehab 38254f38fcaSMauro Carvalho Chehab The, in hindsight quite poor, solution for that is to set 38354f38fcaSMauro Carvalho Chehab ``error_idx`` to ``count`` if the validation failed. This has the 38454f38fcaSMauro Carvalho Chehab unfortunate side-effect that it is not possible to see which 38554f38fcaSMauro Carvalho Chehab control failed the validation. If the validation was successful 38654f38fcaSMauro Carvalho Chehab and the error happened while accessing the hardware, then 38754f38fcaSMauro Carvalho Chehab ``error_idx`` is less than ``count`` and only the controls up to 38854f38fcaSMauro Carvalho Chehab ``error_idx-1`` were read or written correctly, and the state of 38954f38fcaSMauro Carvalho Chehab the remaining controls is undefined. 39054f38fcaSMauro Carvalho Chehab 39154f38fcaSMauro Carvalho Chehab Since :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` does not access hardware there is 39254f38fcaSMauro Carvalho Chehab also no need to handle the validation step in this special way, so 39354f38fcaSMauro Carvalho Chehab ``error_idx`` will just be set to the control that failed the 39454f38fcaSMauro Carvalho Chehab validation step instead of to ``count``. This means that if 39554f38fcaSMauro Carvalho Chehab :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` fails with ``error_idx`` set to ``count``, 39654f38fcaSMauro Carvalho Chehab then you can call :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` to try to discover the 39754f38fcaSMauro Carvalho Chehab actual control that failed the validation step. Unfortunately, 39854f38fcaSMauro Carvalho Chehab there is no ``TRY`` equivalent for :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`. 39954f38fcaSMauro Carvalho Chehab * - __s32 40054f38fcaSMauro Carvalho Chehab - ``request_fd`` 401fea13a69SMauro Carvalho Chehab - File descriptor of the request to be used by this operation. Only 402fea13a69SMauro Carvalho Chehab valid if ``which`` is set to ``V4L2_CTRL_WHICH_REQUEST_VAL``. 403fea13a69SMauro Carvalho Chehab If the device does not support requests, then ``EACCES`` will be returned. 404fea13a69SMauro Carvalho Chehab If requests are supported but an invalid request file descriptor is 405c4a1bff9SMauro Carvalho Chehab given, then ``EINVAL`` will be returned. 406c4a1bff9SMauro Carvalho Chehab * - __u32 40754f38fcaSMauro Carvalho Chehab - ``reserved``\ [1] 40854f38fcaSMauro Carvalho Chehab - Reserved for future extensions. 40954f38fcaSMauro Carvalho Chehab 41054f38fcaSMauro Carvalho Chehab Drivers and applications must set the array to zero. 41154f38fcaSMauro Carvalho Chehab * - struct :c:type:`v4l2_ext_control` * 41254f38fcaSMauro Carvalho Chehab - ``controls`` 41354f38fcaSMauro Carvalho Chehab - Pointer to an array of ``count`` v4l2_ext_control structures. 41454f38fcaSMauro Carvalho Chehab 41554f38fcaSMauro Carvalho Chehab Ignored if ``count`` equals zero. 41654f38fcaSMauro Carvalho Chehab 41754f38fcaSMauro Carvalho Chehab.. tabularcolumns:: |p{7.3cm}|p{2.0cm}|p{8.0cm}| 41854f38fcaSMauro Carvalho Chehab 41935aaa6e6SEzequiel Garcia.. cssclass:: longtable 42054f38fcaSMauro Carvalho Chehab 42135aaa6e6SEzequiel Garcia.. _ctrl-class: 42235aaa6e6SEzequiel Garcia 42354f38fcaSMauro Carvalho Chehab.. flat-table:: Control classes 42454f38fcaSMauro Carvalho Chehab :header-rows: 0 42554f38fcaSMauro Carvalho Chehab :stub-columns: 0 42654f38fcaSMauro Carvalho Chehab :widths: 3 1 4 42754f38fcaSMauro Carvalho Chehab 42854f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_USER`` 42954f38fcaSMauro Carvalho Chehab - 0x980000 43054f38fcaSMauro Carvalho Chehab - The class containing user controls. These controls are described 43154f38fcaSMauro Carvalho Chehab in :ref:`control`. All controls that can be set using the 43254f38fcaSMauro Carvalho Chehab :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` and 43354f38fcaSMauro Carvalho Chehab :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl belong to this 43454f38fcaSMauro Carvalho Chehab class. 43554f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_CODEC`` 43654f38fcaSMauro Carvalho Chehab - 0x990000 43754f38fcaSMauro Carvalho Chehab - The class containing stateful codec controls. These controls are 43854f38fcaSMauro Carvalho Chehab described in :ref:`codec-controls`. 43954f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_CAMERA`` 44054f38fcaSMauro Carvalho Chehab - 0x9a0000 44154f38fcaSMauro Carvalho Chehab - The class containing camera controls. These controls are described 44254f38fcaSMauro Carvalho Chehab in :ref:`camera-controls`. 44354f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_FM_TX`` 44454f38fcaSMauro Carvalho Chehab - 0x9b0000 44554f38fcaSMauro Carvalho Chehab - The class containing FM Transmitter (FM TX) controls. These 44654f38fcaSMauro Carvalho Chehab controls are described in :ref:`fm-tx-controls`. 44754f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_FLASH`` 44854f38fcaSMauro Carvalho Chehab - 0x9c0000 44954f38fcaSMauro Carvalho Chehab - The class containing flash device controls. These controls are 45054f38fcaSMauro Carvalho Chehab described in :ref:`flash-controls`. 45154f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_JPEG`` 45254f38fcaSMauro Carvalho Chehab - 0x9d0000 45354f38fcaSMauro Carvalho Chehab - The class containing JPEG compression controls. These controls are 45454f38fcaSMauro Carvalho Chehab described in :ref:`jpeg-controls`. 455df23e0c1SHans Verkuil * - ``V4L2_CTRL_CLASS_IMAGE_SOURCE`` 456df23e0c1SHans Verkuil - 0x9e0000 457df23e0c1SHans Verkuil - The class containing image source controls. These controls are 458df23e0c1SHans Verkuil described in :ref:`image-source-controls`. 459008d2bd6SEzequiel Garcia * - ``V4L2_CTRL_CLASS_IMAGE_PROC`` 460008d2bd6SEzequiel Garcia - 0x9f0000 461008d2bd6SEzequiel Garcia - The class containing image processing controls. These controls are 462008d2bd6SEzequiel Garcia described in :ref:`image-process-controls`. 4634e4053a2SStanimir Varbanov * - ``V4L2_CTRL_CLASS_FM_RX`` 4644e4053a2SStanimir Varbanov - 0xa10000 4654e4053a2SStanimir Varbanov - The class containing FM Receiver (FM RX) controls. These controls 4664e4053a2SStanimir Varbanov are described in :ref:`fm-rx-controls`. 46754f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_RF_TUNER`` 46854f38fcaSMauro Carvalho Chehab - 0xa20000 46954f38fcaSMauro Carvalho Chehab - The class containing RF tuner controls. These controls are 47054f38fcaSMauro Carvalho Chehab described in :ref:`rf-tuner-controls`. 47154f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_DETECT`` 47254f38fcaSMauro Carvalho Chehab - 0xa30000 47354f38fcaSMauro Carvalho Chehab - The class containing motion or object detection controls. These controls 47454f38fcaSMauro Carvalho Chehab are described in :ref:`detect-controls`. 47554f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_CODEC_STATELESS`` 47654f38fcaSMauro Carvalho Chehab - 0xa40000 47754f38fcaSMauro Carvalho Chehab - The class containing stateless codec controls. These controls are 47854f38fcaSMauro Carvalho Chehab described in :ref:`codec-stateless-controls`. 47954f38fcaSMauro Carvalho Chehab * - ``V4L2_CTRL_CLASS_COLORIMETRY`` 48054f38fcaSMauro Carvalho Chehab - 0xa50000 48154f38fcaSMauro Carvalho Chehab - The class containing colorimetry controls. These controls are 48254f38fcaSMauro Carvalho Chehab described in :ref:`colorimetry-controls`. 48354f38fcaSMauro Carvalho Chehab 48454f38fcaSMauro Carvalho ChehabReturn Value 48554f38fcaSMauro Carvalho Chehab============ 48654f38fcaSMauro Carvalho Chehab 48754f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set 48854f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the 48954f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter. 49054f38fcaSMauro Carvalho Chehab 49154f38fcaSMauro Carvalho ChehabEINVAL 49254f38fcaSMauro Carvalho Chehab The struct :c:type:`v4l2_ext_control` ``id`` is 49354f38fcaSMauro Carvalho Chehab invalid, or the struct :c:type:`v4l2_ext_controls` 49454f38fcaSMauro Carvalho Chehab ``which`` is invalid, or the struct 49554f38fcaSMauro Carvalho Chehab :c:type:`v4l2_ext_control` ``value`` was 49654f38fcaSMauro Carvalho Chehab inappropriate (e.g. the given menu index is not supported by the 49754f38fcaSMauro Carvalho Chehab driver), or the ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL`` 49854f38fcaSMauro Carvalho Chehab but the given ``request_fd`` was invalid or ``V4L2_CTRL_WHICH_REQUEST_VAL`` 49954f38fcaSMauro Carvalho Chehab is not supported by the kernel. 50054f38fcaSMauro Carvalho Chehab This error code is also returned by the 50154f38fcaSMauro Carvalho Chehab :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` and :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ioctls if two or 50254f38fcaSMauro Carvalho Chehab more control values are in conflict. 50354f38fcaSMauro Carvalho Chehab 50454f38fcaSMauro Carvalho ChehabERANGE 50554f38fcaSMauro Carvalho Chehab The struct :c:type:`v4l2_ext_control` ``value`` 50654f38fcaSMauro Carvalho Chehab is out of bounds. 50754f38fcaSMauro Carvalho Chehab 50854f38fcaSMauro Carvalho ChehabEBUSY 50954f38fcaSMauro Carvalho Chehab The control is temporarily not changeable, possibly because another 51054f38fcaSMauro Carvalho Chehab applications took over control of the device function this control 5118c426941SRicardo Ribalda belongs to, or (if the ``which`` field was set to 5128c426941SRicardo Ribalda ``V4L2_CTRL_WHICH_REQUEST_VAL``) the request was queued but not yet 5138c426941SRicardo Ribalda completed. 514 515ENOSPC 516 The space reserved for the control's payload is insufficient. The 517 field ``size`` is set to a value that is enough to store the payload 518 and this error code is returned. 519 520EACCES 521 Attempt to try or set a read-only control, or to get a write-only 522 control, or to get a control from a request that has not yet been 523 completed. 524 525 Or the ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL`` but the 526 device does not support requests. 527 528 Or if there is an attempt to set an inactive control and the driver is 529 not capable of caching the new value until the control is active again. 530