Chapter 5. PCM Interface

Table of Contents

General
Full Code Example
Constructor
... And the Destructor?
Runtime Pointer - The Chest of PCM Information
Hardware Description
PCM Configurations
DMA Buffer Information
Running Status
Private Data
Interrupt Callbacks
Operators
open callback
close callback
ioctl callback
hw_params callback
hw_free callback
prepare callback
trigger callback
pointer callback
copy and silence callbacks
ack callback
page callback
Interrupt Handler
Interrupts at the period (fragment) boundary
High frequency timer interrupts
On calling snd_pcm_period_elapsed()
Atomicity
Constraints

General

The PCM middle layer of ALSA is quite powerful and it is only necessary for each driver to implement the low-level functions to access its hardware.

For accessing to the PCM layer, you need to include <sound/pcm.h> first. In addition, <sound/pcm_params.h> might be needed if you access to some functions related with hw_param.

Each card device can have up to four pcm instances. A pcm instance corresponds to a pcm device file. The limitation of number of instances comes only from the available bit size of the Linux's device numbers. Once when 64bit device number is used, we'll have more pcm instances available.

A pcm instance consists of pcm playback and capture streams, and each pcm stream consists of one or more pcm substreams. Some soundcards support multiple playback functions. For example, emu10k1 has a PCM playback of 32 stereo substreams. In this case, at each open, a free substream is (usually) automatically chosen and opened. Meanwhile, when only one substream exists and it was already opened, the successful open will either block or error with EAGAIN according to the file open mode. But you don't have to care about such details in your driver. The PCM middle layer will take care of such work.