This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x Line In with WM8580 Codec

This entry is kind of a continuation of:

http://e2e.ti.com/support/arm/sitara_arm/f/791/t/307825.aspx

I just felt that putting under the same entry would cause for confusion though.

Anyways if you look at the other post you will see that i was able to get audio output working on all 6 channels awhile back and it has been working great ever since.  Recently i needed to get the line in (2 channel ADC) of the codec working.  I encountered a couple issues in doing this:

1.  If you look at my schematics on the other post i tied the ADC Bit Clk to the DAC Bit Clk and the ADC Frame Sync to the DAC Frame Sync.  I was then setting the Codec up as the master so as soon as both the ADC and DAC were initialized it would all stop working because they were both trying to source a clock.  Anyways this i fixed by modifying sound/soc/codecs/wm8580.c to init the DAC along with the ADC so that i could set the ADC as a slave allowing the DAC to control the clocks.  The way i coded this into wm8580 rather than using calls from my davinci-evm.c file doesn't seem that desireable to me, so i may go back and try to get this set up more cleanly at some point.

2.  Now this is the issue i have question on.  Basically the codec has 6 output channels and only 2 input, so when the ADC is running you get data in the first 2 TDM slots but the other 4 have just garbage.  Everything was set up to have only 2 capture channels and when i record data from linux it reads the garbage slots as input for my 2 channels.  This means my sample is record 3x slower with a bunch of static and stuff introduced from it pulling in the garbage TDM slots.  I could not figure out the way to indicate that only the 2 of the slots should be used.  What i ended up doing was setting capture to 6 channels, so that it is essentially caputuring the other 4 slots as seperate channels.  I can set up a config in asound.conf to use only those 2 channels.  This seems to work great, but it doesn't seem like the right way.  Is there a better way to indicate that the last 4 slots should be ignored or is setting it to 6 channels like i did the only way?

  • I think the way you currently do it is fine, and it definitely requires less effort than modifying the driver.

    However, if you did want to modify the driver to allow for 2 channel input while you have 6 channel output, it should be possible.  For instance, the WiLink8 bluetooth audio configuration on OMAP devices uses 2 channels, but only 1 channel actually has valid data; this is done by setting the BCLK/FSYNC so that only the first channel is extracted.  Look at the source for more information (the dra7_snd_bt_hw_params function is where this occurs).  There would be some work required to modify your machine driver (davinci-evm.c), but it could be done.  The concern would be whether or not it is possible to set the BCLK/FSYNC ratio needed for your case, I suppose.

    There are probably better ways to do it than what I mentioned, but I've never messed around much with cases like what you are dealing with, so my knowledge is limited.

  • Jelliott,

    Thanks for the input!  Okay i just wanted some verification that what i did isn't going to cause some horrible destruction down the road : ).

    What makes it really difficult for me to come up with a good scheme other than fooling the system into thinking both in and out are 6 channels is the fact that they share the same bclk and fsync.  But maybe if I'm bored one day after i finish everything up i will come back to this if it still bothers me : ).

    For now I'm just going to clean up what i did and move on : ).  Thanks!