Skip to content

Instantly share code, notes, and snippets.

@thomasn
Created November 12, 2008 17:09
Show Gist options
  • Save thomasn/24209 to your computer and use it in GitHub Desktop.
Save thomasn/24209 to your computer and use it in GitHub Desktop.

Search: Gentoo Wiki

HOWTO_ALSA

Contents

Introduction

This document explains how to install ALSA with built-in kernel drivers. A seperate section exists for using the alsa-driver package. Most of this document is already covered in the default Gentoo documentation, however, the aim here is to be more complete, and to provide a basis for using multiple sound cards and alternate configurations.

For alsa-driver, see ALSA/alsa-driver.

This article was merged with what was previously HOWTO ALSA Complete (includes dmix). Some items from that page and the original HOWTO ALSA article may have been omitted for one reason or another. See ALSA/Omitted Items for this information.

Prerequisites

The lspci program is required to identify your sound card in software.

# emerge -av pciutils

Identifying

Use the lspci program to identify any sound cards on your system:

# lspci -v | grep -i audio

The output will mimick:

0000:00:0a.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 06)

This information states the type of device, the brand, model, and potentially the ALSA driver that needs to be used. To verify the driver, go to the ALSA sound card matrix. This information is necessary to build the proper drivers in the kernel.

Kernel Configuration

Refer to the official Gentoo Kernel Configuration Guide on other matters surrounding the kernel and recompilation.

Kernel 2.4 Linux Kernel Configuration: Kernel Configuration

Loadable module support --->
    [*] Enable loadable module support
Device Drivers --->	 
    Sound --->	 
         Sound card Support	 
        Advanced Linux Sound Architecture --->	 
         Advanced Linux Sound Architecture	 
        Open Sound System --->	 
        < > Open Sound System (Deprecated)	 

Be sure to include modules for OSS Emulation support as well as for each sound card in your system. When that is done, build the kernel and install it.

Kernel 2.6 Linux Kernel Configuration: Kernel Configuration

Loadable module support --->
    [*] Enable loadable module support
Device Drivers --->
    Character devices --->
        <*> Enhanced Real Time Clock Support
    Sound --->
         Sound card Support
             Advanced Linux Sound Architecture --->
                 Advanced Linux Sound Architecture
                 Sequencer support
                 Sequencer dummy client
                   OSS Mixer API
                   OSS PCM (digital audio) API
                [M]   OSS Sequencer API
                <*>   RTC Timer support
                [*]     Use RTC as default sequencer timer
                [ ]   Dynamic device file minor numbers
                [M]   Support old ALSA API
                [ ]   Verbose procfs contents
                [ ]   Verbose printk
                [ ]   Debug
                Generic devices  --->
                PCI devices  ---> 
                USB devices  --->
                System on Chip audio support  --->
            < > Open Sound System (DEPRECATED)

Select the drivers for which you wish to build support under the Generic devices, PCI devices and USB devices. Include them as modules.

Recompile and install your kernel.

Post-Installation Configuration

Standard Configuration

ALSA does not usually need to be configured if only one sound card is installed on the system. All necessary modules should be loaded by udev automatically, and dmix is enabled by default. Only follow instructions for editing /etc/modprobe.d/alsa if your sound does not work as expected or multiple cards are used!

/etc/modprobe.d/alsa

First, you'll have to edit /etc/modprobe.d/alsa and configure it specifically for your sound cards and OSS emulation.

Example Configuration

Single Card

Here is an acceptable single card configuration complete with OSS emulation. File: /etc/modprobe.d/alsa (Single Card)

alias char-major-116 snd
alias char-major-14 soundcore

alias snd-card-0 snd-emu10k1
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 /dev/dsp snd-pcm-oss

options snd cards_limit=1
Multiple Cards (Different Modules)

Here is an example of a two card configuration with OSS emulation for each (for cards that use different modules). File: /etc/modprobe.d/alsa (Multiple Cards)

alias char-major-116 snd
alias char-major-14 soundcore

#Card 1
alias snd-card-0 snd-emu10k1
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 snd-emu10k1 index=0

alias /dev/dsp snd-pcm-oss

#Card 2
alias snd-card-1 snd-intel8x0
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

options snd-intel8x0 index=1

alias /dev/dsp1 snd-pcm-oss

options snd cards_limit=2

In the duo card configuration above, the index=0 or index=1 decide the order in which the sound card modules are loaded and as such which card is the first sound card. You'd want to do that in order to have a specific sound card being default. Note that the module doesn't actually have to be loaded to 'reserve' the space. Therefore having index=0 and index=2 will leave space for a third sound card in between should you choose to plug it in.

Now if that doesn't work for some reason, read the ALSA wiki entry for more info. But you can still tamper with the order of module loading. So now we'll tell the kernel which modules to load at boot. Replace the examples with your actual modules. The name of your modules will be prefixed by "snd-".

Note that the order with which you list your cards will be the order that ALSA uses to determine which card will be primary (default), and which will be secondary. File: /etc/modules.autoload.d/kernel-2.6

# /etc/modules.autoload.d/kernel-2.6:  kernel modules to load when system boots.
snd-emu10k1
snd-intel8x0

Now run update-modules to commit the changes to both /etc/modprobe.d/alsa and /etc/modules.autoload.d/kernel-2.6:

#update-modules -f
Multiple Cards (Same Module) FIXME: This section is incomplete

(Please copy the example from the ALSA site)

In this case, you can still choose their index individually. The ALSA documentation has an excellent example on how to achieve that for the USB cards (check your card/module entry in ALSA to see if it has similar functions, if so it works just the same), but in the future udev should make it possible for all cards.

Additional Options

Occasionally the sound drivers need to have additional options set in order to function correctly. Additional options can be specified by adding an options line to the /etc/modprobe.d/alsa file. File: /etc/modprobe.d/alsa (Additional Options)

options snd-hda-intel model=laptop

This option instructs the snd-hda-intel driver that it should mute the laptop speakers when headphones are plugged in.

After editing the file, update-modules will need to be run.

USE-Flags

Your USE-flags need to reflect that you want ALSA support enabled on the ebuilds that support it. Add the alsa and oss USE-flag to enable audio support in these applications. The midi flag is optional, and can be used if a synthesiser is used or midi files will be played.

Note: The oss USE-flag does not build the Open Sound System, it simply enables OSS support in applications that otherwise do not have support for a sound system. ALSA contains OSS emulation by default for these applications.

In this example we add both the alsa and oss USE-flags to our /etc/make.conf. File: /etc/make.conf

USE="alsa oss"

Your packages will need to be rebuild to reflect these new USE-flags:

#emerge --ask --newuse world

Extra Packages

Alsa-lib contains a set of plugins which control software mixing (dmix) among other things.

#emerge -av alsa-lib

Alsa-utils contains a set of applications for controlling your audio, such as a command line mixer, a startup script, a configuration saver, and more.

#emerge -av alsa-utils

Alsa-tools might provide some better functionality for your sound card. If you want to use them, add (this is for sound blaster live card)

ALSA_CARDS="emu10k1"

on /etc/make.conf

then

#emerge -av alsa-tools

Plugins

ALSA > 1.0.14a-r1 supports PCM plugins through the ALSA_PCM_PLUGINS variable. These plugins take a raw sound stream and process it further, adding effects or filtering.

This feature is intended for embedded systems, so that the ALSA footprint can be reduced by installing only the necessary plugins. It is recommended that you leave all plugins on unless you know which plugins are required for your sound card or are willing to experiment with which plugins are optional. See the post from the developer of this feature.

To find what plugins are available with alsa-lib, see the ALSA PCM Plugins section of the ALSA wiki.

Automatic Startup

Add alsasound to the boot or default runlevel.

#rc-update add alsasound boot

You can start alsasound manually by,

#/etc/init.d/alsasound start

User Permissions

Users who want to have access to the sound card need to be in the audio group.

#gpasswd -a username audio

Replace username with the user you wish to grant access. If you are adding your user to the group, remember that you must log out and back in before the changes will take effect.

Setting the Mixer

Either log into a desktop environment of choice and edit the mixer levels there, or:

#alsamixer -c (card number)

Specify your card number on the command line. ALSA sound cards start with 0, so 0 is the first card, and 1 is the second card.

Adjust the Master and PCM settings for each card to around 80%. Setting to above this level may cause distortion.

For digital audio output, verify a setting for SPDIF is set to ON and/or the volume level is sufficiently raised.

Lastly, save your settings:

#/etc/init.d/alsasound save

Finish

Your default ALSA configuration without dmix is now complete. Note that it is not at all necessary to continue with a dmix configuration unless you have a specific reason to do so, especially considering that both KDE and GNOME provide ways of doing software mixing. For the basic user, your ALSA installation is now complete.

Advanced dmix Configurations

The following instructions should only be used if

  • The sound card does not support hardware mixing (uses dmix plugin)
  • An application does not work with ALSA with it's default settings

For the normal user, these instructions should not be followed.

See ALSA/Omitted Items for information related to further configuring the dmix plugin.

Many applications will need to be redirected to the dmix plugin, especially if they are older, or have not changed their ALSA support to include dmix.

See ALSA/Software dmix Configurations.

Troubleshooting

If you get errors about entry points in kernel modules missing, such as:

snd_timer: Unknown symbol snd_info_register

check the very first dmesg error that contains the string "snd". If that is

snd: Unknown parameter `device_mode'

comment out or delete any lines in /etc/modprobe.conf, /etc/modules.conf and /etc/modules.d/alsa that mention device_mode, then try

modprobe -a snd
/etc/init.d/alsasound stop
/etc/init.d/alsasound start

again. Perhaps other obsolete cruft in the conf files can cause similar problems.

Gnome Relevant Alsa Package

If you want to use gnome based alsamixer:

# emerge gnome-alsamixer

If you want to use panel button to adjust sound volume:

# emerge gnome-applets gnome-media

Retrieved from "http://www.gentoo-wiki.info/ALSA/Install"

Category: Subpages


Browse categories > Gentoo Linux Wiki > Subpages


Last modified: Sun, 28 Sep 2008 07:59:00 +0000 Hits: 59,113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment