16.2 Setting Up the Sound Card

Contributed by Moses Moore.

16.2.1 Locating the Correct Device

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

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) which can either be done from the command line:

# kldload snd_emu10k1.ko

or by adding the appropriate line to the file /boot/loader.conf like this:

snd_emu10k1_load="YES"

These examples are for a Creative SoundBlaster Live! sound card. Other available loadable sound modules are listed in /boot/defaults/loader.conf.

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.

16.2.1.1 Creative, Advance, and ESS Sound Cards

If you have one of the above cards, you will need to add:

device pcm

to your kernel configuration file. If you have a PnP ISA card, you will also need to add:

device sbc

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.

16.2.1.2 Gravis UltraSound Cards

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.

16.2.1.3 Crystal Sound Cards

For Crystal cards, you will need to add:

device pcm
device csa

to your kernel configuration file.

16.2.1.4 Generic Support

For PnP ISA or PCI cards, you will need to add:

device pcm

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.

16.2.1.5 Onboard Sound

Some systems with built-in motherboard sound devices may require the following device in your kernel configuration:

device pnpbios

16.2.2 Creating and Testing the Device Nodes

After you reboot, log in and check for the device in the /var/run/dmesg.boot file, as shown below:

# grep pcm /var/run/dmesg.boot
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 16.2.2.1.

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:

DeviceDescription
/dev/audioSparc® compatible audio device
/dev/dspDigitized voice device
/dev/dspWLike /dev/dsp, but 16 bits per sample
/dev/midiRaw midi access device
/dev/mixerControl port mixer device
/dev/musicLevel 2 sequencer interface
/dev/sequencerSequencer device
/dev/pssProgrammable 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

Various applications, such as audio/xmms offer a better interface. You may want to install an application such as audio/mpg123 to listen to MP3 audio files.

16.2.2.1 Common Problems

ErrorSolution
``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.

16.2.3 Utilizing Multiple Sound Sources

Contributed by Munish Chopra.

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.

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

As DragonFly doesn't support devfs 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.

Contact the Documentation mailing list for comments, suggestions and questions about this document.