Skip to content

Commit

Permalink
ALSA: usb-audio: prevent CH345 multiport output SysEx corruption
Browse files Browse the repository at this point in the history
The CH345 USB MIDI chip has two output ports.  However, they are
multiplexed through one pin, and the number of ports cannot be reduced
even for hardware that implements only one connector, so for those
devices, data sent to either port ends up on the same hardware output.
This becomes a problem when both ports are used at the same time, as
longer MIDI commands (such as SysEx messages) are likely to be
interrupted by messages from the other port, and thus to get lost.

It would not be possible for the driver to detect how many ports the
device actually has, except that in practice, _all_ devices built with
the CH345 have only one port.  So we can just ignore the device's
descriptors, and hardcode one output port.

Signed-off-by: Clemens Ladisch <[email protected]>
Cc: [email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
cladisch authored and tiwai committed Nov 16, 2015
1 parent 98d362b commit 1ca8b20
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sound/usb/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,9 @@ int snd_usbmidi_create(struct snd_card *card,
if (err < 0)
break;

err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
break;
case QUIRK_MIDI_CH345:
err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
break;
default:
Expand Down
11 changes: 11 additions & 0 deletions sound/usb/quirks-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,17 @@ YAMAHA_DEVICE(0x7010, "UB99"),
.idProduct = 0x1020,
},

/* QinHeng devices */
{
USB_DEVICE(0x1a86, 0x752d),
.driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
.vendor_name = "QinHeng",
.product_name = "CH345",
.ifnum = 1,
.type = QUIRK_MIDI_CH345
}
},

/* KeithMcMillen Stringport */
{
USB_DEVICE(0x1f38, 0x0001),
Expand Down
1 change: 1 addition & 0 deletions sound/usb/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
[QUIRK_MIDI_CME] = create_any_midi_quirk,
[QUIRK_MIDI_AKAI] = create_any_midi_quirk,
[QUIRK_MIDI_FTDI] = create_any_midi_quirk,
[QUIRK_MIDI_CH345] = 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,
Expand Down
1 change: 1 addition & 0 deletions sound/usb/usbaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ enum quirk_type {
QUIRK_MIDI_AKAI,
QUIRK_MIDI_US122L,
QUIRK_MIDI_FTDI,
QUIRK_MIDI_CH345,
QUIRK_AUDIO_STANDARD_INTERFACE,
QUIRK_AUDIO_FIXED_ENDPOINT,
QUIRK_AUDIO_EDIROL_UAXX,
Expand Down

0 comments on commit 1ca8b20

Please sign in to comment.