Configuring Linux for Sound Support

# 3 Configuring Linux for Sound Support

Contents of this section

Configuring Linux to support sound involves the following steps:

1. Installing the sound card.
2. Configuring and building the kernel for sound support.
3. Creating the device files.
4. Testing the installation.

## 3.1 Installing the Sound Card

To install the card, follow the instructions provided by the manufacturer. Be sure to note down the jumper settings for IRQ, DMA channel, etc. If you are unsure, use the factory defaults. Try to avoid conflicts with other devices (e.g. ethernet cards, SCSI host adaptors, serial and parallel ports) if possible.

## 3.2 Configuring the Kernel

If you are using a recent kernel (0.99pl14 or later), the sound drivers are included with the kernel release. Follow the usual procedure for building the kernel. When you run `make config`, a configuration program will ask you what sound card options you want. Carefully read the information displayed by this program.

If you are upgrading from an older sound driver, make sure that the files `/usr/include/sys/soundcard.h` and `/usr/include/sys/ultrasound.h` are symbolic links to the corresponding files in `/usr/include/linux`, or that they simply contain the lines `#include <linux/soundcard.h>` and `#include <linux/ultrasound.h>`, respectively.

It's good idea to read the `Readme` files in the kernel `drivers/sound` directory since there could be some last minute information. The file `CHANGELOG` contains a list of enhancements and new features since the previous version.

Particularly with the 2.90 sound driver, read this documentation to be aware of potential incompatibilities with the older versions of sound drivers.

## 3.3 Creating the Device Files

The first time the kernel sound driver is configured, you need to create the sound device files. The easiest way to do this is to cut the short shell script from the end of the file `Readme.linux` (or possibly `Readme`) in the directory `/usr/src/linux/drivers/sound`, and run it as root.

If your device entries already exist, you might want to ensure they are correct, e.g. `/dev/audio` should have major and minor device numbers 14 and 4. If they are not, or if you are in doubt, run the above script and it will replace any existing entries with correct ones.

Some older Linux distributions provided install scripts which created incorrect sound device files. You may also have a `/dev/MAKEDEV` script for creating device files. Using the script included with the kernel sound driver is preferred since it should always be up to date with the latest supported sound devices.

## 3.4 Testing the Installation

You can now follow these steps to verify the sound hardware and software:

1. Reboot with the new kernel.

Follow your usual procedure for installing and rebooting the new kernel (keep the old kernel around in case of problems, of course).

2. Verify that the sound card is recognized during kernel initialization.

Check for a message such as the following on powerup (if they scroll by too quickly to read, you may be able to retrieve them with the "dmesg" command):

> `

>     snd2 <SoundBlaster Pro 3.2> at 0x220 irq 5 drq 1
>     snd1 <Yamaha OPL-3 FM> at 0x388 irq 0 drq 0

> `

This should match your sound card type and jumper settings.

The driver may also display some error messages and warnings during boot. Watch for these when booting the first time after configuring the sound driver.

If no sound card is detected when booting, here are some possible reasons:

- the configuration of the driver is incorrect and the driver was not able to detect your card in the given I/O address, or
- the sound driver was configured to be inactive or you booted with an old kernel (a common error).

3. Check the device file `/dev/sndstat`.

Reading the sound driver status device file should provide additional information on whether the sound card driver initialized properly. Sample output should look something like this:

> `

>     % cat /dev/sndstat

>     Sound Driver:2.90-2 (Fri Aug 26 20:08:45 EDT 1994 root@fizzbin.ca)
>     Config options: 31402

>     Installed drivers:
>     Type 1: OPL-2/OPL-3 FM
>     Type 2: SoundBlaster

>     Card config:
>     SoundBlaster at 0x220 irq 5 drq 1
>     OPL-2/OPL-3 FM at 0x388 irq 0 drq 0

>     PCM devices:
>     0: SoundBlaster Pro 3.2

>     Synth devices:
>     0: Yamaha OPL-3

>     Midi devices:

>     MIDI Timers:
>     0: System Timer

>     1 mixer(s) installed

> `

If the cat command displays "No such device", the sound driver is not active in the kernel. Make sure that you booted with the newly compiled kernel.

If the printout contains no devices (PCM, Synth or MIDI), your soundcard was not detected. Verify that the "HW config" section contains correct information.

4. Play a simple sound file.

Get hold of a sample sound file, and send it to the sound device as a basic check of sound output, e.g.

> `

>     % cat endoftheworld >/dev/dsp
>     % cat crash.au >/dev/audio

> `

Some sample sound files can be obtained from the file `snd-data-0.1.tar.Z`.

5. Verify sound recording.

If you have sound input capability, you can do a quick test of this using commands such as the following:

> `

>     # record 4 seconds of audio from microphone
>     % dd bs=8k count=4 </dev/audio >sample.au
>     # play back sound
>     % cat sample.au >/dev/audio

> `

If these tests pass, you can be reasonably confident that the sound hardware and software are working. If you experience problems, read the FAQ section of this document.

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter