<?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>Callbacks</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 7. API for AC97 Codec" /><link rel="prev" href="ch07s03.html" title="Constructor" /><link rel="next" href="ch07s05.html" title="Updating Registers in The Driver" /></head><body><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="ch07s03.html">Prev</a> </td><th width="60%" align="center">Chapter 7. API for AC97 Codec</th><td width="20%" align="right"> <a accesskey="n" href="ch07s05.html">Next</a></td></tr></table><hr /></div><div class="section" title="Callbacks"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="api-ac97-callbacks"></a>Callbacks</h2></div></div></div><p> The standard callbacks are <em class="structfield"><code>read</code></em> and <em class="structfield"><code>write</code></em>. Obviously they correspond to the functions for read and write accesses to the hardware low-level codes. </p><p> The <em class="structfield"><code>read</code></em> callback returns the register value specified in the argument. </p><div class="informalexample"><pre class="programlisting"> static unsigned short snd_mychip_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct mychip *chip = ac97->private_data; .... return the_register_value; } </pre></div><p> Here, the chip can be cast from ac97->private_data. </p><p> Meanwhile, the <em class="structfield"><code>write</code></em> callback is used to set the register value. </p><div class="informalexample"><pre class="programlisting"> static void snd_mychip_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) </pre></div><p> </p><p> These callbacks are non-atomic like the control API callbacks. </p><p> There are also other callbacks: <em class="structfield"><code>reset</code></em>, <em class="structfield"><code>wait</code></em> and <em class="structfield"><code>init</code></em>. </p><p> The <em class="structfield"><code>reset</code></em> callback is used to reset the codec. If the chip requires a special kind of reset, you can define this callback. </p><p> The <em class="structfield"><code>wait</code></em> callback is used to add some waiting time in the standard initialization of the codec. If the chip requires the extra waiting time, define this callback. </p><p> The <em class="structfield"><code>init</code></em> callback is used for additional initialization of the codec. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch07.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch07s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Constructor </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Updating Registers in The Driver</td></tr></table></div></body></html>