ASoC: Add WM8510 driver
Subsystems (3)
PATCH 1/3 ASoC: Add WM8510 driver
The WM8510 is a mono CODEC with speaker driver optimised for telephony applications, featuring:
- 16/20/24/32 bit audio at data rates between 8kHz and 48kHz
- On-chip PLL
- Dual microphone inputs
This driver was originally written by Liam Girdwood with updates from Brett Saunders, Geoffrey Wossum and myself.
--- sound/soc/codecs/Kconfig | 3 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wm8510.c | 836 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/wm8510.h | 103 ++++++ 4 files changed, 944 insertions(+), 0 deletions(-) create mode 100644 sound/soc/codecs/wm8510.c create mode 100644 sound/soc/codecs/wm8510.h
sound/soc/codecs/Kconfig +3 -0
@@ -5,6 +5,9 @@ config SND_SOC_AC97_CODEC config SND_SOC_UDA1380 tristate +config SND_SOC_WM8510 + tristate + config SND_SOC_WM8731 tristate
sound/soc/codecs/Makefile +2 -0
@@ -1,5 +1,6 @@ snd-soc-ac97-objs := ac97.o snd-soc-uda1380-objs := uda1380.o +snd-soc-wm8510-objs := wm8510.o snd-soc-wm8731-objs := wm8731.o snd-soc-wm8750-objs := wm8750.o snd-soc-wm8753-objs := wm8753.o
@@ -10,6 +11,7 @@ snd-soc-tlv320aic3x-objs := tlv320aic3x.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o +obj-$(CONFIG_SND_SOC_WM8510) += snd-soc-wm8510.o obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o
sound/soc/codecs/wm8510.c new file +836 -0
836 lines not on this page · raw message
sound/soc/codecs/wm8510.h new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
1.5.5.3
A message that is not in the archive (sent off-list or not yet received): 1212597211-14495-2-git-send-email-broonie@opensource.wolfsonmicro.com
PATCH 3/3 Revised AT32 ASoC Patch
From: Geoffrey Wossum <[email protected]>
Attached is a revised version of my patch to add AT32 to ASoC. This cleans most of the style issues associated with the previous patch. Also fixes an issue with the playpaq_wm8510.c code depending on a non-released patch to th AT32 portmux support.
Patch is against 2.6.24.3.atmel.3 kernel, the latest AVR32 kernel Atmel has released, with the linux-2.6-asoc patches from when v2.6.24 was tagged also applied.
[Fixed up minor checkpatch issues and updated for current kernels -- broonie]
--- sound/soc/Kconfig | 1 + sound/soc/Makefile | 3 +- sound/soc/at32/Kconfig | 34 ++ sound/soc/at32/Makefile | 11 + sound/soc/at32/at32-pcm.c | 491 ++++++++++++++++++++++ sound/soc/at32/at32-pcm.h | 79 ++++ sound/soc/at32/at32-ssc.c | 849 +++++++++++++++++++++++++++++++++++++++ sound/soc/at32/at32-ssc.h | 59 +++ sound/soc/at32/playpaq_wm8510.c | 524 ++++++++++++++++++++++++ 9 files changed, 2050 insertions(+), 1 deletions(-) create mode 100644 sound/soc/at32/Kconfig create mode 100644 sound/soc/at32/Makefile create mode 100644 sound/soc/at32/at32-pcm.c create mode 100644 sound/soc/at32/at32-pcm.h create mode 100644 sound/soc/at32/at32-ssc.c create mode 100644 sound/soc/at32/at32-ssc.h create mode 100644 sound/soc/at32/playpaq_wm8510.c
sound/soc/Kconfig +1 -0
@@ -22,6 +22,7 @@ config SND_SOC_AC97_BUS bool # All the supported Soc's +source "sound/soc/at32/Kconfig" source "sound/soc/at91/Kconfig" source "sound/soc/pxa/Kconfig" source "sound/soc/s3c24xx/Kconfig"
sound/soc/Makefile +2 -1
@@ -1,4 +1,5 @@ snd-soc-core-objs := soc-core.o soc-dapm.o obj-$(CONFIG_SND_SOC) += snd-soc-core.o -obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ omap/ +obj-$(CONFIG_SND_SOC) += codecs/ at32/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ +obj-$(CONFIG_SND_SOC) += omap/
sound/soc/at32/Kconfig new file +34 -0
@@ -0,0 +1,34 @@ +config SND_AT32_SOC + tristate "SoC Audio for the Atmel AT32 System-on-a-Chip" + depends on AVR32 && SND_SOC + help + Say Y or M if you want to add support for codecs attached to + the AT32 SSC interface. You will also need to + to select the audio interfaces to support below. + + +config SND_AT32_SOC_SSC + tristate + + + +config SND_AT32_SOC_PLAYPAQ + tristate "SoC Audio support for PlayPaq with WM8510" + depends on SND_AT32_SOC && BOARD_PLAYPAQ + select SND_AT32_SOC_SSC + select SND_SOC_WM8510 + help + Say Y or M here if you want to add support for SoC audio + on the LRS PlayPaq. + + + +config SND_AT32_SOC_PLAYPAQ_SLAVE + bool "Run CODEC on PlayPaq in slave mode" + depends on SND_AT32_SOC_PLAYPAQ + default n + help + Say Y if you want to run with the AT32 SSC generating the BCLK + and FRAME signals on the PlayPaq. Unless you want to play + with the AT32 as the SSC master, you probably want to say N here, + as this will give you better sound quality.
sound/soc/at32/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# AT32 Platform Support +snd-soc-at32-objs := at32-pcm.o +snd-soc-at32-ssc-objs := at32-ssc.o + +obj-$(CONFIG_SND_AT32_SOC) += snd-soc-at32.o +obj-$(CONFIG_SND_AT32_SOC_SSC) += snd-soc-at32-ssc.o + +# AT32 Machine Support +snd-soc-playpaq-objs := playpaq_wm8510.o + +obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
sound/soc/at32/at32-pcm.c new file +491 -0
491 lines not on this page · raw message
sound/soc/at32/at32-pcm.h new file +79 -0
79 lines not on this page · raw message
sound/soc/at32/at32-ssc.c new file +849 -0
849 lines not on this page · raw message
sound/soc/at32/at32-ssc.h new file +59 -0
59 lines not on this page · raw message
sound/soc/at32/playpaq_wm8510.c new file +524 -0
524 lines not on this page · raw message
Signature · 1 line
1.5.5.3
At Wed, 4 Jun 2008 17:33:29 +0100,
sound/soc/codecs/wm8510.c line 61
Quoted 8 lines · Mark Brown
sound/soc/codecs/wm8510.c new file +7
-0+/* +* wm8510 register cache +* We can't read the WM8510 register space when we are +* using 2 wire for device control, so we cache them instead. +*/ +static const u16 wm8510_reg[WM8510_CACHEREGNUM ] = { +0x0000 ,0x0000 ,0x0000 ,0x0000 ,
Use tabs here.
sound/soc/codecs/wm8510.c line 130
Quoted 5 lines
sound/soc/codecs/wm8510.c new file +5
-0+#define wm8510_reset (c) wm8510_write(c, WM8510_RESET, 0) + +static const char *wm8510_companding[] = {"Off" ,"NC" ,"u-law" ,"A-law" }; +static const char *wm8510_deemp[] = {"None" ,"32kHz" ,"44.1kHz" ,"48kHz" }; +static const char *wm8510_alc[] = {"ALC" ,"Limiter" };
No space after '{' but a space before '}'? Oh I'm too picky...
Quoted 2 lines
sound/soc/codecs/wm8510.c new file +2
-0+static int wm8510_pcm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params)
(snip)
Quoted 31 lines
sound/soc/codecs/wm8510.c new file +31
-0+{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_device *socdev = rtd->socdev; +struct snd_soc_codec *codec = socdev->codec; +u16 iface =wm8510_read_reg_cache (codec,WM8510_IFACE ) &0x19f ; +u16 adn =wm8510_read_reg_cache (codec,WM8510_ADD ) &0x1f1 ; + +/* bit size */ +switch (params_format (params)) { +case SNDRV_PCM_FORMAT_S16_LE : +break ; +case SNDRV_PCM_FORMAT_S20_3LE : + iface |=0x0020 ; +break ; +case SNDRV_PCM_FORMAT_S24_LE : + iface |=0x0040 ; +break ; +case SNDRV_PCM_FORMAT_S32_LE : + iface |=0x0060 ; +break ; + } + +/* filter coefficient */ +switch (params_rate (params)) { +case SNDRV_PCM_RATE_8000 : + adn |=0x5 <<1 ; +break ; +case SNDRV_PCM_RATE_11025 : + adn |=0x4 <<1 ; +break ; +case SNDRV_PCM_RATE_16000 :
sound/soc/codecs/wm8510.c line 524
Quoted 10 lines
sound/soc/codecs/wm8510.c new file +10
-0+ adn |=0x3 <<1 ; +break ; +case SNDRV_PCM_RATE_22050 : + adn |=0x2 <<1 ; +break ; +case SNDRV_PCM_RATE_32000 : + adn |=0x1 <<1 ; +break ; +case SNDRV_PCM_RATE_44100 : +break ;
Just to be sure -- No 48000 case?
sound/soc/codecs/wm8510.c line 571
Quoted 3 lines
sound/soc/codecs/wm8510.c new file +3
-0+#define WM8510_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ + SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
... since I find it here.
sound/soc/codecs/wm8510.c line 574
Quoted 2 lines
sound/soc/codecs/wm8510.c new file +2
-0+#define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ + SNDRV_PCM_FMTBIT_S24_LE)
Don't you need SNDRV_PCM_FMTBIT_S32_LE? It's handled in wm8510_pcm_hw_params().
Also, is the patch author you or Liam?
thanks,
Takashi
Quoted 5 lines · Takashi Iwai
Review
Quoted 2 lines · Mark Brown
(quoted diff) +2
-0+static const u16 wm8510_reg[WM8510_CACHEREGNUM] = { + 0x0000, 0x0000, 0x0000, 0x0000,
Quoted 7 lines
Use tabs here.
sound/soc/codecs/wm8510.c line 130
Quoted 3 lines
sound/soc/codecs/wm8510.c new file +3
-0+static const char *wm8510_companding[] = {"Off" ,"NC" ,"u-law" ,"A-law" }; +static const char *wm8510_deemp[] = {"None" ,"32kHz" ,"44.1kHz" ,"48kHz" }; +static const char *wm8510_alc[] = {"ALC" ,"Limiter" };No space after '{' but a space before '}'? Oh I'm too picky...
Please fix checkpatch for stuff like this :)
Quoted 10 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ case SNDRV_PCM_RATE_44100: + break;Just to be sure -- No 48000 case?
sound/soc/codecs/wm8510.c line 571
Quoted 3 lines
sound/soc/codecs/wm8510.c new file +3
-0+#define WM8510_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ + SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)... since I find it here.
Yes (well, it's the same as the 41000 case - nothing to set). I'll add an empty case for clarity.
Quoted 5 lines
sound/soc/codecs/wm8510.c line 574
Quoted 2 lines
sound/soc/codecs/wm8510.c new file +2
-0+#define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ + SNDRV_PCM_FMTBIT_S24_LE)Don't you need
SNDRV_PCM_FMTBIT_S32_LE? It's handled inwm8510_pcm_hw_params().
Should do, yes.
Quoted 1 line
Also, is the patch author you or Liam?
We've both worked on the driver; Liam did the original driver and I've done some fairly invasive changes to it since then, particularly to the input paths. The Author: is showing as me since that's what git did when I pulled the driver over into mainline for submission.
At Wed, 4 Jun 2008 20:24:56 +0100,
Quoted 7 lines · Mark Brown
Quoted 2 lines
Also, is the patch author you or Liam?
We've both worked on the driver; Liam did the original driver and I've done some fairly invasive changes to it since then, particularly to the input paths. The Author: is showing as me since that's what git did when I pulled the driver over into mainline for submission.
OK. I just wanted to confirm since the patch had no extra From: line although the comment in the code shows Liam as the author.
And, I seem to have cut some review comments accidentally during editing in the previous mail. Here is again:
Quoted 1 line
sound/soc/codecs/wm8510.c +0
-0
(snip)
Quoted 1 line
+#include <
linux/version.h>
This is likely superfluous.
Quoted 1 line
+#include <
sound/initval.h>
Ditto.
sound/soc/codecs/wm8510.c line 646
Quoted 13 lines
sound/soc/codecs/wm8510.c +13
-0+static int wm8510_init (struct snd_soc_device *socdev) +{ +struct snd_soc_codec *codec = socdev->codec; +int ret =0 ; + + codec->name ="WM8510" ; + codec->owner =THIS_MODULE ; + codec->read = wm8510_read_reg_cache; + codec->write = wm8510_write; + codec->set_bias_level = wm8510_set_bias_level; + codec->dai = &wm8510_dai; + codec->num_dai =1 ; + codec->reg_cache_size =sizeof (wm8510_reg);
Isn't this ARRAY_SIZE()? Looks like the all codec codes set the wrong values for this...
thanks,
Takashi
Quoted 2 lines · Takashi Iwai
OK. I just wanted to confirm since the patch had no extra From: line although the comment in the code shows Liam as the author.
Ideally we'd be able to merge the full history.
Quoted 5 lines
This is likely superfluous.
Quoted 1 line
+#include <
sound/initval.h>Ditto.
Needed for SNDRV_DEFAULT_IDX1 and SNDRV_DEFAULT_STR1.
Quoted 4 lines
sound/soc/codecs/wm8510.c line 646
Quoted 1 line
sound/soc/codecs/wm8510.c new file +1
-0+ codec->reg_cache_size =sizeof (wm8510_reg);Isn't this
ARRAY_SIZE()? Looks like the all codec codes set the wrong values for this...
Not all, but most.