FreeBSD: no automatic switching between sound in speaker and built-in headphones jack

Got back to use FreeBSD in my Lenovo, now using FreeBSD 12.0. The previous answer, while not exactly 100% right, put me in the right track.

To get sound to work, out the box, and switch to headphones, when inserting them in the audiojack:

  • The directive hw.snd.default_unit has to be taken out from sysctl.conf;
  • The as/audioset per default is 2, so 2 has to be used, and not 1. Tried as=1, an definitively does not work as intended.

Based on the default sysctl visual inspection, the question/previous posts, and @Trevor's answer, the complete configuration to get a Lenovo Ideapad 100S IBR for getting sound to work, and switch to headphones automatically is:

File: /etc/sysctl.conf

# Without this sound does not even work, both in speakers or headphones
dev.hdac.0.polling=1

File: /boot/loader.conf

snd_hda_load="YES"
mixer_enable="YES"
sound_load="YES"

File: /boot/device.hints

hint.hdaa.1.nid20.config="as=2 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal"
hint.hdaa.0.nid21.config="as=2 seq=15 device=Headphones conn=Jack"

PS. The default system configuration, just for documentation purposes is:

# sysctl -a | egrep "nid20|nid21" | grep original
dev.hdaa.0.nid21_original: 0x04211010 as=1 seq=0 device=Headphones conn=Jack ctype=1/8 loc=Right color=Black misc=0
dev.hdaa.0.nid20_original: 0x90170120 as=2 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1

Tags:

Audio

Freebsd