Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 4169

kernel-doc-2.6.32-71.14.1.el6.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Writing an ALSA Driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="description" content="This document describes how to write an ALSA (Advanced Linux Sound Architecture) driver." /><link rel="home" href="index.html" title="Writing an ALSA Driver" /><link rel="next" href="pr01.html" title="Preface" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Writing an ALSA Driver</th></tr><tr><td width="20%" align="left">&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="pr01.html">Next</a></td></tr></table><hr /></div><div class="book" title="Writing an ALSA Driver"><div class="titlepage"><div><div><h1 class="title"><a id="Writing-an-ALSA-Driver"></a>Writing an ALSA Driver</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Takashi</span> <span class="surname">Iwai</span></h3><div class="affiliation"><div class="address"><p><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code class="email">&lt;<a class="email" href="mailto:tiwai@suse.de">tiwai@suse.de</a>&gt;</code><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p></div></div></div></div><div><div class="legalnotice" title="Legal Notice"><a id="id2901078"></a><p>
    Copyright (c) 2002-2005  Takashi Iwai <code class="email">&lt;<a class="email" href="mailto:tiwai@suse.de">tiwai@suse.de</a>&gt;</code>
    </p><p>
    This document is free; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version. 
    </p><p>
    This document is distributed in the hope that it will be useful,
    but <span class="emphasis"><em>WITHOUT ANY WARRANTY</em></span>; without even the
    implied warranty of <span class="emphasis"><em>MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE</em></span>. See the GNU General Public License
    for more details.
    </p><p>
    You should have received a copy of the GNU General Public
    License along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    MA 02111-1307 USA
    </p></div></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>
        This document describes how to write an ALSA (Advanced Linux
        Sound Architecture) driver.
      </p></div></div></div><hr /></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="preface"><a href="pr01.html">Preface</a></span></dt><dt><span class="chapter"><a href="ch01.html">1. File Tree Structure</a></span></dt><dd><dl><dt><span class="section"><a href="ch01.html#file-tree-general">General</a></span></dt><dt><span class="section"><a href="ch01s02.html">core directory</a></span></dt><dd><dl><dt><span class="section"><a href="ch01s02.html#file-tree-core-directory-oss">core/oss</a></span></dt><dt><span class="section"><a href="ch01s02.html#file-tree-core-directory-ioctl32">core/ioctl32</a></span></dt><dt><span class="section"><a href="ch01s02.html#file-tree-core-directory-seq">core/seq</a></span></dt><dt><span class="section"><a href="ch01s02.html#file-tree-core-directory-seq-oss">core/seq/oss</a></span></dt><dt><span class="section"><a href="ch01s02.html#file-tree-core-directory-deq-instr">core/seq/instr</a></span></dt></dl></dd><dt><span class="section"><a href="ch01s03.html">include directory</a></span></dt><dt><span class="section"><a href="ch01s04.html">drivers directory</a></span></dt><dd><dl><dt><span class="section"><a href="ch01s04.html#file-tree-drivers-directory-mpu401">drivers/mpu401</a></span></dt><dt><span class="section"><a href="ch01s04.html#file-tree-drivers-directory-opl3">drivers/opl3 and opl4</a></span></dt></dl></dd><dt><span class="section"><a href="ch01s05.html">i2c directory</a></span></dt><dd><dl><dt><span class="section"><a href="ch01s05.html#file-tree-i2c-directory-l3">i2c/l3</a></span></dt></dl></dd><dt><span class="section"><a href="ch01s06.html">synth directory</a></span></dt><dt><span class="section"><a href="ch01s07.html">pci directory</a></span></dt><dt><span class="section"><a href="ch01s08.html">isa directory</a></span></dt><dt><span class="section"><a href="ch01s09.html">arm, ppc, and sparc directories</a></span></dt><dt><span class="section"><a href="ch01s10.html">usb directory</a></span></dt><dt><span class="section"><a href="ch01s11.html">pcmcia directory</a></span></dt><dt><span class="section"><a href="ch01s12.html">oss directory</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch02.html">2. Basic Flow for PCI Drivers</a></span></dt><dd><dl><dt><span class="section"><a href="ch02.html#basic-flow-outline">Outline</a></span></dt><dt><span class="section"><a href="ch02s02.html">Full Code Example</a></span></dt><dt><span class="section"><a href="ch02s03.html">Constructor</a></span></dt><dd><dl><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-device-index">1) Check and increment the device index.</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-create-card">2) Create a card instance</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-create-main">3) Create a main component</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-main-component">4) Set the driver ID and name strings.</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-create-other">5) Create other components, such as mixer, MIDI, etc.</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-register-card">6) Register the card instance.</a></span></dt><dt><span class="section"><a href="ch02s03.html#basic-flow-constructor-set-pci">7) Set the PCI driver data and return zero.</a></span></dt></dl></dd><dt><span class="section"><a href="ch02s04.html">Destructor</a></span></dt><dt><span class="section"><a href="ch02s05.html">Header Files</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch03.html">3. Management of Cards and Components</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#card-management-card-instance">Card Instance</a></span></dt><dt><span class="section"><a href="ch03s02.html">Components</a></span></dt><dt><span class="section"><a href="ch03s03.html">Chip-Specific Data</a></span></dt><dd><dl><dt><span class="section"><a href="ch03s03.html#card-management-chip-specific-snd-card-new">1. Allocating via <code class="function">snd_card_create()</code>.</a></span></dt><dt><span class="section"><a href="ch03s03.html#card-management-chip-specific-allocate-extra">2. Allocating an extra device.</a></span></dt></dl></dd><dt><span class="section"><a href="ch03s04.html">Registration and Release</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch04.html">4. PCI Resource Management</a></span></dt><dd><dl><dt><span class="section"><a href="ch04.html#pci-resource-example">Full Code Example</a></span></dt><dt><span class="section"><a href="ch04s02.html">Some Hafta's</a></span></dt><dt><span class="section"><a href="ch04s03.html">Resource Allocation</a></span></dt><dt><span class="section"><a href="ch04s04.html">Registration of Device Struct</a></span></dt><dt><span class="section"><a href="ch04s05.html">PCI Entries</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch05.html">5. PCM Interface</a></span></dt><dd><dl><dt><span class="section"><a href="ch05.html#pcm-interface-general">General</a></span></dt><dt><span class="section"><a href="ch05s02.html">Full Code Example</a></span></dt><dt><span class="section"><a href="ch05s03.html">Constructor</a></span></dt><dt><span class="section"><a href="ch05s04.html">... And the Destructor?</a></span></dt><dt><span class="section"><a href="ch05s05.html">Runtime Pointer - The Chest of PCM Information</a></span></dt><dd><dl><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-hw">Hardware Description</a></span></dt><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-config">PCM Configurations</a></span></dt><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-dma">DMA Buffer Information</a></span></dt><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-status">Running Status</a></span></dt><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-private">Private Data</a></span></dt><dt><span class="section"><a href="ch05s05.html#pcm-interface-runtime-intr">Interrupt Callbacks</a></span></dt></dl></dd><dt><span class="section"><a href="ch05s06.html">Operators</a></span></dt><dd><dl><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-open-callback">open callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-close-callback">close callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-ioctl-callback">ioctl callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-hw-params-callback">hw_params callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-hw-free-callback">hw_free callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-prepare-callback">prepare callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-trigger-callback">trigger callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-pointer-callback">pointer callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-copy-silence">copy and silence callbacks</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-ack">ack callback</a></span></dt><dt><span class="section"><a href="ch05s06.html#pcm-interface-operators-page-callback">page callback</a></span></dt></dl></dd><dt><span class="section"><a href="ch05s07.html">Interrupt Handler</a></span></dt><dd><dl><dt><span class="section"><a href="ch05s07.html#pcm-interface-interrupt-handler-boundary">Interrupts at the period (fragment) boundary</a></span></dt><dt><span class="section"><a href="ch05s07.html#pcm-interface-interrupt-handler-timer">High frequency timer interrupts</a></span></dt><dt><span class="section"><a href="ch05s07.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="ch05s08.html">Atomicity</a></span></dt><dt><span class="section"><a href="ch05s09.html">Constraints</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch06.html">6. Control Interface</a></span></dt><dd><dl><dt><span class="section"><a href="ch06.html#control-interface-general">General</a></span></dt><dt><span class="section"><a href="ch06s02.html">Definition of Controls</a></span></dt><dt><span class="section"><a href="ch06s03.html">Control Names</a></span></dt><dd><dl><dt><span class="section"><a href="ch06s03.html#control-interface-control-names-global">Global capture and playback</a></span></dt><dt><span class="section"><a href="ch06s03.html#control-interface-control-names-tone">Tone-controls</a></span></dt><dt><span class="section"><a href="ch06s03.html#control-interface-control-names-3d">3D controls</a></span></dt><dt><span class="section"><a href="ch06s03.html#control-interface-control-names-mic">Mic boost</a></span></dt></dl></dd><dt><span class="section"><a href="ch06s04.html">Access Flags</a></span></dt><dt><span class="section"><a href="ch06s05.html">Callbacks</a></span></dt><dd><dl><dt><span class="section"><a href="ch06s05.html#control-interface-callbacks-info">info callback</a></span></dt><dt><span class="section"><a href="ch06s05.html#control-interface-callbacks-get">get callback</a></span></dt><dt><span class="section"><a href="ch06s05.html#control-interface-callbacks-put">put callback</a></span></dt><dt><span class="section"><a href="ch06s05.html#control-interface-callbacks-all">Callbacks are not atomic</a></span></dt></dl></dd><dt><span class="section"><a href="ch06s06.html">Constructor</a></span></dt><dt><span class="section"><a href="ch06s07.html">Change Notification</a></span></dt><dt><span class="section"><a href="ch06s08.html">Metadata</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch07.html">7. API for AC97 Codec</a></span></dt><dd><dl><dt><span class="section"><a href="ch07.html#id2949795">General</a></span></dt><dt><span class="section"><a href="ch07s02.html">Full Code Example</a></span></dt><dt><span class="section"><a href="ch07s03.html">Constructor</a></span></dt><dt><span class="section"><a href="ch07s04.html">Callbacks</a></span></dt><dt><span class="section"><a href="ch07s05.html">Updating Registers in The Driver</a></span></dt><dt><span class="section"><a href="ch07s06.html">Clock Adjustment</a></span></dt><dt><span class="section"><a href="ch07s07.html">Proc Files</a></span></dt><dt><span class="section"><a href="ch07s08.html">Multiple Codecs</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch08.html">8. MIDI (MPU401-UART) Interface</a></span></dt><dd><dl><dt><span class="section"><a href="ch08.html#midi-interface-general">General</a></span></dt><dt><span class="section"><a href="ch08s02.html">Constructor</a></span></dt><dt><span class="section"><a href="ch08s03.html">Interrupt Handler</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch09.html">9. RawMIDI Interface</a></span></dt><dd><dl><dt><span class="section"><a href="ch09.html#rawmidi-interface-overview">Overview</a></span></dt><dt><span class="section"><a href="ch09s02.html">Constructor</a></span></dt><dt><span class="section"><a href="ch09s03.html">Callbacks</a></span></dt><dd><dl><dt><span class="section"><a href="ch09s03.html#rawmidi-interface-op-open"><code class="function">open</code> callback</a></span></dt><dt><span class="section"><a href="ch09s03.html#rawmidi-interface-op-close"><code class="function">close</code> callback</a></span></dt><dt><span class="section"><a href="ch09s03.html#rawmidi-interface-op-trigger-out"><code class="function">trigger</code> callback for output
      substreams</a></span></dt><dt><span class="section"><a href="ch09s03.html#rawmidi-interface-op-trigger-in"><code class="function">trigger</code> callback for input
      substreams</a></span></dt><dt><span class="section"><a href="ch09s03.html#rawmidi-interface-op-drain"><code class="function">drain</code> callback</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="ch10.html">10. Miscellaneous Devices</a></span></dt><dd><dl><dt><span class="section"><a href="ch10.html#misc-devices-opl3">FM OPL3</a></span></dt><dt><span class="section"><a href="ch10s02.html">Hardware-Dependent Devices</a></span></dt><dt><span class="section"><a href="ch10s03.html">IEC958 (S/PDIF)</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch11.html">11. Buffer and Memory Management</a></span></dt><dd><dl><dt><span class="section"><a href="ch11.html#buffer-and-memory-buffer-types">Buffer Types</a></span></dt><dt><span class="section"><a href="ch11s02.html">External Hardware Buffers</a></span></dt><dt><span class="section"><a href="ch11s03.html">Non-Contiguous Buffers</a></span></dt><dt><span class="section"><a href="ch11s04.html">Vmalloc'ed Buffers</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch12.html">12. Proc Interface</a></span></dt><dt><span class="chapter"><a href="ch13.html">13. Power Management</a></span></dt><dt><span class="chapter"><a href="ch14.html">14. Module Parameters</a></span></dt><dt><span class="chapter"><a href="ch15.html">15. How To Put Your Driver Into ALSA Tree</a></span></dt><dd><dl><dt><span class="section"><a href="ch15.html#id2953184">General</a></span></dt><dt><span class="section"><a href="ch15s02.html">Driver with A Single Source File</a></span></dt><dt><span class="section"><a href="ch15s03.html">Drivers with Several Source Files</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch16.html">16. Useful Functions</a></span></dt><dd><dl><dt><span class="section"><a href="ch16.html#useful-functions-snd-printk"><code class="function">snd_printk()</code> and friends</a></span></dt><dt><span class="section"><a href="ch16s02.html"><code class="function">snd_BUG()</code></a></span></dt><dt><span class="section"><a href="ch16s03.html"><code class="function">snd_BUG_ON()</code></a></span></dt></dl></dd><dt><span class="chapter"><a href="ch17.html">17. Acknowledgments</a></span></dt></dl></div><div class="list-of-examples"><p><b>List of Examples</b></p><dl><dt>1.1. <a href="ch01.html#id2895790">ALSA File Tree Structure</a></dt><dt>2.1. <a href="ch02s02.html#id2896240">Basic Flow for PCI Drivers - Example</a></dt><dt>4.1. <a href="ch04.html#id2945204">PCI Resource Management Example</a></dt><dt>5.1. <a href="ch05s02.html#id2946143">PCM Example Code</a></dt><dt>5.2. <a href="ch05s04.html#id2946633">PCM Instance with a Destructor</a></dt><dt>5.3. <a href="ch05s07.html#id2948235">Interrupt Handler Case #1</a></dt><dt>5.4. <a href="ch05s07.html#id2948297">Interrupt Handler Case #2</a></dt><dt>5.5. <a href="ch05s09.html#id2948496">Example of Hardware Constraints</a></dt><dt>5.6. <a href="ch05s09.html#id2948548">Example of Hardware Constraints for Channels</a></dt><dt>5.7. <a href="ch05s09.html#id2948609">Example of Hardware Constraints for Channels</a></dt><dt>6.1. <a href="ch06s02.html#id2948748">Definition of a Control</a></dt><dt>6.2. <a href="ch06s05.html#id2949254">Example of info callback</a></dt><dt>6.3. <a href="ch06s05.html#id2949390">Example of get callback</a></dt><dt>6.4. <a href="ch06s05.html#id2949496">Example of put callback</a></dt><dt>7.1. <a href="ch07s02.html#id2949824">Example of AC97 Interface</a></dt><dt>15.1. <a href="ch15s03.html#id2953382">Sample Makefile for a driver xyz</a></dt></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left">&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="pr01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right" valign="top">&#160;Preface</td></tr></table></div></body></html>