Today I’ve been trying to get my FreeBSD machine working with my (wonderful) TV set through HDMI. While I had no problems with the video (It worked out of the box), I was unable to get the sound working.
While searching for a solution, I found the following two messages that gave me the answer:
- http://forums.freebsd.org/archive/index.php/t-22199.html
- http://lists.freebsd.org/pipermail/freebsd-x11/2010-December/010337.html
What you need to do to get everything working is 1) tell X to use the correct video driver, and 2) tell the FreeBSD kernel to use HDMI output for the audio.
In my case, I had X working with HAL, so I had no configuration file to tweak. If this is also your case, you can dump your X configuration to a file with the command:
sudo Xorg -configure
The previous command should have left an xorg.conf.new file in /root. Copy it to some temporary place and edit it. You should look for a line like the following:
Driver "ati"
and substitute it with:
Driver "radeonhd"
Option "Audio" "on"
Option "HDMI" "all"
You can try the new configuration with the command X -config <your-newly-create-file>; if nothing explodes, copy the file to /usr/local/etc/X11/xorg.conf (or anywhere where X can find it; see xorg.conf(5)) and you’re done.
Now we have to tell to FreeBSD that we want to use the friggin’ HDMI channel for sound output. To see what device is currently using, execute the command cat /dev/sndstat. You should see something like this:
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <HDA VIA VT1708S_0 PCM #0 Analog> (play/rec) default
pcm1: <HDA VIA VT1708S_0 PCM #1 Digital> (play)
pcm2: <HDA ATI RS690/780 HDMI PCM #0 HDMI> (play)
As you can see, it is using pcm0 (the analog output) while we want to use pcm2 (the HDMI output). We can change the device with sysctl:
$ sysctl hw.snd.default_unit=2
And now everything is working fine! (well … at least for me). The only remaining step is to add the last tweak to sysctl.conf (but beware if using modules to load the sound driver; see sysctl.conf(5)).