**Search:** **[Gentoo Wiki][1]** # HOWTO\_ALSA ## Contents * [1 Introduction][2] * [2 Prerequisites][3] * [3 Identifying][4] * [4 Kernel Configuration][5] * [4.1 Kernel 2.4][6] * [4.2 Kernel 2.6][7] * [5 Post-Installation Configuration][8] * [5.1 Standard Configuration][9] * [5.2 /etc/modprobe.d/alsa][10] * [5.2.1 Example Configuration][11] * [5.2.1.1 Single Card][12] * [5.2.1.2 Multiple Cards (Different Modules)][13] * [5.2.1.3 Multiple Cards (Same Module)][14] * [5.2.1.4 Additional Options][15] * [5.3 USE-Flags][16] * [5.4 Extra Packages][17] * [5.5 Plugins][18] * [5.6 Automatic Startup][19] * [5.7 User Permissions][20] * [5.8 Setting the Mixer][21] * [6 Finish][22] * [7 Advanced dmix Configurations][23] * [8 Troubleshooting][24] * [9 Gnome Relevant Alsa Package][25] ## 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][26]. This article was merged with what was previously [HOWTO ALSA Complete (includes dmix)][27]. Some items from that page and the original [HOWTO ALSA][28] article may have been omitted for one reason or another. See [ALSA/Omitted Items][29] 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][30]. This information is necessary to build the proper drivers in the kernel. ## Kernel Configuration Refer to the [official Gentoo Kernel Configuration Guide][31] 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][32] 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][33] 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][34]. To find what plugins are available with alsa-lib, see [the ALSA PCM Plugins section][35] 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][29] 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][36]. ## 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][37]" [Category][38]: [Subpages][39] -------------------------------- [Browse categories][40] \> [Gentoo Linux Wiki][41] \> [Subpages][39] -------------------------------- **Last modified**: Sun, 28 Sep 2008 07:59:00 +0000 **Hits**: 59,113 [0]: http://www.gentoo-wiki.info/HOWTO_ALSA [1]: http://www.gentoo-wiki.info [2]: http://www.gentoo-wiki.info/HOWTO_ALSA#Introduction [3]: http://www.gentoo-wiki.info/HOWTO_ALSA#Prerequisites [4]: http://www.gentoo-wiki.info/HOWTO_ALSA#Identifying [5]: http://www.gentoo-wiki.info/HOWTO_ALSA#Kernel_Configuration [6]: http://www.gentoo-wiki.info/HOWTO_ALSA#Kernel_2.4 [7]: http://www.gentoo-wiki.info/HOWTO_ALSA#Kernel_2.6 [8]: http://www.gentoo-wiki.info/HOWTO_ALSA#Post-Installation_Configuration [9]: http://www.gentoo-wiki.info/HOWTO_ALSA#Standard_Configuration [10]: http://www.gentoo-wiki.info/HOWTO_ALSA#.2Fetc.2Fmodprobe.d.2Falsa [11]: http://www.gentoo-wiki.info/HOWTO_ALSA#Example_Configuration [12]: http://www.gentoo-wiki.info/HOWTO_ALSA#Single_Card [13]: http://www.gentoo-wiki.info/HOWTO_ALSA#Multiple_Cards_.28Different_Modules.29 [14]: http://www.gentoo-wiki.info/HOWTO_ALSA#Multiple_Cards_.28Same_Module.29 [15]: http://www.gentoo-wiki.info/HOWTO_ALSA#Additional_Options [16]: http://www.gentoo-wiki.info/HOWTO_ALSA#USE-Flags [17]: http://www.gentoo-wiki.info/HOWTO_ALSA#Extra_Packages [18]: http://www.gentoo-wiki.info/HOWTO_ALSA#Plugins [19]: http://www.gentoo-wiki.info/HOWTO_ALSA#Automatic_Startup [20]: http://www.gentoo-wiki.info/HOWTO_ALSA#User_Permissions [21]: http://www.gentoo-wiki.info/HOWTO_ALSA#Setting_the_Mixer [22]: http://www.gentoo-wiki.info/HOWTO_ALSA#Finish [23]: http://www.gentoo-wiki.info/HOWTO_ALSA#Advanced_dmix_Configurations [24]: http://www.gentoo-wiki.info/HOWTO_ALSA#Troubleshooting [25]: http://www.gentoo-wiki.info/HOWTO_ALSA#Gnome_Relevant_Alsa_Package [26]: http://www.gentoo-wiki.info/ALSA/alsa-driver "ALSA/alsa-driver" [27]: http://www.gentoo-wiki.info/HOWTO_ALSA_Complete_%28includes_dmix%29 "HOWTO ALSA Complete (includes dmix)" [28]: http://www.gentoo-wiki.info/HOWTO_ALSA "HOWTO ALSA" [29]: http://www.gentoo-wiki.info/ALSA/Omitted_Items "ALSA/Omitted Items" [30]: http://bugtrack.alsa-project.org/main/index.php/Matrix:Main "http://bugtrack.alsa-project.org/main/index.php/Matrix:Main" [31]: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7 "http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7" [32]: http://alsa.opensrc.org/MultipleCards "http://alsa.opensrc.org/MultipleCards" [33]: http://alsa.opensrc.org/MultipleUSBAudioDevices "http://alsa.opensrc.org/MultipleUSBAudioDevices" [34]: http://forums.gentoo.org/viewtopic-t-545779.html#3950405 "http://forums.gentoo.org/viewtopic-t-545779.html#3950405" [35]: http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html "http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html" [36]: http://www.gentoo-wiki.info/ALSA/Software_dmix_Configurations "ALSA/Software dmix Configurations" [37]: http://www.gentoo-wiki.info/ALSA/Install [38]: http://www.gentoo-wiki.info/Special:Categories "Special:Categories" [39]: http://www.gentoo-wiki.info/Category:Subpages "Category:Subpages" [40]: http://www.gentoo-wiki.info/Category:Browse_categories "Category:Browse categories" [41]: http://www.gentoo-wiki.info/Category:Gentoo_Linux_Wiki "Category:Gentoo Linux Wiki"