您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > USB-2-0与UVC-1-1-在Webcam-F-W传输设定
題目:USB2.0與UVC1.1在WebcamF/W傳輸設定尚立Webcam高級工程師Aladdin前言:Webcam使用USBVideoClass1.1以及使用USB2.0的通訊協定將Webcam的影像資料傳輸到PC或NB,如果有支援聲音則使用USBAudioClass1.0的協定內容:Webcam可以從程式設定了解USB協定(1)設定StandardDevice主要設定USB2.0HighSpeed的StandardDeviceDescriptor,定義在USB2.0Spec.Table9.8設定USB版本,產品的VID,PID,SerialNumber....等0x00,0x12,//lengthofdevicedecriptor//DeviceDescriptor0x12,//bLength:0x12byte0x01,//bDescriptorType:DEVICE0x00,0x02,//bcdUSB:version2.000xEF,//bDeviceClass:independentinterfaces0x02,//bDeviceSubClass:20x01,//bDeviceProtocol:classspecificprotocolsNOTusedondevicebasis0x40,//bMaxPacketSize0:maximumpacketsizeforendpointzero0xF2,0x04,//idVendor:vendorID0xC3,0xB2,//idProduct:productID0x27,0x11,//bcdDevice:devicereleasenumberinBCD0x01,//iManufacturer:indexofstring0x02,//iProduct:indexofstring0x00,//iSerialNumber:indexofstring0x01,//bNumConfigurations:1configuration解釋Offset0-bLength:為這個Descriptor的長度為18Bytes,,占1Byte,設定為0x12Offset1-bDescriptorType,這個Descriptortype,占1Byte,為0x01Offset2-bcdUSB,USB通訊的版本,占2個Bytes,由於是支援USB2.0,所以要設定0x00,0x02(傳輸先傳低位元組再傳高位元組)Offset4-bDeviceClass,USB_IF對這DeviceClass的編碼,0xEFOffset5-bDeviceSubClass,USB_IF對這DevicesubClass編碼,0x02Offset6-bDeviceProtocol,USB_IF對這DeviceProtocol編碼,0x01Offset7-bMaxPacketSize,傳輸最大數據包的Size,只可以定義8,16,32,64,這裡定義為64Bytes,為0x40Offset8-idVendor,為產品的VID根據USB-IF定義,占2bytes,0xF2,0x40Offset10-idProduct,定義產品的PID,占2bytes,0xC3,0xB2Offset12-bcdDevice,可定義產品的版本,占2bytes,0x27,0x11Offset14-iManufacturer,製造廠商,利用index選擇Strings,0x01Offset15-iProduct,產品名稱,利用index選擇Strings,0x02Offset16-iSerialNumber,序號,利用index選擇Strings,0x00Offset17-bNumConfigurations,結構的編號,使用Configuration1,0x01這個Devicedescriptor傳輸到NB或PC,在Windows的系統的硬體識別碼顯示VID,PID,與Rev(2)其他速率傳輸設定Device_QualifierDescriptor,設定非HighSpeedUSBDeviceDescriptor,如Webcam也有支援FullSpeed傳輸,定義在USBSpec.Table9.9F/W設定為0x00,0x0A,//lengthofdevicequalifierdescriptor//DeviceQualifierDescriptor0x0A,//bLength:0x0Abyte0x06,//bDescriptorType:DEVICEQUALIFIER0x00,0x02,//bcdUSB:version2.000xEF,//bDeviceClass:independentinterfaces0x02,//bDeviceSubClass:20x01,//bDeviceProtocol:classspecificprotocolsNOTusedondevicebasis0x40,//bMaxPacketSize0:maximumpacketsizeforendpointzero0x01,//bNumConfigurations:1configuration0x00,//bReserved:0x00解釋Offset0,為bLength,這DeviceQualifier為10bytes,0x0AOffset1,為bDescriptorType,設定為0x06Offset2,為bcdUSB,USB通訊的版本,占2個Bytes,由於是USB2.0,所以要設定0x00,0x02Offset4,為bDeviceClass,USB-IF對這Device的class編碼,0xEFOffset5,為bDeviceSubClass,USB-IF對這Device的subclass編碼,0x0x02Offset6,為bDeviceProtocol,USB-IF對這Device的protocol編碼,0x0x01Offset7-bMaxPacketSize,傳輸最大數據包的Size,只可以定義8,16,32,64,這裡定義為64,為0x40Offset8-bNumConfigurations,結構的編號,使用Configuration1,0x01Offset9-bReserved,保留,需設定0x00(3)顯示語言編碼顯示Webcam字串的語言編碼,定義在USB2.0Spec.Table9.15F/W設定0x00,0x04,//lengthoflanguageidstringdescriptor//LanguageIDStringDescriptor0x04,//bLength0x03,//bDescriptorType:STRING0x09,0x04,//bString:English(US)解釋Offset0為bLength,因指定義一種語言所以為0x04Offset1為bbDescriptorType,String的Descriptor為0x03Offset2為wLANGID[0],占2bytes,英文編碼為0x09,0x04參考USBLanguage編碼(4)產品名稱編碼Webcam的產品名稱,定義在USB2.0Spec.Table9.16F/W設定0x00,0x32,//lengthofproductstringdescriptor0x32,//ProductStringDescriptor0x03,//bLength0x53,0x00,0x50,0x00,0x43,0x00,0x41,0x00,0x32,0x00,0x32,0x00,0x38,0x00,0x31,0x00,0x20,0x00,0x57,0x00,//'W'0x65,0x00,//'e'0x62,0x00,//'b'0x20,0x00,//''0x43,0x00,//'C'0x61,0x00,//'a'0x6D,0x00,//'m'0x65,0x00,//'e'0x72,0x00,//'r'0x61,0x00,//'a'0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,解釋Offset0為bLength,更具字串+2來定義LengthOffset1為bDescriptorType,設定字串的Descriptor為0x03Offset2~OffsetN設定字串編碼,使用Unicode碼,每個字為2Bytes這個Stringsdescriptor傳輸到NB或PC,在顯示名稱會秀出如USBCamera2.傳輸設定:主要設定USB2.0的Configuration及UVC1.1的定義處理如feature,resolution...等等可分為FullSpeedUSB定義及HighSpeedUSB定義,兩者的Descriptor類似只是參數設定不同,(1)USBConfigurationF/W編碼//ConfigurationDescriptor0x09,//bLength:0x09byte0x02,//bDescriptorType:CONFIGURATION0x81,0x05,//wTotalLength:0x062dbyte0x04,//bNumInterfaces:2interfaces0x01,//bConfigurationValue:configuration10x00,//iConfiguration:indexofstring0x80,//bmAttributes:buspowered0xFA,//MaxPower:500mA這定義USB2.0傳送UVC及UAC的型態,規範在USB2.0Spec.Table9.10解釋Offset0為bLength,ConfigurationDescriptor的長度為9bytes,0x09Offset1為bDescriptorType,ConfigurationDescriptortype,0x02Offset2為wTotalLength,占2bytes為傳送USB2.0的UVC或UAC定義資料的全部長度,包括ConfigurationDescriptor,0x81,0x05(0x581bytes)Offset4為bNumInterfaces,Interfacenumber,SPCA2281有Audio所以設定0x04,如沒有Audio設定0x02Offset5為bConfigurationValue,為設定結構值,定義0x01Offset6為iConfiguration,為設定這結構的描述字串指標,0x00Offset7為bmAttributes,為設定bus的power狀況,D7為reserved必須設定為1,D6為是否要SelfPower,D5為遠端遙控開機功能,D4~D0為reserved設為0,所以為0x80Offset8為bMaxPower,設定USBbus最大電流,每單為為2mA,所以0xfa=250即為500mA(2)VideoInterfaceAssociationDescriptorUSB在Video介面接口關連描述(IAD)定義在UVC1.1Spec.Table3-1F/W設定//VideoInterfaceAssociationDescriptor0x08,//bLength:0x08byte0x0B,//bDescriptorType:INTERFACEASSOCATIONDescriptor0x00,//bInterfaceNumber:interface00x02,//bInterfaceCount:20x0E,//bFunctionClass:0x0E0x03,//bFunctionSubClass:0x030x00,//bInterfaceProtocol:classspecificprotocolNOTusedonthisinterface0x02,//iFunction:2解釋Offset0為bLength,IAD長度為8byte
本文标题:USB-2-0与UVC-1-1-在Webcam-F-W传输设定
链接地址:https://www.777doc.com/doc-7416431 .html