Re: [Alsa-user] Several similar usb midi devices

2016-08-29 Thread Takashi Iwai
On Mon, 29 Aug 2016 17:00:40 +0200,
barmin wrote:
> 
> Hi Takashi,
> 
> Thanks for your answer.
> 
> > 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.)
> 
> I don't think I can use this, as I have two identical devices with same 
> VID/PID.

My patch introduced another option to specify the device path.  It's
evaluated in addition to VID/PID pairs.

> > 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.
> 
> Yeah, I think this is the problem...
> 
> > Another solution would be to load the sequencer stuff only after all
> > your devices are set up.
> 
> I'm not sure what you mean by this?

The whole sequencer stuff (snd-seq* modules) can be unloaded and
reloaded after you load your usb-audio driver *and* do renaming.
It'll be fairly tricky, but it's doable.


Takashi

--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Several similar usb midi devices

2016-08-29 Thread Clemens Ladisch
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.
>
> 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

The card that happens to be registered first with ALSA gets the name
SSCOM, the second one SSCOM_1.  So if they are in the correct order,
run:
aconnect SSCOM:0 14:0
aconnect SSCOM_1:0 14:1

otherwise:
aconnect SSCOM:0 14:1
aconnect SSCOM_1:0 14:0


Regards,
Clemens

--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Several similar usb midi devices

2016-08-29 Thread Takashi Iwai
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 
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 
---
 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,
   );
if (err < 0)
-- 
2.9.3


--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Several similar usb midi devices

2016-08-29 Thread barmin
>> 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...

Thanks,

Matt

--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Several similar usb midi devices

2016-08-22 Thread barmin
Hi Clemens,

Thanks for your answer.

> At the moment, the sequencer client name is not updated together with
> the card ID name.

Are there any plans to add this in future versions?

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

Thanks,

Matt

--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Several similar usb midi devices

2016-08-22 Thread Clemens Ladisch
barmin wrote:
> I'm trying to use two USB MIDI foot controllers from the same
> manufacturer at the same time and I'm facing the usual problem that
> the device names and numbers change depending on connection order. The
> first one connected is called SSCOM, the second one SSCOM_1.
>
> I added udev rules as explained here: http://alsa.opensrc.org/Udev
> (section 1.4) and now the names in /proc/asound/cards reflect the USB
> slot where my controller is connected instead of the order of
> connection (e.g., controller_left and controller_right).
>
> So far so good, but... if I list the MIDI ports with e.g. `pmidi -l`,
> I still get SSCOM and SSCOM_1 instead of my custom names.

At the moment, the sequencer client name is not updated together with
the card ID name.

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.


Regards,
Clemens

--
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user