Tina V833 UVC设备的支持

213 篇文章 29 订阅
98 篇文章 7 订阅

第一步: 开启Tina USB HOST功能.

具体开启方法,可参考《Linux_USB_开发指南》文档

第二步:修改测试用例:

打开Tina menuconfig,配置MPP对UVC设备的支持。

 其次配置内核,打开内核对UVC设备的支持.内核选项CONFIG_USB_VIDEO_CLASS,支持UVC设备.

make kernel_menuconfig

 务必保证配置结束后,下列选项打开:

第三步,重新编译整个SDK,最后打包

之后烧录

第四步,编译UVC测试用例,之后adb推入平台端

打开对 framwork的支持:

修改framwork下的tina.mk,增加对sample_USBCamera用例的支持.

编译完成之后,用例和配置文件可以用ADB,也可以直接用磁盘,拷贝到TF卡上。

第五步:打开对USB HOST的支持

方法是控制台中输入以下命令

cat /sys/devices/platform/soc/usbc0/usb_host

 在插入UVC设备的情况下,输入以上命令,内核会自动探测并加载成功UVC设备,产生新的video设备节点,根据下面的LOG输出可以知道,一开始系统只有内部的/dev/video[0,1,2]三个节点,输入开启USB HOST命令成功后,会出现第四个/dev/video3节点,它就是我们想要的UVC的设备节点。

root@(none):/# cat /sys/devices/platform/soc/usbc0/usb_host
[  441.096205]
[  441.096205] rmmod_device_driver
[  441.096205]
[  441.103186] android_work: did not send uevent (0 0   (null))
[  441.109694]
[  441.109694] insmod_host_driver
[  441.109694]
[  441.109702] [ehci0-controller]: sunxi_usb_enable_ehci
[  441.109717] [sunxi-ehci0]: probe, pdev->name: 5101000.ehci0-controller, sunxi_ehci: 0xc06f3474, 0x:d08e0000, irq_no:12c
[  441.109779] sunxi-ehci 5101000.ehci0-controller: SW USB2.0 'Enhanced' Host Controller (EHCI) Driver
[  441.109843] sunxi-ehci 5101000.ehci0-controller: new USB bus registered, assigned bus number 1
[  441.154834] sunxi-ehci 5101000.ehci0-controller: irq 300, io mem 0xcf44bea7
[  441.185459] sunxi-ehci 5101000.ehci0-controller: USB 0.0 started, EHCI 1.00
[  441.194840] hub 1-0:1.0: USB hub found
[  441.199207] hub 1-0:1.0: 1 port detected
[  441.204489] [ohci0-controller]: sunxi_usb_enable_ohci
[  441.210258] [sunxi-ohci0]: probe, pdev->name: 5101000.ohci0-controller, sunxi_ohci: 0xc06f2c24
[  441.220025] sunxi-ohci 5101000.ohci0-controller: SW USB2.0 'Open' Host Controller (OHCI) Driver
[  441.229878] sunxi-ohci 5101000.ohci0-controller: new USB bus registered, assigned bus number 2
[  441.239644] sunxi-ohci 5101000.ohci0-controller: irq 301, io mem 0xced14000
[  441.320968] hub 2-0:1.0: USB hub found
[  441.325284] hub 2-0:1.0: 1 port detected
host_chose finished!
root@(none):/#
root@(none):/# ls /dev/video*
/dev/video0  /dev/video1  /dev/video2
root@(none):/# [  463.366514] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  463.555691] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  463.625448] usb 1-1: new high-speed USB device number 2 using sunxi-ehci
[  464.005448] usb 1-1: device descriptor read/64, error -71
[  464.205454] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  464.504838] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  464.513465] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  464.603249] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  464.865457] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  465.054032] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  465.305684] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  465.375448] usb 1-1: device descriptor read/64, error -71
[  465.569827] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  468.198548] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  468.395452] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  468.450194] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  468.458807] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect

root@(none):/#
root@(none):/# [A[[  485.499793] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  485.765446] usb 1-1: new high-speed USB device number 5 using sunxi-ehci
[  485.956660] usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x83 has an invalid bInterval 32, changing to 9
[  485.970307] uvcvideo: Found UVC 1.00 device GENERAL WEBCAM (1b3f:2247)
[  485.979750] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[  485.990154] uvcvideo 1-1:1.0: Entity type for entity Extension 7 was not initialized!
[  485.999057] uvcvideo 1-1:1.0: Entity type for entity Extension 6 was not initialized!
[  486.007894] uvcvideo 1-1:1.0: Entity type for entity Processing 5 was not initialized!
[  486.016836] uvcvideo 1-1:1.0: Entity type for entity Camera 1 was not initialized!
[  486.026177] input: GENERAL WEBCAM as /devices/platform/soc/5101000.ehci0-controller/usb1/1-1/1-1:1.0/input/input2
[  487.078609] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  487.087527] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  487.096293] usb 1-1: USB disconnect, device number 5
[  487.425609] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device connect
[  487.495450] usb 1-1: new high-speed USB device number 6 using sunxi-ehci
[  487.805453] sunxi-ehci 5101000.ehci0-controller: ehci_irq: highspeed device disconnect
[  488.275444] usb 2-1: new full-speed USB device number 2 using sunxi-ohci
[  488.528493] usb 2-1: not running at top speed; connect to a high speed hub
[  488.539514] usb 2-1: config 1 interface 1 altsetting 3 endpoint 0x85 has invalid maxpacket 1024, setting to 1023
[  488.551003] usb 2-1: config 1 interface 1 altsetting 4 endpoint 0x85 has invalid maxpacket 2816, setting to 1023
[  488.562470] usb 2-1: config 1 interface 1 altsetting 5 endpoint 0x85 has invalid maxpacket 3072, setting to 1023
[  488.573926] usb 2-1: config 1 interface 1 altsetting 6 endpoint 0x85 has invalid maxpacket 4948, setting to 1023
[  488.585387] usb 2-1: config 1 interface 1 altsetting 7 endpoint 0x85 has invalid maxpacket 5120, setting to 1023
[  488.605772] uvcvideo: Found UVC 1.00 device GENERAL WEBCAM (1b3f:2247)
[  488.615490] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[  488.625974] uvcvideo 2-1:1.0: Entity type for entity Extension 7 was not initialized!
[  488.634837] uvcvideo 2-1:1.0: Entity type for entity Extension 6 was not initialized!
[  488.643686] uvcvideo 2-1:1.0: Entity type for entity Processing 5 was not initialized!
[  488.652629] uvcvideo 2-1:1.0: Entity type for entity Camera 1 was not initialized!
[  488.661935] input: GENERAL WEBCAM as /devices/platform/soc/5101000.ohci0-controller/usb2/2-1/2-1:1.0/input/input3
root@(none):/#
root@(none):/#
root@(none):/#
root@(none):/# ls /dev/video*
/dev/video0  /dev/video1  /dev/video2  /dev/video3
root@(none):/#


第六步:测试验证:

首先执行命令挂载卡

mount -t vfat /dev/mmcblk0p1  /mnt/extsd

之后进入卡目录,输入以下命令验证测试用例

./sample_USBCamera  -path  ./sample_USBCamera.conf

关于Tina USB OTG Host/Device模式切换配置:

查看当前usb的角色:

cat /sys/devices/platform/soc/usbc0/otg_role

切换为host:

cat /sys/devices/platform/soc/usbc0/usb_host

切换为device:

cat /sys/devices/platform/soc/usbc0/usb_device

root@(none):/# cat /sys/devices/platform/soc/usbc0/otg_role
usb_host
root@(none):/# cat /sys/devices/platform/soc/usbc0/usb_device
[ 2509.225982]
[ 2509.225982] rmmod_host_driver
[ 2509.225982]
[ 2509.232845] [ehci0-controller]: sunxi_usb_disable_ehci
[ 2509.238657] [sunxi-ehci0]: remove, pdev->name: 5101000.ehci0-controller, sunxi_ehci: 0xc04c3e68
[ 2509.248510] sunxi-ehci 5101000.ehci0-controller: remove, state 1
[ 2509.255308] usb usb1: USB disconnect, device number 1
[ 2509.261653] sunxi-ehci 5101000.ehci0-controller: USB bus 1 deregistered
[ 2509.269195]
[ 2509.269195] insmod_device_driver
[ 2509.269195]
device_chose finished!
root@(none):/# [ 2509.517015] android_work: sent uevent USB_STATE=CONNECTED
[ 2509.576009] configfs-gadget gadget: high-speed config #1: c
[ 2509.582420] android_work: sent uevent USB_STATE=CONFIGURED

root@(none):/# cat /sys/devices/platform/soc/usbc0/otg_role
usb_device
root@(none):/# cat /sys/devices/platform/soc/usbc0/usb_host
[ 2524.490485]
[ 2524.490485] rmmod_device_driver
[ 2524.490485]
[ 2524.497542] android_work: sent uevent USB_STATE=DISCONNECTED
[ 2524.504723] read descriptors
[ 2524.504734] read strings
[ 2524.505395]
[ 2524.505395] insmod_host_driver
[ 2524.505395]
[ 2524.505400] [ehci0-controller]: sunxi_usb_enable_ehci
[ 2524.505411] [sunxi-ehci0]: probe, pdev->name: 5101000.ehci0-controller, sunxi_ehci: 0xc04c3e68, 0x:c4889000, irq_no:12a
host_chose finished![ 2524.505462] sunxi-ehci 5101000.ehci0-controller: SW USB2.0 'Enhanced' Host Controller (EHCI) Driver

root@(none):/# [ 2524.505502] sunxi-ehci 5101000.ehci0-controller: new USB bus registered, assigned bus number 1
[ 2524.505610] sunxi-ehci 5101000.ehci0-controller: irq 298, io mem 0xc383fea7
[ 2524.536770] sunxi-ehci 5101000.ehci0-controller: USB 0.0 started, EHCI 1.00
[ 2524.537532] hub 1-0:1.0: USB hub found
[ 2524.537566] hub 1-0:1.0: 1 port detected
[ 2524.585387] android_work: did not send uevent (0 0   (null))

root@(none):/# cat /sys/devices/platform/soc/usbc0/otg_role
usb_host
root@(none):/#

切换原理,切换节点是AW自定义的:


结束!

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
在 Linux 系统中,UVC 设备和 U 盘都是通过 USB 接口与计算机进行连接的。它们都使用了 USB 协议,并且在 USB 子系统中都被视为 USB 设备UVC 设备是指符合 USB 视频类设备(USB Video Class,简称 UVC)标准的设备,这类设备通常是摄像头或者视频采集卡等。UVC 设备在 USB 子系统中被识别为 USB 视频类设备,并且包含了对应的设备描述符和接口描述符等信息。 U 盘则是指通用 USB 存储设备,它通常用于存储数据。U 盘在 USB 子系统中被识别为 USB 存储设备,并且包含了对应的设备描述符和接口描述符等信息。 Linux 系统是通过设备驱动程序来区分不同类型的 USB 设备的。对于 UVC 设备,通常需要使用 UVC 驱动程序进行识别和管理;对于 U 盘,则需要使用 USB 存储设备驱动程序进行识别和管理。在内核中,不同类型的 USB 设备驱动程序通常是通过不同的 USB 设备类别(如 USB 视频类、USB 存储类等)进行区分的。 当系统检测到一个 USB 设备被插入时,它会自动根据设备描述符和接口描述符等信息进行匹配,并调用相应的驱动程序进行识别和管理。对于 UVC 设备和 U 盘,系统会根据它们的设备描述符和接口描述符等信息进行区分,并调用相应的驱动程序进行管理。 总的来说,UVC 设备和 U 盘在 Linux 系统中都是通过 USB 子系统进行识别和管理的,系统是通过设备描述符、接口描述符等信息来区分不同类型的 USB 设备的,并根据不同的设备驱动程序进行管理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

papaofdoudou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值