UPDATE
I think this article is basically pretty out of date at this stage (at time of writing, Woody 3.0 is the Debian stable release). Perhaps this tutorial at linuxorbit is more relevant.
Instructions
I did this install because i planned to install another sound card which
only had alsa support, and i wanted to see how tricky it was. Also, this had
the benefit of improving the sound quality on my original Crystal 4237B
sound card (there used to be a click between mp3 tracks, which is gone).
The System was
Debian 2.2r3, kernel 2.2.19 (installed in /usr/src/linux)
Via dselect, I installed alsa-source, alsautils, alsa-base, libasound0.4 and
tried to build drivers (after untaring alsadriver.tar.gz in /usr/src), but
got errors
In file included from persist.c:23: ../include/driver.h:145: redefinition of `wait_queue_t' /usr/src/linux/include/linux/wait.h:19: `wait_queue_t' previously declared here ../include/driver.h:146: redefinition of `wait_queue_head_t' /usr/src/linux/include/linux/wait.h:20: `wait_queue_head_t' previously declared here make[1]: *** [persist.o] Error 1 make[1]: Leaving directory `/usr/src/modules/alsadriver/kernel' make: *** [compile] Error 1
Same happened on home system (2.2.19pre18 IIRC), and i think it is a known
problem, seems to be due to influx of 2.4 merges into 2.2 stream, as
reported here:
http://lists.debian.org/debian-devel-0102/msg01335.html
Instead fetched newer sources from alsa website, as follows:
wget --passive ftp://ftp.alsa-project.org/pub/driver/alsa-driver-0.5.11.tar.bz2
wget --passive ftp://ftp.alsa-project.org/pub/lib/alsa-lib-0.5.10b.tar.bz2
wget --passive ftp://ftp.alsa-project.org/pub/utils/alsa-utils-0.5.10.tar.bz2
Put these in /usr/local/src, then ran
bunzip2 *.bz2 for x in alsa*.tar; do tar -xvf $x; done
(they are all well mannered tar files!)
in alsa-driver-0.5.11 type "./configure; make; make install" Do the same in alsa-lib-0.5.10b and in alsa-utils-0.5.10 (in that order). If you like, you can run the snddevices script in alsa-driver-0.5.11, but it is not really necessary on a Debian system, AFAICS the required dev files are there already.
At this point, you should have /lib/modules/2.2.19/misc very fully populated. We will assume at this point that you have sound support compiled in to your kernel. If you are replacing an existing driver with ALSA, this will certainly be the case. Otherwise, a kernel recompile may be needed (when you do make menuconfig, just select sound support, but don't pick any of the specific models, like es1371 for soundblaster or the like).
Now, you need to pick settings for your individual card. I have configured two cards with Alsa, the Soundblaster 64V PCI (on a Dell Dimension), and a Crystal Wavetable 4237B (onboard on a Dell Precision 410 Workstation). At present, only details on the latter are presented here (although basically the same process is followed in both cases).
To get the 4237B to work, i began by running alsaconf, and selected the appropriate driver to configure, and took all the default settings. When it asked for sizes of buffer, i picked the minimum possible (4) as I thought it least likely to break anything. Since then, I have changed the options to make them a little bigger.
this generated /etc/modutils/alsa. run update-modules to have this reflected in the modules.conf file (at least on a Debian system). At this point I should have been able to load the module, snd-card-cs4236, but it gave errors.
Therefor: Needed to make some changes. Where the generated file said "snd_index=1", i changed it to "snd_index=0". Also, I changed the snd_mpu_irq from 7 to 9 (this might be specific to my own card) which was the setting from my old cs4232 oss module config line (which in turn i had culled from Windows NT settings!). With these changes the module loaded correctly. (the soundblaster was more straight-forward).
To get oss applications to work with your card you need to have the modules snd-pcm-oss and snd-mixer-oss loaded (See INSTALL file that comes with the source, and the FAQ). To achieve this you need to change the mentions of snd-pcm-oss in /etc/modutils/alsa. The references are slightly wrong, something like snd-pcm1-oss or snd-pcm-oss1 (I forget now, and i only changed it 5 minutes ago!), but you want "snd-pcm-oss" so that you end up with a /etc/modutils/alsa as follows:
# --- BEGIN: Generated by ALSACONF, do not edit. --- # --- ALSACONF verion 0.4.2 --- alias char-major-116 snd alias snd-card-0 snd-card-cs4236 alias char-major-14 soundcore alias sound-slot-0 snd-card-0 alias sound-service-0-0 snd-mixer-oss alias sound-service-0-1 snd-seq-oss alias sound-service-0-3 snd-pcm-oss alias sound-service-0-12 snd-pcm-oss options snd snd_major=116 snd_cards_limit=1 snd_device_mode=0660 snd_device_gid=29 snd_device_uid=0 options snd-card-cs4236 snd_index=0 snd_id=CARD_1 snd_port=0x534\ snd_cport=0x120 snd_mpu_port=0x300 snd_fm_port=0x388 snd_irq=11\ snd_mpu_irq=9 snd_dma1=0 snd_dma1_size=4 snd_dma2=3 snd_dma2_size=4 # --- END: Generated by ALSACONF, do not edit. ---
Which should work. After running update-modules, try a "modprobe snd-card-cs4236" and all the required modules should load (you could load snd-mixer-oss and snd-pcm-oss by hand if required, but handier to fix the modules.conf).
Everything is muted initially, and set to zero volume, so to get some volume:
amixer set 'Master Digital' 80% unmute amixer set 'PCM' 80% unmute amixer set 'Aux',1 80% unmute
I am not well up on the details of Sound, but the first line is just plain necessary (i think), the second one makes sound work for things like xmms, and the third makes cd playing work. There are lots of other volumes, mutes to play with too!
So as not to have to set up your sound volumes every time, you should use
alsactl store alsactl restoreat close down and start up respectively. Have a look at the /etc/init.d/alsa script and see what it does (i have yet to do this)
Finally, of interest may be Linux Audio-Quality-HOWTO Alsa-sound-mini-HOWTO
Final note (added some time later) you must not have any sound module already loaded when you try to load the ALSA modules. do lsmod, and rmmod all the sound modules. Then start loading ALSA modules. Ideally, you should also remove any existing sound modules permanently (i just deleted them from /lib/modules/2.2.19/misc/) so that they are not loaded during boot before ALSA loads (thus stopping alsa from loading). Also, note that if you are in X when doing this, and have gnome (or KDE) which makes sounds for events and the like, you probably won't be able to unload the modules as they will be in use. Quit to the terminal first, then reload window manager.
One more thing! If you install a new kernel, say go from 2.2.19 to 2.2.20, then modules will now be in a different directory, so you have to reinstall alsa (just follow the installation steps for modules above).
Definition
Someone who listens to the equipment instead of the music.