aboutsummaryrefslogtreecommitdiff
path: root/sound/usb/midi.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2015-12-10 07:23:15 -0800
committerKevin Hilman <khilman@linaro.org>2015-12-10 07:23:15 -0800
commitc228c8e94b9e56032d475abc8f5978a73ac3f699 (patch)
treea3045c46c383f00d3fd7bcefee16c10c68643953 /sound/usb/midi.c
parent1388239cd22fcaf1572a12197faa14a63d45aa27 (diff)
parent5d7b0fcc26d66db767a477574effc764022c19ac (diff)
Merge tag 'v3.14.58' of git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable into linux-linaro-lsk-v3.14lsk-v3.14-16.01lsk-v3.14-15.12
This is the 3.14.58 stable release # gpg: Signature made Wed Dec 9 10:43:44 2015 PST using RSA key ID 6092693E # gpg: Good signature from "Greg Kroah-Hartman (Linux kernel stable release signing key) <greg@kroah.com>" * tag 'v3.14.58' of git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable: (38 commits) Linux 3.14.58 ALSA: usb-audio: work around CH345 input SysEx corruption ALSA: usb-audio: prevent CH345 multiport output SysEx corruption ALSA: usb-audio: add packet size quirk for the Medeli DD305 USB: option: add XS Stick W100-2 from 4G Systems USB: serial: option: add support for Novatel MiFi USB620L USB: ti_usb_3410_5052: Add Honeywell HGI80 ID usb: musb: core: fix order of arguments to ulpi write callback usblp: do not set TASK_INTERRUPTIBLE before lock arm64: Fix compat register mappings can: sja1000: clear interrupts on start Bluetooth: ath3k: Add support of AR3012 0cf3:817b device Bluetooth: ath3k: Add new AR3012 0930:021c id Bluetooth: hidp: fix device disconnect on idle timeout staging: rtl8712: Add device ID for Sitecom WLA2100 mwifiex: fix mwifiex_rdeeprom_read() net: mvneta: Fix CPU_MAP registers initialisation mac80211: fix driver RSSI event calculations x86/cpu: Fix SMAP check in PVOPS environments x86/cpu: Call verify_cpu() after having entered long mode too ...
Diffstat (limited to 'sound/usb/midi.c')
-rw-r--r--sound/usb/midi.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index c7aa71ee775b..9123fc518f07 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -174,6 +174,8 @@ struct snd_usb_midi_in_endpoint {
u8 running_status_length;
} ports[0x10];
u8 seen_f5;
+ bool in_sysex;
+ u8 last_cin;
u8 error_resubmit;
int current_port;
};
@@ -465,6 +467,39 @@ static void snd_usbmidi_maudio_broken_running_status_input(
}
/*
+ * QinHeng CH345 is buggy: every second packet inside a SysEx has not CIN 4
+ * but the previously seen CIN, but still with three data bytes.
+ */
+static void ch345_broken_sysex_input(struct snd_usb_midi_in_endpoint *ep,
+ uint8_t *buffer, int buffer_length)
+{
+ unsigned int i, cin, length;
+
+ for (i = 0; i + 3 < buffer_length; i += 4) {
+ if (buffer[i] == 0 && i > 0)
+ break;
+ cin = buffer[i] & 0x0f;
+ if (ep->in_sysex &&
+ cin == ep->last_cin &&
+ (buffer[i + 1 + (cin == 0x6)] & 0x80) == 0)
+ cin = 0x4;
+#if 0
+ if (buffer[i + 1] == 0x90) {
+ /*
+ * Either a corrupted running status or a real note-on
+ * message; impossible to detect reliably.
+ */
+ }
+#endif
+ length = snd_usbmidi_cin_length[cin];
+ snd_usbmidi_input_data(ep, 0, &buffer[i + 1], length);
+ ep->in_sysex = cin == 0x4;
+ if (!ep->in_sysex)
+ ep->last_cin = cin;
+ }
+}
+
+/*
* CME protocol: like the standard protocol, but SysEx commands are sent as a
* single USB packet preceded by a 0x0F byte.
*/
@@ -650,6 +685,12 @@ static struct usb_protocol_ops snd_usbmidi_cme_ops = {
.output_packet = snd_usbmidi_output_standard_packet,
};
+static struct usb_protocol_ops snd_usbmidi_ch345_broken_sysex_ops = {
+ .input = ch345_broken_sysex_input,
+ .output = snd_usbmidi_standard_output,
+ .output_packet = snd_usbmidi_output_standard_packet,
+};
+
/*
* AKAI MPD16 protocol:
*
@@ -1326,6 +1367,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
* Various chips declare a packet size larger than 4 bytes, but
* do not actually work with larger packets:
*/
+ case USB_ID(0x0a67, 0x5011): /* Medeli DD305 */
case USB_ID(0x0a92, 0x1020): /* ESI M4U */
case USB_ID(0x1430, 0x474b): /* RedOctane GH MIDI INTERFACE */
case USB_ID(0x15ca, 0x0101): /* Textech USB Midi Cable */
@@ -2290,6 +2332,10 @@ int snd_usbmidi_create(struct snd_card *card,
err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
break;
+ case QUIRK_MIDI_CH345:
+ umidi->usb_protocol_ops = &snd_usbmidi_ch345_broken_sysex_ops;
+ err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
+ break;
default:
snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
err = -ENXIO;