Skip to content

Commit 1ef0e0a

Browse files
kramlietiwai
authored andcommitted
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>
1 parent 391e691 commit 1ef0e0a

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎sound/usb/midi.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,22 @@ static struct usb_protocol_ops snd_usbmidi_raw_ops = {
816816
.output = snd_usbmidi_raw_output,
817817
};
818818

819+
/*
820+
* FTDI protocol: raw MIDI bytes, but input packets have two modem status bytes.
821+
*/
822+
823+
static void snd_usbmidi_ftdi_input(struct snd_usb_midi_in_endpoint* ep,
824+
uint8_t* buffer, int buffer_length)
825+
{
826+
if (buffer_length > 2)
827+
snd_usbmidi_input_data(ep, 0, buffer + 2, buffer_length - 2);
828+
}
829+
830+
static struct usb_protocol_ops snd_usbmidi_ftdi_ops = {
831+
.input = snd_usbmidi_ftdi_input,
832+
.output = snd_usbmidi_raw_output,
833+
};
834+
819835
static void snd_usbmidi_us122l_input(struct snd_usb_midi_in_endpoint *ep,
820836
uint8_t *buffer, int buffer_length)
821837
{
@@ -2163,6 +2179,17 @@ int snd_usbmidi_create(struct snd_card *card,
21632179
/* endpoint 1 is input-only */
21642180
endpoints[1].out_cables = 0;
21652181
break;
2182+
case QUIRK_MIDI_FTDI:
2183+
umidi->usb_protocol_ops = &snd_usbmidi_ftdi_ops;
2184+
2185+
/* set baud rate to 31250 (48 MHz / 16 / 96) */
2186+
err = usb_control_msg(umidi->dev, usb_sndctrlpipe(umidi->dev, 0),
2187+
3, 0x40, 0x60, 0, NULL, 0, 1000);
2188+
if (err < 0)
2189+
break;
2190+
2191+
err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
2192+
break;
21662193
default:
21672194
snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
21682195
err = -ENXIO;

‎sound/usb/quirks-table.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
.idProduct = prod, \
4040
.bInterfaceClass = USB_CLASS_VENDOR_SPEC
4141

42+
/* FTDI devices */
43+
{
44+
USB_DEVICE(0x0403, 0xb8d8),
45+
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
46+
/* .vendor_name = "STARR LABS", */
47+
/* .product_name = "Starr Labs MIDI USB device", */
48+
.ifnum = 0,
49+
.type = QUIRK_MIDI_FTDI
50+
}
51+
},
52+
4253
/* Creative/Toshiba Multimedia Center SB-0500 */
4354
{
4455
USB_DEVICE(0x041e, 0x3048),

‎sound/usb/quirks.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
306306
[QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
307307
[QUIRK_MIDI_CME] = create_any_midi_quirk,
308308
[QUIRK_MIDI_AKAI] = create_any_midi_quirk,
309+
[QUIRK_MIDI_FTDI] = create_any_midi_quirk,
309310
[QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
310311
[QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
311312
[QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,

‎sound/usb/usbaudio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum quirk_type {
8080
QUIRK_MIDI_CME,
8181
QUIRK_MIDI_AKAI,
8282
QUIRK_MIDI_US122L,
83+
QUIRK_MIDI_FTDI,
8384
QUIRK_AUDIO_STANDARD_INTERFACE,
8485
QUIRK_AUDIO_FIXED_ENDPOINT,
8586
QUIRK_AUDIO_EDIROL_UAXX,

0 commit comments

Comments
 (0)