diff options
author | Kristian Amlie <kristian@amlie.name> | 2011-08-26 13:19:49 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-08-26 14:12:34 +0200 |
commit | 1ef0e0a05345b7411bdabbfca27f58bd33dcc7c8 (patch) | |
tree | 84e8816d89a6918411226c3f58501db59cd0b924 /sound/usb/midi.c | |
parent | 391e69143d0a05f960e3ab39a8c26b7b230bb8a9 (diff) |
ALSA: usb-audio: add Starr Labs USB MIDI support
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>
Diffstat (limited to 'sound/usb/midi.c')
-rw-r--r-- | sound/usb/midi.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index f9289102886a..e21f026d9577 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -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; |