Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 2/7] ALSA: usb-audio: detect implicit feedback on Roland devices
Date: Thu, 27 Jun 2013 22:18:31 +0200	[thread overview]
Message-ID: <51CC9E17.2040102@ladisch.de> (raw)
In-Reply-To: <51CC9D8B.7060601@ladisch.de>

All the Roland/Edirol/BOSS USB audio devices that need implicit feedback
show this unambiguously in their descriptors, so it might be a good idea
to let the driver detect this.

This should make playback work correctly (at least with Jack) with the
following devices:
- BOSS GT-100
- BOSS JS-8 Jam Station
- Edirol M-16DX
- Roland GAIA SH-01

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 sound/usb/pcm.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 776c58c..15b151e 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -298,6 +298,35 @@ static int deactivate_endpoints(struct snd_usb_substream *subs)
 	return 0;
 }

+static int search_roland_implicit_fb(struct usb_device *dev, int ifnum,
+				     unsigned int altsetting,
+				     struct usb_host_interface **alts,
+				     unsigned int *ep)
+{
+	struct usb_interface *iface;
+	struct usb_interface_descriptor *altsd;
+	struct usb_endpoint_descriptor *epd;
+
+	iface = usb_ifnum_to_if(dev, ifnum);
+	if (!iface || iface->num_altsetting < altsetting + 1)
+		return -ENOENT;
+	*alts = &iface->altsetting[altsetting];
+	altsd = get_iface_desc(*alts);
+	if (altsd->bAlternateSetting != altsetting ||
+	    altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
+	    (altsd->bInterfaceSubClass != 2 &&
+	     altsd->bInterfaceProtocol != 2   ) ||
+	    altsd->bNumEndpoints < 1)
+		return -ENOENT;
+	epd = get_endpoint(*alts, 0);
+	if (!usb_endpoint_is_isoc_in(epd) ||
+	    (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
+					USB_ENDPOINT_USAGE_IMPLICIT_FB)
+		return -ENOENT;
+	*ep = epd->bEndpointAddress;
+	return 0;
+}
+
 /*
  * find a matching format and set up the interface
  */
@@ -393,6 +422,18 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
 			goto add_sync_ep;
 		}
 	}
+	if (is_playback &&
+	    attr == USB_ENDPOINT_SYNC_ASYNC &&
+	    altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
+	    altsd->bInterfaceProtocol == 2 &&
+	    altsd->bNumEndpoints == 1 &&
+	    USB_ID_VENDOR(subs->stream->chip->usb_id) == 0x0582 /* Roland */ &&
+	    search_roland_implicit_fb(dev, altsd->bInterfaceNumber + 1,
+				      altsd->bAlternateSetting,
+				      &alts, &ep) >= 0) {
+		implicit_fb = 1;
+		goto add_sync_ep;
+	}

 	if (((is_playback && attr == USB_ENDPOINT_SYNC_ASYNC) ||
 	     (!is_playback && attr == USB_ENDPOINT_SYNC_ADAPTIVE)) &&

  parent reply	other threads:[~2013-06-27 20:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 20:16 [git pull] [PATCH 0/7] add support for many Roland and Yamaha devices Clemens Ladisch
2013-06-27 20:18 ` [PATCH 1/7] ALSA: usb-audio: store protocol version in struct audioformat Clemens Ladisch
2013-07-09 18:34   ` Eldad Zack
2013-06-27 20:18 ` Clemens Ladisch [this message]
2013-06-27 20:19 ` [PATCH 3/7] ALSA: usb-audio: add support for many Roland/Yamaha devices Clemens Ladisch
2013-06-27 20:19 ` [PATCH 4/7] ALSA: usb-audio: add MIDI port names for some Roland devices Clemens Ladisch
2013-06-27 20:19 ` [PATCH 5/7] ALSA: usb-audio: remove superfluous Roland quirks Clemens Ladisch
2013-06-27 20:20 ` [PATCH 6/7] ALSA: usb-audio: claim autodetected PCM interfaces all at once Clemens Ladisch
2013-06-27 20:20 ` [PATCH 7/7] ALSA: usb-audio: add quirks for Roland QUAD/OCTO-CAPTURE Clemens Ladisch
2013-06-28 10:17 ` [git pull] [PATCH 0/7] add support for many Roland and Yamaha devices Takashi Iwai
2013-08-09 10:52 ` Keith A. Milner
2013-08-09 13:17   ` Clemens Ladisch
2013-08-09 15:02     ` Keith A. Milner
2013-08-09 18:18       ` Clemens Ladisch
2013-08-10 12:35         ` Keith A. Milner
2013-08-11  0:10         ` Keith A. Milner
2013-08-11 12:13           ` [PATCH] ALSA: usb-audio: fix automatic Roland/Yamaha MIDI detection Clemens Ladisch
2013-08-12  9:41             ` Takashi Iwai
2013-08-12 22:00             ` Keith A. Milner
2013-08-12 22:38             ` Keith A. Milner
2013-08-12 22:42               ` Keith A. Milner
2013-08-16 12:06               ` Keith A. Milner
2013-08-11 12:15           ` [git pull] [PATCH 0/7] add support for many Roland and Yamaha devices Clemens Ladisch

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=51CC9E17.2040102@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox