2

我有一个嵌入式 Linux 项目,我需要通过 USB 端口读取视频,对该视频进行一些修改(例如压缩),然后最好通过相同的 USB 端口将其发送回主机。如果我们可以发送命令来更改诸如从主机到设备的视频压缩级别等内容,这也是一个首选功能。

可以假设主机是运行某个版本的 Linux 的桌面,而实际执行此视频处理的设备是运行嵌入式 Linux 的 Gumstix。

我基本上不知道如何开始这个项目或在 Linux 中的输入/输出划分中研究什么。首先,是否可以通过同一个 USB 端口同时读取视频、写入视频和发送命令?视频比较小,尤其是经过设备压缩后,所以带宽不是问题。主要问题是知道从哪里开始这个项目的研究。有没有像 USB 的 TCP/IP 这样的东西,您可以在主机和设备之间打开多个连接来传输数据?

我们是否必须编写自己的 USB 设备驱动程序?开发我们自己的协议还是 USB 支持在同一个端口上做多个事情相对容易?

我应该开始研究 Linux 驱动程序、用户级编程和 API 还是 USB 协议?还是完全不同的东西?

我是一名高级计算机工程专业的学生,​​所以我的经验水平是 C、C++、Java、Verilog、TCL 等编程的混合体。几乎所有与套接字相关的编程都使用 Java(独立于操作系统)所以我真的不确定从哪里开始编写 Linux 应用程序来执行这样的任务。我在微处理器编程(AVR、coldfire)方面有相当多的经验,但是尽管已经接近我需要的东西,但它并没有真正帮助我弄清楚从哪里开始。

4

2 回答 2

4

USB 端口有两种形式;主机是总线的控制器,可以在 PC 和设备上找到,也可以在 Linux 中找到一个小工具(静态相机中常见的一个版本,端口可以在连接时切换类型,称为 USB on the go)。一个主机端口可以连接到多个小工具端口(通过集线器)。主机在很大程度上控制着作为奴隶运行的小工具。两种端口类型的硬件非常不同,许多嵌入式内核包含每种类型控制器的示例。Linux 内核包含 OHCI EHCI 和 UHCI 主机控制器硬件的主机驱动程序和各种协议驱动程序(打印机、键盘等)。对于某些设备类型,USB 组织已实施标准协议,因此您无需

If you want your device to talk to a PC host you will need to implement a device/gadget interface, there is far greater variety in hardware designs for the other end of the cable, but you should find the Linux kernel supports a selection of the more common ones.

The gadget directory also includes a selection of protocol drivers as well. One trick that could save a lot of work would be to configure your device to appear as a USB network interface, this avoids writing a lot of low level stuff and you can take advantage of the network diagnostic tools and the USB layer is abstracted out of your application on both ends. This even works with a Windows host without needing to write custom Windows drivers (XP only supports the Microsoft RNDIS USB protocol and the Windows driver is buggy and can hang on disconnects but the kernel includes a RNDIS wrapper and this solution can be made to work well).

I wasn't sure from your question is the video source was an independent USB device in which case it will need a separate USB host port on your device or if it was supplied by the host.

Get your self set of kernel sources and study the USB gadget directory, also download the USB specifications from USB.org You will want to understand chapters 8 9 10 11 as they explain what happens once a host detects a gadget and also the concept of endpoints. Mindshare did USB book that was a ok as a quick introduction to USB.

于 2010-10-26T07:37:18.853 回答
1

您想要的是 Linux 上的“Gadget”驱动程序——一种使 Linux 充当 USB 设备的驱动程序。这篇关于 USB 复合框架的 LWN 文章是一个很好的起点。

于 2010-10-06T10:30:13.503 回答