Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 4162

kernel-doc-2.6.32-131.17.1.el6.centos.plus.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>Full Code Example</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="ch07.html" title="Chapter&#160;7.&#160;API for AC97 Codec" /><link rel="next" href="ch07s03.html" title="Constructor" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Full Code Example</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch07.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="ch07s03.html">Next</a></td></tr></table><hr /></div><div class="section" title="Full Code Example"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="api-ac97-example"></a>Full Code Example</h2></div></div></div><p>
          </p><div class="example"><a id="id2739496"></a><p class="title"><b>Example&#160;7.1.&#160;Example of AC97 Interface</b></p><div class="example-contents"><pre class="programlisting">

  struct mychip {
          ....
          struct snd_ac97 *ac97;
          ....
  };

  static unsigned short snd_mychip_ac97_read(struct snd_ac97 *ac97,
                                             unsigned short reg)
  {
          struct mychip *chip = ac97-&gt;private_data;
          ....
          /* read a register value here from the codec */
          return the_register_value;
  }

  static void snd_mychip_ac97_write(struct snd_ac97 *ac97,
                                   unsigned short reg, unsigned short val)
  {
          struct mychip *chip = ac97-&gt;private_data;
          ....
          /* write the given register value to the codec */
  }

  static int snd_mychip_ac97(struct mychip *chip)
  {
          struct snd_ac97_bus *bus;
          struct snd_ac97_template ac97;
          int err;
          static struct snd_ac97_bus_ops ops = {
                  .write = snd_mychip_ac97_write,
                  .read = snd_mychip_ac97_read,
          };

          err = snd_ac97_bus(chip-&gt;card, 0, &amp;ops, NULL, &amp;bus);
          if (err &lt; 0)
                  return err;
          memset(&amp;ac97, 0, sizeof(ac97));
          ac97.private_data = chip;
          return snd_ac97_mixer(bus, &amp;ac97, &amp;chip-&gt;ac97);
  }


          </pre></div></div><p><br class="example-break" />
      </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07.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="ch07s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;7.&#160;API for AC97 Codec&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Constructor</td></tr></table></div></body></html>