Skip to contentSkip to conversation

Naming two identical USB devices (need help)

DISCUSSION Jean-Michel Pouré 3 participants 6 messages Feb 9, 2007 – Feb 10, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

My need is very basic.

I am using two Terratec Aureon USB MK2 devices. But this could be any case where two devices are the same.

My question is:

Is there a way to make sure that each physical device always has the same name: plughw:0,0 (first identical card) and plughw:1,0 (second identical card). This would allow me to plug the cards and forget the plugs.

Presently, numbers change on every reboot or if I hotplug devices.

I read on the wiki that it was possible to load modules in a precise order. But it seems to be working in case of several ***different*** devices, not several identical devices:
http://alsa.opensrc.org/MultipleCards

Any idea? Is there a way to use Udev?

If it is not possible in the current state of Alsa, I will send back one device to the retailer, in which case I need your kind advice quickly.

Kind regards,
Jean-Michel Pouré

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#1 lore raw
Quoted 7 lines · Jean-Michel Pouré

Hello,

My need is very basic.

I am using two Terratec Aureon USB MK2 devices. But this could be any case where two devices are the same.

Quoted 7 lines

My question is:

Is there a way to make sure that each physical device always has the same name: plughw:0,0 (first identical card) and plughw:1,0 (second identical card). This would allow me to plug the cards and forget the plugs.

I don't think there's an easy way with any current Linux distro.

Don't USB devices have some kind of hardware serial number or GUID that udev could be taught about?

Lee

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#2 lore raw
Quoted 6 lines · Lee Revell

I don't think there's an easy way with any current Linux distro.

Don't USB devices have some kind of hardware serial number or GUID that udev could be taught about?

Lee

Dear Alsa developpers,

udevinfo can handle serial ID.
It is very versatile.

But then the question is, how do I use Udev to teach Alsa how to set up plughw:x,y numbers. It should be possible to rename PCMs using Udev. But how do I rename plughw:x,y.

I searched on Google and the wiki without answers.

I can hardly imagine that professionnal hardware with several identical cards cannot distinguish audio devices once for all.

I am very happy with Alsa, and I can wait a couple of months before Alsa handles Udev better. But please inform me so that I can ship my second card back.

Kind regards,
Jean-Michel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#3 lore raw
In reply to Jean-Michel Pouré

Hi!

I thought about your problem again and I think I made a small progress! I was able to set the cards number to any number I want using a udev rule, so I could use that card with plughw:n,0 where n was the number of my choise. I didn't use a udev rule that makes a lot of sense, but I'm sure that there is a possibility to create a rule that depends on the usb port your usb sound card is plugged in. Here is what I did:

I looked at the devices that where created before I did anything:

ingo@ingo-desktop:~$ls -l /dev/snd/
insgesamt 0
crw-rw---- 1 root audio 116, 11 2007-02-10 18:26 controlC0 crw-rw---- 1 root audio 116, 3 2007-02-10 18:26 hwC0D0 crw-rw---- 1 root audio 116, 13 2007-02-10 18:26 hwC0D2 crw-rw---- 1 root audio 116, 4 2007-02-10 18:26 midiC0D0 crw-rw---- 1 root audio 116, 14 2007-02-10 18:26 midiC0D1 crw-rw---- 1 root audio 116, 15 2007-02-10 18:26 midiC0D2 crw-rw---- 1 root audio 116, 10 2007-02-10 18:26 pcmC0D0c

crw-rw---- 1 root audio 116,  9 2007-02-10 18:26 pcmC0D0p
crw-rw---- 1 root audio 116,  8 2007-02-10 18:26 pcmC0D1c
crw-rw---- 1 root audio 116,  7 2007-02-10 18:26 pcmC0D2c
crw-rw---- 1 root audio 116,  6 2007-02-10 18:26 pcmC0D2p
crw-rw---- 1 root audio 116,  5 2007-02-10 18:26 pcmC0D3p

crw-rw---- 1 root audio 116, 12 2007-02-10 18:26 seq crw-rw---- 1 root audio 116, 2 2007-02-10 18:26 timer

The I looked at the udev rules, that created these devices (in /etc/udev/rules.d/20-names.rules):

# Sound devices, group under /dev/snd
KERNEL=="controlC[0-9]*", NAME="snd/%k"
KERNEL=="hwC[D0-9]*", NAME="snd/%k"
KERNEL=="midiC[D0-9]*", NAME="snd/%k"
KERNEL=="pcmC[D0-9cp]*", NAME="snd/%k"
KERNEL=="seq", NAME="snd/%k"
KERNEL=="timer", NAME="snd/%k"

These rules only "move" the sound devices to the snd/ directory. In order to change the name of the created devices, I created a rule for every device that has been created before, using its name from the first ls command, and changed the card number (still moving it to snd/), here it is number 3.

KERNEL=="controlC0", NAME="snd/controlC3"
KERNEL=="hwC0D0", NAME="snd/hwC3D0"
KERNEL=="hwC0D2", NAME="snd/hwC3D2"
KERNEL=="midiC0D0", NAME="snd/midiC3D0"
KERNEL=="midiC0D1", NAME="snd/midiC3D1"
KERNEL=="midiC0D2", NAME="snd/midiC3D2"
KERNEL=="pcmC0D0c", NAME="snd/pcmC3D0c"
KERNEL=="pcmC0D0p", NAME="snd/pcmC3D0p"
KERNEL=="pcmC0D1c", NAME="snd/pcmC3D1c"
KERNEL=="pcmC0D2c", NAME="snd/pcmC3D2c"
KERNEL=="pcmC0D2p", NAME="snd/pcmC3D2p"
KERNEL=="pcmC0D3p", NAME="snd/pcmC3D3p"

The result: My card was not card 0 anymore ("Karte 0"), but card 3 ("Karte 3") and I was able to use it with plughw:3,0.

ingo@ingo-desktop:~$aplay -l
**** Liste von PLAYBACK Geräten ****
Karte 3: Live [SBLive! Platinum [CT4760P]], Gerät 0: emu10k1 [ADC Capture/Standard PCM Playback]
Untergeordnete Geräte: 32/32
Untergeordnetes Gerät '0: subdevice #0 Untergeordnetes Gerät '1: subdevice #1 Untergeordnetes Gerät '2: subdevice #2 Untergeordnetes Gerät '3: subdevice #3
...

That means that there is a way to influence the number of the card with udev! Now, everything you have to do is find a udev rule that matches a certain usb port. As you can run external programs with udev, there must be a way to do that.

I'm going to play with udev now, too, so if I find something, I'll tell you. In return, it would be awesome if you could write down - even it is only short - a howto about how to manage two identical devices, once we got it working.

Regards, Ingo

Quoted 21 lines · Jean-Michel Pouré

Hello,

My need is very basic.

I am using two Terratec Aureon USB MK2 devices. But this could be any case where two devices are the same.

My question is:

Is there a way to make sure that each physical device always has the same name: plughw:0,0 (first identical card) and plughw:1,0 (second identical card). This would allow me to plug the cards and forget the plugs.

Presently, numbers change on every reboot or if I hotplug devices.

I read on the wiki that it was possible to load modules in a precise order. But it seems to be working in case of several ***different*** devices, not several identical devices:
http://alsa.opensrc.org/MultipleCards

Quoted 7 lines

Any idea? Is there a way to use Udev?

If it is not possible in the current state of Alsa, I will send back one device to the retailer, in which case I need your kind advice quickly.

Kind regards,
Jean-Michel Pouré

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#4 lore raw

Hi!

I found a command that may be very usefull to create a udev rule:

udevinfo -a -p $(udevinfo -q path -n <path-to-current-device-node>)

If I get it right, it displays everything you can use to create udev rules (except external programs). I've run it for a non sound card usb device and it lists the usb port! If youre lucky, there is even an unique identifier - just compare the output of the two devices.

Regards, Ingo

Quoted 2 lines · Ingo Müller

I'm going to play with udev now, too, so if I find something, I'll tell you.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#5 lore raw
In reply to Ingo Müller
Quoted 8 lines · Ingo Müller

I'm going to play with udev now, too, so if I find something, I'll tell
you. In return, it would be awesome if you could write down - even it is
only short - a howto about how to manage two identical devices, once we
got it working.

Fantastic.

Thank you very much for your help.
I will add a page on the wiki about udev rules.

Kind regards,
Jean-Michel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel