[haiku-development] Re: (USB MIDI) Device hierarchy

  • From: Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 10 Feb 2011 21:19:00 +0100

> Yes, it's there in the MIDI Endpoint Descriptor as an extended field.
> I presume it is actually read -- just not exposed by the current structure.
> That's what I intend to play with today.

I just defined those missing MIDI descriptors structs. in r40429.
You can get some coding inspiration from ACMDevice::AddDevice()
(src/add-ons/kernel/drivers/ports/usb_serial/ACMDevice.cpp) to see how
interface generic descriptors are parsed there.
It would be a little bit more complex for usb_midi, as there is more
variable length descriptors.

BTW, everybody is welcome to attach the "listusb -v
/dev/bus/usb/<path_to_your_midi_device_here>" command output of their
USB MIDI adapter(s) to this ticket:
http://dev.haiku-os.org/ticket/4463
That will help us a lot to actually see those descriptors dump and,
hopefully, how useable are the jack strings given by manufacturers, if
any.

>> What the driver is not ready is to multiplex the received
>> usb_midi_event_packet on the matching dev entry according to the
>> channel number.
>
> I think we will need one ring-buffer per 'cable'.

For input demultiplexing, yes.
For output multiplexing, it's only a matter of writing the jack ID
affected to the device entry in the "cn" field and queueing the
midi packet will to the multiplexing/serializing for free. It's done
already that way, except cn is always set to 0 with no warrant it's a
valid MIDI jack ID, which could also explain that nothing comes out on
complex USB MIDI keyboard, for instance ;-)

Each bulk endpoint is supposed to advertize a class-specific endpoint
descriptor giving the list of
jack id(s) connected to this endpoint. The "cn" field is in midi event
packet received is the source jack id.
On output, it should be set to the destination jack id.
Parsing this descriptor will give how much input and output jacks are
available per endpoint, doing this for all endpoints and for all
interfaces of a device will give the total input and output port to
support for this device only.

What worry me is, after reading again the spec, I fail to see how you
could know which MIDI IN and MIDI OUT jacks are actually sharing the
same *physical* cable.
:-\

That would means, then, that we should publish
/dev/midi/usb/<device_unique_id>/in/<jack_id> and a distinct entry for
the output jacks.
Each device entry will be only MidiProducerPort or MidiConsummerPort
in the midi_server, then.
Since r40419 it should support this case, though.

Other related posts: