Obsolete!
ALSA support for the Bt878a
Components:
Fedora Core 2
Linux Kernel 2.6.5
ALSA 1.0.6a
Setup
Linux out of the box. We load the SoundBlaster and Bt878 ADC modules:
# modprobe snd-sb16
#
modprobe snd-bt87x
Check whether they load:
# lsmod
Module Size Used by snd_bt87x 11720 0 snd_mixer_oss 17664 2 snd_sb16 12620 4 snd_opl3_lib 9472 1 snd_sb16 snd_hwdep 9220 1 snd_opl3_lib snd_sb16_dsp 8576 1 snd_sb16 snd_sb_common 13696 2 snd_sb16,snd_sb16_dsp snd_pcm 75144 2 snd_bt87x,snd_sb16_dsp snd_timer 21636 2 snd_opl3_lib,snd_pcm snd_page_alloc 9224 2 snd_bt87x,snd_pcm snd_mpu401_uart 6784 1 snd_sb16 snd_rawmidi 21156 1 snd_mpu401_uart snd_seq_device 7816 2 snd_opl3_lib,snd_rawmidi snd 46724 16 snd_bt87x,snd_mixer_oss,snd_sb16,snd_opl3_lib,snd_hwdep,snd_sb16_dsp,snd_sb_common,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device soundcore 6112 3 snd autofs4 10880 0 ne2k_pci 7136 0 8390 6912 1 ne2k_pci floppy 47952 0 sg 28192 0 scsi_mod 91984 1 sg dm_mod 33312 0 ipv6 186080 6 ext3 102248 2 jbd 40216 1 ext3
Install gnome-alsamixer. Seems that the mixer included in Fedora Core 2 connects with the emulated OSS mixer and not with the native one from ALSA. (?)
Official gnome-alsamixer page
http://www.paw.co.za/projects/gnome-alsamixer/ . They have some problem in
their FTP server. Finally I'd get the 0.9.3 version from here:
http://prdownloads.sourceforge.net/dropline-gnome/gnome-alsamixer-0.9.3.tar.bz2?download
.
Uncompress, setup, compile and install:
# cd gnome-alsamixer-0.9.3
# ./configure
# make
# make install
# gnome-alsamixer
Increase the volume at maximum (see image).
Obsolete!
Capture test (1)
We will use the arecord utility native from ALSA:
# arecord -D hw:1,1 -f S16_LE -t wav test.wav
-D hw:1,1 1 for the second physical device (0 is
the first one, in my case the SoundBlaster) and 1 for the second logical device
(0 is the first one, the digital audio interface from the Bt878a)
-f S16_LE Format signed word little-endian
And then we get these error messages in /var/log/messages:
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xb8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 22 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xb8008008, PCI
status 0x290
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xc8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 3 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xd8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 23 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xd8008808, PCI
status 0x8290
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xd8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 2 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xe8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 13 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0xf8008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 13 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0x8008008, PCI status
0x8290
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0x8008008, PCI status
0x8290
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0x18008008, PCI
status 0x8290
Oct 3 16:18:49 lab last message repeated 18 times
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0x18008008, PCI
status 0x290
Oct 3 16:18:49 lab kernel: Aieee - PCI error! status 0x18008008, PCI
status 0x8290
I don't understand why these errors appears. The same hardware work well under OSS.
I explained to Clemens Ladisch (the module bt87x creator) and gently he tells me:
"... "PCI status 8xxx" means that there was a parity
error, i.e., some
data on the PCI bus was corrupted.
This is a hardware problem. The
OSS driver silently ignores such errors.
If you want the same behaviour with the ALSA driver, remove the lines
if (chip->reg_control & CTL_ACAP_EN)
snd_pcm_stop(chip->substream, SNDRV_PCM_STATE_XRUN);
from the bt87x.c file, and remove the "else" in the next line ..."
Obsolete!
ALSA update
We should get the latest stable files from here: http://www.alsa-project.org/ . Download alsa-driver-1.0.6a.tar.bz2, alsa-lib-1.0.6.tar.bz2, alsa-utils-1.0.6.tar.bz2 y alsa-oss-1.0.6.tar.bz2 .
# cd alsa-lib-1.0.6
# ./configure
# make
# make install
# cd alsa-driver-1.0.6a
# ./configure --with-cards=sb16,bt87x
# make
# make install
# cd alsa-utils-1.0.6
# ./configure
# make
# make install
# cd alsa-oss-1.0.6
# ./configure
# make
# make install
Execute alsaconf:
# cd
# alsaconf
But in my case this command didn't detect the Bt878's ADC. Let's see the content of /etc/modprobe.conf:
# cat /etc/modprobe.conf
alias eth0 ne2k-pci
alias char-major-81 bttv
# --- BEGIN: Generated by ALSACONF, do not edit. ---
# --- ALSACONF verion 1.0.6 ---
alias snd-card-0 snd-sb16
alias sound-slot-0 snd-sb16
options snd-sb16 isapnp=0
# --- END: Generated by ALSACONF, do not edit. ---
And add the following lines at the end of the file:
alias snd-card-1 snd-bt87x
alias sound-slot-1 snd-bt87x
We should restart the PC and check whether the modules load automatically.
Obsolete!
Patch the bt87x.c module (1)
Edit the file bt87x.c inside the folder from the module we have compiled. I've deactivated all the PCI check section. I've commented the "if (status & ERROR_INTERRUPTS)" function.
# cd alsa-driver-1.0.6a/alsa-kernel/pci/
# gedit bt87x.c
Add /* at the beginning of the line 252.
Add */ at the end of the line 267.
# cd alsa-driver-1.0.6a
# make
# make install
Unload and load the module:
# rmmod snd-bt87x
# modprobe snd-bt87x
Capture test (2)
# arecord -D hw:1,1 -f S16_LE -t wav test.wav Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono Warning: rate is not accurate (requested = 8000Hz, got = 119466Hz) please, try the plug plugin (-Dplug:hw:1,1)
Now, logically, we don't see the PCI error messages. Let's try higher speeds:
# arecord -D hw:1,1 -r 192000 -f S16_LE -t wav test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate
192000 Hz, Mono
Works perfect. Now the next speed: 448000 Sps:
# arecord -D hw:1,1 -r 448000 -f S16_LE -t wav test.wav
arecord: main:434: bad speed value 448000
Fails. The ALSA utility is limited at 192000 Sps.
Patch aplay.c
We will modify aplay.c to obtain higher sampling speeds. Go to the ALSA utilities folder we have previously compiled. The arecord utility is an alias from aplay.
# cd alsa-utils-1.0.6/aplay
# gedit aplay.c
Place the cursor in line 433 and change the value 192000 to 896000:
if (tmp < 2000 || tmp > 896000) {
Save and compile.
# cd alsa-utils-1.0.6
# make
# make install
Obsolete!
Capture test (3)
# arecord -D hw:1,1 -r 448000 -f S16_LE -t wav test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 448000 Hz,
Mono
Works. Let's try a bit higher: 896000 Sps.
# arecord -D hw:1,1 -r 896000 -f S16_LE -t wav test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 896000 Hz, Mono
Warning: rate is not accurate (requested = 896000Hz, got = 448000Hz)
please, try the plug plugin (-Dplug:hw:1,1)
Fails. Now we have the 448000 limit inside the module.
Patch the bt87x.c module (2)
Let's modify the bt87x.c module again but now to get 896000 Sps.
# cd alsa-driver-1.0.6a/alsa-kernel/pci/
# gedit bt87x.c
Place the cursor in line 308 and change the value 448000 with 896000:
.rate_max = 896000,
Now in line 351 and change the value 4 by 2:
.den_min = 2,
Save and compile again:
# make
# make install
Unload and load the module:
# rmmod snd-bt87x
# modprobe snd-bt87x
Capture test:
# arecord -D hw:1,1 -r 896000 -f S16_LE -t wav test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 896000 Hz, Mono
And works perfect. Now we have ALSA working at 896000 Sps. We get the following spectrum using the "cable around TV" technique (as previously explained).
Obsolete!
SoX under ALSA
SoX support ALSA but is necessary to compile it to use the native device. (?) Download the last stable version (sox-12.17.5.tar.gz) from here: http://sox.sourceforge.net/.
Compile:
# cd sox-12.17.5
# ./configure
Then get this Warning but I've ignored it:
...
configure: WARNING: sound/asound.h: present but cannot be compiled
configure: WARNING: sound/asound.h: check for missing prerequisite headers?
configure: WARNING: sound/asound.h: proceeding with the preprocessor's result
configure: WARNING: ##
------------------------------------ ##
configure: WARNING: ## Report this to bug-autoconf@gnu.org.
##
configure: WARNING: ##
------------------------------------ ##
...
# make
And not we get this error:
cc -g -O2 -Wall -I. -I. -c -o alsa.o alsa.c
In file included from alsa.c:32:
/usr/include/sound/asound.h:140: error: syntax error before '*' token
/usr/include/sound/asound.h:143: error: syntax error before '}' token
/usr/include/sound/asound.h:149: error: invalid application of `sizeof' to an
incomplete type
/usr/include/sound/asound.h:451: error: variable or field `__user' declared void
/usr/include/sound/asound.h:451: error: syntax error before '*' token
/usr/include/sound/asound.h:453: error: syntax error before '}' token
/usr/include/sound/asound.h:457: error: variable or field `__user' declared void
/usr/include/sound/asound.h:457: error: syntax error before '*' token
/usr/include/sound/asound.h:459: error: syntax error before '}' token
/usr/include/sound/asound.h:484: error: invalid application of `sizeof' to an
incomplete type
/usr/include/sound/asound.h:485: error: invalid application of `sizeof' to an
incomplete type
/usr/include/sound/asound.h:486: error: invalid application of `sizeof' to an
incomplete type
/usr/include/sound/asound.h:487: error: invalid application of `sizeof' to an
incomplete type
/usr/include/sound/asound.h:781: error: syntax error before '*' token
/usr/include/sound/asound.h:783: error: syntax error before '}' token
/usr/include/sound/asound.h:845: error: invalid application of `sizeof' to an
incomplete type
make: *** [alsa.o] Error 1
In this article: http://lwn.net/Articles/28348/ we can see the missing header. Edit the /usr/include/sound/asound.h file.
# gedit /usr/include/sound/asound.h
At line 22 (i.e.) we should add this text:
#define __user __attribute__((address_space(1)))
Compile again and install:
# make
# make install
Check the Sox installation and we can see ALSA as one supported "file format":
# sox -h sox: Version 12.17.5 Usage: [ gopts ] [ fopts ] ifile [ fopts ] ofile [ effect [ effopts ] ] gopts: -e -h -p -v volume -V fopts: -r rate -c channels -s/-u/-U/-A/-a/-i/-g/-f -b/-w/-l/-d -x effect: avg band bandpass bandreject chorus compand copy dcshift deemph earwax echo echos fade filter flanger highp highpass lowp lowpass map mask pan phaser pick pitch polyphase rate repeat resample reverb reverse silence speed stat stretch swap synth trim vibro vol effopts: depends on effect Supported file formats: aiff al alsa au auto avr cdr cvs dat vms gsm hcom la lu maud nul ossdsp prc raw sb sf sl smp sndt sph 8svx sw txw ub ul uw voc vorbis vox wav wve
Now the problem is that SoX gives the error "ioctl operation failed 22" with every parameters combination I've tried.
# sox -V -r 448000 -sw -t alsa /dev/snd/pcmC1D1c -t .wav test.wav
sox: Failed reading /dev/snd/pcmC1D1c: ioctl operation failed 22
-V Verbose
-r Sample rate
-sw Signed Word (?)
-b Byte (tested but give the same error)
-w Word (16 bits) (tested but give the same error)
/dev/snd/pcmC1D1c Native device from ALSA for the Bt878a. C1
is the second physical device (C0 for the first one, my SoundBlaster). D1 is the
second logical device (D0 is the digital audio interface from the Bt878). The c
letter in the device name stands for capture (and p for play).
I've successfully checked that SoX captures thru ALSA with the SoundBlaster card (/dev/snd/pcmC0D0c) but not with our beloved chip.
email sent to [SoX-Users]
Here you have more tests:
SoX with ALSA and my old “Creative ViBRA16C pnp”. Works perfect.
[root@lab root]# sox -V -w -c 1 -r 44100 -t alsa /dev/snd/pcmC0D0c -t .wav
test.wav
sox: Input file /dev/snd/pcmC0D0c: using sample rate 44100
size shorts, encoding signed (2's complement), 1 channel
sox: Input file /dev/snd/pcmC0D0c: comment "/dev/snd/pcmC0D0c"
sox: Writing Wave file: Microsoft PCM format, 1 channel, 44100 samp/sec
sox: 88200 byte/sec, 2 block align, 16 bits/samp
sox: Output file test.wav: using sample rate 44100
size shorts, encoding signed (2's complement), 1 channel
sox: Output file: comment "/dev/snd/pcmC0D0c"
sox: Finished writing Wave file, 196608 data bytes 98304 samples
But there is no way to make the Bt878a to work.
[root@lab root]# sox -V -b -c 1 -r 448000 -t alsa /dev/snd/pcmC1D1c -t .wav
test.wav
sox: Failed reading /dev/snd/pcmC1D1c: ioctl operation failed 22
[root@lab root]# sox -V -w -c 1 –r 448000 -t alsa /dev/snd/pcmC1D1c -t .wav
test.wav
sox: Failed reading /dev/snd/pcmC1D1c: ioctl operation failed 22
[root@lab root]# sox -V -w -c 2 –r 448000 -t alsa /dev/snd/pcmC1D1c -t .wav
test.wav
sox: Failed reading /dev/snd/pcmC1D1c: ioctl operation failed 22
And default sample rate:
[root@lab root]# sox -V -w -c 1 -t alsa /dev/snd/pcmC1D1c -t .wav test.wav
sox: Failed reading /dev/snd/pcmC1D1c: ioctl operation failed 22
The conclusion is clear: I have some problem with the Bt878 driver. It’s strange
because with the native arecord utility works well.
I’ll try to activate some kind of debug into the driver.
I’ll keep you posted.
Bye.
Obsolete!
ToDo List
- Make SoX work together with ALSA
- Check the operation of the ALSA OSS emulator with Audacity and baudline.
-
- Credits
Clemens Ladisch
- Author:
Juan Domenech Fernandez
http://www.domenech.org
I'll appreciate any comment or suggestion sending me an email with the Subject:
[domenech]
v0.2 16-october-2004
v0 11-october-2004
Obsolete!