5. Audio

The VIA EPIA boards use the VT1612A and VT1616 audio controllers, but you won't see them on the mainboard because they are integrated onto the Southbridge chip. EPIA boards use the 8231 southbridge (which includes the VT1612A) and EPIA M-series use the newer 8235 (which includes the VT1616). The VT1612A is a two channel AC97 codec; the VT1616 supports 6 channels. Both include microphone in and digital in.

This section will discuss three audio drivers: the linux 2.4 kernel driver, the viaaudiocombo driver, and the ALSA drivers. I used to recommend the ALSA drivers, but I've been converted to viaaudiocombo. I have found that viaaudiocombo has fewer clicks and pops. The ALSA stuff will stay in this document in case someone needs it.

5.1. Kernel Audio Support

Some of the latest distributions include kernels with working 82xx support provided by the via82cxxx_audio kernel module. For instance, the Red Hat 9 kernel supports EPIA M audio. However earlier distributions such as Red Hat 8 will not.

5.2. VIA Audio Combo

VIA provides a single linux driver which supports the following audio chips: VT82C686A, VT82C686B, VT8231, VT8233, VT8233A, VT8233B, VT8235, and VT8237. The driver is available from the viaarena linux audio page. This is a good driver: in addition to supporting all the via sound chips, it also supports all their special features such as six channel audio and S/PDIF. The driver is distributed as a source rpm, which is great for rpm based distros but not so good for gentoo and slack. I will have a short description of installing for rpm based systems, then a short description of how to install for non-rpm based distros.

The viaudiocombo driver creates a /dev/dsp device, so you can tell applications like xmms to use the OSS driver and that will be ok. In order to use the advanced features like six channel sound the application must have support for the viaudiocombo driver.

The aumix command line mixer works with viaudiocombo. kmix does not work.

5.2.1. VIA Audio Combo RPM Install

Download and extract the viaudiocombo package from viaarena. It contains a source rpm. Build the source rpm

bash# rpmbuild --rebuild viaudiocombo-2.3-1.src.rpm

Now change to the /usr/src/redhat/RPMS/i386 directory. The viaudiocombo-2.3-1.i386.rpm file should be there. If it isn't, then look in the i586 or i686 directories. Once you have found the rpm install it:

bash# rpm -ivh viaudiocombo-2.3-1.i386.rpm

The rpm package includes install scripts which should modify your /etc/modules.conf file, your /etc/sysconfig files, and your /etc/rc.d files. These scripts should also stop and remove any existing audio drivers. But sometimes these scripts don't work - for instance, if an audio application is running, even if it is just sitting idle in a background process, the install script will fail. In which case you should follow the directions from the non-rpm distribution installation in the following section.

5.2.2. VIA Audio Combo non-RPM Install

The source rpm contains an rpm spec file and the viaudiocombo source tarball. You need to extract the source tarball from the source rpm. The easiest way is to install the source rpm using the rpm install command (shown below) which will install the source tarball at /usr/src/redhat/SOURCES. Or you can use the rpm2cpio command which will extract it to the current directory. Or you could ask someone at the viaarena linux forum for help.

bash# rpm -i viaudiocombo-2.3-1.src.rpm
bash$ rpm2cpio viaudiocombo-2.3-1.src.rpm | cpio -i

Once you have the source tarball you can extract it and run the install.sh script. You have the source code for the current kernel - look at the install.sh script for source locations. After the compile you should copy the viaudiocombo.o module to /lib/modules/{kernelversion}/kernel/drivers/sound and run depmod. You should copy the viasound script to your /etc/init.d and make a symlink in /etc/rc.d/rc5.d or wherever your init scripts are stored. Finally, add this line to /etc/modules.conf:

alias sound-slot-0 viaudiocombo

If you had other sound drivers installed, then you should remove their stuff from /etc/modules.conf and the init directories.

5.3. ALSA

The Advanced Linux Sound Architecture (ALSA) version 0.9.6 works well with the 8231, 8233 and 8235 chips. If you use an rpm based distro then you can download ALSA rpms from freshrpms.net; you will need five rpms: alsa-drivers, kernel-module-alsa, alsa-lib, alsa-lib-dev, and alsa-utils. The remainder of this section will discuss installation from source. First, download the alsa 0.9.6 drivers from the ALSA Project. The alsa via82xx driver supports both sound chips so the instructions are the same for both chips. There is a lot of documentation for the alsa 82xx driver: the ALSA sound card matrix, the AlsaOpensrcOrg via8233 wiki, the INSTALL file included in the tarball, and especially alsa-driver-0.9.6/alsa-kernel/Documentation/ALSA-Configuration.txt are good sources. I have tried to synthesize the most relevant information into this HowTo.

Before installing the alsa drivers you should uninstall any other sound modules that might be in the kernel. Use the lsmod command to find out what modules are installed and the rmmod command to remove them.

Next, download, unzip and extract the tarball. Next, configure the source. When configuring the alsa-driver source, use the command:

bash# ./configure --with-cards=via82xx --with-sequencer=yes

The --with-cards=via82xx argument ensures that only the via82xx hardware driver gets built and installed. The alsa build process will look for your kernel source at /lib/modules/$KERNELVERSION/build. If you want to compile for a different kernel then use the command below, then the normal make and make install and run the snddevices script.

bash# ./configure --with-cards=via82xx --with-sequencer=yes --with-kernel=/my/kernel/path
bash# make
bash# make install
bash# ./snddevices

The snddevices script adds the necessary devices files in the /dev directory. ALSA should automatically add some lines to your /etc/modules.conf file, but sometimes it doesn't, so you must check. This is what you should see:

# --- BEGIN: Generated by ALSACONF, do not edit. ---
# --- ALSACONF verion 0.9.0 ---
alias char-major-116 snd
alias snd-card-0 snd-via82xx
alias char-major-14 soundcore
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 major=116 cards_limit=1 
options snd-via82xx index=0 dxs_support=3 

Depending on your distro, you might already have some OSS sound devices programmed into /etc/modules.conf. It would be prudent to comment out those lines to eliminate confusion between the originall OSS drivers and the newer ALSA drivers; something like this:

#alias sound-slot-0 via82cxxx_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 || :

Now you have to download, build and install the alsa-lib and alsa-utils-0.9.6 tarballs, also from the ALSA Project. Build and install them using the standard build-from-source procedure:

bash# ./configure; make; make install

Depending on your distribution, you might have to modify your library path. Further instructions regarding the library path are included in the appendix.

Now you have built and installed ALSA. So you run your favourite multimedia application and ... you still can't hear anything. At this point many people get extremely annoyed, but you must fix one more thing. When the kernel loads the driver it sets all the channels to zero volume and mutes them. The VIA support file includes a script which, when executed, resets the volume and unmutes each channel. The script is named "audunmute". You have to unmute and set the volume for each channel. You can control the mixer settings using whatever mixer program you like. Or you can copy the following lines into a text file named alsa_set_mixer.sh:

#!/bin/sh
amixer set PCM 22 unmute 
amixer set PC\ Speaker 22 unmute 
amixer set Master 22 unmute 
amixer set Master\ Mono 22 unmute 
amixer set Headphone 22 unmute 
amixer set Phone 22 unmute 
amixer set Aux 22 unmute 
amixer set Video 22 unmute 
amixer set CD 22 unmute 
amixer set Input\ Gain 22 unmute 
amixer set Line 22 unmute 
amixer set MIC 22 unmute 

and set the file as executable

bash# chmod +x alsa_set_mixer.sh

Notice that it just runs the amixer utility to set the properties for each channel. You can run this script manually every time you load the snd-via82xx module, but a better way is to modify the /etc/modules.conf file to automatically run the script. After the alsa driver lines, add the following line:

post-install snd-card-0 /usr/local/bin/alsa_set_mixer.sh>/dev/null 2>&1 || :

Then copy the script file to /usr/local/bin/alsa_set_mixer.sh, like this:

bash# cp alsa_set_mixer.sh /usr/local/bin

Now the channels should be set automatically each time you load the driver.

On some older boards users have reported contention between X and the sound system. You might be able to reduce the problem by adding this line to the Devices section of /etc/X11/XF86Config:

option  "PciRetry"  "true"  

5.4. Six Channel Audio

Both the viaudiocombo and ALSA drivers support six channel. raltieri tried both drivers and he suggested that viaudiocombo works better. On the other hand, Bheremans offered a good description of how he got six channel audio to work using ALSA:

From: Bheremans
Date: Thursday February 26, 2004 2:37 PM

It took some evenings but I have six sound working wohoo , first some specs:

# distro : Gentoo
# audio Driver : Alsa 1.0.2
# mplayer : 1.0-pre3
# xine : xine-ui 0.9.23 , xine-lib 1-rc2

For playing dvd's I normally use xine, I did choose the alsa driver, and activated 5lfe channel
For Divx and others I use gentoo, for 6-channel files I use : -ao oss:/dev/adsp -channels 6

If you play a two channel file with these options you will get sound out front and rear, if you
wan't to activate others I did it with this : -af channels=6:6:0:0:1:1:0:2:1:3:0:4:1:5

Finally some noise in the house ;-)

The problem why it wasn't working was not the software !! I had a case with front audio connectors,
so I removed the jumpers that default are on pin 5&6 and 9&10 on the onbaord audio connector. I'm
not using this case anymore and I don't have front audio connectors anymore, but I dind't put the
jumpers back, aaaarghhh. So much trouble and it where just the jumpers. After putting them back all
speakers worked right away.

So it all works nice and I don't have to use the binary viaudiocombo driver :-)

Bart

Six channel analog output uses the three mini-phono sockets. See your mainboard user's manual for details. The top socket is Line In, the middle one is Line Out, and the bottom one is MIC. If your manual isn't handy, here's what it says:

 

Please note when 6-channel applications are used, all three connectors become output connectors. Line-Out becomes Front L/R; Line-In becomes Rear L/R; Mic-In becomes Center/Sub.

 
--VIA EPIA-M USer's Manual November 4th, 2002 

Six channel audio must be supported by the application. For instance, to run mplayer with six channel audio you might use the following command:

bash$ mplayer -af channels=6:6:0:0:1:1:0:2:1:3:0:4:1:5 -channels 6 mp3file.mp3

I have also read that the -af surround 0 option will play a two channel audio file to the rear speakers.

Regardless of whether you decide to use the viaudiocombo or ALSA sound drivers, you must use the ALSA mixer. You should "mute all downmix channels and unmute alternate level to surround out.". Here is the mapping of mixer controls to speakers:

Table 4. Mapping Mixer Control to 5.1 Speakers

Mixer ControlSpeakers     
MasterFront     
HeadphonesRear     
PCMMaster     

5.5. S/PDIF

Sony/Philips Digital Interface (S/PDIF or SPDIF) is a standard digital audio transfer format (see ePanorama.net for more info about the standards). SPDIF allows the audio hardware to transfer the audio information to another digital audio device in digital format. VIA supports six channel SPDIF audio on the RCA jack using the viaudiocombo driver. Of course, if you are using the RCA jack for SPDIF, you cannot use it for TVout. A jumper on the EPIA board determines whether the RCA jack will be used for SPDIF or RCA Video. Consult your User Manual for the location and pin-out of the jumper.

If you intend to use S/PDIF then you must use the spdif_out=1 option when you load the viaudiocombo driver e.g. modprobe viaudiocombo spdif_out=1.

To use S/PDIF with the ALSA modules, you must first execute the command amixer set 'IEC958 Playback AC97-SPSA' 0. This command does not set the volume - S/PDIF output is always at maximum volume. Instead, it sets the S/PDIF channel. The settings are: 0 - PCM1; 1 - PCM2, PCM1 (rear); 2 - Center and LFE; 3 PCM3, modem dedicated S/PDIF. The application must send its output to the S/PDIF device. For instance, to play PCM with mplayer using spdif, use the mplayer -ao alsa9:iec958 command; or to play AC3 use mplayer -ao alsa9:iec958 -ac hwac3.

5.6. 48kHz Sampling

There is a serious issue regarding the sampling rate of the VIA DSP. I won't claim to understand it, instead I'll copy a message from someone who definitely knows what he is talking about. This message was posted to the alsa-user mailing list by Takashi Iwai.


    * From: Takashi Iwai
    * Subject: Noises on via82xx (Re: Fwd: Re: [Alsa-user] Onboard via8233 crackling)
    * Date: Wed, 02 Jul 2003 10:16:34 -0700

At Wed, 2 Jul 2003 18:11:27 +0200,
Gregor Riepl wrote:

> Isn't there any documentation on this?
> I would really appreciate if someone could finally sort this trouble out 
> since there are a lot of people who use a VIA8233+.

ok, let me explain briefly about this theme.

VIA82xx chip has different revisions, and the behavior of the chip
depends on the revision.
basically, via chip has two different playback modes.
one is called DXS (direct sound) mode, and another is multi-channel
mode.  the former supports only two-channel format but you can play
up to 4 streams at the same time.  the sample rate of these 4 streams
must be identical, though.

the another mode, multi-channel mode, supports only one stream but you
can play from 2 to 6 (5.1) channels with this.  obviously, this is
used for playback of AC3 decoding, etc.

in the recent ALSA via82xx driver, the DXS mode is used as default
(i.e. the first pcm device hw:0,0) on the chip models which support
it.  the multi-channel mode is assigned to the secondary pcm (hw:0,1),
which corresponds to /dev/adsp in the OSS-emulation mode.

the chip with the revision 0x40, which is called VIA8233A, has no DXS
mode.  other revisions, VIA8233, 8233C and 8235, do support it.
each DXS channel (from 0 to 3) has an indepedent stereo volume.
please make sure that these volumes, "VIA DXS Playback Volume", are
set to full (although they are initialized to full as default).

unfortuantely, some motherboards have the problems of DXS channels.
on some, DXS mode doesn't work at all, and on some, only 48kHz is
available (otherwise you'll hear click noises).
according to the people of VIA tech, this is because of the BIOS
(typically AWARD BIOS).  so, one solution is to update the BIOS.
but it's not always a preferred solution.

in the recent driver version, a workaround is provided instead.
there is a module option "dxs_support", which defines how to handle
the DXS channels.  if you have a problem with the first pcm device,
try dxs_support=2 or dxs_support=3.

when dxs_support=2 is given, the DXS mode is disabled and you'll have
only the multi-channel playback mode.  this means, the chip is handled
as VIA8233A.  of course, you can play only on stream.  in this case,
dmix plugin would be a workaround.

when dxs_support=3 is given, only 48kHz is allowed for the DXS
channels.  that means, the sample-rate conversion will be done in
alsa-lib or OSS-emulation for playing MP3.  but it's cheaper than dmix
plugin.  so, try this once, and if still doesn't work, try the
previous one.

how to add such an option?  if you already have module options for
via82xx driver, you should see the line like following in
/etc/modules.conf

        options snd-via82xx index=0

and just add dxs_support=2 (or 3) there.

        options snd-via82xx index=0 dxs_support=2

then restart the driver.

in future, i'll add a black-list of motherboards which don't work well
with DXS mode.  if your mobo needs the workaround above, please let me
know the pci-subsystem vendor/device ids, which can be obtained via
"lspci -nv" command.

Takashi

It seems to help if you force your applications to deliver 48 kHz sampling to the sound driver. Then no cross sampling is required (or at least, the audio application is doing the conversion). Each audio application has a different method to force 48 kHz sampling. Here are some "magic words" which might help.

bash# mplayer -aop list=resample:fout=48000 myfile.mp3
bash# mpg123 -r48000 myfile.mp3
bash# mplayer -ao oss -srate48000 myfile.mp3

You might also create a ~/.asoundrc file containing the following lines:

pcm.via82xx {
  type plug
  slave {
    pcm "hw:0,0"
    rate 48000
  }
}
ctl.via82xx {
  type hw
  card 0
}

5.7. XMMS

XMMS comes with many distributions, but ALSA support might not be compiled into the distributed version. XMMS is Free Software, and simple to compile. First, download the xmms-1.2.7 source and the alsa-xmms-0.9.12 plug-in. But before you start compiling, remove any existing copies of xmms. For instance, if you use Red Hat, use this command:

bash# rpm -ev --nodeps xmms xmms-skins

Then compile and install xmms and alsa-xmms. Strangely, I couldn't hear anything even after changing to the ALSA 0.9 plug. Someone suggested using the crossfade plug-in. So download, compile and install the crossfade plug-in.

Now you have to configure xmms and crossfade. Launch xmms. Use ctrl-P to get the preferences window. Set the output plugin to crossfade, and click the configure button. Under the Output tab, set the sampling rate to 48000 Hz and set the output plug-in to ALSA 0.9. Now click the Configure button for the ALSA plug-in and set the Mixer Device to PCM1. Click the "Apply" and "OK" buttons, and again "Apply" and "OK". XMMS should work now.