Re: Controlling card number assignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 07 Jul 2017 19:55:10 +0200,
Paul D. DeRocco wrote:
> 
> > From: Clemens Ladisch [mailto:clemens@xxxxxxxxxx] 
> > 
> > You could use the vid/pid options of the driver.  See
> > <http://alsa.opensrc.org/MultipleUSBAudioDevices> or
> > <https://help.ubuntu.com/community/UbuntuStudio/UsbAudioDevices>.
> 
> The DAC isn't a USB device. It connects to the RPi's I2S interface, and is
> controlled by I2C, and enumerated via a .dto file. It does, however, have
> a consistent name, so I'm alright with that.
> 
> The USB to MIDI converters are a different matter. They're USB, but they
> could be any brand. I have a cheap Chinese converter whose name comes up
> as "Interface", and an E-Mu device called "XMidiX1". It would be really
> nice to have some geographic way to refer to them, based on the USB port
> they're plugged into. But I guess that's something I should ask about on
> the systemd list.

The patch below adds a new module option to USB-audio driver for
specifying the devpath string.  Together with index option, you can
define the card index for the fixed devpath.  Would it work for you?

The patch has been floating around over years, and not merged just
because I haven't heard of the good usage of it.


Takashi

-- 8< --
From: Takashi Iwai <tiwai@xxxxxxx>
Subject: [PATCH] ALSA: usb-audio - Add devpath option

Added devpath module option to specify the USB devpath for the
specific device index.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
 sound/usb/card.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 6640277a725b..a9af497d19bf 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -79,6 +79,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card *
 /* Vendor/product IDs for this card */
 static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
+static char *devpath[SNDRV_CARDS];
 static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
 static bool ignore_ctl_error;
 static bool autoclock = true;
@@ -94,6 +95,8 @@ module_param_array(vid, int, NULL, 0444);
 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
 module_param_array(pid, int, NULL, 0444);
 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
+module_param_array(devpath, charp, NULL, 0444);
+MODULE_PARM_DESC(devpath, "USB devpath for the specific index.");
 module_param_array(device_setup, int, NULL, 0444);
 MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
 module_param(ignore_ctl_error, bool, 0444);
@@ -506,6 +509,21 @@ get_alias_quirk(struct usb_device *dev, unsigned int id)
 	return NULL;
 }
 
+static int is_matching_device(int i, u32 id, struct usb_device *dev)
+{
+	if (vid[i] != -1 && vid[i] != USB_ID_VENDOR(id))
+		return 0;
+	if (pid[i] != -1 && pid[i] != USB_ID_PRODUCT(id))
+		return 0;
+	if (devpath[i]) {
+		char tmppath[64];
+		usb_make_path(dev, tmppath, sizeof(tmppath));
+		if (strcmp(devpath[i], tmppath))
+			return 0;
+	}
+	return 1;
+}
+
 /*
  * probe the active usb device
  *
@@ -566,8 +584,7 @@ static int usb_audio_probe(struct usb_interface *intf,
 		 */
 		for (i = 0; i < SNDRV_CARDS; i++)
 			if (enable[i] && ! usb_chip[i] &&
-			    (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
-			    (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
+			    is_matching_device(i, id, dev)) {
 				err = snd_usb_audio_create(intf, dev, i, quirk,
 							   id, &chip);
 				if (err < 0)
-- 
2.13.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user



[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux