new support for ad1938 codec
Subsystems (3)
cover new support for ad1938 codec
Hi Liam&Mark,
The following series add support for ad1938 codec
*PATCH 1: ad1938 codec driver
*PATCH 2: blackfin I2S(in TDM mode) DAI driver
Even though TDM mode can be as part of I2S DAI, but there are so much difference in configuration and data flow,
it's very ugly to integrate I2S and TDM into a module. So we use the DAI type, but split normal I2S and TDM into individual files.
*PATCH 3: board driver to connect bf5xx with ad1938
--
Thanks,
Barry
PATCH 1/3 new ad1938 codec driver based on asoc
--- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ad1938.c | 652 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ad1938.h | 100 +++++++ 4 files changed, 758 insertions(+), 0 deletions(-) create mode 100644 sound/soc/codecs/ad1938.c create mode 100644 sound/soc/codecs/ad1938.h
sound/soc/codecs/Kconfig +4 -0
@@ -12,6 +12,7 @@ config SND_SOC_ALL_CODECS tristate "Build all ASoC CODEC drivers" select SND_SOC_L3 select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS + select SND_SOC_AD1938 if SPI_MASTER select SND_SOC_AD1939 if I2C select SND_SOC_AD1980 if SND_SOC_AC97_BUS select SND_SOC_AD73311 if I2C
@@ -70,6 +71,9 @@ config SND_SOC_ALL_CODECS config SND_SOC_AC97_CODEC tristate +config SND_SOC_AD1938 + tristate + config SND_SOC_AD1939 tristate
sound/soc/codecs/Makefile +2 -0
@@ -1,4 +1,5 @@ snd-soc-ac97-objs := ac97.o +snd-soc-ad1938-objs := ad1938.o snd-soc-ad1939-objs := ad1939.o snd-soc-ad1980-objs := ad1980.o snd-soc-ak4535-objs := ak4535.o
@@ -49,6 +50,7 @@ snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o +obj-$(CONFIG_SND_SOC_AD1938) += snd-soc-ad1938.o obj-$(CONFIG_SND_SOC_AD1939) += snd-soc-ad1939.o obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
sound/soc/codecs/ad1938.c new file +652 -0
652 lines not on this page · raw message
sound/soc/codecs/ad1938.h new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Re: [PATCH 1/3] new ad1938 codec driver based on asoc
Quoted 1 line · Barry Song
Signed-off-by Barry Song <[email protected]>
This is fine from a code point of view but there are a *lot* of tab/space problems in the code. I'd suggest running checkpatch over your patches before sending them to make sure you catch issues like that. Also, the patch was against the ASoC dev branch rather than ALSA git - the most current mailine ALSA code is in the topic/asoc branch of:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git
Please submit patches againt that or my current queue which will be in:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git
Since the code is all good I've applied the patch as-is but a followup fixing the tab/space stuff would be appreciated.
PATCH 2/3 Blackfin I2S(TDM) CPU DAI driver
In reply to Barry SongEven though TDM mode can be as part of I2S DAI, but there are so much difference in configuration and data flow, it's very ugly to integrate I2S and TDM into a module.
--- sound/soc/blackfin/Kconfig | 23 +++- sound/soc/blackfin/Makefile | 6 + sound/soc/blackfin/bf5xx-tdm-pcm.c | 330 ++++++++++++++++++++++++++++++++++++ sound/soc/blackfin/bf5xx-tdm-pcm.h | 21 +++ sound/soc/blackfin/bf5xx-tdm.c | 313 ++++++++++++++++++++++++++++++++++ sound/soc/blackfin/bf5xx-tdm.h | 14 ++ 6 files changed, 706 insertions(+), 1 deletions(-) create mode 100644 sound/soc/blackfin/bf5xx-tdm-pcm.c create mode 100644 sound/soc/blackfin/bf5xx-tdm-pcm.h create mode 100644 sound/soc/blackfin/bf5xx-tdm.c create mode 100644 sound/soc/blackfin/bf5xx-tdm.h
sound/soc/blackfin/Kconfig +22 -1
@@ -7,6 +7,15 @@ config SND_BF5XX_I2S mode (supports single stereo In/Out). You will also need to select the audio interfaces to support below. +config SND_BF5XX_TDM + tristate "SoC I2S(TDM mode) Audio for the ADI BF5xx chip" + depends on BLACKFIN && SND_SOC + help + Say Y or M if you want to add support for codecs attached to + the Blackfin SPORT (synchronous serial ports) interface in TDM + mode. + You will also need to select the audio interfaces to support below. + config SND_BF5XX_SOC_SSM2602 tristate "SoC SSM2602 Audio support for BF52x ezkit" depends on SND_BF5XX_I2S
@@ -69,6 +78,10 @@ config SND_BF5XX_SOC_I2S tristate select SND_BF5XX_SOC_SPORT +config SND_BF5XX_SOC_TDM + tristate + select SND_BF5XX_SOC_SPORT + config SND_BF5XX_SOC_AC97 tristate select AC97_BUS
@@ -83,9 +96,17 @@ config SND_BF5XX_SOC_AD1980 help Say Y if you want to add support for SoC audio on BF5xx STAMP/EZKIT. +config SND_BF5XX_SOC_AD1938 + tristate "SoC AD1938 Audio support for Blackfin" + depends on SND_BF5XX_TDM + select SND_BF5XX_SOC_TDM + select SND_SOC_AD1938 + help + Say Y if you want to add support for AD1938 codec on Blackfin. + config SND_BF5XX_SPORT_NUM int "Set a SPORT for Sound chip" - depends on (SND_BF5XX_I2S || SND_BF5XX_AC97) + depends on (SND_BF5XX_I2S || SND_BF5XX_AC97 || SND_BF5XX_TDM) range 0 3 if BF54x range 0 1 if !BF54x default 0
sound/soc/blackfin/Makefile +6 -0
@@ -1,21 +1,27 @@ # Blackfin Platform Support snd-bf5xx-ac97-objs := bf5xx-ac97-pcm.o snd-bf5xx-i2s-objs := bf5xx-i2s-pcm.o +snd-bf5xx-tdm-objs := bf5xx-tdm-pcm.o snd-soc-bf5xx-sport-objs := bf5xx-sport.o snd-soc-bf5xx-ac97-objs := bf5xx-ac97.o snd-soc-bf5xx-i2s-objs := bf5xx-i2s.o +snd-soc-bf5xx-tdm-objs := bf5xx-tdm.o obj-$(CONFIG_SND_BF5XX_AC97) += snd-bf5xx-ac97.o obj-$(CONFIG_SND_BF5XX_I2S) += snd-bf5xx-i2s.o +obj-$(CONFIG_SND_BF5XX_TDM) += snd-bf5xx-tdm.o obj-$(CONFIG_SND_BF5XX_SOC_SPORT) += snd-soc-bf5xx-sport.o obj-$(CONFIG_SND_BF5XX_SOC_AC97) += snd-soc-bf5xx-ac97.o obj-$(CONFIG_SND_BF5XX_SOC_I2S) += snd-soc-bf5xx-i2s.o +obj-$(CONFIG_SND_BF5XX_SOC_TDM) += snd-soc-bf5xx-tdm.o # Blackfin Machine Support snd-ad1980-objs := bf5xx-ad1980.o snd-ssm2602-objs := bf5xx-ssm2602.o snd-ad73311-objs := bf5xx-ad73311.o +snd-ad1938-objs := bf5xx-ad1938.o obj-$(CONFIG_SND_BF5XX_SOC_AD1980) += snd-ad1980.o obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o +obj-$(CONFIG_SND_BF5XX_SOC_AD1938) += snd-ad1938.o
sound/soc/blackfin/bf5xx-tdm-pcm.c new file +330 -0
330 lines not on this page · raw message
sound/soc/blackfin/bf5xx-tdm-pcm.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* linux/sound/arm/bf5xx-tdm-pcm.h -- ALSA PCM interface for the Blackfin +* +* Copyright 2009 Analog Device Inc. +* +* 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 _BF5XX_TDM_PCM_H +#define _BF5XX_TDM_PCM_H + +struct bf5xx_pcm_dma_params { +char *name;/* stream identifier */ +}; + +/* platform data */ +extern struct snd_soc_platform bf5xx_tdm_soc_platform; + +#endif
sound/soc/blackfin/bf5xx-tdm.c new file +313 -0
313 lines not on this page · raw message
sound/soc/blackfin/bf5xx-tdm.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* linux/sound/arm/bf5xx-i2s.h +* +* 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 _BF5XX_TDM_H +#define _BF5XX_TDM_H + +extern struct snd_soc_dai bf5xx_tdm_dai; + +#endif
Signature · 1 line
1.5.6.3
Re: [PATCH 2/3] Blackfin I2S(TDM) CPU DAI driver
Quoted 4 lines · Barry Song
Signed-off-by Barry Song <[email protected]>Even though TDM mode can be as part of I2S DAI, but there are so much difference in configuration and data flow, it's very ugly to integrate I2S and TDM into a module.
It'll be a day or two before I have the bandwidth to properly review the code here but one thing that springs to mind reading the commit message:
is the 2 channel I2S case not just a special case of the TDM mode? Is it just that the extra work required for being able to handle TDM has a big runtime cost in buffer allocation or something and so treating it as a special case of TDM introduces unacceptable overheads. I'd just like to better understand what the problems are here, I'm perfectly willing to believe that this is a sensible solution.
Re: [PATCH 2/3] Blackfin I2S(TDM) CPU DAI driver
In reply to Barry SongQuoted 4 lines · Barry Song
Signed-off-by Barry Song <[email protected]>Even though TDM mode can be as part of I2S DAI, but there are so much difference in configuration and data flow, it's very ugly to integrate I2S and TDM into a module.
This is broadly fine, though there are some issues below.
sound/soc/blackfin/Kconfig config SND_BF5XX_SOC_AD1980 · line 106
Quoted 8 lines
sound/soc/blackfin/Kconfig +8
-0+config SND_BF5XX_SOC_AD1938 + tristate "SoC AD1938 Audio support for Blackfin" + depends on SND_BF5XX_TDM + select SND_BF5XX_SOC_TDM + select SND_SOC_AD1938 + help + Say Y if you want to add support for AD1938 codec on Blackfin. +
This should be in the following patch.
sound/soc/blackfin/bf5xx-tdm-pcm.c line 58
Quoted 8 lines
sound/soc/blackfin/bf5xx-tdm-pcm.c new file +7
-0+static void bf5xx_dma_irq (void *data) +{ +struct snd_pcm_substream *pcm = data; +snd_pcm_period_elapsed (pcm); +} +static const struct snd_pcm_hardware bf5xx_pcm_hardware = { + .info = (SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_RESUME ),
There are quite a few checkpatch issues such as this in the patch.
sound/soc/blackfin/bf5xx-tdm-pcm.c line 93
Quoted 6 lines
sound/soc/blackfin/bf5xx-tdm-pcm.c new file +5
-0+struct snd_pcm_runtime *runtime = substream->runtime; +struct sport_device *sport = runtime->private_data; +int fragsize_bytes =frames_to_bytes (runtime, runtime->period_size); + fragsize_bytes /= runtime->channels; + fragsize_bytes *=8 ;/* inflate the fragsize to match */
This could use some clarification - what is being matched here?
sound/soc/blackfin/bf5xx-tdm-pcm.c line 161
Quoted 4 lines
sound/soc/blackfin/bf5xx-tdm-pcm.c new file +4
-0+snd_soc_set_runtime_hwparams (substream, &bf5xx_pcm_hardware); + + ret =snd_pcm_hw_constraint_integer (runtime, \ +SNDRV_PCM_HW_PARAM_PERIODS );
There's no need to use a '\' here.
sound/soc/blackfin/bf5xx-tdm-pcm.c line 186
Quoted 10 lines
sound/soc/blackfin/bf5xx-tdm-pcm.c new file +10
-0+static int bf5xx_pcm_copy (struct snd_pcm_substream *substream,int channel, +snd_pcm_uframes_t pos,void *buf,snd_pcm_uframes_t count) +{ +unsigned int *src; +unsigned int *dst; +int i; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + src = (unsigned int *)buf; + dst = (unsigned int *)substream->runtime->dma_area;
You shouldn't need to cast away from void.
Quoted 5 lines
sound/soc/blackfin/bf5xx-tdm.c new file +5
-0+static int bf5xx_tdm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +int ret =0 ;
sound/soc/blackfin/bf5xx-tdm.c line 140
Quoted 10 lines
sound/soc/blackfin/bf5xx-tdm.c new file +10
-0+ + bf5xx_tdm.tcr2 &= ~0x1f ; + bf5xx_tdm.rcr2 &= ~0x1f ; +switch (params_format (params)) { +case SNDRV_PCM_FORMAT_S32_LE : + bf5xx_tdm.tcr2 |=31 ; + bf5xx_tdm.rcr2 |=31 ; + sport_handle->wdsize =4 ; +break ; + }
This ought to error out if it gets another format (though constraints should prevent that).
sound/soc/blackfin/bf5xx-tdm.c line 149
Quoted 8 lines
sound/soc/blackfin/bf5xx-tdm.c new file +8
-0+if (!bf5xx_tdm.configured) { +/* +* TX and RX are not independent,they are enabled at the +* same time, even if only one side is running. So, we +* need to configure both of them at the time when the first +* stream is opened. +* +* CPU DAI:slave mode.
I can't see anywhere in the code where the configured flag is cleared. If there's only one configuration that is supported you may as well just set this up once on init rather than having this.
sound/soc/blackfin/bf5xx-tdm.c line 307
Quoted 11 lines
sound/soc/blackfin/bf5xx-tdm.c new file +10
-0+static int __init bfin_tdm_init (void ) +{ +return snd_soc_register_dai (&bf5xx_tdm_dai); +} +module_init (bfin_tdm_init); +static void __exit bfin_tdm_exit(void) +{ +snd_soc_unregister_dai (&bf5xx_tdm_dai); +} +module_exit (bfin_tdm_exit);
This should be converted to use a platform device to probe the DAI, with the DAI being registered in the probe() function of the platform device. Most of the code in the existing probe() function to acquire resources should also be merged into that probe function.
Doing this will be required at some point in the future since it is needed to support some newer functionality such as better integration with suspend and resume.
PATCH 3/3 board driver to connect bf5xx with ad1938
In reply to Barry Song--- sound/soc/blackfin/bf5xx-ad1938.c | 142 +++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) create mode 100644 sound/soc/blackfin/bf5xx-ad1938.c
sound/soc/blackfin/bf5xx-ad1938.c new file +142 -0
@@ -0,0 +1,142 @@ +/* +* File: sound/soc/blackfin/bf5xx-ad1938.c +* Author: Barry Song <[email protected]> +* +* Created: Thur June 4 2009 +* Description: Board driver for ad1938 sound chip +* +* Bugs: Enter bugs at http://blackfin.uclinux.org/ +* +* 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see the file COPYING, or write +* to the Free Software Foundation, Inc., +* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/device.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/pcm_params.h> + +#include <asm/blackfin.h> +#include <asm/cacheflush.h> +#include <asm/irq.h> +#include <asm/dma.h> +#include <asm/portmux.h> + +#include "../codecs/ad1938.h" +#include "bf5xx-sport.h" + +#include "bf5xx-tdm-pcm.h" +#include "bf5xx-tdm.h" + +static struct snd_soc_card bf5xx_ad1938; + +static int bf5xx_ad1938_startup (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + + cpu_dai->private_data = sport_handle; +return 0 ; +} + +static int bf5xx_ad1938_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_dai *cpu_dai = rtd->dai->cpu_dai; +struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; +int ret =0 ; +/* set cpu DAI configuration */ + ret =snd_soc_dai_set_fmt (cpu_dai,SND_SOC_DAIFMT_DSP_A | +SND_SOC_DAIFMT_IB_IF |SND_SOC_DAIFMT_CBM_CFM ); +if (ret <0 ) +return ret; + +/* set codec DAI configuration */ + ret =snd_soc_dai_set_fmt (codec_dai,SND_SOC_DAIFMT_DSP_A | +SND_SOC_DAIFMT_IB_IF |SND_SOC_DAIFMT_CBM_CFM ); +if (ret <0 ) +return ret; + +/* set codec DAI slots */ + ret =snd_soc_dai_set_tdm_slot (codec_dai,0 ,8 ); +if (ret <0 ) +return ret; + +return 0 ; +} + +static struct snd_soc_ops bf5xx_ad1938_ops = { + .startup = bf5xx_ad1938_startup, + .hw_params = bf5xx_ad1938_hw_params, +}; + +static struct snd_soc_dai_link bf5xx_ad1938_dai = { + .name ="ad1938" , + .stream_name ="AD1938" , + .cpu_dai = &bf5xx_tdm_dai, + .codec_dai = &ad1938_dai, + .ops = &bf5xx_ad1938_ops, +}; + +static struct snd_soc_card bf5xx_ad1938 = { + .name ="bf5xx_ad1938" , + .platform = &bf5xx_tdm_soc_platform, + .dai_link = &bf5xx_ad1938_dai, + .num_links =1 , +}; + +static struct snd_soc_device bf5xx_ad1938_snd_devdata = { + .card = &bf5xx_ad1938, + .codec_dev = &soc_codec_dev_ad1938, +}; + +static struct platform_device *bfxx_ad1938_snd_device; + +static int __init bf5xx_ad1938_init (void ) +{ +int ret; + + bfxx_ad1938_snd_device =platform_device_alloc ("soc-audio" ,-1 ); +if (!bfxx_ad1938_snd_device) +return -ENOMEM ; + +platform_set_drvdata (bfxx_ad1938_snd_device, &bf5xx_ad1938_snd_devdata); + bf5xx_ad1938_snd_devdata.dev = &bfxx_ad1938_snd_device->dev; + ret =platform_device_add (bfxx_ad1938_snd_device); + +if (ret) +platform_device_put (bfxx_ad1938_snd_device); + +return ret; +} + +static void __exit bf5xx_ad1938_exit(void) +{ +platform_device_unregister (bfxx_ad1938_snd_device); +} + +module_init (bf5xx_ad1938_init); +module_exit (bf5xx_ad1938_exit); + +/* Module information */ +MODULE_AUTHOR ("Barry Song" ); +MODULE_DESCRIPTION ("ALSA SoC AD1938 board driver" ); +MODULE_LICENSE ("GPL" ); +
Signature · 1 line
1.5.6.3
Re: [PATCH 3/3] board driver to connect bf5xx with ad1938
sound/soc/blackfin/bf5xx-ad1938.c line 80
Quoted 4 lines · Barry Song
sound/soc/blackfin/bf5xx-ad1938.c new file +4
-0+/* set codec DAI slots */ + ret =snd_soc_dai_set_tdm_slot (codec_dai,0 ,8 ); +if (ret <0 ) +return ret;
That mask looks wrong - it's saying not to use any slots at all.
Otherwise this looks good.