Logitech USB Headset on FreeBSD

This post is sort of a reminder to myself (and other poor souls like you) on how to configure FreeBSD to use a USB headset for audio output (for some reason I always forget this particular thing …). I’ve tested this on both FreeBSD 8.2 and 9.0.

The first step is to load the uadio device driver in the system.  You can do it manually with

sudo kldload uaudio

Once you’ve got everything working, you can compile the driver in the kernel or load it at boot time as explained in the snd_uaudio manpage.

Once the driver is loaded, and the headset is attached to a usb port, you should see a new entry appear in /dev/sndstat (in my case, it is pcm3):

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <HDA VIA VT1708S_0 PCM #0 Analog> (play/rec)
pcm1: <HDA VIA VT1708S_0 PCM #1 Digital> (play)
pcm2: <HDA ATI RS690/780 HDMI PCM #0 HDMI> (play)
pcm3: <USB audio> (play/rec) default

Now, we only have to tell the kernel to actually use pcm3 (or whatever it’s called in your case) for audio output:

$ sudo sysctl hw.snd.default_unit=3

Enjoy!

HDMI sound output with Radeon RS780 on FreeBSD

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.

I was able to put everything in place by “merging” the information in:

  1. http://forums.freebsd.org/archive/index.php/t-22199.html
  2. http://lists.freebsd.org/pipermail/freebsd-x11/2010-December/010337.html

In this post I’ll put everything together as a reminder to myself; as a nice side effect, this may be useful to other people with the same issues.

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)).