All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rolf Meeser <rolfm_9dq@yahoo.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: [PATCH] snd-usb-audio with multiple audio functions
Date: Mon, 06 Jun 2011 08:49:32 +0200	[thread overview]
Message-ID: <4DEC787C.3050805@yahoo.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1974 bytes --]

Hello,

This patch fixes the currently broken support for multiple audio 
functions (AF) in snd-usb-audio.
The patch is against the stable 2.6.39.1 kernel.

It addresses three issues:
1. Controls of the second and any further AF are currently not 
accessibly (controls of the first AF are duplicated!)
2. Multiple AF's are currently incorrectly combined into one sound card 
index.
3. Module usage count of snd-usb-audio does not drop to zero after 
disconnecting a multiple AF device.

All three issues are fixed by assigning a new card index for each AF in 
a USB device.


Rationale:

- A USB audio function (AF) consists of a control interface and zero or 
more streaming interfaces. USB devices can have multiple AF, where the 
individual AF are completely independent of each other. In particular, 
it cannot be assumed that the controls of one AF can be manipulated 
through the control interface of another (the first) AF.

- Older kernels (up to 2.6.32? at least before the major rewrite of USB 
audio code) supported multiple AF's. However, they combined the streams 
into one sound card: For instance hw:1,0 for the stream interface of the 
first AF, and hw:1,1 for the stream interface of the second AF.
I believe this is incorrect, as different AF's must be treated as an 
independent entity. Each AF must get its own card index, for the example 
this would be hw:1,0 and hw:2,0. This is also the way THE OTHER OS 
implements it.

- Newer kernels have broken multiple AF support. In a dual AF setup 
these kernels detect the second AF, but they duplicate the controls of 
the first AF, and ignore the controls of the second one!

- The patch also fixes a problem with module usage: When you unplug a 
multiple AF device, the snd-usb-audio module usage count currently stays 
at 1, while you could expect it to go to zero.

This is the first time I'm sending a patch to this list. Please be 
patient with me if I did something in a wrong way :-)

Regards,
Rolf


[-- Attachment #2: patch-multiple-aic --]
[-- Type: text/plain, Size: 683 bytes --]

diff -ur linux-2.6.39.1.orig/sound/usb/card.c linux-2.6.39.1/sound/usb/card.c
--- linux-2.6.39.1.orig/sound/usb/card.c	2011-06-06 06:37:26.000000000 +0200
+++ linux-2.6.39.1/sound/usb/card.c	2011-06-06 07:06:06.000000000 +0200
@@ -461,7 +461,10 @@
 	chip = NULL;
 	mutex_lock(&register_mutex);
 	for (i = 0; i < SNDRV_CARDS; i++) {
-		if (usb_chip[i] && usb_chip[i]->dev == dev) {
+		if (usb_chip[i] &&
+			(usb_chip[i]->dev == dev) &&
+			(usb_chip[i]->ctrl_intf) &&
+			(usb_chip[i]->ctrl_intf->desc.bInterfaceNumber == ifnum)) {
 			if (usb_chip[i]->shutdown) {
 				snd_printk(KERN_ERR "USB device is in the shutdown state, cannot create a card instance\n");
 				goto __error;


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2011-06-06  6:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06  6:49 Rolf Meeser [this message]
2011-06-06  8:45 ` [PATCH] snd-usb-audio with multiple audio functions Daniel Mack
2011-06-06  9:08   ` Takashi Iwai
2011-06-06 15:17     ` Rolf Meeser
2011-06-06 11:44 ` Clemens Ladisch
     [not found]   ` <4DECC12F.60101@yahoo.de>
2011-06-06 15:47     ` 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=4DEC787C.3050805@yahoo.de \
    --to=rolfm_9dq@yahoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --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.