SAMV71 Xplained Ultra Software Package 1.3

VIDEODescriptors.h

Go to the documentation of this file.
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 
00030 /** \file
00031  *
00032  *  Definitions and classes for USB Audio class descriptors.
00033  *
00034  */
00035 
00036 #ifndef _VIDEODESCRIPTORS_H_
00037 #define _VIDEODESCRIPTORS_H_
00038 /** \addtogroup usb_video
00039  *@{
00040  */
00041 
00042 /*----------------------------------------------------------------------------
00043  *         Includes
00044  *----------------------------------------------------------------------------*/
00045  
00046 #include <stdint.h>
00047 #include <USBVideo.h>
00048 /*----------------------------------------------------------------------------
00049  *         Definitions
00050  *----------------------------------------------------------------------------*/
00051 
00052 /** Video frame BitsPerPixel */
00053 #define FRAME_BPP         (16)
00054 /** Video frame buffer size calculation */
00055 #define FRAME_BUFFER_SIZEC(W,H)  ((W)*(H)*FRAME_BPP/8)
00056 /** Video frame bit-rate calculation */
00057 #define FRAME_BITRATEC(W,H,FR)  ((FR)*FRAME_BUFFER_SIZEC(W,H)*8)
00058 /** Video frame interval calculation (100ns) */
00059 #define FRAME_INTERVALC(FR) (1*1000*1000*(1000/100)/(FR))
00060 /** Packet size for FS */
00061 #define FRAME_PACKET_SIZE_FS    640
00062 
00063 /** Packet size for HS */
00064 #define FRAME_PACKET_SIZE_HS    (1020)
00065 
00066 /** Payload header size */
00067 #define FRAME_PAYLOAD_HDR_SIZE  2
00068 
00069 /** High Bandwidth mode: 0 ~ 2 */
00070 #define ISO_HIGH_BW_MODE    2
00071 
00072 #define VIDCAMD_EpDesc_MaxPacketSize   (FRAME_PACKET_SIZE_HS | (ISO_HIGH_BW_MODE << 11))
00073 
00074 /** Interface number of USB Video Control Interface */
00075 #define VIDCAMD_ControlInterfaceNum     0
00076 /** Interface number of USB Video Streaming Interface */
00077 #define VIDCAMD_StreamInterfaceNum      1
00078 /** Endpoint number of USB Video Streaming ISO IN endpoint */
00079 #define VIDCAMD_IsoInEndpointNum        2
00080 
00081 /** Number of Video Frame Types */
00082 #define VIDCAMD_NumFrameTypes           3
00083 
00084 #define VIDCAMD_FW_1                 320
00085 #define VIDCAMD_FH_1                 240
00086 
00087 #define VIDCAMD_FW_2                 640
00088 #define VIDCAMD_FH_2                 480
00089 
00090 #define VIDCAMD_FW_3                 176
00091 #define VIDCAMD_FH_3                 144
00092 
00093 /*----------------------------------------------------------------------------
00094  *         Types
00095  *----------------------------------------------------------------------------*/
00096 #pragma pack(1)
00097 #if defined   ( __CC_ARM   ) /* Keil ¦̀Vision 4 */
00098 #elif defined ( __ICCARM__ ) /* IAR Ewarm */
00099 #define __attribute__(...)
00100 #define __packed__  packed
00101 #elif defined (  __GNUC__  ) /* GCC CS3 */
00102 #define __packed__  aligned(1)
00103 #endif
00104 /**
00105  * VideoControl Interface with 1 streaming interface
00106  */
00107 typedef struct _UsbVideoControlInterfaceHeader1 {
00108     uint8_t     bLength;
00109     uint8_t     bDescriptorType;
00110     uint8_t     bDescriptorSubType;
00111     uint16_t    bcdVDC;
00112     uint16_t    wTotalLength;
00113     uint32_t    dwClockFrequency;
00114     uint8_t     bInCollection;
00115     uint8_t     bInterface1;
00116 } UsbVideoControlInterfaceHeader1;
00117 
00118 /**
00119  * Input header descriptor (with 1 format)
00120  */
00121 typedef struct _UsbVideoInputHeaderDescriptor1 {
00122     uint8_t     bLength;
00123     uint8_t     bDescriptorType;
00124     uint8_t     bDescriptorSubType;
00125     uint8_t     bNumFormats;
00126     uint16_t    wTotalLength;
00127     uint8_t     bEndpointAddress;
00128     uint8_t     bmInfo;
00129     uint8_t     bTerminalLink;
00130     uint8_t     bStillCaptureMethod;
00131     uint8_t     bTriggerSupport;
00132     uint8_t     bTriggerUsage;
00133     uint8_t     bControlSize;
00134     uint8_t     bmaControls1;
00135 } UsbVideoInputHeaderDescriptor1;
00136 
00137 /**
00138  * Class-specific USB VideoControl Interface descriptor list
00139  */
00140 typedef struct _UsbVideoControlInterfaceDescriptor {
00141     UsbVideoControlInterfaceHeader1 header;
00142     USBVideoCameraTerminalDescriptor it;
00143     USBVideoOutputTerminalDescriptor ot;
00144 } UsbVideoControlInterfaceDescriptor;
00145 
00146 /** USB Video Format with 1 frame, 1 compression, without STI */
00147 typedef struct _UsbVideoFormatDescriptor {
00148     USBVideoUncompressedFormatDescriptor payload;
00149     USBVideoUncompressedFrameDescriptor1 frame320x240; /* 153.6K/f,  4f/s */
00150     USBVideoUncompressedFrameDescriptor1 frame640x480; /* 614.4K/f,  1f/s */
00151     USBVideoUncompressedFrameDescriptor1 frame160x120; /* 614.4K/f,  16f/s */
00152     USBVideoColorMatchingDescriptor colorUncompressed;
00153 } UsbVideoFormatDescriptor;
00154 
00155 typedef struct _UsbVideoStreamingInterfaceDescriptor {
00156     UsbVideoInputHeaderDescriptor1 inHeader;
00157     UsbVideoFormatDescriptor format;
00158 } UsbVideoStreamingInterfaceDescriptor;
00159 
00160 struct UsbVideoCamConfigurationDescriptors {
00161     /* Configuration descriptor */
00162     USBConfigurationDescriptor configuration;
00163     /* IAD */
00164     USBInterfaceAssociationDescriptor iad;
00165     /* VideoControl I/F */
00166     USBInterfaceDescriptor interface0;
00167     /* VideoControl I/F Descriptors */
00168     UsbVideoControlInterfaceDescriptor vcInterface;
00169     /* VideoStreaming I/F */
00170     USBInterfaceDescriptor interface10;
00171     /* VideoStreaming I/F Descriptors */
00172     UsbVideoStreamingInterfaceDescriptor vsInterface;
00173     /* VideoStreaming I/F */
00174     USBInterfaceDescriptor interface11;
00175     /* Endpoint */
00176     USBEndpointDescriptor ep11;
00177 };
00178 
00179 #pragma pack()
00180 
00181 
00182 /**@}*/
00183 #endif /* _VIDEODESCRIPTORS_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines