Unfortunately, changing the audio hardware settings is somewhat complex, especially if the vendor wired the codecs in unusual ways, and/or if the BIOS contains bugs pertaining to the audio configuration.
A good start is to type
grep hda /var/run/dmesg.boot
. First, this tells you what audio controllers are present (
hdac<X>
). Just as an example, these are mine:
Code:
hdac0: <NVIDIA (0x0fb8) HDA Controller> mem 0xf7080000-0xf7083fff irq 55 at device 0.1 on pci10
hdac1: <AMD (0x1457) HDA Controller> mem 0xf7900000-0xf7907fff irq 43 at device 0.3 on pci13
So, hdac0 is my Nvidia card that supports audio output through HDMI and DisplayPort, and hdac1 is the audio hardware on my mainboard.
Second, you can see what audio codecs are present on those controllers (
hdacc<X>
). You can think of a “codec” as a chip on that controller. In most cases there is just one codec per controller, numbered “cad 0”:
Code:
hdacc0: <NVIDIA (0x0081) HDA CODEC> at cad 0 on hdac0
hdacc1: <Realtek ALC1220 HDA CODEC> at cad 0 on hdac1
Third, there are so-called “audio function groups” named
hdaa<X>
. In my case there is just one such group per codec, but I’m not sure if that’s the common case. Mayber there can be more than one. Anyway, this is how it looks for me:
Code:
hdaa0: <NVIDIA (0x0081) Audio Function Group> at nid 1 on hdacc0
hdaa1: <Realtek ALC1220 Audio Function Group> at nid 1 on hdacc1
Every function group has a number of “nodes”. This is what the “nid” (node ID) number refers to. Nodes can be input (line-in, microphone, CD audio, …), output (line-out, headphones, spdif, …), or various other functional units like mixer nodes and vendor-specific nodes. Usually there are several nodes that are disabled, because not all channels supported by the codec are actually used by the hardware. The function group itself is always identified as nid 1, as far as I know.
And finally there are the actual pcm devices. Every pcm device is associated with a number of nids (node IDs) on a function group:
Code:
pcm0: <NVIDIA (0x0081) (HDMI/DP 8ch)> at nid 4 on hdaa0
pcm1: <NVIDIA (0x0081) (HDMI/DP 8ch)> at nid 5 on hdaa0
pcm2: <Realtek ALC1220 (Analog 5.1+HP/2.0)> at nid 20,22,21,27 and 24,26 on hdaa1
pcm3: <Realtek ALC1220 (Rear Digital)> at nid 30 on hdaa1
pcm4: <Realtek ALC1220 (Front Analog Mic)> at nid 25 on hdaa1
In my case, I have a 2.1 speaker system connected to the mainboard’s line-out jack, which is pcm2, so I have the following line in my
/etc/sysctl.conf:
In your case, you want to change the association of the built-in microphone. You want to associate it with your default pcm device. In order to do that, you have to find out the function group (i.e. the
hdaa<X>
device) and the nid number
<Y>
of that microphone, then create a tunable entry for
/etc/loader.conf that looks like this:
Code:
hint.hdaa.<X>.nid<Y>.config="..."
where
<X>
is the number of the
hdaa
device (function group) and
<X>
is the ID number of the microphone node.
The value of the entry needs to be constructed so the node is assigned to the same association as your default pcm device.
You can see the current configuration with this command:
Code:
sysctl dev.hdaa.<X>.nid<Y>_config
For example:
Code:
$ sysctl dev.hdaa.1.nid25_config
dev.hdaa.1.nid25_config: 0x02a19050 as=5 seq=0 device=Mic conn=Jack ctype=1/8 loc=Front color=Pink misc=0
Here you can see that the microphone is connected to the 5th association (
as=5
), which is pcm4 (association numbering starts at 1, while pcm device numbering starts at 0, thus as=5 refers to pcm4). You want to swap this with the node ID that is currently associated with the recoding channel of your default pcm device.
In my particular case, that would be:
Code:
hint.hdaa.1.nid25.config="as=3"
hint.hdaa.1.nid24.config="as=5"
hint.hdaa.1.nid26.config="as=5"
I haven’t actually tried that (my PC doesn’t have a built-in microphone, and I don’t own an external microphone), but I think it should work like that. This is similar to the “Example 1” in the
snd_hda(4) manual page.
By the way, you can type
sysctl dev.hdaa | less
to see a very detailed (and long!) description of your audio setup. However, I’m not really sure if that really helps in this situation… maybe it just creates even more confusion.