USBHost UVC Class video driver

mborgerson

Well-known member
I'm making slow, but steady progress on adding a UVC class video driver to the USBHost library. So far, I have spent most of my time consulting books and downloads about the UVC class and slowly adding code to my driver skeleton. Today's breakthrough was getting my driver to claim an interface from the device data arriving from the camera. That raised the question: How do I get my driver to claim the desired alternate configuration from among the dozen or more interface options for UVC devices? Apparently, there are different options for each of the combinations of image size and format as well as for the different data configurations. At some point, I need to tell the camera that I want uncompressed YUV data in VGA resolution.

The interfaces in the configuration data are in sequential order with an index as part of the data. As it stands now, the function to claim a device for the UVC driver always stops after claiming the first option.

I haven't yet explored all the other host drivers, so I don't know if other drivers face the same challenges with multiple alternate configurations. Can anyone point me to a discussion of selecting alternate configurations?

I found a very comprehensive discussion of implementing a UVC class driver for the STM32 microprocessors using Arduino at Codeproject.com:

Getting video stream from USB web-camera on Arduino DueCodeProjecthttps://www.codeproject.com › ... › Arduino

There are 9 or more segments, each with downloadable source code. I've only used some of the debug output routines for the UVC class at this point. I suspect that I will spend many weeks in the gray days of the Oregon winter adapting the control and data flow in that project to the Teensy USB host. Multiple sources state that most modern WebCams can be set up for bulk mode transfers---and such transfers are preferred for the collection of data for video editing. Yet another thing I need to work out, as the TeensyHost does not handle isochronous endpoints.

For those of you who may want to work on a UVC driver, you can get version 1.5 of the UVC class specification through the Wayback Machine. Apparently, USB.org only restricted access to the updated specification many months after it was available with unrestricted access.
 
Do you have any specific webcam model that definitely supports bulk transfer? I'd like to buy one to have for testing. Even if odds are slim I'll manage a lot, maybe I can help in small ways with the low-level stuff if you get stuck.
 
I do have a camera with a bulk endpoint. It's not exactly a web camera---it's a FLIR Boson 640 with radiometric calibration. They retail in the $3-$5K range. I got the camera in return for developing a T4.1 driver using the CSI in 8-bit mode . That software was developed under an NDA, so I haven't posted it on GITHUB. After the initial tests of the driver, The engineer with whom I was working designed and built a custom T4.1 in a smaller form factor--three stacked PCBs fitting the form factor of the Boson. I added a couple of Lithium batteries and a home-made mounting handle and ended up with the device in the attached photo. The photo doesn't show the trigger button, power switch, or 1" OLED viewfinder.

The custom T4.1 is under the tape behind the Boson. Only the heatsink for the switching stepdown supply is visible.

The incentive for the development of the UVC driver is to reduce the complexity of the interface between the Boson and the T4.1. The Boson signals are 1.8V, so level shifters are required between the Boson and the T4.1. The Boson presents a UVC device with a bulk endpoint. All the control of the camera is done through a USB Serial interface. I suspect that control is done that way to allow more complex exchanges than would be possible through only a UVC control endpoint.

I'm hoping to find a less expensive device to work with while developing the software. However, the three webcams I have tested do not show any bulk endpoints.

Here's the device and configuration data that I received from the Boson--the bulk input endpoint is at the end of the listing.
Code:
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 03 EF 02 01 40 CB 09 07 40 00 01 01 02
         03 01
    VendorID = 09CB, ProductID = 4007, Version = 0100
    Class/Subclass/Protocol = 239 / 2 / 1
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: FLIR
enumeration:
Product: Boson
enumeration:
Serial Number: 135651
enumeration:
Config data length = 579
enumeration:
Configuration descriptor:
bLength:            9
bDescriptorType:        0X 02
wTotalLength:            579
bNumInterfaces:            4
bConfigurationValue:        1
iConfiguration:            0
bmAttributes:        0b11000000
bMaxPower:            250


PRINTING FULL CONFIGURATION.
-------------------------------------
Configuration descriptor:
bLength:            9
bDescriptorType:        0X 02
wTotalLength:            579
bNumInterfaces:            4
bConfigurationValue:        1
iConfiguration:            0
bmAttributes:        0b11000000
bMaxPower:            250
-------------------------------------
Interface Association Descriptor:
bLength:            8
bDescriptorType:        0X 0B
bFirstInterface:        0
bInterfaceCount:        2
bFunctionClass:            0X 0E
bFunctionSubClass:        0X 03
bFunctionProtocol:        0X 00
iFunction:            4
-------------------------------------
Interface Descriptor:
bLength:            9
bDescriptorType:        0X 04
bInterfaceNumber:        0
bAlternateSetting:        0
bNumEndpoints:            0
bInterfaceClass:        0X 0E
bInterfaceSubClass:        0X 01
bInterfaceProtocol:        0X 00
iInterface:            5
-------------------------------------
VC Header Descriptor:
bLength:            13
bDescriptorType:        0X 24
bDescriptorSubType:        0X 01
bcdUVC:                0X01
wTotalLength:            50
dwClockFrequency:        1000
bInCollection:        1
baInterfaceNr(1)        1
-------------------------------------
VC Input Terminal Descriptor:
bLength:            17
bDescriptorType:        0X 24
bDescriptorSubType:        0X 02
bTerminalID:            1
wTerminalType:            0X12
bAssocTerminal:            0
iTerminal:            0
wObjectiveFocalLengthMin:    0X00
wObjectiveFocalLengthMax:    0X00
wOcularFocalLength:        0X00
bControlSize:            2
bmControls(1):        0b00000000
bmControls(2):        0b00000000
-------------------------------------
VC Output Terminal Descriptor:
bLength:            9
bDescriptorType:        0X 24
bDescriptorSubType:        0X 03
bTerminalID:            2
wTerminalType:        0X11
bAssocTerminal:        0
bSourceID:            3
iTerminal:            0
-------------------------------------
VC Processing Unit Descriptor:
bLength:            11
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bUnitID:            3
bSourceID:            1
wMaxMultiplier:            0
bControlSize:            2
bmControls(1):        0b00000010
bmControls(2):        0b00000000
iProcessing:            0
-------------------------------------
Interface Descriptor:
bLength:            9
bDescriptorType:        0X 04
bInterfaceNumber:        1
bAlternateSetting:        0
bNumEndpoints:            1
bInterfaceClass:        0X 0E
bInterfaceSubClass:        0X 02
bInterfaceProtocol:        0X 00
iInterface:            6
-------------------------------------
VS Input Header Descriptor:
bLength:            17
bDescriptorType:        0X 24
bDescriptorSubType:        0X 01
bNumFormats:            4
wTotalLength:            403
bEndpointAddress:        0b10000001
bmInfo:                0b00000000
bTerminalLink:        2
bStillCaptureMethod:    0
bTriggerSupport:        0
bTriggerUsage:        0
bControlSize:            1
bmControls(1):        0b00000001
-------------------------------------
VS Uncompressed Format Descriptor:
bLength:            27
bDescriptorType:        0X 24
bDescriptorSubType:        0X 04
bFormatIndex:            1
bNumFrameDescriptors:    2
guidFormat:            0X 49 34 32 30 00 00 10 00 80 00 00 AA 00 38 9B 71
bBitsPerPixel:        12
bDefaultFrameIndex:        1
bAspectRatioX:        0
bAspectRatioY:        0
bmInterlaceFlags:        0b00000000
bCopyProtect:            0
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            1
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            512
dwMinBitRate:        117964800
dwMaxBitRate:        235929600
dwMaxVideoFrameBufferSize:    491520
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            2
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            514
dwMinBitRate:        118425600
dwMaxBitRate:        236851200
dwMaxVideoFrameBufferSize:    493440
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Color Matching Descriptor:
bLength:            6
bDescriptorType:        0X 24
bDescriptorSubType:        0X 0D
bColorPrimaries:        1
bTransferCharacteristics:    1
bMatrixCoefficients:    1
-------------------------------------
VS Uncompressed Format Descriptor:
bLength:            27
bDescriptorType:        0X 24
bDescriptorSubType:        0X 04
bFormatIndex:            2
bNumFrameDescriptors:    2
guidFormat:            0X 59 31 36 20 00 00 10 00 80 00 00 AA 00 38 9B 71
bBitsPerPixel:        16
bDefaultFrameIndex:        1
bAspectRatioX:        0
bAspectRatioY:        0
bmInterlaceFlags:        0b00000000
bCopyProtect:            0
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            1
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            512
dwMinBitRate:        157286400
dwMaxBitRate:        314572800
dwMaxVideoFrameBufferSize:    655360
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            2
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            514
dwMinBitRate:        157900800
dwMaxBitRate:        315801600
dwMaxVideoFrameBufferSize:    657920
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Color Matching Descriptor:
bLength:            6
bDescriptorType:        0X 24
bDescriptorSubType:        0X 0D
bColorPrimaries:        1
bTransferCharacteristics:    1
bMatrixCoefficients:    1
-------------------------------------
VS Uncompressed Format Descriptor:
bLength:            27
bDescriptorType:        0X 24
bDescriptorSubType:        0X 04
bFormatIndex:            3
bNumFrameDescriptors:    2
guidFormat:            0X 4E 56 31 32 00 00 10 00 80 00 00 AA 00 38 9B 71
bBitsPerPixel:        12
bDefaultFrameIndex:        1
bAspectRatioX:        0
bAspectRatioY:        0
bmInterlaceFlags:        0b00000000
bCopyProtect:            0
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            1
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            512
dwMinBitRate:        117964800
dwMaxBitRate:        235929600
dwMaxVideoFrameBufferSize:    491520
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            2
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            514
dwMinBitRate:        118425600
dwMaxBitRate:        236851200
dwMaxVideoFrameBufferSize:    493440
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Color Matching Descriptor:
bLength:            6
bDescriptorType:        0X 24
bDescriptorSubType:        0X 0D
bColorPrimaries:        1
bTransferCharacteristics:    1
bMatrixCoefficients:    1
-------------------------------------
VS Uncompressed Format Descriptor:
bLength:            27
bDescriptorType:        0X 24
bDescriptorSubType:        0X 04
bFormatIndex:            4
bNumFrameDescriptors:    2
guidFormat:            0X 4E 56 32 31 00 00 10 00 80 00 00 AA 00 38 9B 71
bBitsPerPixel:        12
bDefaultFrameIndex:        1
bAspectRatioX:        0
bAspectRatioY:        0
bmInterlaceFlags:        0b00000000
bCopyProtect:            0
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            1
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            512
dwMinBitRate:        117964800
dwMaxBitRate:        235929600
dwMaxVideoFrameBufferSize:    491520
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Uncompressed Frame Descriptor:
bLength:            34
bDescriptorType:        0X 24
bDescriptorSubType:        0X 05
bFrameIndex:            2
bmCapabilities:            0b00000010
wWidth:                640
wHeight:            514
dwMinBitRate:        118425600
dwMaxBitRate:        236851200
dwMaxVideoFrameBufferSize:    493440
dwDefaultFrameInterval:        166666
bFrameIntervalType:        2
dwFrameInterval[1]:        168430090
dwFrameInterval[2]:        353703189
-------------------------------------
VS Color Matching Descriptor:
bLength:            6
bDescriptorType:        0X 24
bDescriptorSubType:        0X 0D
bColorPrimaries:        1
bTransferCharacteristics:    1
bMatrixCoefficients:    1
-------------------------------------
Endpoint Descriptor:
bLength:            7
bDescriptorType:        0X 05
bEndpointAddress:    IN,      1
bmAttributes:                 BULK
wMaxPacketSize:            512
bInterval:            0
-------------------------------------
enumeration:
Claiming Drivers in enumeration
USBDriver (UVC Camera) list: 200045E0 -> 20004220
 

Attachments

  • FLIRCam.jpg
    FLIRCam.jpg
    138.1 KB · Views: 14
Back
Top