Introduction 15 KB

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