1<html><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.78.1"><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="power-management.html" title="Chapter 13. Power Management"><link rel="next" href="how-to-put-your-driver.html" title="Chapter 15. How To Put Your Driver Into ALSA Tree"></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">Chapter 14. Module Parameters</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="power-management.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="how-to-put-your-driver.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="module-parameters"></a>Chapter 14. Module Parameters</h1></div></div></div><p> 2 There are standard module options for ALSA. At least, each 3 module should have the <em class="parameter"><code>index</code></em>, 4 <em class="parameter"><code>id</code></em> and <em class="parameter"><code>enable</code></em> 5 options. 6 </p><p> 7 If the module supports multiple cards (usually up to 8 8 = <code class="constant">SNDRV_CARDS</code> cards), they should be 9 arrays. The default initial values are defined already as 10 constants for easier programming: 11 12 </p><div class="informalexample"><pre class="programlisting"> 13 14 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 15 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 16 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 17 18 </pre></div><p> 19 </p><p> 20 If the module supports only a single card, they could be single 21 variables, instead. <em class="parameter"><code>enable</code></em> option is not 22 always necessary in this case, but it would be better to have a 23 dummy option for compatibility. 24 </p><p> 25 The module parameters must be declared with the standard 26 <code class="function">module_param()()</code>, 27 <code class="function">module_param_array()()</code> and 28 <code class="function">MODULE_PARM_DESC()</code> macros. 29 </p><p> 30 The typical coding would be like below: 31 32 </p><div class="informalexample"><pre class="programlisting"> 33 34 #define CARD_NAME "My Chip" 35 36 module_param_array(index, int, NULL, 0444); 37 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 38 module_param_array(id, charp, NULL, 0444); 39 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); 40 module_param_array(enable, bool, NULL, 0444); 41 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); 42 43 </pre></div><p> 44 </p><p> 45 Also, don't forget to define the module description, classes, 46 license and devices. Especially, the recent modprobe requires to 47 define the module license as GPL, etc., otherwise the system is 48 shown as <span class="quote">“<span class="quote">tainted</span>”</span>. 49 50 </p><div class="informalexample"><pre class="programlisting"> 51 52 MODULE_DESCRIPTION("My Chip"); 53 MODULE_LICENSE("GPL"); 54 MODULE_SUPPORTED_DEVICE("{{Vendor,My Chip Name}}"); 55 56 </pre></div><p> 57 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="power-management.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="how-to-put-your-driver.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> 58