Sophie

Sophie

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

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="ch07.html" title="Chapter&#160;7.&#160;API for AC97 Codec" /><link rel="prev" href="ch07s02.html" title="Full Code Example" /><link rel="next" href="ch07s04.html" title="Callbacks" /></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="ch07s02.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;7.&#160;API for AC97 Codec</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch07s04.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="api-ac97-constructor"></a>Constructor</h2></div></div></div><p>
        To create an ac97 instance, first call <code class="function">snd_ac97_bus</code>
      with an <span class="type">ac97_bus_ops_t</span> record with callback functions.

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

  struct snd_ac97_bus *bus;
  static struct snd_ac97_bus_ops ops = {
        .write = snd_mychip_ac97_write,
        .read = snd_mychip_ac97_read,
  };

  snd_ac97_bus(card, 0, &amp;ops, NULL, &amp;pbus);

          </pre></div><p>

      The bus record is shared among all belonging ac97 instances.
      </p><p>
      And then call <code class="function">snd_ac97_mixer()</code> with an
      struct <span class="structname">snd_ac97_template</span>
      record together with the bus pointer created above.

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

  struct snd_ac97_template ac97;
  int err;

  memset(&amp;ac97, 0, sizeof(ac97));
  ac97.private_data = chip;
  snd_ac97_mixer(bus, &amp;ac97, &amp;chip-&gt;ac97);

          </pre></div><p>

        where chip-&gt;ac97 is a pointer to a newly created
        <span class="type">ac97_t</span> instance.
        In this case, the chip pointer is set as the private data, so that
        the read/write callback functions can refer to this chip instance.
        This instance is not necessarily stored in the chip
	record.  If you need to change the register values from the
        driver, or need the suspend/resume of ac97 codecs, keep this
        pointer to pass to the corresponding functions.
      </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07s02.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch07.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch07s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Full Code Example&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Callbacks</td></tr></table></div></body></html>