alsa: ASoC driver for s6000 I2S interface
PATCH 1/2 alsa: ASoC driver for s6000 I2S interface
This patch adds a driver for the I2S interface found on Stretch s6000 family processors.
--- sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/s6000/Kconfig | 10 + sound/soc/s6000/Makefile | 6 + sound/soc/s6000/s6000-i2s.c | 421 +++++++++++++++++++++++++++++++++++ sound/soc/s6000/s6000-i2s.h | 167 ++++++++++++++ sound/soc/s6000/s6000-pcm.c | 518 +++++++++++++++++++++++++++++++++++++++++++ sound/soc/s6000/s6000-pcm.h | 41 ++++ 8 files changed, 1165 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 && SND_SOC + 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 +421 -0
421 lines not on this page · raw message
sound/soc/s6000/s6000-i2s.h new file +167 -0
167 lines not on this page · raw message
sound/soc/s6000/s6000-pcm.c new file +518 -0
518 lines not on this page · raw message
sound/soc/s6000/s6000-pcm.h new file +41 -0
41 lines not on this page · raw message
Signature · 6 lines
1.6.2.107.ge47ee _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 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.
--- sound/soc/s6000/Kconfig | 9 ++ sound/soc/s6000/Makefile | 5 + sound/soc/s6000/s6105-ipcam.c | 286 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 300 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 +286 -0
286 lines not on this page · raw message
Signature · 6 lines
1.6.2.107.ge47ee _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [patch 2/2] alsa: s6105 IP camera machine specific ASoC code
Quoted 2 lines · Daniel Gl??ckner
This patch adds machine specific code for the audio part of the Stretch s6105 IP camera reference design.
This looks mostly good, though some of the comments on the platform support affect this driver too. You should also check for current ASoC APIs.
sound/soc/s6000/s6105-ipcam.c line 53
Quoted 3 lines
sound/soc/s6000/s6105-ipcam.c new file +3
-0+/* set the codec system clock */ + ret =snd_soc_dai_set_sysclk (codec_dai,0 ,S6105_CODEC_CLOCK , +SND_SOC_CLOCK_OUT );
Are you sure you're applying the correct configuration to the correct DAI here - S6105_CODEC_CLOCK is a CPU define, not a CODEC define?
sound/soc/s6000/s6105-ipcam.c line 113
Quoted 8 lines
sound/soc/s6000/s6105-ipcam.c new file +8
-0+static int snd_soc_dapm_set_endpoint (struct snd_soc_codec *codec,char *name, +int status) +{ +if (status) +return snd_soc_dapm_enable_pin (codec, name); +else +return snd_soc_dapm_disable_pin (codec, name); +}
This shouldn't be in a driver!
sound/soc/s6000/s6105-ipcam.c line 127
Quoted 3 lines
sound/soc/s6000/s6105-ipcam.c new file +3
-0+snd_soc_dapm_set_endpoint (codec,"Audio Out Differential" , !val); +snd_soc_dapm_set_endpoint (codec,"Audio Out Stereo" , val); +snd_soc_dapm_sync (codec);
Hrm. Given the fact that you can't have the stereo and differential outputs enabled simultaneously is it not safer to first disable the active output, then sync, then enable the new output?
Re: [patch 2/2] alsa: s6105 IP camera machine specific ASoC code
Quoted 2 lines · Mark Brown
Are you sure you're applying the correct configuration to the correct DAI here -
S6105_CODEC_CLOCKis a CPU define, not a CODEC define?
In this case S6105 was referring to the S6105 reference design. It's a machine define at the top of the file.
Quoted 10 lines
sound/soc/s6000/s6105-ipcam.c line 113
Quoted 8 lines
sound/soc/s6000/s6105-ipcam.c new file +8
-0+static int snd_soc_dapm_set_endpoint (struct snd_soc_codec *codec,char *name, +int status) +{ +if (status) +return snd_soc_dapm_enable_pin (codec, name); +else +return snd_soc_dapm_disable_pin (codec, name); +}This shouldn't be in a driver!
I know, but it was made static in soc-dapm.c when it was renamed to snd_soc_dapm_set_pin.
Quoted 3 lines
Hrm. Given the fact that you can't have the stereo and differential outputs enabled simultaneously is it not safer to first disable the active output, then sync, then enable the new output?
The pins are connected via 0.47uF..
I'll insert the sync. Then I won't have to bug you about exporting snd_soc_dapm_set_pin as well (as it will no longer result in shorter code).
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
Re: [patch 2/2] alsa: s6105 IP camera machine specific ASoC code
Quoted 7 lines · Daniel Glöckner
Quoted 2 lines · Mark Brown
Are you sure you're applying the correct configuration to the correct DAI here -
S6105_CODEC_CLOCKis a CPU define, not a CODEC define?In this case S6105 was referring to the S6105 reference design. It's a machine define at the top of the file.
Hrm, OK.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+static int snd_soc_dapm_set_endpoint(struct
snd_soc_codec*codec, char *name,This shouldn't be in a driver!
I know, but it was made static in
soc-dapm.cwhen it was renamed tosnd_soc_dapm_set_pin.
In cases like this you should submit a patch adding the API back to the core rather than adding a generic API as local code in your machine driver.
Quoted 2 lines · Daniel Gl??ckner
This patch adds a driver for the I2S interface found on Stretch s6000 family processors.
Thanks for this. It looks basically good - there's some issues below, several of which appear to be due to this having been done against a slightly old kernel version. Please see the topic/asoc branch of
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git
for the most current code.
sound/soc/s6000/Kconfig line 4
Quoted 4 lines
sound/soc/s6000/Kconfig new file +4
-0+config SND_S6000_SOC + tristate "SoC Audio for the Stretch s6000 family" + depends on XTENSA_VARIANT_S6000 && SND_SOC + help
I'm not seeing any hits on XTENSA_VARIANT_S6000 in next? While that shouldn't hurt immediately since it'll just never appear it'd be good to make sure that the APIs this depends on are going into mainline in the form they're in. Do you know what the status is there?
The SND_SOC isn't required due to the use of menuconfig in the sound/soc directory.
sound/soc/s6000/s6000-i2s.c line 154
Quoted 13 lines
sound/soc/s6000/s6000-i2s.c new file +13
-0+static int __devinit s6000_i2s_probe (struct platform_device *pdev, +struct snd_soc_dai *dai) +{ +struct s6000_i2s_dev *dev; +struct resource *scbmem, *sifmem, *region, *dma_in, *dma_out; +struct s6000_snd_platform_data *pdata; +u8 __iomem *mmio; +int ret; + + pdata = pdev->dev.platform_data; + + scbmem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!scbmem) {
With current ASoC it is now possible for the DAIs to be probed using the regular device model and register with the core when that happens. The core will delay probe of the card until all components have registered with it. For CPU side stuff this means that you can provide a standard set of resources for the device in your architecture code without having to have all the machines replicate them in their soc-audio device.
Look at the PXA AC97 driver for an example of this on the platform side.
sound/soc/s6000/s6000-i2s.c line 375
Quoted 2 lines
sound/soc/s6000/s6000-i2s.c new file +2
-0+#define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT | \ + SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000)
SND_PCM_RATE_KNOT doesn't work with ASoC (though it shouldn't do any harm since it'll just get removed).
sound/soc/s6000/s6000-i2s.c line 403
Quoted 5 lines
sound/soc/s6000/s6000-i2s.c new file +5
-0+ .ops = { + .set_fmt = s6000_i2s_set_dai_fmt, + .set_clkdiv = s6000_i2s_set_clkdiv, + .hw_params = s6000_i2s_hw_params, + }
This won't build with current ASoC, the DAI ops have been moved out of line.
sound/soc/s6000/s6000-i2s.h line 85
Quoted 4 lines
sound/soc/s6000/s6000-i2s.h new file +4
-0+static inline void s6_i2s_write_reg (struct s6000_i2s_dev *dev,int reg,u32 val) +{ +writel (val, dev->scbbase + reg); +}
Any reason to expose these to users?
sound/soc/s6000/s6000-i2s.h line 101
Quoted 3 lines
sound/soc/s6000/s6000-i2s.h new file +3
-0+static inline void s6000_i2s_start_channel (struct s6000_i2s_dev *dev, +int channel) +{
This and the rest of the functions in the file look especially like it should be in the body of the driver. It also looks a little large to be forcing inline?
sound/soc/s6000/s6000-pcm.c line 35
Quoted 6 lines
sound/soc/s6000/s6000-pcm.c new file +6
-0+#define S6000_PCM_DEBUG 0 +#if S6000_PCM_DEBUG +#define DPRINTK(x...) printk(KERN_DEBUG x) +#else +#define DPRINTK(x...) +#endif
Use the standard pr_dbg() (or dev_dbg()), no need to reproduce it.
Quoted 5 lines
sound/soc/s6000/s6000-pcm.c new file +3
-0+if (unlikely (i2s_errors &S6_I2S_INT_ALIGNMENT )) { +printk (KERN_ERR "s6000-i2s: Alignment Error\n" ); + if (unlikely(i2s_errors & S6_I2S_INT_UNDERRUN) &&
sound/soc/s6000/s6000-pcm.c line 141
Quoted 10 lines
sound/soc/s6000/s6000-pcm.c new file +10
-0+ playback->runtime && + snd_pcm_running(playback)) { +printk (KERN_WARNING "s6000-i2s: Tx Underrun\n" ); +s6000_i2s_start (playback); + + prtd = playback->runtime->private_data; +spin_lock (&prtd->lock); +s6000_pcm_enqueue_dma (playback); +/* a second descriptor will be queued below */ +spin_unlock (&prtd->lock);
Hrm. ALSA has underrun handling mechanisms as standard?
sound/soc/s6000/s6000-pcm.c line 146
Quoted 1 line
sound/soc/s6000/s6000-pcm.c new file +1
-0+for (i =0 ; i <2 ; ++i) {
Magic number here - ARRAY_SIZE()?
sound/soc/s6000/s6000-pcm.c line 220
Quoted 13 lines
sound/soc/s6000/s6000-pcm.c new file +13
-0+int s6000_pcm_start (struct snd_pcm_substream *substream) +{ +struct s6000_runtime_data *prtd = substream->runtime->private_data; +struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; +struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; +unsigned long flags; + +spin_lock_irqsave (&prtd->lock, flags); + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +s6dmac_enable_chan (DMA_MASK_DMAC (par->dma_out), +DMA_INDEX_CHNL (par->dma_out), +1 ,0 ,1 ,0 ,0 ,0 ,0 ,4 ,-1 ,0 ,0 ,1 );
Hrm. Lots of magic numbers here but it seems to come from the API you're using so not much doing I guess.
Quoted 4 lines · Mark Brown
I'm not seeing any hits on
XTENSA_VARIANT_S6000in next? While that shouldn't hurt immediately since it'll just never appear it'd be good to make sure that the APIs this depends on are going into mainline in the form they're in. Do you know what the status is there?
The patch introducing XTENSA_VARIANT_S6000 has already been reviewed by the architecture maintainer and there is hope that it will make it into 2.6.30. The dma api, which we posted four days ago to LKML, has not received any comments so far.
Quoted 5 lines
sound/soc/s6000/s6000-i2s.c line 375
Quoted 2 lines
sound/soc/s6000/s6000-i2s.c new file +2
-0+#define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT | \ + SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000)
SND_PCM_RATE_KNOTdoesn't work with ASoC (though it shouldn't do any harm since it'll just get removed).
Except for the maximum bit clock (50 MHz) the interface doesn't care about the sampling rate, so I put in all SNDRV_PCM_RATE_* constants. Shall I remove it?
Quoted 7 lines
sound/soc/s6000/s6000-i2s.h line 85
Quoted 4 lines
sound/soc/s6000/s6000-i2s.h new file +4
-0+static inline void s6_i2s_write_reg (struct s6000_i2s_dev *dev,int reg,u32 val) +{ +writel (val, dev->scbbase + reg); +}Any reason to expose these to users?
Quoted 7 lines
sound/soc/s6000/s6000-i2s.h line 101
Quoted 3 lines
sound/soc/s6000/s6000-i2s.h new file +3
-0+static inline void s6000_i2s_start_channel (struct s6000_i2s_dev *dev, +int channel) +{This and the rest of the functions in the file look especially like it should be in the body of the driver. It also looks a little large to be forcing inline?
This was an attempt to avoid symbol exports..
I'll move everything to s6000-i2s.c and export the three necessary functions.
Quoted 5 lines
Quoted 5 lines
sound/soc/s6000/s6000-pcm.c new file +5
-0+if (unlikely (i2s_errors &S6_I2S_INT_UNDERRUN ) && + playback->runtime && +snd_pcm_running (playback)) { +printk (KERN_WARNING "s6000-i2s: Tx Underrun\n" ); +s6000_i2s_start (playback);
Quoted 8 lines
sound/soc/s6000/s6000-pcm.c line 141
Quoted 6 lines
sound/soc/s6000/s6000-pcm.c new file +6
-0+ + prtd = playback->runtime->private_data; +spin_lock (&prtd->lock); +s6000_pcm_enqueue_dma (playback); +/* a second descriptor will be queued below */ +spin_unlock (&prtd->lock);Hrm. ALSA has underrun handling mechanisms as standard?
I guess snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN) is the way to go then?
The remaining issues will be addressed in the v2 patch as well.
Daniel
Signature · 11 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 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 11 lines · Daniel Glöckner
Quoted 4 lines · Mark Brown
I'm not seeing any hits on
XTENSA_VARIANT_S6000in next? While that shouldn't hurt immediately since it'll just never appear it'd be good to make sure that the APIs this depends on are going into mainline in the form they're in. Do you know what the status is there?The patch introducing
XTENSA_VARIANT_S6000has already been reviewed by the architecture maintainer and there is hope that it will make it into 2.6.30. The dma api, which we posted four days ago to LKML, has not received any comments so far.
OK, might be worth nagging the architecture maintainer to get their tree included in -next if it isn't already.
Quoted 9 lines
Quoted 5 lines
sound/soc/s6000/s6000-i2s.c line 375
Quoted 2 lines
sound/soc/s6000/s6000-i2s.c new file +2
-0+#define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT | \ + SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000)
SND_PCM_RATE_KNOTdoesn't work with ASoC (though it shouldn't do any harm since it'll just get removed).Except for the maximum bit clock (50 MHz) the interface doesn't care about the sampling rate, so I put in all SNDRV_PCM_RATE_* constants. Shall I remove it?
Yes, please - this applies to almost all CPU side drivers, it's kind of unfortunate but in practice it generally makes very little practical difference since applications tend to use one of the standard audio rates.
Quoted 5 lines
Quoted 1 line
Any reason to expose these to users?
This was an attempt to avoid symbol exports..
I'll move everything tos6000-i2s.cand export the three necessary functions.
Which functions are you exporting? None of this looked like anything that I'd expect to see used outside of the driver.
Quoted 8 lines · Mark Brown
Quoted 5 lines
Quoted 1 line
Any reason to expose these to users?
This was an attempt to avoid symbol exports..
I'll move everything tos6000-i2s.cand export the three necessary functions.Which functions are you exporting? None of this looked like anything that I'd expect to see used outside of the driver.
s6000_i2s_start and s6000_i2s_stop are called in s6000_pcm_trigger and s6000_i2s_int_sources is called in the interrupt handler.
s6000_i2s_start can't be called from the dai's trigger callback on playback as the data sheet is very explicit about the order of enabling dma and i2s.
s6000_i2s_stop is called there for consistency. The order on disabling is uncritical.
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
Quoted 8 lines · Daniel Glöckner
s6000_i2s_startands6000_i2s_stopare called ins6000_pcm_triggerands6000_i2s_int_sourcesis called in the interrupt handler.
s6000_i2s_startcan't be called from the dai's trigger callback on playback as the data sheet is very explicit about the order of enabling dma and i2s.
s6000_i2s_stopis called there for consistency. The order on disabling is uncritical.
Are these two drivers really separate? The reason for splitting out the DMA driver in the normal case is that it is common for CPUs to be able to use the same DMA driver for multiple interfaces - if that's not the case then don't feel obligated to split them up too much.
Also note that you can pass data from the I2S driver to the PCM driver via the dma_data pointer - if you need to pass a little vtable through there then that's another option.