Adjusting ALSA ASoC driver for Beaglebone hooked w ADAU1373

I am hooking up an ADAU1373 with a Beaglebone board to use as audio codec. The codec is on an eval board, and I connect the I2C and I2S lines from the Beaglebone pinrow connecters manually (later we will be making a custom cape with the codec).

I am using a kernel compiled from the package linux-04.06.00.03.tar.gz inside the latest AM335X-LINUX-PSP-04.06.00.03 package from TI.

uname -a gives "Linux am335x-evm 3.1.0 #16 Sun Apr 29 18:41:48 CEST 2012 armv7l unknown"

My problem now is that I can't get ALSA to register a sound card. By inserting printk's in soc_bind_dai_link in sound/soc/soc-core.c I can see that the codec is not getting registered (codec_list is apparantly empty) preventing the sound card to register (the platform and cpu_dai  'davinci-mcasp.0' are found). Since there are no codecs natively on the Beaglebone this is not too surprising.

I also do understand that I need to setup pinmuxing on the Beaglebone; I have adjusted the pinmux settings in the file arch/arm/mach-omap2/board-am335xevm.c, but this is not the issue here I think (for details see e.g. a thread here: http://e2e.ti.com/support/embedded/linux/f/354/p/158851/621986.aspx#621986)

I also need to configure the snd_soc_dai_link struct called am335x_evm_dai in sound/soc/davinci/davinci-evm.c to use my codec. Most people using sound on the Beaglebone have used an AIC3X codec (codec_dai_name = "tlv320aic3x-hifi") on a DVI-D cape for the Beaglebone board, but if I specify this codec in davinci-evm.c no codec registers (I suppose linux somehow knows the codec is not present although I dont understand how).

What I would like to be able to is to have a bunch of different codec drivers as kernel modules, and load the one I need (i.e. connect a codec manually, and insmod something, then have sound playing with alsa) - the 1373 is not the only codec I want to be able to connect to this board, its just the one I'd like to use as a starting point and hopefully from this discussion here learn enough to adjust this driver for other codecs.

To begin with I can configure the codec using the sigma studio software running on a pc, so I suspect all that would be required as a starting point is some extremely simple codec driver that merely registers itself without actually doing much else. 

So I am basically asking: how do I go about creating a codec driver for the 1373, so that the codec driver gets to show up in the codec_list (in soc-core) so that my platform will be able to register a sound card? Does what I am trying to do make sense?

Thanks a lot for any help!

  • Hi,

    You need to register the CODEC as an I2C device for it to show up in the codec_list. An example for this can be found here. There are already i2c_board_info tables in board-am335xevm.c, so it should just be a matter of adding the adau1373 entry to the right one.

    Btw. there are a few debug files in /sys/kernel/debug/asoc/ which list all registered codecs, dais and platforms.

  • Hi,

    You need to select the codec from the Kconfig entry for your ASoC board file: 'select SND_SOC_ADAU1373'.

    Take a look at the SND_SOC_BFIN_EVAL_ADAU1373 entry in sound/soc/blackfin/Kconfig.

    - Lars

  • Yes, you need to make sure that you configure the PLL and sysclks properly. Please take a look at

    http://wiki.analog.com/resources/tools-software/linux-drivers/sound/adau1373#pll_configuration for an example and a description which configuration options are available.

  • OK thanks. I ran into a problem here: how do I make the kernel compile the code for my codec?

    I am using the kernel source linux-04.06.00.03.tar.gz as I wrote, and this tar file does not include the 1373 codec source code you refer to. I downloaded the three files (sound/soc/codecs/adau1373.c and .h and include/sound/adau1373.h) and I tried adding lines to sound/soc/Makefile


    snd-soc-adau1373-objs := adau1373.o

    and

    obj-$(CONFIG_SND_SOC_ADAU1373)  += snd-soc-adau1373.o

    but when I try to cross-compile with

    make CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm uImage modules

    the module does not get compiled.

  • I got the codec registered! What I missed for the 1373 module to compile were two lines in sound/soc/codecs/Kconfig:

      config SND_SOC_ADAU1373

              tristate

    When compiling the  adau1373.c file I get an error in the adau1373_probe() function, at the two places where the snd_soc_add_codec_controls is called. To get by this I changed the function call to snd_soc_add_controls (I could see from some posts that this was probably the old name in the kernel version 3.1.0 I am using)  and I was able to get the codec registered,and I now have a sound card registered with alsa, hurray!

    Now, my problem is to get sound to play.. When I try to play a 44.1 kHz wav file with aplay, I get the following output (probably because the above lines were commented out): (ADDED LATER: I think the bug is in evm_hw_params in davinvi-evm.c where sysclk is specified to 12MHz)

    [ 1721.465733] asoc: can't set codec adau1373-aif1 hw params

    aplay: set_params:1129: Unable to install hw params:

    ACCESS:  RW_INTERLEAVED

    FORMAT:  S16_LE

    SUBFORMAT:  STD

    SAMPLE_BITS: 16

    FRAME_BITS: 32

    CHANNELS: 2

    RATE: 44100

    PERIOD_TIME: (46439 46440)

    PERIOD_SIZE: 2048

    PERIOD_BYTES: 8192

    PERIODS: 16

    BUFFER_TIME: (743038 743039)

    BUFFER_SIZE: 32768

    BUFFER_BYTES: 131072

    TICK_TIME: 0