Jetson TK1 behaving like an usb camera

Hi,
I’ve read some threads about the possibility to set a jetson’s usb port in client mode (for example behaving like an usb drive).

In my case I’d like to acquire images from a camera or a video, do some elaborations on them and send them on the usb.

In practice connecting the jetson tk1 to another pc, I’d like that the other pc sees the jetson like a normal camera, is it possible? Is there a software layer that do that?

First, the micro-A/B USB port has to be set to device mode. See this thread:
https://devtalk.nvidia.com/default/topic/897104/jetson-tk1-usb-otg-client-mode/#4729731

Second, you have to write some kernel driver code. The device mode in the linux kernel is somewhat modular, intended to allow you to do this without writing everything from scratch, so you’re in luck. This is the USB gadget code. See these URLs, but understand that some of the articles in the wild about gadget code are out of date…everything mentioned is generally already available in the TK1 kernel even if something out on the web says there needs to be some kind of patch or download:
https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt
http://www.linux-usb.org/gadget/

Thanks linuxdev for the useful advice.

Hi,
I’ve compiled L4T R23.1 kernel (3.10.67) L4T R24.1 kernel (3.10.40) with the g_webcam module.

In practice using make menuconfig: Device Drivers > USB support USB Webcam Gadget.

Follow the sequence of commands used and outputs.

Jetson side:

[b]echo 0 |sudo tee /sys/devices/platform/tegra-otg/enable_host 
echo 1 | sudo tee /sys/devices/platform/tegra-otg/enable_device[/b]

<b>sudo dmesg -C</b>

[  138.192312] otg state changed: HOST --> SUSPEND
[  138.196585] tegra-ehci tegra-ehci.0: remove, state 4
[  138.196606] usb usb3: USB disconnect, device number 1
[  138.198599] tegra-ehci tegra-ehci.0: USB bus 3 deregistered
[  138.265069] otg state changed: SUSPEND --> PERIPHERAL
[  140.084530] init: failsafe main process (1045) killed by TERM signal
[  140.484325] init: plymouth-stop pre-start process (1978) terminated with status 1

[b]sudo modprobe g_webcam

sudo dmesg -C[/b]

[  210.441588] g_webcam gadget: uvc_function_bind
[  210.441608] ------------[ cut here ]------------
[  210.441624] WARNING: at drivers/media/v4l2-core/videobuf2-core.c:2066 vb2_queue_init+0xe4/0x194()
[  210.441629] Modules linked in: g_webcam(+) libcomposite configfs dm_crypt dm_mod joydev rfcomm bnep bluetooth rfkill nvhost_vi
[  210.441663] CPU: 0 PID: 2009 Comm: modprobe Not tainted 3.10.40gwebcam #1
[  210.441684] [<c0016350>] (unwind_backtrace+0x0/0x13c) from [<c0012be4>] (show_stack+0x18/0x1c)
[  210.441697] [<c0012be4>] (show_stack+0x18/0x1c) from [<c0062888>] (warn_slowpath_common+0x5c/0x74)
[  210.441706] [<c0062888>] (warn_slowpath_common+0x5c/0x74) from [<c0062954>] (warn_slowpath_null+0x24/0x2c)
[  210.441716] [<c0062954>] (warn_slowpath_null+0x24/0x2c) from [<c0531708>] (vb2_queue_init+0xe4/0x194)
[  210.441733] [<c0531708>] (vb2_queue_init+0xe4/0x194) from [<bf09b6d8>] (uvc_function_bind+0x354/0x49c [g_webcam])
[  210.441756] [<bf09b6d8>] (uvc_function_bind+0x354/0x49c [g_webcam]) from [<bf05cd80>] (usb_add_function+0x7c/0x198 [libcomposite])
[  210.441773] [<bf05cd80>] (usb_add_function+0x7c/0x198 [libcomposite]) from [<bf09b9e0>] (uvc_bind_config+0x1c0/0x234 [g_webcam])
[  210.441790] [<bf09b9e0>] (uvc_bind_config+0x1c0/0x234 [g_webcam]) from [<bf09ba80>] (webcam_config_bind+0x2c/0x34 [g_webcam])
[  210.441806] [<bf09ba80>] (webcam_config_bind+0x2c/0x34 [g_webcam]) from [<bf05d9e8>] (usb_add_config+0x70/0x2d4 [libcomposite])
[  210.441821] [<bf05d9e8>] (usb_add_config+0x70/0x2d4 [libcomposite]) from [<bf09b350>] (webcam_bind+0x4c/0x80 [g_webcam])
[  210.441836] [<bf09b350>] (webcam_bind+0x4c/0x80 [g_webcam]) from [<bf05f2c4>] (composite_bind+0x88/0x18c [libcomposite])
[  210.441852] [<bf05f2c4>] (composite_bind+0x88/0x18c [libcomposite]) from [<c04ecb1c>] (udc_bind_to_driver+0x4c/0xe4)
[  210.441864] [<c04ecb1c>] (udc_bind_to_driver+0x4c/0xe4) from [<c04ece44>] (usb_gadget_probe_driver+0x78/0xd0)
[  210.441875] [<c04ece44>] (usb_gadget_probe_driver+0x78/0xd0) from [<c0008748>] (do_one_initcall+0xdc/0x188)
[  210.441884] [<c0008748>] (do_one_initcall+0xdc/0x188) from [<c00c4f3c>] (load_module+0xcf8/0x10c8)
[  210.441893] [<c00c4f3c>] (load_module+0xcf8/0x10c8) from [<c00c56b4>] (SyS_finit_module+0x190/0x2a0)
[  210.441902] [<c00c56b4>] (SyS_finit_module+0x190/0x2a0) from [<c000ed00>] (ret_fast_syscall+0x0/0x30)
[  210.441908] ---[ end trace 196c77c38f513659 ]---
[  210.450193] g_webcam gadget: Webcam Video Gadget
[  210.450203] g_webcam gadget: g_webcam ready
[  210.450212] tegra-udc: bind to driver g_webcam

[b]echo connect | sudo tee /sys/devices/platform/tegra-udc.0/udc/tegra-udc.0/soft_connect

sudo dmesg -C[/b]

[  435.293966] g_webcam gadget: high-speed config #1: Video
[  435.294178] g_webcam gadget: uvc_function_set_alt(0, 0)
[  435.294337] g_webcam gadget: uvc_function_set_alt(1, 0)
[  435.296690] g_webcam gadget: uvc_function_set_alt(1, 0)
[  435.304327] tegra-udc tegra-udc.0: connected to SDP

Host side (dmesg more verbose):

<b>sudo echo 0xffff > /sys/module/uvcvideo/parameters/trace</b>

Now I’ve physically connected the micro-B USB cable between the Jetson and the Host PC.

Jetson side:

<b>sudo dmesg -C</b>

[  435.293966] g_webcam gadget: high-speed config #1: Video
[  435.294178] g_webcam gadget: uvc_function_set_alt(0, 0)
[  435.294337] g_webcam gadget: uvc_function_set_alt(1, 0)
[  435.296690] g_webcam gadget: uvc_function_set_alt(1, 0)
[  435.304327] tegra-udc tegra-udc.0: connected to SDP

Host side:

<b>sudo dmesg -C</b>

[ 2480.811139] usb 1-6: new high-speed USB device number 12 using xhci_hcd
[ 2480.944480] usb 1-6: New USB device found, idVendor=1d6b, idProduct=0102
[ 2480.944489] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2480.944494] usb 1-6: Product: Webcam gadget
[ 2480.944497] usb 1-6: Manufacturer: Linux Foundation
[ 2480.948059] uvcvideo: Probing generic UVC device 6
[ 2480.948071] uvcvideo: Found format YUV 4:2:2 (YUYV).
[ 2480.948075] uvcvideo: - 640x360 (15.0 fps)
[ 2480.948078] uvcvideo: - 1280x720 (2.0 fps)
[ 2480.948080] uvcvideo: Found format MJPEG.
[ 2480.948082] uvcvideo: - 640x360 (15.0 fps)
[ 2480.948085] uvcvideo: - 1280x720 (2.0 fps)
[ 2480.948090] uvcvideo: Found a Status endpoint (addr 81).
[ 2480.948094] uvcvideo: Found UVC 1.00 device Webcam gadget (1d6b:0102)
[ 2480.948270] uvcvideo: Added control 00000000-0000-0000-0000-000000000001/2 to device 6 entity 1
[ 2480.948278] uvcvideo: Adding mapping 'Exposure, Auto' to control 00000000-0000-0000-0000-000000000001/2.
[ 2480.948284] uvcvideo: Added control 00000000-0000-0000-0000-000000000101/2 to device 6 entity 2
[ 2480.948291] uvcvideo: Adding mapping 'Brightness' to control 00000000-0000-0000-0000-000000000101/2.
[ 2480.948296] uvcvideo: Scanning UVC chain: OT 3 <- PU 2 <- IT 1
[ 2480.948305] uvcvideo: Found a valid video chain (1 -> 3).
[ 2485.951328] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[ 2490.955372] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[ 2490.955379] uvcvideo: Failed to initialize the device (-5).

Host side (trying to reload the g_webcam module):

<b>sudo rmmod uvcvideo</b>

<b>dmesg -C</b>

[ 2618.573482] usbcore: deregistering interface driver uvcvideo
[ 2618.654812] uvcvideo: Resuming interface 0
[ 2618.654830] uvcvideo: Resuming interface 1

<b>sudo modprobe uvcvideo</b>

<b>sudo dmesg -C</b>

[ 2701.169651] uvcvideo: Found UVC 1.00 device WebCam SC-10HDP12631N (2232:1045)
[ 2701.178480] input: WebCam SC-10HDP12631N as /devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/input/input20
[ 2701.178622] uvcvideo: Found UVC 1.00 device Webcam gadget (1d6b:0102)
[ 2706.181681] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[ 2711.185702] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[ 2711.185713] uvcvideo: Failed to initialize the device (-5).
[ 2711.186082] usbcore: registered new interface driver uvcvideo
[ 2711.186091] USB Video Class driver (1.1.1)

Jetson side:

<b>sudo dmesg -C</b>

[  655.351526] g_webcam gadget: uvc_function_set_alt(1, 0)

Host side:

#here just a part of the output
<b>sudo hwinfo --usb</b>

26: USB 00.0: 0000 Unclassified device
  [Created at usb.122]
  Unique ID: MtLc.X743vncU2k3
  Parent ID: k4bc.2DFUsyrieMD
  SysFS ID: /devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0
  SysFS BusID: 1-6:1.0
  Hardware Class: unknown
  Model: "Linux Foundation Webcam gadget"
  Hotplug: USB
  Vendor: usb 0x1d6b "Linux Foundation"
  Device: usb 0x0102 "Webcam gadget"
  Revision: "3.10"
  Speed: 480 Mbps
  Module Alias: "usb:v1D6Bp0102d0310dcEFdsc02dp01ic0Eisc01ip00in00"
  Driver Info #0:
    Driver Status: uvcvideo is active
    Driver Activation Cmd: "modprobe uvcvideo"
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #23 (Hub)

<b>lsusb</b>

Bus 004 Device 002: ID 8087:8000 Intel Corp. 
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 8087:8008 Intel Corp. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 05dc:0803 Lexar Media, Inc. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 8087:07dc Intel Corp. 
Bus 001 Device 012: ID 1d6b:0102 Linux Foundation EEM Gadget
Bus 001 Device 013: ID 062a:4102 Creative Labs 
Bus 001 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 005: ID 2232:1045 Silicon Motion 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

<b>lsusb -s 1:12 -v</b>

Bus 001 Device 012: ID 1d6b:0102 Linux Foundation EEM Gadget
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0102 EEM Gadget
  bcdDevice            3.10
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          309
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 
    bmAttributes         0xc0
      Self Powered
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass         14 Video
      bFunctionSubClass       3 Video Interface Collection
      bFunctionProtocol       0 
      iFunction               5 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass        14 Video
      bInterfaceSubClass      1 Video Control
      bInterfaceProtocol      0 
      iInterface              5 
      VideoControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdUVC               1.00
        wTotalLength           51
        dwClockFrequency       48.000000MHz
        bInCollection           1
        baInterfaceNr( 0)       1
      VideoControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Camera Sensor
        bAssocTerminal          0
        iTerminal               0 
        wObjectiveFocalLengthMin      0
        wObjectiveFocalLengthMax      0
        wOcularFocalLength            0
        bControlSize                  3
        bmControls           0x00000002
          Auto-Exposure Mode
      VideoControl Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      5 (PROCESSING_UNIT)
      Warning: Descriptor too short
        bUnitID                 2
        bSourceID               1
        wMaxMultiplier      16384
        bControlSize            2
        bmControls     0x00000001
          Brightness
        iProcessing             0 
        bmVideoStandards     0x 9
          None
          SECAM - 625/50
      VideoControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        iTerminal               0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass        14 Video
      bInterfaceSubClass      2 Video Streaming
      bInterfaceProtocol      0 
      iInterface              6 
      VideoStreaming Interface Descriptor:
        bLength                            15
        bDescriptorType                    36
        bDescriptorSubtype                  1 (INPUT_HEADER)
        bNumFormats                         2
        wTotalLength                      195
        bEndPointAddress                  130
        bmInfo                              0
        bTerminalLink                       3
        bStillCaptureMethod                 0
        bTriggerSupport                     0
        bTriggerUsage                       0
        bControlSize                        1
        bmaControls( 0)                    27
        bmaControls( 1)                    27
      VideoStreaming Interface Descriptor:
        bLength                            27
        bDescriptorType                    36
        bDescriptorSubtype                  4 (FORMAT_UNCOMPRESSED)
        bFormatIndex                        1
        bNumFrameDescriptors                2
        guidFormat                            {59555932-0000-1000-8000-00aa00389b71}
        bBitsPerPixel                      16
        bDefaultFrameIndex                  1
        bAspectRatioX                       0
        bAspectRatioY                       0
        bmInterlaceFlags                 0x00
          Interlaced stream or variable: No
          Fields per frame: 2 fields
          Field 1 first: No
          Field pattern: Field 1 only
          bCopyProtect                      0
      VideoStreaming Interface Descriptor:
        bLength                            38
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         1
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           360
        dwMinBitRate                 18432000
        dwMaxBitRate                 55296000
        dwMaxVideoFrameBufferSize      460800
        dwDefaultFrameInterval         666666
        bFrameIntervalType                  3
        dwFrameInterval( 0)            666666
        dwFrameInterval( 1)           1000000
        dwFrameInterval( 2)           5000000
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         2
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                 29491200
        dwMaxBitRate                 29491200
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval        5000000
        bFrameIntervalType                  1
        dwFrameInterval( 0)           5000000
      VideoStreaming Interface Descriptor:
        bLength                            11
        bDescriptorType                    36
        bDescriptorSubtype                  6 (FORMAT_MJPEG)
        bFormatIndex                        2
        bNumFrameDescriptors                2
        bFlags                              0
          Fixed-size samples: No
        bDefaultFrameIndex                  1
        bAspectRatioX                       0
        bAspectRatioY                       0
        bmInterlaceFlags                 0x00
          Interlaced stream or variable: No
          Fields per frame: 1 fields
          Field 1 first: No
          Field pattern: Field 1 only
          bCopyProtect                      0
      VideoStreaming Interface Descriptor:
        bLength                            38
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         1
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           360
        dwMinBitRate                 18432000
        dwMaxBitRate                 55296000
        dwMaxVideoFrameBufferSize      460800
        dwDefaultFrameInterval         666666
        bFrameIntervalType                  3
        dwFrameInterval( 0)            666666
        dwFrameInterval( 1)           1000000
        dwFrameInterval( 2)           5000000
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         2
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                 29491200
        dwMaxBitRate                 29491200
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval        5000000
        bFrameIntervalType                  1
        dwFrameInterval( 0)           5000000
      VideoStreaming Interface Descriptor:
        bLength                             6
        bDescriptorType                    36
        bDescriptorSubtype                 13 (COLORFORMAT)
        bColorPrimaries                     1 (BT.709,sRGB)
        bTransferCharacteristics            1 (BT.709)
        bMatrixCoefficients                 4 (SMPTE 170M (BT.601))
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass        14 Video
      bInterfaceSubClass      2 Video Streaming
      bInterfaceProtocol      0 
      iInterface              6 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               1

To avoid “uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround” I’ve set quirks to 0x0100.

Then I’ve tried to change the timeout too (to 10000 ms), but I always get the same error.

What could be the problem?

I’ve tried to acquire the data exchanged on the usb when I connect the Jetson to the Host (the device number is different from the previous output because I’ve done this test after some connection/disconnection of the Jetson). Before to connect the Jetson I’ve filter out every source of data on the usb using a series of “!(usb.device_address == ADDR1)&&!(usb.device_address == ADDR2)&&…&&!(usb.device_address == ADDRN)”.

Wireshark output on the Host side:

No.     Time           Source                Destination           Protocol Length Info
   3767 33.757933000   host                  0.0                   USB      64     GET DESCRIPTOR Request DEVICE

Frame 3767: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 0
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 743023
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 64
    Data length [bytes]: 0
    [Response in: 3768]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x01
    Language Id: no language specified (0x0000)
    wLength: 64

No.     Time           Source                Destination           Protocol Length Info
   3768 33.758398000   0.0                   host                  USB      82     GET DESCRIPTOR Response DEVICE

Frame 3768: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 0
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 743488
    URB status: Success (0)
    URB length [bytes]: 18
    Data length [bytes]: 18
    [Request in: 3767]
    [Time from request: 0.000465000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
DEVICE DESCRIPTOR
    bLength: 18
    bDescriptorType: 0x01 (DEVICE)
    bcdUSB: 0x0200
    bDeviceClass: Miscellaneous (0xef)
    bDeviceSubClass: 2
    bDeviceProtocol: 1 (Interface Association Descriptor)
    bMaxPacketSize0: 64
    idVendor: Linux Foundation (0x1d6b)
    idProduct: EEM Gadget (0x0102)
    bcdDevice: 0x0310
    iManufacturer: 1
    iProduct: 2
    iSerialNumber: 0
    bNumConfigurations: 1

No.     Time           Source                Destination           Protocol Length Info
   3775 33.885943000   host                  18.0                  USB      64     GET DESCRIPTOR Request DEVICE

Frame 3775: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 871033
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 18
    Data length [bytes]: 0
    [Response in: 3776]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x01
    Language Id: no language specified (0x0000)
    wLength: 18

No.     Time           Source                Destination           Protocol Length Info
   3776 33.886396000   18.0                  host                  USB      82     GET DESCRIPTOR Response DEVICE

Frame 3776: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 871486
    URB status: Success (0)
    URB length [bytes]: 18
    Data length [bytes]: 18
    [Request in: 3775]
    [Time from request: 0.000453000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
DEVICE DESCRIPTOR
    bLength: 18
    bDescriptorType: 0x01 (DEVICE)
    bcdUSB: 0x0200
    bDeviceClass: Miscellaneous (0xef)
    bDeviceSubClass: 2
    bDeviceProtocol: 1 (Interface Association Descriptor)
    bMaxPacketSize0: 64
    idVendor: Linux Foundation (0x1d6b)
    idProduct: EEM Gadget (0x0102)
    bcdDevice: 0x0310
    iManufacturer: 1
    iProduct: 2
    iSerialNumber: 0
    bNumConfigurations: 1

No.     Time           Source                Destination           Protocol Length Info
   3777 33.886422000   host                  18.0                  USB      64     GET DESCRIPTOR Request CONFIGURATION

Frame 3777: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 871512
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 9
    Data length [bytes]: 0
    [Response in: 3778]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x02
    Language Id: no language specified (0x0000)
    wLength: 9

No.     Time           Source                Destination           Protocol Length Info
   3778 33.886663000   18.0                  host                  USB      73     GET DESCRIPTOR Response CONFIGURATION

Frame 3778: 73 bytes on wire (584 bits), 73 bytes captured (584 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 871753
    URB status: Success (0)
    URB length [bytes]: 9
    Data length [bytes]: 9
    [Request in: 3777]
    [Time from request: 0.000241000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
CONFIGURATION DESCRIPTOR
    bLength: 9
    bDescriptorType: 0x02 (CONFIGURATION)
    wTotalLength: 309
    bNumInterfaces: 2
    bConfigurationValue: 1
    iConfiguration: 4
    Configuration bmAttributes: 0xc0  SELF-POWERED  NO REMOTE-WAKEUP
        1... .... = Must be 1: Must be 1 for USB 1.1 and higher
        .1.. .... = Self-Powered: This device is SELF-POWERED
        ..0. .... = Remote Wakeup: This device does NOT support remote wakeup
    bMaxPower: 250  (500mA)

No.     Time           Source                Destination           Protocol Length Info
   3779 33.886686000   host                  18.0                  USB      64     GET DESCRIPTOR Request CONFIGURATION

Frame 3779: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 871776
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 309
    Data length [bytes]: 0
    [Response in: 3780]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x02
    Language Id: no language specified (0x0000)
    wLength: 309

No.     Time           Source                Destination           Protocol Length Info
   3780 33.887036000   18.0                  host                  USB      373    GET DESCRIPTOR Response CONFIGURATION

Frame 3780: 373 bytes on wire (2984 bits), 373 bytes captured (2984 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 872126
    URB status: Success (0)
    URB length [bytes]: 309
    Data length [bytes]: 309
    [Request in: 3779]
    [Time from request: 0.000350000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
CONFIGURATION DESCRIPTOR
    bLength: 9
    bDescriptorType: 0x02 (CONFIGURATION)
    wTotalLength: 309
    bNumInterfaces: 2
    bConfigurationValue: 1
    iConfiguration: 4
    Configuration bmAttributes: 0xc0  SELF-POWERED  NO REMOTE-WAKEUP
        1... .... = Must be 1: Must be 1 for USB 1.1 and higher
        .1.. .... = Self-Powered: This device is SELF-POWERED
        ..0. .... = Remote Wakeup: This device does NOT support remote wakeup
    bMaxPower: 250  (500mA)
INTERFACE ASSOCIATION DESCRIPTOR
    bLength: 8
    bDescriptorType: 0x0b (INTERFACE ASSOCIATION)
    bFirstInterface: 0
    bInterfaceCount: 2
    bFunctionClass: Video (0x0e)
    bFunctionSubClass: 0x03
    bFunctionProtocol: 0x00
    iFunction: 5
INTERFACE DESCRIPTOR (0.0): class Video
    bLength: 9
    bDescriptorType: 0x04 (INTERFACE)
    bInterfaceNumber: 0
    bAlternateSetting: 0
    bNumEndpoints: 1
    bInterfaceClass: Video (0x0e)
    bInterfaceSubClass: 0x01
    bInterfaceProtocol: 0x00
    iInterface: 5
VIDEO CONTROL INTERFACE DESCRIPTOR [Header]
VIDEO CONTROL INTERFACE DESCRIPTOR [Input Terminal] (Entity 1)
VIDEO CONTROL INTERFACE DESCRIPTOR [Processing Unit] (Entity 2)
VIDEO CONTROL INTERFACE DESCRIPTOR [Output Terminal] (Entity 3)
ENDPOINT DESCRIPTOR
    bLength: 7
    bDescriptorType: 0x05 (ENDPOINT)
    bEndpointAddress: 0x81  IN  Endpoint:1
    bmAttributes: 0x03
    wMaxPacketSize: 16
    bInterval: 8
VIDEO CONTROL ENDPOINT DESCRIPTOR [Interrupt]
INTERFACE DESCRIPTOR (1.0): class Video
    bLength: 9
    bDescriptorType: 0x04 (INTERFACE)
    bInterfaceNumber: 1
    bAlternateSetting: 0
    bNumEndpoints: 0
    bInterfaceClass: Video (0x0e)
    bInterfaceSubClass: 0x02
    bInterfaceProtocol: 0x00
    iInterface: 6
VIDEO STREAMING INTERFACE DESCRIPTOR [Input Header]
VIDEO STREAMING INTERFACE DESCRIPTOR [Format Uncompressed]  (Format 1): YUY2
VIDEO STREAMING INTERFACE DESCRIPTOR [Frame Uncompressed]   (Index  1):  640 x  360
VIDEO STREAMING INTERFACE DESCRIPTOR [Frame Uncompressed]   (Index  2): 1280 x  720
VIDEO STREAMING INTERFACE DESCRIPTOR [Format MJPEG]  (Format 2)
VIDEO STREAMING INTERFACE DESCRIPTOR [Frame MJPEG]   (Index  1):  640 x  360
VIDEO STREAMING INTERFACE DESCRIPTOR [Frame MJPEG]   (Index  2): 1280 x  720
VIDEO STREAMING INTERFACE DESCRIPTOR 
INTERFACE DESCRIPTOR (1.1): class Video
    bLength: 9
    bDescriptorType: 0x04 (INTERFACE)
    bInterfaceNumber: 1
    bAlternateSetting: 1
    bNumEndpoints: 1
    bInterfaceClass: Video (0x0e)
    bInterfaceSubClass: 0x02
    bInterfaceProtocol: 0x00
    iInterface: 6
ENDPOINT DESCRIPTOR
    bLength: 7
    bDescriptorType: 0x05 (ENDPOINT)
    bEndpointAddress: 0x82  IN  Endpoint:2
    bmAttributes: 0x05
    wMaxPacketSize: 1024
    bInterval: 1

No.     Time           Source                Destination           Protocol Length Info
   3781 33.887062000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 3781: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 872152
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 3782]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x03
    Language Id: no language specified (0x0000)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   3782 33.887367000   18.0                  host                  USB      68     GET DESCRIPTOR Response STRING

Frame 3782: 68 bytes on wire (544 bits), 68 bytes captured (544 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 872457
    URB status: Success (0)
    URB length [bytes]: 4
    Data length [bytes]: 4
    [Request in: 3781]
    [Time from request: 0.000305000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 4
    bDescriptorType: 0x03 (STRING)
    wLANGID: English (United States) (0x0409)

No.     Time           Source                Destination           Protocol Length Info
   3783 33.887387000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 3783: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 872477
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 3784]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x02
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   3784 33.887674000   18.0                  host                  USB      92     GET DESCRIPTOR Response STRING

Frame 3784: 92 bytes on wire (736 bits), 92 bytes captured (736 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 872764
    URB status: Success (0)
    URB length [bytes]: 28
    Data length [bytes]: 28
    [Request in: 3783]
    [Time from request: 0.000287000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 28
    bDescriptorType: 0x03 (STRING)
    bString: Webcam gadget

No.     Time           Source                Destination           Protocol Length Info
   3785 33.887700000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 3785: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 872790
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 3786]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x01
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   3786 33.888120000   18.0                  host                  USB      98     GET DESCRIPTOR Response STRING

Frame 3786: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface 0
USB URB
    URB id: 0xffff880221dedc00
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 873210
    URB status: Success (0)
    URB length [bytes]: 34
    Data length [bytes]: 34
    [Request in: 3785]
    [Time from request: 0.000420000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 34
    bDescriptorType: 0x03 (STRING)
    bString: Linux Foundation

No.     Time           Source                Destination           Protocol Length Info
   3787 33.888558000   host                  18.0                  USB      64     SET CONFIGURATION Request

Frame 3787: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedcc0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: present (0)
    URB sec: 1448292932
    URB usec: 873648
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Response in: 3788]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x00
        0... .... = Direction: Host-to-device
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: SET CONFIGURATION (9)
    bConfigurationValue: 1
    wIndex: 0
    wLength: 0

No.     Time           Source                Destination           Protocol Length Info
   3788 33.888813000   18.0                  host                  USB      64     SET CONFIGURATION Response

Frame 3788: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedcc0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: not present ('>')
    URB sec: 1448292932
    URB usec: 873903
    URB status: Success (0)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Request in: 3787]
    [Time from request: 0.000255000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0

No.     Time           Source                Destination           Protocol Length Info
   3789 33.888821000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 3789: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221dedcc0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 873911
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 3790]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x04
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   3790 33.889113000   18.0                  host                  USB      76     GET DESCRIPTOR Response STRING

Frame 3790: 76 bytes on wire (608 bits), 76 bytes captured (608 bits) on interface 0
USB URB
    URB id: 0xffff880221dedcc0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 874203
    URB status: Success (0)
    URB length [bytes]: 12
    Data length [bytes]: 12
    [Request in: 3789]
    [Time from request: 0.000292000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 12
    bDescriptorType: 0x03 (STRING)
    bString: Video

No.     Time           Source                Destination           Protocol Length Info
   3791 33.889146000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 3791: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880221ded9c0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 874236
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 3792]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x05
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   3792 33.889358000   18.0                  host                  USB      86     GET DESCRIPTOR Response STRING

Frame 3792: 86 bytes on wire (688 bits), 86 bytes captured (688 bits) on interface 0
USB URB
    URB id: 0xffff880221ded9c0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292932
    URB usec: 874448
    URB status: Success (0)
    URB length [bytes]: 22
    Data length [bytes]: 22
    [Request in: 3791]
    [Time from request: 0.000212000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 22
    bDescriptorType: 0x03 (STRING)
    bString: UVC Camera

No.     Time           Source                Destination           Protocol Length Info
   3793 33.889487000   host                  18.0                  USB      64     SET INTERFACE Request

Frame 3793: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: present (0)
    URB sec: 1448292932
    URB usec: 874577
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Response in: 3794]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x01
        0... .... = Direction: Host-to-device
        .00. .... = Type: Standard (0x00)
        ...0 0001 = Recipient: Interface (0x01)
    bRequest: SET INTERFACE (11)
    bAlternateSetting: 0
    wInterface: 1
    wLength: 0

No.     Time           Source                Destination           Protocol Length Info
   3794 33.889628000   18.0                  host                  USB      64     SET INTERFACE Response

Frame 3794: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: not present ('>')
    URB sec: 1448292932
    URB usec: 874718
    URB status: Success (0)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Request in: 3793]
    [Time from request: 0.000141000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0

No.     Time           Source                Destination           Protocol Length Info
   3795 33.889646000   host                  18.0                  USBVIDEO 64     GET DEF Request  [Probe]

Frame 3795: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292932
    URB usec: 874736
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 26
    Data length [bytes]: 0
    [Response in: 4100]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
    [bInterfaceClass: Video (0x0e)]
URB setup
    bmRequestType: 0xa1
        1... .... = Direction: Device-to-host
        .01. .... = Type: Class (0x01)
        ...0 0001 = Recipient: Interface (0x01)
    bRequest: 135
    wValue: 0x0100
    wIndex: 1
    wLength: 26
bRequest: GET DEF (0x87)
Control Selector: Probe (0x01)
Interface: 0x01
Entity: 0x00
wLength: 26

No.     Time           Source                Destination           Protocol Length Info
   4100 38.885962000   18.0                  host                  USB      64     URB_CONTROL in

Frame 4100: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292937
    URB usec: 871052
    URB status: No such file or directory (-ENOENT) (-2)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Request in: 3795]
    [Time from request: 4.996316000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0

No.     Time           Source                Destination           Protocol Length Info
   4101 38.885980000   host                  18.0                  USBVIDEO 64     GET CUR Request  [Probe]

Frame 4101: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292937
    URB usec: 871070
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 26
    Data length [bytes]: 0
    [Response in: 4742]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
    [bInterfaceClass: Video (0x0e)]
URB setup
    bmRequestType: 0xa1
        1... .... = Direction: Device-to-host
        .01. .... = Type: Class (0x01)
        ...0 0001 = Recipient: Interface (0x01)
    bRequest: 129
    wValue: 0x0100
    wIndex: 1
    wLength: 26
bRequest: GET CUR (0x81)
Control Selector: Probe (0x01)
Interface: 0x01
Entity: 0x00
wLength: 26

No.     Time           Source                Destination           Protocol Length Info
   4742 43.885964000   18.0                  host                  USB      64     URB_CONTROL in

Frame 4742: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf6c0
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292942
    URB usec: 871054
    URB status: No such file or directory (-ENOENT) (-2)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Request in: 4101]
    [Time from request: 4.999984000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0

No.     Time           Source                Destination           Protocol Length Info
   4743 43.886192000   host                  18.0                  USB      64     GET DESCRIPTOR Request STRING

Frame 4743: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf240
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: relevant (0)
    Data: not present ('<')
    URB sec: 1448292942
    URB usec: 871282
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 255
    Data length [bytes]: 0
    [Response in: 4744]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x80
        1... .... = Direction: Device-to-host
        .00. .... = Type: Standard (0x00)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x06
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

No.     Time           Source                Destination           Protocol Length Info
   4744 43.887454000   18.0                  host                  USB      96     GET DESCRIPTOR Response STRING

Frame 4744: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface 0
USB URB
    URB id: 0xffff880065eaf240
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 18
    URB bus id: 1
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1448292942
    URB usec: 872544
    URB status: Success (0)
    URB length [bytes]: 32
    Data length [bytes]: 32
    [Request in: 4743]
    [Time from request: 0.001262000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
STRING DESCRIPTOR
    bLength: 32
    bDescriptorType: 0x03 (STRING)
    bString: Video Streaming

You mentioned that you’re using L4T R23.1 kernel (3.10.67), but earlier mentioned this was a TK1. The R23.1 kernel 3.10.67 might be ok with TK1, but this kernel was intended for TX1…just a warning that even if that kernel appears to work on TK1, there may be some unforeseen issue. Then again, maybe compiling and using this kernel on TK1 provides a better kernel. Time will tell.

I have not set up one of these webcam gadgets. I’m not sure what has to be added or configured on the Jetson to support this gadget, but I suspect the host is just doing what it’s supposed to do and the Jetson is failing to reply for lack of code or configuration. This is getting into the details of a specific class of device as well as the exact hardware being emulated. This information seems to support the notion that the gadget is not fully implemented or not fully configured:

[ 2701.178622] uvcvideo: Found UVC 1.00 device Webcam gadget (1d6b:0102)
[ 2706.181681] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[ 2711.185702] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[ 2711.185713] uvcvideo: Failed to initialize the device (-5).

The part which is missing is the control code whereby the host might do things such as request the camera snap a picture or just initialize. Most of the “gadget” code is a stub or framework that covers all that it can for a given class, but details need to be written in terms of either configuration or even kernel driver code additions. In this case all I can tell you is that the device is responding that the Jetson is this uvc video device, but that the host has no way to actually operate the device…this device operation code/configuration needs to be completed. In particular, the failure to query the uvc probe control means the host wants more information and the camera is not giving details.

If you have a similar uvc device which is a real device and if you have a way to monitor the same probe control, this may show what needs to be done. Otherwise I think it’s just a case of research.

You’re right I’ve made an error copying the version. Actually it is L4T R24.1 kernel (3.10.40) on TK1. I’ve corrected it.

I was hoping that g_webcam creates a /dev/video* and then use this device similar to the v4l2looback.
I’ll try to better analyse the problem.

Thanks linuxdev.

R21.4 rather than R24.1 :P

All of the “gadget” devices are intended as having what’s necessary to emulate that device, but none of them have all of the details to work without addition of some form of configuration or driver support. The g_mass_storage is probably the closest one to being able to configure without any real coding…anything more complicated will need a bit of extra effort.

:P I can write it correctly! :D

Yes I’ve tried to use g_mass_storage and g_ether and both work without problems.

Thanks linuxdev.

Hi,
Reference to above discussion, now our jetson-TK1 can be enumerated as a UVC device after connecting to the host side, and also having the same fail in the UVC streaming parameters negotiation [probe & commit controls] which is composed of UVC specific requests sequences [refer to USB_Video_Class_1.1 chapter 4]. See below output.

output on the Host side:

[10300.979577] usb 1-1: USB disconnect, device number 4
[10380.382998] usb 1-1: new high-speed USB device number 5 using ehci-pci
[10381.105795] usb 1-1: New USB device found, idVendor=0fb8, idProduct=1112
[10381.105799] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[10381.105800] usb 1-1: Product: UVC Camera
[10381.105802] usb 1-1: Manufacturer: UVC Test
[10381.281581] uvcvideo: Found UVC 1.00 device UVC Camera (0fb8:1112)
[10386.394888] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
[10391.395047] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[10391.395055] uvcvideo: Failed to initialize the device (-5).

The progress is that we can handle the GET request [for example GET_CUR, GET_DEF,…] by using V4L ioctl, to response data to host. But cannot handle the SET request to receive data from host.
For the SET request, we can get its SETUP command and know the following data length in the last field of SETUP command, but doesn`t known how to get the following data.
Is there any way to do that? Any help will be greatly appreciated.

Would you describe more about how this is set up? Is it correct that your Jetson TK1 is in device mode, and that you have used the gadget interface to make the Jetson appear as a USB video device? Assuming this is the case, is the Jetson itself expected to be controlled as a camera using some form of device emulation, or is the Jetson passing through control to an actual camera device? If there is an actual camera device, can you provide more details on how it is connected?

I am sorry I describe it not clear enough.

Yes, its correct that we want to make TK1 appear as a USB video device (UVC class).
In our model, jetson TK1 outputs image to PC via otg port while getting image from other usb camera connected with usb 3.0 port or from camera modules connected with MIPI-CSI interface.
Now were focusing on making Jetson be controlled as a usb camera means that we have to handle all kind of class specific request from the PC host for UVC enumeration, control and streaming. The [b]GET [/b] and [b]SET [/b]request mentioned from last post are delivered from the PC host, to get/set data from/to Jetson. And currently we have a problem in [b]SET [/b]request(SET_CUR) composed of [u]SETUP[/u] packet and [u]OUT[/u] data packet, we can receive the [u]SETUP[/u] packet but [u]OUT[/u] packet cant.

This is kind of a wide open topic, it’s hard to narrow down on what you specifically need. In general, what comes to mind are the design patterns “proxy” and “facade”. I don’t know enough about the UVC protocols for any detailed answer, but perhaps some questions and suggestions can help take it a step further.

It seems rather obvious that you want the Jetson to do more than run a camera. If you just wanted the camera, then you could have simply plugged the camera into your PC or recorded data and then streamed it over network. So I’m assuming you want something to be done by the Jetson using GPU processing prior to forwarding the data, but that you do not want to have to write a custom driver on your desktop PC (evidenced by mimicking a UVC device). Can you give more information on how you want Jetson to modify the video from your camera source before sending it on? Especially important are any real-time requirements and if the data is to be stored on disk or simply buffered in RAM, along with what you want to happen if data arrives too quickly or if the camera is actually disconnected from the Jetson.

Not knowing more, here are some thoughts on the project in general. First, you need to create a kernel space “proxy” (design pattern) object which behaves as if it were a camera driver. When in USB device mode using the gadget interface, only the very basics are actually implemented by the gadget code (gadget is a facade design pattern). The things which are purely USB are either provided or easily assigned as a kind of template. Actual device behavior is not assigned and is only a stub, requiring you to implement this. If for example a device special file has a defined set of ioctl calls to interface with that class, then you’ll have to write code to accept and behave correctly based on those calls. The behavior can be limited to the case of no actual camera, but I am unfamiliar with USB UVC requirements. Somewhere in USB UVC requirements will be a possible response by a camera that says the camera is unavailable, for example because of being in standby mode…you could choose to simplify all initial proxy response by pretending the camera is in a non-usable mode. Or you could have the proxy always pretend that every frame it shoots is always available, and that a test pattern is sent instead of what a real camera sees. The goal is that your device mode driver cannot be detected as not a real camera to your PC. You’ll have to understand UVC quite well to do that.

Once you have a proxy, you can use a user space application to process the v4l2 device special file of the real camera using completely stock and unmodified camera driver code. The user space application can do whatever transformations are required, e.g., color conversions or contrast changes, so on. One or more other device special files can be created from a new kernel driver, and your user space application can send to one device special file while receiving instructions from another device special file…the act of opening one of those file for read or write can cause the proxy to start taking real data and commands via this user space application, while closing those files could cause the proxy to go back to test pattern or standby behavior.

One reason I suggest using user space for the transformations is to keep from having to write a new driver for the camera itself when it plugs into USB on the Jetson. A less obvious reason is that you may not want to put a lot of code in the kernel where things can go wrong simply by consuming kernel mode time and blocking interrupts when it isn’t needed. Only CPU0 can process hardware interrupts, so pushing as much as possible to user space will in the end be less complicated if performance matters. The scheme of the “activate when device special file is opened” is simple, and for example is how the watchdog timer works (if you enable watchdog code in the kernel, and open a device special file for read, then the kernel code activates and reboots if the device special file is not written to in time…this is a perfect design you could re-use). In a way the gadget interface and the device special file to redirect to/from a proxy are design pattern facade, and connecting it to a proxy should have existing code samples.

Thank you for the useful suggestion.

This is a stereo vision project built in the Jetson. Now We have our own software tools in Windows for algorithm simulation, debug and camera calibration. For the reason, we have to forward images to the PC host. Temporarily we use grab image from other USB cameras for the Jetson and also directly use the USB cameras in the PC host. But in the future, well replace with MIPI-CSI camera modules mounted on the Jetson TK1 as an input source. Hence, we need another output interface of the Jetson TK1 to forward the image to the PC host, and thats why we try to implement the UVC on the Jetson.

Nice concept about the design patterns “proxy” and “facade”. Now we`re writing the camera driver code as the “proxy” at the same time.
Before the “proxy” is completed, we will have a test pattern to pretend real camera image and have some fake behaviors to response the UVC request.
So the first thing is to check if the UVC request can be correctly received in Jetson.
Based on the UVC spec, following stages show the general USB camera behavior during USB enumeration.

  1. Host gets descriptor from device (device provides UVC descriptor to host)
  2. Host gets control parameters from device
  3. Host negotiates the image format with device ( UVC Probe & commit control).
  4. Host notices device to start streaming
  5. device starts to forward the streaming data
    (Here the Host is PC, the device is Jetson TK1.)

Each stage is composed of standard UVC requests including the SET & GET requests.
Since we found we can get the events in user space when the UVC request is comming and do some V4L2 ioctl operations to response it, we try to implement all above stages. But as you know, we failed in handling “SET” request at the stage 3.

Below is the composition of SET request (with data) in USB packet layer.

Host                dir         Device
==========================================
SETUP packet        ->   
DATA-OUT packet     ->
                    <-          status packet

In our case, the “SETUP packet” event can be detected but “DATA-OUT packet” event can`t. After tracing kernel code(Tegra_udc.c) and observing the usb interrupt at run time, it seems no interrupt appears in tegra_udc_irq handler while “DATA-OUT packet” is coming (DATA-OUT packet can be probed in USB analyzer).

And so far we have no idea how to do. Is there any suggestion for that?

Before talking about GET/SET, one thing not yet mentioned are requirements for real-time. Unless the image size is small or the frame rate is small (or both, or some miraculous compression), a USB2 port will not stand a chance of having enough throughput to keep up. The micro-B port is only USB2 (480Mbit/s minus overhead), and would have trouble keeping up with just a single camera if for example this is hidef. How fast must data be passed? How much latency is allowed?

If you have the money, the first thing I’d do is throw on a USB2 analyzer. A USB2 analyzer is far less expensive than a USB3 analyzer, and the micro-B port is USB2, but even that has a significant cost. An analyzer would would probably give you instant results on what’s waiting or missing, or just validate what is already there. If you end up needing to build your own USB3 adapter, then you’ll need a USB3 analyzer (expensive, but you wouldn’t want to build a new USB3 device port without an analyzer).

I lack knowledge of UVC, but assuming you are using the gadget interface, it sounds like you’ve just run into the point where the stub of the interface now needs an implementation…have you written any code to react to the SETUP and put the proxy in a state to generate interrupts and switch to the next state for reading DATA-OUT packet? It may be up to your proxy to generate the interrupt or at least an ack to the SETUP packet. Something else I know nothing about is if your real MIPI-CSI camera module will generate hardware interrupts or not…it could be you need a second proxy to emulate a hardware interrupt (or two interrupts for stereo) and switch to the real interrupt when the module is physically installed.

Our primary video output resolution is 640x240 combined with two 320x240 resized image from both cameras.
the format is yuv422 / 8 bits,so the frame size will be 640 * 240 * 8 * 4 = 4.6875Mbits per frame.
Under USB2.0 high speed, we hope that the frame rate reach to 15 fps if no other device occupies the USB bandwidth.
Besides, we do not very care about the latency because the uvc camera is just for calibration and simulation with bigger latency tolerance.

Current webcam gadget driver bind to the V4L2 driver after module insertion. The V4L2 driver layer provides some APIs for UVC related operation for user space. Once USB UVC interrupt appears, the V4L2 driver will generate the related event, then if you subscribe the event, the application will be noticed to do some responses.

Following steps shows how to handle the UVC event.

  1. Open device special file /dev/video0
  2. Subscribe uvc event by calling API “VIDIOC_SUBSCRIBE_EVENT”
  3. Use select( ) to detect event
  4. Get SETUP(8 bytes) packet by calling API “VIDIOC_DQEVENT”
  5. Parse the SETUP packet, if its GET request, calling API “UVCIOC_SEND_RESPONSE” to response it. (The SET request is fail and under investigation now.)

our testing code shows below:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

/* getopt_long() */
#include <getopt.h>
/* low-level i/o */
#include <fcntl.h>

#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/poll.h>
#include <linux/videodev2.h>
#include "uvc.h"
#include <stdio.h>
#include <pthread.h>
//#include "uvc_def.h"
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

#define UVC_OUTPUT "/dev/video0"
#define CLEAR(x) memset(&(x), 0, sizeof(x))

enum io_method {
	IO_METHOD_READ,
	IO_METHOD_MMAP,
	IO_METHOD_USERPTR,
};

struct buffer {
	void   *start;
	size_t  length;
};

static char            *dev_name = (char*)UVC_OUTPUT;;
static enum io_method   io = IO_METHOD_MMAP;
static int              fd = -1;
struct buffer          *buffers;
static unsigned int     n_buffers;
static int              out_buf;
static int              force_format;

static void errno_exit(const char *s)
{
	fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno));
	exit(EXIT_FAILURE);
}
static void close_device(void)
{
	if (-1 == close(fd))
		errno_exit("close");

	fd = -1;
}
int isready(int fd)
{
	int rc;
	fd_set fds;
	struct timeval tv;

	FD_ZERO(&fds);
	FD_SET(fd, &fds);
	tv.tv_sec = 0;
	tv.tv_usec = 100;
	//printf("select!fd = %d\n", fd);
	//if (select (fd +1, NULL, NULL, &fds, &tv) < 0)
	if (select (fd +1, NULL, NULL,&fds , &tv) < 0)
		return -1;
	//printf("select end!fd = %d\n", fd);
	return FD_ISSET(fd, &fds)?1:0;

}
int iclass_specific_get_inft_request(uvc_event* req_data)
{
	usb_ctrlrequest req;
	if (NULL == req_data)
		return -1;

	memcpy (&req, &req_data->req, sizeof(usb_ctrlrequest));
	req_data->data.length = req.wLength;

	switch (req.bRequest)
	{
		case GET_CUR: // TODO
			break;
		case GET_MIN: // TODO
			break;
		case GET_MAX: // TODO
			break;
		case GET_RES: // TODO
			break;
		case GET_LEN: // TODO
			break;
		case GET_INFO:
			if (req.wValue == 0x0400)
			{
				req_data->data.data[0] = 0x03;
			}
			else if(req.wValue == 0x0900)
			{
				req_data->data.data[0] = 0x03;
			}
			else if(req.wValue == 0x0200)
			{
				req_data->data.data[0]  = 0x03;
			}
			break;
		case GET_DEF: // TODO
			break;
		default:
			break;
	}
	//printf ("req data s = 0x%x\n", req_data->data.data[0] );
	return 0;
}
int iclass_specific_request (int fd, usb_ctrlrequest* uvc_req)
{
	uvc_event req_data;
	v4l2_event V4l2_event;
	int iret = 0;

	if (fd == -1)
		return -1;

	if (NULL == uvc_req)
		return -1;

	memcpy (&req_data.req, uvc_req, sizeof(usb_ctrlrequest));
	printf("usb_ctrlreques:0x%02x, 0x%02x, 0x%04x, 0x%04x, 0x%04x\n", req_data.req.bRequestType, req_data.req.bRequest, req_data.req.wValue, req_data.req.wIndex, req_data.req.wLength);
	//GET Request
	if (req_data.req.bRequestType & 0x80)
	{
		if ((req_data.req.bRequestType & 0xf) == 0x01) // interface
		{
			iret = iclass_specific_get_inft_request(&req_data);
		}
		else if ((req_data.req.bRequestType & 0xf) == 0x10)
		{
			// endpoint -- TODO
		}

		// response data to usb host
		if (iret >= 0)
		{
			printf ("data length, = 0x%x, req data = 0x%x\n",req_data.data.length, req_data.data.data[0]);
			iret = ioctl (fd, UVCIOC_SEND_RESPONSE, &req_data.data);
		}
	}
	//SET Request -- TODO
	else
	{
		// dequeue event
		iret = ioctl (fd, VIDIOC_DQEVENT, &V4l2_event); // test
		printf("itet = %d, type:%d, ID=%d\n",iret, V4l2_event.type, V4l2_event.id ); //test
	}
	return iret;
}

int isubscribe_event (int fd, unsigned int uitype, unsigned int uiID, unsigned int uiflag)
{
	v4l2_event_subscription V4l2_sub;
	int iret = 0;
	if (fd == -1)
		return -1;

	V4l2_sub.type = uitype;
	printf("subcription type = %d\n", V4l2_sub.type );
	V4l2_sub.id = uiID;
	V4l2_sub.flags = uiflag;
	iret = ioctl (fd, VIDIOC_SUBSCRIBE_EVENT, &V4l2_sub);

	return iret;

}

static void* uvc_control_thread (void* arg)
{
	char* uargv;
	v4l2_event V4l2_event;
	usb_ctrlrequest uvc_req;
	int iret = 0;
	printf("create thread\r\n");
	// subscribe uvc class request event
	iret =  isubscribe_event (fd, UVC_EVENT_SETUP, 0, V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK);
	//iret =  isubscribe_event (fd, UVC_EVENT_DATA, 0, V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK);

	// Check event loop
	do
	{
		// check event entering
		if (isready(fd) > 0)
		{
			// dequeue event
			iret = ioctl (fd, VIDIOC_DQEVENT, &V4l2_event);
			printf("type:%d, ID=%d\n",V4l2_event.type, V4l2_event.id );
			memcpy(&uvc_req, V4l2_event.u.data, sizeof(usb_ctrlrequest));
			iret = iclass_specific_request (fd, &uvc_req);
		}
		usleep (100);
	}
	while( 1);

	return uargv;

}

int main(int argc, char **argv)
{
	struct stat st;
	struct pollfd fds;
	int iret = 0;
	int i;
	pthread_t id;

	// Open deive
	if (-1 == stat(dev_name, &st))
	{
		fprintf(stderr, "Cannot identify '%s': %d, %s\n", dev_name, errno, strerror(errno));
		exit(EXIT_FAILURE);
	}

	if (!S_ISCHR(st.st_mode))
	{
		fprintf(stderr, "%s is no device\n", dev_name);
		exit(EXIT_FAILURE);
	}

	fd = open(dev_name, O_RDWR /* required */ | O_NONBLOCK, 0);
	if (-1 == fd)
	{
		fprintf(stderr, "Cannot open '%s': %d, %s\n", dev_name, errno, strerror(errno));
		exit(EXIT_FAILURE);
	}

	// create thread for uvc control
	iret=pthread_create(&id, NULL, &uvc_control_thread, NULL);
	if(iret!=0)
	{
		printf ("Create pthread error!\n");
		exit (1);
	}
	pthread_join(id,NULL);

	close_device();

	return 0;
}

BTW, We have connected to USB analyzer to observe the USB bus activity at run time.
below link shows analyzer recorded for this issue.
http://imgur.com/0DtUzLN

Observing the USB bus by analyzer. Once we call the “VIDIOC_DQEVENT” to get the SETUP “packet”, the ack will be generated from udc PHY to complete the SETUP transition, then the DATA_OUT packet will follow up (but not complete). Unlike the “SETUP” packet, no interrupt happens while the “DATA-OUT” packet is coming.
As a result, maybe we have to add some code in tegra_udc.c to trigger interrupt? Or maybe the interrupt is shared with “SETUP” and we ust need to know how to get the data?

One thing I noticed which could help as an example is that in kernel config “Device Drivers -> Multimedia support” is a “Media test drivers” option, which in turn has “Virtual Video Driver”. This just generates a test pattern…I wonder what the USB analyzer would show for the SELECT when this is used instead of the proxy driver (media test drivers appears to be a proxy as well).

There are several kernel config options which help debug traffic between a host USB system and the driver, but it may be a moot point because the Jetson micro USB port is in device mode, not host mode. You could enable those options on your Linux host, but this won’t help in knowing what goes on inside the device mode Jetson. There does happen to be a kernel config for the gadget interface to go verbose, and this might help if it is something the gadget interface is paying attention to.

My interests have been in HID devices, so it is a struggle to absorb the UVC specification. Knowing exactly what to look at requires better knowledge than I have for UVC, or else actual hardware and USB analyzer to sit down with for testing.

Hi,

Maybe this would be useful for you:

Regards,

Hi Lukehuang,

I am experiencing the same problem with the g_webcam driver. I used a user space application that works perfect on other platforms but when using it on the TK1 I am getting the same probe/commit errors. I am using pretty much the same UVC configuration that worked on other platform (UVC driver has not changed a lot) so I am pretty sure the problem is on the tegra_udc driver or close to it. Did you find the cause of the setup issue based on your USB analysis tool?

Regards

Hi,

I am planning to interface multiple Small size spy camera(Mini size cameras) to the TK1 Board (Any interface USB,CSI etc.)for capturing 360 degree view.

Is that possible to interface spy cameras on TK1 Board? which spy camera would be suitable for the TK1 Board.

Hoping for the earnest reply.

Regards,
Saurabh Pahune