New USB MIDI driver for FreeBSD

Hans Petter Selasky hselasky at
Tue Apr 24 20:54:17 UTC 2007

On Tuesday 24 April 2007 22:15, Rasmus Kaj wrote:
> >>>>> "HPS" == Hans Petter Selasky <hselasky at> wrote on 2006-08-27:
>  HPS> During the past week I have been working on USB MIDI support for
>  HPS> FreeBSD. I choose the simplest approach, and that was to create
>  HPS> a raw/direct MIDI device.
> Hi!  Thanks for giving me some hope regarding MIDI on FreeBSD again!
>  HPS> svn --username anonsvn --password anonsvn \
>  HPS>       checkout svn://
> What version of FreeBSD was this supposed to work with?  I was able to
> run it with releng_6 as of about a week ago, but not talk to my midi
> device [1], so I thought I'd try it with current.  Unfortunatley,
> there seems to have been some changes (in bus_setup_intr and
> cam_sim_alloc, possibly more) in current that this code does not
> reflect.

Currently FreeBSD 6.x stable. You can get it working with FreeBSD 7.x also, 
but you need to work a little bit then.

> Is there a more up-to-date version somewhere else?  Should I go back
> to releng_6 and try to insert some "magic numbers" (device id) for my
> device?  Or is (relevant parts of) this included in current by now?
> Maybe current just needs some device ids?

No, the SVN version is the latest.

> By the way, what does the MIDI support have in common with the ISDN
> support?

Not much, except that there are USB ISDN adapters :-)

By the way, when you go into the "FreeBSD.usb" folder you don't install any 
ISDN stuff. Also don't forget editing and running the "".

I'm just looking forward till all of my code gets committed to FreeBSD. Then 
you don't have to worry any more.

> [1] I've got a "MIDI Mate", it is a simple gateway between a USB
> connector in one end an a single pair (in / out) of midi connectors in
> the other, that identifies as follows on FreeBSD current:

Same here, but there are some notes. When I implemented the USB MIDI support 
there was no MIDI API in the kernel, so I created my own. That means you get 
some raw devices, /dev/umidiX.X, which I have created some utilities for in 
my SVN repo.

So there might be some work to do, if you want to use your MIDI mate with 
ordinary MIDI applications.

> ugen0: <Ego Systems Inc XP MIDI mate, class 0/0, rev 1.10/1.01, addr
> 2> on uhub1
> Unknown USB device: vendor 0x0a92 product 0x1000 bus uhub1

Do a "svn update", make a new package, install it, and compile a new kernel.

If you use FreeBSD 7.x, then:

In /sys/dev/usb/usb_port.h, use the following:

/* preliminary fix for a bug in msleep on FreeBSD,
 * which cannot sleep with Giant:
#undef msleep
#define msleep(i,m,p,w,t) _sleep(i,(((m) == &Giant) ? \
  NULL : &(m)->mtx_object),p,w,t)

After this patch you have to insert a NULL argument, to all bus_setup_intr() 
functions you find in the files /sys/dev/usb/*pci.c like shown below ?

        error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
-                              si_intr, sc, &ih);
+                              NULL, si_intr, sc, &ih);

Also please find attached the "/usr/src/sys/dev/sound/usb/uaudioxxx" 
and "/usr/src/sys/dev/sound/pcm/mixerxxx" files you need.


More information about the freebsd-multimedia mailing list