-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UVC example: change input terminal type to camera from external #1150
UVC example: change input terminal type to camera from external #1150
Conversation
@hathach |
@kkitayam it has improvement, linux now attempt to
Update: confirmed that the GET_DEF() is not currently handled. I try to check if I could quickly add support for this. Unfortunately, I don't understand the UVC spec enough for now. It seems that Linux host tries to ask for default values of your interface. Here is the debug log
|
…reaming interface
@hathach Thank you for confirming and logging!
Ahh, I did not implemented handling for the request. Other requests(GET_RES, GET_LEN) were not implemented, too. I add support for these. |
@hathach I have a bit of a strange situation here. Trying to get UVC to work on a Mac (that is the only computer currently available to me) and for some reason the ESP32S2 is stalling on SET_CONFIG? |
@me-no-dev I haven't tested with esp32s2. One note that although using the same synopsys dwc as stm32, stm32 driver receive more update and implementation to support ISO transfer and other improvement by other contributors. I have an plan to sync the driver of esp32s2 and/or unify the synopsys dwc2 ( since it is very common) but haven't got time to do so. I will try to pull out the esp32s2 to test with uvc/uac later on. It probably needs to have some fifo allocation update etc ... |
@hathach it's not an S2 driver problem. I am using BULK endpoints (grabbed a descriptor from a working camera). It's something that TinyUSB does not like about the descriptor, because other devices work fine (and SET_CONFIG is ACKed). |
if the config parser spot something unusual, it will normally output through the uart log. Could you enable the |
I doubt this is chip specific :) here is the descriptor: const uint8_t jpeg_cam_descriptor[] = {
// Interface Association Video/Interface Collection
0x08, // bLength
0x0B, // bDescriptorType (Interface Association Descriptor)
0x00, // bFirstInterface 0
0x02, // bInterfaceCount 2
0x0E, // bFunctionClass 14 (Video)
0x03, // bFunctionSubClass 3 (Interface Collection)
0x00, // bFunctionProtocol 0
0x00, // iFunction 0
// Interface #0 - Video/Control
0x09, // bLength
0x04, // bDescriptorType (Interface)
0x00, // bInterfaceNumber 0
0x00, // bAlternateSetting
0x01, // bNumEndpoints 1
0x0E, // bInterfaceClass (Video)
0x01, // bInterfaceSubClass (Control)
0x00, // bInterfaceProtocol
0x00, // iInterface (String Index)
// VDC (Control) Header
0x0D, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x01, // bDescriptorSubType: 0x1
0x00, 0x01, 0x4E, 0x00, // Specification Version Number: 01.0
0x80, 0x8D, 0x5B, 0x00, // Device Clock Frequency (Hz): 6000000
0x01, // Number of Video Streaming Interfaces: 1
0x01, // Video Interface Number: 1
// VDC (Control) Input Terminal
0x12, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x02, // bDescriptorSubType: 0x2
0x01, // Terminal ID 1
0x01, 0x02, // Input Terminal Type: 0x201 (Camera Sensor)
0x00, // Input Terminal ID: 0 [NONE]
0x00, // Input Terminal String Index: 0 [NONE]
0x00, 0x00, // Minimum Focal Length 0
0x00, 0x00, // Maximum Focal Length 0
0x00, // Ocular Focal Length 0
0x00, // Controls Supported Description
0x03, 0x12, 0x00, 0x00, // Auto Exposure Mode, Exposure Time (Relative)
// VDC (Control) Processing Unit
0x0C, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x05, // bDescriptorSubType: 0x5
0x03, // Unit ID: 3
0x01, // Source ID: 1
0x00, // Digital Multiplier (100X): 0
0x00, // Controls Supported Description
0x03, 0x7B, 0x14, 0x00, // Brightness, Contrast, Saturation, Sharpness, Gamma, White Balance Temperature, Power Line Frequency, White Balance Temperature, Auto
0x00, // Processing Unit String Index: 0 [NONE]
// VDC (Control) Extension Unit
0x1A, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x06, // bDescriptorSubType: 0x6
0x04, // Unit ID: 4
0x26, 0x52, 0x21, 0x5A, 0x89, 0x32, 0x56, 0x41, 0x89, 0x4A, 0x5C, 0x55, 0x7C, 0xDF, 0x96, 0x64, // Vendor UUID: 5a215226-3289-4156-894a-5c557cdf9664
0x04, // Number of Controls: 4
0x01, // Number of In pins: 1
0x03, // Source ID Pin[0]: 3
0x01, // Controls Supported Description
0x1F, // Vendor Specific Byte[i] = 0x1f
0x00, // Processing Unit String Index: 0 [NONE]
// VDC (Control) Output Terminal
0x09, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x03, // bDescriptorSubType: 0x3
0x02, // Terminal ID: 2
0x01, 0x01, // Output Terminal Type: 0x101 (USB streaming)
0x00, // Output Terminal ID: 0 [NONE]
0x04, //
0x00, // Output Terminal String Index: 0 [NONE]
// Endpoint 0x81 - Interrupt Input
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x81, // bEndpointAddress (IN/D2H)
0x03, // bmAttributes (Interrupt)
0x08, 0x00, // wMaxPacketSize 8
0x20, // bInterval 32 (unit depends on device speed)
// VDC Specific Interrupt Endpoint
0x05, // bLength
0x25, // bDescriptorType (Dependant on Type)
0x03, // bDescriptorSubType: 0x3
0x08, 0x00, // Max Transfer Size: 8
// Interface #1 - Video/Streaming
0x09, // bLength
0x04, // bDescriptorType (Interface)
0x01, // bInterfaceNumber 1
0x00, // bAlternateSetting
0x01, // bNumEndpoints 1
0x0E, // bInterfaceClass (Video)
0x02, // bInterfaceSubClass (Streaming)
0x00, // bInterfaceProtocol
0x00, // iInterface (String Index)
// VDC (Streaming) Input Header
0x0E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x01, // bDescriptorSubType: 0x1
0x01, // bNumFormats: 1
0xC0, 0x00, // wTotalLength: 0xc0 (192)
0x82, // bEndpointAddress: 0x82
0x00, // Capabilities (0x0) bmInfo
0x02, // bTerminalLink: 2
0x02, // bStillCaptureMethod: 2 (Method 2)
0x01, // bTriggerSupport 1 (Supported)
0x00, // bTriggerUsage (0) Initiate Still Image Capture
0x01, // bControlSize: 0x1
0x00, // bmaControls( Format 1): 0x0
// VDC (Streaming) MJPEG Format Descriptor
0x0B, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x06, // bDescriptorSubType: 0x6
0x01, // bFormatIndex: 0x1
0x05, // bNumFrameDescriptors: 0x5
0x00, // bmFlags (0x0)
0x01, // bDefaultFrameIndex: 0x1
0x00, // bAspectRatioX: 0x0
0x00, // bAspectRatioY: 0x0
0x00, // bmInterlaceFlags (0x0)
0x00, // bCopyProtect No Restriction
// VDC (Streaming) MJPEG Frame Descriptor (640x480)
0x1E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x07, // bDescriptorSubType: 0x7
0x01, // bFrameIndex: 1
0x00, // bmCapabilities (0x0)
0x80, 0x02, // wWidth: 640
0xE0, 0x01, // wHeight: 480
0x00, 0x00, 0x08, 0xCA, // dwMinBitRate (bps): 0xca080000 (3389521920)
0x00, 0x00, 0x08, 0xCA, // dwMaxBitRate (bps): 0xca080000 (3389521920)
0x00, 0x00, 0x0A, 0x00, // dwMaxVideoFrameBufferSize (bytes): 0xa0000 (655360)
0x15, 0x16, 0x05, 0x00, // dwDefaultFrameInterval: 0x51615 ( 33.000 ms)
0x01, // Discrete Frame Intervals supported 1
0x15, 0x16, 0x05, 0x00, // dwFrameInterval[1] (100 ns) 0x51615 ( 33.000 ms)
// VDC (Streaming) MJPEG Frame Descriptor (320x240)
0x1E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x07, // bDescriptorSubType: 0x7
0x02, // bFrameIndex: 2
0x00, // bmCapabilities (0x0)
0x40, 0x01, // wWidth: 320
0xF0, 0x00, // wHeight: 240
0x80, 0x00, 0x02, 0x32, // dwMinBitRate (bps): 0x32020080 (838992000)
0x80, 0x00, 0x02, 0x32, // dwMaxBitRate (bps): 0x32020080 (838992000)
0x00, 0x00, 0x0A, 0x00, // dwMaxVideoFrameBufferSize (bytes): 0xa0000 (655360)
0x15, 0x16, 0x05, 0x00, // dwDefaultFrameInterval: 0x51615 ( 33.000 ms)
0x01, // Discrete Frame Intervals supported 1
0x15, 0x16, 0x05, 0x00, // dwFrameInterval[1] (100 ns) 0x51615 ( 33.000 ms)
// VDC (Streaming) MJPEG Frame Descriptor (176x144)
0x1E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x07, // bDescriptorSubType: 0x7
0x03, // bFrameIndex: 3
0x00, // bmCapabilities (0x0)
0xB0, 0x00, // wWidth: 176
0x90, 0x00, // wHeight: 144
0xA0, 0x00, 0x00, 0xB9, // dwMinBitRate (bps): 0xb90000a0 (3103785120)
0xA0, 0x00, 0x00, 0xB9, // dwMaxBitRate (bps): 0xb90000a0 (3103785120)
0x00, 0x00, 0x0A, 0x00, // dwMaxVideoFrameBufferSize (bytes): 0xa0000 (655360)
0x15, 0x16, 0x05, 0x00, // dwDefaultFrameInterval: 0x51615 ( 33.000 ms)
0x01, // Discrete Frame Intervals supported 1
0x15, 0x16, 0x05, 0x00, // dwFrameInterval[1] (100 ns) 0x51615 ( 33.000 ms)
// VDC (Streaming) MJPEG Frame Descriptor (160x120)
0x1E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x07, // bDescriptorSubType: 0x7
0x04, // bFrameIndex: 4
0x00, // bmCapabilities (0x0)
0xA0, 0x00, // wWidth: 0xa0 (160)
0x78, 0x00, // wHeight: 0x78 (120)
0xA0, 0x00, 0x00, 0x8C, // dwMinBitRate (bps): 0x8c0000a0 (2348810400)
0xA0, 0x00, 0x00, 0x8C, // dwMaxBitRate (bps): 0x8c0000a0 (2348810400)
0x00, 0x00, 0x0A, 0x00, // dwMaxVideoFrameBufferSize (bytes): 0xa0000 (655360)
0x15, 0x16, 0x05, 0x00, // dwDefaultFrameInterval: 0x51615 ( 33.000 ms)
0x01, // Discrete Frame Intervals supported 1
0x15, 0x16, 0x05, 0x00, // dwFrameInterval[1] (100 ns) 0x51615 ( 33.000 ms)
// VDC (Streaming) MJPEG Frame Descriptor (352x288)
0x1E, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x07, // bDescriptorSubType: 0x7
0x05, // bFrameIndex: 5
0x00, // bmCapabilities (0x0)
0x60, 0x01, // wWidth: 0x160 (352)
0x20, 0x01, // wHeight: 0x120 (288)
0x80, 0x00, 0x02, 0xE6, // dwMinBitRate (bps): 0xe6020080 (3858890880)
0x80, 0x00, 0x02, 0xE6, // dwMaxBitRate (bps): 0xe6020080 (3858890880)
0x00, 0x00, 0x0A, 0x00, // dwMaxVideoFrameBufferSize (bytes): 0xa0000 (655360)
0x15, 0x16, 0x05, 0x00, // dwDefaultFrameInterval: 0x51615 ( 33.000 ms)
0x01, // Discrete Frame Intervals supported 1
0x15, 0x16, 0x05, 0x00, // dwFrameInterval[1] (100 ns) 0x51615 ( 33.000 ms)
// VDC (Streaming) Still Image Frame Descriptor
0x0B, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x03, // bDescriptorSubType: 0x3
0x00, // bEndpointAddress: 0x0
0x01, // bNumImageSizePatterns 1
0x80, 0x02, // wWidth: 640
0xE0, 0x01, // wHeight: 480
0x01, // bCompressionPatterns 1
0x00, // bCompression[1] 0
// VDC (Streaming) Color Format Descriptor
0x06, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x0D, // bDescriptorSubType: 0xd
0x00, // Color Primaries: 0 ( Unspecified (Image characteristic unknown) )
0x00, // Transfer Characteristics: 0 ( Unspecified (Image characteristic unknown) )
0x00, // Matrix Coefficients: 0 ( Unspecified (Image characteristic unknown) )
// Endpoint 0x82 - Bulk Input
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x82, // bEndpointAddress (IN/D2H)
0x02, // bmAttributes (Bulk)
0x40, 0x00, // wMaxPacketSize 64
0x01, // bInterval 1 (unit depends on device speed)
// 315 bytes
}; |
@me-no-dev can you enable the CFG_TUSB_DEBUG = 3 then check its output ? Update: since the UVC is just newly added, maybe you should use the current template as https://github.com/hathach/tinyusb/blob/master/examples/device/video_capture/src/usb_descriptors.c#L99 . Since not all features are supported. |
It came out to be that the video driver is expecting interface protocol 1 for some reason: https://github.com/hathach/tinyusb/blob/master/src/class/video/video_device.c#L972 @kkitayam can you comment on this requirement? |
@me-no-dev |
b3b6b4f adds these requests handlings. It suppresses probably the warning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested and it works great. Linux no longer complains about unsupported request. I still haven't found an application similar to virtualdub but this PR is already great enough to merge
[ 253.418744] usb 3-2: new full-speed USB device number 11 using xhci_hcd
[ 253.595921] usb 3-2: New USB device found, idVendor=cafe, idProduct=4020, bcdDevice= 1.00
[ 253.595922] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 253.595923] usb 3-2: Product: TinyUSB Device
[ 253.595924] usb 3-2: Manufacturer: TinyUSB
[ 253.595925] usb 3-2: SerialNumber: 123456
[ 253.603928] uvcvideo: Found UVC 1.50 device TinyUSB Device (cafe:4020)
@hathach |
no problems, I am the one to say thanks :) . I will try to do more test with it on Linux later on. |
Describe the PR
Update the configuration descriptor of
video_capture
example to change input terminal type to camera from external.Additional context
It may be Linux has no support for external input terminal.