^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) The Linux USB Video Class (UVC) driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) This file documents some driver-specific aspects of the UVC driver, such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) driver-specific ioctls and implementation notes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Questions and remarks can be sent to the Linux UVC development mailing list at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) linux-uvc-devel@lists.berlios.de.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Extension Unit (XU) support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) The UVC specification allows for vendor-specific extensions through extension
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) units (XUs). The Linux UVC driver supports extension unit controls (XU controls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) through two separate mechanisms:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) - through mappings of XU controls to V4L2 controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) - through a driver-specific ioctl interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) The first one allows generic V4L2 applications to use XU controls by mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) certain XU controls onto V4L2 controls, which then show up during ordinary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) control enumeration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) The second mechanism requires uvcvideo-specific knowledge for the application to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) access XU controls but exposes the entire UVC XU concept to user space for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) maximum flexibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Both mechanisms complement each other and are described in more detail below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Control mappings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) The UVC driver provides an API for user space applications to define so-called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) control mappings at runtime. These allow for individual XU controls or byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) ranges thereof to be mapped to new V4L2 controls. Such controls appear and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) function exactly like normal V4L2 controls (i.e. the stock controls, such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) brightness, contrast, etc.). However, reading or writing of such a V4L2 controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) triggers a read or write of the associated XU control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) The ioctl used to create these control mappings is called UVCIOC_CTRL_MAP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) Previous driver versions (before 0.2.0) required another ioctl to be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) beforehand (UVCIOC_CTRL_ADD) to pass XU control information to the UVC driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) This is no longer necessary as newer uvcvideo versions query the information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) directly from the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) For details on the UVCIOC_CTRL_MAP ioctl please refer to the section titled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) "IOCTL reference" below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 3. Driver specific XU control interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) For applications that need to access XU controls directly, e.g. for testing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) purposes, firmware upload, or accessing binary controls, a second mechanism to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) access XU controls is provided in the form of a driver-specific ioctl, namely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) UVCIOC_CTRL_QUERY.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) A call to this ioctl allows applications to send queries to the UVC driver that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) directly map to the low-level UVC control requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) In order to make such a request the UVC unit ID of the control's extension unit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) and the control selector need to be known. This information either needs to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) hardcoded in the application or queried using other ways such as by parsing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) UVC descriptor or, if available, using the media controller API to enumerate a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) device's entities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) Unless the control size is already known it is necessary to first make a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) UVC_GET_LEN requests in order to be able to allocate a sufficiently large buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) and set the buffer size to the correct value. Similarly, to find out whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) UVC_GET_CUR or UVC_SET_CUR are valid requests for a given control, a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) UVC_GET_INFO request should be made. The bits 0 (GET supported) and 1 (SET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) supported) of the resulting byte indicate which requests are valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) With the addition of the UVCIOC_CTRL_QUERY ioctl the UVCIOC_CTRL_GET and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) UVCIOC_CTRL_SET ioctls have become obsolete since their functionality is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) subset of the former ioctl. For the time being they are still supported but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) application developers are encouraged to use UVCIOC_CTRL_QUERY instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) For details on the UVCIOC_CTRL_QUERY ioctl please refer to the section titled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) "IOCTL reference" below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) Security
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) The API doesn't currently provide a fine-grained access control facility. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) UVCIOC_CTRL_ADD and UVCIOC_CTRL_MAP ioctls require super user permissions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) Suggestions on how to improve this are welcome.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) Debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) ~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) In order to debug problems related to XU controls or controls in general it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) recommended to enable the UVC_TRACE_CONTROL bit in the module parameter 'trace'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) This causes extra output to be written into the system log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) IOCTL reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) UVCIOC_CTRL_MAP - Map a UVC control to a V4L2 control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) Argument: struct uvc_xu_control_mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) **Description**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) This ioctl creates a mapping between a UVC control or part of a UVC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) control and a V4L2 control. Once mappings are defined, userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) applications can access vendor-defined UVC control through the V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) control API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) To create a mapping, applications fill the uvc_xu_control_mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) structure with information about an existing UVC control defined with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) UVCIOC_CTRL_ADD and a new V4L2 control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) A UVC control can be mapped to several V4L2 controls. For instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) a UVC pan/tilt control could be mapped to separate pan and tilt V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) controls. The UVC control is divided into non overlapping fields using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) the 'size' and 'offset' fields and are then independently mapped to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) V4L2 control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) For signed integer V4L2 controls the data_type field should be set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) UVC_CTRL_DATA_TYPE_SIGNED. Other values are currently ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) **Return value**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) On success 0 is returned. On error -1 is returned and errno is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) ENOMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) Not enough memory to perform the operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) EPERM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) Insufficient privileges (super user privileges are required).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) No such UVC control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) EOVERFLOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) The requested offset and size would overflow the UVC control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) EEXIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) Mapping already exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) **Data types**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .. code-block:: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * struct uvc_xu_control_mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) __u32 id V4L2 control identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) __u8 name[32] V4L2 control name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) __u8 entity[16] UVC extension unit GUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) __u8 selector UVC control selector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __u8 size V4L2 control size (in bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) __u8 offset V4L2 control offset (in bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) enum v4l2_ctrl_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) v4l2_type V4L2 control type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) enum uvc_control_data_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) data_type UVC control data type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct uvc_menu_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *menu_info Array of menu entries (for menu controls only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __u32 menu_count Number of menu entries (for menu controls only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * struct uvc_menu_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) __u32 value Menu entry value used by the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) __u8 name[32] Menu entry name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * enum uvc_control_data_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) UVC_CTRL_DATA_TYPE_RAW Raw control (byte array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) UVC_CTRL_DATA_TYPE_SIGNED Signed integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) UVC_CTRL_DATA_TYPE_UNSIGNED Unsigned integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) UVC_CTRL_DATA_TYPE_BOOLEAN Boolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) UVC_CTRL_DATA_TYPE_ENUM Enumeration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) UVC_CTRL_DATA_TYPE_BITMASK Bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) UVCIOC_CTRL_QUERY - Query a UVC XU control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) Argument: struct uvc_xu_control_query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) **Description**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) This ioctl queries a UVC XU control identified by its extension unit ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) and control selector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) There are a number of different queries available that closely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) correspond to the low-level control requests described in the UVC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) specification. These requests are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) UVC_GET_CUR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) Obtain the current value of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) UVC_GET_MIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) Obtain the minimum value of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) UVC_GET_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) Obtain the maximum value of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) UVC_GET_DEF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) Obtain the default value of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) UVC_GET_RES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) Query the resolution of the control, i.e. the step size of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) allowed control values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) UVC_GET_LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) Query the size of the control in bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) UVC_GET_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) Query the control information bitmap, which indicates whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) get/set requests are supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) UVC_SET_CUR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) Update the value of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) Applications must set the 'size' field to the correct length for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) control. Exceptions are the UVC_GET_LEN and UVC_GET_INFO queries, for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) which the size must be set to 2 and 1, respectively. The 'data' field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) must point to a valid writable buffer big enough to hold the indicated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) number of data bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) Data is copied directly from the device without any driver-side
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) processing. Applications are responsible for data buffer formatting,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) including little-endian/big-endian conversion. This is particularly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) important for the result of the UVC_GET_LEN requests, which is always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) returned as a little-endian 16-bit integer by the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) **Return value**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) On success 0 is returned. On error -1 is returned and errno is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ENOENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) The device does not support the given control or the specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) extension unit could not be found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ENOBUFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) The specified buffer size is incorrect (too big or too small).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) An invalid request code was passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) EBADRQC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) The given request is not supported by the given control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) EFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) The data pointer references an inaccessible memory area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) **Data types**:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .. code-block:: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * struct uvc_xu_control_query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) __u8 unit Extension unit ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) __u8 selector Control selector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) __u8 query Request code to send to the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) __u16 size Control data size (in bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) __u8 *data Control value