[alsa-devel] ca0106 Digital Output at 44.1kHz
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.
Details:
The card I have is characterised by the following: http://www.soundblaster.com/products/product.asp?category=1&subcategory=... 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=... ) 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.
Ben Stanley wrote:
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 ca0106 chip has 3 or 4 digital outputs. These outputs may or may not be present on the output connectors of the card. I know that one of the SB cards does in fact work with 3 digital outputs using the 4 pin jacks because I have tested it myself. I GPIO is programmed to switch it between 3 digital outputs and 1 in, 1 out.
Details:
The card I have is characterised by the following: http://www.soundblaster.com/products/product.asp?category=1&subcategory=... 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.
The ca0106 can do 44.1kHz for digital output ONLY. The ca0106 cannot output 44.1kHz to the DACs so it will only work in Digital mode. It is a hardware restriction. You are correct, all the inputs and outputs have to be at the same rate.
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?
You can sign an open-source NDA and get the datasheets. It lets me write drivers like the current ca0106 and E-Mu drivers. If you are interested in a NDA, priv-email me.
Kind Regards
James
James,
Thanks for taking the time to read through my long and perhaps slightly prickly email.
On Sat, 2008-03-22 at 10:31 +0000, James Courtier-Dutton wrote:
Ben Stanley wrote:
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 ca0106 chip has 3 or 4 digital outputs. These outputs may or may not be present on the output connectors of the card. I know that one of the SB cards does in fact work with 3 digital outputs using the 4 pin jacks because I have tested it myself. I GPIO is programmed to switch it between 3 digital outputs and 1 in, 1 out.
So, could we then change the number of channels available depending upon which card is detected? It doesn't seem to make sense to make things available to the user via the driver that they can't plug something into on their particular model card. I guess that to do this I would have to know how many digital output channels are supported by each card. I downloaded the user manuals for a few of the cards; I only got the impression that each card supported one digital output. Do you know which card you tested for multiple outputs?
(I appreciate that you still have very low version numbers on this driver, and that therefore it remains a work in progress.)
Now, the Creative Labs user documentation gives me the impression that I can use the analog output channels at the same time as the digital output channel. That also doesn't appear to agree with how the driver is written. I am currently under the impression that the driver is written to allow 4 stereo analog channels or 4 digital channels. At least that is how things look when configuring things using alsamixer. Perhaps I am confused and should go and look at the GPIO that you mentioned above.
Details:
The card I have is characterised by the following: http://www.soundblaster.com/products/product.asp?category=1&subcategory=... 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.
The ca0106 can do 44.1kHz for digital output ONLY. The ca0106 cannot output 44.1kHz to the DACs so it will only work in Digital mode. It is a hardware restriction. You are correct, all the inputs and outputs have to be at the same rate.
So far I haven't considered 'inputs', although I do now have the digital I/O module so that I can get digital signals into the card. I suspect I can only generate 44.1kHz and 48kHz sampled input signals to test with.
So for my card where only one output channel appears to be available (can you tell from the doc if this is true?), then I would just slave the other hardware channels to hw:0,0 settings. However, on other cards where the other channels are in fact available, how do you enforce the restriction that all the channels must have the same sampling frequency within the ALSA model?
I'm just trying to plan how I would fix this properly within the driver.
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?
You can sign an open-source NDA and get the datasheets. It lets me write drivers like the current ca0106 and E-Mu drivers. If you are interested in a NDA, priv-email me.
I have applied to Creative's 'Partnership' program and faxed off the forms last week. I've written user-space drivers for custom wire-wrapped logic + PAL glued hardware before, but not for modern chips, or coded for kernel space. Anyway, there's a first time for everything :-)
Kind Regards
James
Thanks for your help, Ben.
Ben Stanley wrote:
So, could we then change the number of channels available depending upon which card is detected? It doesn't seem to make sense to make things available to the user via the driver that they can't plug something into on their particular model card. I guess that to do this I would have to know how many digital output channels are supported by each card. I downloaded the user manuals for a few of the cards; I only got the impression that each card supported one digital output. Do you know which card you tested for multiple outputs?
Unfortunately the datasheets do not give me card specific details. Only how to program the ca0106 chip. The GPIO etc. for each card is determined by trial and error.
Now, the Creative Labs user documentation gives me the impression that I can use the analog output channels at the same time as the digital output channel. That also doesn't appear to agree with how the driver is written. I am currently under the impression that the driver is written to allow 4 stereo analog channels or 4 digital channels. At least that is how things look when configuring things using alsamixer. Perhaps I am confused and should go and look at the GPIO that you mentioned above.
This particular sound card can output to both analog and digital channels. The sound is simply duplicated to both. I disabled it happening at the same time mainly due to what happens when AC3 or DTS is output to the digital. One would not want that send to the analog outputs!
Details:
The card I have is characterised by the following: http://www.soundblaster.com/products/product.asp?category=1&subcategory=... 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.
The ca0106 can do 44.1kHz for digital output ONLY. The ca0106 cannot output 44.1kHz to the DACs so it will only work in Digital mode. It is a hardware restriction. You are correct, all the inputs and outputs have to be at the same rate.
So far I haven't considered 'inputs', although I do now have the digital I/O module so that I can get digital signals into the card. I suspect I can only generate 44.1kHz and 48kHz sampled input signals to test with.
So for my card where only one output channel appears to be available (can you tell from the doc if this is true?), then I would just slave the other hardware channels to hw:0,0 settings. However, on other cards where the other channels are in fact available, how do you enforce the restriction that all the channels must have the same sampling frequency within the ALSA model?
I'm just trying to plan how I would fix this properly within the driver.
You could set the driver to fix to the rate of the first opened device, and only when all devices have been closed could the rate change again. This is unfortunately not at all intuitive for the user. I would therefore add a global mixer control to set 44.1 or 48kHz. The user could then decide which to use. 44.1 would mean 44.1, 88.2 etc. 48 would mean 48, 96, 192.
By the way, the spdif output on the ca0106 works well at 96kHz also.
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?
You can sign an open-source NDA and get the datasheets. It lets me write drivers like the current ca0106 and E-Mu drivers. If you are interested in a NDA, priv-email me.
I have applied to Creative's 'Partnership' program and faxed off the forms last week. I've written user-space drivers for custom wire-wrapped logic + PAL glued hardware before, but not for modern chips, or coded for kernel space. Anyway, there's a first time for everything :-)
Good luck. Who are you talking to?
James
Further to this old discussion of 44.1kHz on ca0106 cards,
I have implemented a patch that 'works for me' on my mythtv box. It allows me to play 44.1kHz to SPDIF digital output.
I only need one 'device', e.g. hw:0,0 . Just as well, I can only manage to get output from hw:0,0 on SPDIF on my Sound Blaster Audigy Value! card.
I never received any reply from Creative on my NDA request. I followed up with Phillip Williams, who forwarded my query to corporate, but didn't receive a reply from that. I need to follow up again.
Anyway, I have a patch. I have based it upon the current Ubuntu kernel 2.6.22-14.52. I have attached the patch with respect to the original file, and the complete modified file. I think I have more work to do before it can be merged, such as re-basing the patch on latest git. (I had problems accessing git tonight, so I'll try again when fixed.)
I implemented a constraint system to restrict the available sampling frequencies in accordance with the rules previously determined (you may select one or more channels in 44.1kHz, XOR you may select one or more channels in any of 48kHz, 96kHz and 192kHz).
The problem is to decide when a device has its sampling frequency 'allocated'. At the moment, the patch uses the 'running' (true between triggering RUN and triggering STOP) variable to determine if the device is in use. This definition probably allows a race condition between testing the constraint and triggering the RUN. I need some help here to figure out a more robust scheme, as I don't understand the internals of the ALSA PCM layer yet.
Once we have figured out how to deal with the sampling frequencies, I'll deal with the sampling format in the same way.
Anyway, I submit the patch to the list for review and comment.
Ben Stanley.
On Thu, 2008-04-17 at 21:52 +0100, James Courtier-Dutton wrote:
Ben Stanley wrote:
So, could we then change the number of channels available depending upon which card is detected? It doesn't seem to make sense to make things available to the user via the driver that they can't plug something into on their particular model card. I guess that to do this I would have to know how many digital output channels are supported by each card. I downloaded the user manuals for a few of the cards; I only got the impression that each card supported one digital output. Do you know which card you tested for multiple outputs?
Unfortunately the datasheets do not give me card specific details. Only how to program the ca0106 chip. The GPIO etc. for each card is determined by trial and error.
Now, the Creative Labs user documentation gives me the impression that I can use the analog output channels at the same time as the digital output channel. That also doesn't appear to agree with how the driver is written. I am currently under the impression that the driver is written to allow 4 stereo analog channels or 4 digital channels. At least that is how things look when configuring things using alsamixer. Perhaps I am confused and should go and look at the GPIO that you mentioned above.
This particular sound card can output to both analog and digital channels. The sound is simply duplicated to both. I disabled it happening at the same time mainly due to what happens when AC3 or DTS is output to the digital. One would not want that send to the analog outputs!
Details:
The card I have is characterised by the following: http://www.soundblaster.com/products/product.asp?category=1&subcategory=... 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.
The ca0106 can do 44.1kHz for digital output ONLY. The ca0106 cannot output 44.1kHz to the DACs so it will only work in Digital mode. It is a hardware restriction. You are correct, all the inputs and outputs have to be at the same rate.
So far I haven't considered 'inputs', although I do now have the digital I/O module so that I can get digital signals into the card. I suspect I can only generate 44.1kHz and 48kHz sampled input signals to test with.
So for my card where only one output channel appears to be available (can you tell from the doc if this is true?), then I would just slave the other hardware channels to hw:0,0 settings. However, on other cards where the other channels are in fact available, how do you enforce the restriction that all the channels must have the same sampling frequency within the ALSA model?
I'm just trying to plan how I would fix this properly within the driver.
You could set the driver to fix to the rate of the first opened device, and only when all devices have been closed could the rate change again. This is unfortunately not at all intuitive for the user. I would therefore add a global mixer control to set 44.1 or 48kHz. The user could then decide which to use. 44.1 would mean 44.1, 88.2 etc. 48 would mean 48, 96, 192.
By the way, the spdif output on the ca0106 works well at 96kHz also.
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?
You can sign an open-source NDA and get the datasheets. It lets me write drivers like the current ca0106 and E-Mu drivers. If you are interested in a NDA, priv-email me.
I have applied to Creative's 'Partnership' program and faxed off the forms last week. I've written user-space drivers for custom wire-wrapped logic + PAL glued hardware before, but not for modern chips, or coded for kernel space. Anyway, there's a first time for everything :-)
Good luck. Who are you talking to?
James _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (2)
-
Ben Stanley
-
James Courtier-Dutton