1<html><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.78.1"><link rel="home" href="index.html" title="Writing an ALSA Driver"><link rel="up" href="api-ac97.html" title="Chapter&#160;7.&#160;API for AC97 Codec"><link rel="prev" href="api-ac97-callbacks.html" title="Callbacks"><link rel="next" href="api-ac97-clock-adjustment.html" title="Clock Adjustment"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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="api-ac97-callbacks.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="api-ac97-clock-adjustment.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="api-ac97-updating-registers"></a>Updating Registers in The Driver</h2></div></div></div><p>
2        If you need to access to the codec from the driver, you can
3      call the following functions:
4      <code class="function">snd_ac97_write()</code>,
5      <code class="function">snd_ac97_read()</code>,
6      <code class="function">snd_ac97_update()</code> and
7      <code class="function">snd_ac97_update_bits()</code>. 
8      </p><p>
9        Both <code class="function">snd_ac97_write()</code> and
10        <code class="function">snd_ac97_update()</code> functions are used to
11        set a value to the given register
12        (<code class="constant">AC97_XXX</code>). The difference between them is
13        that <code class="function">snd_ac97_update()</code> doesn't write a
14        value if the given value has been already set, while
15        <code class="function">snd_ac97_write()</code> always rewrites the
16        value. 
17
18        </p><div class="informalexample"><pre class="programlisting">
19
20  snd_ac97_write(ac97, AC97_MASTER, 0x8080);
21  snd_ac97_update(ac97, AC97_MASTER, 0x8080);
22
23          </pre></div><p>
24      </p><p>
25        <code class="function">snd_ac97_read()</code> is used to read the value
26        of the given register. For example, 
27
28        </p><div class="informalexample"><pre class="programlisting">
29
30  value = snd_ac97_read(ac97, AC97_MASTER);
31
32          </pre></div><p>
33      </p><p>
34        <code class="function">snd_ac97_update_bits()</code> is used to update
35        some bits in the given register.  
36
37        </p><div class="informalexample"><pre class="programlisting">
38
39  snd_ac97_update_bits(ac97, reg, mask, value);
40
41          </pre></div><p>
42      </p><p>
43        Also, there is a function to change the sample rate (of a
44        given register such as
45        <code class="constant">AC97_PCM_FRONT_DAC_RATE</code>) when VRA or
46        DRA is supported by the codec:
47        <code class="function">snd_ac97_set_rate()</code>. 
48
49        </p><div class="informalexample"><pre class="programlisting">
50
51  snd_ac97_set_rate(ac97, AC97_PCM_FRONT_DAC_RATE, 44100);
52
53          </pre></div><p>
54      </p><p>
55        The following registers are available to set the rate:
56      <code class="constant">AC97_PCM_MIC_ADC_RATE</code>,
57      <code class="constant">AC97_PCM_FRONT_DAC_RATE</code>,
58      <code class="constant">AC97_PCM_LR_ADC_RATE</code>,
59      <code class="constant">AC97_SPDIF</code>. When
60      <code class="constant">AC97_SPDIF</code> is specified, the register is
61      not really changed but the corresponding IEC958 status bits will
62      be updated. 
63      </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="api-ac97-callbacks.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="api-ac97.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="api-ac97-clock-adjustment.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>
64