From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 6/7] ALSA: usb-audio: claim autodetected PCM interfaces all at once
Date: Thu, 27 Jun 2013 22:20:13 +0200 [thread overview]
Message-ID: <51CC9E7D.60703@ladisch.de> (raw)
In-Reply-To: <51CC9D8B.7060601@ladisch.de>
snd_card_register() registers all devices newly added since the last
call. However, the playback/capture streams are handled as one ALSA
device, so the second /dev device will not be registered if the PCM
streams are added in two steps.
QUIRK_AUTODETECT caused the probe callback to be called once for each
interface, which triggered this problem. Work around this by handling
this like the composite quirk, i.e., autodetecting all other interfaces
that might be used for PCM or MIDI.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
sound/usb/quirks.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 5363bcc..5b01330 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -337,8 +337,7 @@ static int create_auto_midi_quirk(struct snd_usb_audio *chip,
static int create_autodetect_quirk(struct snd_usb_audio *chip,
struct usb_interface *iface,
- struct usb_driver *driver,
- const struct snd_usb_audio_quirk *quirk)
+ struct usb_driver *driver)
{
int err;
@@ -348,6 +347,41 @@ static int create_autodetect_quirk(struct snd_usb_audio *chip,
return err;
}
+static int create_autodetect_quirks(struct snd_usb_audio *chip,
+ struct usb_interface *iface,
+ struct usb_driver *driver,
+ const struct snd_usb_audio_quirk *quirk)
+{
+ int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
+ int ifcount, ifnum, err;
+
+ err = create_autodetect_quirk(chip, iface, driver);
+ if (err < 0)
+ return err;
+
+ /*
+ * ALSA PCM playback/capture devices cannot be registered in two steps,
+ * so we have to claim the other corresponding interface here.
+ */
+ ifcount = chip->dev->actconfig->desc.bNumInterfaces;
+ for (ifnum = 0; ifnum < ifcount; ifnum++) {
+ if (ifnum == probed_ifnum || quirk->ifnum >= 0)
+ continue;
+ iface = usb_ifnum_to_if(chip->dev, ifnum);
+ if (!iface ||
+ usb_interface_claimed(iface) ||
+ get_iface_desc(iface->altsetting)->bInterfaceClass !=
+ USB_CLASS_VENDOR_SPEC)
+ continue;
+
+ err = create_autodetect_quirk(chip, iface, driver);
+ if (err >= 0)
+ usb_driver_claim_interface(driver, iface, (void *)-1L);
+ }
+
+ return 0;
+}
+
/*
* Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.
* The only way to detect the sample rate is by looking at wMaxPacketSize.
@@ -476,7 +510,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
static const quirk_func_t quirk_funcs[] = {
[QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
[QUIRK_COMPOSITE] = create_composite_quirk,
- [QUIRK_AUTODETECT] = create_autodetect_quirk,
+ [QUIRK_AUTODETECT] = create_autodetect_quirks,
[QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
[QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
[QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
next prev parent reply other threads:[~2013-06-27 20:19 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 ` [PATCH 2/7] ALSA: usb-audio: detect implicit feedback on Roland devices Clemens Ladisch
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 ` Clemens Ladisch [this message]
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=51CC9E7D.60703@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 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.