LinHES Forums
http://forum.linhes.org/

using udev to lock two sound devices to /dev/dspX
http://forum.linhes.org/viewtopic.php?f=5&t=16726
Page 1 of 1

Author:  cfr131 [ Tue Sep 25, 2007 1:55 pm ]
Post subject:  using udev to lock two sound devices to /dev/dspX

My system has two sound devices, an on-board Intel sound and a Turtle Beach Audio Advantage USB plug. When I reboot, I can not count on these devices being assigned to the same /dev/dsp or /dev/dsp1 It seems that I should use udev to make sure these are located at the same location each time.

Looking udevinfo for these devices:

Code:
udevinfo -a -p /class/sound/dsp

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/class/sound/dsp':
    KERNEL=="dsp"
    SUBSYSTEM=="sound"
    DRIVER==""
    ATTR{dev}=="14:3"

  looking at parent device '/devices/pci0000:00/0000:00:1f.5':
    KERNELS=="0000:00:1f.5"
    SUBSYSTEMS=="pci"
    DRIVERS=="Intel ICH"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{modalias}=="pci:v00008086d000024D5sv0000103Csd000012BCbc04sc01i00"
    ATTRS{local_cpus}=="ffffffff"
    ATTRS{irq}=="20"
    ATTRS{class}=="0x040100"
    ATTRS{subsystem_device}=="0x12bc"
    ATTRS{subsystem_vendor}=="0x103c"
    ATTRS{device}=="0x24d5"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""




Code:
udevinfo -a -p /class/sound/dsp1

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/class/sound/dsp1':
    KERNEL=="dsp1"
    SUBSYSTEM=="sound"
    DRIVER==""
    ATTR{dev}=="14:19"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="snd-usb-audio"
    ATTRS{modalias}=="usb:v0D8Cp0103d0010dc00dsc00dp00ic01isc01ip00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceClass}=="01"
    ATTRS{bNumEndpoints}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{product}=="C-Media USB Audio       "
    ATTRS{manufacturer}=="C-Media INC."
    ATTRS{maxchild}=="0"
    ATTRS{version}==" 1.10"
    ATTRS{devnum}=="3"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bcdDevice}=="0010"
    ATTRS{idProduct}=="0103"
    ATTRS{idVendor}=="0d8c"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{bmAttributes}=="80"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 2"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{serial}=="0000:00:1d.0"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{manufacturer}=="Linux 2.6.18-chw-13 uhci_hcd"
    ATTRS{maxchild}=="2"
    ATTRS{version}==" 1.10"
    ATTRS{devnum}=="1"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0206"
    ATTRS{idProduct}=="0000"
    ATTRS{idVendor}=="0000"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0':
    KERNELS=="0000:00:1d.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{modalias}=="pci:v00008086d000024D2sv0000103Csd000012BCbc0Csc03i00"
    ATTRS{local_cpus}=="ffffffff"
    ATTRS{irq}=="18"
    ATTRS{class}=="0x0c0300"
    ATTRS{subsystem_device}=="0x12bc"
    ATTRS{subsystem_vendor}=="0x103c"
    ATTRS{device}=="0x24d2"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""


I created a new rules file in /etc/udev called sound.rules. The contents are: (sorry for the word wrap)

Code:
cat sound.rules
#Using info from:
#http://mysettopbox.tv/phpBB2/viewtopic.php?t=13520&sid=2c2fde4ddac1200f22a9125b98a570e3


#This sets the USB audio device to DSP1
DRIVERS=="snd-usb-audio", ATTRS{product}=="C-Media USB Audio       ", KERNELS=="1-1:1.0", NAME="dsp", SYMLINK+="C-Media-Audio", SUBSYSTEM=="sound", GROUP="audio"

#This should set the internal sound to DSP
DRIVERS=="Intel ICH ", KERNELS=="0000:00:1f.5", ATTR{dev}=="14:4", NAME="dsp1", SYMLINK+="On-Board-Intel", GROUP="audio"

I then made a simlink in /etc/udev/rules.d
Code:
z99_sound.rules -> ../sound.rules

Reboot the machine and no difference, the Intel came up as /dev/dsp, the USB device came up as DSP1 and there was no symlink in /dev.

This is my first attempt at using udev; I have read what I could find, but I have yet to find where udev puts any error messages?

Any other suggestions would be helpful.

_____
/ony

Author:  cecil [ Sun Sep 30, 2007 1:18 pm ]
Post subject: 

I've no idea where udev logs either. Here is a link to writing rules:http://reactivated.net/writing_udev_rules.html I'd suggest starting off by make your rules simply. Only offer one or two elements. For instance, here is my rule for my PVR 500:
Code:
SUBSYSTEM=="video4linux", ATTR{name}=="ivtv0 encoder MPEG", SYMLINK+="pvr501"
SUBSYSTEM=="video4linux", ATTR{name}=="ivtv1 encoder MPEG", SYMLINK+="pvr502"

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/