1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Constructor</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="control-interface.html" title="Chapter 6. Control Interface"><link rel="prev" href="control-interface-callbacks.html" title="Callbacks"><link rel="next" href="control-interface-change-notification.html" title="Change Notification"></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">Constructor</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="control-interface-callbacks.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Control Interface</th><td width="20%" align="right"> <a accesskey="n" href="control-interface-change-notification.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="control-interface-constructor"></a>Constructor</h2></div></div></div><p> 2 When everything is ready, finally we can create a new 3 control. To create a control, there are two functions to be 4 called, <code class="function">snd_ctl_new1()</code> and 5 <code class="function">snd_ctl_add()</code>. 6 </p><p> 7 In the simplest way, you can do like this: 8 9 </p><div class="informalexample"><pre class="programlisting"> 10 11 err = snd_ctl_add(card, snd_ctl_new1(&my_control, chip)); 12 if (err < 0) 13 return err; 14 15 </pre></div><p> 16 17 where <em class="parameter"><code>my_control</code></em> is the 18 struct <span class="structname">snd_kcontrol_new</span> object defined above, and chip 19 is the object pointer to be passed to 20 kcontrol->private_data 21 which can be referred to in callbacks. 22 </p><p> 23 <code class="function">snd_ctl_new1()</code> allocates a new 24 <span class="structname">snd_kcontrol</span> instance, 25 and <code class="function">snd_ctl_add</code> assigns the given 26 control component to the card. 27 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="control-interface-callbacks.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="control-interface.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="control-interface-change-notification.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Callbacks </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Change Notification</td></tr></table></div></body></html> 28