All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Steinmetz <ast@domdv.de>
To: alsa-devel@alsa-project.org
Cc: clemens@ladisch.de
Subject: PATCH: ALSA USB MIDI: Fix case when USB MIDI interface has more than one extra endpoint descriptor
Date: Thu, 26 Mar 2020 18:18:55 +0100	[thread overview]
Message-ID: <00decacc4cac6a9d88fe696f94a077284fb8bbb9.camel@domdv.de> (raw)

The Miditech MIDIFACE 16x16 (USB ID 1290:1749) has more than one extra
endpoint descriptor.

The first extra descriptor is: 0x06 0x30 0x00 0x00 0x00 0x00

As the code in snd_usbmidi_get_ms_info() looks only at the
first extra descriptor to find USB_DT_CS_ENDPOINT the device
as such is recognized but there is neither input nor output
configured.

The patch iterates through the extra descriptors to find the
proper one. With this patch the device is correctly configured.

Signed-off-by: Andreas Steinmetz <ast@domdv.de>

--- a/sourd/usb/midi.c	2020-03-26 17:34:40.073929497 +0100
+++ b/sound/usb/midi.c	2020-03-26 17:43:39.123252612 +0100
@@ -1839,7 +1839,8 @@
 	struct usb_host_endpoint *hostep;
 	struct usb_endpoint_descriptor *ep;
 	struct usb_ms_endpoint_descriptor *ms_ep;
-	int i, epidx;
+	int i, epidx, extralen;
+	unsigned char *extra;
 
 	intf = umidi->iface;
 	if (!intf)
@@ -1863,12 +1864,21 @@
 		ep = get_ep_desc(hostep);
 		if (!usb_endpoint_xfer_bulk(ep) && !usb_endpoint_xfer_int(ep))
 			continue;
-		ms_ep = (struct usb_ms_endpoint_descriptor *)hostep->extra;
-		if (hostep->extralen < 4 ||
+		extralen = hostep->extralen;
+		extra = hostep->extra;
+repeat:		ms_ep = (struct usb_ms_endpoint_descriptor *)extra;
+		if (extralen < 1)
+			continue;
+		if (extralen < 4 ||
 		    ms_ep->bLength < 4 ||
 		    ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT ||
-		    ms_ep->bDescriptorSubtype != UAC_MS_GENERAL)
-			continue;
+		    ms_ep->bDescriptorSubtype != UAC_MS_GENERAL) {
+			if (!extra[0])
+				continue;
+			extralen -= extra[0];
+			extra += extra[0];
+			goto repeat;
+		}
 		if (usb_endpoint_dir_out(ep)) {
 			if (endpoints[epidx].out_ep) {
 				if (++epidx >= MIDI_MAX_ENDPOINTS) {


             reply	other threads:[~2020-03-26 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 17:18 Andreas Steinmetz [this message]
2020-03-29  8:45 ` PATCH: ALSA USB MIDI: Fix case when USB MIDI interface has more than one extra endpoint descriptor Takashi Iwai
2020-03-31 12:25   ` PATCH v2: " Andreas Steinmetz
2020-03-31 12:35     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00decacc4cac6a9d88fe696f94a077284fb8bbb9.camel@domdv.de \
    --to=ast@domdv.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.