SAMV71 Xplained Ultra Software Package 1.4

USBVideo.h

00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 /** \cond usb_video */
00030 /** \file */
00031 
00032 #ifndef _USBVID_H_
00033 #define _USBVID_H_
00034 /** \addtogroup usb_video
00035  *@{
00036  */
00037 
00038 /*----------------------------------------------------------------------------
00039  *         Includes
00040  *----------------------------------------------------------------------------*/
00041  
00042 #include <stdint.h>
00043 #include <USBRequests.h>
00044 /*----------------------------------------------------------------------------
00045  *         Definitions
00046  *----------------------------------------------------------------------------*/
00047 
00048 /* Video Interface Class Code */
00049 #define CC_VIDEO                        0x0E
00050 /* Video Interface Subclass Code */
00051 #define SC_UNDEFINED                    0x00
00052 #define SC_VIDEOCONTROL                 0x01
00053 #define SC_VIDEOSTREAMING               0x02
00054 #define SC_VIDEO_INTERFACE_COLLECTION   0x03
00055 /* Video Interface Protocol Codes */
00056 #define PC_PROTOCOL_UNDEFINED           0x00
00057 /* Video Class-Specific Descriptor Types */
00058 #define CS_UNDEFINED                    0x20
00059 #define CS_DEVICE                       0x21
00060 #define CS_CONFIGURATION                0x22
00061 #define CS_STRING                       0x23
00062 #define CS_INTERFACE                    0x24
00063 #define CS_ENDPOINT                     0x25
00064 /* Video Class-Specific VC Interface Descriptor Subtypes */
00065 #define VC_DESCRIPTOR_UNDEFINED         0x00
00066 #define VC_HEADER                       0x01
00067 #define VC_INPUT_TERMINAL               0x02
00068 #define VC_OUTPUT_TERMINAL              0x03
00069 #define VC_SELECTOR_UNIT                0x04
00070 #define VC_PROCESSING_UNIT              0x05
00071 #define VC_EXTENSION_UNIT               0x06
00072 /* Video Class-Specific VS Interface Descriptor Subtypes */
00073 #define VS_UNDEFINED                    0x00
00074 #define VS_INPUT_HEADER                 0x01
00075 #define VS_OUTPUT_HEADER                0x02
00076 #define VS_STILL_IMAGE_FRAME            0x03
00077 #define VS_FORMAT_UNCOMPRESSED          0x04
00078 #define VS_FRAME_UNCOMPRESSED           0x05
00079 #define VS_FORMAT_MJPEG                 0x06
00080 #define VS_FRAME_MJPEG                  0x07
00081 #define VS_FORMAT_MPEG1                 0x08
00082 #define VS_FORMAT_MPEG2PS               0x09
00083 #define VS_FORMAT_MPEG2TS               0x0A
00084 #define VS_FORMAT_MPEG4SL               /* TBD(not 0x0B) */
00085 #define VS_FORMAT_DV                    0x0C
00086 #define VS_COLORFORMAT                  0x0D
00087 #define VS_FORMAT_VENDOR                0x0E
00088 #define VS_FRAME_VENDOR                 0x0F
00089 /* Video Class-Specific Endpoint Descriptor Subtypes */
00090 #define EP_UNDEFINED                    0x00
00091 #define EP_GENERAL                      0x01
00092 #define EP_ENDPOINT                     0x02
00093 #define EP_INTERRUPT                    0x03
00094 /* USB Terminal Types */
00095 #define TT_VENDOR_SPECIFIC              0x0100
00096 #define TT_STREAMING                    0x0101
00097 /* Input Terminal Types */
00098 #define ITT_VENDOR_SPECIFIC             0x0200
00099 #define ITT_CAMERA                      0x0201
00100 #define ITT_MEDIA_TRANSPORT_INPUT       0x0202
00101 /* Output Terminal Types */
00102 #define OTT_VENDOR_SPECIFIC             0x0300
00103 #define OTT_DISPLAY                     0x0301
00104 #define OTT_MEDIA_TRANSPORT_OUTPUT      0x0302
00105 /* External Terminal Types */
00106 #define EXTERNAL_VENDOR_SPECIFIC        0x0400
00107 #define COMPOSITE_CONNECTOR             0x0401
00108 #define SVIDEO_CONNECTOR                0x0402
00109 #define COMPONENT_CONNECTOR             0x0403
00110 /* Compression formats GUID */
00111 #define guidYUY2    {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}}
00112 #define guidNV12    {0x3231564E, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}}
00113 
00114 /* Video Class-Specific Request Codes */
00115 #define RC_UNDEFINED                    0x00
00116 #define SET_CUR                         0x01
00117 #define GET_CUR                         0x81
00118 #define GET_MIN                         0x82
00119 #define GET_MAX                         0x83
00120 #define GET_RES                         0x84
00121 #define GET_LEN                         0x85
00122 #define GET_INFO                        0x86
00123 #define GET_DEF                         0x87
00124 /* VideoControl Interface Control Selectors */
00125 #define VC_CONTROL_UNDEFINED                    0x00
00126 #define VC_VIDEO_POWER_MODE_CONTROL             0x01
00127 #define VC_REQUEST_ERROR_CODE_CONTROL           0x02
00128 #define VC_REQUEST_INDICATE_HOST_CLOCK_CONTROL  0x03
00129 /* Terminal Control Selectors */
00130 #define TE_CONTROL_UNDEFINED            0x00
00131 /* Selector Unit Control Selectors */
00132 #define SU_CONTROL_UNDEFINED            0x00
00133 #define SU_INPUT_SELECT_CONTROL         0x01
00134 /* Camera Terminal Control Selectors */
00135 #define CT_CONTROL_UNDEFINED                0x00
00136 #define CT_SCANNING_MODE_CONTROL            0x01
00137 #define CT_AE_MODE_CONTROL                  0x02
00138 #define CT_AE_PRIORITY_CONTROL              0x03
00139 #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL   0x04
00140 #define CT_EXPOSURE_TIME_RELATIVE_CONTROL   0x05
00141 #define CT_FOCUS_ABSOLUTE_CONTROL           0x06
00142 #define CT_FOCUS_RELATIVE_CONTROL           0x07
00143 #define CT_FOCUS_AUTO_CONTROL               0x08
00144 #define CT_IRIS_ABSOLUTE_CONTROL            0x09
00145 #define CT_IRIS_RELATIVE_CONTROL            0x0A
00146 #define CT_ZOOM_ABSOLUTE_CONTROL            0x0B
00147 #define CT_ZOOM_RELATIVE_CONTROL            0x0C
00148 #define CT_PANTILT_ABSOLUTE_CONTROL         0x0D
00149 #define CT_PANTILT_RELATIVE_CONTROL         0x0E
00150 #define CT_ROLL_ABSOLUTE_CONTROL            0x0F
00151 #define CT_ROLL_RELATIVE_CONTROL            0x10
00152 #define CT_PRIVACY_CONTROL                  0x11
00153 /* Processing Unit Control Selectors */
00154 #define PU_CONTROL_UNDEFINED                0x00
00155 #define PU_BACKLIGHT_COMPENSATION_CONTROL   0x01
00156 #define PU_BRIGHTNESS_CONTROL               0x02
00157 #define PU_CONTRAST_CONTROL                 0x03
00158 #define PU_GAIN_CONTROL                     0x04
00159 #define PU_POWER_LINE_FREQUENCY_CONTROL     0x05
00160 #define PU_HUE_CONTROL                      0x06
00161 #define PU_STATURATION_CONTROL              0x07
00162 #define PU_SHARPNESS_CONTROL                0x08
00163 #define PU_GAMMA_CONTROL                    0x09
00164 #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL        0x0A
00165 #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL   0x0B
00166 #define PU_WHITE_BALANCE_COMPONENT_CONTROL          0x0C
00167 #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL     0x0D
00168 #define PU_DIGITAL_MULTIPLIER_CONTROL               0x0E
00169 #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL         0x0F
00170 #define PU_HUE_AUTO_CONTROL                         0x10
00171 /* Extension Unit Control Selectors */
00172 #define XU_CONTROL_UNDEFINED                0x00
00173 /* VideoStreaming Interface Control Selectors */
00174 #define VS_CONTROL_UNDEFINED                0x00
00175 #define VS_PROBE_CONTROL                    0x01
00176 #define VS_COMMIT_CONTROL                   0x02
00177 #define VS_STILL_PROBE_CONTROL              0x03
00178 #define VS_STILL_COMMIT_CONTROL             0x04
00179 #define VS_STILL_IMAGE_TRIGGER_CONTROL      0x05
00180 #define VS_STREAM_ERROR_CODE_CONTROL        0x06
00181 #define VS_GENERATE_KEY_FRAME_CONTROL       0x07
00182 #define VS_UPDATE_FRAME_SEGMENT_CONTROL     0x08
00183 #define VS_SYNCH_DELAY_CONTROL              0x09
00184 
00185 /** \addtogroup usb_video_desc_type USB Video descriptor types
00186  *      @{
00187  * This section lists the available types for USB video-specific descriptors.
00188  */
00189 
00190 /** Descriptor gives detail about the whole device (CS_DEVICE).*/
00191 #define VIDGenericDescriptor_DEVICE                     0x21
00192 /** Descriptor gives detail about a configuration (CS_CONFIGURATION).*/
00193 #define VIDGenericDescriptor_CONFIGURATION              0x22
00194 /** Descriptor gives detail about a string (CS_STRING).*/
00195 #define VIDGenericDescriptor_STRING                     0x23
00196 /** Descriptor gives detail about an interface (CS_INTERFACE).*/
00197 #define VIDGenericDescriptor_INTERFACE                  0x24
00198 /** Descriptor gives detail about an endpoint (CS_ENDPOINT).  */
00199 #define VIDGenericDescriptor_ENDPOINT                   0x25
00200 /**     @}*/
00201 
00202 /** \addtogroup usb_video_desc_subtype USB Video descriptor subtypes
00203  *      @{
00204  * This section lists the possible subtypes for USB video-specific descriptors.
00205  */
00206 /** Header descriptor subtype(VC_HEADER).*/
00207 #define VIDGenericDescriptor_HEADER                     0x01
00208 /** Input terminal descriptor subtype(VC_INPUT_TERMINAL).*/
00209 #define VIDGenericDescriptor_INPUTTERMINAL              0x02
00210 /** Output terminal descriptor subtype(VC_OUTPUT_TERMINAL).*/
00211 #define VIDGenericDescriptor_OUTPUTTERMINAL             0x03
00212 /** Selector unit descriptor subtype(VC_SELECTOR_UNIT).*/
00213 #define VIDGenericDescriptor_SELECTORUNIT               0x04
00214 /** Processing unit descriptor subtype(VC_PROCESSING_UNIT).*/
00215 #define VIDGenericDescriptor_PROCESSINGUNIT             0x05
00216 /** Extension unit descriptor subtype(VC_EXTENSION_UNIT).*/
00217 #define VIDGenericDescriptor_EXTENSIONUNIT              0x06
00218 /**     @}*/
00219 
00220 
00221 /** \addtogroup usb_video_desc USB Video Descriptors
00222  *      @{
00223  * USB Video device descriptor values
00224  *
00225  * This section lists the class, subclass & protocol codes that a USB video
00226  * device should display in its device descriptor.
00227  */
00228 /** Class code for a USB video device. */
00229 #define VIDDeviceDescriptor_CLASS                           0xEF
00230 /** Subclass code for a USB video device. */
00231 #define VIDDeviceDescriptor_SUBCLASS                        0x02
00232 /** Protocol code for a USB video device. */
00233 #define VIDDeviceDescriptor_PROTOCOL                        0x01
00234 /**     @}*/
00235 
00236 /** \addtogroup usb_iad USB IAD
00237  *      @{
00238  */
00239 /** Video Interface Class Code (CC_VIDEO) */
00240 #define VIDIADDescriptor_CLASS                              0x0E
00241 /** Video Interface SubClass Code (SC_VIDEO_INTERFACE_COLLECTION) */
00242 #define VIDIADDescriptor_SUBCLASS                           0x03
00243 /** Protocol (PC_PROTOCOL_UNDEFINED) */
00244 #define VIDIADDescriptor_PROTOCOL                           0x00
00245 /**     @}*/
00246 
00247 /** \addtogroup usb_video_ctrl_if USB Video Control Interface
00248  *      @{
00249  * This section lists the class, subclass and protocol codes that a USB Video
00250  * Control interface descriptor should display.
00251  */
00252 /** Class code for an video control interface (CC_VIDEO). */
00253 #define VIDControlInterfaceDescriptor_CLASS                 0x0E
00254 /** Subclass code for an video control interface (SC_VIDEOCONTROL). */
00255 #define VIDControlInterfaceDescriptor_SUBCLASS              0x01
00256 /** Protocol code for an video control interface (PC_PROTOCOL_UNDEFINED). */
00257 #define VIDControlInterfaceDescriptor_PROTOCOL              0x00
00258 /**     @}*/
00259 
00260 /**
00261  *  \addtogroup usb_video_stream_if USB VideoStreaming interface codes
00262  *      @{
00263  * This section lists the class, subclass and protocol codes that an Video
00264  * Streaming interface should display in its descriptor.
00265  */
00266 /** Class code for an USB video streaming interface (CC_VIDEO).*/
00267 #define VIDStreamingInterfaceDescriptor_CLASS               0x0E
00268 /** Subclass code for an video streaming interface (SC_VIDEOSTREAMING).*/
00269 #define VIDStreamingInterfaceDescriptor_SUBCLASS            0x02
00270 /** Protocol code for an video streaming interface (PC_PROTOCOL_UNDEFINED).*/
00271 #define VIDStreamingInterfaceDescriptor_PROTOCOL            0x00
00272 /**     @}*/
00273 
00274 /**
00275  * \addtogroup usb_video_stream_subtype USB Video streaming descriptor subtypes
00276  *      @{
00277  * This section lists the possible subtypes for video-specific descriptor
00278  * appended to an Video Streaming interface.
00279  */
00280 /** Undefined */
00281 #define VIDStreamingInterfaceDescriptor_UNDEFINED           0x00
00282 /** Input header.*/
00283 #define VIDStreamingInterfaceDescriptor_INPUTHEADER         0x01
00284 /** Output Header.*/
00285 #define VIDStreamingInterfaceDescriptor_OUTPUTHEADER        0x02
00286 /** Still Image Frame.*/
00287 #define VIDStreamingInterfaceDescriptor_STI_FRAME           0x03
00288 #define VIDStreamingInterfaceDescriptor_FMT_UNCOMPRESSED    0x04
00289 #define VIDStreamingInterfaceDescriptor_FRM_UNCOMPRESSED    0x05
00290 #define VIDStreamingInterfaceDescriptor_FMT_MJPEG           0x06
00291 #define VIDStreamingInterfaceDescriptor_FRM_MJPEG           0x07
00292 #define VIDStreamingInterfaceDescriptor_FMT_MPEG1           0x08
00293 #define VIDStreamingInterfaceDescriptor_FMT_MPEG2PS         0x09
00294 #define VIDStreamingInterfaceDescriptor_FMT_MPEG2TS         0x0A
00295 #define VIDStreamingInterfaceDescriptor_FMT_DV              0x0C
00296 #define VIDStreamingInterfaceDescriptor_COLORFORMAT         0x0D
00297 #define VIDStreamingInterfaceDescriptor_FMT_VENDOR          0x0E
00298 #define VIDStreamingInterfaceDescriptor_FRM_VENDOR          0x0F
00299 /**     @}*/
00300 
00301 /** \addtogroup usb_video_ep_subtype USB Video Endpoint descriptor subtypes
00302  *      @{
00303  */
00304 /** EP_UNDEFINED */
00305 #define VIDEndpointDescriptor_UNDEFINED         0x00
00306 /** EP_GENERAL */
00307 #define VIDEndpointDescriptor_GENERAL           0x01
00308 /** EP_ENDPOINT */
00309 #define VIDEndpointDescriptor_ENDPOINT          0x02
00310 /** EP_INTERRUPT */
00311 #define VIDEndpointDescriptor_INTERRUPT         0x03
00312 /**     @}*/
00313 
00314 /** \addtogroup usb_video_class_ver USB Video class releases
00315  *      @{
00316  * This section lists the existing versions of the Video class specification.
00317  * - \ref VIDHeaderDescriptor_VID1_00
00318  */
00319  
00320 /** Identifies the USB video specification release 1.00.*/
00321 #define VIDHeaderDescriptor_VID1_00                 0x0110
00322 /**     @}*/
00323 
00324 /** TT_STREAMING */
00325 #define VIDTerminalDescriptor_STREAMING             0x0101
00326 
00327 /** \addtogroup usb_video_in_term USB Video Input terminal types
00328  *  @{
00329  * This section lists the available types for an Input terminal.
00330  */
00331 /** ITT_VENDOR_SPECIFIC */
00332 #define VIDInputTerminalDescriptor_VENDOR           0x0200
00333 /** ITT_CAMERA */
00334 #define VIDInputTerminalDescriptor_CAMERA           0x0201
00335 /** ITT_MEDIA_TRANSPORT_INPUT */
00336 #define VIDInputTerminalDescriptor_MED_TRAN_INPUT   0x0202
00337 /** @}*/
00338 
00339 /** \addtogroup usb_video_out_term USB Video Output terminal types
00340  *  @{
00341  * This section lists the available types for an output terminal.
00342  */
00343 /** OTT_VENDOR_SPECIFIC */
00344 #define VIDOutputTerminalDescriptor_VENDOR              0x0300
00345 /** OTT_DISPLAY */
00346 #define VIDOutputTerminalDescriptor_DISPLAY             0x0301
00347 /** OTT_MEDIA_TRANSPORT_OUTPUT */
00348 #define VIDOutputTerminalDescriptor_MED_TRAN_OUTPUT     0x0302
00349 /** @}*/
00350 
00351 /** \addtogroup usb_video_out_term USB Video External terminal types
00352  *  @{
00353  * This section lists the available types for an external terminal.
00354  */
00355 /** OTT_VENDOR_SPECIFIC */
00356 #define VIDExtTerminalDescriptor_VENDOR              0x0400
00357 /** COMPOSITE_CONNECTOR */
00358 #define VIDExtTerminalDescriptor_COMPOSITE_CONN      0x0401
00359 /** SVIDEO_CONNECTOR */
00360 #define VIDExtTerminalDescriptor_SVID_CONN           0x0402
00361 /** COMPONENT_CONNECTOR */
00362 #define VIDExtTerminalDescriptor_COMPONENT_CONN      0x0403
00363 /** @}*/
00364 
00365 /** \addtogroup usb_video_request USB Video request codes
00366  *      @{
00367  * This section lists the codes of the existing Video requests.
00368  */
00369 /** SET_CUR request code.*/
00370 #define VIDGenericRequest_SETCUR                0x01
00371 /** GET_CUR request code.*/
00372 #define VIDGenericRequest_GETCUR                0x81
00373 /** GET_MIN request code.*/
00374 #define VIDGenericRequest_GETMIN                0x82
00375 /** GET_MAX request code.*/
00376 #define VIDGenericRequest_GETMAX                0x83
00377 /** GET_RES request code.*/
00378 #define VIDGenericRequest_GETRES                0x84
00379 #define VIDGenericRequest_GETLEN                0x85
00380 #define VIDGenericRequest_GETINFO               0x86
00381 #define VIDGenericRequest_GETDEF                0x87
00382 /**     @}*/
00383 
00384 
00385 
00386 /*----------------------------------------------------------------------------
00387  *         Types
00388  *----------------------------------------------------------------------------*/
00389  
00390 COMPILER_PACK_SET(1)
00391 
00392 /** GUID */
00393 typedef struct _sGDID {
00394     uint32_t data1;
00395     uint16_t data2;
00396     uint16_t data3;
00397     uint8_t  data4[8];
00398 } sGUID; /* GCC */
00399 
00400 /* USB Video, 2.4.2.2 */
00401 /**
00402  * Status packet header
00403  */
00404 typedef struct _USBVideoStatusHdr {
00405     uint8_t bStatusType; /**< Originator VideoControl(1) or VideoStreaming(2) */
00406     uint8_t bOriginator; /**< ID of the Terminal, Unit or Interface */
00407 }  USBVideoStatusHdr; /* GCC */
00408 /**
00409  * Status packet for VideoControl Interface
00410  */
00411 typedef struct _USBVideoStatusVC {
00412     uint8_t bStatusType; /**< Originator: VideoControl(1) */
00413     uint8_t bOriginator; /**< ID of the Terminal, Unit or Interface */
00414     uint8_t bEvent;      /**< 0x00: Control Change */
00415     uint8_t bSelector;   /**< Control change selector */
00416     uint8_t bAttribute;  /**< Type of control change: value(0), info(1), failure(2) */
00417     uint8_t bValue;      /**< Control request description value \sa "VideoControl Requests" */
00418 } USBVideoStatusVC;
00419 /**
00420  * Status packet for VideoStreaming Interface
00421  */
00422 typedef struct _USBVideoStatusVS {
00423     uint8_t bStatusType; /**< Originator VideoStreaming(2) */
00424     uint8_t bOriginator; /**< ID of the Terminal, Unit or Interface */
00425     uint8_t bEvent;      /**< 0x00: Button Press, others: Stream Error */
00426     uint8_t bValue;      /**< Button Pressed/Released */
00427 } USBVideoStatusVS; /* GCC */
00428 
00429 /* USB Video, 2.4.3.3 */
00430 /**
00431  * Payload Header
00432  */
00433 typedef struct _USBVideoPayloadHeader {
00434     uint8_t bHeaderLength; /**< Length of header including this field */
00435     union _USBVideoHeaderInfo {
00436         uint8_t B;
00437         struct _USBVideoHeaderInfoBits {
00438             uint8_t FID:1, /**< D0: Frame ID */
00439                     EoF:1, /**< D1: End of Frame */
00440                     PTS:1, /**< D2: Presentation Time */
00441                     SCR:1, /**< D3: Source Clock Reference */
00442                     reserved:1,
00443                     STI:1, /**< D4: Still Image */
00444                     ERR:1, /**< D5: Error */
00445                     EOH:1; /**< D6: End of Header */
00446         } bm;
00447     } bmHeaderInfo;  /**< Information on the sample data following header */
00448 } USBVideoPayloadHeader;
00449 /**
00450  * Payload header with extended fields
00451  */
00452 typedef struct _USBVideoPayloadHdrExt {
00453     uint8_t  bHeaderLength; /**< Length of header including this field */
00454     uint8_t  bmHeaderInfo;  /**< Information on the sample data following header */
00455     uint32_t dwPresentationTime; /**< Source Clock Time in native device clock units when the raw frame capture begins */
00456     struct _SourceClockReference {
00457         uint32_t dwSrcTimeClk;  /**< Source Time Clock in native device clock units */
00458         uint16_t sofCounter:11, /**< 1KHz SOF token counter */
00459                  reserved;      /**< Reserved, 0 */
00460     } scrSourceClock; /**< SourceClockReference SCR */
00461 }  USBVideoPayloadHdrExt;
00462 
00463 /* USB Video, 3.7.2 */
00464 /**
00465  * Class-specific VideoControl Interface Header Descriptor
00466  * (With 1 streaming interface).
00467  */
00468 typedef struct _USBVideoControlInterfaceDescriptor {
00469     uint8_t  bLength; /**< Size of descriptor: 12 + 1 bytes */
00470     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00471     uint8_t  bDescriptorSubType; /**< VC_HEADER descriptor subtype */
00472     uint16_t bcdVDC; /**< Video Device Class Specification release number in BCD */
00473     uint16_t wTotalLength; /**< Total number of bytes, including combined header and all unit and terminal descriptors */
00474     uint32_t dwClockFrequency; /**< Device clock frequency in Hz */
00475     uint8_t  bInCollection; /**< Number of VS interfaces in the Video Interface Collection */
00476     uint8_t  baInterfaceNr[1]; /**< Interface numbers of the VS interface in collection */
00477 }USBVideoControlInterfaceDescriptor;
00478 /**
00479  * Input Terminal Descriptor (ITD)
00480  * (With no additional fields depending on the Terminal Type)
00481  */
00482 typedef struct _USBVideoInputTerminalDescriptor {
00483     uint8_t  bLength; /**< Size of descriptor: 8 + 0 bytes */
00484     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00485     uint8_t  bDescriptorSubType; /**< VC_INPUTTERMINAL descriptor subtype */
00486     uint8_t  bTerminalID; /**< None-zero Terminal ID */
00487     uint16_t wTerminalType; /**< Type of Terminal */
00488     uint8_t  bAssocTerminal; /**< ID of the output terminal to which this input terminal is associated */
00489     uint8_t  iTerminal; /**< Index of string descriptor */
00490 } USBVideoInputTerminalDescriptor;
00491 /**
00492  * Output Terminal Descriptor (OTD)
00493  * (With no additional fields depending on the Terminal Type)
00494  */
00495 typedef struct _USBVideoOutputTerminalDescriptor {
00496     uint8_t  bLength; /**< Size of descriptor: 9 + 0 bytes */
00497     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00498     uint8_t  bDescriptorSubType; /**< VC_OUTPUT_TERMINAL descriptor subtype */
00499     uint8_t  bTerminalID; /**< None-zero Terminal ID */
00500     uint16_t wTerminalType; /**< Type of Terminal */
00501     uint8_t  bAssocTerminal; /**< Input Terminal to which this Output Terminal is connected */
00502     uint8_t  bSourceID; /**< ID of the Unit or Terminal to which this terminal is connected */
00503     uint8_t  iTerminal; /**< Index of string descriptor */
00504 } USBVideoOutputTerminalDescriptor;
00505 /**
00506  * Camera Terminal Descriptor
00507  */
00508 typedef struct _USBVideoCameraTerminalDescriptor {
00509     uint8_t  bLength; /**< Size of descriptor: 15 + 3 bytes */
00510     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00511     uint8_t  bDescriptorSubType; /**< VC_INPUT_TERMINAL descriptor subtype */
00512     uint8_t  bTerminalID; /**< None-zero Terminal ID */
00513     uint16_t wTerminalType; /**< Type of Terminal: ITT_CAMERA */
00514     uint8_t  bAssocTerminal; /**< ID of the output terminal to which this input terminal is associated */
00515     uint8_t  iTerminal; /**< Index of string descriptor */
00516     uint16_t wObjectiveFocalLengthMin;
00517     uint16_t wObjectiveFocalLengthMax;
00518     uint16_t wOcularFocalLength;
00519     uint8_t  bControlSize; /**< Size in bytes of bmControls: 3 */
00520     uint8_t  bmControls[3];
00521 } USBVideoCameraTerminalDescriptor;
00522 /**
00523  * Selector Unit Descriptor (SUD)
00524  * (with 1 input pin)
00525  */
00526 typedef struct _USBVideoSelectorUnitDescriptor {
00527     uint8_t  bLength; /**< Size of descriptor: 6 + 1 bytes */
00528     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00529     uint8_t  bDescriptorSubType; /**< VC_SELECTOR_UNIT descriptor subtype */
00530     uint8_t  bUnitID; /**< None-zero Unit ID */
00531     uint8_t  bNrInPins; /**< Number of Input Pins of this Unit */
00532     uint8_t  baSourceID[1]; /**< ID of the Unit or Terminal to which the Input Pins is connected */
00533     uint8_t  iSelector; /**< Index of string descriptor */
00534 } USBVideoSelectorUnitDescriptor;
00535 /**
00536  * Processing Unit Descriptor (PUD)
00537  */
00538 typedef struct _USBVideoProcessingUnitDescriptor {
00539     uint8_t  bLength; /**< Size of descriptor: 9 + 2 bytes */
00540     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00541     uint8_t  bDescriptorSubType; /**< VC_PROCESSING_UNIT descriptor subtype */
00542     uint8_t  bUnitID; /**< None-zero Unit ID */
00543     uint8_t  bSourceID; /**< ID of the Unit or Terminal to which this Unit is connected */
00544     uint16_t wMaxMultiplier; /**< Max digital magnification, multiplied by 100 */
00545     uint8_t  bControlSize; /**< Size of bmControls: 2 */
00546     uint8_t  bmControls[2];
00547     uint8_t  iProcessing; /**< Index of string descriptor */
00548 } USBVideoProcessingUnitDescriptor;
00549 /**
00550  * Extension Unit Descriptor (XUD)
00551  * (with 1 input pin)
00552  */
00553 typedef struct _USBVideoExtensionUnitDescriptor {
00554     uint8_t  bLength; /**< Size of descriptor: 24 + 1 + 1 bytes */
00555     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00556     uint8_t  bDescriptorSubType; /**< VC_EXTENSION_UNIT descriptor subtype */
00557     uint8_t  bUnitID; /**< None-zero Unit ID */
00558     sGUID    guidExtensionCode; /**< Vendor-specific code identifying the Extension Unit */
00559     uint8_t  bNumControls; /**< Number of controls in this extension unit */
00560     uint8_t  bNrInPins; /**< Number of Input Pins of this Unit */
00561     uint8_t  baSourceID[1]; /** ID of the Unit or Terminal to which the Input Pins of this extension unit is connected */
00562     uint8_t  bControlSize; /**< Size of bmControls field */
00563     uint8_t  bmControls[1];
00564     uint8_t  iExtension; /**< Index of string descriptor */
00565 }  USBVideoExtensionUnitDescriptor;
00566 
00567 /* USB Video, 3.8.2.2 */
00568 /**
00569  * Class-specific VC Interrupt Endpoint Descriptor
00570  */
00571 typedef struct _USBVideoControlInterruptEndpointDescriptor {
00572     uint8_t  bLength; /**< Size of descriptor: 5 bytes */
00573     uint8_t  bDescriptorType; /**< CS_ENDPOINT descriptor type */
00574     uint8_t  bDescriptorSubType; /**< EP_INTERRUPT descriptor subtype */
00575     uint16_t wMaxTransferSize; /**< Max interrupt structure size */
00576 } USBVideoControlInterruptEndpointDescriptor;
00577 
00578 /* USB Video, 3.9.2 */
00579 /**
00580  * Class-specific VS Interface Input Header Descriptor
00581  * (with 1 format)
00582  */
00583 typedef struct _USBVideoStreamingInputHeaderDescriptor {
00584     uint8_t  bLength; /**< Size of descriptor: 13 + (1*1) bytes */
00585     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00586     uint8_t  bDescriptorSubType; /**< VS_INPUT_HEADER descriptor subtype */
00587     uint8_t  bNumFormats; /**< Number of video payload format descriptors following (excluding frame descriptors) */
00588     uint16_t wTotalLength; /**< Total number of bytes returned for the VS interface descriptors */
00589     uint8_t  bEndpointAddress; /**< EP address for video data */
00590     uint8_t  bmInfo; /**< Capabilities, D0: Dynamic Format Change Supported */
00591     uint8_t  bTerminalLink; /**< Terminal ID of the Output Terminal to which the video EP is connected */
00592     uint8_t  bStillCaptureMethod; /**< Method of still image capture */
00593     uint8_t  bTriggerSupport; /**< If hardware trigger is supported */
00594     uint8_t  bTriggerUsage; /**< How host respond to HW trigger interrupt event: 0 initialize still image capture, 1 general purpose button */
00595     uint8_t  bControlSize; /**< Size of each bmaControls(x):8 */
00596     uint8_t  bmaControls[1][1];
00597 }  USBVideoStreamingInputHeaderDescriptor;
00598 /**
00599  * Class-specific VS Interface Output Header Descriptor
00600  */
00601 typedef struct _USBVideoStreamingOutputHeaderDescriptor {
00602     uint8_t  bLength; /**< Size of descriptor: 8 bytes */
00603     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00604     uint8_t  bDescriptorSubType; /**< VS_OUTPUT_HEADER descriptor subtype */
00605     uint8_t  bNumFormats; /**< Number of video payload format descriptors following (excluding frame descriptors) */
00606     uint16_t wTotalLength; /**< Total number of bytes returned for the VS interface descriptors */
00607     uint8_t  bEndpointAddress; /**< EP address for video data */
00608     uint8_t  bTerminalLink; /**< Terminal ID of the Input Terminal to which the video EP is connected */
00609 }  USBVideoStreamingOutputHeaderDescriptor;
00610 
00611 /* USB Video Payload Uncompressed, 2.3 */
00612 /**
00613  * Stream Header Format for Uncompressed Streams
00614  */
00615 typedef USBVideoPayloadHeader USBVideoUncompressedStreamHeader;
00616 /**
00617  * Stream Header Format for Uncompressed Streams with extension
00618  */
00619 typedef USBVideoPayloadHdrExt USBVideoUncompressedStreamHeaderExt;
00620 
00621 /* USB Video Payload Uncompressed, 3.1 */
00622 /**
00623  * Uncompressed Video Format Descriptor
00624  */
00625 typedef struct _USBVideoUncompressedFormatDescriptor {
00626     uint8_t  bLength; /**< Size of descriptor: 27 bytes */
00627     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00628     uint8_t  bDescriptorSubType; /**< VS_FORMAT_UNCOMPRESSED descriptor subtype */
00629     uint8_t  bFormatIndex; /**< Index of this format descriptor */
00630     uint8_t  bNumFrameDescriptors; /**< Number of frame descriptors following */
00631     sGUID    guidFormat; /**< GUID for stream-encoding format */
00632     uint8_t  bBitsPerPixel; /**< Number of bits per pixel used to specify color */
00633     uint8_t  bDefaultFrameIndex; /**< Optimum Frame Index (used to select resolution) for this stream */
00634     uint8_t  bAspectRatioX; /**< The X dimension of the picture aspect ratio */
00635     uint8_t  bAspectRatioY; /**< The Y dimension of the picture aspect ratio */
00636     uint8_t  bmInterlaceFlags; /**< interlace information */
00637     uint8_t  bCopyProtect; /**< Whether duplication of the video stream is restricted */
00638 }  USBVideoUncompressedFormatDescriptor;
00639 /**
00640  * Uncompressed Video Frame Descriptor
00641  * (bFrameIntervalType is 0, continuous)
00642  */
00643 typedef struct _USBVideoUncompressedFrameDescriptor {
00644     uint8_t  bLength; /**< Size of descriptor: 27 bytes */
00645     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00646     uint8_t  bDescriptorSubType; /**< VS_FRAME_UNCOMPRESSED descriptor subtype */
00647     uint8_t  bFrameIndex; /**< Index of this frame descriptor */
00648     uint8_t  bmCapabilities; /**< Whether still images are supported */
00649     uint16_t wWidth; /**< Width of decoded bitmap frame in pixels */
00650     uint16_t wHeight; /**< Height of decoded bitmap frame in pixels */
00651     uint32_t dwMinBitRate; /**< Minimum bit rate at the longest frame interval, in bps */
00652     uint32_t dwMaxBitRate; /**< Maximum bit rate at the longest frame interval, in bps */
00653     uint32_t dwMaxVideoFrameBufferSize; /**< Max number of bytes that the compressor will produce for a video frame or still image */
00654     uint32_t dwDefaultFrameInterval; /**< Frame interval the device uses as default */
00655     uint8_t  bFrameIntervalType; /**< 0: Continuous frame interval */
00656 
00657     uint32_t dwMinFrameInterval; /**< shortest interval, in 100ns */
00658     uint32_t dwMaxFrameInterval; /**< longest interval, in 100ns */
00659     uint32_t dwFrameIntervalStep;/**< granularity of interval range, in 100ns */
00660 }USBVideoUncompressedFrameDescriptor;
00661 /**
00662  * Uncompressed Video Frame Descriptor
00663  * (with 1 interval setting)
00664  */
00665 typedef struct _USBVideoUncompressedFrameDescriptor1 {
00666     uint8_t  bLength; /**< Size of descriptor: 26 + 4*1 bytes */
00667     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00668     uint8_t  bDescriptorSubType; /**< VS_FRAME_UNCOMPRESSED descriptor subtype */
00669     uint8_t  bFrameIndex; /**< Index of this frame descriptor */
00670     uint8_t  bmCapabilities; /**< Whether still images are supported */
00671     uint16_t wWidth; /**< Width of decoded bitmap frame in pixels */
00672     uint16_t wHeight; /**< Height of decoded bitmap frame in pixels */
00673     uint32_t dwMinBitRate; /**< Minimum bit rate at the longest frame interval, in bps */
00674     uint32_t dwMaxBitRate; /**< Maximum bit rate at the longest frame interval, in bps */
00675     uint32_t dwMaxVideoFrameBufferSize; /**< Max number of bytes that the compressor will produce for a video frame or still image */
00676     uint32_t dwDefaultFrameInterval; /**< Frame interval the device uses as default */
00677     uint8_t  bFrameIntervalType; /**< 1: The number of discrete frame intervals */
00678 
00679     uint32_t dwFrameInterva[1]; /**< shortest interval, in 100ns ... following are longer */
00680 } USBVideoUncompressedFrameDescriptor1;
00681 
00682 /* USB Video, 3.9.2.5, Table 3-17 */
00683 /**
00684  * Still Image Frame Descriptor
00685  * (with 1 size and 1 compression format)
00686  */
00687 typedef struct _USBVideoStillImageFrameDescriptor {
00688     uint8_t  bLength; /**< Size of descriptor: 10 + 4*1-4 + 1 bytes */
00689     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00690     uint8_t  bDescriptorSubType; /**< VS_STILL_IMAGE_FRAME descriptor subtype */
00691     uint8_t  bEndpointAddress; /**< EP address if method 3 of still image capture is used */
00692     uint8_t  bNumImageSizePatterns; /**< Number of Image Size patterns */
00693     uint16_t wWidth; /**< Width of image pattern 1 */
00694     uint16_t wHeight; /**< Height of image pattern 1 */
00695     uint8_t  bNumCompressionPattern; /**< Number of Compression pattern */
00696     uint8_t  bCompression[1]; /**< Compression of the still image */
00697 } USBVideoStillImageFrameDescriptor;
00698 
00699 /* USB Video, 3.9.2.6, Table 3-18 */
00700 /**
00701  * Color Matching Descriptor
00702  */
00703 typedef struct _USBVideoColorMatchingDescriptor {
00704     uint8_t  bLength; /**< Size of descriptor: 6 bytes */
00705     uint8_t  bDescriptorType; /**< CS_INTERFACE descriptor type */
00706     uint8_t  bDescriptorSubType; /**< VS_COLORFORMAT descriptor subtype */
00707     uint8_t  bColorPrimaries; /**< 1: BT.709, sRGB (default) */
00708     uint8_t  bTransferCharacteristics; /**< 1: BT.709 (default) */
00709     uint8_t  bMarixCoefficients; /**< 4: SMPTE 170M (BT.601, default) */
00710 } USBVideoColorMatchingDescriptor;
00711 
00712 /* USB Video, 4.3.1.1 */
00713 /**
00714  * Video Probe and Commit Control Data
00715  */
00716 typedef struct _USBVideoProbeCommitData {
00717     uint16_t bmHint; /**< Parameters shall be kept fixed */
00718     uint8_t  bFormatIndex; /**< Video format index from a format descriptor */
00719     uint8_t  bFrameIndex; /**< Video frame index from a frame descriptor */
00720     uint32_t dwFrameInterval; /**< Frame interval in 100ns units */
00721     uint16_t wKeyFrameRate; /**< Key frame rate in key frame/video frame units */
00722     uint16_t wPFrameRate; /**< PFrame rate in PFrame/key frame units */
00723     uint16_t wCompQuality; /**< Compression quality control in abstract units 0(lowest) to 10000(highest) */
00724     uint16_t wCompWindowSize; /**< Window size for average bit rate control */
00725     uint16_t wDelay; /**< Internal video streaming interface latency in ms from video data capture to presentation on the USB */
00726     uint32_t dwMaxVideoFrameSize; /**< Maximum video frame size in bytes */
00727     uint32_t dwMaxPayloadTransferSize; /**< Maximum number of bytes that the device can transmit in a single payload transfer */
00728 } USBVideoProbeData, USBVideoCommitData;
00729 
00730 COMPILER_PACK_RESET()
00731 
00732 /*----------------------------------------------------------------------------
00733  *         Functions
00734  *----------------------------------------------------------------------------*/
00735 
00736 /**
00737  * Return Control selector (CS), the high byte of wValue.
00738  */
00739 static inline uint8_t USBVideoRequest_GetControlSelector(const USBGenericRequest *req)
00740 {
00741     return ((req->wValue >> 8) & 0xFF);
00742 }
00743 
00744 
00745 /**@}*/
00746 #endif /* _VIDDESCRIPTORS_H_ */
00747 /** \endcond */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines