Configuring Linux to support sound
Installation
Configuring Linux to support sound involves the following steps:
- Installing the sound card
- Configuring Plug and Play (if applicable)
- Configuring and building the kernel for sound support
- Creating the device files
- Booting the Linux kernel and testing the installation
If you are running Red Hat Linux there is a utility called sndconfig that in most cases will detect your sound card and set up all of the necessary configuration files to load the appropriate sound drivers for your card. If you are running Red Hat I suggest you try using it. If it works for you then you can skip the rest of the instructions in this section.
If sndconfig fails, you are using another Linux distribution, or you want to follow the manual method in order to better understand what you are doing, then the next sections will cover each of these steps in detail.
Installing the Sound Card
Installing the Sound Card
Follow the manufacturer's instructions for installing the hardware or have your dealer perform the installation.
Older sound cards usually have switch or jumper settings for IRQ, DMA channel, etc; note down the values used. 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.
Usually you should use the same I/O port, IRQ, and DMA settings that work under DOS. In some cases though (particularly with PnP cards) you may need to use different settings to get things to work under Linux. Some experimentation may be needed.
Configuring Plug and Play
Configuring Plug and Play
Most sound cards now use the Plug and Play protocol to configure settings for i/o addresses, interrupts, and DMA channels. If you have one of the older sound cards that uses fixed settings or jumpers, then you can skip this section.
As of version 2.2 Linux does not yet have full Plug and Play support in the kernel. The preferred solution is to use the isapnp tools which ship with most Linux distributions (or you can download them from Red Hat's web site http://www.redhat.com.
First check the documentation for your Linux distribution. It may already have Plug and Play support set up for you or it may work slightly differently than described here. If you need to configure it yourself,the details can be found in the man pages for the isapnp tools. Briefly the process you would normally follow is:
- Use pnpdump to capture the possible settings for all your Plug and Play devices, saving the result to the file /etc/isapnp.conf.
- Choose settings for the sound card that do not conflict with any other devices in your system and uncomment the appropriate lines in /etc/isapnp.conf. Don't forget to uncomment the (ACT Y) command near the end.
- Make sure that isapnp is run when your system boots up, normally done by one of the startup scripts. Reboot your system or run isapnp manually.
If for some reason you cannot or do not wish to use the isapnp tools, there are a couple of other options. If you use the card under Microsoft Windows 95 or 98, you can use the device manager to set up the card, then soft boot into Linux using the LOADLIN program. Make sure Windows and Linux use the same card setup parameters.
If you use the card under DOS, you can use the icu utility that comes with SoundBlaster16 PnP cards to configure it under DOS, then soft boot into Linux using the LOADLIN program. Again, make sure DOS and Linux use the same card setup parameters.
A few of the sound card drivers include the necessary software to initialize Plug and Play for the card. Check the documentation for that card's driver for details.
Creating the Device Files
Creating the Device Files
For proper operation, device file entries must be created for the sound devices. These are normally created for you during installation of your Linux system. A quick check can be made using the command listed below. If the output is as shown (the date stamp will vary) then the device files are almost certainly okay.
Quote:
% ls -l /dev/sndstat
crw-rw-rw- 1 root root 14, 6 Apr 25 1995 /dev/sndstat
Note that having the right device files there doesn't guarantee anything on its own. The kernel driver must also be loaded or compiled in before the devices will work (more on that later).
In rare cases, if you believe the device files are wrong, you can recreate them. Most Linux distributions have a /dev/MAKEDEV script which can be used for this purpose.
Booting Linux and Testing the Installation
Booting Linux and Testing the Installation
You should now be ready to boot the new kernel and test the sound drivers. Follow your usual procedure for installing and rebooting the new kernel (keep the old kernel around in case of problems, of course).
During booting, 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):
Quote:
Sound initialization started
<Sound Blaster 16 (4.13)> at 0x220 irq 5 dma 1,5
<Sound Blaster 16> at 0x330 irq 5 dma 0
<Yamaha OPL3 FM> at 0x388
Sound initialization complete
This should match your sound card type and jumper settings (if any).
Note that the above messages are not displayed when using loadable sound driver module (unless you enable it, e.g. using insmod sound trace_init=1).
When the sound driver is linked into the kernel, the Sound initialization started and Sound initialization complete messages should be displayed. If they are not printed, it means that there is no sound driver present in the kernel. In this case you should check that you actually installed the kernel you compiled when enabling the sound driver.
If nothing is printed between the Sound initialization started and the Sound initialization complete lines, it means that no sound devices were detected. Most probably it means that you don't have the correct driver enabled, the card is not supported, the I/O port is bad or that you have a PnP card that has not been configured.
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.
Next you should 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:
Quote:
% cat /dev/sndstat
Sound Driver:3.5.4-960630 (Sat Jan 4 23:56:57 EST 1997 root,
Linux fizzbin 2.0.27 #48 Thu Dec 5 18:24:45 EST 1996 i586)
Kernel: Linux fizzbin 2.0.27 #48 Thu Dec 5 18:24:45 EST 1996 i586
Config options: 0
Installed drivers:
Type 1: OPL-2/OPL-3 FM
Type 2: Sound Blaster
Type 7: SB MPU-401
Card config:
Sound Blaster at 0x220 irq 5 drq 1,5
SB MPU-401 at 0x330 irq 5 drq 0
OPL-2/OPL-3 FM at 0x388 drq 0
Audio devices:
0: Sound Blaster 16 (4.13)
Synth devices:
0: Yamaha OPL-3
Midi devices:
0: Sound Blaster 16
Timers:
0: System clock
Mixers:
0: Sound Blaster
The command above can report some error messages. "No such file or directory" indicates that you need to create the device files (see section 4.3). "No such device" means that sound driver is not loaded or linked into kernel. Go back to section 4.2 to correct this.
If lines in the "Card config:" section of /dev/sndstat are listed inside parentheses (such as "(SoundBlaster at 0x220 irq 5 drq 1,5)"), it means that this device was configured but not detected.
Now you should be ready to play a simple sound file. Get hold of a sound sample file, and send it to the sound device as a basic check of sound output, e.g.
Quote:
% cat endoftheworld >/dev/dsp
% cat crash.au >/dev/audio
(Make sure you don't omit the ">" in the commands above).
Note that, in general, using cat is not the proper way to play audio files, it's just a quick check. You'll want to get a proper sound player program (described later) that will do a better job.
This command will work only if there is at least one device listed in the audio devices section of /dev/sndstat. If the audio devices section is empty you should check why the device was not detected.
If the above commands return "I/O error", you should look at the end of the kernel messages listed using the "dmesg" command. It's likely that an error message is printed there. Very often the message is "Sound: DMA (output) timed out - IRQ/DRQ config error?". The above message means that the driver didn't get the expected interrupt from the sound card. In most cases it means that the IRQ or the DMA channel configured to the driver doesn't work. The best way to get it working is to try with all possible DMAs and IRQs supported by the device.
Another possible reason is that the device is not compatible with the device the driver is configured for. This is almost certainly the case when a supposedly "SoundBlaster (Pro/16) compatible" sound card doesn't work with the SoundBlaster driver. In this case you should try to find out the device your sound card is compatible with (by posting to the comp.os.linux.hardware newsgroup, for example).
Some sample sound files can be obtained from ftp://tsx-11.mit.edu/pub/linux/packa...data-0.1.tar.Z
Now you can verify sound recording. If you have sound input capability, you can do a quick test of this using commands such as the following:
Quote:
# record 4 seconds of audio from microphone
EDT% dd bs=8k count=4 </dev/audio >sample.au
4+0 records in
4+0 records out
# play back sound
% cat sample.au >/dev/audio
Obviously for this to work you need a microphone connected to the sound card and you should speak into it. You may also need to obtain a mixer program to set the microphone as the input device and adjust the recording gain level.
If these tests pass, you can be reasonably confident that the sound D/A and A/D hardware and software are working.