[alsa-devel] ca0106 Digital Output at 44.1kHz

Ben Stanley Ben.Stanley at exemail.com.au
Thu Mar 13 13:15:24 CET 2008

Dear List,

Hello. I'm new here. This is my first attempt to hack an alsa driver.

I recently purchased a "Sound Blaster Audigy Value!" card for use in a
MythTV box. As I have a digital receiver, I was mainly concerned with
getting a working S/PDIF output (coax or optical) and not too much more.

Summary: I can make 44.1kHz digital output work, but I think that the
driver model of the card having 3 or 4 digital output channels is
incorrect. I believe the card only has 1 digital output channel.


The card I have is characterised by the following:
Model: SB0570
serial: 100a1102
Also known as: Sound Blaster Audigy SE

During initial testing, I noticed that 44.1kHz playback was not
implemented. Subsequent testing shows that speaker-test works fine with
48kHz, 96kHz and 192kHz. (I only tested 16bit output so far.)

I noticed in the source code that 44.1k was explicitly disabled. I added
code in snd_ca0106_pcm_prepare_playback to set up this rate for S/PDIF
output as per the comments in ca0106.h . Initial tests using hw:0,0 at
44.1kHz produced recognisable signals with some noisy corruption. Later
I accidentally discovered that serially opening hw:0,2 , hw:0,1 and
hw:0,0  at 44.1kHz then produces perfectly good 44.1kHz sampled digital
audio output. Removing hw:0,1 or hw:0,2 from this sequence causes noisy
corruption. It seems that channels 0-2 in reg40 must all be set to the
same sampling frequency for S/PDIF to work where 44.1kHz is concerned.
Conversely, to sucessfully output 48kHz again, I have to open hw:0,2 ,
hw:0,1 and hw:0,0 at 48kHz to restore proper output. I do not have such
troubles with 96kHz and 192kHz, for which it suffices to just open
hw:0,0 at the relevant sampling rate.

Using these tricks, I can successfully output 44.1kHz encoded Dolby
Digital and DTS signals (found at
http://www.sr.se/cgi-bin/mall/index.asp?programid=2445 , as mentioned at
http://alsa.opensrc.org/DigitalOut . )

Later, I examined the product manual (from a Windows compressed helpfile
on the CD), and noticed that Creative instruct you to connect to the
blue socket in only two ways:
1) with a mono 3.5mm jack plug to RCA plug -> S/PDIF input to external
device, and
2) a proprietary digital I/O module (see
http://www.soundblaster.com/products/product.asp?category=1&subcategory=16&product=1780 )
The digital I/O module only has one input and one output (the
optical/coaxial pairs are duplicates of each other). 

The manual does not say how to connect a S/PDIF input signal other than
through the digital I/O module.

This suggests to me that the following comment near the top of
ca0106_main.c is incorrect for the SB0570:

 *    ( In theory one could output 3 different AC3 streams at once, to 3
different SPDIF outputs. )

I think you can only output one AC3 stream, and that there is only one
S/PDIF output.

Given this knowledge of the digital I/O module, I suggest that the
pinout *may* possibly be:
1 (tip): S/PDIF output
2      : S/PDIF input
3      : power to digital I/O module
4      : gnd
I have not been able to get any S/PDIF signal out of pin 2 (I only have
a stereo cable to test with at the moment). I will attempt to test pin 2
as an input at some point.

I think that this card can only output one S/PDIF channel, given the
discovery of the required clock settings above, and that Creative's own
hardware only gives you access to one output.

Anyway, I don't have access to documentation. From reading around, I
believe James has the docs under NDA from Creative Labs. Perhaps James
could confirm these suspicions?

Anyway, this is speculation. I'd love to have the docs. I haven't tried
to get them. Is it likely/unlikely that I would get them?

I'm currently working on kernel 2.6.22 from Ubuntu. They don't seem to
have changed the ca0106 driver, and not much has happened there (for
output) in the newer kernels.

Please find attached my current patch, which is only suitable for the
purposes of discussion. I need to clarify some things about channel
arrangements with those who have the documentation before I begin to try
to fix things up. This patch was written with a faulty understanding of
the interaction between the channel model and the spdif_enable. I don't
know how any of this affects other models in the ca0106 range.

So, I think that before I go any further here, I need some feedback, and
access to some documentation would be useful.

Ben Stanley.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ca0106_44.1kHz_v0.1.patch
Type: text/x-patch
Size: 4140 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20080313/f52484b8/attachment.patch 

More information about the Alsa-devel mailing list