[alsa-devel] Naming multiple USB devices (solved)

Giovanni Maruzzelli gmaruzz.lists at gmail.com
Wed Nov 14 13:52:42 CET 2007


Hi list,

I've added the following script to
http://alsa.opensrc.org/index.php/Udev  (it's not the most elegant
solution, but it works for me):

BEWARE of the linebreaks, they are mangled by the mail client
=================================
#!/usr/bin/perl
# fixed persistent naming for multiple usb soundcards
# gmaruzz (at) celliax.org

# This is to be executed by udev with the following rules:
# KERNEL=="controlC[0-9]*",
DRIVERS=="usb",PROGRAM="/usr/bin/alsa_name.pl %k", NAME="snd/%c{1}"
# KERNEL=="hwC[D0-9]*", DRIVERS=="usb", PROGRAM="/usr/bin/alsa_name.pl
%k", NAME="snd/%c{1}"
# KERNEL=="midiC[D0-9]*",
DRIVERS=="usb",PROGRAM="/usr/bin/alsa_name.pl %k", NAME="snd/%c{1}"
# KERNEL=="pcmC[D0-9cp]*",
DRIVERS=="usb",PROGRAM="/usr/bin/alsa_name.pl %k", NAME="snd/%c{1}"

use strict;
use warnings;

my $alsaname = $ARGV[0]; #udev called us with this argument (%k)
my $physdevpath = $ENV{PHYSDEVPATH}; #udev put this in our environment
my $alsanum = "cucu";
#you can find the physdevpath of a device with "udevinfo -a -p
$(udevinfo -q path -n /dev/snd/pcmC0D0c)"


$physdevpath =~ s/.*\/([^\/]*)/$1/; #eliminate until last slash
$physdevpath =~ s/([^:]*):.*/$1/; #eliminate from twopoint (:) to end_of_line

if($physdevpath eq "1-5.2") # you can find this value with "dmesg"
{
       $alsanum="11"; #start from "10" (easier for debugging), "0" is
for motherboard soundcard, max is "31"
}
if($physdevpath eq "1-5.3") # you can find this value with "dmesg"
{
       $alsanum="12"; #start from "10" (easier for debugging), "0" is
for motherboard soundcard, max is "31"
}
if($physdevpath eq "1-5.4") # you can find this value with "dmesg"
{
       $alsanum="13"; #start from "10" (easier for debugging), "0" is
for motherboard soundcard, max is "31"
}
if($physdevpath eq "3-2") # you can find this value with "dmesg"
{
       $alsanum="14"; #start from "10" (easier for debugging), "0" is
for motherboard soundcard, max is "31"
}
# other bus positions....

if($alsanum ne "cucu")
{
       $alsaname=~ s/(.*)C([0-9]+)(.*)/$1C$alsanum$3/;
}

print $alsaname;
exit 0;

=======================

Ciao,

Giovanni


On Feb 10, 2007 8:31 PM, Jean-Michel Pouré <jmpoure at free.fr> wrote:
> Le samedi 10 février 2007 à 18:53 +0100, Ingo Müller a écrit :
> > 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
> Alsa-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/alsa-devel
>


More information about the Alsa-devel mailing list