[alsa-devel] Writing an ASoC codec driver for Beaglebone McASP

Ulrik Kjems ulrikkjems at yahoo.dk
Wed Apr 25 15:20:41 CEST 2012

I am working on connecting audio from the beaglebone McASP to a codec on an eval board, supporting a general TDM format. I know for sure the setup is viable because I have the system running in a bare-metal configuration using Starterware. I want to make it work under Linux ALSA/ASoC. I am willing to share the source code if anyone is interested in working on this as well.

To do this I need to configure/write a driver for ALSA/ASoC, and my goal is to be able to perform multi-channel sound capture and playback using ALSA.

The current kernel (3.2.14) davinci platform driver (davinci-evm.c) apparantly supports TI's AM3358 EVM board, which uses the same ARM3358 Sitara processor as the Beaglebone. The EVM board uses a similar (but not identical) McASP config (and a TLV320AIC3x codec, I believe).

When booting the kernel on the Beaglebone the ALSA driver fails to register with the McASP. 
I can see in soc-core.c around line 825 that four client devices must be found: codec, codec_dai, platform, and platform_dai. By modifying sound/soc/davinci/davinci-evm.c to reflect the fact that for beaglebone McASP 0 is being used (as opposed to the EVM board where mcasp 1 is in use), I can make the platform register:

static struct snd_soc_dai_link am335x_evm_dai = {
    .name = "TLV320AIC3X",
    .stream_name = "AIC3X",
    //    .cpu_dai_name = "davinci-mcasp.1",   
    .cpu_dai_name = "davinci-mcasp.0",  // <<<<<<<Changed
    .codec_dai_name = "tlv320aic3x-hifi",
    .codec_name = "tlv320aic3x-codec.1-001b",
    .platform_name = "davinci-pcm-audio",
    .init = evm_aic3x_init,
    .ops = &evm_ops,

Now, all I need is for the codec to register. If I look at /sys/kernel/debug/asoc/ I can see the davinci platform now (the above change enables this)

~# cat /sys/kernel/debug/asoc/platforms 
~# cat /sys/kernel/debug/asoc/dais      
~# cat /sys/kernel/debug/asoc/codecs      # No codecs!

Of course, I dont have the codec tlv320aic3x-hifi on my system,- but for now I would be happy configuring my codec manually (as I said its on an eval board with a config software tool I can use in place of I2C) so that I could get sound through the system. 
So my question is, how do I go about convincing ALSA that its OK not to have the codec? 

Is there a generic codec I could use as a starting point (e.g. setting codec_dai_name in the above struct to something else)?

I dont understand the kernel code well enough to see why and how the kernel can detect the absence of the TLV codec above - I dont seem to be getting any calls to any of the functions inside sound/soc/codecs/tlv320aic3x.c except aic3x_modinit(void) - how on earth does the system know the codec is not there ?

More information about the Alsa-devel mailing list