Mark, I suggest to do the same naming changes in the machine part like I 've suggested for tlv32024K codec driver: rename all tlv320 places to tlv320aic2x and "aic2x_" Also I suggest to name all static functions in the machine ASoC part to begin from ameson_ and not the codec one. Regards, Vladimir Mark Brown wrote: > From: Liam Girdwood <liam@xxxxxxxxxxxxxxxxxxxxx> > > Signed-off-by: Nicola Perrino <nicola.perrino@xxxxxxxx> > Signed-off-by: Liam Girdwood <lg@xxxxxxxxxxxxxxxxxxxxxxxxxxx> > --- > sound/soc/pxa/Kconfig | 10 ++ > sound/soc/pxa/Makefile | 3 +- > sound/soc/pxa/amesom_tlv320.c | 211 +++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 223 insertions(+), 1 deletions(-) > create mode 100644 sound/soc/pxa/amesom_tlv320.c > > diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig > index ca825e6..bcb3aa0 100644 > --- a/sound/soc/pxa/Kconfig > +++ b/sound/soc/pxa/Kconfig > @@ -57,3 +57,13 @@ config SND_PXA2XX_SOC_TOSA > help > Say Y if you want to add support for SoC audio on Sharp > Zaurus SL-C6000x models (Tosa). > + > +config SND_PXA2XX_SOC_AMESOM_TLV320 > + tristate "SoC SSP Audio support for AMESOM - TLV320AIC24k" > + depends on SND_PXA2XX_SOC && MACH_AMESOM > + select SND_PXA2XX_SOC_I2S > + select SND_PXA2XX_SOC_SSP > + select SND_SOC_TLV320 > + help > + Say Y if you want to add support for SoC audio on Amesom > + with the tlv320. > diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile > index c631651..931bdc7 100644 > --- a/sound/soc/pxa/Makefile > +++ b/sound/soc/pxa/Makefile > @@ -14,9 +14,10 @@ snd-soc-corgi-objs := corgi.o > snd-soc-poodle-objs := poodle.o > snd-soc-tosa-objs := tosa.o > snd-soc-spitz-objs := spitz.o > +snd-soc-amesom-tlv320-objs := amesom_tlv320.o > > obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o > obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o > obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o > obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o > - > +obj-$(CONFIG_SND_PXA2XX_SOC_AMESOM_TLV320) += snd-soc-amesom-tlv320.o > diff --git a/sound/soc/pxa/amesom_tlv320.c b/sound/soc/pxa/amesom_tlv320.c > new file mode 100644 > index 0000000..6aa1c2c > --- /dev/null > +++ b/sound/soc/pxa/amesom_tlv320.c > @@ -0,0 +1,211 @@ > +/* > + * amesom_tlv320.c -- SoC audio for Amesom > + * > + * Copyright 2005 Wolfson Microelectronics PLC. > + * Copyright 2006 Atlab srl. > + * > + * Authors: Liam Girdwood <liam.girdwood@xxxxxxxxxxxxxxxx> > + * Nicola Perrino <nicola.perrino@xxxxxxxx> > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or (at your > + * option) any later version. > + * > + * Revision history > + * 5th Dec 2006 Initial version. > + * > + */ > + > +#include <linux/module.h> > +#include <linux/moduleparam.h> > +#include <linux/device.h> > +#include <linux/i2c.h> > +#include <sound/driver.h> > +#include <sound/core.h> > +#include <sound/pcm.h> > +#include <sound/soc.h> > +#include <sound/soc-dapm.h> > + > +#include <asm/hardware.h> > +#include <asm/arch/pxa-regs.h> > +#include <asm/arch/audio.h> > + > +#include "../codecs/tlv320.h" > +#include "pxa2xx-pcm.h" > +#include "pxa2xx-i2s.h" > +#include "pxa2xx-ssp.h" > + > + > +/* > + * SSP2 GPIO's > + */ > + > +#define GPIO11_SSP2RX_MD (11 | GPIO_ALT_FN_2_IN) > +#define GPIO13_SSP2TX_MD (13 | GPIO_ALT_FN_1_OUT) > +#define GPIO50_SSP2CLKS_MD (50 | GPIO_ALT_FN_3_IN) > +#define GPIO14_SSP2FRMS_MD (14 | GPIO_ALT_FN_2_IN) > +#define GPIO50_SSP2CLKM_MD (50 | GPIO_ALT_FN_3_OUT) > +#define GPIO14_SSP2FRMM_MD (14 | GPIO_ALT_FN_2_OUT) > + > + > +static struct snd_soc_machine amesom; > + > + > +static int amesom_probe(struct platform_device *pdev) > +{ > + return 0; > +} > + > +static int amesom_remove(struct platform_device *pdev) > +{ > + return 0; > +} > + > +static int tlv320_voice_startup(struct snd_pcm_substream *substream) > +{ > + return 0; > +} > + > +static void tlv320_voice_shutdown(struct snd_pcm_substream *substream) > +{ > + return; > +} > + > +/* > + * Tlv320 uses SSP port for playback. > + */ > +static int tlv320_voice_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai; > + struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; > + int ret = 0; > + > + //printk("tlv320_voice_hw_params enter\n"); > + switch(params_rate(params)) { > + case 8000: > + //printk("tlv320_voice_hw_params 8000\n"); > + break; > + case 16000: > + //printk("tlv320_voice_hw_params 16000\n"); > + break; > + default: > + break; > + } > + > + // CODEC MASTER, SSP SLAVE > + > + /* set codec DAI configuration */ > + ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_MSB | > + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); > + if (ret < 0) > + return ret; > + > + /* set cpu DAI configuration */ > + ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_MSB | > + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); > + if (ret < 0) > + return ret; > + > + /* set the SSP system clock as input (unused) */ > + ret = cpu_dai->dai_ops.set_sysclk(cpu_dai, PXA2XX_SSP_CLK_NET_PLL, 0, > + SND_SOC_CLOCK_IN); > + if (ret < 0) > + return ret; > + > + /* set SSP slots */ > + //ret = cpu_dai->dai_ops.set_tdm_slot(cpu_dai, 0x1, slots); > + ret = cpu_dai->dai_ops.set_tdm_slot(cpu_dai, 0x3, 1); > + if (ret < 0) > + return ret; > + > + return 0; > +} > + > +static int tlv320_voice_hw_free(struct snd_pcm_substream *substream) > +{ > + return 0; > +} > + > +static struct snd_soc_ops tlv320_voice_ops = { > + .startup = tlv320_voice_startup, > + .shutdown = tlv320_voice_shutdown, > + .hw_params = tlv320_voice_hw_params, > + .hw_free = tlv320_voice_hw_free, > +}; > + > + > +static struct snd_soc_dai_link amesom_dai[] = { > +{ > + .name = "TLV320", > + .stream_name = "TLV320 Voice", > + .cpu_dai = &pxa_ssp_dai[PXA2XX_DAI_SSP2], > + .codec_dai = &tlv320_dai[TLV320_DAI_MODE1_VOICE], > + .ops = &tlv320_voice_ops, > +}, > +}; > + > +static struct snd_soc_machine amesom = { > + .name = "Amesom", > + .probe = amesom_probe, > + .remove = amesom_remove, > + .dai_link = amesom_dai, > + .num_links = ARRAY_SIZE(amesom_dai), > +}; > + > +static struct tlv320_setup_data amesom_tlv320_setup = { > +#ifdef TLV320AIC24K //codec2 > + .i2c_address = 0x41, > +#else // TLV320AIC14k > + .i2c_address = 0x40, > +#endif > +}; > + > +static struct snd_soc_device amesom_snd_devdata = { > + .machine = &amesom, > + .platform = &pxa2xx_soc_platform, > + .codec_dev = &soc_codec_dev_tlv320, > + .codec_data = &amesom_tlv320_setup, > +}; > + > +static struct platform_device *amesom_snd_device; > + > +static int __init amesom_init(void) > +{ > + int ret; > + > + amesom_snd_device = platform_device_alloc("soc-audio", -1); > + if (!amesom_snd_device) > + return -ENOMEM; > + > + platform_set_drvdata(amesom_snd_device, &amesom_snd_devdata); > + amesom_snd_devdata.dev = &amesom_snd_device->dev; > + ret = platform_device_add(amesom_snd_device); > + > + if (ret) > + platform_device_put(amesom_snd_device); > + > + > + /* SSP port 2 slave */ > + pxa_gpio_mode(GPIO11_SSP2RX_MD); > + pxa_gpio_mode(GPIO13_SSP2TX_MD); > + pxa_gpio_mode(GPIO50_SSP2CLKS_MD); > + pxa_gpio_mode(GPIO14_SSP2FRMS_MD); > + > + return ret; > +} > + > +static void __exit amesom_exit(void) > +{ > + platform_device_unregister(amesom_snd_device); > +} > + > +module_init(amesom_init); > +module_exit(amesom_exit); > + > +/* Module information */ > +MODULE_AUTHOR("Nicola Perrino"); > +MODULE_DESCRIPTION("ALSA SoC TLV320 Amesom"); > +MODULE_LICENSE("GPL"); > _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel