]> Pileus Git - ~andy/linux/commitdiff
ALSA: usb-audio: add Starr Labs USB MIDI support
authorKristian Amlie <kristian@amlie.name>
Fri, 26 Aug 2011 11:19:49 +0000 (13:19 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 26 Aug 2011 12:12:34 +0000 (14:12 +0200)
Add support for Starr Labs USB MIDI devices such as the Z7S, which are
based on an FTDI serial UART chip.

Based on a patch by Daniel Mack.

Signed-off-by: Kristian Amlie <kristian@amlie.name>
Acked-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/midi.c
sound/usb/quirks-table.h
sound/usb/quirks.c
sound/usb/usbaudio.h

index f9289102886ad890987a0d27739a19f1e48afdd4..e21f026d9577504fe4ac8aef70ef2bfc6eff04f3 100644 (file)
@@ -816,6 +816,22 @@ static struct usb_protocol_ops snd_usbmidi_raw_ops = {
        .output = snd_usbmidi_raw_output,
 };
 
+/*
+ * FTDI protocol: raw MIDI bytes, but input packets have two modem status bytes.
+ */
+
+static void snd_usbmidi_ftdi_input(struct snd_usb_midi_in_endpoint* ep,
+                                  uint8_t* buffer, int buffer_length)
+{
+       if (buffer_length > 2)
+               snd_usbmidi_input_data(ep, 0, buffer + 2, buffer_length - 2);
+}
+
+static struct usb_protocol_ops snd_usbmidi_ftdi_ops = {
+       .input = snd_usbmidi_ftdi_input,
+       .output = snd_usbmidi_raw_output,
+};
+
 static void snd_usbmidi_us122l_input(struct snd_usb_midi_in_endpoint *ep,
                                     uint8_t *buffer, int buffer_length)
 {
@@ -2163,6 +2179,17 @@ int snd_usbmidi_create(struct snd_card *card,
                /* endpoint 1 is input-only */
                endpoints[1].out_cables = 0;
                break;
+       case QUIRK_MIDI_FTDI:
+               umidi->usb_protocol_ops = &snd_usbmidi_ftdi_ops;
+
+               /* set baud rate to 31250 (48 MHz / 16 / 96) */
+               err = usb_control_msg(umidi->dev, usb_sndctrlpipe(umidi->dev, 0),
+                                     3, 0x40, 0x60, 0, NULL, 0, 1000);
+               if (err < 0)
+                       break;
+
+               err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
+               break;
        default:
                snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
                err = -ENXIO;
index a42e3ef3832d709d11b1653bc8385d20c5a8271f..da898229bb1192e74948bfeabb4857ece15b544b 100644 (file)
        .idProduct = prod, \
        .bInterfaceClass = USB_CLASS_VENDOR_SPEC
 
+/* FTDI devices */
+{
+       USB_DEVICE(0x0403, 0xb8d8),
+       .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+               /* .vendor_name = "STARR LABS", */
+               /* .product_name = "Starr Labs MIDI USB device", */
+               .ifnum = 0,
+               .type = QUIRK_MIDI_FTDI
+       }
+},
+
 /* Creative/Toshiba Multimedia Center SB-0500 */
 {
        USB_DEVICE(0x041e, 0x3048),
index 81e07d842581771ac82d4a3107f2a54cd69663e3..cf61b03400263dcfceffdc7a2ace018fc4c5175c 100644 (file)
@@ -306,6 +306,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
                [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
                [QUIRK_MIDI_CME] = create_any_midi_quirk,
                [QUIRK_MIDI_AKAI] = create_any_midi_quirk,
+               [QUIRK_MIDI_FTDI] = create_any_midi_quirk,
                [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
                [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
                [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,
index 1e79986b577749ca0ebea31aa7b5c7c46ac750b1..3e2b035779362d6adc733ba5fa8396590e98e8d6 100644 (file)
@@ -80,6 +80,7 @@ enum quirk_type {
        QUIRK_MIDI_CME,
        QUIRK_MIDI_AKAI,
        QUIRK_MIDI_US122L,
+       QUIRK_MIDI_FTDI,
        QUIRK_AUDIO_STANDARD_INTERFACE,
        QUIRK_AUDIO_FIXED_ENDPOINT,
        QUIRK_AUDIO_EDIROL_UAXX,