|
发表于 2004-8-11 20:50:01
|
显示全部楼层
贴一个HOWTO
Installing and Configuring ALSA Sound Modules in Debian GNU/Linux HOWTO Version 1.1
(1584 total words in this text)
(80140 Reads)
Published by LinuxOrbit.com, November 1, 2002
by Dan "overridex" McCombs
Introduction
If you're like a lot of the users on the Linux Orbit IRC support channel, a very common question that comes up when trying Debian GNU/Linux is how the heck do you get Advanced Linux Sound Architecture aka ALSA setup properly? In this HOWTO we'll show you how to compile and install the ALSA kernel modules, and then setup things using the ALSA Debian script so that modules are automatically loaded and unloaded, and your mixer levels are saved and restored on boot up. Here's some things you'll need to have before you start this HOWTO:
Internet connection on the machine you want to setup ALSA on for apt-get'ing packages or the alsa-base, alsa-utils and alsa-source packages, along with any dependencies you may need and any needed packages for building debs (such as debhelper or dpkg-dev) on CD.
Debian 3.0 (Woody) or newer, you should be able to install ALSA on older versions, but this HOWTO won't focus on that.
Sound card that's supported by ALSA
Getting Started
First, you should head over to http://www.alsa-project.org/alsa-doc/ and make sure your card is supported, and also check what module it uses. Click on the install link to the right of the name of your card and it should say the name of the module, for instance clicking on the install link next to Abit AU10 shows it uses the snd-fm801 module.
While this isn't specific to ALSA sound, you need to add your user to the audio group so that they have permission to use the sound device, you can do this as root with the adduser command, for example if your username is jessica the command would look like:
adduser jessica audio
Please remember you need to log your user out and back in for this to take effect.
Compiling and Installing the Modules
The Compiling and Installing the Modules section of this HOWTO is the most complicated, because you need to know what the situation is with your kernel and follow the instructions for that scenario, I'll cover a few different possibilities below, follow the one that best suits your setup.
2.5.x kernel or above, or a kernel patchset that provides the ALSA modules
Kernel 2.5.x and above include the ALSA modules in the kernel config, which makes life much easier when trying to setup ALSA. There are also kernel patchsets which include a backport of the ALSA drivers to 2.4.x, such as WOLK (http://freshmeat.net/projects/wolk/) and jp (http://infolinux.de). Making the modules with this setup is pretty simple, when you configure your kernel (with make xconfig or make menuconfig) enable Sound card support, Advanced Linux Sound Architecture, OSS API Emulation, OSS Mixer API, OSS PCM API and the module for your sound card, all as modules (except for OSS API emulation which can only be yes). Then configure and compile your kernel how you usually would, after you've done this and are on the new kernel, you can move on to the section Setting Things Up.
Custom kernel built with make-kpkg (Recommended if you're using a custom kernel)
Things are pretty simple if you have a kernel built with make-kpkg:
apt-get install alsa-source
After alsa-source installs, debconf should ask you some questions. Choose the module for your sound card from the list (that you looked up in the Getting Started section of this HOWTO).
Figure A: Debconf will present the list to you in a text based interface or this Gnome one.
You don't need to enable debugging, and you don't need to enable isa-pnp if you aren't using an isa soundcard.
Figure B: You can click the Help buttons to the right of options if you're not sure whether to enable an option or not.
Now unpack the source code:
cd /usr/src
tar xvzf alsa-driver.tar.gz
And compile the modules:
cd /usr/src/linux (or whatever directory where your kernel source is)
make-kpkg modules_image
That will build a .deb in /usr/src, which you can then install as root with dpkg -i:
dpkg -i /usr/src/alsa-modules-*
Now that your modules are installed, you can move on to the section Setting Things Up.
Stock Debian kernel (Recommended if you're using a stock kernel)
With a stock Debian kernel, you can probably apt-get precompiled modules, however Sarge doesn't seem to have any in it's apt archive at the time of this writing, so you may need to compile them yourself.
Run this to check what version kernel you have:
uname -r
If uname -r returns 2.4.18-686, you can install the modules like this:
apt-get install alsa-modules-2.4.18-686
If uname -r returns 2.4.18-bf2.4, then:
apt-get install alsa-modules-2.4.18-bf2.4
If you're able to install the precompiled modules this way, move on to the section Setting Things Up otherwise, read on.
Stock Debian kernel without precompiled modules
With a stock Debian kernel that does not have precompiled modules available in apt, follow the instructions below, it gets a bit hairy, but thankfully when 2.5.x goes stable we won't have to deal with this anymore as the modules will be in the kernel:
Note: You could also try installing the modules from source from www.alsa-project.org, but we'll do it the Debian way and build a Debian package here to try and keep things organized.
First you'll need to install your kernel-headers, you'll need to find out the version kernel you're on by running:
uname -r
If this command returns 2.4.18-686, then you can:
apt-get install kernel-headers-2.4.18-686
If uname -r returns 2.4.18-bf2.4, then:
apt-get install kernel-headers-2.4.18-bf2.4
You get the idea.
Now install the alsa-source package.
apt-get install alsa-source
After alsa-source installs, debconf should ask you some questions. Choose the module for your sound card from the list (that you looked up in the Getting Started section of this HOWTO). See Figure A above.
You don't need to enable debugging, and you don't need to enable isa-pnp if you aren't using an isa soundcard. See Figure B above.
Now unpack the source code:
cd /usr/src
tar xvzf alsa-driver.tar.gz
Next, compile the modules and build the Debian package of them:
cd /usr/src/modules/alsa-driver/
In this next command a few things need to be explained, so please read on before you run this command:
./debian/rules KSRC=/usr/src/kernel-headers-2.4.18-bf2.4-xfs KVERS=2.4.18-bf2.4-xfs KDREV=10.00.Custom binary-modules
First thing we'll explain is the KSRC option:
KSRC=/usr/src/kernel-headers-2.4.18-bf2.4-xfs
It needs to be set to the directory with your kernel headers, so if your kernel is 2.4.18-686 this would be:
KSRC=/usr/src/kernel-headers-2.4.18-686
The KDREV option is the version of the kernel you want this ALSA package to recommend, you can probably get this version number from the command (assuming you have a 2.4.18-686 kernel):
dpkg -l kernel-image-2.4.18-686
The KVERS option is the kernel version, you can get this with the command:
uname -r
So, your command for a 2.4.18-686 kernel might look something like: <p> ./debian/rules KSRC=/usr/src/kernel-headers-2.4.18-686 KVERS=2.4.18-686 KDREV=2.4.18-5 binary-modules
When it finishes building, you'll have a .deb sitting in /usr/src/modules, su to root and install this:
su -
password:
dpkg -i /usr/src/modules/alsa-modules-*
Please note that alsa-source versions below 0.9.0rc5-2 have a bug in it, it installs the modules into /lib/modules/alsa. If this happens to you please mv /lib/modules/alsa/* /lib/modules/<kernel version>/alsa/. and run depmod -A before proceeding, i.e.:
mv /lib/modules/alsa/* /lib/modules/2.4.18-686/alsa/.
depmod -A
Setting Things Up
Well, if you've made it this far the hard part is behind you, if you used a kernel with ALSA modules built in or apt-get install'd a package of the modules, consider yourself lucky.
First we need to install the alsa-utils package, copy a file and create a symlink:
apt-get install alsa-utils
cp /usr/share/doc/alsa-base/examples/modules-0.9.conf /etc/alsa/modutils/0.9
ln -s /etc/alsa/modutils/0.9 /etc/modutils/alsa
Now edit /etc/alsa/alsa-base.conf with your favorite editor, it should look something like this:
# This is a configuration file for alsa-base.
# Define true if you want the OSS compatibility layer
# to be automatically loaded as well
startosslayer=true
# Define true if you want to unload alsa modules before
# your system suspneds. This is currently useful if your
# machine is hanged up after resume.
force_stop_modules_before_suspend=false
# Uncomment if you always want to stop alsa modules forcibly in
# /etc/init.d/alsa stop or restart by killing all of running
# applications which use sound devices.
ALSA_KILL_MODE="force"
Make sure that startosslayer is set to true, and any other options set how you like.
Next, we edit the /etc/modutils/alsa file, it should look something like this:
Note that as of version 0.9.0rc5 the snd_ prefixes on the module options have been dropped, so follow the example file and ignore the snd_ prefixes on the options in the third uncommented line of the example below.
# Example Configuration of ALSA 0.9 for Debian GNU/Linux
alias char-major-116 snd
alias char-major-14 soundcore
options snd snd_major=116 snd_cards_limit=4 \
snd_device_mode=0660 snd_device_gid=29 snd_device_uid=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
#alias snd-card-0 snd-dummy
#alias snd-card-1 snd-serial
#alias snd-card-2 snd-share
#alias snd-card-3 snd-virmidi
alias sound-slot-0 snd-card-0
alias sound-slot-1 snd-card-1
alias sound-slot-2 snd-card-2
alias sound-slot-3 snd-card-3
# You must need to add your own card setteings below.
# or use alsaconf to setup in menu form.
Edit the 3rd uncommented line in this file and change snd_cards_limit=4 to snd_cards_limit=1 if you only have one sound card to avoid annoying error messages on boot up. Next, edit the line
#alias snd-card-0 snd-dummy
Change snd-dummy to the module of your sound card (i.e. snd-maestro3) and uncomment the line.
Now run as root:
update-modules
/etc/init.d/alsa start
Your ALSA modules should load, and this script will run automatically on boot up and shutdown, it'll save your mixer levels on shutdown and restore them on boot up.
Mission Accomplished
You should now have sound and it's all setup correctly using the Debian script. If you installed using a kernel that had the ALSA modules in it, used the make-kpkg command or apt-get install'd the modules, it shouldn't of been too hard, but if you compiled the modules into a deb you've done the most work out of the possible scenarios. Now sit back, relax and crank up some tunes in xmms, enjoy! |
|