Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=61870aed229519e7cd7f1899a19e4e7c8ba915e4
Commit:     61870aed229519e7cd7f1899a19e4e7c8ba915e4
Parent:     20a45e8644ef4f5e7dfd727859301c4c581e9489
Author:     Clemens Ladisch <[EMAIL PROTECTED]>
AuthorDate: Thu Aug 16 08:44:51 2007 +0200
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 15:59:01 2007 +0200

    [ALSA] usb-audio: fix parsing of SysEx messages from CME keyboards
    
    When CME keyboards send a SysEx message (e.g. master volume), the USB
    packet uses a format different from the standard format.  Parsing this
    packet according to the specification corrupts the SysEx message itself
    and can cause the following MIDI messages to be misinterpreted, too.
    This patch adds a workaround for this case.
    
    Signed-off-by: Clemens Ladisch <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/usb/usbmidi.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 99295f9..2bb1834 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -407,6 +407,20 @@ static void snd_usbmidi_maudio_broken_running_status_input(
 }
 
 /*
+ * CME protocol: like the standard protocol, but SysEx commands are sent as a
+ * single USB packet preceded by a 0x0F byte.
+ */
+static void snd_usbmidi_cme_input(struct snd_usb_midi_in_endpoint *ep,
+                                 uint8_t *buffer, int buffer_length)
+{
+       if (buffer_length < 2 || (buffer[0] & 0x0f) != 0x0f)
+               snd_usbmidi_standard_input(ep, buffer, buffer_length);
+       else
+               snd_usbmidi_input_data(ep, buffer[0] >> 4,
+                                      &buffer[1], buffer_length - 1);
+}
+
+/*
  * Adds one USB MIDI packet to the output buffer.
  */
 static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0,
@@ -572,6 +586,12 @@ static struct usb_protocol_ops 
snd_usbmidi_maudio_broken_running_status_ops = {
        .output_packet = snd_usbmidi_output_standard_packet,
 };
 
+static struct usb_protocol_ops snd_usbmidi_cme_ops = {
+       .input = snd_usbmidi_cme_input,
+       .output = snd_usbmidi_standard_output,
+       .output_packet = snd_usbmidi_output_standard_packet,
+};
+
 /*
  * Novation USB MIDI protocol: number of data bytes is in the first byte
  * (when receiving) (+1!) or in the second byte (when sending); data begins
@@ -1690,6 +1710,7 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* 
chip,
                err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);
                break;
        case QUIRK_MIDI_CME:
+               umidi->usb_protocol_ops = &snd_usbmidi_cme_ops;
                err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
                break;
        default:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to