Writing USB Device Driver in Linux
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)?
Yes, but it is very dated. Look a kernelnewbies.org, lwn.net (Kernel page) for up to date information. Check the sites where USB and audio drivers hang out, perhaps this has been done/is in the works.
4 Answers 4
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.