Index of /~stuartl/asoc

[ICO]NameLast modifiedSizeDescription
[DIR]Parent Directory   -  
[TXT]0001-ASoC-Add-new-TI..>05-Jul-2010 14:34 176K 
[TXT]COPYING 03-Jun-2010 21:25 18K 

ASoC driver for the TLV320AIC3204

What is it?

This is an early stab at a CODEC driver for the Texas Instruments TLV320AIC3204 audio CODEC. This is being done as part of my work with Jacques Electronics Pty Ltd, and will be contributed to the opensource community as part of the ALSA ASoC tree.

What stage is it at?

The patch above has been submitted for inclusion, hopefully in the 2.6.36 kernel.

How do I use it?

Apply the above patch, this patch was made against this commit and should apply to most contemporary kernels.

Much like other CODEC drivers; you ensure the CODEC is added as a platform device in your board's I2C config...

e.g. in arch/arm/mach-mx2/mach-tx27.c (yes, I'll contribute that too when it's ready)

/* Don't forget to include the driver's header! */
#include <sound/tlv320aic3204.h>

/* ... etc ... */

static struct aic3204_pdata tx27_aic3204_pdata = {
	/* Your GPIO line wired to the hardware reset */
	.gpio_reset		= -1,	

	/* Analogue Input power-up delay; in this case 1.65msec */
	.ain_powerup_delay	= AIC3204_PDATA_AIN_PWRUP_1M65S,
	
	/* Analogue reference voltage power-up delay; in this case 40msec */
	.ref_powerup_delay	= AIC3204_PDATA_REF_PWRUP_40MS,

	/* Whether to keep the link between AVDD and DVDD; in this case no */
	.avdd_link_en		= 0;

	/* Whether to enable the LDO; in this case yes */
	.ldo_en			= 1;
	
	/* Oversampling ratio for both ADC and DAC */
	.osr			= 128;
};

static struct i2c_board_info tx27_i2c0_devices[] __initdata = {
        {
                I2C_BOARD_INFO("24c16", 0x50),
                .platform_data = &tx27_eeprom,
                .type = "24c16",
        },
        {
                I2C_BOARD_INFO("tlv320aic3204", 0x18),
		.platform_data = &tx27_aic3204_pdata,
                .type = "tlv320aic3204",
        },

While you're in there... don't forget to set up your host's DAI too... e.g.

/* The AIC3204 driver works best in I2S Slave mode */
static struct imx_ssi_platform_data foobar_ssi_pdata = {
	.flags  = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
};

...

static void __init tx27_board_init(void)
{
	...

	mxc_register_device(&imx_ssi_device0, &foobar_ssi_pdata);

	...
}

Then use it in your ASoC machine driver.

e.g. in sound/soc/imx/jem3.c (also will be contributed when ready)

static struct snd_soc_dai_link jem3_dai = {
        .name = "JEM3",
        .stream_name = "Audio",
        .cpu_dai = &imx_ssi_pcm_dai[0],
        .codec_dai = &aic3204_dai,
        .init = jem3_init,
        .ops = &jem3_ops,
        .symmetric_rates = 1,
};

Finally, in your initialisation, be sure to set up your DAI formats, and the CODEC's source clock speed!

#define CODEC_CLKIN	1228800	/* Frequency in Hz */

...

static int foobar_init(struct snd_soc_codec *codec)
{
	...
	
        /* set CODEC clock */
        ret = snd_soc_dai_set_sysclk(&aic3204_dai, 0, CODEC_CLKIN,
                        SND_SOC_CLOCK_IN);
        if (ret < 0) {
                printk( KERN_ERR "%s: Unable to set CODEC sysclock (%d)\n",
                                __func__, res );
                return ret;
        }

	...
}

Contact

Feedback and patches greatly welcome (and encouraged!)... send to me@vk4msl.yi.org