Skip to contentSkip to conversation

ASoC codec: SSM2602 audio codec driver (v2)

PATCH In review Bryan Wu 2 participants 2 messages Sep 4, 2008

Subsystems (3)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 ASoC codec: SSM2602 audio codec driver (v2)

From: Cliff Cai <[email protected]>

v1-v2:
- coding style fixing
- use pr_xxx macros to replace printk(KERN_XXX...)
- use new-style i2c interface
- update to use latest ASoC API

---
 sound/soc/codecs/Kconfig   |    3 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/ssm2602.c |  773 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ssm2602.h |  131 ++++++++
 4 files changed, 909 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/ssm2602.c
 create mode 100644 sound/soc/codecs/ssm2602.h
sound/soc/codecs/Kconfig +3 -0
index 5d77dc3..8ef5ce6 100644
@@ -92,3 +92,6 @@ config SND_SOC_TLV320AIC26
 config SND_SOC_TLV320AIC3X
 	tristate
 	depends on I2C
+
+config SND_SOC_SSM2602
+	tristate
sound/soc/codecs/Makefile +2 -0
index 35daaa9..0cd55ee 100644
@@ -15,6 +15,7 @@ snd-soc-wm9713-objs := wm9713.o
 snd-soc-cs4270-objs := cs4270.o
 snd-soc-tlv320aic26-objs := tlv320aic26.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
+snd-soc-ssm2602-objs := ssm2602.o
 
 obj-$(CONFIG_SND_SOC_AC97_CODEC)	+= snd-soc-ac97.o
 obj-$(CONFIG_SND_SOC_AD1980)	+= snd-soc-ad1980.o
@@ -33,3 +34,4 @@ obj-$(CONFIG_SND_SOC_WM9713)	+= snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
 obj-$(CONFIG_SND_SOC_TLV320AIC26)	+= snd-soc-tlv320aic26.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
+obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
sound/soc/codecs/ssm2602.c new file +773 -0

773 lines not on this page · raw message

sound/soc/codecs/ssm2602.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.5.6
#1 lore raw

On Thu, Sep 04, 2008 at 02:59:17PM +0800, Bryan Wu wrote:

Looks good - most of this is minor stuff here that shouldn't be an obstacle to merging, but there does look to be an issue with DAPM and the bias configuration.

sound/soc/codecs/Kconfig config SND_SOC_TLV320AIC26 · line 97

Quoted 9 lines
sound/soc/codecs/Kconfig +3 -0
@@ -92,3 +92,6 @@ config SND_SOC_TLV320AIC26
 config SND_SOC_TLV320AIC3X
 	tristate
 	depends on I2C
+
+config SND_SOC_SSM2602
+	tristate

Please also add the codec to SND_SOC_ALL_CODECS.

sound/soc/codecs/Kconfig

Quoted 2 lines
sound/soc/codecs/Kconfig +2 -0
+#define ssm2602_reset(c)	ssm2602_write(c, SSM2602_RESET, 0)
+/*Appending several "None"s just for OSS mixer use*/

Very minor but a blank line between these two would help.

sound/soc/codecs/Kconfig

Quoted 2 lines
sound/soc/codecs/Kconfig +2 -0
+	/* terminator */
+	{NULL, NULL, NULL},

This terminator is not needed with the bulk registration API.

sound/soc/codecs/Kconfig

Quoted 10 lines
sound/soc/codecs/Kconfig +10 -0
+static inline int get_coeff(int mclk, int rate)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
+		if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
+			return i;
+	}
+	return 0;
+}

Zero is a valid return value but is also returned if no match is found. Is this intended?

sound/soc/codecs/Kconfig

Quoted 10 lines
sound/soc/codecs/Kconfig +10 -0
+static void ssm2602_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
+	/* deactivate */
+	if (!codec->active) {
+		udelay(50);
+		ssm2602_write(codec, SSM2602_ACTIVE, 0);
+	}

Hrm. That udelay() looks suspicious - what's it there for? There's no previous activity in this function for it to leave an interval from. If it's delaying from some previous activity then might the udelay() break if the time between that activity and this being called changes for some reason.

sound/soc/codecs/Kconfig

Quoted 11 lines
sound/soc/codecs/Kconfig +11 -0
+static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	u16 mute_reg = ssm2602_read_reg_cache(codec, SSM2602_APDIGI) & 0xfff7;
+	if (mute)
+		ssm2602_write(codec, SSM2602_APDIGI,
+				mute_reg | ENABLE_DAC_MUTE);
+	else
+		ssm2602_write(codec, SSM2602_APDIGI, mute_reg);
+	return 0;
+}

Might be slightly clearer to use ~ENABLE_DAC_MUTE rather than 0xfff7.

sound/soc/codecs/Kconfig

Quoted 10 lines
sound/soc/codecs/Kconfig +10 -0
+static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
+				 enum snd_soc_bias_level level)
+{
+	u16 reg = ssm2602_read_reg_cache(codec, SSM2602_PWR) & 0xff7f;
+
+	switch (level) {
+	case SND_SOC_BIAS_ON:
+		/* vref/mid, osc on, dac unmute */
+		ssm2602_write(codec, SSM2602_PWR, 0);
+		break;

This looks like it's going to override DAPM - when the driver goes to bias on this will overwrite the DAPM power configuration. This will mean that, for example, the ADC will be powered up during playback. The bias configuration should be leaving the power bits controlled by DAPM as they are when changing bias levels.

sound/soc/codecs/Kconfig

Quoted 4 lines
sound/soc/codecs/Kconfig +4 -0
+/*Left ADC Volume Control (SSM2602_REG_LEFT_ADC_VOL)*/
+#define     LIN_VOL                0x01F   /* Left Channel PGA Volume control                      */
+#define     LIN_ENABLE_MUTE        0x080   /* Left Channel Input Mute                              */
+#define     LRIN_BOTH              0x100   /* Left Channel Line Input Volume update                */

Sorry, didn't pick this up last time but the register bit defines in the header may benefit from namespacing. It's not such a big deal since only machine drivers and this codec driver should be using this header but it'd be nice.