Mirrored from http://www.sonic.net/~rknop/linux/debian_alsa.html , with the author's permission.
Debian and ALSA
Debian Sarge, a Stock Kernel, and ALSA
I've recently moved to using Sarge. As I write this, I'm working on an IBM X31, which has an Intel 82801DB sound card. I'm using the kernel-image-2.4.26-1-686 kernel package— I have not compiled my own kernel, as the packaged kernel has everything I need in it.
1. Get the ALSA packages
Install the following packages. For the alsa-modules package, install the versions that goes with the Debian kernel you are using.
2. Figure out which driver you should use
Go to the ALSA Soundcard Matrix to figure out which driver goes with your card. In my case, I want to use the snd-intel8x0 driver. Substitude your driver for everything below where you see this.
3. Edit /etc/modules/alsa
Add lines similar to the following. If you follow the "details" link off of the ALSA Soundcard Matrix, you will get the right lines for your card— it's where I got the lines below.
# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-intel8x0
# module options should go here
# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0
# card #1
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-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
4. Stop the kernel from doing bad things
Debian Sarge has some nice features that do a lot of stuff for you at boot time. Unfortunately, sometimes it gets a little over enthusaistic. You have to tell it not to do things that will get in the way of ALSA.
Prevent OSS drivers from loading
The discover1 pacakage tries to figure out what hardware you have and load the modules for them. Very nice. Except that it loads the OSS sound modules. To prevent it from doing this, add the line:
to the file /etc/discover.conf. Put the name of the OSS module for your sound card in place of i810_audio. (You can probably figure this out by perusing the output if lsmod.)
Prevent ALSA from thinking your card is a modem
Don't try this at first. If things aren't working the first time through, this may be the source of your problem. The hotplug system may try to initialize the modem before the soundcard, and may conclude that your ALSA soundcard is a modem. Figure out what the "modem" module for your soundcard is, and add that to the hotplug blacklist (in the file /etc/hotplug/blacklist). In my case, I added the line "snd-intel8x0m" to the bottom of that file.
If all goes well, when your system comes back up you will be running ALSA, and you will be running ALSA thereafter. Try playing sounds. Run alsamixer; if you get anything, then you know you're running ALSA rather than OSS.
Debian Woody, a Custom Kernel, and ALSA
This document gives some brief notes as to how you can install ALSA using your own custom kernel in a manner which should be completely friendly with the Debian package system.
I'm using testing (Sarge), but the same basic procedure should work with Woody.
Packages and Archives to Get
You will want to install the following packages (with apt-get install packagename):
Note that if you're going to compile your own custom kernel, you do not need to get any of the alsa-modules debs.
You also need the source code to whichever kernel you want to install. I just used the standard linux-2.4.20.tar.bz2 archive one can get from ftp.kernel.org.
Compiling the Kernel
This is covered in the Debian FAQ, and I encourage you to look there. However, here's what I did:
Make the ALSA Modules
The first time I did this, it worked fine. I was running testing (sarge), and as such got the 0.9.0rc6-3 version of the alsa-source package. That's what's installed and working with my ens1371 card on my desktop. However, a subsequent attempt (with a much more stripped down kernel) failed. I think that for the compilation of recent 0.9.x versions of ALSA to wor, you need some things like USB and PCI in the kernel. (I don't know this for sure, but base this on cruising Debian bug reports.)
When compiling ALSA for a truly ancient 486 laptop, I got things to work by dropping back to the alsa-source-0.5 package from stable (woody).
Install the kernel and the ALSA modules
dpkg -i kernel-image-....deb alsa-modules....deb
This will run LILO so that your new kernel will be the default next time you boot.
You will need to create a file:
(Assuming that you're using a 0.9.x release of ALSA, which is current as of this writing.) In here, put the module commands your system will need for your sound card. This is what I used:
alias char-major-14 soundcore alias char-major-116 snd alias snd-card-0 snd-ens1371 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-8 snd-seq-oss alias sound-service-0-12 snd-pcm-oss
Of course, replace "snd-ens1371" with the right module for your soundcard. You may also want to add an "options" line for your sound card. And some of the rest of that stuff may be different for your card... read the docs on the ALSA home page and/or the ALSA Wiki about your card for more info.
You should also have a link /etc/modutils/alsa that points to /etc/alsa/modutils/0.9; I believe that one of the packages you've installed should do this automatically, but I found that link missing after a recent recompile. You might want to check that it's there if your sound modules aren't getting loaded automatically.
You're done. You've got a new kernel, with ALSA (hopefully) working, and everything is completely happy under the Debian Package system.
(Well, almost. You probably want to go back sometime and do an "rm -rf" under /usr/src/modules, as the package system doesn't really know about that.)
A Note on Permissions
The startup script /etc/init.d/alsa seems to set the permissions on the various audio devices (e.g. /dev/mixer and /dev/dsp) to 660, i.e. so that only root and the "audio" group can read and write to them. Previously, I'd made the mode 666 so that any user could use audio; however, at shutodown, the script was wiping this out.
There's a number of ways to deal with this; you could modify the startup script, or you could write your own startup script that makes the mode what you want it to be. What I did was add a few users (as there are only are a few on this system) to the "audio" group in /etc/groups.
Another, perhaps preferable way, pointed out to me by Alexander Maassen is to add the following line to the file /etc/alsa/modules/0.9 (where 0.9 is the major version of ALSA; it may be different than 0.9 for you):
options snd major=116 cards_limit=4 device_mode=0666 device_gid=29 device_uid=0
(You may want to verify that GID 29 is audio in your /etc/group file.)
For versions of ALSA older than 0.9.0rc5 (which includes the 0.9.x ALSA that is in Debian Woody), you need to use slightly different options:
options snd snd_major=116 snd_cards_limit=4 snd_device_mode=0666 snd_device_gid=29 snd_device_uid=0