UHCI Driver

Blog post by emitrax on Sun, 2007-04-29 22:10

After reading the main part of the USB specs, I moved on to the UHCI driver specs this week-end. I can now say, that implementing the isochronous part to the UHCI driver is a lot easier than I thought, and I guess Micheal can confirm. While reading the UHCI specs I followed Micheal's code, and I have some questions about it, but I'll write him an email for that. By the way, is R1 intended only for x86?

I just wanted to _announce_, that my gsoc project will probably change to adding USB OHCI full support, as the former would take less than a whole summer. I obviously already talked to both my mentor Oliver and Micheal about it. If it's ok with him though, I'd like to add isochronous support to the UHCI driver first. By the way, how does it work with patches and commits? Shall I just commit my changes to the svn or shall I first provide a patch so that someone can review it before it goes into the svn?

Anyway, I'm looking for some USB driver written in kernel space to see how drivers communicate with the bus_manager. I'm also looking for some USBKit documentation, even though I found some code like the FinePix driver, and the usb_dev_info command line that use it.

I guess it's all for now.

Stay tuned ;-)

Comments

Re: UHCI Driver

Admin note (2009-10-04): Updated links to refer to svn.haiku-os.org.

We've few USB kernel drivers already in our source tree, like:
http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/kernel/drivers/inp...
http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/kernel/drivers/por...
http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/kernel/drivers/mid...
http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/kernel/drivers/aud...

Even the USB stack <-> userland gateway driver, usb_raw, could worth a look on how to use the USB module API:
http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/kernel/drivers/bus...

Regarding isochronous transferts, usb_audio is a good kernel driver to stress output transferts. You'll need some USB speakers for that, though. For isochronous *input* transferts, AFAIK we don't have any kernel driver using it yet.
I've an unfinished (like always :-\ ) kernel driver for Philips webcams (Logitec QuickCam 4000 Pro & like) that rely on isochronous inputs, I will commit it in a few days...

----
Philippe Houdoin, occasional OpenGL & Networking team leader ;-)

Re: UHCI Driver

Admin note (2009-10-04): Updated links to refer to svn.haiku-os.org.

As for usb_audio driver, I recall trying to fix it once to work with the v3 usb bus manager, but it didn't fit exactly. Though I added some other stuff to support other descriptors because the usb key I had there (At BeGeistert, that was from another french dev) was different than the single supported one.
I'll dig that and see if I can commit anything to help.

About kernel webcam drivers, I'd advise you to move to userland.
I also started by a kernel driver for mine (Sonix cheapo), as I fancy kernel land more, but for what is needed there isn't really much that is required in the kernel. It led to duplicating the init code from other driver for nothing, and deframing functions not easy to debug. In fact, the USB Kit works quite well for mine. For others it would just need to get support for isochronous (hint). Plus you will require a media addon anyway to interface with the media kit. At most the kernel driver will only contain usb init stuff (set_configuration()) and that's it. It could be made generic like usb_scanner, but it's IMO useless, as means having to maintain 2 lists of USB IDs, one in the driver and one in userland, just like usb_scanner needs to be fixed when one updates SANE, and believe me it's a pain once you did that 4 or 5 times already.
Also the usb_webcam driver in http://svn.haiku-os.org/haiku/haiku/trunk/src/add-ons/media/media-add-on... should be modular enough you can fit yours quite easily in I hope, and make parts sharable with other webcams (usually they share either sensors or usb chips between brands/models).

Re: UHCI Driver

François, I agree.

But AFAIK the USBKit didn't support Isochronous transfer, and Philips webcams uses these beasts. Hence why I've started a kernel driver, and I don't fancy kernel land that much...

I also think we don't even needs an usb_scanner kernel driver anymore, the usb_raw + USBkit (wrapped into a BeOS-libusb) should be enough these days.
Which make me think that BeOS have a Device Kit, and USB kit should be in fact part of it, IMHO.

----
Philippe Houdoin, occasional OpenGL & Networking team leader ;-)

Re: UHCI Driver

Yes USB Kit doesn't support iso yet, thus the *hint* :)
I once meant to add it to the Zeta version, but I think my USB controller didn't work with iso, so it wouldn't have been testable.

Anyway I'd like first to at least get my own webcam working in Haiku, but the usb controller doesn't like it it seems ("can't set device address" or so in syslog)...

Re: UHCI Driver

Great news! I got my wireless keyboard (logitech keyb and mouse) working with the Haiku usb stack from mlotz, thanks a lot all of you!

:-)

Re: UHCI Driver

Btw, I asked Michael some time ago to make the usb_raw.h file publicisable, so I could use it in SANE directly. I'd likely also write a libusb.so compatible with the Linux one (there is also a win32 version so it's becoming a standard), as some SANE backends insist on using it instead of the compatibility layer.
That would include renaming ioctl codes and structs to have the B_ prefix, and also removing the last struct (internal device descriptor of interest only to the driver itself) which would also get lock.h out of it, which would also allow building the USBKit.a for dano with DEBUG=1.

Re: UHCI Driver

What about Haiku having a libusb.so that would export both USB Kit API and the Linux "libusb" API, the later using the former? Or move this into libdevice.so, and have a libusb.so symlinked to it?

----
Philippe Houdoin, occasional OpenGL & Networking team leader ;-)

Re: UHCI Driver

Yes that was the plan, getting both in libusb.so or something alike =)

OHCI

If you are starting on OHCI, drop me a line. I´ve got some code lying around that you might want to have a look at, as well as some helpful pointers.