| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 | /* |
| 3 | * USB Video Class definitions. |
| 4 | * |
| 5 | * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be> |
| 6 | * |
| 7 | * This file holds USB constants and structures defined by the USB Device |
| 8 | * Class Definition for Video Devices. Unless otherwise stated, comments |
| 9 | * below reference relevant sections of the USB Video Class 1.1 specification |
| 10 | * available at |
| 11 | * |
| 12 | * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip |
| 13 | */ |
| 14 | |
| 15 | #ifndef __LINUX_USB_VIDEO_H |
| 16 | #define __LINUX_USB_VIDEO_H |
| 17 | |
| 18 | #include <linux/types.h> |
| 19 | |
| 20 | /* -------------------------------------------------------------------------- |
| 21 | * UVC constants |
| 22 | */ |
| 23 | |
| 24 | /* A.2. Video Interface Subclass Codes */ |
| 25 | #define UVC_SC_UNDEFINED				0x00 |
| 26 | #define UVC_SC_VIDEOCONTROL				0x01 |
| 27 | #define UVC_SC_VIDEOSTREAMING				0x02 |
| 28 | #define UVC_SC_VIDEO_INTERFACE_COLLECTION		0x03 |
| 29 | |
| 30 | /* A.3. Video Interface Protocol Codes */ |
| 31 | #define UVC_PC_PROTOCOL_UNDEFINED			0x00 |
| 32 | #define UVC_PC_PROTOCOL_15				0x01 |
| 33 | |
| 34 | /* A.5. Video Class-Specific VC Interface Descriptor Subtypes */ |
| 35 | #define UVC_VC_DESCRIPTOR_UNDEFINED			0x00 |
| 36 | #define UVC_VC_HEADER					0x01 |
| 37 | #define UVC_VC_INPUT_TERMINAL				0x02 |
| 38 | #define UVC_VC_OUTPUT_TERMINAL				0x03 |
| 39 | #define UVC_VC_SELECTOR_UNIT				0x04 |
| 40 | #define UVC_VC_PROCESSING_UNIT				0x05 |
| 41 | #define UVC_VC_EXTENSION_UNIT				0x06 |
| 42 | |
| 43 | /* A.6. Video Class-Specific VS Interface Descriptor Subtypes */ |
| 44 | #define UVC_VS_UNDEFINED				0x00 |
| 45 | #define UVC_VS_INPUT_HEADER				0x01 |
| 46 | #define UVC_VS_OUTPUT_HEADER				0x02 |
| 47 | #define UVC_VS_STILL_IMAGE_FRAME			0x03 |
| 48 | #define UVC_VS_FORMAT_UNCOMPRESSED			0x04 |
| 49 | #define UVC_VS_FRAME_UNCOMPRESSED			0x05 |
| 50 | #define UVC_VS_FORMAT_MJPEG				0x06 |
| 51 | #define UVC_VS_FRAME_MJPEG				0x07 |
| 52 | #define UVC_VS_FORMAT_MPEG2TS				0x0a |
| 53 | #define UVC_VS_FORMAT_DV				0x0c |
| 54 | #define UVC_VS_COLORFORMAT				0x0d |
| 55 | #define UVC_VS_FORMAT_FRAME_BASED			0x10 |
| 56 | #define UVC_VS_FRAME_FRAME_BASED			0x11 |
| 57 | #define UVC_VS_FORMAT_STREAM_BASED			0x12 |
| 58 | |
| 59 | /* A.7. Video Class-Specific Endpoint Descriptor Subtypes */ |
| 60 | #define UVC_EP_UNDEFINED				0x00 |
| 61 | #define UVC_EP_GENERAL					0x01 |
| 62 | #define UVC_EP_ENDPOINT					0x02 |
| 63 | #define UVC_EP_INTERRUPT				0x03 |
| 64 | |
| 65 | /* A.8. Video Class-Specific Request Codes */ |
| 66 | #define UVC_RC_UNDEFINED				0x00 |
| 67 | #define UVC_SET_CUR					0x01 |
| 68 | #define UVC_GET_CUR					0x81 |
| 69 | #define UVC_GET_MIN					0x82 |
| 70 | #define UVC_GET_MAX					0x83 |
| 71 | #define UVC_GET_RES					0x84 |
| 72 | #define UVC_GET_LEN					0x85 |
| 73 | #define UVC_GET_INFO					0x86 |
| 74 | #define UVC_GET_DEF					0x87 |
| 75 | |
| 76 | /* A.9.1. VideoControl Interface Control Selectors */ |
| 77 | #define UVC_VC_CONTROL_UNDEFINED			0x00 |
| 78 | #define UVC_VC_VIDEO_POWER_MODE_CONTROL			0x01 |
| 79 | #define UVC_VC_REQUEST_ERROR_CODE_CONTROL		0x02 |
| 80 | |
| 81 | /* A.9.2. Terminal Control Selectors */ |
| 82 | #define UVC_TE_CONTROL_UNDEFINED			0x00 |
| 83 | |
| 84 | /* A.9.3. Selector Unit Control Selectors */ |
| 85 | #define UVC_SU_CONTROL_UNDEFINED			0x00 |
| 86 | #define UVC_SU_INPUT_SELECT_CONTROL			0x01 |
| 87 | |
| 88 | /* A.9.4. Camera Terminal Control Selectors */ |
| 89 | #define UVC_CT_CONTROL_UNDEFINED			0x00 |
| 90 | #define UVC_CT_SCANNING_MODE_CONTROL			0x01 |
| 91 | #define UVC_CT_AE_MODE_CONTROL				0x02 |
| 92 | #define UVC_CT_AE_PRIORITY_CONTROL			0x03 |
| 93 | #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL		0x04 |
| 94 | #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL		0x05 |
| 95 | #define UVC_CT_FOCUS_ABSOLUTE_CONTROL			0x06 |
| 96 | #define UVC_CT_FOCUS_RELATIVE_CONTROL			0x07 |
| 97 | #define UVC_CT_FOCUS_AUTO_CONTROL			0x08 |
| 98 | #define UVC_CT_IRIS_ABSOLUTE_CONTROL			0x09 |
| 99 | #define UVC_CT_IRIS_RELATIVE_CONTROL			0x0a |
| 100 | #define UVC_CT_ZOOM_ABSOLUTE_CONTROL			0x0b |
| 101 | #define UVC_CT_ZOOM_RELATIVE_CONTROL			0x0c |
| 102 | #define UVC_CT_PANTILT_ABSOLUTE_CONTROL			0x0d |
| 103 | #define UVC_CT_PANTILT_RELATIVE_CONTROL			0x0e |
| 104 | #define UVC_CT_ROLL_ABSOLUTE_CONTROL			0x0f |
| 105 | #define UVC_CT_ROLL_RELATIVE_CONTROL			0x10 |
| 106 | #define UVC_CT_PRIVACY_CONTROL				0x11 |
| 107 | #define UVC_CT_REGION_OF_INTEREST_CONTROL		0x14 |
| 108 | |
| 109 | /* A.9.5. Processing Unit Control Selectors */ |
| 110 | #define UVC_PU_CONTROL_UNDEFINED			0x00 |
| 111 | #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL		0x01 |
| 112 | #define UVC_PU_BRIGHTNESS_CONTROL			0x02 |
| 113 | #define UVC_PU_CONTRAST_CONTROL				0x03 |
| 114 | #define UVC_PU_GAIN_CONTROL				0x04 |
| 115 | #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL		0x05 |
| 116 | #define UVC_PU_HUE_CONTROL				0x06 |
| 117 | #define UVC_PU_SATURATION_CONTROL			0x07 |
| 118 | #define UVC_PU_SHARPNESS_CONTROL			0x08 |
| 119 | #define UVC_PU_GAMMA_CONTROL				0x09 |
| 120 | #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL	0x0a |
| 121 | #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL	0x0b |
| 122 | #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL		0x0c |
| 123 | #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL	0x0d |
| 124 | #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL		0x0e |
| 125 | #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL		0x0f |
| 126 | #define UVC_PU_HUE_AUTO_CONTROL				0x10 |
| 127 | #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL		0x11 |
| 128 | #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL		0x12 |
| 129 | |
| 130 | /* A.9.7. VideoStreaming Interface Control Selectors */ |
| 131 | #define UVC_VS_CONTROL_UNDEFINED			0x00 |
| 132 | #define UVC_VS_PROBE_CONTROL				0x01 |
| 133 | #define UVC_VS_COMMIT_CONTROL				0x02 |
| 134 | #define UVC_VS_STILL_PROBE_CONTROL			0x03 |
| 135 | #define UVC_VS_STILL_COMMIT_CONTROL			0x04 |
| 136 | #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL		0x05 |
| 137 | #define UVC_VS_STREAM_ERROR_CODE_CONTROL		0x06 |
| 138 | #define UVC_VS_GENERATE_KEY_FRAME_CONTROL		0x07 |
| 139 | #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL		0x08 |
| 140 | #define UVC_VS_SYNC_DELAY_CONTROL			0x09 |
| 141 | |
| 142 | /* B.1. USB Terminal Types */ |
| 143 | #define UVC_TT_VENDOR_SPECIFIC				0x0100 |
| 144 | #define UVC_TT_STREAMING				0x0101 |
| 145 | |
| 146 | /* B.2. Input Terminal Types */ |
| 147 | #define UVC_ITT_VENDOR_SPECIFIC				0x0200 |
| 148 | #define UVC_ITT_CAMERA					0x0201 |
| 149 | #define UVC_ITT_MEDIA_TRANSPORT_INPUT			0x0202 |
| 150 | |
| 151 | /* B.3. Output Terminal Types */ |
| 152 | #define UVC_OTT_VENDOR_SPECIFIC				0x0300 |
| 153 | #define UVC_OTT_DISPLAY					0x0301 |
| 154 | #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT			0x0302 |
| 155 | |
| 156 | /* B.4. External Terminal Types */ |
| 157 | #define UVC_EXTERNAL_VENDOR_SPECIFIC			0x0400 |
| 158 | #define UVC_COMPOSITE_CONNECTOR				0x0401 |
| 159 | #define UVC_SVIDEO_CONNECTOR				0x0402 |
| 160 | #define UVC_COMPONENT_CONNECTOR				0x0403 |
| 161 | |
| 162 | /* 2.4.2.2. Status Packet Type */ |
| 163 | #define UVC_STATUS_TYPE_CONTROL				1 |
| 164 | #define UVC_STATUS_TYPE_STREAMING			2 |
| 165 | |
| 166 | /* 2.4.3.3. Payload Header Information */ |
| 167 | #define UVC_STREAM_EOH					(1 << 7) |
| 168 | #define UVC_STREAM_ERR					(1 << 6) |
| 169 | #define UVC_STREAM_STI					(1 << 5) |
| 170 | #define UVC_STREAM_RES					(1 << 4) |
| 171 | #define UVC_STREAM_SCR					(1 << 3) |
| 172 | #define UVC_STREAM_PTS					(1 << 2) |
| 173 | #define UVC_STREAM_EOF					(1 << 1) |
| 174 | #define UVC_STREAM_FID					(1 << 0) |
| 175 | |
| 176 | /* 4.1.2. Control Capabilities */ |
| 177 | #define UVC_CONTROL_CAP_GET				(1 << 0) |
| 178 | #define UVC_CONTROL_CAP_SET				(1 << 1) |
| 179 | #define UVC_CONTROL_CAP_DISABLED			(1 << 2) |
| 180 | #define UVC_CONTROL_CAP_AUTOUPDATE			(1 << 3) |
| 181 | #define UVC_CONTROL_CAP_ASYNCHRONOUS			(1 << 4) |
| 182 | |
| 183 | /* 3.9.2.6 Color Matching Descriptor Values */ |
| 184 | enum uvc_color_primaries_values { |
| 185 | 	UVC_COLOR_PRIMARIES_UNSPECIFIED, |
| 186 | 	UVC_COLOR_PRIMARIES_BT_709_SRGB, |
| 187 | 	UVC_COLOR_PRIMARIES_BT_470_2_M, |
| 188 | 	UVC_COLOR_PRIMARIES_BT_470_2_B_G, |
| 189 | 	UVC_COLOR_PRIMARIES_SMPTE_170M, |
| 190 | 	UVC_COLOR_PRIMARIES_SMPTE_240M, |
| 191 | }; |
| 192 | |
| 193 | enum uvc_transfer_characteristics_values { |
| 194 | 	UVC_TRANSFER_CHARACTERISTICS_UNSPECIFIED, |
| 195 | 	UVC_TRANSFER_CHARACTERISTICS_BT_709, |
| 196 | 	UVC_TRANSFER_CHARACTERISTICS_BT_470_2_M, |
| 197 | 	UVC_TRANSFER_CHARACTERISTICS_BT_470_2_B_G, |
| 198 | 	UVC_TRANSFER_CHARACTERISTICS_SMPTE_170M, |
| 199 | 	UVC_TRANSFER_CHARACTERISTICS_SMPTE_240M, |
| 200 | 	UVC_TRANSFER_CHARACTERISTICS_LINEAR, |
| 201 | 	UVC_TRANSFER_CHARACTERISTICS_SRGB, |
| 202 | }; |
| 203 | |
| 204 | enum uvc_matrix_coefficients { |
| 205 | 	UVC_MATRIX_COEFFICIENTS_UNSPECIFIED, |
| 206 | 	UVC_MATRIX_COEFFICIENTS_BT_709, |
| 207 | 	UVC_MATRIX_COEFFICIENTS_FCC, |
| 208 | 	UVC_MATRIX_COEFFICIENTS_BT_470_2_B_G, |
| 209 | 	UVC_MATRIX_COEFFICIENTS_SMPTE_170M, |
| 210 | 	UVC_MATRIX_COEFFICIENTS_SMPTE_240M, |
| 211 | }; |
| 212 | |
| 213 | /* ------------------------------------------------------------------------ |
| 214 | * UVC structures |
| 215 | */ |
| 216 | |
| 217 | /* All UVC descriptors have these 3 fields at the beginning */ |
| 218 | struct uvc_descriptor_header { |
| 219 | 	__u8 bLength; |
| 220 | 	__u8 bDescriptorType; |
| 221 | 	__u8 bDescriptorSubType; |
| 222 | } __attribute__((packed)); |
| 223 | |
| 224 | /* 3.7.2. Video Control Interface Header Descriptor */ |
| 225 | struct uvc_header_descriptor { |
| 226 | 	__u8 bLength; |
| 227 | 	__u8 bDescriptorType; |
| 228 | 	__u8 bDescriptorSubType; |
| 229 | 	__le16 bcdUVC; |
| 230 | 	__le16 wTotalLength; |
| 231 | 	__le32 dwClockFrequency; |
| 232 | 	__u8 bInCollection; |
| 233 | 	__u8 baInterfaceNr[]; |
| 234 | } __attribute__((__packed__)); |
| 235 | |
| 236 | #define UVC_DT_HEADER_SIZE(n)				(12+(n)) |
| 237 | |
| 238 | #define UVC_HEADER_DESCRIPTOR(n) \ |
| 239 | 	uvc_header_descriptor_##n |
| 240 | |
| 241 | #define DECLARE_UVC_HEADER_DESCRIPTOR(n)		\ |
| 242 | struct UVC_HEADER_DESCRIPTOR(n) {			\ |
| 243 | 	__u8 bLength;					\ |
| 244 | 	__u8 bDescriptorType;				\ |
| 245 | 	__u8 bDescriptorSubType;			\ |
| 246 | 	__le16 bcdUVC;					\ |
| 247 | 	__le16 wTotalLength;				\ |
| 248 | 	__le32 dwClockFrequency;			\ |
| 249 | 	__u8 bInCollection;				\ |
| 250 | 	__u8 baInterfaceNr[n];			\ |
| 251 | } __attribute__ ((packed)) |
| 252 | |
| 253 | /* 3.7.2.1. Input Terminal Descriptor */ |
| 254 | struct uvc_input_terminal_descriptor { |
| 255 | 	__u8 bLength; |
| 256 | 	__u8 bDescriptorType; |
| 257 | 	__u8 bDescriptorSubType; |
| 258 | 	__u8 bTerminalID; |
| 259 | 	__le16 wTerminalType; |
| 260 | 	__u8 bAssocTerminal; |
| 261 | 	__u8 iTerminal; |
| 262 | } __attribute__((__packed__)); |
| 263 | |
| 264 | #define UVC_DT_INPUT_TERMINAL_SIZE			8 |
| 265 | |
| 266 | /* 3.7.2.2. Output Terminal Descriptor */ |
| 267 | struct uvc_output_terminal_descriptor { |
| 268 | 	__u8 bLength; |
| 269 | 	__u8 bDescriptorType; |
| 270 | 	__u8 bDescriptorSubType; |
| 271 | 	__u8 bTerminalID; |
| 272 | 	__le16 wTerminalType; |
| 273 | 	__u8 bAssocTerminal; |
| 274 | 	__u8 bSourceID; |
| 275 | 	__u8 iTerminal; |
| 276 | } __attribute__((__packed__)); |
| 277 | |
| 278 | #define UVC_DT_OUTPUT_TERMINAL_SIZE			9 |
| 279 | |
| 280 | /* 3.7.2.3. Camera Terminal Descriptor */ |
| 281 | struct uvc_camera_terminal_descriptor { |
| 282 | 	__u8 bLength; |
| 283 | 	__u8 bDescriptorType; |
| 284 | 	__u8 bDescriptorSubType; |
| 285 | 	__u8 bTerminalID; |
| 286 | 	__le16 wTerminalType; |
| 287 | 	__u8 bAssocTerminal; |
| 288 | 	__u8 iTerminal; |
| 289 | 	__le16 wObjectiveFocalLengthMin; |
| 290 | 	__le16 wObjectiveFocalLengthMax; |
| 291 | 	__le16 wOcularFocalLength; |
| 292 | 	__u8 bControlSize; |
| 293 | 	__u8 bmControls[3]; |
| 294 | } __attribute__((__packed__)); |
| 295 | |
| 296 | #define UVC_DT_CAMERA_TERMINAL_SIZE(n)			(15+(n)) |
| 297 | |
| 298 | /* 3.7.2.4. Selector Unit Descriptor */ |
| 299 | struct uvc_selector_unit_descriptor { |
| 300 | 	__u8 bLength; |
| 301 | 	__u8 bDescriptorType; |
| 302 | 	__u8 bDescriptorSubType; |
| 303 | 	__u8 bUnitID; |
| 304 | 	__u8 bNrInPins; |
| 305 | 	__u8 baSourceID[0]; |
| 306 | 	__u8 iSelector; |
| 307 | } __attribute__((__packed__)); |
| 308 | |
| 309 | #define UVC_DT_SELECTOR_UNIT_SIZE(n)			(6+(n)) |
| 310 | |
| 311 | #define UVC_SELECTOR_UNIT_DESCRIPTOR(n)	\ |
| 312 | 	uvc_selector_unit_descriptor_##n |
| 313 | |
| 314 | #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n)	\ |
| 315 | struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) {		\ |
| 316 | 	__u8 bLength;					\ |
| 317 | 	__u8 bDescriptorType;				\ |
| 318 | 	__u8 bDescriptorSubType;			\ |
| 319 | 	__u8 bUnitID;					\ |
| 320 | 	__u8 bNrInPins;				\ |
| 321 | 	__u8 baSourceID[n];				\ |
| 322 | 	__u8 iSelector;				\ |
| 323 | } __attribute__ ((packed)) |
| 324 | |
| 325 | /* 3.7.2.5. Processing Unit Descriptor */ |
| 326 | struct uvc_processing_unit_descriptor { |
| 327 | 	__u8 bLength; |
| 328 | 	__u8 bDescriptorType; |
| 329 | 	__u8 bDescriptorSubType; |
| 330 | 	__u8 bUnitID; |
| 331 | 	__u8 bSourceID; |
| 332 | 	__le16 wMaxMultiplier; |
| 333 | 	__u8 bControlSize; |
| 334 | 	__u8 bmControls[2]; |
| 335 | 	__u8 iProcessing; |
| 336 | 	__u8 bmVideoStandards; |
| 337 | } __attribute__((__packed__)); |
| 338 | |
| 339 | #define UVC_DT_PROCESSING_UNIT_SIZE(n)			(10+(n)) |
| 340 | |
| 341 | /* 3.7.2.6. Extension Unit Descriptor */ |
| 342 | struct uvc_extension_unit_descriptor { |
| 343 | 	__u8 bLength; |
| 344 | 	__u8 bDescriptorType; |
| 345 | 	__u8 bDescriptorSubType; |
| 346 | 	__u8 bUnitID; |
| 347 | 	__u8 guidExtensionCode[16]; |
| 348 | 	__u8 bNumControls; |
| 349 | 	__u8 bNrInPins; |
| 350 | 	__u8 baSourceID[0]; |
| 351 | 	__u8 bControlSize; |
| 352 | 	__u8 bmControls[0]; |
| 353 | 	__u8 iExtension; |
| 354 | } __attribute__((__packed__)); |
| 355 | |
| 356 | #define UVC_DT_EXTENSION_UNIT_SIZE(p, n)		(24+(p)+(n)) |
| 357 | |
| 358 | #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ |
| 359 | 	uvc_extension_unit_descriptor_##p_##n |
| 360 | |
| 361 | #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n)	\ |
| 362 | struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) {		\ |
| 363 | 	__u8 bLength;					\ |
| 364 | 	__u8 bDescriptorType;				\ |
| 365 | 	__u8 bDescriptorSubType;			\ |
| 366 | 	__u8 bUnitID;					\ |
| 367 | 	__u8 guidExtensionCode[16];			\ |
| 368 | 	__u8 bNumControls;				\ |
| 369 | 	__u8 bNrInPins;				\ |
| 370 | 	__u8 baSourceID[p];				\ |
| 371 | 	__u8 bControlSize;				\ |
| 372 | 	__u8 bmControls[n];				\ |
| 373 | 	__u8 iExtension;				\ |
| 374 | } __attribute__ ((packed)) |
| 375 | |
| 376 | /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */ |
| 377 | struct uvc_control_endpoint_descriptor { |
| 378 | 	__u8 bLength; |
| 379 | 	__u8 bDescriptorType; |
| 380 | 	__u8 bDescriptorSubType; |
| 381 | 	__le16 wMaxTransferSize; |
| 382 | } __attribute__((__packed__)); |
| 383 | |
| 384 | #define UVC_DT_CONTROL_ENDPOINT_SIZE			5 |
| 385 | |
| 386 | /* 3.9.2.1. Input Header Descriptor */ |
| 387 | struct uvc_input_header_descriptor { |
| 388 | 	__u8 bLength; |
| 389 | 	__u8 bDescriptorType; |
| 390 | 	__u8 bDescriptorSubType; |
| 391 | 	__u8 bNumFormats; |
| 392 | 	__le16 wTotalLength; |
| 393 | 	__u8 bEndpointAddress; |
| 394 | 	__u8 bmInfo; |
| 395 | 	__u8 bTerminalLink; |
| 396 | 	__u8 bStillCaptureMethod; |
| 397 | 	__u8 bTriggerSupport; |
| 398 | 	__u8 bTriggerUsage; |
| 399 | 	__u8 bControlSize; |
| 400 | 	__u8 bmaControls[]; |
| 401 | } __attribute__((__packed__)); |
| 402 | |
| 403 | #define UVC_DT_INPUT_HEADER_SIZE(n, p)			(13+(n*p)) |
| 404 | |
| 405 | #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ |
| 406 | 	uvc_input_header_descriptor_##n_##p |
| 407 | |
| 408 | #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p)	\ |
| 409 | struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) {		\ |
| 410 | 	__u8 bLength;					\ |
| 411 | 	__u8 bDescriptorType;				\ |
| 412 | 	__u8 bDescriptorSubType;			\ |
| 413 | 	__u8 bNumFormats;				\ |
| 414 | 	__le16 wTotalLength;				\ |
| 415 | 	__u8 bEndpointAddress;			\ |
| 416 | 	__u8 bmInfo;					\ |
| 417 | 	__u8 bTerminalLink;				\ |
| 418 | 	__u8 bStillCaptureMethod;			\ |
| 419 | 	__u8 bTriggerSupport;				\ |
| 420 | 	__u8 bTriggerUsage;				\ |
| 421 | 	__u8 bControlSize;				\ |
| 422 | 	__u8 bmaControls[p][n];			\ |
| 423 | } __attribute__ ((packed)) |
| 424 | |
| 425 | /* 3.9.2.2. Output Header Descriptor */ |
| 426 | struct uvc_output_header_descriptor { |
| 427 | 	__u8 bLength; |
| 428 | 	__u8 bDescriptorType; |
| 429 | 	__u8 bDescriptorSubType; |
| 430 | 	__u8 bNumFormats; |
| 431 | 	__le16 wTotalLength; |
| 432 | 	__u8 bEndpointAddress; |
| 433 | 	__u8 bTerminalLink; |
| 434 | 	__u8 bControlSize; |
| 435 | 	__u8 bmaControls[]; |
| 436 | } __attribute__((__packed__)); |
| 437 | |
| 438 | #define UVC_DT_OUTPUT_HEADER_SIZE(n, p)			(9+(n*p)) |
| 439 | |
| 440 | #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ |
| 441 | 	uvc_output_header_descriptor_##n_##p |
| 442 | |
| 443 | #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p)	\ |
| 444 | struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) {		\ |
| 445 | 	__u8 bLength;					\ |
| 446 | 	__u8 bDescriptorType;				\ |
| 447 | 	__u8 bDescriptorSubType;			\ |
| 448 | 	__u8 bNumFormats;				\ |
| 449 | 	__le16 wTotalLength;				\ |
| 450 | 	__u8 bEndpointAddress;			\ |
| 451 | 	__u8 bTerminalLink;				\ |
| 452 | 	__u8 bControlSize;				\ |
| 453 | 	__u8 bmaControls[p][n];			\ |
| 454 | } __attribute__ ((packed)) |
| 455 | |
| 456 | /* 3.9.2.6. Color matching descriptor */ |
| 457 | struct uvc_color_matching_descriptor { |
| 458 | 	__u8 bLength; |
| 459 | 	__u8 bDescriptorType; |
| 460 | 	__u8 bDescriptorSubType; |
| 461 | 	__u8 bColorPrimaries; |
| 462 | 	__u8 bTransferCharacteristics; |
| 463 | 	__u8 bMatrixCoefficients; |
| 464 | } __attribute__((__packed__)); |
| 465 | |
| 466 | #define UVC_DT_COLOR_MATCHING_SIZE			6 |
| 467 | |
| 468 | /* 4.3.1.1. Video Probe and Commit Controls */ |
| 469 | struct uvc_streaming_control { |
| 470 | 	__u16 bmHint; |
| 471 | 	__u8 bFormatIndex; |
| 472 | 	__u8 bFrameIndex; |
| 473 | 	__u32 dwFrameInterval; |
| 474 | 	__u16 wKeyFrameRate; |
| 475 | 	__u16 wPFrameRate; |
| 476 | 	__u16 wCompQuality; |
| 477 | 	__u16 wCompWindowSize; |
| 478 | 	__u16 wDelay; |
| 479 | 	__u32 dwMaxVideoFrameSize; |
| 480 | 	__u32 dwMaxPayloadTransferSize; |
| 481 | 	__u32 dwClockFrequency; |
| 482 | 	__u8 bmFramingInfo; |
| 483 | 	__u8 bPreferedVersion; |
| 484 | 	__u8 bMinVersion; |
| 485 | 	__u8 bMaxVersion; |
| 486 | } __attribute__((__packed__)); |
| 487 | |
| 488 | /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */ |
| 489 | struct uvc_format_uncompressed { |
| 490 | 	__u8 bLength; |
| 491 | 	__u8 bDescriptorType; |
| 492 | 	__u8 bDescriptorSubType; |
| 493 | 	__u8 bFormatIndex; |
| 494 | 	__u8 bNumFrameDescriptors; |
| 495 | 	__u8 guidFormat[16]; |
| 496 | 	__u8 bBitsPerPixel; |
| 497 | 	__u8 bDefaultFrameIndex; |
| 498 | 	__u8 bAspectRatioX; |
| 499 | 	__u8 bAspectRatioY; |
| 500 | 	__u8 bmInterlaceFlags; |
| 501 | 	__u8 bCopyProtect; |
| 502 | } __attribute__((__packed__)); |
| 503 | |
| 504 | #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE			27 |
| 505 | |
| 506 | /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */ |
| 507 | struct uvc_frame_uncompressed { |
| 508 | 	__u8 bLength; |
| 509 | 	__u8 bDescriptorType; |
| 510 | 	__u8 bDescriptorSubType; |
| 511 | 	__u8 bFrameIndex; |
| 512 | 	__u8 bmCapabilities; |
| 513 | 	__le16 wWidth; |
| 514 | 	__le16 wHeight; |
| 515 | 	__le32 dwMinBitRate; |
| 516 | 	__le32 dwMaxBitRate; |
| 517 | 	__le32 dwMaxVideoFrameBufferSize; |
| 518 | 	__le32 dwDefaultFrameInterval; |
| 519 | 	__u8 bFrameIntervalType; |
| 520 | 	__le32 dwFrameInterval[]; |
| 521 | } __attribute__((__packed__)); |
| 522 | |
| 523 | #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n)		(26+4*(n)) |
| 524 | |
| 525 | #define UVC_FRAME_UNCOMPRESSED(n) \ |
| 526 | 	uvc_frame_uncompressed_##n |
| 527 | |
| 528 | #define DECLARE_UVC_FRAME_UNCOMPRESSED(n)		\ |
| 529 | struct UVC_FRAME_UNCOMPRESSED(n) {			\ |
| 530 | 	__u8 bLength;					\ |
| 531 | 	__u8 bDescriptorType;				\ |
| 532 | 	__u8 bDescriptorSubType;			\ |
| 533 | 	__u8 bFrameIndex;				\ |
| 534 | 	__u8 bmCapabilities;				\ |
| 535 | 	__le16 wWidth;					\ |
| 536 | 	__le16 wHeight;					\ |
| 537 | 	__le32 dwMinBitRate;				\ |
| 538 | 	__le32 dwMaxBitRate;				\ |
| 539 | 	__le32 dwMaxVideoFrameBufferSize;		\ |
| 540 | 	__le32 dwDefaultFrameInterval;			\ |
| 541 | 	__u8 bFrameIntervalType;			\ |
| 542 | 	__le32 dwFrameInterval[n];			\ |
| 543 | } __attribute__ ((packed)) |
| 544 | |
| 545 | /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */ |
| 546 | struct uvc_format_mjpeg { |
| 547 | 	__u8 bLength; |
| 548 | 	__u8 bDescriptorType; |
| 549 | 	__u8 bDescriptorSubType; |
| 550 | 	__u8 bFormatIndex; |
| 551 | 	__u8 bNumFrameDescriptors; |
| 552 | 	__u8 bmFlags; |
| 553 | 	__u8 bDefaultFrameIndex; |
| 554 | 	__u8 bAspectRatioX; |
| 555 | 	__u8 bAspectRatioY; |
| 556 | 	__u8 bmInterlaceFlags; |
| 557 | 	__u8 bCopyProtect; |
| 558 | } __attribute__((__packed__)); |
| 559 | |
| 560 | #define UVC_DT_FORMAT_MJPEG_SIZE			11 |
| 561 | |
| 562 | /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */ |
| 563 | struct uvc_frame_mjpeg { |
| 564 | 	__u8 bLength; |
| 565 | 	__u8 bDescriptorType; |
| 566 | 	__u8 bDescriptorSubType; |
| 567 | 	__u8 bFrameIndex; |
| 568 | 	__u8 bmCapabilities; |
| 569 | 	__le16 wWidth; |
| 570 | 	__le16 wHeight; |
| 571 | 	__le32 dwMinBitRate; |
| 572 | 	__le32 dwMaxBitRate; |
| 573 | 	__le32 dwMaxVideoFrameBufferSize; |
| 574 | 	__le32 dwDefaultFrameInterval; |
| 575 | 	__u8 bFrameIntervalType; |
| 576 | 	__le32 dwFrameInterval[]; |
| 577 | } __attribute__((__packed__)); |
| 578 | |
| 579 | #define UVC_DT_FRAME_MJPEG_SIZE(n)			(26+4*(n)) |
| 580 | |
| 581 | #define UVC_FRAME_MJPEG(n) \ |
| 582 | 	uvc_frame_mjpeg_##n |
| 583 | |
| 584 | #define DECLARE_UVC_FRAME_MJPEG(n)			\ |
| 585 | struct UVC_FRAME_MJPEG(n) {				\ |
| 586 | 	__u8 bLength;					\ |
| 587 | 	__u8 bDescriptorType;				\ |
| 588 | 	__u8 bDescriptorSubType;			\ |
| 589 | 	__u8 bFrameIndex;				\ |
| 590 | 	__u8 bmCapabilities;				\ |
| 591 | 	__le16 wWidth;					\ |
| 592 | 	__le16 wHeight;					\ |
| 593 | 	__le32 dwMinBitRate;				\ |
| 594 | 	__le32 dwMaxBitRate;				\ |
| 595 | 	__le32 dwMaxVideoFrameBufferSize;		\ |
| 596 | 	__le32 dwDefaultFrameInterval;			\ |
| 597 | 	__u8 bFrameIntervalType;			\ |
| 598 | 	__le32 dwFrameInterval[n];			\ |
| 599 | } __attribute__ ((packed)) |
| 600 | |
| 601 | /* Frame Based Payload - 3.1.1. Frame Based Video Format Descriptor */ |
| 602 | struct uvc_format_framebased { |
| 603 | 	__u8 bLength; |
| 604 | 	__u8 bDescriptorType; |
| 605 | 	__u8 bDescriptorSubType; |
| 606 | 	__u8 bFormatIndex; |
| 607 | 	__u8 bNumFrameDescriptors; |
| 608 | 	__u8 guidFormat[16]; |
| 609 | 	__u8 bBitsPerPixel; |
| 610 | 	__u8 bDefaultFrameIndex; |
| 611 | 	__u8 bAspectRatioX; |
| 612 | 	__u8 bAspectRatioY; |
| 613 | 	__u8 bmInterfaceFlags; |
| 614 | 	__u8 bCopyProtect; |
| 615 | 	__u8 bVariableSize; |
| 616 | } __attribute__((__packed__)); |
| 617 | |
| 618 | #define UVC_DT_FORMAT_FRAMEBASED_SIZE 28 |
| 619 | |
| 620 | /* Frame Based Payload - 3.1.2. Frame Based Video Frame Descriptor */ |
| 621 | struct uvc_frame_framebased { |
| 622 | 	__u8 bLength; |
| 623 | 	__u8 bDescriptorType; |
| 624 | 	__u8 bDescriptorSubType; |
| 625 | 	__u8 bFrameIndex; |
| 626 | 	__u8 bmCapabilities; |
| 627 | 	__u16 wWidth; |
| 628 | 	__u16 wHeight; |
| 629 | 	__u32 dwMinBitRate; |
| 630 | 	__u32 dwMaxBitRate; |
| 631 | 	__u32 dwDefaultFrameInterval; |
| 632 | 	__u8 bFrameIntervalType; |
| 633 | 	__u32 dwBytesPerLine; |
| 634 | 	__u32 dwFrameInterval[]; |
| 635 | } __attribute__((__packed__)); |
| 636 | |
| 637 | #define UVC_DT_FRAME_FRAMEBASED_SIZE(n) (26+4*(n)) |
| 638 | |
| 639 | #define UVC_FRAME_FRAMEBASED(n) \ |
| 640 | 	uvc_frame_framebased_##n |
| 641 | |
| 642 | #define DECLARE_UVC_FRAME_FRAMEBASED(n)			\ |
| 643 | struct UVC_FRAME_FRAMEBASED(n) {			\ |
| 644 | 	__u8 bLength;					\ |
| 645 | 	__u8 bDescriptorType;				\ |
| 646 | 	__u8 bDescriptorSubType; \ |
| 647 | 	__u8 bFrameIndex; \ |
| 648 | 	__u8 bmCapabilities; \ |
| 649 | 	__u16 wWidth; \ |
| 650 | 	__u16 wHeight; \ |
| 651 | 	__u32 dwMinBitRate; \ |
| 652 | 	__u32 dwMaxBitRate; \ |
| 653 | 	__u32 dwDefaultFrameInterval; \ |
| 654 | 	__u8 bFrameIntervalType; \ |
| 655 | 	__u32 dwBytesPerLine; \ |
| 656 | 	__u32 dwFrameInterval[n]; \ |
| 657 | } __attribute__ ((packed)) |
| 658 | |
| 659 | #endif /* __LINUX_USB_VIDEO_H */ |