在Linux中编写USB设备驱动程序

发布于 2024-11-06 06:54:25 字数 337 浏览 7 评论 0原文

ALSA 或 libusb api 是两种选择;两者对我来说都是新的;自从我编写设备驱动程序以来,已经有很多年了,它是在 80 年代为 Unix 编写的,但我确实知道,一旦我知道要使用什么工具,我就能弄清楚如何使用,我猜它们仍然使用 C;我查看了 libusb api;很不错;但我不知道 ALSA 项目;似乎他们准备将模块放入内核中以实现这一目标。

这是一个通用问题,但我感兴趣的设备是 Roland GR-55;它具有来自同一 USB 连接的 MIDI 和音频;它有 Windows 和 MAC 驱动程序,但没有 Linux。

您更喜欢使用哪些库或工具?

我是否编写设备驱动程序或可加载内核模块 (LKM)?

ALSA or libusb api are two choices; both are new to me; its been years since I wrote a device driver and it was for Unix back in the 80's, but I do know I can figure out how, once I know what tools to use, which I'm guessing both use C still; I have looked at the libusb api; very nice; but I have no idea about ALSA project; seems they are geared into getting modules into the kernel to achieve this.

This is a generic question, but the Device I'm interested in is the Roland GR-55; it has MIDI and Audio from the same USB connection; it has Windows and MAC Drivers but no Linux.

Which libraries or tools do you prefer to use?

Do I write a Device Driver or Loadable Kernel Modules (LKM)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

荒芜了季节 2024-11-13 06:54:25

libusb 很有用且易于启动和运行。我建议您从这里开始,特别是如果您已经有一段时间没有编写 Linux 驱动程序了。使用 libusb 了解 Roland GR-55 的信号协议是什么并做一些实验。

USB 支持通过同一物理线路进行多种类型的逻辑连接。设备可能有可用的数据和控制管道,您需要在启动正确的驱动程序之前将其映射出来。

正如我所说,libusb 很容易上手,如果您只想编写一个控制接口并存储来自设备的原始数据,几天后您就可以得到一些有用的东西。然而,如果您想将设备与现有音乐软件一起使用,ALSA 是您的最佳选择。此外,通过更新 ALSA,您将支持更大的社区,因为您可以将您的工作合并到 ALSA 项目中。

从头开始编写内核模块可能很有趣,但 USB 有点像野兽,可能不是一个理想的开始。有了 ALSA,您将拥有一个框架来指导您,而无需过多担心定义您自己的 API。

libusb is useful and easy to get up and running. I would suggest that you start there, especially if you haven't written Linux drivers in a while. Use libusb to understand what the signalling protocol is for the Roland GR-55 and do some experiments.

USB supports several types of logical connections over the same physical wire. There will likely be DATA and CONTROL pipes available from the device and you will need to map that out before starting on a proper driver.

As I said, libusb is easy to get going and you could have something useful in a few days if you just want to write a control interface and store raw data from the device. However, ALSA is the way to go if you want to use the device with existing music software. Also, by updating ALSA you would be supporting the larger community because you could merge your work in to the ALSA project.

Writing a kernel module from scratch could be fun, but USB is a bit of a beast and would probably not be an ideal one to start with. With ALSA you will have a framework to guide you and won't need to worry so much about defining your own APIs.

陌上青苔 2024-11-13 06:54:25

如上所述,请查看 Linux 设备驱动程序 http://lwn.net/Kernel/LDD3/ 章节13专门讨论了USB驱动程序。对于开发来说,将驱动程序编写为内核模块会更容易,因为这样在进行更改时就不需要重新编译内核。

As commented above, check out Linux Device Drivers http://lwn.net/Kernel/LDD3/ chapter 13 talks specifically about USB drivers. For development it's easier to write your driver as a kernel module because then you don't need to recompile the kernel when you make a change.

池予 2024-11-13 06:54:25

无需编写新的驱动程序 - ALSA 已经支持这一点一段时间了。请参阅提交 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=0ef283247a0cf0fd2e8370ee467030292eb3129e

No need for writing a new driver - ALSA already has support for that since a while. See commit https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=0ef283247a0cf0fd2e8370ee467030292eb3129e

剩余の解释 2024-11-13 06:54:25

由于您可能想在声卡上听到声音,因此您应该选择 ALSA。这样,当你完成后,你就完成了。如果您编写 libusb 驱动程序,那么您必须编写自己的用户空间工具来为声卡提供声音以供播放。

Since you probably want to hear sound on your sound card, you should opt for ALSA. That way after you are done you are done. If you write libusb driver, then you would have to write your own user space tools for feeding that sound card sound for playing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文