Sophie

Sophie

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

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>Constructor</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Writing an ALSA Driver" /><link rel="up" href="ch06.html" title="Chapter&#160;6.&#160;Control Interface" /><link rel="prev" href="ch06s05.html" title="Callbacks" /><link rel="next" href="ch06s07.html" title="Change Notification" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Constructor</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06s05.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;6.&#160;Control Interface</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch06s07.html">Next</a></td></tr></table><hr /></div><div class="section" title="Constructor"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="control-interface-constructor"></a>Constructor</h2></div></div></div><p>
        When everything is ready, finally we can create a new
      control. To create a control, there are two functions to be
      called, <code class="function">snd_ctl_new1()</code> and
      <code class="function">snd_ctl_add()</code>. 
      </p><p>
        In the simplest way, you can do like this:

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

  err = snd_ctl_add(card, snd_ctl_new1(&amp;my_control, chip));
  if (err &lt; 0)
          return err;

          </pre></div><p>

        where <em class="parameter"><code>my_control</code></em> is the
      struct <span class="structname">snd_kcontrol_new</span> object defined above, and chip
      is the object pointer to be passed to
      kcontrol-&gt;private_data 
      which can be referred to in callbacks. 
      </p><p>
        <code class="function">snd_ctl_new1()</code> allocates a new
      <span class="structname">snd_kcontrol</span> instance (that's why the definition
      of <em class="parameter"><code>my_control</code></em> can be with
      the <em class="parameter"><code>__devinitdata</code></em> 
      prefix), and <code class="function">snd_ctl_add</code> assigns the given
      control component to the card. 
      </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06s05.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch06s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Callbacks&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Change Notification</td></tr></table></div></body></html>