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 typedef struct usbvc_class_descriptor { 94 uint8 length; 95 uint8 descriptorType; 96 uint8 descriptorSubtype; 97 } _PACKED usbvc_class_descriptor; 98 99 struct usbvc_input_header_descriptor { 100 uint8 length; 101 uint8 descriptorType; 102 uint8 descriptorSubtype; 103 uint8 numFormats; 104 uint16 totalLength; 105 uint8 endpointAddress; 106 uint8 info; 107 uint8 terminalLink; 108 uint8 stillCaptureMethod; 109 uint8 triggerSupport; 110 uint8 triggerUsage; 111 uint8 controlSize; 112 uint8 controls[0]; 113 } _PACKED; 114 115 struct usbvc_output_header_descriptor { 116 uint8 length; 117 uint8 descriptorType; 118 uint8 descriptorSubtype; 119 uint8 numFormats; 120 uint16 totalLength; 121 uint8 endpointAddress; 122 uint8 terminalLink; 123 uint8 controlSize; 124 uint8 controls[0]; 125 } _PACKED; 126 127 typedef uint8 usbvc_guid[16]; 128 129 struct usbvc_format_descriptor { 130 uint8 length; 131 uint8 descriptorType; 132 uint8 descriptorSubtype; 133 uint8 formatIndex; 134 uint8 numFrameDescriptors; 135 union { 136 struct { 137 usbvc_guid format; 138 uint8 bytesPerPixel; 139 uint8 defaultFrameIndex; 140 uint8 aspectRatioX; 141 uint8 aspectRatioY; 142 uint8 interlaceFlags; 143 uint8 copyProtect; 144 } uncompressed; 145 struct { 146 uint8 flags; 147 uint8 defaultFrameIndex; 148 uint8 aspectRatioX; 149 uint8 aspectRatioY; 150 uint8 interlaceFlags; 151 uint8 copyProtect; 152 } mjpeg; 153 }; 154 } _PACKED; 155 156 struct usbvc_frame_descriptor { 157 uint8 length; 158 uint8 descriptorType; 159 uint8 descriptorSubtype; 160 uint8 frameIndex; 161 uint8 capabilities; 162 uint16 width; 163 uint16 height; 164 uint32 minBitRate; 165 uint32 maxBitRate; 166 uint32 maxVideoFrameBufferSize; 167 uint32 defaultFrameInterval; 168 uint8 frameIntervalType; 169 union { 170 struct { 171 uint32 minFrameInterval; 172 uint32 maxFrameInterval; 173 uint32 frameIntervalStep; 174 } continuous; 175 uint32 discreteFrameIntervals[0]; 176 }; 177 } _PACKED; 178 179 typedef struct { 180 uint16 width; 181 uint16 height; 182 } _PACKED usbvc_image_size_pattern; 183 184 struct usbvc_still_image_frame_descriptor { 185 uint8 length; 186 uint8 descriptorType; 187 uint8 descriptorSubtype; 188 uint8 endpointAddress; 189 uint8 numImageSizePatterns; 190 usbvc_image_size_pattern imageSizePatterns[0]; 191 uint8 NumCompressionPatterns() const { return *(CompressionPatterns() - 1); } 192 const uint8* CompressionPatterns() const { 193 return ((const uint8*)imageSizePatterns + sizeof(usbvc_image_size_pattern) 194 * numImageSizePatterns + sizeof(uint8)); 195 } 196 } _PACKED; 197 198 struct usbvc_color_matching_descriptor { 199 uint8 length; 200 uint8 descriptorType; 201 uint8 descriptorSubtype; 202 uint8 colorPrimaries; 203 uint8 transferCharacteristics; 204 uint8 matrixCoefficients; 205 } _PACKED; 206 207 208 struct usbvc_interface_header_descriptor { 209 uint8 length; 210 uint8 descriptorType; 211 uint8 descriptorSubtype; 212 uint16 version; 213 uint16 totalLength; 214 uint32 clockFrequency; 215 uint8 numInterfacesNumbers; 216 uint8 interfaceNumbers[0]; 217 } _PACKED; 218 219 struct usbvc_input_terminal_descriptor { 220 uint8 length; 221 uint8 descriptorType; 222 uint8 descriptorSubtype; 223 uint8 terminalID; 224 uint16 terminalType; 225 uint8 associatedTerminal; 226 uint8 terminal; 227 } _PACKED; 228 229 struct usbvc_output_terminal_descriptor { 230 uint8 length; 231 uint8 descriptorType; 232 uint8 descriptorSubtype; 233 uint8 terminalID; 234 uint16 terminalType; 235 uint8 associatedTerminal; 236 uint8 sourceID; 237 uint8 terminal; 238 } _PACKED; 239 240 struct usbvc_camera_terminal_descriptor { 241 uint8 length; 242 uint8 descriptorType; 243 uint8 descriptorSubtype; 244 uint8 terminalID; 245 uint16 terminalType; 246 uint8 associatedTerminal; 247 uint8 terminal; 248 uint16 objectiveFocalLengthMin; 249 uint16 objectiveFocalLengthMax; 250 uint16 ocularFocalLength; 251 uint8 controlSize; 252 uint8 controls[0]; 253 } _PACKED; 254 255 struct usbvc_selector_unit_descriptor { 256 uint8 length; 257 uint8 descriptorType; 258 uint8 descriptorSubtype; 259 uint8 unitID; 260 uint8 numInputPins; 261 uint8 sourceID[0]; 262 uint8 Selector() const { return sourceID[numInputPins]; } 263 } _PACKED; 264 265 struct usbvc_processing_unit_descriptor { 266 uint8 length; 267 uint8 descriptorType; 268 uint8 descriptorSubtype; 269 uint8 unitID; 270 uint8 sourceID; 271 uint16 maxMultiplier; 272 uint8 controlSize; 273 uint8 controls[0]; 274 uint8 Processing() const { return controls[controlSize]; } 275 uint8 VideoStandards() const { return controls[controlSize+1]; } 276 } _PACKED; 277 278 struct usbvc_extension_unit_descriptor { 279 uint8 length; 280 uint8 descriptorType; 281 uint8 descriptorSubtype; 282 uint8 unitID; 283 usbvc_guid guidExtensionCode; 284 uint8 numControls; 285 uint8 numInputPins; 286 uint8 sourceID[0]; 287 uint8 ControlSize() const { return sourceID[numInputPins]; } 288 const uint8* Controls() const { return &sourceID[numInputPins+1]; } 289 uint8 Extension() const 290 { return sourceID[numInputPins + ControlSize() + 1]; } 291 } _PACKED; 292 293 294 #endif /* _USB_VIDEO_H */ 295