ALSA under Vector Linux 5.9

ALSA stands for Advanced Linux Sound Architecture. An ALSA driver may work for your soundcard if you can not get sound to work otherwise. Unfortunately, ALSA is complicated, and it may be especially so for Linux and/or VL newcomers.

CONTENTS
1. INFORMATIONAL SEARCH
2. GET ALSA SOURCE
3. COMPILE YOUR VL KERNEL FROM SOURCE
4. ALSA INSTALLATION
5. SETTING UP AND TESTING ALSA
6. TELL VL TO INSERT YOUR ALSA MODULES AUTOMATICALLY AT BOOT

1. INFORMATIONAL SEARCH

Step 1 is a very thorough informational search.

a. Try to establish if ALSA will even work for your particular soundcard. It's useless to continue unless you can determine for sure that some specific ALSA driver will work with your card. There may not even be one, but if there is, you need to know which one. (See 1.c below). Your first stop should be:

the ALSA site -- http://www.alsa-project.org

Look under "New Users." There you will find a page devoted to the sound cards ALSA supports, but also use search engines if that fails. In my case, the ALSA site did not list my card, but I found out that I could use it under another ALSA driver name. I found that the most helpful search keywords were the name of my soundcard, "ALSA," and "slackware" (VL is slackware-based).

b. You must also read about (and save for future reference) the settings that you will need once ALSA is actually running. The installation instructions for each driver at the ALSA web site include this information. These settings automatically insert the ALSA modules and set things properly at boot, once you have everything running by hand. The information for my driver was good, but I also found even more information specific either to my card or to a slackware-based distro at other places. Also, the information at the ALSA site made more sense after reading other people's postings.

c. If your search fails, the whole process outlined here is too complex, or it's just not worth your time, and you have $20 US, then you might try http://www.4front-tech.com/. They recommend you first download as a free trial to see if they have what you need to get sound working quickly.

2. GET ALSA SOURCE

Now get the ALSA source files, available at the ALSA site above. You will need at least the driver, lib, and utils (you may or may not need oss and tools - determine this through your research). The main page will list the current release. Clicking on "0.94" (or whatever the current number is) for each part of ALSA should enable you to save the source files for each element to your hard drive.

3. COMPILE YOUR VL KERNEL FROM SOURCE

In order to configure itself correctly, ALSA needs to see certain kernel configuration files. The precompiled VL kernel that came with your distro is "clean" and no longer has some of these files. This means that before you can successfully compile ALSA under VL, you first need to do something that may seem intimidating. You must (re)compile your VL kernel from source.

a. Do not panic. First, a VL Kernel Compilation Howto exists.


Second, VL, and #3 in VLK, have been set up so that recompiling the kernel from source is a completely mechanical process that automatically gives you, in every detail, exactly the same working VL kernel that you have now, unless you consciously and deliberately change something. You won't break a thing, guaranteed.

b. However, before you even think about beginning, there is one step in VLK that you should study carefully first. So open (but NOT as root, so you can't do any damage) in your favorite text editor the file /etc/lilo.conf. Among other things, the /etc/lilo.conf file tells Linux where it can find a Linux boot image. Study the lines toward the bottom. Compare these lines to #13 in VLK. You will shortly be making another kernel in addition to the one you have now, keeping both. You will also keep the ability to boot into your old kernel just in case.

Make sure you understand in VLK #13 exactly how you will alter your own /etc/lilo.conf after you compile the new kernel, to give it two separate sets of Linux boot instructions. The first (your new kernel) will be with image = /boot/vmlinuz and label = linux, the second (your old kernel) with image = /boot/vmlinuz.old and label = linuxold. Note also that VLK #13 uses mcedit, but that (when you get to #13 for real) you can use any text editor you like to alter /etc/lilo.conf. After studying /etc/lilo.conf, close it.

c. You must obtain the source files from http://www.kernel.org , but you need to know your kernel version first. So open a terminal and type "uname -r" (everything except the quotes). The output will be something like "2.4.20-pent-ide." The series of numbers (in this case, 2.4.20) is your kernel version. That's the version you need to download from kernel.org. The file will be named something like "linux-2.4.20.tar.bz2," that's the kind you want. You can download the kernel source to any convenient location.

d. After this is done, open a terminal (or use the same one if it's still open), and cd to the directory where you downloaded the kernel source. Now type "su". At the prompt, give your root password. You have become (in this terminal) the superuser. You should remain the superuser throughout the kernel compilation.

This next little bit may or may not be necessary immediately, but it will be eventually. Doing it now won't hurt anything and might help. So (still as root) type "nedit [or the path and name of your preferred text editor] /etc/rc.d/rc.modules". This is a long file, almost all commented out. Scroll down until you see something like this line:

### Sound support ###

In this Sound support section, comment out (add a # to the beginning of) any uncommented line that wants to "/sbin/modprobe [some soundcard]". Just after that section ends, insert these lines:

# alsa sound
/sbin/modprobe soundcore
/sbin/modprobe snd-intel8x0

replacing "snd-intel8x0" with your driver name.

e. At this point you can begin to follow the instructions given in VLK. Note that you will have to change the kernel version number appropriately if it varies from VLK, but otherwise you can and should follow VLK precisely. Hint: you can just copy and paste the commands from VLK into your terminal window to save typing and avoid errors. Just follow the instructions exactly until you get to VLK #4, "make menuconfig" or "make xconfig." Then go to the next section here.

NOTE re VLK #3."cp /boot/.config ./"

In VL 4.0, the name of the file /boot/.config has been changed to /boot/config (without the period). Look in /boot, see which is which, and change this step if needed to:

cp /boot/config ./

f. Assuming you are in X anyway, for VLK #4, type "make xconfig" instead of "make menuconfig." After a few seconds, the xconfig screen will appear.

g. You're officially at VLK #5: "now change the options you want to change." Look for the "Sound" tab in xconfig and click it. This is the only stuff you need to change to run ALSA. Remember, if you just ignore everything else within every other configuration tab, that's exactly right: you'll retain the kernel settings you have now.

h. Here, within the Sound support tab, it couldn't be more simple. The very first button will say, "Sound card support." All you have to do make sure the "m" button is set here. That's it. Now go down through ALL the remaining options in the sound section and make sure that absolutely everything else is "n." So: "Sound card support" is "m," absolutely everything else is "n." That's it!

i. Then click on the "Main Menu" tab at the bottom of the Sound section to return to the Main Menu. Now, as per VLK #6, click on "Save and Exit" in order to save your change and exit. You'll be given the information that your next step is to "make dep," which not by chance is VLK #7.

j. So now, go on through all the remaining steps in VLK, beginning with where you left off, #7, "make dep," up to and including VLK #15, "reboot," where you get the ultimate check on your work. Use your work in 3.b above to remind yourself what to do in VLK #13.

k. Be prepared to wait. On very old machines, kernel compilation sometimes literally took days. Even on a very fast machine of today, it can still take many minutes.

l. If the reboot was NOT successful, reboot again and this time select the old kernel and try compiling again. Remember that all you basically did is recompile a kernel that already works on your machine. If the new kernel doesn't work, it is highly likely that you made a typing or other clerical error the first time, and highly unlikely that there's something really wrong.

4. ALSA INSTALLATION

The truly hairy part is over, and ALSA should now configure and install fine under VL. However, the steps now become more specific to your soundcard, thus more dependent on the specific information you have gathered (and more apt to fail from a lack of knowledge on your part). In particular, you should have the ALSA installation web page for your driver readily available. Do the following steps as a regular user, not as root, until told differently.

a. DECOMPRESSING THE ALSA SOURCE FILES. In a terminal window, cd to the directory where you have saved the ALSA source files. For example, in that directory, when you type "ls alsa*", you should see, alsa-driver-0.9.4.tar.bz2 (or whatever the revision number is), and equivalent lib, and utils files, as well as oss and tools if you have and need them. Decompress each in turn with the following commands. Type them exactly, literally as they are here:

tar vxjf *driver*
tar vxjf *lib*
tar vxjf *util*

and if your research has determined these to be necessary:

tar vxjf *oss*
tar vxjf *tools*

b. CONFIGURING THE DRIVER. This is soundcard specific and depends on the information you have gathered. In my case, I knew that the "intel8x0" driver would work for my soundcard. So I followed the installation instructions at the ALSA site for its configuration. You may have to type something completely different. Look for and cd to the alsa-driver* directory created when you decompressed the ALSA files, and type what will configure your driver. I had to type:

./configure --with-cards=intel8x0 --with-sequencer=yes

Configuration should begin and proceed without errors. If there are errors, then you have done absolutely everything you could reasonably do, so consider 1.c, above.

c. MAKING THE DRIVER. Now type:

make

Make should begin and proceed without errors. If not, see 1.c.

d. RUNNING checkinstall. Your ALSA instructions will now tell you to type "make install." Under VL, you can do much better. You can run checkinstall instead. Type "su" and give your password. (In almost every case, you must be root to successfully install programs, and ALSA is no exception). Now type "checkinstall." checkinstall will do the "make install" and at the end, allow you to create a Slackware package, so you can easily uninstall or re-install the driver. Accepting all the defaults in checkinstall as they come is fine. Type "S" because you want to make a Slackware (VL) - type package.

e. FINAL DRIVER STEPS. devfs is not run on VL by default, so if you don't know what devfs is or whether you are running it, you aren't. If you are not running devfs, then you should now type:

./snddevices

the following may vary slightly depending on the ALSA installation instructions for your driver. You should find the exact line and type what it says but in general it will look something (or exactly) like the following, which you should now type. It gives all users permission to access the devices:

chmod a+rw /dev/dsp /dev/mixer /dev/sequencer /dev/midi

When you're done, hit CRL-D to go back to being a regular user.

f. LIB, THEN UTILS, ETC. If the driver installs, these are simplicity itself. Do the lib first. For example, as a regular user, cd to the alsa-lib* directory, and type

./configure && make

This will configure and then make the lib. After that, type "su" to become root and run checkinstall for the lib, similar to what you did for the driver. When done, hit CTRL-D and then re-trace your path and do the utils (and oss and tools if needed) in the same way.

5. SETTING UP AND TESTING ALSA


a. Type "su" and become root, if you are not already. Type "lsmod" to see the modules already inserted. The module "soundcore" should be listed. If it is not, then type "modprobe soundcore". If the soundcore module doesn't exist, the only thing for it is to recompile the kernel, this time paying better attention to 3.g - 3.i, above.

Now you will need to insert the modules you have built into the kernel space. Follow your ALSA installation instructions as to what to type. The instructions for the intel8x0 driver directed me to type:

modprobe snd-intel8x0;modprobe snd-pcm-oss;modprobe snd-mixer-oss;modprobe snd-seq-oss

Now type "lsmod" again and you should see (a lot of) ALSA modules.

b. Moment of Truth time. Try stopping and starting the alsasound daemon. Type the lines in quotations, without the quotation marks. Depending on your driver, the outputs should look something like this, and if they do, that's a very good sign:

"su"
Password:
[type your root Password]
"/etc/rc.d/init.d/alsasound stop"
Shutting down sound driver: done
"/etc/rc.d/init.d/alsasound start"
Starting sound driver: snd-intel8x0 done

c. Still as root, type "alsamixer". Use the left and right arrows to get around, up and down arrows to raise volume. There will be more settings than you can see at any one time. Keep hitting the right arrow until you really stop. Hit "M" to unmute a column (this will eliminate the "MM" at the top of the column). You must unmute at least some channels and raise some volumes, especially the Master, or you won't hear anything! Hit ESC to exit.

d. Moment of Truth time, part 2. Now see if you can hear anything. If you know where a good soundfile is, type "aplay [path and name of your soundfile]". If not, type "ls /usr/share/sndconfig/sample.au". If the file exists, then type "aplay /usr/share/sndconfig/sample.au". If your speakers are connected and functioning, you should hear Linus Torvalds speaking. If that file doesn't exist, try to find some .wav sound file (include the quotation marks in your typing) or an .au sound file somewhere:

find / -name "*.wav"
find / -name "*.au"

e. I can't help you if you do not (finally, actually) hear sound with "aplay [your soundfile]" at this point - I've done my best. But if you do hear sound, then you should have ALSA sound on every sound device, as long as you have unmuted the channel and pumped some volume in. You have already set your CD and whatever else with alsamixer to your satisfaction, haven't you? If not, then go back to 5.c and try again. Once you have completed 5.c to your satisfaction and ESC'd alsamixer, then (still as root) type "alsactl store". This saves (stores) your mixer settings to the file /etc/asound.state.

6. TELL VL TO INSERT YOUR ALSA MODULES AUTOMATICALLY AT BOOT

a. MODIFYING /etc/modules.conf. The ALSA installation page for your driver will tell you most of what to add to /etc/modules.conf. You can alter that advice IF you found more relevant information elsewhere. In a terminal, type "su" and give your root password. Then type:

"cp /etc/modules.conf /etc/modules.conf.backup" -- saves your original in case you mess up
"nedit /etc/modules.conf" -- replace the word "nedit" with the name and path of your preferred text editor.

This allows you to edit /etc/modules.conf, which only root can do. Do not erase any lines! Just put a comment (#) in front of them so that VL will ignore them. Find and comment out the lines (if any) that refer to "sound-slot-0," which VL tried to configure for you. Here are the lines that were in my file, now commented out:

#alias sound-slot-0 i810_audio
#post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || :
#pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || :

Insert the ALSA lines recommended for your card after the lines you just commented out. If you don't seem to have any sound lines, just add the lines to the end. These lines might look something like mine (my ALSA driver is "snd-intel8x0"):

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-intel8x0

# 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

b. In 5.e, above, you saved your mixer settings in /etc/asound.state. Now add the following 4 lines to /etc/modules.conf, after the ALSA lines, replacing "snd-intel8x0" with the name of your ALSA driver. These lines tell VL to set up the sound at boot to be in the state you just saved (which means you'll hear sound):

# restore mixer settings from /etc/asound.state
post-install snd-intel8x0 /usr/sbin/alsactl restore
# Save mixer settings to /etc/asound.state
pre-remove snd-intel8x0 /usr/sbin/alsactl store

c. Save your work and close the text editor.

d. Hit CTRL-D to become a regular user again. If all went well, you should be all done and you should have a basic configuration of ALSA sound now and in the future.