Before you begin, you should know the model of the card you have, the chip it uses, and whether it is a PCI or ISA card. FreeBSD supports a wide variety of both PCI and ISA cards. If you do not see your card in the following list, check the pcm(4) manual page. This is not a complete list; however, it does list some of the most common cards.
Crystal 4237, 4236, 4232, 4231
Ensoniq AudioPCI 1370/1371
Sound Blaster Pro, 16, 32, AWE64, AWE128, Live
Advanced Asound 100, 110, and Logic ALS120
ES 1868, 1869, 1879, 1888
Aureal Vortex 1 or 2
To use your sound device, you will need to load the proper device driver. This may be accomplished in one of two ways. The easiest way is to simply load a kernel module for your sound card with kldload(8). Alternatively, you may statically compile in support for your sound card in your kernel. The sections below provide the information you need to add support for your hardware in this manner. For more information about recompiling your kernel, please see Chapter 9.
If you have one of the above cards, you will need to add:
to your kernel configuration file. If you have a PnP ISA card, you will also need to add:
For a non-PnP ISA card, add:
device pcm device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15
to your kernel configuration file. The settings shown above are the defaults. You may need to change the IRQ or the other settings to match your card. See the sbc(4) manual page for more information.
Note: The Sound Blaster Live is not supported under FreeBSD 4.0 without a patch, which this section will not cover. It is recommended that you update to the latest -STABLE before trying to use this card.
For a PnP ISA card, you will need to add:
device pcm device gusc
to your kernel configuration file. If you have a non-PnP ISA card, you will need to add:
device pcm device gus0 at isa? port 0x220 irq 5 drq 1 flags 0x13
to your kernel configuration file. You may need to change the IRQ or the other settings to match your card. See the gusc(4) manual page for more information.
For Crystal cards, you will need to add:
device pcm device csa
to your kernel configuration file.
For PnP ISA or PCI cards, you will need to add:
to your kernel configuration file. If you have a non-PnP ISA sound card that does not have a bridge driver, you will need to add:
device pcm0 at isa? irq 10 drq 1 flags 0x0
to your kernel configuration file. You may need to change the IRQ or the other settings to match your card.
Some systems with built-in motherboard sound devices may require the following option in your kernel configuration:
After you reboot, log in and run dmesg | grep pcm as shown below:
# dmesg | grep pcm pcm0: <SB16 DSP 4.11> on sbc0
The output from your system may look different. If no pcm devices show up, something went wrong earlier. If that happens, go through your kernel configuration file again and make sure you chose the correct device. Common problems are listed in Section 18.104.22.168.
Note: If you are running FreeBSD 5.0 or later, you can safely skip the rest of this section. These versions use devfs(5) to automatically create devices nodes.
If the previous command returned pcm0, you will have to run the following as root:
# cd /dev # sh MAKEDEV snd0
If the command returned pcm1, follow the same steps as shown above, replacing snd0 with snd1.
Note: The above commands will not create a /dev/snd device!
MAKEDEV will create a group of device nodes, including:
|/dev/audio||SPARC-compatible audio device|
|/dev/dsp||Digitized voice device|
|/dev/dspW||Like /dev/dsp, but 16 bits per sample|
|/dev/midi||Raw midi access device|
|/dev/mixer||Control port mixer device|
|/dev/music||Level 2 sequencer interface|
|/dev/pss||Programmable device interface|
If all goes well, you should now have a functioning sound card. If your CD-ROM or DVD-ROM drive is properly coupled to your sound card, you can put a CD in the drive and play it with cdcontrol(1):
% cdcontrol -f /dev/acd0c play 1
|``unsupported subdevice XX''||
One or more of the device nodes was not created correctly. Repeat the steps above.
|``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!''||
Check with fstat | grep dsp if another application is holding the device open. Noteworthy troublemakers are esound and KDE's sound support.
It is often desirable to have multiple sources of sound that are able to play simultaneously, such as when esound or artsd do not support sharing of the sound device with a certain application.
FreeBSD lets you do this through Virtual Sound Channels, which can be set with the sysctl(8) facility. Virtual channels allow you to multiplex your sound card's playback channels by mixing sound in the kernel.
To set the number of virtual channels, there are two sysctl knobs which, if you are the root user, can be set like this:
# sysctl hw.snd.pcm0.vchans=4 # sysctl hw.snd.maxautovchans=4
The above example allocates four virtual channels, which is a practical number for everyday use. hw.snd.pcm0.vchans is the number of virtual channels pcm0 has, and is configurable once a device has been attached. hw.snd.maxautovchans is the number of virtual channels a new audio device is given when it is attached using kldload(8). Since the pcm module can be loaded independently of the hardware drivers, hw.snd.maxautovchans can store how many virtual channels any devices which are attached later will be given.
If you are not using devfs(5), you will have to point your applications at /dev/dsp0.x, where x is 0 to 3 if hw.snd.pcm.0.vchans is set to 4 as in the above example. On a system using devfs(5), the above will automatically be allocated transparently to the user.
This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.
For questions about FreeBSD, read the
before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.