1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;3.&#160;Management of Cards and Components</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="basic-flow-header-files.html" title="Header Files"><link rel="next" href="card-management-component.html" title="Components"></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;3.&#160;Management of Cards and Components</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="basic-flow-header-files.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="card-management-component.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="card-management"></a>Chapter&#160;3.&#160;Management of Cards and Components</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="card-management.html#card-management-card-instance">Card Instance</a></span></dt><dt><span class="section"><a href="card-management-component.html">Components</a></span></dt><dt><span class="section"><a href="card-management-chip-specific.html">Chip-Specific Data</a></span></dt><dd><dl><dt><span class="section"><a href="card-management-chip-specific.html#card-management-chip-specific-snd-card-new">1. Allocating via <code class="function">snd_card_new()</code>.</a></span></dt><dt><span class="section"><a href="card-management-chip-specific.html#card-management-chip-specific-allocate-extra">2. Allocating an extra device.</a></span></dt></dl></dd><dt><span class="section"><a href="card-management-registration.html">Registration and Release</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="card-management-card-instance"></a>Card Instance</h2></div></div></div><p>
2      For each soundcard, a <span class="quote">&#8220;<span class="quote">card</span>&#8221;</span> record must be allocated.
3      </p><p>
4      A card record is the headquarters of the soundcard.  It manages
5      the whole list of devices (components) on the soundcard, such as
6      PCM, mixers, MIDI, synthesizer, and so on.  Also, the card
7      record holds the ID and the name strings of the card, manages
8      the root of proc files, and controls the power-management states
9      and hotplug disconnections.  The component list on the card
10      record is used to manage the correct release of resources at
11      destruction. 
12      </p><p>
13        As mentioned above, to create a card instance, call
14      <code class="function">snd_card_new()</code>.
15
16        </p><div class="informalexample"><pre class="programlisting">
17
18  struct snd_card *card;
19  int err;
20  err = snd_card_new(&amp;pci-&gt;dev, index, id, module, extra_size, &amp;card);
21
22          </pre></div><p>
23      </p><p>
24        The function takes six arguments: the parent device pointer,
25        the card-index number, the id string, the module pointer (usually
26        <code class="constant">THIS_MODULE</code>),
27        the size of extra-data space, and the pointer to return the
28        card instance.  The extra_size argument is used to
29        allocate card-&gt;private_data for the
30        chip-specific data.  Note that these data
31        are allocated by <code class="function">snd_card_new()</code>.
32      </p><p>
33	The first argument, the pointer of struct
34	<span class="structname">device</span>, specifies the parent device.
35	For PCI devices, typically &amp;pci-&gt; is passed there.
36      </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="basic-flow-header-files.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="card-management-component.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Header Files&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Components</td></tr></table></div></body></html>
37