Before beginning the configuration, determine the model of the sound card and the chip it uses. FreeBSD supports a wide variety of sound cards. Check the supported audio devices list of the Hardware Notes to see if the card is supported and which FreeBSD driver it uses.
In order to use the sound device, its device driver must be loaded. The easiest way is to load a kernel module for the sound card with kldload(8). This example loads the driver for a built-in audio chipset based on the Intel specification:
To automate the loading of this driver at boot time, add the
/boot/loader.conf. The line for
this driver is:
Other available sound modules are listed in
/boot/defaults/loader.conf. When unsure
which driver to use, load the
This is a metadriver which loads all of the most common
sound drivers and can be used to speed up the search for the
correct driver. It is also possible to load all sound drivers
by adding the metadriver to
To determine which driver was selected for the sound card
after loading the
This section is for users who prefer to statically compile in support for the sound card in a custom kernel. For more information about recompiling a kernel, refer to Chapter8, Configuring the FreeBSD Kernel.
When using a custom kernel to provide sound support, make sure that the audio framework driver exists in the custom kernel configuration file:
Next, add support for the sound card. To continue the example of the built-in audio chipset based on the Intel specification from the previous section, use the following line in the custom kernel configuration file:
Be sure to read the manual page of the driver for the device name to use for the driver.
Non-PnP ISA sound cards may require the IRQ and I/O port
settings of the card to be added to
/boot/device.hints. During the boot
process, loader(8) reads this file and passes the
settings to the kernel. For example, an old Creative
SoundBlaster 16 ISA non-PnP card will use the
snd_sbc(4) driver in conjunction with
snd_sb16. For this card, the following
lines must be added to the kernel configuration file:
device snd_sbc device snd_sb16
If the card uses the
0x220 I/O port and
5, these lines must also be added to
hint.sbc.0.at="isa" hint.sbc.0.port="0x220" hint.sbc.0.irq="5" hint.sbc.0.drq="1" hint.sbc.0.flags="0x15"
The syntax used in
is described in sound(4) and the manual page for the
driver of the sound card.
The settings shown above are the defaults. In some cases, the IRQ or other settings may need to be changed to match the card. Refer to snd_sbc(4) for more information about this card.
After loading the required module or rebooting into the
custom kernel, the sound card should be detected. To confirm,
dmesg | grep pcm. This example is
from a system with a built-in Conexant CX20590 chipset:
pcm0: <NVIDIA (0x001c) (HDMI/DP 8ch)> at nid 5 on hdaa0 pcm1: <NVIDIA (0x001c) (HDMI/DP 8ch)> at nid 6 on hdaa0 pcm2: <Conexant CX20590 (Analog 2.0+HP/2.0)> at nid 31,25 and 35,27 on hdaa1
The status of the sound card may also be checked using this command:
cat /dev/sndstatFreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64) Installed devices: pcm0: <NVIDIA (0x001c) (HDMI/DP 8ch)> (play) pcm1: <NVIDIA (0x001c) (HDMI/DP 8ch)> (play) pcm2: <Conexant CX20590 (Analog 2.0+HP/2.0)> (play/rec) default
The output will vary depending upon the sound card. If no
pcm devices are listed, double-check
that the correct device driver was loaded or compiled into the
kernel. The next section lists some common problems and their
If all goes well, the sound card should now work in FreeBSD. If the CD or DVD drive is properly connected to the sound card, one can insert an audio CD in the drive and play it with cdcontrol(1):
cdcontrol -f /dev/acd0 play 1
Audio CDs have specialized encodings which means that they should not be mounted using mount(8).
Another quick way to test the card is to send data to
be any type of file. This command should produce some noise,
confirming that the sound card is working.
/dev/dsp* device nodes will
be created automatically as needed. When not in use, they
do not exist and will not appear in the output of
Table7.1, “Common Error Messages” lists some common error messages and their solutions:
|sb_dspwr(XX) timed out|
The I/O port is not set correctly.
|bad irq XX|
The IRQ is set incorrectly. Make sure that the set IRQ and the sound IRQ are the same.
|xxx: gus pcm not attached, out of memory|
There is not enough available memory to use the device.
|xxx: can't open /dev/dsp!|
Modern graphics cards often come with their own sound
driver for use with HDMI. This sound
device is sometimes enumerated before the sound card meaning
that the sound card will not be used as the default playback
device. To check if this is the case, run
dmesg and look for
pcm. The output looks something like
... hdac0: HDA Driver Revision: 20100226_0142 hdac1: HDA Driver Revision: 20100226_0142 hdac0: HDA Codec #0: NVidia (Unknown) hdac0: HDA Codec #1: NVidia (Unknown) hdac0: HDA Codec #2: NVidia (Unknown) hdac0: HDA Codec #3: NVidia (Unknown) pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 0 nid 1 on hdac0 pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 1 nid 1 on hdac0 pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 2 nid 1 on hdac0 pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 3 nid 1 on hdac0 hdac1: HDA Codec #2: Realtek ALC889 pcm4: <HDA Realtek ALC889 PCM #0 Analog> at cad 2 nid 1 on hdac1 pcm5: <HDA Realtek ALC889 PCM #1 Analog> at cad 2 nid 1 on hdac1 pcm6: <HDA Realtek ALC889 PCM #2 Digital> at cad 2 nid 1 on hdac1 pcm7: <HDA Realtek ALC889 PCM #3 Digital> at cad 2 nid 1 on hdac1 ...
In this example, the graphics card
NVidia) has been enumerated before the
sound card (
Realtek ALC889). To use the
sound card as the default playback device, change
hw.snd.default_unit to the unit that should
be used for playback:
n is the number of the sound
device to use. In this example, it should be
4. Make this change permanent by adding
the following line to
It is often desirable to have multiple sources of sound that are able to play simultaneously. FreeBSD uses “Virtual Sound Channels” to multiplex the sound card's playback by mixing sound in the kernel.
Three sysctl(8) knobs are available for configuring virtual channels:
This example allocates four virtual channels, which is a
practical number for everyday use. Both
dev.pcm.0.rec.vchans=4 are configurable
after a device has been attached and represent the number of
pcm0 has for playback
and recording. Since the
pcm module can
be loaded independently of the hardware drivers,
hw.snd.maxautovchans indicates how many
virtual channels will be given to an audio device when it is
attached. Refer to pcm(4) for more information.
The number of virtual channels for a device cannot be changed while it is in use. First, close any programs using the device, such as music players or sound daemons.
pcm device will
automatically be allocated transparently to a program that
The default values for the different mixer channels are
hardcoded in the source code of the pcm(4) driver. While
sound card mixer levels can be changed using mixer(8) or
third-party applications and daemons, this is not a permanent
solution. To instead set default mixer values at the driver
level, define the appropriate values in
/boot/device.hints, as seen in this
This will set the volume channel to a default value of
50 when the pcm(4) module is