1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Callbacks</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-constructor.html" title="Constructor"><link rel="next" href="api-ac97-updating-registers.html" title="Updating Registers in The Driver"></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">Callbacks</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="api-ac97-constructor.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-updating-registers.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-callbacks"></a>Callbacks</h2></div></div></div><p>
2        The standard callbacks are <em class="structfield"><code>read</code></em> and
3      <em class="structfield"><code>write</code></em>. Obviously they 
4      correspond to the functions for read and write accesses to the
5      hardware low-level codes. 
6      </p><p>
7        The <em class="structfield"><code>read</code></em> callback returns the
8        register value specified in the argument. 
9
10        </p><div class="informalexample"><pre class="programlisting">
11
12  static unsigned short snd_mychip_ac97_read(struct snd_ac97 *ac97,
13                                             unsigned short reg)
14  {
15          struct mychip *chip = ac97-&gt;private_data;
16          ....
17          return the_register_value;
18  }
19
20          </pre></div><p>
21
22        Here, the chip can be cast from ac97-&gt;private_data.
23      </p><p>
24        Meanwhile, the <em class="structfield"><code>write</code></em> callback is
25        used to set the register value. 
26
27        </p><div class="informalexample"><pre class="programlisting">
28
29  static void snd_mychip_ac97_write(struct snd_ac97 *ac97,
30                       unsigned short reg, unsigned short val)
31
32          </pre></div><p>
33      </p><p>
34      These callbacks are non-atomic like the control API callbacks.
35      </p><p>
36        There are also other callbacks:
37      <em class="structfield"><code>reset</code></em>,
38      <em class="structfield"><code>wait</code></em> and
39      <em class="structfield"><code>init</code></em>. 
40      </p><p>
41        The <em class="structfield"><code>reset</code></em> callback is used to reset
42      the codec. If the chip requires a special kind of reset, you can
43      define this callback. 
44      </p><p>
45        The <em class="structfield"><code>wait</code></em> callback is used to
46      add some waiting time in the standard initialization of the codec. If the
47      chip requires the extra waiting time, define this callback. 
48      </p><p>
49        The <em class="structfield"><code>init</code></em> callback is used for
50      additional initialization of the codec.
51      </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="api-ac97-constructor.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-updating-registers.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Constructor&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Updating Registers in The Driver</td></tr></table></div></body></html>
52