1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;10.&#160;Miscellaneous Devices</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="rawmidi-interface-callbacks.html" title="Callbacks"><link rel="next" href="misc-devices-hardware-dependent.html" title="Hardware-Dependent Devices"></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&#160;10.&#160;Miscellaneous Devices</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rawmidi-interface-callbacks.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="misc-devices-hardware-dependent.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="misc-devices"></a>Chapter&#160;10.&#160;Miscellaneous Devices</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="misc-devices.html#misc-devices-opl3">FM OPL3</a></span></dt><dt><span class="section"><a href="misc-devices-hardware-dependent.html">Hardware-Dependent Devices</a></span></dt><dt><span class="section"><a href="misc-devices-IEC958.html">IEC958 (S/PDIF)</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="misc-devices-opl3"></a>FM OPL3</h2></div></div></div><p>
2        The FM OPL3 is still used in many chips (mainly for backward
3      compatibility). ALSA has a nice OPL3 FM control layer, too. The
4      OPL3 API is defined in
5      <code class="filename">&lt;sound/opl3.h&gt;</code>. 
6      </p><p>
7        FM registers can be directly accessed through the direct-FM API,
8      defined in <code class="filename">&lt;sound/asound_fm.h&gt;</code>. In
9      ALSA native mode, FM registers are accessed through
10      the Hardware-Dependent Device direct-FM extension API, whereas in
11      OSS compatible mode, FM registers can be accessed with the OSS
12      direct-FM compatible API in <code class="filename">/dev/dmfmX</code> device. 
13      </p><p>
14        To create the OPL3 component, you have two functions to
15        call. The first one is a constructor for the <span class="type">opl3_t</span>
16        instance. 
17
18        </p><div class="informalexample"><pre class="programlisting">
19
20  struct snd_opl3 *opl3;
21  snd_opl3_create(card, lport, rport, OPL3_HW_OPL3_XXX,
22                  integrated, &amp;opl3);
23
24          </pre></div><p>
25      </p><p>
26        The first argument is the card pointer, the second one is the
27      left port address, and the third is the right port address. In
28      most cases, the right port is placed at the left port + 2. 
29      </p><p>
30        The fourth argument is the hardware type.
31      </p><p>
32        When the left and right ports have been already allocated by
33      the card driver, pass non-zero to the fifth argument
34      (<em class="parameter"><code>integrated</code></em>). Otherwise, the opl3 module will
35      allocate the specified ports by itself. 
36      </p><p>
37        When the accessing the hardware requires special method
38        instead of the standard I/O access, you can create opl3 instance
39        separately with <code class="function">snd_opl3_new()</code>.
40
41        </p><div class="informalexample"><pre class="programlisting">
42
43  struct snd_opl3 *opl3;
44  snd_opl3_new(card, OPL3_HW_OPL3_XXX, &amp;opl3);
45
46          </pre></div><p>
47      </p><p>
48	Then set <em class="structfield"><code>command</code></em>,
49	<em class="structfield"><code>private_data</code></em> and
50	<em class="structfield"><code>private_free</code></em> for the private
51	access function, the private data and the destructor.
52	The l_port and r_port are not necessarily set.  Only the
53	command must be set properly.  You can retrieve the data
54	from the opl3-&gt;private_data field.
55      </p><p>
56	After creating the opl3 instance via <code class="function">snd_opl3_new()</code>,
57	call <code class="function">snd_opl3_init()</code> to initialize the chip to the
58	proper state. Note that <code class="function">snd_opl3_create()</code> always
59	calls it internally.
60      </p><p>
61        If the opl3 instance is created successfully, then create a
62        hwdep device for this opl3. 
63
64        </p><div class="informalexample"><pre class="programlisting">
65
66  struct snd_hwdep *opl3hwdep;
67  snd_opl3_hwdep_new(opl3, 0, 1, &amp;opl3hwdep);
68
69          </pre></div><p>
70      </p><p>
71        The first argument is the <span class="type">opl3_t</span> instance you
72      created, and the second is the index number, usually 0. 
73      </p><p>
74        The third argument is the index-offset for the sequencer
75      client assigned to the OPL3 port. When there is an MPU401-UART,
76      give 1 for here (UART always takes 0). 
77      </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="rawmidi-interface-callbacks.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="misc-devices-hardware-dependent.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Callbacks&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Hardware-Dependent Devices</td></tr></table></div></body></html>
78