cleanup
[linux-2.4.21-pre4.git] / Documentation / sound / Introduction
1 Introduction    Notes on Modular Sound Drivers and Soundcore
2 Wade Hampton 
3 2/14/2001
4
5 Purpose:  
6 ========
7 This document provides some general notes on the modular 
8 sound drivers and their configuration, along with the 
9 support modules sound.o and soundcore.o.
10
11 Note, some of this probably should be added to the Sound-HOWTO!
12
13 Note, soundlow.o was present with 2.2 kernels but is not 
14 required for 2.4.x kernels.  References have been removed
15 to this.
16
17
18 Copying:
19 ========
20 none
21
22
23 History:
24 ========
25 0.1.0  11/20/1998  First version, draft
26 1.0.0  11/1998     Alan Cox changes, incorporation in 2.2.0
27                    as /usr/src/linux/Documentation/sound/Introduction
28 1.1.0  6/30/1999   Second version, added notes on making the drivers,
29                    added info on multiple sound cards of similar types,]
30                    added more diagnostics info, added info about esd.
31                    added info on OSS and ALSA.
32 1.1.1  19991031    Added notes on sound-slot- and sound-service.
33                         (Alan Cox)
34 1.1.2  20000920    Modified for Kernel 2.4 (Christoph Hellwig)
35 1.1.3  20010214    Minor notes and corrections (Wade Hampton)
36                    Added examples of sound-slot-0, etc.
37
38
39 Modular Sound Drivers:
40 ======================
41
42 Thanks to the GREAT work by Alan Cox (alan@lxorguk.ukuu.org.uk),
43
44 [And Oleg Drokin, Thomas Sailer, Andrew Veliath and more than a few 
45  others - not to mention Hannu's original code being designed well
46  enough to cope with that kind of chopping up](Alan)
47
48 the standard Linux kernels support a modular sound driver.  From
49 Alan's comments in linux/drivers/sound/README.FIRST:
50
51   The modular sound driver patches were funded by Red Hat Software 
52   (www.redhat.com). The sound driver here is thus a modified version of 
53   Hannu's code. Please bear that in mind when considering the appropriate
54   forums for bug reporting.
55
56 The modular sound drivers may be loaded via insmod or modprobe.  
57 To support all the various sound modules, there are two general 
58 support modules that must be loaded first:
59  
60    soundcore.o:   Top level handler for the sound system, provides
61                   a set of functions for registration of devices
62                   by type.
63
64    sound.o:       Common sound functions required by all modules.
65
66 For the specific sound modules (e.g., sb.o for the Soundblaster), 
67 read the documentation on that module to determine what options
68 are available, for example IRQ, address, DMA.
69
70 Warning, the options for different cards sometime use different names 
71 for the same or a similar feature (dma1= versus dma16=).  As a last 
72 resort, inspect the code (search for MODULE_PARM).
73
74 Notes:
75
76 1.  There is a new OpenSource sound driver called ALSA which is
77     currently under development:  http://www.alsa-project.org/
78     The ALSA drivers support some newer hardware that may not 
79     be supported by this sound driver and also provide some 
80     additional features.
81
82 2.  The commercial OSS driver may be obtained from the site:
83     http://www/opensound.com.  This may be used for cards that
84     are unsupported by the kernel driver, or may be used
85     by other operating systems.  
86
87 3.  The enlightenment sound daemon may be used for playing
88     multiple sounds at the same time via a single card, eliminating
89     some of the requirements for multiple sound card systems.  For
90     more information, see:  http://www.tux.org/~ricdude/EsounD.html  
91     The "esd" program may be used with the real-player and mpeg 
92     players like mpg123 and x11amp.  The newer real-player 
93     and some games even include built-in support for ESD!
94
95
96 Building the Modules:
97 =====================
98
99 This document does not provide full details on building the 
100 kernel, etc.  The notes below apply only to making the kernel
101 sound modules.   If this conflicts with the kernel's README,
102 the README takes precedence. 
103
104 1.  To make the kernel sound modules, cd to your /usr/src/linux
105     directory (typically) and type make config, make menuconfig, 
106     or make xconfig (to start the command line, dialog, or x-based
107     configuration tool).  
108
109 2.  Select the Sound option and a dialog will be displayed.  
110
111 3.  Select M (module) for "Sound card support".
112
113 4.  Select your sound driver(s) as a module.  For ProAudio, Sound
114     Blaster, etc., select M (module) for OSS sound modules.
115     [thanks to Marvin Stodolsky <stodolsk@erols.com>]A
116
117 5.  Make the kernel (e.g., make dep ; make bzImage), and install
118     the kernel.
119
120 6.  Make the modules and install them (make modules; make modules_install).
121
122 Note, for 2.4.x kernels, make sure you have the newer modutils 
123 loaded or modules will not be loaded properly.  2.4.x changed the 
124 layout of /lib/modules/2.4.x and requires an updated modutils.
125
126
127 Plug and Play (PnP:
128 ===================
129
130 If the sound card is an ISA PnP card, isapnp may be used
131 to configure the card.  See the file isapnp.txt in the 
132 directory one level up (e.g., /usr/src/linux/Documentation).
133
134 Also the 2.4.x kernels provide PnP capabilities, see the 
135 file NEWS in this directory.
136
137 PCI sound cards are highly recommended, as they are far 
138 easier to configure and from what I have read, they use
139 less resources and are more CPU efficient.
140
141
142 INSMOD:
143 =======
144
145 If loading via insmod, the common modules must be loaded in the 
146 order below BEFORE loading the other sound modules.  The card-specific
147 modules may then be loaded (most require parameters).  For example,
148 I use the following via a shell script to load my SoundBlaster:
149
150 SB_BASE=0x240
151 SB_IRQ=9
152 SB_DMA=3
153 SB_DMA2=5
154 SB_MPU=0x300
155 #
156 echo Starting sound
157 /sbin/insmod soundcore
158 /sbin/insmod sound  
159 #
160 echo Starting sound blaster....
161 /sbin/insmod uart401
162 /sbin/insmod sb io=$SB_BASE irq=$SB_IRQ dma=$SB_DMA dma16=$SB_DMA2 mpu_io=$SB_MP
163
164 When using sound as a module, I typically put these commands
165 in a file such as /root/soundon.sh.
166
167
168 MODPROBE:
169 =========
170
171 If loading via modprobe, these common files are automatically loaded 
172 when requested by modprobe.  For example, my /etc/modules.conf contains:
173
174 alias sound sb 
175 options sb io=0x240 irq=9 dma=3 dma16=5 mpu_io=0x300
176
177 All you need to do to load the module is:
178
179         /sbin/modprobe sb
180
181
182 Sound Status:
183 =============
184
185 The status of sound may be read/checked by:
186         cat (anyfile).au >/dev/audio
187
188 [WWH:  This may not work properly for SoundBlaster PCI 128 cards
189 such as the es1370/1 (see the es1370/1 files in this directory) 
190 as they do not automatically support uLaw on /dev/audio.]
191
192 The status of the modules and which modules depend on 
193 which other modules may be checked by:
194         /sbin/lsmod
195
196 /sbin/lsmod should show something like the following:
197         sb                     26280   0 
198         uart401                 5640   0  [sb]
199         sound                  57112   0  [sb uart401]
200         soundcore               1968   8  [sb sound]
201
202
203 Removing Sound: 
204 =============== 
205
206 Sound may be removed by using /sbin/rmmod in the reverse order
207 in which you load the modules.  Note, if a program has a sound device
208 open (e.g., xmixer), that module (and the modules on which it 
209 depends) may not be unloaded.
210
211 For example, I use the following to remove my Soundblaster (rmmod
212 in the reverse order in which I loaded the modules):
213
214 /sbin/rmmod sb
215 /sbin/rmmod uart401
216 /sbin/rmmod sound
217 /sbin/rmmod soundcore
218
219 When using sound as a module, I typically put these commands
220 in a script such as /root/soundoff.sh.
221
222
223 Removing Sound for use with OSS: 
224 ================================ 
225
226 If you get really stuck or have a card that the kernel modules
227 will not support, you can get a commercial sound driver from
228 http://www.opensound.com.  Before loading the commercial sound
229 driver, you should do the following:
230
231 1.  remove sound modules (detailed above)
232 2.  remove the sound modules from /etc/modules.conf
233 3.  move the sound modules from /lib/modules/<kernel>/misc
234     (for example, I make a /lib/modules/<kernel>/misc/tmp
235     directory and copy the sound module files to that 
236     directory).
237
238
239 Multiple Sound Cards:
240 =====================
241
242 The sound drivers will support multiple sound cards and there
243 are some great applications like multitrack that support them.  
244 Typically, you need two sound cards of different types.  Note, this
245 uses more precious interrupts and DMA channels and sometimes 
246 can be a configuration nightmare.  I have heard reports of 3-4
247 sound cards (typically I only use 2).  You can sometimes use
248 multiple PCI sound cards of the same type.
249
250 On my machine I have two sound cards (cs4232 and Soundblaster Vibra
251 16).  By loading sound as modules, I can control which is the first
252 sound device (/dev/dsp, /dev/audio, /dev/mixer) and which is 
253 the second.  Normally, the cs4232 (Dell sound on the motherboard) 
254 would be the first sound device, but I prefer the Soundblaster.  
255 All you have to do is to load the one you want as /dev/dsp 
256 first (in my case "sb") and then load the other one
257 (in my case "cs4232").
258
259 If you have two cards of the same type that are jumpered 
260 cards or different PnP revisions, you may load the same 
261 module twice.  For example, I have a SoundBlaster vibra 16
262 and an older SoundBlaster 16 (jumpers).  To load the module
263 twice, you need to do the following:
264
265 1.  Copy the sound modules to a new name.  For example
266     sb.o could be copied (or symlinked) to sb1.o for the
267     second SoundBlaster.
268
269 2.  Make a second entry in /etc/modules.conf, for example,
270     sound1 or sb1.  This second entry should refer to the
271     new module names for example sb1, and should include
272     the I/O, etc. for the second sound card.
273
274 3.  Update your soundon.sh script, etc.
275
276 Warning:  I have never been able to get two PnP sound cards of the
277 same type to load at the same time.  I have tried this several times
278 with the Soundblaster Vibra 16 cards.  OSS has indicated that this
279 is a PnP problem....  If anyone has any luck doing this, please 
280 send me an E-MAIL.  PCI sound cards should not have this problem.a
281 Since this was originally release, I have received a couple of 
282 mails from people who have accomplished this!
283
284 NOTE: In Linux 2.4 the Sound Blaster driver (and only this one yet)
285 supports multiple cards with one module by default.
286 Read the file 'Soundblaster' in this directory for details.
287
288
289 Sound Problems:
290 ===============
291
292 First RTFM (including the troubleshooting section 
293 in the Sound-HOWTO). 
294
295 1)  If you are having problems loading the modules (for
296     example, if you get device conflict errors) try the
297     following:
298
299   A)  If you have Win95 or NT on the same computer,  
300       write down what addresses, IRQ, and DMA channels
301       those were using for the same hardware.  You probably 
302       can use these addresses, IRQs, and DMA channels.
303       You should really do this BEFORE attempting to get
304       sound working!
305   
306   B)  Check (cat) /proc/interrupts, /proc/ioports,
307       and /proc/dma.  Are you trying to use an address,
308       IRQ or DMA port that another device is using?
309   
310   C)  Check (cat) /proc/isapnp
311   
312   D)  Inspect your /var/log/messages file.  Often that will 
313       indicate what IRQ or IO port could not be obtained.
314   
315   E)  Try another port or IRQ.  Note this may involve 
316       using the PnP tools to move the sound card to 
317       another location.  Sometimes this is the only way 
318       and it is more or less trial and error.
319
320 2)  If you get motor-boating (the same sound or part of a 
321     sound clip repeated), you probably have either an IRQ
322     or DMA conflict.  Move the card to another IRQ or DMA
323     port.  This has happened to me when playing long files 
324     when I had an IRQ conflict.
325
326 3.  If you get dropouts or pauses when playing high sample
327     rate files such as using mpg123 or x11amp/xmms, you may 
328     have too slow of a CPU and may have to use the options to 
329     play the files at 1/2 speed.  For example, you may use
330     the -2 or -4 option on mpg123.  You may also get this
331     when trying to play mpeg files stored on a CD-ROM
332     (my Toshiba T8000 PII/366 sometimes has this problem).
333
334 4.  If you get "cannot access device" errors, your /dev/dsp
335     files, etc. may be set to owner root, mode 600.  You 
336     may have to use the command:
337       chmod 666 /dev/dsp /dev/mixer /dev/audio
338
339 5.  If you get "device busy" errors, another program has the
340     sound device open.  For example, if using the Enlightenment
341     sound daemon "esd", the "esd" program has the sound device.
342     If using "esd", please RTFM the docs on ESD.  For example,
343     esddsp <program> may be used to play files via a non-esd
344     aware program.
345
346 6)  Ask for help on the sound list or send E-MAIL to the
347     sound driver author/maintainer.
348
349 7)  Turn on debug in drivers/sound/sound_config.h (DEB, DDB, MDB).
350
351 8)  If the system reports insufficient DMA memory then you may want to
352     load sound with the "dmabufs=1" option. Or in /etc/conf.modules add
353         
354         preinstall sound dmabufs=1
355
356     This makes the sound system allocate its buffers and hang onto them.
357
358     You may also set persistent DMA when building a 2.4.x kernel.
359
360
361 Configuring Sound:
362 ==================
363
364 There are several ways of configuring your sound:
365
366 1)  On the kernel command line (when using the sound driver(s)
367     compiled in the kernel). Check the driver source and
368     documentation for details.
369
370 2)  On the command line when using insmod or in a bash script
371     using command line calls to load sound.
372
373 3)  In /etc/modules.conf when using modprobe.
374
375 4)  Via Red Hat's GPL'd /usr/sbin/sndconfig program (text based).
376
377 5)  Via the OSS soundconf program (with the commercial version
378     of the OSS driver.
379
380 6)  By just loading the module and let isapnp do everything relevant
381     for you. This works only with a few drivers yet and - of course -
382     only with isapnp hardware.
383
384 And I am sure, several other ways.  
385
386 Anyone want to write a linuxconf module for configuring sound?
387
388
389 Module Loading:
390 ===============
391
392 When a sound card is first referenced and sound is modular, the sound system
393 will ask for the sound devices to be loaded. Initially it requests that
394 the driver for the sound system is loaded. It then will ask for 
395 sound-slot-0, where 0 is the first sound card. (sound-slot-1 the second and
396 so on). Thus you can do
397
398 alias sound-slot-0 sb
399
400 To load a soundblaster at this point. If the slot loading does not provide
401 the desired device - for example a soundblaster does not directly provide
402 a midi synth in all cases then it will request "sound-service-0-n" where n
403 is
404
405   0     Mixer
406
407   2     MIDI
408
409   3, 4  DSP audio
410
411
412 For example, I use the following to load my Soundblaster PCI 128
413 (ES 1371) card first, followed by my SoundBlaster Vibra 16 card,
414 then by my TV card:
415
416 # Load the Soundblaster PCI 128 as /dev/dsp, /dev/dsp1, /dev/mixer
417 alias sound-slot-0 es1371
418
419 # Load the Soundblaster Vibra 16 as /dev/dsp2, /dev/mixer1
420 alias sound-slot-1 sb
421 options sb io=0x240 irq=5 dma=1 dma16=5 mpu_io=0x330
422
423 # Load the BTTV (TV card) as /dev/mixer2
424 alias sound-slot-2 bttv
425 alias sound-service-2-0 tvmixer
426
427 pre-install bttv  modprobe tuner ; modprobe tvmixer
428 pre-install tvmixer modprobe msp3400; modprobe tvaudio 
429 options tuner debug=0 type=8 
430 options bttv  card=0 radio=0 pll=0
431
432
433 For More Information (RTFM):
434 ============================
435 1)  Information on kernel modules:  linux/Documentation/modules.txt
436     and manual pages for insmod and modprobe.
437
438 2)  Information on PnP, RTFM manual pages for isapnp.
439
440 3)  Sound-HOWTO and Sound-Playing-HOWTO.
441
442 4)  OSS's WWW site at http://www.opensound.com.
443
444 5)  All the files in linux/Documentation/sound.
445
446 6)  The comments and code in linux/drivers/sound.
447
448 7)  The sndconfig and rhsound documentation from Red Hat.
449
450 8)  The Linux-sound mailing list:  sound-list@redhat.com.
451
452 9)  Enlightenment documentation (for info on esd)
453     http://www.tux.org/~ricdude/EsounD.html.
454
455 10) ALSA home page:  http://www.alsa-project.org/
456
457
458 Contact Information:
459 ====================
460 Wade Hampton:  (whampton@staffnet.com)
461