Re: Several similar usb midi devices

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

 



On Mon, 29 Aug 2016 16:18:08 +0200,
barmin wrote:
> 
> >> As a workaround, load the snd-seq-dummy module with at least two
> >> ports (add "options snd-seq-dummy ports=2" to some .conf file in
> >> /etc/modprobe.d/), and write a script that identifies the devices
> >> and connects the correct ones to 14:0 and 14:1.
> >
> > That's probably a silly question but I'm not sure at all how to do
> > this. I know how to distinguish the cards from Udev, but I don't know
> > how to find the corresponding midi ports - that's precisely why I was
> > hoping they would be renamed at the same time.
> 
> Maybe it wasn't a silly question after all... any idea anyone?
> 
> Maybe I should just go on unplugging and re-plugging the devices in a given order to know who is who, but it somehow seems suboptimal...

Once upon a time, I wrote a patch like below, to assign the USB-audio
device to a specific device path.  Would it help in your case?
(Of course, it's useless for a real hotplug.)

Following the sequencer client name to the card name change is likely
no-go.  The sequencer subsystem is basically independent from the
underlying device implementation, and it makes many things
inconsistent.

Another solution would be to load the sequencer stuff only after all
your devices are set up.


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 9e5276d6dda0..1ae8c61dec58 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,
 							   &chip);
 				if (err < 0)
-- 
2.9.3


------------------------------------------------------------------------------
_______________________________________________
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