Today I won in one minor battle between snd_hda and headphone output. I couldn't force my headphones work without some magic. The first thing I found is that headphone nid should be on the same association with speaker. In my verbose dmesg I had:
hdac0: Processing audio FG cad=2 nid=1...
hdac0: GPIO: 0xc0000003 NumGPIO=3 NumGPO=0 NumGPI=0 GPIWake=1 GPIUnsol=1
hdac0: nid 10 0x0221421f as 1 seq 15 Headphones Jack jack 1 loc 2 color Green misc 2
hdac0: Patching pin config nid=10 0x0221421f -> 0x0221431f
hdac0: nid 11 0x01a19023 as 2 seq 3 Mic Jack jack 1 loc 1 color Pink misc 0
hdac0: nid 12 0x01813221 as 2 seq 1 Line-in Jack jack 1 loc 1 color Blue misc 2
hdac0: nid 13 0x01114210 as 1 seq 0 Speaker Jack jack 1 loc 1 color Green misc 2
hdac0: nid 14 0x40f0f0f0 as 15 seq 0 Other None jack 0 loc 0 color Other misc 0
hdac0: nid 15 0x40f0f0f1 as 15 seq 1 Other None jack 0 loc 0 color Other misc 0
hdac0: nid 16 0x40f0f0f2 as 15 seq 2 Other None jack 0 loc 0 color Other misc 0
hdac0: nid 17 0x40f0f0f3 as 15 seq 3 Other None jack 0 loc 0 color Other misc 0
hdac0: nid 18 0x503301f0 as 15 seq 0 CD None jack 3 loc 16 color Unknown misc 1
hdac0: nid 33 0x01442170 as 7 seq 0 SPDIF-out Jack jack 4 loc 1 color Grey misc 1
hdac0: nid 34 0x81c42090 as 9 seq 0 SPDIF-in Fixed jack 4 loc 1 color Grey misc 0
The only advice I found was to put headphones nid (in my case, 10 nid) on the same association with speaker (nid 13). To do this you should add the following line to /boot/loader.conf:
After doing that I understood, that my configuration already was right in this sense. This hint didn't change anything. After reading manual for snd_hda and consulting with Oleg (http://www.oleg-sharoyko.net) I set misc for nid10 to 3 (zero bit says that jack detection is not implemented in hardware). Now I have working headphones and can listen to music without doing harm to my neighbors...
So, this time the force is in another magic line in loader.conf:
The battle is won. But the war continues... I'd like to have separate mixer for headphones. When I make it functional, I'll write...