Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 1a595394b241504ff370a8d12ebfcea7 > files > 5291

kernel-doc-3.11.10-100.fc18.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>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="card-management.html" title="Chapter&#160;3.&#160;Management of Cards and Components" /><link rel="prev" href="card-management.html" title="Chapter&#160;3.&#160;Management of Cards and Components" /><link rel="next" href="card-management-chip-specific.html" title="Chip-Specific Data" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Components</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="card-management.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Management of Cards and Components</th><td width="20%" align="right">&#160;<a accesskey="n" href="card-management-chip-specific.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="card-management-component"></a>Components</h2></div></div></div><p>
        After the card is created, you can attach the components
      (devices) to the card instance. In an ALSA driver, a component is
      represented as a struct <span class="structname">snd_device</span> object.
      A component can be a PCM instance, a control interface, a raw
      MIDI interface, etc.  Each such instance has one component
      entry.
      </p><p>
        A component can be created via
        <code class="function">snd_device_new()</code> function. 

        </p><div class="informalexample"><pre class="programlisting">

  snd_device_new(card, SNDRV_DEV_XXX, chip, &amp;ops);

          </pre></div><p>
      </p><p>
        This takes the card pointer, the device-level
      (<code class="constant">SNDRV_DEV_XXX</code>), the data pointer, and the
      callback pointers (<em class="parameter"><code>&amp;ops</code></em>). The
      device-level defines the type of components and the order of
      registration and de-registration.  For most components, the
      device-level is already defined.  For a user-defined component,
      you can use <code class="constant">SNDRV_DEV_LOWLEVEL</code>.
      </p><p>
      This function itself doesn't allocate the data space. The data
      must be allocated manually beforehand, and its pointer is passed
      as the argument. This pointer (<em class="parameter"><code>chip</code></em> in the
      above example) is used as the identifier for the instance.
      </p><p>
        Each pre-defined ALSA component such as ac97 and pcm calls
      <code class="function">snd_device_new()</code> inside its
      constructor. The destructor for each component is defined in the
      callback pointers.  Hence, you don't need to take care of
      calling a destructor for such a component.
      </p><p>
        If you wish to create your own component, you need to
      set the destructor function to the dev_free callback in
      the <em class="parameter"><code>ops</code></em>, so that it can be released
      automatically via <code class="function">snd_card_free()</code>.
      The next example will show an implementation of chip-specific
      data.
      </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="card-management.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="card-management.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="card-management-chip-specific.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;3.&#160;Management of Cards and Components&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chip-Specific Data</td></tr></table></div></body></html>