1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;5.&#160;PCM Interface</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Writing an ALSA Driver"><link rel="up" href="index.html" title="Writing an ALSA Driver"><link rel="prev" href="pci-resource-entries.html" title="PCI Entries"><link rel="next" href="pcm-interface-example.html" title="Full Code Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;5.&#160;PCM Interface</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pci-resource-entries.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="pcm-interface-example.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="pcm-interface"></a>Chapter&#160;5.&#160;PCM Interface</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="pcm-interface.html#pcm-interface-general">General</a></span></dt><dt><span class="section"><a href="pcm-interface-example.html">Full Code Example</a></span></dt><dt><span class="section"><a href="pcm-interface-constructor.html">Constructor</a></span></dt><dt><span class="section"><a href="pcm-interface-destructor.html">... And the Destructor?</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html">Runtime Pointer - The Chest of PCM Information</a></span></dt><dd><dl><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-hw">Hardware Description</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-config">PCM Configurations</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-dma">DMA Buffer Information</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-status">Running Status</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-private">Private Data</a></span></dt><dt><span class="section"><a href="pcm-interface-runtime.html#pcm-interface-runtime-intr">Interrupt Callbacks</a></span></dt></dl></dd><dt><span class="section"><a href="pcm-interface-operators.html">Operators</a></span></dt><dd><dl><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-open-callback">open callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-close-callback">close callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-ioctl-callback">ioctl callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-hw-params-callback">hw_params callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-hw-free-callback">hw_free callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-prepare-callback">prepare callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-trigger-callback">trigger callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-pointer-callback">pointer callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-copy-silence">copy and silence callbacks</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-ack">ack callback</a></span></dt><dt><span class="section"><a href="pcm-interface-operators.html#pcm-interface-operators-page-callback">page callback</a></span></dt></dl></dd><dt><span class="section"><a href="pcm-interface-interrupt-handler.html">Interrupt Handler</a></span></dt><dd><dl><dt><span class="section"><a href="pcm-interface-interrupt-handler.html#pcm-interface-interrupt-handler-boundary">Interrupts at the period (fragment) boundary</a></span></dt><dt><span class="section"><a href="pcm-interface-interrupt-handler.html#pcm-interface-interrupt-handler-timer">High frequency timer interrupts</a></span></dt><dt><span class="section"><a href="pcm-interface-interrupt-handler.html#pcm-interface-interrupt-handler-both">On calling <code class="function">snd_pcm_period_elapsed()</code></a></span></dt></dl></dd><dt><span class="section"><a href="pcm-interface-atomicity.html">Atomicity</a></span></dt><dt><span class="section"><a href="pcm-interface-constraints.html">Constraints</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="pcm-interface-general"></a>General</h2></div></div></div><p>
2        The PCM middle layer of ALSA is quite powerful and it is only
3      necessary for each driver to implement the low-level functions
4      to access its hardware.
5      </p><p>
6        For accessing to the PCM layer, you need to include
7      <code class="filename">&lt;sound/pcm.h&gt;</code> first. In addition,
8      <code class="filename">&lt;sound/pcm_params.h&gt;</code> might be needed
9      if you access to some functions related with hw_param. 
10      </p><p>
11        Each card device can have up to four pcm instances. A pcm
12      instance corresponds to a pcm device file. The limitation of
13      number of instances comes only from the available bit size of
14      the Linux's device numbers. Once when 64bit device number is
15      used, we'll have more pcm instances available. 
16      </p><p>
17        A pcm instance consists of pcm playback and capture streams,
18      and each pcm stream consists of one or more pcm substreams. Some
19      soundcards support multiple playback functions. For example,
20      emu10k1 has a PCM playback of 32 stereo substreams. In this case, at
21      each open, a free substream is (usually) automatically chosen
22      and opened. Meanwhile, when only one substream exists and it was
23      already opened, the successful open will either block
24      or error with <code class="constant">EAGAIN</code> according to the
25      file open mode. But you don't have to care about such details in your
26      driver. The PCM middle layer will take care of such work.
27      </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pci-resource-entries.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="pcm-interface-example.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PCI Entries&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Full Code Example</td></tr></table></div></body></html>
28