Sophie

Sophie

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

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>Updating Registers in The Driver</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="ch07s04.html" title="Callbacks" /><link rel="next" href="ch07s06.html" title="Clock Adjustment" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Updating Registers in The Driver</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch07s04.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="ch07s06.html">Next</a></td></tr></table><hr /></div><div class="section" title="Updating Registers in The Driver"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="api-ac97-updating-registers"></a>Updating Registers in The Driver</h2></div></div></div><p>
        If you need to access to the codec from the driver, you can
      call the following functions:
      <code class="function">snd_ac97_write()</code>,
      <code class="function">snd_ac97_read()</code>,
      <code class="function">snd_ac97_update()</code> and
      <code class="function">snd_ac97_update_bits()</code>. 
      </p><p>
        Both <code class="function">snd_ac97_write()</code> and
        <code class="function">snd_ac97_update()</code> functions are used to
        set a value to the given register
        (<code class="constant">AC97_XXX</code>). The difference between them is
        that <code class="function">snd_ac97_update()</code> doesn't write a
        value if the given value has been already set, while
        <code class="function">snd_ac97_write()</code> always rewrites the
        value. 

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

  snd_ac97_write(ac97, AC97_MASTER, 0x8080);
  snd_ac97_update(ac97, AC97_MASTER, 0x8080);

          </pre></div><p>
      </p><p>
        <code class="function">snd_ac97_read()</code> is used to read the value
        of the given register. For example, 

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

  value = snd_ac97_read(ac97, AC97_MASTER);

          </pre></div><p>
      </p><p>
        <code class="function">snd_ac97_update_bits()</code> is used to update
        some bits in the given register.  

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

  snd_ac97_update_bits(ac97, reg, mask, value);

          </pre></div><p>
      </p><p>
        Also, there is a function to change the sample rate (of a
        given register such as
        <code class="constant">AC97_PCM_FRONT_DAC_RATE</code>) when VRA or
        DRA is supported by the codec:
        <code class="function">snd_ac97_set_rate()</code>. 

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

  snd_ac97_set_rate(ac97, AC97_PCM_FRONT_DAC_RATE, 44100);

          </pre></div><p>
      </p><p>
        The following registers are available to set the rate:
      <code class="constant">AC97_PCM_MIC_ADC_RATE</code>,
      <code class="constant">AC97_PCM_FRONT_DAC_RATE</code>,
      <code class="constant">AC97_PCM_LR_ADC_RATE</code>,
      <code class="constant">AC97_SPDIF</code>. When
      <code class="constant">AC97_SPDIF</code> is specified, the register is
      not really changed but the corresponding IEC958 status bits will
      be updated. 
      </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07s04.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="ch07s06.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;Clock Adjustment</td></tr></table></div></body></html>