Author: hselasky
Date: Sun Jul  3 13:27:23 2011
New Revision: 223736
URL: http://svn.freebsd.org/changeset/base/223736

Log:
  Introduce a quirk for broken USB MIDI hardware instead of limiting performance
  in general.
  
  MFC after:    1 week

Modified:
  head/sys/dev/sound/usb/uaudio.c
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/quirk/usb_quirk.h
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/sound/usb/uaudio.c
==============================================================================
--- head/sys/dev/sound/usb/uaudio.c     Sun Jul  3 12:22:02 2011        
(r223735)
+++ head/sys/dev/sound/usb/uaudio.c     Sun Jul  3 13:27:23 2011        
(r223736)
@@ -192,7 +192,7 @@ struct uaudio_chan {
 };
 
 #define        UMIDI_CABLES_MAX   16           /* units */
-#define        UMIDI_TX_FRAMES    64           /* units */
+#define        UMIDI_TX_FRAMES    128          /* units */
 #define        UMIDI_TX_BUFFER    (UMIDI_TX_FRAMES * 4)        /* bytes */
 
 enum {
@@ -236,6 +236,7 @@ struct umidi_chan {
        uint8_t curr_cable;
        uint8_t max_cable;
        uint8_t valid;
+       uint8_t single_command;
 };
 
 struct uaudio_softc {
@@ -499,7 +500,6 @@ static const struct usb_config
                .endpoint = UE_ADDR_ANY,
                .direction = UE_DIR_OUT,
                .bufsize = UMIDI_TX_BUFFER,
-               .frames = UMIDI_TX_FRAMES,
                .callback = &umidi_bulk_write_callback,
        },
 
@@ -3565,6 +3565,7 @@ tr_setup:
                nframes = 0;    /* reset */
                start_cable = chan->curr_cable;
                tr_any = 0;
+               pc = usbd_xfer_get_frame(xfer, 0);
 
                while (1) {
 
@@ -3592,15 +3593,11 @@ tr_setup:
                                            sub->temp_cmd[0], sub->temp_cmd[1],
                                            sub->temp_cmd[2], sub->temp_cmd[3]);
 
-                                       usbd_xfer_set_frame_offset(xfer, 4 * 
nframes, nframes);
-                                       usbd_xfer_set_frame_len(xfer, nframes, 
4);
-
-                                       pc = usbd_xfer_get_frame(xfer, nframes);
-
-                                       usbd_copy_in(pc, 0, sub->temp_cmd, 4);
+                                       usbd_copy_in(pc, nframes * 4, 
sub->temp_cmd, 4);
 
                                        nframes++;
-                                       if (nframes >= UMIDI_TX_FRAMES)
+
+                                       if ((nframes >= UMIDI_TX_FRAMES) || 
(chan->single_command != 0))
                                                break;
                                } else {
                                        continue;
@@ -3618,9 +3615,9 @@ tr_setup:
                        }
                }
 
-               if (nframes > 0) {
+               if (nframes != 0) {
                        DPRINTF("Transferring %d frames\n", (int)nframes);
-                       usbd_xfer_set_frames(xfer, nframes);
+                       usbd_xfer_set_frame_len(xfer, 0, 4 * nframes);
                        usbd_transfer_submit(xfer);
                }
                break;
@@ -3792,6 +3789,9 @@ umidi_probe(device_t dev)
        int error;
        uint32_t n;
 
+       if (usb_test_quirk(uaa, UQ_SINGLE_CMD_MIDI))
+               chan->single_command = 1;
+
        if (usbd_set_alt_interface_index(sc->sc_udev, chan->iface_index,
            chan->iface_alt_index)) {
                DPRINTF("setting of alternate index failed!\n");

Modified: head/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- head/sys/dev/usb/quirk/usb_quirk.c  Sun Jul  3 12:22:02 2011        
(r223735)
+++ head/sys/dev/usb/quirk/usb_quirk.c  Sun Jul  3 13:27:23 2011        
(r223736)
@@ -472,6 +472,7 @@ static struct usb_quirk_entry usb_quirks
        USB_QUIRK(ROLAND, SD20, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS),
        USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS),
        USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS),
+       USB_QUIRK(MEDELI, DD305, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI, 
UQ_MATCH_VENDOR_ONLY),
 };
 #undef USB_QUIRK_VP
 #undef USB_QUIRK
@@ -538,6 +539,7 @@ static const char *usb_quirk_str[USB_QUI
        [UQ_MSC_EJECT_TCT]              = "UQ_MSC_EJECT_TCT",
        [UQ_BAD_MIDI]                   = "UQ_BAD_MIDI",
        [UQ_AU_VENDOR_CLASS]            = "UQ_AU_VENDOR_CLASS",
+       [UQ_SINGLE_CMD_MIDI]            = "UQ_SINGLE_CMD_MIDI",
 };
 
 /*------------------------------------------------------------------------*

Modified: head/sys/dev/usb/quirk/usb_quirk.h
==============================================================================
--- head/sys/dev/usb/quirk/usb_quirk.h  Sun Jul  3 12:22:02 2011        
(r223735)
+++ head/sys/dev/usb/quirk/usb_quirk.h  Sun Jul  3 13:27:23 2011        
(r223736)
@@ -102,6 +102,7 @@ enum {
 
        UQ_BAD_MIDI,            /* device claims MIDI class, but isn't */
        UQ_AU_VENDOR_CLASS,     /* audio device uses vendor and not audio class 
*/
+       UQ_SINGLE_CMD_MIDI,     /* at most one command per USB packet */
 
        USB_QUIRK_MAX
 };

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs    Sun Jul  3 12:22:02 2011        (r223735)
+++ head/sys/dev/usb/usbdevs    Sun Jul  3 13:27:23 2011        (r223736)
@@ -484,6 +484,7 @@ vendor SHANTOU              0x0a46  ShanTou
 vendor MEDIAGEAR       0x0a48  MediaGear
 vendor BROADCOM                0x0a5c  Broadcom
 vendor GREENHOUSE      0x0a6b  GREENHOUSE
+vendor MEDELI          0x0a67  Medeli
 vendor GEOCAST         0x0a79  Geocast Network Systems
 vendor IDQUANTIQUE     0x0aba  id Quantique
 vendor ZYDAS           0x0ace  Zydas Technology Corporation
@@ -2130,6 +2131,9 @@ product MCT DU_H3SP_USB232        0x0200  D-Link
 product MCT USB232             0x0210  USB-232 Interface
 product MCT SITECOM_USB232     0x0230  Sitecom USB-232 Products
 
+/* Medeli */
+product MEDELI DD305           0x5011  DD305 Digital Drum Set
+
 /* MediaTek, Inc. */
 product MEDIATEK MTK3329       0x3329  MTK II GPS Receiver
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to