Contents of /trunk/udev/udev-sound-card.rules.magellan
Parent Directory | Revision Log
Revision 1016 -
(show annotations)
(download)
Tue Apr 6 23:46:22 2010 UTC (14 years, 5 months ago) by niro
File size: 5752 byte(s)
Tue Apr 6 23:46:22 2010 UTC (14 years, 5 months ago) by niro
File size: 5752 byte(s)
-merged with upstream udev-151 rules
1 | # /etc/udev/rules/78-sound-card.rules: device naming rules for udev |
2 | # $Header: /root/magellan-cvs/src/udev/udev-sound-card.rules.magellan,v 1.2 2010-04-06 23:46:22 niro Exp $ |
3 | # |
4 | # There are a number of modifiers that are allowed to be used in some |
5 | # of the different fields. They provide the following subsitutions: |
6 | # %n - the "kernel number" of the device. |
7 | # For example, 'sda3' has a "kernel number" of '3' |
8 | # %k - the kernel name for the device. |
9 | # %M - the kernel major number for the device |
10 | # %m - the kernel minor number for the device |
11 | # %b - the bus id for the device |
12 | # %c - the string returned by the PROGRAM. (Note, this doesn't work within |
13 | # the PROGRAM field for the obvious reason.) |
14 | # %s{filename} - the content of a sysfs attribute. |
15 | # %% - the '%' char itself. |
16 | # |
17 | # Try not to modify this file, if you wish to change things, create a new rule |
18 | # file that can be run before this one. |
19 | # |
20 | |
21 | SUBSYSTEM!="sound", GOTO="sound_end" |
22 | |
23 | ACTION=="add|change", KERNEL=="controlC*", ATTR{../uevent}="change" |
24 | ACTION!="change", GOTO="sound_end" |
25 | |
26 | # Ok, we probably need a little explanation here for what the two lines above |
27 | # are good for. |
28 | # |
29 | # The story goes like this: when ALSA registers a new sound card it emits a |
30 | # series of 'add' events to userspace, for the main card device and for all the |
31 | # child device nodes that belong to it. udev relays those to applications, |
32 | # however only maintains the order between father and child, but not between |
33 | # the siblings. The control device node creation can be used as synchronization |
34 | # point. All other devices that belong to a card are created in the kernel |
35 | # before it. However unfortunately due to the fact that siblings are forwarded |
36 | # out of order by udev this fact is lost to applications. |
37 | # |
38 | # OTOH before an application can open a device it needs to make sure that all |
39 | # its device nodes are completely created and set up. |
40 | # |
41 | # As a workaround for this issue we have added the udev rule above which will |
42 | # generate a 'change' event on the main card device from the 'add' event of the |
43 | # card's control device. Due to the ordering semantics of udev this event will |
44 | # only be relayed after all child devices have finished processing properly. |
45 | # When an application needs to listen for appearing devices it can hence look |
46 | # for 'change' events only, and ignore the actual 'add' events. |
47 | # |
48 | # When the application is initialized at the same time as a device is plugged |
49 | # in it may need to figure out if the 'change' event has already been triggered |
50 | # or not for a card. To find that out we store the flag environment variable |
51 | # SOUND_INITIALIZED on the device which simply tells us if the card 'change' |
52 | # event has already been processed. |
53 | |
54 | KERNEL!="card*", GOTO="sound_end" |
55 | |
56 | ENV{SOUND_INITIALIZED}="1" |
57 | |
58 | SUBSYSTEMS=="usb", ENV{ID_MODEL}=="", IMPORT{program}="usb_id --export %p" |
59 | SUBSYSTEMS=="usb", ENV{ID_VENDOR_FROM_DATABASE}=="", IMPORT{program}="usb-db %p" |
60 | SUBSYSTEMS=="usb", ATTRS{idVendor}!="", ATTRS{idProduct}!="", ENV{ID_VENDOR_ID}="$attr{idVendor}", ENV{ID_MODEL_ID}="$attr{idProduct}" |
61 | SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}!="", ENV{ID_IFACE}="$attr{bInterfaceNumber}" |
62 | SUBSYSTEMS=="usb", GOTO="skip_pci" |
63 | |
64 | SUBSYSTEMS=="pci", ENV{ID_VENDOR_FROM_DATABASE}=="", IMPORT{program}="pci-db %p" |
65 | SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" |
66 | |
67 | LABEL="skip_pci" |
68 | |
69 | ENV{ID_SERIAL}=="?*", ENV{ID_IFACE}=="?*", ENV{ID_ID}="$env{ID_BUS}-$env{ID_SERIAL}-$env{ID_IFACE}-$attr{id}" |
70 | ENV{ID_SERIAL}=="?*", ENV{ID_IFACE}=="", ENV{ID_ID}="$env{ID_BUS}-$env{ID_SERIAL}-$attr{id}" |
71 | |
72 | ENV{ID_PATH}=="", IMPORT{program}="path_id %p/controlC%n" |
73 | |
74 | # The values used here for $SOUND_FORM_FACTOR and $SOUND_CLASS should be kept |
75 | # in sync with those defined for PulseAudio's src/pulse/proplist.h |
76 | # PA_PROP_DEVICE_FORM_FACTOR, PA_PROP_DEVICE_CLASS properties. |
77 | |
78 | # If the first PCM device of this card has the pcm class 'modem', then the card is a modem |
79 | ATTR{pcmC%nD0p/pcm_class}=="modem", ENV{SOUND_CLASS}="modem", GOTO="sound_end" |
80 | |
81 | # Identify cards on the internal PCI bus as internal |
82 | SUBSYSTEMS=="pci", DEVPATH=="*/0000:00:??.?/sound/*", ENV{SOUND_FORM_FACTOR}="internal", GOTO="sound_end" |
83 | |
84 | # Recognize good old WinTV cards and those based on saa7134 as TV cards |
85 | SUBSYSTEMS=="pci", DRIVERS=="Bt87x", ENV{SOUND_FORM_FACTOR}="tv", GOTO="sound_end" |
86 | SUBSYSTEMS=="pci", DRIVERS=="saa7134", ENV{SOUND_FORM_FACTOR}="tv", GOTO="sound_end" |
87 | |
88 | # Hmm, do we really want this database here? |
89 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="0311", ENV{SOUND_FORM_FACTOR}="webcam", GOTO="sound_end" |
90 | |
91 | # Devices that also support Image/Video interfaces are most likely webcams |
92 | SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACES}=="*:0e????:*", ENV{SOUND_FORM_FACTOR}="webcam", GOTO="sound_end" |
93 | |
94 | # Matching on the model strings is a bit ugly, I admit |
95 | ENV{ID_MODEL}=="*[Ss]peaker*", ENV{SOUND_FORM_FACTOR}="speaker", GOTO="sound_end" |
96 | ENV{ID_MODEL_FROM_DATABASE}=="*[Ss]peaker*", ENV{SOUND_FORM_FACTOR}="speaker", GOTO="sound_end" |
97 | |
98 | ENV{ID_MODEL}=="*[Hh]eadphone*", ENV{SOUND_FORM_FACTOR}="headphone", GOTO="sound_end" |
99 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]eadphone*", ENV{SOUND_FORM_FACTOR}="headphone", GOTO="sound_end" |
100 | |
101 | ENV{ID_MODEL}=="*[Hh]eadset*", ENV{SOUND_FORM_FACTOR}="headset", GOTO="sound_end" |
102 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]eadset*", ENV{SOUND_FORM_FACTOR}="headset", GOTO="sound_end" |
103 | |
104 | ENV{ID_MODEL}=="*[Hh]andset*", ENV{SOUND_FORM_FACTOR}="handset", GOTO="sound_end" |
105 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]andset*", ENV{SOUND_FORM_FACTOR}="handset", GOTO="sound_end" |
106 | |
107 | ENV{ID_MODEL}=="*[Mm]icrophone*", ENV{SOUND_FORM_FACTOR}="microphone", GOTO="sound_end" |
108 | ENV{ID_MODEL_FROM_DATABASE}=="*[Mm]icrophone*", ENV{SOUND_FORM_FACTOR}="microphone", GOTO="sound_end" |
109 | |
110 | LABEL="sound_end" |