用户模式USB同步传输与设备到主机 [英] User mode USB isochronous transfer from device-to-host

查看:2507
本文介绍了用户模式USB同步传输与设备到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图从用户空间USB音频设备接口。我公司目前拥有的设备完全列举,我已经设置了接口,并设置了另外一个接口接口非零带宽的备用接口。

I am currently trying to interface with a USB audio device from user land. I currently have the device fully enumerated and I've set the interface and set the alternative interface to the interface non-zero-bandwidth alternative interface.

首先,我不得不说我不能使用像libusb的东西。我通过定义的Linux的USB设备文件系统来做到这一点。

Firstly I have to say I can't use anything like libusb. I ned to do this via Linux's USB device file system.

所以,据我可以告诉我已经准备好开始接收同步数据。不过,我可以找到如何做一个同步传输的信息非常少。

So as far as I can tell I'm ready to begin receiving isochronous data. However I can find very little information on how to do an isochronous transfer.

从我可以告诉我需要填充usbdevfs_urb结构,但我完全不能确定究竟如何填补这一结构。

From what I can tell I need to populate a usbdevfs_urb structure but I'm completely unsure of how exactly to fill this structure.

此外,一旦我填补这个结构我是正确的思维我需要调用以下内容:

Also, once I have filled this structure am I right in thinking I need to call the following:

int retSubmit   = ioctl( fd, USBDEVFS_SUBMITURB, &usbRequest );

然后一旦提交,我可以等待请求通过完成

and then once submitted I can wait for the request to complete using

USBDEVFS_REAPURBNDELAY

在REAPURBNDELAY的情况下,究竟是什么,我需要传递参数?

In the case of REAPURBNDELAY what exactly is the parameter I need to pass?

难道我连吠叫右树?

任何信息将是大规模AP preciated。

Any information would be massively appreciated.

在此先感谢!

编辑:

我试图做同步传输如下:

I attempt to do the isochronous transfer as follows:

usbdevfs_urb&   urbRequest      = *(usbdevfs_urb*)malloc( 384 );
urbRequest.type                 = USBDEVFS_URB_TYPE_ISO;
urbRequest.endpoint             = mpEndpoint->GetEndpointAddress();//mpEndpoint->GetEndpointIndex();
urbRequest.status               = 0;
urbRequest.flags                = USBDEVFS_URB_ISO_ASAP;
urbRequest.buffer               = pData;
urbRequest.buffer_length        = 0;
urbRequest.actual_length        = 0;
urbRequest.start_frame          = 0;
urbRequest.number_of_packets    = 1;
urbRequest.error_count          = 0;
urbRequest.signr                = 0;
urbRequest.usercontext          = pData;

usbdevfs_iso_packet_desc* pIsoPacketDesc    = &urbRequest.iso_frame_desc[0];
pIsoPacketDesc->length          = 384;
pIsoPacketDesc->actual_length   = 0;
pIsoPacketDesc->status          = 0;

Unfgortunately这给了我-28(EN​​OSPC)错误。

Unfgortunately this gives me an error of -28 (ENOSPC).

<7>[ 3184.243163] usb 1-1: usbfs: usb_submit_urb returned -28

我不明白为什么就不会有足够的USB总线带宽。只有1 USB端口和我的设备插入它的唯一设备。

I can't understand why there wouldn't be enough usb bus bandwidth. There is only 1 usb port and my device is the only device plugged into it.

有什么想法?

推荐答案

好了,所以事实证明,这个问题是由于一个事实,即Android操作系统已经放置在HID驱动来处理HID控制。这似乎是堵塞的带宽。卸下从HID接口,这些驱动程序释放带宽,允许同步传输继续。

Ok so it turns out that the problem is due to the fact that the android OS has placed an HID driver to handle the HID controls. This seems to block up the bandwidth. Detaching these drivers from the HID interfaces releases the bandwidth allowing the isochronous transfer to proceed.

您取下通过执行以下操作内核驱动程序:

You detach the kernel driver by doing the following:

usbdevfs_ioctl command;
command.ifno        = mpInterface->GetInterfaceNumber();
command.ioctl_code  = USBDEVFS_DISCONNECT;
command.data        = NULL;

int ret = ioctl( fd, USBDEVFS_IOCTL, &command );

否则我所做的是正确的。

Otherwise what I have done is correct.

这篇关于用户模式USB同步传输与设备到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆