BarryK wrote:If you don't have any alsa configuration at all, no asound.conf, nothing to affect snd module parameters, etc., will alsa always default to using card 0 and device 0 for sound output? and ctrl 0?
On this machine, with "options snd-hda-intel id=HDMI index=1" applied
Code: Select all
# cat /proc/asound/cards
0 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xb3814000 irq 49
1 [HDMI ]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xb3810000 irq 53
"PCH" is the analog sound.
Without it:
Code: Select all
# cat /proc/asound/cards
0 [HDMI ]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xb3810000 irq 53
1 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xb3814000 irq 49
This is coming from a machine with this devices. (Note the devices are different from the one in my previous post, but the points I want to discuss is still the same).
Code: Select all
# lspci -d ::0403
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 09)
00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)
Without the modprobe option, we don't know which one of these PCI devices become card 0, and which one becomes card 1 - it depends on which device is recognised first by the kernel, but for my case, the HDMI is consistently detected as card 0.
If you don't have any /etc/asound.conf, then hw:0 is your default device; this corresponds to card 0. Most of the time I don't have anything attached to the HDMI port so I hear nothing.
With /etc/asound.conf, you can easily set the default device to hw:1 (which is card 1) and problem is "solved". Yes, solved except that certain programs that dont't use ALSA but use OSS, will always use card 0, so they won't make any sound. It is also, that if you accidentally remove /etc/asound.conf (or $HOME/.asoundrc, same thing), then ALSA suddenly reverts to hw:0 as default and you have no sound.
Now, with the modprobe options, you are swapping the definition of card 0/card 1 below the ALSA layer. With this, the analog audio becomes card 0, and HDMI becomes card 1. This, without any /etc/asound.conf, hw:0 is the default and you have nice sound coming out from your analog speaker. OSS programs will also work nicely.
Of course, in this situation, you can always reverse the situation again with /etc/asound.conf too to swap the default device to card 1 for HDMI if you want to use it.
Also, there doesn't seem to be any utility that will return the current default card, device and ctrl numbers. I suppose it is possible to find that info in /sys/sound?
As above, there are two meaning of "default" card, ALSA "default" (hw:0) and "system default" (=card 0). You can change the ALSA default by editing /etc/asound.conf, but if there is nothing else, ALSA default is __always__ hw:0. Otherwise, if you have /etc/asound.conf, the default is defined using the line "pcm.!default" line.
"system default" is whatever gets loaded as "card 0", which you can find out from /proc/asound/cards, and you can change this by using the modprobe line.
So you can set the defaults in two different ways.
Bonus:
If you want to associate the device listed by "lspci -d ::0403" with the cards listed in /proc/asound/cards, you can find them in "/sys/class/sound/card0/device/uevent" (replace card0 with card1, card2, etc as needed). The PCI_SLOT_NAME will be the same as the device ID you get from lspci.
For example, in this machine, with the modprobe options applied (so card 0 is the analog output)
Code: Select all
# cat /sys/class/sound/card0/device/uevent
DRIVER=snd_hda_intel
PCI_CLASS=40300
PCI_ID=8086:9C20
PCI_SUBSYS_ID=104D:90BE
PCI_SLOT_NAME=0000:00:1b.0
MODALIAS=pci:v00008086d00009C20sv0000104Dsd000090BEbc04sc03i00
So my analog card, which is currently set as "card 0", is actually the "Intel Corporation 8 Series HD Audio Controller", the second device listed in "lspci". As it is further in the PCI device tree that the other card (which is HDMI), without any modprobe options it would have become the second card (card 1) instead.
I hope this clarifies everything.