Skip to contentSkip to conversation

ASoC: Add WM8510 driver

PATCH In review Mark Brown 2 participants 5 messages Jun 5, 2008 – Jun 6, 2008 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

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
index 7beefcc..ef400b3 100644
@@ -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
index d5926a1..b92c665 100644
@@ -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): 1212656047-24209-2-git-send-email-broonie@opensource.wolfsonmicro.com

author
#2 lore raw

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
index fd7bc4f..b939e22 100644
@@ -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
index 782db21..3645f95 100644
@@ -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
new file mode 100644
index 0000000..b0765e8
@@ -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
new file mode 100644
index 0000000..c03e55e
@@ -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
#3 lore raw

Re: [PATCH 2/3] ASoC: Add WM8990 driver

In reply to a message not in the archive

At Thu, 5 Jun 2008 09:54:06 +0100,

Quoted 10 lines · Mark Brown

The WM8990 is a highly integrated ultra-low power hi-fi codec designed for handsets rich in multimedia features such as mobile TV, digital audio playback and gaming.

The bulk of this driver was written by Liam Girdwood with some additional development and updates for new ASoC APIs by me.

Hm, I obviously didn't review it in the last cycle.

Quoted 1 line

+#include <linux/kernel.h>

Heh, the same issue as wm8510.

Review

Quoted 6 lines
(quoted diff) +6 -0
+/*
+ * wm8990 register cache.  Note that register 0 is not included in the
+ * cache.
+ */
+static const u16 wm8990_reg[] = {
+    /*0x8990,*/     /* R0  - Reset */

Ditto.

sound/soc/codecs/wm8510.c

Quoted 8 lines
sound/soc/codecs/wm8510.c new file +8 -0
+/*
+ * read wm8990 register cache
+ */
+static inline unsigned int wm8990_read_reg_cache(struct snd_soc_codec *codec,
+	unsigned int reg)
+{
+	u16 *cache = codec->reg_cache;
+	BUG_ON(reg < 1 || reg > (ARRAY_SIZE(wm8990_reg) + 1));

Isn't it

	BUG_ON(reg < 1 || reg > ARRAY_SIZE(wm8990_reg));

??

But at the first place this is bad, because codec_reg_show() in soc-core.c always loops from 0 to codec->reg_cache_size-1. At least, reg == 0 should be simply ignored.

sound/soc/codecs/wm8510.c

Quoted 11 lines
sound/soc/codecs/wm8510.c new file +11 -0
+	return cache[reg - 1];
+}
+
+/*
+ * write wm8990 register cache
+ */
+static inline void wm8990_write_reg_cache(struct snd_soc_codec *codec,
+	unsigned int reg, unsigned int value)
+{
+	u16 *cache = codec->reg_cache;
+	BUG_ON(reg < 1 || reg > (ARRAY_SIZE(wm8990_reg) + 1));

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+static int wm8990_set_bias_level(struct snd_soc_codec *codec,
+	enum snd_soc_bias_level level)

(snip)

Quoted 5 lines
(quoted diff) +5 -0
+	case SND_SOC_BIAS_STANDBY:
+		if (codec->bias_level == SND_SOC_BIAS_OFF) {
+			/* Enable all output discharge bits */
+			wm8990_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE |
+				WM8990_DIS_RLINE | WM8990_DIS_OUT3 |

Review

Quoted 10 lines
(quoted diff) +10 -0
+				WM8990_DIS_OUT4 | WM8990_DIS_LOUT |
+				WM8990_DIS_ROUT);
+
+			/* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */
+			wm8990_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST |
+				     WM8990_BUFDCOPEN | WM8990_POBCTRL |
+				     WM8990_VMIDTOG);
+
+			/* Delay to allow output caps to discharge */
+			schedule_timeout_interruptible(msecs_to_jiffies(300));

Why interruptible? Maybe msleep() is better for such a purpose?

Review

Quoted 12 lines
(quoted diff) +12 -0
+
+			/* Disable VMIDTOG */
+			wm8990_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST |
+				     WM8990_BUFDCOPEN | WM8990_POBCTRL);
+
+			/* disable all output discharge bits */
+			wm8990_write(codec, WM8990_ANTIPOP1, 0);
+
+			/* Enable outputs */
+			wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1b00);
+
+			schedule_timeout_interruptible(msecs_to_jiffies(50));

Ditto.

Quoted 38 lines
(quoted diff) +38 -0
+
+			/* Enable VMID at 2x50k */
+			wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f02);
+
+			schedule_timeout_interruptible(msecs_to_jiffies(100));
+
+			/* Enable VREF */
+			wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03);
+
+			schedule_timeout_interruptible(msecs_to_jiffies(600));
+
+			/* Enable BUFIOEN */
+			wm8990_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST |
+				     WM8990_BUFDCOPEN | WM8990_POBCTRL |
+				     WM8990_BUFIOEN);
+
+			/* Disable outputs */
+			wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x3);
+
+			/* disable POBCTRL, SOFT_ST and BUFDCOPEN */
+			wm8990_write(codec, WM8990_ANTIPOP2, WM8990_BUFIOEN);
+		} else {
+			/* ON -> standby */
+
+		}
+		break;
+
+	case SND_SOC_BIAS_OFF:
+		/* Enable POBCTRL and SOFT_ST */
+		wm8990_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST |
+			WM8990_POBCTRL | WM8990_BUFIOEN);
+
+		/* Enable POBCTRL, SOFT_ST and BUFDCOPEN */
+		wm8990_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST |
+			WM8990_BUFDCOPEN | WM8990_POBCTRL |
+			WM8990_BUFIOEN);
+
+		/* mute DAC */

Review

Quoted 10 lines
(quoted diff) +10 -0
+		val = wm8990_read_reg_cache(codec, WM8990_DAC_CTRL);
+		wm8990_write(codec, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE);
+
+		/* Enable any disabled outputs */
+		wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03);
+
+		/* Disable VMID */
+		wm8990_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f01);
+
+		schedule_timeout_interruptible(msecs_to_jiffies(300));

Ditto.

Quoted 4 lines
(quoted diff) +4 -0
+static int wm8990_init(struct snd_soc_device *socdev)
+{
+	struct snd_soc_codec *codec = socdev->codec;
+	u16 reg;

Review

Quoted 10 lines
(quoted diff) +10 -0
+	int ret = 0;
+
+	codec->name = "WM8990";
+	codec->owner = THIS_MODULE;
+	codec->read = wm8990_read_reg_cache;
+	codec->write = wm8990_write;
+	codec->set_bias_level = wm8990_set_bias_level;
+	codec->dai = &wm8990_dai;
+	codec->num_dai = 2;
+	codec->reg_cache_size = sizeof(wm8990_reg);

A wrong value assignment in this file, too. But, ARRAY_SIZE() is also wrong since the max reg value is ARRAY_SIZE(). ARRAY_SIZE()+1 is the right value, but then it's really unclear what it means...

thanks,

Takashi

author
#4 lore raw

Re: [PATCH 2/3] ASoC: Add WM8990 driver

Quoted 4 lines · Takashi Iwai

Review

Quoted 2 lines
(quoted diff) +2 -0
+			/* Delay to allow output caps to discharge */
+			schedule_timeout_interruptible(msecs_to_jiffies(300));

Why interruptible? Maybe msleep() is better for such a purpose?

The general pattern is to use schedule_timeout_interruptible() in these bias state changes since several of the transitions may be triggered as part of stream startup and teardown and therefore probably should be interruptible in case someone has second thoughts about starting a playback or something. However, in this driver there aren't any delays outside of the initial power up and power down sequences so I'll just change it to use msleep().

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	codec->num_dai = 2;
+	codec->reg_cache_size = sizeof(wm8990_reg);

A wrong value assignment in this file, too. But, ARRAY_SIZE() is also wrong since the max reg value is ARRAY_SIZE(). ARRAY_SIZE()+1 is the right value, but then it's really unclear what it means...

What's happening is that the code this was taken from has saved a word of memory by not including the (non-cacheable) reset/id register in the cache but tripped up a bit doing it. I don't think the two bytes are worth the complexity so I'll simplify.

#5 lore raw
In reply to Mark Brown

At Thu, 5 Jun 2008 09:54:05 +0100,

Quoted 7 lines · Mark Brown

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

Quoted 7 lines

This driver was originally written by Liam Girdwood with updates from Brett Saunders, Geoffrey Wossum and myself.

Thanks. Applied all.

Takashi