[ALSA] hda-codec - Add SPDIF support on ALC880 fujitsu model
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / usb / usbmidi.c
index 911f4482b5e11c3f95b21aa81c13b7c21a245f2f..2bb1834a8c22fe532ab611ae9c1cc8051f377f35 100644 (file)
@@ -406,6 +406,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.
  */
@@ -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
@@ -965,7 +985,11 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
        }
        /* we never use interrupt output pipes */
        pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep);
-       ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1);
+       if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */
+               /* FIXME: we need more URBs to get reasonable bandwidth here: */
+               ep->max_transfer = 4;
+       else
+               ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1);
        buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer,
                                  GFP_KERNEL, &ep->urb->transfer_dma);
        if (!buffer) {
@@ -1686,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: