  <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.alsa-project.org/main/index.php?action=history&amp;feed=atom&amp;title=Changing_card_IDs_with_udev</id>
	<title>Changing card IDs with udev - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.alsa-project.org/main/index.php?action=history&amp;feed=atom&amp;title=Changing_card_IDs_with_udev"/>
	<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Changing_card_IDs_with_udev&amp;action=history"/>
	<updated>2026-04-24T20:53:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.0</generator>
	<entry>
		<id>https://www.alsa-project.org/main/index.php?title=Changing_card_IDs_with_udev&amp;diff=6519&amp;oldid=prev</id>
		<title>ClemensLadisch: card ordering with udev</title>
		<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Changing_card_IDs_with_udev&amp;diff=6519&amp;oldid=prev"/>
		<updated>2012-07-23T21:06:10Z</updated>

		<summary type="html">&lt;p&gt;card ordering with udev&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Determining the device path ==&lt;br /&gt;
&lt;br /&gt;
First, run the command&lt;br /&gt;
 udevadm monitor --kernel --subsystem-match=sound&lt;br /&gt;
Then plug your USB device in; the output will look like this:&lt;br /&gt;
 KERNEL[1343075515.559055] add      /devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5 (sound)&lt;br /&gt;
 KERNEL[1343075515.559673] add      /devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5/pcmC5D0p (sound)&lt;br /&gt;
 KERNEL[1343075515.559978] add      /devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5/pcmC5D0c (sound)&lt;br /&gt;
 KERNEL[1343075515.561556] add      /devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5/controlC5 (sound)&lt;br /&gt;
 KERNEL[1343075515.575976] change   /devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5 (sound)&lt;br /&gt;
For PCI cards, unload and reload the driver module; the output will look like this:&lt;br /&gt;
 KERNEL[1343075492.525461] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2 (sound)&lt;br /&gt;
 KERNEL[1343075492.530679] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/midiC2D0 (sound)&lt;br /&gt;
 KERNEL[1343075492.536421] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/midi2 (sound)&lt;br /&gt;
 KERNEL[1343075492.541358] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/dmmidi2 (sound)&lt;br /&gt;
 KERNEL[1343075492.546662] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/pcmC2D1p (sound)&lt;br /&gt;
 KERNEL[1343075492.551704] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/pcmC2D1c (sound)&lt;br /&gt;
 KERNEL[1343075492.557349] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/pcmC2D0p (sound)&lt;br /&gt;
 KERNEL[1343075492.562739] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/pcmC2D0c (sound)&lt;br /&gt;
 KERNEL[1343075492.568942] add      /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2/controlC2 (sound)&lt;br /&gt;
 KERNEL[1343075492.574929] change   /devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2 (sound)&lt;br /&gt;
&lt;br /&gt;
The device path we want is the string that is output for the last change event.&amp;lt;br&amp;gt;&lt;br /&gt;
In these example, the device path would be &amp;lt;tt&amp;gt;/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card5&amp;lt;/tt&amp;gt;&lt;br /&gt;
or &amp;lt;tt&amp;gt;/devices/pci0000:00/0000:00:14.4/0000:06:05.0/sound/card2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Creating udev rules ==&lt;br /&gt;
&lt;br /&gt;
Create a file in &amp;lt;tt&amp;gt;/lib/udev/rules.d/&amp;lt;/tt&amp;gt; with a name like &amp;lt;tt&amp;gt;85-my-usb-audio.rules&amp;lt;/tt&amp;gt;&lt;br /&gt;
and contents like the following:&lt;br /&gt;
&lt;br /&gt;
 SUBSYSTEM!=&amp;quot;sound&amp;quot;, GOTO=&amp;quot;my_usb_audio_end&amp;quot;&lt;br /&gt;
 ACTION!=&amp;quot;add&amp;quot;, GOTO=&amp;quot;my_usb_audio_end&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 DEVPATH==&amp;quot;/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card?&amp;quot;, ATTR{id}=&amp;quot;MyDev_A&amp;quot;&lt;br /&gt;
 DEVPATH==&amp;quot;/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.2/1-4.2:1.0/sound/card?&amp;quot;, ATTR{id}=&amp;quot;MyDev_B&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 LABEL=&amp;quot;my_usb_audio_end&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The SUBSYSTEM and ACTION rules skip over the file if udev is called for any non-sound device,&lt;br /&gt;
or if some sound device is removed.&lt;br /&gt;
&lt;br /&gt;
The DEVPATH==&amp;quot;...&amp;quot; check matches our cards.&lt;br /&gt;
Please note the &amp;quot;card?&amp;quot; at the end which will match for any random sound card number.&lt;br /&gt;
&lt;br /&gt;
The ATTR{id}=&amp;quot;...&amp;quot; assignment actually changes the card's ID.&lt;br /&gt;
Use whatever ID you want (but most special characters are not allowed).&lt;br /&gt;
&lt;br /&gt;
== Using the devices ==&lt;br /&gt;
&lt;br /&gt;
Use the ID string where you would otherwise use the card number, such as&lt;br /&gt;
 aplay -D default:MyDev_A something.wav&lt;br /&gt;
 mplayer -ao alsa:device=hw=MyDev_B somethingelse.avi&lt;/div&gt;</summary>
		<author><name>ClemensLadisch</name></author>
	</entry>
</feed>