uvc-gadget icon indicating copy to clipboard operation
uvc-gadget copied to clipboard

UVC: Possible USB shutdown requested from Host, seen during VIDIOC_DQBUF

Open embedded-explorer opened this issue 4 years ago • 6 comments

We are using zynq Ultrascale + MPSoC with custom board. Our board has 2 USB ports(Host 2.0 and device 3.0), 2 SDI(one input and another output). Kernel version on board is 4.19.0 and In host PC 5.4.0-58-generic. Final project according to customers requirement is Streaming 1080p video taking input from SDI and taking output from USB(device). Currently We are trying with connecting C922 Pro Stream Webcam to USB(host) port.This creates /dev/video0 node. Then modprobe g_webcam. This creates /dev/video1. Using the application https://github.com/peterbay/uvc-gadget At host side /dev/video0 is created. When I try to display using application such as guvcview, at the device side, getting below attached log. I need some more input so that I can move forward with this project. USBGITLOG.txt host

embedded-explorer avatar Feb 26 '21 11:02 embedded-explorer

Manual for installation of uvc-gadget you can found at http://www.davidhunt.ie/raspberry-pi-zero-with-pi-camera-as-usb-webcam/. My version of uvc-gadget is based on David Hunt repo. You can check your configuration with a script gadget-check.sh. Here is the sample output from gadget-check.sh after proper setup.

INFO: --- Gadget check ---
INFO: Configfs path:        /sys/kernel/config
INFO: libcomposite module:  libcomposite 57344 25 usb_f_acm,usb_f_uvc, Live 0x00000000
INFO: dwc2 module:          dwc2 163840 0 - Live 0x00000000
INFO: Gadget path:          /sys/kernel/config/usb_gadget/rpi_gadget
INFO: UDC interface:        20980000.usb
INFO: USB UDC driver:       rpi_gadget
INFO: Gadget configs:       /sys/kernel/config/usb_gadget/rpi_gadget/configs/c.2/acm.usb0
INFO: Gadget configs:       /sys/kernel/config/usb_gadget/rpi_gadget/configs/c.2/uvc.usb0
INFO: Gadget function:      /sys/kernel/config/usb_gadget/rpi_gadget/functions/acm.usb0
INFO: Gadget function:      /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/1200p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/900p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/864p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/1080p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/960p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/720p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/768p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/600p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/480p
INFO: UVC streaming format: /sys/kernel/config/usb_gadget/rpi_gadget/functions/uvc.usb0/streaming/mjpeg/m/360p

peterbay avatar Mar 04 '21 19:03 peterbay

  • In my case webcam gadget configuration is made using g_webcam module(drivers/usb/gadget/legacy/webcam.c) and dwc3 driver is used because I am using USB 3.0 inteface(super-speed) for 1080p@60 fps . So before executing gadget-check.sh I need to modify it.

  • First I need to prove the interface using vivid(virtual video driver) as a source to webcam gadget. So I execute #modprobe vivid [ 28.237715] vivid-000: using single planar format API [ 28.244827] vivid-000: V4L2 capture device registered as video3 [ 28.250901] vivid-000: V4L2 output device registered as video4 [ 28.256846] vivid-000: V4L2 capture device registered as vbi0, supports raw and sliced VBI [ 28.265248] vivid-000: V4L2 output device registered as vbi1, supports raw and sliced VBI [ 28.273539] vivid-000: V4L2 capture device registered as swradio0 [ 28.279758] vivid-000: V4L2 receiver device registered as radio0 [ 28.285869] vivid-000: V4L2 transmitter device registered as radio1

  • Two video dev nodes are creates - /dev/video3 and /dev/video4 Then I check the capability of /dev/video3 #v4l2-ctl -d /dev/video3 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Type: Video Capture

      [0]: 'YUYV' (YUYV 4:2:2)
              Size: Discrete 320x180
                      Interval: Discrete 1.000s (1.000 fps)
                      Interval: Discrete 0.500s (2.000 fps)
                      Interval: Discrete 0.250s (4.000 fps)
                      Interval: Discrete 0.200s (5.000 fps)
                      Interval: Discrete 0.100s (10.000 fps)
                      Interval: Discrete 0.067s (15.000 fps)
                      Interval: Discrete 0.040s (25.000 fps)
                      Interval: Discrete 0.033s (30.000 fps)
                      Interval: Discrete 0.020s (50.000 fps)
                      Interval: Discrete 0.017s (60.000 fps)
              Size: Discrete 640x360
                      Interval: Discrete 1.000s (1.000 fps)
                      Interval: Discrete 0.500s (2.000 fps)
                      Interval: Discrete 0.250s (4.000 fps)
                      Interval: Discrete 0.200s (5.000 fps)
                      Interval: Discrete 0.100s (10.000 fps)
                      Interval: Discrete 0.067s (15.000 fps)
                      Interval: Discrete 0.040s (25.000 fps)
                      Interval: Discrete 0.033s (30.000 fps)
              Size: Discrete 1280x720
                      Interval: Discrete 1.000s (1.000 fps)
                      Interval: Discrete 0.500s (2.000 fps)
                      Interval: Discrete 0.250s (4.000 fps)
                      Interval: Discrete 0.200s (5.000 fps)
                      Interval: Discrete 0.100s (10.000 fps)
                      Interval: Discrete 0.067s (15.000 fps)
              Size: Discrete 1920x1080
                      Interval: Discrete 1.000s (1.000 fps)
                      Interval: Discrete 0.500s (2.000 fps)
                      Interval: Discrete 0.250s (4.000 fps)
                      Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 3840x2160
                      Interval: Discrete 1.000s (1.000 fps)
                      Interval: Discrete 0.500s (2.000 fps)
    

and many more formats...............................

But I need to test 1080@60 fps, but I have proven 1080@5 till now.

  • I am trying to set resolution #v4l2-ctl -d /dev/video3 --set-fmt-video=width=1920,height=1080,pixelformat=0
  • Then fps #v4l2-ctl -d /dev/video3 -p 60 Frame rate set to 5.000 fps how do I achieve 1080@60fps? 1080p

embedded-explorer avatar Mar 08 '21 08:03 embedded-explorer

The vivid driver will not do 1080p60 from what I recall. That's hard coded in the vivid driver, so you can add new rates, but no guarantees on performance as I believe the driver generates each frame.

kbingham avatar Mar 08 '21 08:03 kbingham

Thank you for immediate reply. As you said I have hard coded in vivid driver, but I can observe frame drops even if I increase the number of buffers. Instead of vivid can I go with gstreamer commands to send test patterns?

  • If so, then how do I specify uvc sink ? videotestsrc -> /dev/video3 (g_webcam video node)

  • If not, any other input from your knowledge is appreciated.

embedded-explorer avatar Mar 08 '21 11:03 embedded-explorer

SDI to UVC

TESTING PROCEDURE THAT I FOLLOW:

  1. Connect SDI cable which will create /dev/video0 node

v4l2-ctl -d /dev/video0 --all Driver Info: Driver name : xilinx-vipp Card type : vcap_sdirx output 0 Bus info : platform:vcap_sdirx:0 Driver version : 4.19.0 Capabilities : 0x84201000 Video Capture Multiplanar Streaming Extended Pix Format Device Capabilities Device Caps : 0x04201000 Video Capture Multiplanar Streaming Extended Pix Format Media Driver Info: Driver name : xilinx-video Model : Xilinx Video Composite Device Serial : Bus info : Media version : 4.19.0 Hardware revision: 0x00000000 (0) Driver version : 4.19.0 Interface Info: ID : 0x03000003 Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : vcap_sdirx output 0 Function : V4L2 I/O Pad 0x01000002 : 0: Sink Link 0x02000007: from remote pad 0x1000006 of entity 'a0040000.v_smpte_uhdsdi_rx_ss': Data, Enabled Priority: 2 Video input : 0 (a0040000.v_smpte_uhdsdi_rx_ss: ok) Format Video Capture Multiplanar: Width/Height : 1920/0 Pixel Format : 'YUYV' Field : None Number of planes : 0 Flags : Colorspace : sRGB Transfer Function : Default YCbCr/HSV Encoding: Default Quantization : Default Selection: compose, Left 0, Top 0, Width 0, Height 0, Flags: Selection: compose_default, Left 0, Top 0, Width 1920, Height 0, Flags: Selection: compose_bounds, Left 0, Top 0, Width 1920, Height 0, Flags: Selection: crop, Left 0, Top 0, Width 0, Height 0, Flags: Selection: crop_default, Left 0, Top 0, Width 1920, Height 0, Flags: Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 0, Flags:

User Controls

low_latency_controls 0x0098ca21 (int) : min=2 max=8 step=1 default=4 value=4 root@PRGLT:~# v4l2-ctl -d /dev/video0 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Type: Video Capture Multiplanar

[0]: 'XM20' (Y/CrCb 4:2:2 10-bit (N-C)) [1]: 'XV20' (Y/CrCb 4:2:2 10-bit) 2) modprobe g_webcam

which will create /dev/video1 node

  1. Running the application ./uvc-gadget -r 0 -s 2 -f 0 -u /dev/video1 -v /dev/video0

V4L2 open V4L2: /dev/video0 is V4L2_CAP_VIDEO_CAPTURE_MPLANE video capture device V4L2: /dev/video0 is no video capture device

My query is:

  1. How do I handle multiplanar input video in this application?
  2. If the input format is XV20 and XM20 and if my application expects YUYV and MJPG, how do we deal with it?

Can you please help me in streaming SDI to UVC 3.0 with 1080p @ 60fps?

embedded-explorer avatar Mar 12 '21 09:03 embedded-explorer

Hello, I'm using zynq to implement UVC. The underlying USB3.0 hardware has been enabled. Please refer to the official tutorial given by Xilinx:”https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/2046001302/Building+Linux+usb+device+drivers+with+2021.1#UVC-Gadget“; But the results I got are inconsistent with those in the tutorial. Figure 1 shows the results of the tutorial, and Figure 2 shows the results I produced according to the tutorial. Why is this? picture 1:

image

picture 2:The process will be stuck in "v4l2:2 buffers allocated", and there will be no change image

66cavy avatar Jul 06 '22 10:07 66cavy