diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-08-25 11:10:05 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-08-30 08:47:34 +0200 |
commit | c347e9fca710551f0def6a4d58505a6f4c0d87f6 (patch) | |
tree | 7a581a03569249bd70d9dbba96966d94d9e96a9e /sound/usb | |
parent | a278655ff5d0c9d5eb34cf99f3a4c20da09eb09e (diff) | |
download | linux-3.10-c347e9fca710551f0def6a4d58505a6f4c0d87f6.tar.gz linux-3.10-c347e9fca710551f0def6a4d58505a6f4c0d87f6.tar.bz2 linux-3.10-c347e9fca710551f0def6a4d58505a6f4c0d87f6.zip |
[ALSA] usb-audio: fix Emagic MIDI protocol handling
USB generic driver
Emagic devices pad their packets not with 0xff bytes but with a 0xff
byte followed by garbage, so we have to stop at the first such byte.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/usbmidi.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index d0d895df537..5f19b494923 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c @@ -594,17 +594,20 @@ static void snd_usbmidi_emagic_finish_out(snd_usb_midi_out_endpoint_t* ep) static void snd_usbmidi_emagic_input(snd_usb_midi_in_endpoint_t* ep, uint8_t* buffer, int buffer_length) { - /* ignore padding bytes at end of buffer */ - while (buffer_length > 0 && buffer[buffer_length - 1] == 0xff) - --buffer_length; + int i; + + /* FF indicates end of valid data */ + for (i = 0; i < buffer_length; ++i) + if (buffer[i] == 0xff) { + buffer_length = i; + break; + } /* handle F5 at end of last buffer */ if (ep->seen_f5) goto switch_port; while (buffer_length > 0) { - int i; - /* determine size of data until next F5 */ for (i = 0; i < buffer_length; ++i) if (buffer[i] == 0xf5) @@ -671,6 +674,10 @@ static void snd_usbmidi_emagic_output(snd_usb_midi_out_endpoint_t* ep) break; } } + if (buf_free < ep->max_transfer && buf_free > 0) { + *buf = 0xff; + --buf_free; + } ep->urb->transfer_buffer_length = ep->max_transfer - buf_free; } |