alsa: ASoC driver for s6000 I2S interface
PATCH v2 1/2 alsa: ASoC driver for s6000 I2S interface
This patch adds a driver for the I2S interface found on Stretch s6000 family processors.
Changes compared to v1 of this patch:
- removed superfluous dependency on SND_SOC
- moved all function and register definitions from header to .c file
- implemented remaining interaction between s6000-pcm
and s6000-i2c with function pointers passed in cpu_dai->dma_data
- removed SNDRV_PCM_RATE_KNOT
- moved snd_soc_dai_ops outside s6000_i2s_dai
- made s6000-i2s a platform driver that registers the dai
- freeing s6000_i2s_dev _after_ last usage
- replaced release_region with release_mem_region
- handling dma underflow/overflow with SNDRV_PCM_STATE_XRUN
- replaced DPRINTK with dev_dbg
- made remaining not exported symbols static
- added comments describing dma channel parameters
--- sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/s6000/Kconfig | 10 + sound/soc/s6000/Makefile | 6 + sound/soc/s6000/s6000-i2s.c | 629 +++++++++++++++++++++++++++++++++++++++++++ sound/soc/s6000/s6000-i2s.h | 25 ++ sound/soc/s6000/s6000-pcm.c | 497 ++++++++++++++++++++++++++++++++++ sound/soc/s6000/s6000-pcm.h | 35 +++ 8 files changed, 1204 insertions(+), 0 deletions(-) create mode 100644 sound/soc/s6000/Kconfig create mode 100644 sound/soc/s6000/Makefile create mode 100644 sound/soc/s6000/s6000-i2s.c create mode 100644 sound/soc/s6000/s6000-i2s.h create mode 100644 sound/soc/s6000/s6000-pcm.c create mode 100644 sound/soc/s6000/s6000-pcm.h
sound/soc/Kconfig +1 -0
@@ -31,6 +31,7 @@ source "sound/soc/fsl/Kconfig" source "sound/soc/omap/Kconfig" source "sound/soc/pxa/Kconfig" source "sound/soc/s3c24xx/Kconfig" +source "sound/soc/s6000/Kconfig" source "sound/soc/sh/Kconfig" # Supported codecs
sound/soc/Makefile +1 -0
@@ -10,4 +10,5 @@ obj-$(CONFIG_SND_SOC) += fsl/ obj-$(CONFIG_SND_SOC) += omap/ obj-$(CONFIG_SND_SOC) += pxa/ obj-$(CONFIG_SND_SOC) += s3c24xx/ +obj-$(CONFIG_SND_SOC) += s6000/ obj-$(CONFIG_SND_SOC) += sh/
sound/soc/s6000/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config SND_S6000_SOC + tristate "SoC Audio for the Stretch s6000 family" + depends on XTENSA_VARIANT_S6000 + help + Say Y or M if you want to add support for codecs attached to + s6000 family chips. You will also need to select the platform + to support below. + +config SND_S6000_SOC_I2S + tristate
sound/soc/s6000/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# s6000 Platform Support +snd-soc-s6000-objs := s6000-pcm.o +snd-soc-s6000-i2s-objs := s6000-i2s.o + +obj-$(CONFIG_SND_S6000_SOC) += snd-soc-s6000.o +obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o
sound/soc/s6000/s6000-i2s.c new file +629 -0
629 lines not on this page · raw message
sound/soc/s6000/s6000-i2s.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* ALSA SoC I2S Audio Layer for the Stretch s6000 family +* +* Author: Daniel Gloeckner, <[email protected]> +* Copyright: (C) 2009 emlix GmbH <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _S6000_I2S_H +#define _S6000_I2S_H + +extern struct snd_soc_dai s6000_i2s_dai; + +struct s6000_snd_platform_data { +int lines_in; +int lines_out; +int channel_in; +int channel_out; +int wide; +int same_rate; +}; +#endif
sound/soc/s6000/s6000-pcm.c new file +497 -0
497 lines not on this page · raw message
sound/soc/s6000/s6000-pcm.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* ALSA PCM interface for the Stretch s6000 family +* +* Author: Daniel Gloeckner, <[email protected]> +* Copyright: (C) 2009 emlix GmbH <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _S6000_PCM_H +#define _S6000_PCM_H + +struct snd_soc_dai ; +struct snd_pcm_substream ; + +struct s6000_pcm_dma_params { +unsigned int (*check_xrun)(struct snd_soc_dai *cpu_dai); +int (*trigger)(struct snd_pcm_substream *substream,int cmd,int after); +dma_addr_t sif_in; +dma_addr_t sif_out; +u32 dma_in; +u32 dma_out; +int irq; +int same_rate; + +spinlock_t lock; +int in_use; +int rate; +}; + +extern struct snd_soc_platform s6000_soc_platform; + +#endif
Signature · 6 lines
1.6.1.3 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v2 2/2 alsa: s6105 IP camera machine specific ASoC code
This patch adds machine specific code for the audio part of the Stretch s6105 IP camera reference design.
The device uses the tlv320aic31(01) codec to generate the clock for both I2S ports of the soc. While the master clock is generated by a configurable PLL chip, the code assumes the factory default settings.
An additional kcontrol has been added to handle the special routing of the board, connecting both HPLCOM and HPROUT to the same pin of the audio jack. One of these should always be switched off.
Changes compared to v1 of this patch:
- renamed codec clock define
- removed dapm helper function
- calling sync between disabling one pin and enabling the other pin
- removed resources as they are no longer passed via soc-audio
- using platform_device_add_data
--- sound/soc/s6000/Kconfig | 9 ++ sound/soc/s6000/Makefile | 5 + sound/soc/s6000/s6105-ipcam.c | 244 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+), 0 deletions(-) create mode 100644 sound/soc/s6000/s6105-ipcam.c
sound/soc/s6000/Kconfig +9 -0
@@ -8,3 +8,12 @@ config SND_S6000_SOC config SND_S6000_SOC_I2S tristate + +config SND_S6000_SOC_S6IPCAM + tristate "SoC Audio support for Stretch 6105 IP Camera" + depends on SND_S6000_SOC && XTENSA_PLATFORM_S6105 + select SND_S6000_SOC_I2S + select SND_SOC_TLV320AIC3X + help + Say Y if you want to add support for SoC audio on the + Stretch s6105 IP Camera Reference Design.
sound/soc/s6000/Makefile +5 -0
@@ -4,3 +4,8 @@ snd-soc-s6000-i2s-objs := s6000-i2s.o obj-$(CONFIG_SND_S6000_SOC) += snd-soc-s6000.o obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o + +# s6105 Machine Support +snd-soc-s6ipcam-objs := s6105-ipcam.o + +obj-$(CONFIG_SND_S6000_SOC_S6IPCAM) += snd-soc-s6ipcam.o
sound/soc/s6000/s6105-ipcam.c new file +244 -0
244 lines not on this page · raw message
Signature · 6 lines
1.6.1.3 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH v2 2/2] alsa: s6105 IP camera machine specific ASoC code
sound/soc/s6000/s6105-ipcam.c line 48
Quoted 11 lines · Daniel Gl??ckner
sound/soc/s6000/s6105-ipcam.c new file +10
-0+/* set codec DAI configuration */ + ret =snd_soc_dai_set_fmt (codec_dai,SND_SOC_DAIFMT_I2S | +SND_SOC_DAIFMT_CBM_CFM ); +if (ret <0 ) +return ret; +/* set cpu DAI configuration */ + ret =snd_soc_dai_set_fmt (cpu_dai,SND_SOC_DAIFMT_CBM_CFM | +SND_SOC_DAIFMT_IB_IF ); +if (ret <0 ) +return ret;
Why do these two differ? It's very unusual to see different formats and generally indicates a bug in one of the drivers involved that's being worked around. The omission of I2S is understandable since the CPU only does I2S (though ideally it'd be specified) but the inversion of the bit and frame clocks for the CPU only looks like the CPU is generating inverted clocks by default.
Quoted 2 lines · Daniel Glöckner
This patch adds a driver for the I2S interface found on Stretch s6000 family processors.
This all looks good - the only concern I have is the issue with the polarity of the clock signals I mentioned in reply to the machine driver. The code in the machine driver does make it look like the I2S driver is using the opposite polarity to that expected. If that's not the case then I guess the thing to do is have some documentation in the machine driver explaining what's going on.
In order to simplify review I've applied both patches to the s6000 branch of my sound git repository. Please submit any changes as incremental patches against that rather than as whole new patches.
Thanks!
Quoted 4 lines · Mark Brown
This all looks good - the only concern I have is the issue with the polarity of the clock signals I mentioned in reply to the machine driver. The code in the machine driver does make it look like the I2S driver is using the opposite polarity to that expected.
You are right, this is wrong.
Patch follows
Daniel
Signature · 6 lines
Dipl.-Math. Daniel Glöckner, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax -11, Bahnhofsallee 1b, 37081 Göttingen, Germany Geschäftsführung: Dr. Uwe Kracke, Dr. Cord Seele, Ust-IdNr.: DE 205 198 055 Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 emlix - your embedded linux partner
PATCH 1/1 ASoC: correct s6000 I2S clock polarity
According to the data sheet data is clocked out on the falling edge and latched on the rising edge of the bit clock. While the left sample is transmitted the word clock line is low.
--- sound/soc/s6000/s6000-i2s.c | 4 ++-- sound/soc/s6000/s6105-ipcam.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/s6000/s6000-i2s.c +2 -2
@@ -252,10 +252,10 @@ static int s6000_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, }switch (fmt &SND_SOC_DAIFMT_INV_MASK ) { -case SND_SOC_DAIFMT_IB_IF : +case SND_SOC_DAIFMT_NB_NF : w |=S6_I2S_LEFT_FIRST ;break ; -case SND_SOC_DAIFMT_IB_NF : +case SND_SOC_DAIFMT_NB_IF : w |=S6_I2S_RIGHT_FIRST ;break ;default :
sound/soc/s6000/s6105-ipcam.c +1 -1
@@ -43,7 +43,7 @@ static int s6105_hw_params(struct snd_pcm_substream *substream,/* set cpu DAI configuration */ ret =snd_soc_dai_set_fmt (cpu_dai,SND_SOC_DAIFMT_CBM_CFM | -SND_SOC_DAIFMT_IB_IF ); +SND_SOC_DAIFMT_NB_NF );if (ret <0 )return ret;
Signature · 6 lines
1.6.1.3 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
AppliedRe: [PATCH] ASoC: correct s6000 I2S clock polarity
Quoted 5 lines · Daniel Glöckner
According to the data sheet data is clocked out on the falling edge and latched on the rising edge of the bit clock. While the left sample is transmitted the word clock line is low.
Signed-off-by Daniel Glöckner <[email protected]>
Applied, thanks!