<?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>Chapter 14. Module Parameters</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="index.html" title="Writing an ALSA Driver" /><link rel="prev" href="ch13.html" title="Chapter 13. Power Management" /><link rel="next" href="ch15.html" title="Chapter 15. How To Put Your Driver Into ALSA Tree" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 14. Module Parameters</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch13.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch15.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 14. Module Parameters"><div class="titlepage"><div><div><h2 class="title"><a id="module-parameters"></a>Chapter 14. Module Parameters</h2></div></div></div><p> There are standard module options for ALSA. At least, each module should have the <em class="parameter"><code>index</code></em>, <em class="parameter"><code>id</code></em> and <em class="parameter"><code>enable</code></em> options. </p><p> If the module supports multiple cards (usually up to 8 = <code class="constant">SNDRV_CARDS</code> cards), they should be arrays. The default initial values are defined already as constants for easier programming: </p><div class="informalexample"><pre class="programlisting"> static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; </pre></div><p> </p><p> If the module supports only a single card, they could be single variables, instead. <em class="parameter"><code>enable</code></em> option is not always necessary in this case, but it would be better to have a dummy option for compatibility. </p><p> The module parameters must be declared with the standard <code class="function">module_param()()</code>, <code class="function">module_param_array()()</code> and <code class="function">MODULE_PARM_DESC()</code> macros. </p><p> The typical coding would be like below: </p><div class="informalexample"><pre class="programlisting"> #define CARD_NAME "My Chip" module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); </pre></div><p> </p><p> Also, don't forget to define the module description, classes, license and devices. Especially, the recent modprobe requires to define the module license as GPL, etc., otherwise the system is shown as <span class="quote">“<span class="quote">tainted</span>”</span>. </p><div class="informalexample"><pre class="programlisting"> MODULE_DESCRIPTION("My Chip"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Vendor,My Chip Name}}"); </pre></div><p> </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch13.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch15.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 13. Power Management </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 15. How To Put Your Driver Into ALSA Tree</td></tr></table></div></body></html>