Skip to contentSkip to conversation

ASoC WM8753 codec driver.

PATCH In review Liam Girdwood 2 participants 2 messages Feb 2, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC WM8753 codec driver.

This patch adds ASoC support WM8753 dual interface codec.

Features:-

o Full mixer support.
o Dual DAI support. (one DAI can be configured for HiFi whilst the
other DAI can be used for GSM or BT voice simultaneously)
o Dynamic Audio Power Management.
o Fixed point PLL calculator.

soc/codecs/Kconfig +4 -0
diff -r 0f9c7c3b7657 soc/codecs/Kconfig
@@ -10,6 +10,10 @@ config SND_SOC_WM8750
 	tristate
 	depends on SND_SOC
 
+config SND_SOC_WM8753
+	tristate
+	depends on SND_SOC
+
 config SND_SOC_WM9712
 	tristate
 	depends on SND_SOC
soc/codecs/Makefile +2 -0
diff -r 0f9c7c3b7657 soc/codecs/Makefile
@@ -1,9 +1,11 @@ snd-soc-ac97-objs := ac97.o
 snd-soc-ac97-objs := ac97.o
 snd-soc-wm8731-objs := wm8731.o
 snd-soc-wm8750-objs := wm8750.o
+snd-soc-wm8753-objs := wm8753.o
 snd-soc-wm9712-objs := wm9712.o
 
 obj-$(CONFIG_SND_SOC_AC97_CODEC)	+= snd-soc-ac97.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
 obj-$(CONFIG_SND_SOC_WM9712)	+= snd-soc-wm9712.o
soc/codecs/wm8753.c new file +1738 -0

1,738 lines not on this page · raw message

soc/codecs/wm8753.h new file +126 -0

126 lines not on this page · raw message

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#1 lore raw

At Fri, 02 Feb 2007 17:30:43 +0000,

soc/codecs/wm8753.c line 682

Quoted 7 lines · Liam Girdwood
soc/codecs/wm8753.c new file +7 -0
+static int wm8753_add_widgets(struct snd_soc_codec *codec)
+{
+	int i;
+
+	for(i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++) {
+		snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
+	}

Put a space after 'for'. No braces needed here.

soc/codecs/wm8753.c line 688

Quoted 6 lines
soc/codecs/wm8753.c new file +6 -0
+
+	/* set up the WM8753 audio map */
+	for(i = 0; audio_map[i][0] != NULL; i++) {
+		snd_soc_dapm_connect_input(codec, audio_map[i][0],
+			audio_map[i][1], audio_map[i][2]);
+	}

Ditto.

soc/codecs/wm8753.c line 701

Quoted 8 lines
soc/codecs/wm8753.c new file +8 -0
+/* PLL divisors */
+struct _pll_div {
+	u32 div2:1;
+	u32 n:4;
+	u32 k:24;
+};
+
+static struct _pll_div pll_div;

Is it OK to use a global static varible here? Shouldn't be in codec_priv or something else locally?

Quoted 23 lines
soc/codecs/wm8753.c new file +23 -0
+static int wm8753_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
+		int pll_id, unsigned int freq_in, unsigned int freq_out)
+{
+	if (!freq_in || !freq_out) {
+		/* disable PLL  */
+		wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0026);
+		wm8753_write(codec, WM8753_CLOCK, reg);
+		return 0;
+	} else {
+
+        u16 value = 0;
+
+		pll_factors(freq_out * 8, freq_in);
+
+        /* set up N and K PLL divisor ratios */
+        /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */
+        value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18);
+        wm8753_write(codec, WM8753_PLL1CTL2 + offset, value);
+
+        /* bits 8:0 = PLL_K[17:9] */
+        value = (pll_div.k & 0x03fe00) >> 9;
+        wm8753_write(codec, WM8753_PLL1CTL3 + offset, value);
+

soc/codecs/wm8753.c line 791

Quoted 10 lines
soc/codecs/wm8753.c new file +10 -0
+        /* bits 8:0 = PLL_K[8:0] */
+        value = pll_div.k & 0x0001ff;
+        wm8753_write(codec, WM8753_PLL1CTL4 + offset, value);
+
+        /* set PLL as input and enable */
+        wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 |
+        	(pll_div.div2 << 3));
+		wm8753_write(codec, WM8753_CLOCK, reg | enable);
+    }
+	return 0;

Broken indentation.

Quoted 12 lines
soc/codecs/wm8753.c new file +12 -0
+/*
+ * Clock after PLL and dividers
+ */
+static int wm8753_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
+		int clk_id, unsigned int freq, int dir)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+	struct wm8753_priv *wm8753 = codec->private_data;
+
+	switch (freq) {
+	case 11289600:
+	case 12000000:

soc/codecs/wm8753.c line 883

Quoted 10 lines
soc/codecs/wm8753.c new file +10 -0
+	case 12288000:
+	case 16934400:
+	case 18432000:
+		if (clk_id == WM8753_MCLK) {
+			wm8753->sysclk = freq;
+			return 0;
+		} else if (clk_id == WM8753_PCMCLK) {
+			wm8753->pcmclk = freq;
+			return 0;
+		}

Put break here (just to be sure - so I leared).

Quoted 4 lines
soc/codecs/wm8753.c new file +4 -0
+	}
+	return -EINVAL;
+}
+

(snip)

Quoted 18 lines

diff -r 0f9c7c3b7657 soc/codecs/wm8753.h

soc/codecs/wm8753.h new file +14 -0
@@ -0,0 +1,126 @@
+/*
+ * wm8753.h  --  audio driver for WM8753
+ *
+ * Copyright 2003 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         [email protected] or [email protected]
+ *
+ *  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.
+ *
+ */
+

soc/codecs/wm8753.h line 24

Quoted 10 lines
soc/codecs/wm8753.h new file +10 -0
+#ifndef _WM8753_H
+#define _WM8753_H
+
+/* WM8753 register space */
+
+#define WM8753_DAC		0x01
+#define WM8753_ADC		0x02
+#define WM8753_PCM		0x03
+#define WM8753_HIFI		0x04
+#define WM8753_IOCTL	0x05

It'd be more beautiful if you use the same spaces there :)

I suppose the merge of this driver can be also postponed (until the platform driver is submitted)?

Thanks,

Takashi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642