next up previous
Next: Bringing your hat up Up: Installing Planet CCRMA on Previous: Installing apt (Advanced Package

Subsections



Installing the kernel and sound drivers

The kernel is the core of linux and provides all services that programs need to interface with the hardware.

The Planet CCRMA package collection distributes two kernels. The Planet CCRMA kernel includes several patches that enhance low latency and real time performance. It is normally based on the original Linus kernel and the number of added patches added to it is quite low. This kernel is the one that has the best low latency performace but it may happen that it cannot run in your hardware (or has problems). Why? The original RedHat kernel that was installed during the RedHat install is heavily patched. RedHat adds quite a number of fixes for problems it finds and new drivers and those patches are not present in the original Linus kernel or the Planet CCRMA kernel. On the other hand the Planet CCRMA kernel is usually based on much newer versions of the Linux kernel than the patched RedHat kernel, so some or all those fixes might be already included! I know, it is confusing...

As this has been a problem in some occassions I'm including a RedHat kernel with matching alsa drivers based on the latest released official RedHat kernel. The only difference is that it has capabilities enabled and thus can be used to run Jack with realtime priority as a normal non-root user. So, if you have been able to install RedHat in your machine you should be able to boot into this kernel without problems.

You can choose. The Planet CCRMA kernel is the best choice if it runs well on your hardware. Otherwise install the RedHat kernel with capabilities (the RedHat kernel includes a partial low latency patch so all is not lost :-)

The current Planet CCRMA kernel rpms are version 2.4.26-1.ll. The RedHat kernel rpms are version 2.4.20-31.1.caps. The ALSA sound driver rpms for all kernels are version 1.0.4-1.cvs, extracted from CVS on 20040417.103251.

This assumes you have RedHat 7.3, 8.0, 9 or Fedora Core 1 installed and that you are using the grub boot loader (it is the default).

[Note: don't forget to do an ``apt-get update'' before starting a new session of apt-get install or upgrade commands]


Installing the kernel and sound drivers

  1. create an emergency boot floppy. Most probably you already have one. Make sure it is in working condition and that you can use it to boot the machine. It can help you recover from mistakes and is good to have in any case.

    Make sure you have an empty formatted floppy in the drive and type:

    mkbootdisk kernel_version

    See the mkbootdisk man page for details. To find out what is the kernel version you are currently running type ``uname -r'', the result of which should be the argument to mkbootdisk. Make sure you can indeed boot from the bootdisk.

  2. install the kernel and sound driver packages. If your machine has only one processor and you want to install the Planet CCRMA kernel type:

    apt-get -o RPM::Install-Options::=--oldpackage install planetccrma-core

    If you have a machine with multiple processors you probably want to install the multiprocessor kernel and alsa sound drivers in addition to the single processor versions. Installing this package will install both Planet CCRMA kernels:

    apt-get -o RPM::Install-Options::=--oldpackage install planetccrma-core-smp

    If you want to install the RedHat kernel with capabilities type:

    apt-get -o RPM::Install-Options::=--oldpackage install planetccrma-core-redhat

    Or type this for a machine with multiple processors:

    apt-get -o RPM::Install-Options::=--oldpackage install planetccrma-core-redhat-smp

    Of course you can install both kernels and choose which one to boot from at the grub prompt.

  3. reboot the machine to test the kernel (do you have the emergency rescue floppy handy?). Reboot the machine and select the new kernel when the grub prompt appears. The kernel should hopefully boot cleanly. If you have problems you can always reboot and choose the original kernel instead.

    Note for laptop users and the Planet CCRMA kernel: after rebooting into the new kernel make sure that the cooling fan starts working when you start using the machine. The new kernel includes the latest ACPI (Advanced Configuration and Power Interface) at that should make power management work on newer laptops, but I have seen one laptop that did not like the ACPI enabled kernel and had to be rebooted with acpi turned off for the fan to work. Go figure...

    To turn ACPI off edit the /boot/grub/grub.conf file and add ``acpi=off'' at the end of the kernel line that corresponds to kernel 2.4.26-1.ll, and reboot the machine.

  4. edit your grub configuration file. The kernel installation process automatically adds the new kernel to the grub configuration file. If you want to make the new kernel the default kernel on boot you have to edit the /boot/grub/grub.conf file and change the ``default='' line to point to the first kernel, which should be the one that just got installed (so the line should read ``default=0'').

  5. [OPTIONAL] install the kernel source. If you need to compile extra kernel modules (for example for a modem, a display driver, etc) you will need the kernel source and headers that correspond to the kernel you are running, in this case the Planet CCRMA kernel (or the RedHat kernel with capabilities enabled). The kernel source is in itself an rpm, install it by typing:

    apt-get install kernel-source#2.4.26-1.ll.rh90.ccrma

    (or .rh80 or .rh73 if you are running RedHat 8.0 or 7.3, or rhfc1.ccrma if you are running Fedora Core 1). or type this for the RedHat kernel:

    apt-get install kernel-source#2.4.20-31.1.caps.rh90

    The source will be installed in /usr/src/linux-2.4.26-1.ll (or 2.4.20-31.1.caps), the software you are compiling might be smart enough to discover its location. If it is not, you may have to create a link from /usr/src/linux to /usr/src/linux-2.4.26-1.ll. To do that type:

    ln -s /usr/src/linux-2.4.26-1.ll /usr/src/linux


Configuring the alsa sound driver

At this point you are ready to configure alsa. If your sound card is a PCI card and it is supported by ALSA then most probably it will possible to configure it by using alsaconf:

  1. the easy way: the alsaconf script: the alsaconf script is a very simple configurator that is part of the alsa-driver package and will probably be able to recognize the card you have installed and write a matching /etc/modules.conf configuration file for it.

    Type ``/usr/sbin/alsaconf'' in a terminal window and follow the prompts (when it asks whether you want to modify the configuration answer ``yes''). The last steps (starting the alsa sound drivers and playing a test soundfile) may fail because you probably have the oss kernel modules for your soundcard loaded at this point (the alsa kernel modules cannot load if the oss kernel modules are loaded and using the soundcard).

    Caveat: alsaconf will not automatically detect USB soundcards. If you have a USB card you also probably have another soundcard in your motherboard, so you probably want to read through the rest of the instructions (I know it is boring reading but go through it anyway), and then go to the section on configuring multiple soundcards. Also read the extra instructions for USB soundcards.

    Caveat: if alsaconf succeded in configuring your soundcard and you want your sound modules to stay loaded at all times add these couple of lines at the very end of the /etc/modules.conf file that was changed by alsaconf:

    # -- Keep modules from being autocleaned
    add options -k snd-card-0

    RedHat has an autoclean process that runs every 10 minutes and removes kernel modules that have not been used for a while.

    If alsaconf succeeded in configuring your card and you heard the sample sound play back from your setup you can jump to the section that deals with configuring the mixer so that you can double check the settings.

    If the card was detected and configured but you heard no sound (assuming the audio connections are fine), then most probably the ALSA drivers could not be loaded because you still have the OSS drivers loaded. In that case jump to the section that deals with unloading the oss drivers, otherwise go ahead with the rest.

If alsaconf was not successful in detecting your card then you can try to do the configuration process manually:

  1. find out which sound chipset your soundcard is using. What is important here is to know the chipset the card is using so that you can select the proper alsa kernel sound driver that supports it. In general the commercial name of the soundcard is not always helpful, as it does not have a reference to the chipset actually used in the soundcard. If the card is a PCI soundcard do an 'lspci -v' to list all available pci devices. The list will most probably include a reference to a multimedia audio device: that is your soundcard. For example this is what lspci says about an Ensoniq AudioPCI soundcard:

    If you don't have /sbin/lspci install it by doing:
    apt-get install pciutils

    02:0b.0 Multimedia audio controller: Ensoniq ES1370 [AudioPCI]
            Subsystem: Unknown device 4942:4c4c
            Flags: bus master, slow devsel, latency 64, IRQ 10
            I/O ports at 4080 [size=64]
    

    You could now have a look at the ALSA soundcard matrix to find out which driver name can be used for the chipset you found. If you found the name of the module you have to use, jump to the section on configuring your /etc/modules.conf file.

    You can try searching for the module in the modules directory tree for your kernel. In this example the chipset is probably the es1370. Looking through the available sound modules we find the following (substitute the version of the kernel in all examples with either 2.4.26-1.ll for single processor machines or 2.4.26-1.llsmpfor multiprocessor machines):

    # find /lib/modules/2.4.26-1.ll.rh90.ccrma/ -name \*1370\*
      /lib/modules/2.4.26-1.ll.rh90.ccrma/kernel/drivers/sound/es1370.o
      /lib/modules/2.4.26-1.ll.rh90.ccrma/kernel/drivers/sound/pci/snd-ens1370.o
    

    Of the two kernel modules found the one that interests us is the second (because alsa drivers always start with snd-). The other module one is the OSS Free driver that is included with the standard kernel.

    Another, more complicated example. Here is the lspci -v output for a Midiman Delta 66:

    03:05.0 Multimedia audio controller: IC Ensemble Inc ICE1712 [Envy24]
            Subsystem: IC Ensemble Inc: Unknown device d632
            Flags: bus master, medium devsel, latency 32, IRQ 21
            I/O ports at a000 [size=32]
            I/O ports at a400 [size=16]
            I/O ports at a800 [size=16]
            I/O ports at ac00 [size=64]
            Capabilities: [80] Power Management version 1
    

    What is the chipset for this card? It could be envy24 or ice1712. A quick search shows which one is the one:

    # find /lib/modules/2.4.26-1.ll.rh90.ccrma/ -name \*envy24\*
    
    # find /lib/modules/2.4.26-1.ll.rh90.ccrma/ -name \*ice1712\*
      /lib/modules/2.4.26-1.ll.rh90.ccrma/kernel/drivers/sound/pci/snd-ice1712.o
    

    Things are not always that easy as there are some drivers that support more than one closely related chip and thus have a more generic name that is not going to match your chipset number.

    If you have an ISA soundcard that has PNP you can try ``pnpdump'' to try to find out what it is.

    If your card was automatically configured to work under RedHat with the OSS Free sound drivers then look at your current /etc/modules.conf file. There will be an entry for the OSS Free module that will also give you a clue of the chipset involved. Look for a similarly named module that starts with ``snd-'' instead.

  2. configure the /etc/modules.conf file. This file links specific kernel module names to the service names the kernel knows (this is not all this file does but it will suffice for now). As a very simple example, it could link the service ``eth0'' to the kernel driver module for the particular ethernet card you have installed in your computer. Modifying this file is easier said than done. This is an example of what you could add to it to enable an ens1370 based soundcard (like the SoundBlaster PCI128):

    # --- ALSA configuration
    alias char-major-116 snd
    alias char-major-14 soundcore
    alias snd-card-0 snd-ens1370
    #--- OSS compatibility alias
    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
    #--- Options 
    options snd major=116 cards_limit=1 \backslash
      device_mode=0666 device_gid=0 device_uid=0
    options snd-ens1370 index=0 id=SBPCI128
    #--- Keep modules from being autocleaned
    add options -k snd-card-0
    #--- ALSA configuration END
    

    For other cards use this as a template and replace ``snd-ens1370'' with the name of the module that handles your soundcard.

    Don't forget to disable any lines in /etc/modules.conf that correspond to the oss sound driver kernel modules.

    [TODO: how to find which lines to comment out, maybe not necessary as alsaconf is now doing that automatically]

    After you are done editing the file, use depmod to parse it again and determine module dependencies:

    /sbin/depmod -a

  3. unload any oss sound driver modules. If the oss drivers were correctly configured by the RedHat installation you most probably have them loaded into the new kernel at this point (even if you changed the modules.conf configuration file to not load them in the future, they are probably still there - well, most probably, it could be that they have been autocleaned since they were loaded). Check to see if you still have them by doing an '/sbin/lsmod'. If you do, remove them with '/sbin/rmmod module_name'. If you don't unload them the alsa driver will not be able to start because the oss driver will be using the hardware resources associated with your soundcard.

  4. start the alsa sound driver. At this point you are ready to start the alsa sound driver. The alsa-driver rpm installed a sound startup script in /etc/rc.d/init.d/alsasound. Execute the script with the 'start' parameter:

    /etc/rc.d/init.d/alsasound start

    If everything is fine you should see the familiar [OK] startup aknowledgements from the script and the sound driver kernel modules should load.

  5. configure the alsa mixer. If the modules loaded successfully it is time to configure the alsa mixer (provided your soundcard has one). By default alsa mutes all channels and sets the volume to '0' for all of them. Start the command line alsamixer program and unmute (press 'm') and change the volume of the channels you are interested in (use the arrow keys to navigate and change volume). Try to keep most channels muted if you are not using them, unmuted and unused channels in analog cards only add noise to the main outputs. Exit alsamixer by pressing the ``Esc'' key. If you have an ice1712 based card you could also use the nicer envy24control GUI tool (part of the alsa-tools package) to configure its internal digital mixer.

  6. make the mixer configuration permanent. When you are happy with the mixer configuration you can use the alsactl program to store the mixer configuration to a file. Type:

    /usr/sbin/alsactl store

    This will write a file to /etc/asound.state that contains all the current settings of the mixer. It is a readable ASCII file that you can also change with your favorite text editor.

    Alsactl can also restore a previously stored configuration (this is automatically done by the alsa sound startup script):

    /usr/sbin/alsactl restore

  7. test the driver. Are you feeling lucky today? (TM). You can try to play a stereo wav soundfile. For now use aplay, which is a program that is part of the alsa-utils packages and should be able to play correctly in all supported soundcards. Use the following incantation:

    aplay -device="plughw" soundfile.wav

    ``aplay'' is an example program and only understands .wav files so it will not be able to play any other format.

  8. [OPTIONAL AND DANGEROUS] remove the oss mixer save shutdown code.

    [WARNING]: skip this step if you are not confortable editing files! It is possible to mess up the shutdown procedure if you make a mistake while editing this critical system file.

    The halt script lives in /etc/rc.d/init.d/halt. These are the lines I comment out, they try to save the state of the oss mixer, that does not make sense for the alsa drivers (which have their own program to save and restore mixer settings).

    # Save mixer settings, here for lack of a better place.
    grep -q "\(sparcaudio\|sound\)" /proc/devices
    if [ $? = 0 -a -x /bin/aumix-minimal ]; then
       runcmd $"Saving mixer settings" /bin/aumix-minimal -f /etc/.aumixrc -S
    fi
    

    Just comment the previous lines out (put a ``#'' at the beginning of each line).

  9. configure the startup script to execute at boot time. Woohoo! You're almost ready to go now! The only thing left that I can think of is making sure that the sound driver is started and stopped when the machine boots and shuts down. For that use the chkconfig utility to add the alsasound script to the proper run levels:

    /sbin/chkconfig --add alsasound

    If you want, you can check that the script was added by doing:

    /sbin/chkconfig --list alsasound

    At this point you should be able to reboot your computer and have the alsa sound driver start automatically.


Configuring USB sound cards

There are some caveats when dealing with USB soundcards. Alsaconf will not detect them automatically. The ALSA kernel module name for USB soundcards is ``snd-usb-audio'' (you can take the modules.conf template for single cards and use snd-usb-audio for the kernel module name).

  1. The USB startup code runs very early in the boot sequence, before the alsasound startup script gets a chance to run. So you have to disable the automatic load of OSS USB modules that will be detected by the hotplug subsystem. To do that add these two lines to the ``/etc/hotplug/blacklist'' file:

    audio
    usb-midi

    This will disable only the USB OSS drivers. You can also add:

    snd-usb-audio

    so that your USB soundcard will be started with the rest of the ALSA soundcards (if there are more). Otherwise hotplug will start it early in the boot sequencer (but there's no harm in that).


Configuring multiple sound cards

If you have multiple sound cards you will need to manually edit your /etc/modules.conf file to add the proper kernel modules for all of them so that the alsa startup script will load them all.

  1. find the kernel modules that correspond to your sound cards The easiest way to do this is to use alsaconf multiple times. Alsaconf will scan your pci bus and present you with a choice of soundcards to configure. Repeat the configuration for all your cards, one at a time, and each time write down the kernel module name that alsaconf selected for your card (it will be written to your /etc/modules.conf file in the ``alias snd-card-0'' line).

    Alsaconf will not find USB soundcards. If your second (or first) card is a USB soundcard then the name of the corresponding kernel module is ``snd-usb-audio''.

  2. modify your modules.conf file to include multiple cards You can use this as a template:

    # -- ALSA configuration
    alias char-major-116 snd
    alias char-major-14 soundcore
    alias snd-card-0 snd-CARD_0
    ...
    alias snd-card-N snd-CARD_N
    #-- OSS compatibility alias
    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
    ...
    alias sound-slot-N snd-card-N
    alias sound-service-N-0 snd-mixer-oss
    alias sound-service-N-3 snd-pcm-oss
    alias sound-service-N-12 snd-pcm-oss
    #-- Options
    options snd major=116 cards_limit=N+1
    device_mode=0666 device_gid=0 device_uid=0
    options snd-CARD_0 index=0
    ...
    options snd-CARD_N index=N
    #-- Keep modules from being autocleaned
    add options -k snd-card-0
    ...
    add options -k snd-card-N
    #-- ALSA configuration END

    In this template ``...'' stands for more lines here, one for each extra card (don't copy the dots! :-) ``CARD_N'' is the name of the kernel module that corresponds to the card you want in position ``N'' (N=0 is the first card, usually the default device used by all programs). ``N+1'' is the total number of soundcards in your system. Just fill in the kernel module names that corresponds to your cards. Please note that the OSS section for the first card (the ``sound-service-*'' part) is different than the ones for subsequent cards. The OSS sequencer lines have to appear only once, there is only one sequencer for all midi ports in the system.

    Here is a filled in example that includes three cards (the last one being an USB soundcard).

    # --- ALSA configuration
    alias char-major-116 snd
    alias char-major-14 soundcore
    alias snd-card-0 snd-ice1712
    alias snd-card-1 snd-ens1370
    alias snd-card-2 snd-usb-audio
    #--- OSS compatibility alias
    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
    alias sound-slot-1 snd-card-1
    alias sound-service-1-0 snd-mixer-oss
    alias sound-service-1-3 snd-pcm-oss
    alias sound-service-1-12 snd-pcm-oss
    alias sound-slot-2 snd-card-2
    alias sound-service-2-0 snd-mixer-oss
    alias sound-service-2-3 snd-pcm-oss
    alias sound-service-2-12 snd-pcm-oss
    #--- Options 
    options snd major=116 cards_limit=3 \backslash
      device_mode=0666 device_gid=0 device_uid=0
    options snd-ice1712 index=0
    options snd-ens1372 index=1
    options snd-usb-audio index=2
    #--- Keep modules from being autocleaned
    add options -k snd-card-0
    add options -k snd-card-1
    add options -k snd-card-2
    #--- ALSA configuration END
    

  3. update the module dependencies After you are done editing the file, use depmod to parse it again and determine module dependencies:

    /sbin/depmod -a

  4. configure the mixer for all cards If you are using ``alsamixer'' then the ``-c'' option followed by ``N'' (the card number) will start alsamixer pointing at the proper card. Once you are done configuring your mixers you can save the whole setup with ``/usr/sbin/alsactl store'', just as outlined for single cards.

  5. restart the alsa sound driver. At this point you are ready to restart the alsa sound driver. First stop the sound driver:

    /etc/rc.d/init.d/alsasound stop

    Then start it again:

    /etc/rc.d/init.d/alsasound start

    It should load all the modules for all your soundcards.


next up previous
Next: Bringing your hat up Up: Installing Planet CCRMA on Previous: Installing apt (Advanced Package

© Copyright 2001...2005 Fernando Lopez-Lezcano, CCRMA, Stanford University.
All rights reserved.