Monday, November 20, 2006

Setting up the Sound card in FreeBSD

Setting up the sound card in FreeBSD
System:

  • This howto is for FreeBSD and FreeBSD based systems.
Prerequisites:
  • root access to the system
  • A text editor (I will use vi for this tutorial)

As FreeBSD is a server operating system things like sound are not configured to work out of the box. Yet getting sound working is a very simple task once you know how.

Step one:
Firstly you need to find out what driver you need to use with your sound card, (If you already know this you can move onto Step two). This step is not as scary as it sounds.

First try to load the snd_driver module, This module loads all of the most common sound device drivers at once:
# kldload snd_driver

You can now easily see which driver to use, by using the following command:
# cat /dev/sndstat
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: at io 0xd800, 0xdc80 irq 5 bufsz 16384
kld snd_ich (1p/2r/0v channels duplex default)


The output will vary depending on your system. Yet from the above output we can see that snd_ich is the driver needed.
*Note if you did not get a response you can do a couple of other things:
  1. You could look at the FreeBSD 6.1 Hardware Notes, or the FreeBSD 5.5 Hardware notes to find out if your card is supported.
  2. Investigate the use of another sound system e.g. OSS (Open Sound System).
If anyone has any other suggestions please let me know.

Step two:
Now that we know which sound driver to use you can load that exact sound driver every time you boot by adding it to your /boot/loader.conf file. You do this by adding a line like this:
snd_YourDriverName_load="YES"
an example using the above driver would be:
# vi /boot/loader.conf
add:
snd_ich_load="YES"

For more information please see: FreeBSD Handbook - Setting up sound and snd(4) man page.