Chapter 8, The CD-ROM Driver, covered the installation and testing of the sound driver for the built-in PC speaker. Currently this driver is distributed as a kernel patch. This driver doesn't require a sound card, only the standard PC speaker. It tries to be as compatible as possible with the real sound driver, supporting a subset of the kernel sound API. It also supports some homebrew sound hardware you can build yourself.
Not surprisingly it does not support emulation of an FM synthesizer or MIDI interface. It does support replacements for the /dev/audio and /dev/dsp devices, but for sound output only. There is also limited /dev/mixer support.
The driver uses unique device files and can co-exist with the real sound driver. Users that do not have a sound card typically create the standard sound device files as symbolic links to the PC speaker devices, so that sound applications will be able to open the expected devices. The driver includes a soundcard.h header file, which is necessary only if the user does not already have the standard sound header file installed. I'll briefly look at all of the supported devices.
This device emulates the /dev/dsp device, for output only. Attempts to read from it will always return the error EINVAL. It accepts all of the standard /dev/dsp ioctl calls (although some are simply ignored), including the mixer ioctl functions. Some additional ioctl calls exist for setting parameters specific to the PC speaker driver. You'll find it easier to use the pcsel program (included with the driver source distribution) to set these parameters.
This device simulates a 16-bit sound card. The driver is optional, selected when configuring the kernel driver. Internally the driver is 8-bit, but it is included for applications that insist on a 16-bit sound device (most notably, the game DOOM).
This device is the analog of /dev/audio, the mu-law device. It has the same limitations as /dev/pcsp.
This device accepts all of the kernel mixer ioctl calls. Only a master volume control is supported, and there are no recording source devices. There is support for stereo if a stereo DAC device is used.
You can run the mixer_info and dsp_info programs listed earlier to display the devices' capabilities.
The PC speaker driver is quite an accomplishment, considering the limitations of the hardware it has to work with. Many applications designed for the real sound card will work with the driver without changes. Results vary depending on the type of speaker installed and the speed of the system, but given a fast enough machine, you can even play MOD files.