| news - about me - my system - columns - blackbox styles - projects - licenses - the curse - contact | |||
|
Using FM801 chipset soundcards (Genius SoundMaker Live 5.1) II |
|
||
|
path xlife columns 20040418 |
|||
Using FM801 chipset soundcards (Genius SoundMaker Live 5.1) IIXlife column for April 18, 2004:Summary:
1 IntroductionIt's been a while since my previous column detailing how to make the SoundMaker from Genius work in Linux with the ALSA drivers. Since then, the ALSA project has come a long way, went through two major overhauls and has been nominated as the sound framework of choice for the new stable kernel version (2.6.x). This new column intends to cover all the tricks and tips needed to make a SoundMaker owner who uses Linux moderately happy. It covers the drivers (getting them, installing them and setting them up properly); the ALSA support in various multimedia applications; how to achieve seamless software mixing (ie. being able to play more than one sound stream at the same time). I said "moderately happy" because the ALSA drivers, while great, cannot achieve the same level of functionality as the original drivers. And there are no original drivers for Linux. So there. 1.1 About compiling from sourceYou may have to compile some source packages, including the kernel. I will not offer a tutorial for source installations here. Sorry, but I will assume you know what you're doing and I will offer just the essential stuff that is meant to save you time. Please also note that my 2 The ALSA drivers2.1 ALSA vs OSSALSA (Advanced Linux Sound Architecture) intends to replace the proprietary OSS drivers which have been the sound drivers of choice for Linux for quite a while now. The main problem with the OSS drivers is that they're not free, and what you get for free is actually a reduced version of the drivers. You have to pay for the full package with all the nifty options and support of advanced features. Considering this, once ALSA has reached a stable state it was adopted as the default sound support framework in the kernel, starting with version 2.6.x. 2.2 Getting the driversIf you use or intend to use a 2.6.x kernel, the drivers are already included in it. It's just a matter of activating them, or checking if they are already available. If you use an older kernel version, or you simply don't want to use the driver that ships with the kernel, you can get the driver as a separate package. Some people choose to do this even though they have kernel 2.6 because (theoretically) the external driver may be updated more often than the kernel releases new versions. Also theoretically, the version in the kernel is less prone to incompatibilities with the kernel. In practice, nothing changes that much from one version of the driver to the other to cause an acute need to upgrade often, and on the other hand I've never had problems myself with the external driver. So feel free to go whatever route you want. If you want the external drivers, grab the latest alsa-driver package. 2.3 Installing the drivers2.3.1 The driver may already be installedRun the following command in a terminal or console: find /lib/modules/`uname -r`/ -type f -name "snd*" You should see something along the lines below. The following output is for a 2.4 kernel. For 2.6 kernels you should see .ko files. /lib/modules/2.4.20/kernel/sound/acore/snd-hwdep.o /lib/modules/2.4.20/kernel/sound/acore/snd-page-alloc.o /lib/modules/2.4.20/kernel/sound/acore/snd-pcm.o /lib/modules/2.4.20/kernel/sound/acore/snd-rawmidi.o /lib/modules/2.4.20/kernel/sound/acore/snd-timer.o /lib/modules/2.4.20/kernel/sound/acore/snd.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq-device.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq-instr.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq-midi-emul.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq-midi-event.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq-midi.o /lib/modules/2.4.20/kernel/sound/acore/seq/snd-seq.o /lib/modules/2.4.20/kernel/sound/acore/seq/instr/snd-ainstr-fm.o /lib/modules/2.4.20/kernel/sound/acore/seq/oss/snd-seq-oss.o /lib/modules/2.4.20/kernel/sound/acore/oss/snd-mixer-oss.o /lib/modules/2.4.20/kernel/sound/acore/oss/snd-pcm-oss.o /lib/modules/2.4.20/kernel/sound/i2c/other/snd-tea575x-tuner.o /lib/modules/2.4.20/kernel/sound/drivers/snd-dummy.o /lib/modules/2.4.20/kernel/sound/drivers/mpu401/snd-mpu401-uart.o /lib/modules/2.4.20/kernel/sound/drivers/opl3/snd-opl3-lib.o /lib/modules/2.4.20/kernel/sound/drivers/opl3/snd-opl3-synth.o /lib/modules/2.4.20/kernel/sound/pci/snd-fm801.o /lib/modules/2.4.20/kernel/sound/pci/ac97/snd-ac97-codec.o There may actually be many more or less lines than above, so these are orientative. If you don't have these modules you may still need to properly adjust your kernel configuration and recompile it to get them. 2.3.2 Using the driver included in kernel 2.6.xYou will need to recompile the kernel for this, and no, I am not going to
describe how to do it here. I assume you know what you're doing. All you need
to know regarding this subject is this: in the kernel configuration, go to
Optionally, but highly recommended, also select the following:
You may of course look around and enable other options as well (such as verbose debugging, dummy soundcard or generic UART device). Compile and install your kernel. You should now be able to find the new modules as described in the section above. 2.3.3 Installing the external driver2.3.3.1 Basic soundcard supportEven if you use the external driver, you still have to make sure that the kernel has at least the basic support for sound. It may not care about the external driver you intend to use, but it still has to be able to know about sound drivers in general. Use the following command to detect if you have the basic sound support included in the kernel: find /lib/modules/`uname -r`/ -type f -name "soundcore*" You should find a soundcore.o file (kernel 2.4.x-) or a soundcore.ko file (kernel 2.5+). If it's not there, you will still have to recompile the kernel. It's highly
recommended to compile this thing as a module, not built-in. Go into the
kernel configuration and for kernel 2.4.x select 2.3.3.2 The external driverYour distribution may carry the drivers in a dedicated binary package, but I doubt it; kernel modules are highly dependent on the particular kernel configuration and version, so you may need to build your own after all. So unpack the alsa-driver archive somewhere. I'm also not going to cover the topic of compiling applications from source, so I'll just assume you know what you're doing and offer just the ./configure command that worked best for me: ./configure \ --prefix=/opt/alsa-driver \ # install into /opt/alsa-driver --sysconfdir=/etc \ # use /etc as the system settings dir --localstatedir=/var \ # use /var for runtime files --disable-nls \ # no I18N support --with-cards=fm801 \ # build FM801 support --with-redhat=no \ # install /etc/rc.d/init.d startup script --with-sequencer=yes \ # build sequencer support --with-oss=yes # build OSS emulation support It's important to tell the driver which kernel source to use. It will
determine the kernel image it works with, and the install place
( Next run 2.3.4 Preliminary testing of the driversIf you were using any application that makes sound, please stop it at this
point. Also, do a The purpose is to remain with just Module Size Used by Tainted: PF
snd-fm801 11428 1
snd-mpu401-uart 5520 0 [snd-fm801]
snd-rawmidi 19584 0 [snd-mpu401-uart]
snd-opl3-lib 9412 0 [snd-fm801]
snd-seq-device 6284 0 [snd-rawmidi snd-opl3-lib]
snd-hwdep 7008 0 [snd-opl3-lib]
snd-ac97-codec 60220 0 [snd-fm801]
snd-pcm-oss 44132 0
snd-pcm 84580 0 [snd-fm801 snd-pcm-oss]
snd-page-alloc 9204 0 [snd-pcm]
snd-timer 20772 0 [snd-opl3-lib snd-pcm]
snd-mixer-oss 16280 1 [snd-pcm-oss]
snd 47524 0 [snd-fm801 snd-mpu401-uart snd-rawmidi\
snd-opl3-lib snd-seq-device snd-hwdep\
snd-ac97-codec snd-pcm-oss snd-pcm\
snd-timer snd-mixer-oss]
soundcore 6564 6 [snd]
If any modules fail to load saying something about dependencies, please
make sure you are booted with the kernel you compiled the drivers for. Also,
you can try runnind After you load the drivers, a 3 The ALSA libraryNow that you have the drivers working, it's time to make other applications use them. This is done by providing a central library package, and have the other apps link to it. It's a good idea, because you only need to upgrade the central library to upgrade ALSA, not all the packages involved with it. You can probably get the relevant bits and packages for ALSA support from your distro's binary repository. In case you want to use the source, the ALSA package for this is called alsa-lib, and here's the configure command: ./configure \ --prefix=/opt/alsa-lib \ # install into /opt/alsa-lib --sysconfdir=/etc \ # use /etc as the system settings dir --localstatedir=/var \ # use /var for runtime files --disable-nls # no I18N support Other applications (such as MPlayer, or XMMS) may provide ALSA support as
optional binary packages, or you may have to add some options to their
configure commands too if you decide to install them from source too. I won't
provide relevant configure options for all the packages out there, go read
What's for sure is thay you need to both install the ALSA library, and enable ALSA support in applications. Otherwise you're left with a perfectly good driver and nobody to use it. 4 The ALSA utilitiesThe corresponding ALSA package is called alsa-utils. You can find it as a binary package for your distro, or you can compile it yourself. Here's the configure command for the compilation: ./configure \ --prefix=/opt/alsa-utils \ # install into /opt/alsa-utils --sysconfdir=/etc \ # use /etc as the system settings dir --localstatedir=/var \ # use /var for runtime files --disable-nls \ # no I18N support --with-alsa-prefix=/opt/alsa-lib/lib \ --with-alsa-inc-prefix=/opt/alsa-lib/include Why do you need the utilies? In the first place, for the alsamixer tool. It's a mixer, as the name implies. A mixer is a tool that allows you to set the levels of sound for various channels on your sound card, and also enable and disable various options, such as 3D Sound or Surround Sound. 4.1 Using AlsaMixerWhy AlsaMixer? Because unlike other, generic, mixers out there, who only provide some standard settings (such as PCM, Master, Line), alsamixer is a native ALSA tool. It knows how to talk to the drivers and gets all kinds of useful information from them: the names of the soundcards and the ability to setup channels for all ALSA soundcards installed; the actual channels and the names for them as they are actually defined in the drivers, not some generic channels. AlsaMixer is a console application, and it uses a ncurses interface to make it appear somewhat graphical. If you have just one soundcard, simply run it and start moving around the channels. Please note the name of the soundcard and of the current channel at the top of the terminal. Use the left and right arrows to change channel, up/down to change level, M to mute/unmute, Esc to exit (saving is done instantly when you change something), and H for help with more keys. Also read 'man alsamixer' if you will. 4.2 If you don't hear anything, unmute the channels!Please note that you probably HAVE to use a mixer after every time you install the drivers from the separate package. By default, the ALSA driver mutes all the channels, so unless you use a mixer to unmute at least the master and one other channel you'll never get any sound playing. Why does it do this? Think about it. The moment you insert the modules and the sound card becomes available, the channels may be in any state. You may have a radio or a TV tuner active, for instance. For some reason or other, you could suddenly start hearing those sounds. OK, this is the entire point, you'd say. Yeah, but what happens if you get blasted away at 100% volume? You could turn down the speakers, but the channel volumes are independent from one another, and by doing that you may be still hearing the line-in but miss out on the PCM output, for instance. And how about frantically researching "how do I turn down the volume?" while being blasted with random sounds? Anyway, muting all channels by default is a safe default. It also has good consequences: it forces you to learn about AlsaMixer and use it or any other mixer, which you were going to do anyway; provides you with silence so you can concentrate when learning these new things; makes you run through all the available channels at your own pace, discovering new things as you go (I never knew I could control the 3D output or its level until I used AlsaMixer). 5 Soundcard configuration5.1 The module configurationThese things go into # device setup alias char-major-14 soundcore alias char-major-116 snd # ALSA services setup alias snd-card-0 snd-fm801 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 # additional ALSA options options snd major=116 cards_limit=1 options snd-fm801 index=0 id="MYCARDNAME"
After adding these to Reloading the modules will pick up the new configuration. You can check by
exploring 5.2 The asoundrc configuration (including software mixing)There are also per user configurations that are used by the ALSA drivers.
They are placed either in It's probably a good idea to test the following configuration with a regular user first, and write it to the global file only when you're satisfied with it. There are quite a few different setups you can use, and the syntax and features are wide and flexible. You can read more about that in various tutorials:
The configuration I'm about to present achieves seamless software mixing for all the applications using the ALSA drivers. That means that as long as an application is using ALSA as its output driver, they can all play simultaneously without any problems. OSS and Here's the magical .asoundrc: pcm.!default {
type plug
slave.pcm "MYNAME"
}
pcm.dsp0 {
type plug
slave.pcm "MYNAME"
}
ctl.mixer0 {
type hw
card 0
}
pcm.MYNAME {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024 # must be power of 2
buffer_size 8192 # must be power of 2
#rate 8000
}
bindings {
0 0 # from 0 => to 0
1 1 # from 1 => to 1
}
}
Use anything you like instead of MYNAME above. The If you have any trouble with the above configuration, please use the gradual approach presented in the official ALSA asoundrc tutorial to identify where exactly it is you're getting into trouble. 5.3 Testing software mixingSince you installed alsa-utils, you should have the aplay tool available. It can play wav, pcm and au files, so get one of those. To test, run it like this: aplay test.wav One instance of aplay should work anyway. To see if you have software mixing, open a second terminal and run the same command while the first one is still playing. You should hear both playing at once. If the second one hangs, it means it's trying to use OSS. If it works, congratulations, you've got your ALSA setup with software mixing working. 5.4 Setting up various applicationsProvided the above test worked well, all that's left is to make various
applications use the ALSA driver. Be warned that ALSA support should already
be included with them. For binary packages, your distro may carry add-on
packs that provide the ALSA functionality. In other cases you may need to
compile the application yourself and enable ALSA support with the relevant
If an application fails to work in software mixing mode (together with an aplay playing at the same time, for instance) you have to re-check its ALSA-using options or your asoundrc. Some other silly thing may be the cause of failure. I once used as the test file for XMMS an mp3 on a not yet mounted partition. It took me a while to realise that XMMS was working fine, it just couldn't access the file. 5.4.1 MPlayerTest if ALSA support is included like this: mplayer -ao help You should see alsa9 among the available sound output methods. You should be able to play something using ALSA using the following option for the command line MPlayer version: mplayer -ao alsa9:MYNAME test.avi Be sure to use your own name chosen for the asoundrc, instead of MYNAME. You can also play a sound-only file for testing, such as a MP3 or WAV or OGG, it's the sound we're interested in anyway. The tutorials mentioned above carry some alternative ways to specify the ALSA driver should this one not work. Test software mixing by using another MPlayer or another aplay or whatever ALSA enabled application you have, at the same time. If MPlayer hangs when attempting to play along with other ALSA apps, it means it's still using the OSS output. Of course, you don't want to have to use that command line option all the
time, especially if you use the GUI. So add the following to either
ao=alsa9:MYNAME If you changed the option above, use that instead, but mind the way a command line option transforms into a config file option. If you get it wrong (use a space instead of the equal sign in the config file, for instance) MPlayer will crash horribly. 5.4.2 XMMSWith XMMS you have to enter the preferences (Control+P), go to the "Audio I/O Plugins" tab, in the "Output plugin" section. Choose ALSA as the output driver, then click "Configure". Use "default" as the audio device, and write MYNAME in the driver box. Make sure you press Stop before you enter the preferences. Playing a song after exiting the preferences should give you ALSA enabled output, with software mixing. 5.4.3 AlsaPlayerAlsaPlayer is a nice little player I've come to like very much. It has a bare-essentials interface, plus built-in speed regulator and it is even able to play songs backwards. It has a playlist which it can save and load, as well as visualisation plugins. It can play many types of sound files. The configuration is done via command line options passed to it. The
relevant ones for using ALSA are these: Other useful options are 5.4.4 TV and FM tunersIt depends on how such tuners output sound. If you have a tuner that needs a cord from it's output jack to the soundcard line-in jack, then you don't have to do anything, this will be handled by the card's internal hardware mixing (which unfortunately isn't available with ALSA). If the tuner outputs sound digitally, directly to the soundcard, it may also be handled by hardware mixing. Only if the particular player you are using is unable to use the soundcard directly, which is probably unlikely, you'll have to convince the player to use ALSA. 5.4.5 CD playersCD playing applications can also use two methods. Some of them use the analog cord the runs between the CD drive and a plug on your motherboard inside the computer case. If this is not available, you can still play CD's digitally, using the IDE cable to transfer the data from the CD. However, in this case the player must have ALSA support. I recommend XMMS for this, since it is both able to play CD's digitally, and has ALSA output support. 6 OSS-only applicationsApplications that only know how to use OSS (or applications that at a certain moment use OSS for output) will work under this setup, provided you've activated OSS emulation in your driver installation. I've emphasized the appropriate options above in the driver configuration sections. However, OSS-only applications will break software mixing. For as long as an OSS-only application is using the sound system, it takes over the entire driver, which it shouldn't do. This means that any other application that tries to use it will hang until it is released. This is valid for both ALSA-enabled applications and OSS-only applications, because at this point the entire driver is tied up. 6.1 alsa-ossOne possible workaround for this is the alsa-oss package. You can get it as a binary package from your distro repositories, or you can download the source and compile it. Here's the configure command: ./configure \ --prefix=/opt/alsa-oss \ # install into /opt/alsa-oss --sysconfdir=/etc \ # use /etc as the system settings dir --localstatedir=/var \ # use /var for runtime files --disable-nls \ # no I18N support --with-aoss=yes \ # build the aoss tool --with-alsa-prefix=/opt/alsa-lib/lib \ --with-alsa-inc-prefix=/opt/alsa-lib/include This package provides a shared library called libaoss.so. The trick is to forcefully preload this library into an OSS-only application. Doing this will override the sound-handling functions of that application and trick them into using ALSA while the application is thinking it's using OSS. There's a shell script called aoss mygame -option1 -option2 However, please note that many times even this will fail, if the application does some strange things that the libaoss library can't control. If that's the case you're out of luck. Contact the application author if possible and ask them to provide ALSA support. It's year 2004 and ALSA has become the reference sound framework under Linux for a while now, so please get with the times. < Back to the top | Read other columns | Choose what column I should write next! > |
|||
|
Xlife ©2001-2009 Zuavra. All rights reserved. You are welcome to link to this site's text pages, but you must get explicit permission before you may reproduce or quote their contents. You may not link directly to binary files, such as images or tarballs. I do keep logs, you know, and offending sites will get their links redirected to shameful error messages. |
|||