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