Subject: retry: NetBSD umidi driver shuns M-Audio / Midiman Midisport 2x4
To: None <tech-kern@netbsd.org>
From: Chapman Flack <flack@cerias.purdue.edu>
List: tech-kern
Date: 08/26/2004 10:25:50
Martin Husemann wrote:

> Please do not use multipart/html messages when writing to tech-kern;
> they are blocked. Could you please re-post this message as plain
> ascii?

Umm, sure.  Just call me the human MIME-user-agent...   ;)

Contents:
1.  Problem description, questions
2.  dmesg, usbdevs -v, and ugen ioctl details

----
1.  Problem description, questions

My Midisport 2x4 (*1) arrived today but the NetBSD umidi (*2) driver
declines to attach it, so ugen (*3) picks it up.  I was hoping the
device would be one of those "devices that follow the USB MIDI
standard" so umidi would Just Work(tm), but no such luck.

Using ugen I can query the Midisport to see what it identifies as, and
it presents a single config and a single interface with five endpoints.
The reason umidi wouldn't attach is the interface class and subclass
are not UICLASS_AUDIO(1),UISUBCLASS_MIDISTREAM(3) but
UICLASS_VENDOR(0xff),0. Darn.

Google found this quirk entry for me in a Linux repository (*4):

      USB_DEVICE_VENDOR_SPEC(0x0763, 0x1041),
      .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
              .vendor_name = "M-Audio",
              .product_name = "MidiSport 2x4",
              .ifnum = QUIRK_ANY_INTERFACE,
              .type = QUIRK_MIDI_MIDIMAN,
              .data = & (const snd_usb_midi_endpoint_info_t) {
                      .out_cables = 0x000f,
                      .in_cables  = 0x0003
              }
      }

I notice there aren't any Midiman devices represented in umidi_quirks.c
(*5) yet.  Is this the sort of device I could probably get going just
by adding a quirk entry to recognize it and set up the 2in/4out
endpoints, reusing most of the existing umidi code?  Or will it be
using a protocol so different from the "USB MIDI
standard"/Roland/Yamaha devices already supported that a ton of new
code would be needed to work it in? Would I be better off sending the
thing back and getting a different one?

M-Audio people, is tech documentation for this device available?

Thanks,
Chapman Flack
chap0@cs.purdue.edu

*1 http://www.m-audio.com/products/en_us/MIDISPORT2x4-focus.html
*2 http://netbsd.gw.com/cgi-bin/man-cgi?umidi++NetBSD-current
*3 http://netbsd.gw.com/cgi-bin/man-cgi?ugen++NetBSD-current
*4 http://www.ru.kernel.org/pub/scm/linux/kernel/bkcvs/linux-2.5/sound/usb/usbquirks.h,v
*5 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/umidi_quirks.c

----
2. dmesg, usbdevs -v, and ugen ioctl details

mainbus0 (root)
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
uhci0 at pci0 dev 7 function 2: Intel 82371AB USB Host Controller (PIIX4) (rev. 0x01)
uhci0: interrupting at irq 11
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ugen0 at uhub0 port 1
ugen0: Midiman product 0x1041, rev 1.00/1.00, addr 2
# usbdevs -a 2 -v
Controller /dev/usb0:
addr 2: full speed, power 198 mA, config 1, product 0x1041(0x1041), Midiman(0x0763), rev 1.00
# gdb grab
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
(gdb) break bye
Breakpoint 1 at 0x804896a: file grab.c, line 5.
(gdb) run /dev/ugen0.00
Starting program: /root/grab 

Breakpoint 1, bye () at grab.c:5
5       void bye() { exit( 0); }
(gdb) up
#1  0x8048add in main (argc=1, argv=0xbfbfd888) at grab.c:48
48        bye();
(gdb) p/x udd
$1 = {bLength = 0x12, bDescriptorType = 0x1, bcdUSB = {0x0, 0x1}, 
  bDeviceClass = 0x0, bDeviceSubClass = 0x0, bDeviceProtocol = 0x0, 
  bMaxPacketSize = 0x40, idVendor = {0x63, 0x7}, idProduct = {0x41, 0x10}, 
  bcdDevice = {0x0, 0x1}, iManufacturer = 0x0, iProduct = 0x0, 
  iSerialNumber = 0x0, bNumConfigurations = 0x1}
(gdb) p/x uai
$2 = {uai_config_index = 0xffffffff, uai_interface_index = 0x0, 
  uai_alt_no = 0x1}
(gdb) p/x uid
$3 = {uid_config_index = 0xffffffff, uid_interface_index = 0x0, 
  uid_alt_index = 0xffffffff, uid_desc = {bLength = 0x9, 
    bDescriptorType = 0x4, bInterfaceNumber = 0x0, bAlternateSetting = 0x0, 
    bNumEndpoints = 0x5, bInterfaceClass = 0xff, bInterfaceSubClass = 0x0, 
    bInterfaceProtocol = 0x0, iInterface = 0x0}}
(gdb) quit
The program is running.  Exit anyway? (y or n) y
#