您尚未登录。

楼主 # 2023-04-17 18:08:02

Flork
会员
注册时间: 2023-04-17
已发帖子: 6
积分: 40

求助:T5实现uvc视频输出问题

我需要利用T5的usb0输出视频图像,脚本参考run_otg,应用层demo来自uvc-gadget,应用层启动指令为./uvc-gadget -i /root/images.jpg -f 1 -s 1 -r 1。
在设备树中CONFIG_USB_F_UVC和CONFIG_USB_LIBCOMPOSITE都已经打开,接入Ubuntu之后也能识别出video设备,但是无法通过VLC或者cheese打开,想问下大佬们这是什么问题导致的,是应用层还是脚本的问题。几个打印信息的报错都找过,没能找到解决方法。。。

相关信息如下
在ubuntu中使用v4l-utils查看打印信息如下

❯ v4l2-ctl -d /dev/video0 --all
Driver Info (not using libv4l2):
        Driver name   : uvcvideo
        Card type     : UVC Camera (1f3a:100d): UVC Cam
        Bus info      : usb-0000:02:03.0-1
        Driver version: 5.4.218
        Capabilities  : 0x84A00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps   : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 1280/720
        Pixel Format      : 'MJPG'
        Field             : None
        Bytes per Line    : 0
        Size Image        : 460800
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 1280, Height 720
        Default     : Left 0, Top 0, Width 1280, Height 720
        Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1280, Height 720
Selection: crop_bounds, Left 0, Top 0, Width 1280, Height 720
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 15.000 (15/1)
        Read buffers     : 0
                     brightness 0x00980900 (int)    : min=0 max=255 step=1 default=127 value=0
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=0 value=0

VLC 报错日志

main debug: looking for art finder module matching "any": 2 candidates
v4l2 debug: opening device '/dev/video0'
v4l2 error: cannot open device '/dev/video0': Operation not permitted
v4l2 debug: opening device '/dev/video0'
v4l2 error: cannot open device '/dev/video0': Operation not permitted
main debug: no access_demux modules matched
main debug: creating access: v4l2:///dev/video0
main debug:  (path: /dev/video0)
main debug: looking for access module matching "v4l2": 29 candidates
v4l2 debug: opening device '/dev/video0'
v4l2 error: cannot open device '/dev/video0': Operation not permitted
main debug: no access modules matched

Ubuntu的dmesg信息

[18491.358318] usb 1-1: new high-speed USB device number 23 using ehci-pci
[18491.710832] usb 1-1: New USB device found, idVendor=1f3a, idProduct=100d, bcdDevice= 4.09
[18491.710834] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[18491.710834] usb 1-1: Product: 123
[18491.710835] usb 1-1: Manufacturer: Test
[18491.710835] usb 1-1: SerialNumber: 20080411
[18491.754885] uvcvideo: Found UVC 1.00 device 123 (1f3a:100d)
[18496.942618] uvcvideo: Failed to query (GET_INFO) UVC control 2 on unit 1: -110 (exp. 1).
[18497.056143] uvcvideo: Failed to query (GET_INFO) UVC control 2 on unit 2: -32 (exp. 1).
[18502.318681] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[18507.439217] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[18507.439221] uvcvideo: Failed to initialize the device (-5).

lsusb的输出为

❯ sudo lsusb -v -d 1f3a:100d
Bus 001 Device 023: ID 1f3a:100d Onda (unverified)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x1f3a Onda (unverified)
  idProduct          0x100d
  bcdDevice            4.09
  iManufacturer           1 Test
  iProduct                2 123
  iSerial                 3 20080411
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          175
    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 UVC Camera
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass        14 Video
      bInterfaceSubClass      1 Video Control
      bInterfaceProtocol      0
      iInterface              5 UVC Camera
      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     0x84  EP 4 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 Video Streaming
      VideoStreaming Interface Descriptor:
        bLength                            14
        bDescriptorType                    36
        bDescriptorSubtype                  1 (INPUT_HEADER)
        bNumFormats                         1
        wTotalLength                       61
        bEndPointAddress                  131
        bmInfo                              0
        bTerminalLink                       3
        bStillCaptureMethod                 0
        bTriggerSupport                     0
        bTriggerUsage                       0
        bControlSize                        1
        bmaControls( 0)                    11
      VideoStreaming Interface Descriptor:
        bLength                            11
        bDescriptorType                    36
        bDescriptorSubtype                  6 (FORMAT_MJPEG)
        bFormatIndex                        1
        bNumFrameDescriptors                1
        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                            30
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         1
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                442368000
        dwMaxBitRate                442368000
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  1
        dwFrameInterval( 0)            333333
      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 Video Streaming
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               1
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

在尝试使用g_webcam.ko之后也是不成功

最近编辑记录 Flork (2023-04-17 19:21:46)

离线

楼主 #1 2023-04-17 18:46:41

Flork
会员
注册时间: 2023-04-17
已发帖子: 6
积分: 40

Re: 求助:T5实现uvc视频输出问题

脚本如下

#!/bin/sh
# now using this scripts
# MODULES_DIR="/lib/modules/`uname -r`"
#insmod $MODULES_DIR/sunxi_usb_udc.ko
#insmod $MODULES_DIR/sunxi_usbc.ko

mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/g1
echo "0x1f3a" > /sys/kernel/config/usb_gadget/g1/idVendor
echo "0x100f" > /sys/kernel/config/usb_gadget/g1/idProduct
mkdir /sys/kernel/config/usb_gadget/g1/strings/0x409
echo "20080411" > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
echo "Test" > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer

mkdir /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p
echo 1280 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/wWidth
echo 720 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/wHeight
echo 333333 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/dwFrameInterval
echo 333333 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/dwDefaultFrameInterval
echo 442368000 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/dwMinBitRate
echo 442368000 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/dwMaxBitRate
echo 1843200 > /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/480p/dwMaxVideoFrameBufferSize
mkdir /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/mjpeg/m/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/class/fs
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/streaming/class/hs
mkdir /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/class/fs/
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/header/h/ /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/control/class/ss/

mkdir /sys/kernel/config/usb_gadget/g1/functions/ffs.adb
mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1
echo 0xc0 > /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
echo 500 > /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
mkdir /sys/kernel/config/usb_gadget/g1/functions/mass_storage.usb0
ln -s /sys/kernel/config/usb_gadget/g1/functions/mass_storage.usb0/ /sys/kernel/config/usb_gadget/g1/configs/c.1/mass_storage.usb0
mkdir /dev/usb-ffs
mkdir /dev/usb-ffs/adb
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb/
udc=`ls /sys/class/udc`
isudc=0
start(){
    while [ 1 ]
    do
        sleep 1
        otg_role=`cat /sys/devices/platform/soc/usbc0/otg_role`
        if [ "$otg_role" = "usb_device" ]
        then
            if [ $isudc == 0 ]
            then
                echo $udc > /sys/kernel/config/usb_gadget/g1/UDC
                isudc=1
            fi
        else
            isudc=0
        fi
    done
}
start &

echo > /sys/kernel/config/usb_gadget/g1/UDC
echo 0x100d > /sys/kernel/config/usb_gadget/g1/idProduct
rm /sys/kernel/config/usb_gadget/g1/configs/c.1/mass_storage.usb0
rm /sys/kernel/config/usb_gadget/g1/configs/c.1/uvc.usb0
ln -s /sys/kernel/config/usb_gadget/g1/functions/uvc.usb0/ /sys/kernel/config/usb_gadget/g1/configs/c.1/uvc.usb0
ls /sys/class/udc | xargs echo > /sys/kernel/config/usb_gadget/g1/UDC

离线

楼主 #2 2023-04-17 19:08:30

Flork
会员
注册时间: 2023-04-17
已发帖子: 6
积分: 40

Re: 求助:T5实现uvc视频输出问题

插入usb后机子的打印信息如下

[  142.870690] android_work: sent uevent USB_STATE=CONNECTED
[  143.444380] nf_conntrack: default automatic helper assignment has been turned off for security reasons and CT-based  firewall rule not found. Use the iptables CT target to attach helpers instead.
[  143.698733] configfs-gadget gadget: high-speed config #1: c
[  143.704992] configfs-gadget gadget: uvc_function_set_alt(0, 0)
[  143.711516] configfs-gadget gadget: reset UVC Control
[  143.717185] configfs-gadget gadget: uvc_function_set_alt(1, 0)
[  143.723808] configfs-gadget gadget: uvc_function_set_alt(1, 0)
[  143.730450] android_work: sent uevent USB_STATE=CONFIGURED
[  148.773269] handle_ep0: ep0 setup end
[  148.816828] handle_ep0: ep0 setup end
[  148.838899] configfs-gadget gadget: uvc_function_set_alt(1, 0)
[  153.874769] handle_ep0: ep0 setup end
[  153.936786] handle_ep0: ep0 setup end
[  158.963752] handle_ep0: ep0 setup end
[  159.054766] handle_ep0: ep0 setup end
[  584.116224] ERR: Operation not supported

最近编辑记录 Flork (2023-04-17 19:26:29)

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn