The Linux sound driver tries to present an idealized sound card interface to the application programmer. It takes care of the hardware differences between cards although you do sometimes have to worry about whether a specific function is supported or not (e.g., whether a MIDI interface exists).
Figure 14-1 shows a block diagram of the idealized model of a sound card that the Linux sound driver provides. The diagram is somewhat simplified, and not all sound cards support all of the devices shown.
The various hardware blocks (D/A converter, synthesizer, etc.) are controlled by the CPU via the ISA[1] bus. The ISA bus consists of data, address, and control signals that connect to the sound card via the slot in which the sound card is inserted. The bus allows the CPU to control the devices on the sound card, but it has no support for analog inputs or outputs; these are typically supported by connectors on the rear panel of the card.
[1] Sound cards could use buses other than ISA, such as EISA and PCI, but these are not in common use.
There are several analog inputs on the left-hand side--microphone, CD audio, and line level input are the most common. On the right side are the analog outputs--usually speaker and line level as a minimum. An output mixer combines the various signal sources and sends them to the output devices. The signal sources may include input devices, to support playing the input signals through the speakers (a common example is playing audio CDs through the sound card using a CD-ROM drive).
Similarly, an input mixer accepts several analog signals, combines them, and feeds the output to an analog to digital converter to be digitized. Many sound cards also provide CD-ROM, MIDI, and joystick interfaces.
Applications that access the sound devices should include the sound header file linux/soundcard.h. Some additional functions specific to the Gravis UltraSound card are defined in linux/ultrasound.h.
In the next sections I will step through each of the sound driver device files, exploring the application programming interface, and looking at some small code examples. I recommend trying the code out on your system and modifying it, to fully illustrate the concepts.
Programming /dev/sndstat
Example of Linux System Calls