Introduce a quirk for broken USB MIDI hardware instead of limiting performance

in general.

MFC after:	1 week
This commit is contained in:
hselasky 2011-07-03 13:27:23 +00:00
parent 9cad5bfef3
commit f91c2275ef
4 changed files with 18 additions and 11 deletions

View File

@ -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 @@ umidi_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
nframes = 0; /* reset */
start_cable = chan->curr_cable;
tr_any = 0;
pc = usbd_xfer_get_frame(xfer, 0);
while (1) {
@ -3592,15 +3593,11 @@ umidi_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
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 @@ umidi_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
}
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");

View File

@ -472,6 +472,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = {
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_QUIRK_MAX] = {
[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",
};
/*------------------------------------------------------------------------*

View File

@ -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
};

View File

@ -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 DU-H3SP USB BAY Hub
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