[alsa-devel] Controlling the cards order

Olivier Langlois olivier at trillion01.com
Fri Mar 7 05:06:55 CET 2014


On Thu, 2014-03-06 at 12:42 -0500, Olivier Langlois wrote:
> Hi,
> 
> I have added a second sound device in my system and it unexpectedly took
> the first card slot.
> 
> I have found that it is easy to control the order as long as the devices
> use different drivers by modifying
> 
> /etc/modprobe.d/alsa.conf
> 
> ( http://alsa.opensrc.org/MultipleCards )
> 
> but in my situation I have 2 different devices using the same driver. I
> think that there is hope that I find an answer by digging the more
> general topic of ordering PCI devices drivers loading but if someone has
> few pointers to share, any help is welcome!
> 
> Here are my 2 devices that I would like to change the order:
> 
> lano1106 at whippet2 /proc/asound $ cat cards
>  0 [PCH            ]: HDA-Intel - HDA Intel PCH
>                       HDA Intel PCH at 0xfbf20000 irq 84
>  1 [HDMI           ]: HDA-Intel - HDA ATI HDMI
>                       HDA ATI HDMI at 0xfbe60000 irq 88

I love Linux for allowing almost anything imaginable!

in the kernel command line, I added the following:

1.

pci-stub.ids=1002:aaa0,8086:1d20

2.

Create a systemd service

/usr/lib/systemd/system/snd_hda_intel-bind.service:

[Unit]
Description=Binds PCI Audio devices to snd_hda_intel in the specified
order
After=syslog.target

[Service]
EnvironmentFile=-/etc/snd_hda_intel.cfg
Type=oneshot
RemainAfterExit=yes
ExecStart=-/usr/bin/snd_hda_intel-bind $DEVICES

[Install]
WantedBy=multi-user.target

3.

/etc/snd_hda_intel.cfg:

DEVICES="0000:01:00.1 0000:00:1b.0"

4.

/usr/bin/snd_hda_intel-bind:

#!/bin/bash

modprobe snd_hda_intel

for var in "$@"; do
	if [ -e /sys/bus/pci/devices/$var/driver ]; then
		echo $var > /sys/bus/pci/devices/$var/driver/unbind
	fi
	echo $var > /sys/bus/pci/drivers/snd_hda_intel/bind
done


Result:

lano1106 at whippet2 /proc/asound :( $ cat cards 
 0 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfbe60000 irq 87
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xfbf20000 irq 88


tadam!




More information about the Alsa-devel mailing list