1 /* 2 * Copyright 2011, Haiku Inc. All Rights Reserved. 3 * Copyright 2009, Ithamar Adema, <ithamar.adema@team-embedded.nl>. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef _USB_VIDEO_H 7 #define _USB_VIDEO_H 8 9 10 /* Class/Subclass/Protocol */ 11 #define CC_VIDEO 0xE 12 #define SC_UNDEFINED 0x0 13 #define SC_VIDEOCONTROL 0x1 14 #define SC_VIDEOSTREAMING 0x2 15 #define SC_VIDEO_INTERFACE_COLLECTION 0x3 16 #define PC_PROTOCOL_UNDEFINED 0x0 17 18 #define CS_UNDEFINED 0x20 19 #define CS_DEVICE 0x21 20 #define CS_CONFIGURATION 0x22 21 #define CS_STRING 0x23 22 #define CS_INTERFACE 0x24 23 #define CS_ENDPOINT 0x25 24 25 /* Video Control Class Descriptors */ 26 #define VC_DESCRIPTOR_UNDEFINED 0x0 27 #define VC_HEADER 0x1 28 #define VC_INPUT_TERMINAL 0x2 29 #define VC_OUTPUT_TERMINAL 0x3 30 #define VC_SELECTOR_UNIT 0x4 31 #define VC_PROCESSING_UNIT 0x5 32 #define VC_EXTENSION_UNIT 0x6 33 34 /* Video Streaming Class Descriptors */ 35 #define VS_UNDEFINED 0x00 36 #define VS_INPUT_HEADER 0x01 37 #define VS_OUTPUT_HEADER 0x02 38 #define VS_STILL_IMAGE_FRAME 0x03 39 #define VS_FORMAT_UNCOMPRESSED 0x04 40 #define VS_FRAME_UNCOMPRESSED 0x05 41 #define VS_FORMAT_MJPEG 0x06 42 #define VS_FRAME_MJPEG 0x07 43 #define VS_FORMAT_MPEG2TS 0x0a 44 #define VS_FORMAT_DV 0x0c 45 #define VS_COLORFORMAT 0x0d 46 #define VS_FORMAT_FRAME_BASED 0x10 47 #define VS_FRAME_FRAME_BASED 0x11 48 #define VS_FORMAT_STREAM_BASED 0x12 49 50 #define EP_UNDEFINED 0x0 51 #define EP_GENERAL 0x1 52 #define EP_ENDPOINT 0x2 53 #define EP_INTERRUPT 0x3 54 55 #define RC_UNDEFINED 0x00 56 #define SET_CUR 0x01 57 #define GET_CUR 0x81 58 #define GET_MIN 0x82 59 #define GET_MAX 0x83 60 #define GET_RES 0x84 61 #define GET_LEN 0x85 62 #define GET_INFO 0x86 63 #define GET_DEF 0x87 64 65 #define VC_CONTROL_UNDEFINED 0x0 66 #define VC_VIDEO_POWER_MODE_CONTROL 0x1 67 #define VC_REQUEST_ERROR_CODE_CONTROL 0x2 68 69 #define TE_CONTROL_UNDEFINED 0x0 70 71 #define SU_CONTROL_UNDEFINED 0x0 72 #define SU_INPUT_SELECT_CONTROL 0x1 73 74 #define CT_CONTROL_UNDEFINED 0x0 75 #define CT_SCANNING_MODE_CONTROL 0x1 76 #define CT_AE_MODE_CONTROL 0x2 77 #define CT_AE_PRIORITY_CONTROL 0x3 78 #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x4 79 #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x5 80 #define CT_FOCUS_ABSOLUTE_CONTROL 0x6 81 #define CT_FOCUS_RELATIVE_CONTROL 0x7 82 #define CT_FOCUS_AUTO_CONTROL 0x8 83 #define CT_IRIS_ABSOLUTE_CONTROL 0x9 84 #define CT_IRIS_RELATIVE_CONTROL 0xa 85 #define CT_ZOOM_ABSOLUTE_CONTROL 0xb 86 #define CT_ZOOM_RELATIVE_CONTROL 0xc 87 #define CT_PANTILT_ABSOLUTE_CONTROL 0xd 88 #define CT_PANTILT_RELATIVE_CONTROL 0xe 89 #define CT_ROLL_ABSOLUTE_CONTROL 0xf 90 #define CT_ROLL_RELATIVE_CONTROL 0x10 91 #define CT_PRIVACY_CONTROL 0x11 92 93 #define PU_CONTROL_UNDEFINED 0x0 94 #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x1 95 #define PU_BRIGHTNESS_CONTROL 0x2 96 #define PU_CONTRAST_CONTROL 0x3 97 #define PU_GAIN_CONTROL 0x4 98 #define PU_POWER_LINE_FREQUENCY_CONTROL 0x5 99 #define PU_HUE_CONTROL 0x6 100 #define PU_SATURATION_CONTROL 0x7 101 #define PU_SHARPNESS_CONTROL 0x8 102 #define PU_GAMMA_CONTROL 0x9 103 #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0xa 104 #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0xb 105 #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0xc 106 #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0xd 107 #define PU_DIGITAL_MULTIPLIER_CONTROL 0xe 108 #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0xf 109 #define PU_HUE_AUTO_CONTROL 0x10 110 #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 111 #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 112 113 #define XU_CONTROL_UNDEFINED 0x0 114 115 #define VS_CONTROL_UNDEFINED 0x0 116 #define VS_PROBE_CONTROL 0x1 117 #define VS_COMMIT_CONTROL 0x2 118 #define VS_STILL_PROBE_CONTROL 0x3 119 #define VS_STILL_COMMIT_CONTROL 0x4 120 #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x5 121 #define VS_STREAM_ERROR_CODE_CONTROL 0x6 122 #define VS_GENERATE_KEY_FRAME_CONTROL 0x7 123 #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x8 124 #define VS_SYNCH_DELAY_CONTROL 0x9 125 126 typedef struct usbvc_class_descriptor { 127 uint8 length; 128 uint8 descriptorType; 129 uint8 descriptorSubtype; 130 } _PACKED usbvc_class_descriptor; 131 132 struct usbvc_input_header_descriptor { 133 uint8 length; 134 uint8 descriptorType; 135 uint8 descriptorSubtype; 136 uint8 numFormats; 137 uint16 totalLength; 138 uint8 endpointAddress; 139 uint8 info; 140 uint8 terminalLink; 141 uint8 stillCaptureMethod; 142 uint8 triggerSupport; 143 uint8 triggerUsage; 144 uint8 controlSize; 145 uint8 controls[0]; 146 } _PACKED; 147 148 struct usbvc_output_header_descriptor { 149 uint8 length; 150 uint8 descriptorType; 151 uint8 descriptorSubtype; 152 uint8 numFormats; 153 uint16 totalLength; 154 uint8 endpointAddress; 155 uint8 terminalLink; 156 uint8 controlSize; 157 uint8 controls[0]; 158 } _PACKED; 159 160 typedef uint8 usbvc_guid[16]; 161 162 struct usbvc_format_descriptor { 163 uint8 length; 164 uint8 descriptorType; 165 uint8 descriptorSubtype; 166 uint8 formatIndex; 167 uint8 numFrameDescriptors; 168 union { 169 struct { 170 usbvc_guid format; 171 uint8 bytesPerPixel; 172 uint8 defaultFrameIndex; 173 uint8 aspectRatioX; 174 uint8 aspectRatioY; 175 uint8 interlaceFlags; 176 uint8 copyProtect; 177 } uncompressed; 178 struct { 179 uint8 flags; 180 uint8 defaultFrameIndex; 181 uint8 aspectRatioX; 182 uint8 aspectRatioY; 183 uint8 interlaceFlags; 184 uint8 copyProtect; 185 } mjpeg; 186 }; 187 } _PACKED; 188 189 struct usbvc_frame_descriptor { 190 uint8 length; 191 uint8 descriptorType; 192 uint8 descriptorSubtype; 193 uint8 frameIndex; 194 uint8 capabilities; 195 uint16 width; 196 uint16 height; 197 uint32 minBitRate; 198 uint32 maxBitRate; 199 uint32 maxVideoFrameBufferSize; 200 uint32 defaultFrameInterval; 201 uint8 frameIntervalType; 202 union { 203 struct { 204 uint32 minFrameInterval; 205 uint32 maxFrameInterval; 206 uint32 frameIntervalStep; 207 } continuous; 208 uint32 discreteFrameIntervals[0]; 209 }; 210 } _PACKED; 211 212 typedef struct { 213 uint16 width; 214 uint16 height; 215 } _PACKED usbvc_image_size_pattern; 216 217 struct usbvc_still_image_frame_descriptor { 218 uint8 length; 219 uint8 descriptorType; 220 uint8 descriptorSubtype; 221 uint8 endpointAddress; 222 uint8 numImageSizePatterns; 223 usbvc_image_size_pattern imageSizePatterns[0]; 224 uint8 NumCompressionPatterns() const { return *(CompressionPatterns() - 1); } 225 const uint8* CompressionPatterns() const { 226 return ((const uint8*)imageSizePatterns + sizeof(usbvc_image_size_pattern) 227 * numImageSizePatterns + sizeof(uint8)); 228 } 229 } _PACKED; 230 231 struct usbvc_color_matching_descriptor { 232 uint8 length; 233 uint8 descriptorType; 234 uint8 descriptorSubtype; 235 uint8 colorPrimaries; 236 uint8 transferCharacteristics; 237 uint8 matrixCoefficients; 238 } _PACKED; 239 240 241 struct usbvc_interface_header_descriptor { 242 uint8 length; 243 uint8 descriptorType; 244 uint8 descriptorSubtype; 245 uint16 version; 246 uint16 totalLength; 247 uint32 clockFrequency; 248 uint8 numInterfacesNumbers; 249 uint8 interfaceNumbers[0]; 250 } _PACKED; 251 252 struct usbvc_input_terminal_descriptor { 253 uint8 length; 254 uint8 descriptorType; 255 uint8 descriptorSubtype; 256 uint8 terminalID; 257 uint16 terminalType; 258 uint8 associatedTerminal; 259 uint8 terminal; 260 } _PACKED; 261 262 struct usbvc_output_terminal_descriptor { 263 uint8 length; 264 uint8 descriptorType; 265 uint8 descriptorSubtype; 266 uint8 terminalID; 267 uint16 terminalType; 268 uint8 associatedTerminal; 269 uint8 sourceID; 270 uint8 terminal; 271 } _PACKED; 272 273 struct usbvc_camera_terminal_descriptor { 274 uint8 length; 275 uint8 descriptorType; 276 uint8 descriptorSubtype; 277 uint8 terminalID; 278 uint16 terminalType; 279 uint8 associatedTerminal; 280 uint8 terminal; 281 uint16 objectiveFocalLengthMin; 282 uint16 objectiveFocalLengthMax; 283 uint16 ocularFocalLength; 284 uint8 controlSize; 285 uint8 controls[0]; 286 } _PACKED; 287 288 struct usbvc_selector_unit_descriptor { 289 uint8 length; 290 uint8 descriptorType; 291 uint8 descriptorSubtype; 292 uint8 unitID; 293 uint8 numInputPins; 294 uint8 sourceID[0]; 295 uint8 Selector() const { return sourceID[numInputPins]; } 296 } _PACKED; 297 298 struct usbvc_processing_unit_descriptor { 299 uint8 length; 300 uint8 descriptorType; 301 uint8 descriptorSubtype; 302 uint8 unitID; 303 uint8 sourceID; 304 uint16 maxMultiplier; 305 uint8 controlSize; 306 uint8 controls[0]; 307 uint8 Processing() const { return controls[controlSize]; } 308 uint8 VideoStandards() const { return controls[controlSize+1]; } 309 } _PACKED; 310 311 struct usbvc_extension_unit_descriptor { 312 uint8 length; 313 uint8 descriptorType; 314 uint8 descriptorSubtype; 315 uint8 unitID; 316 usbvc_guid guidExtensionCode; 317 uint8 numControls; 318 uint8 numInputPins; 319 uint8 sourceID[0]; 320 uint8 ControlSize() const { return sourceID[numInputPins]; } 321 const uint8* Controls() const { return &sourceID[numInputPins+1]; } 322 uint8 Extension() const 323 { return sourceID[numInputPins + ControlSize() + 1]; } 324 } _PACKED; 325 326 struct usbvc_probecommit { 327 uint16 hint; 328 uint8 formatIndex; 329 uint8 frameIndex; 330 uint32 frameInterval; 331 uint16 keyFrameRate; 332 uint16 pFrameRate; 333 uint16 compQuality; 334 uint16 compWindowSize; 335 uint16 delay; 336 uint32 maxVideoFrameSize; 337 uint32 maxPayloadTransferSize; 338 uint32 clockFrequency; 339 uint8 framingInfo; 340 uint8 preferredVersion; 341 uint8 minVersion; 342 uint8 maxVersion; 343 void SetFrameInterval(uint32 interval) 344 { frameInterval = interval; } 345 } _PACKED; 346 347 348 #endif /* _USB_VIDEO_H */ 349