Skip to contentSkip to conversation

v2: ASoC: Add new Realtek ALC5632 CODEC driver.

PATCH Superseded Leon Romanovsky 2 participants 2 messages Oct 25, 2011 – Oct 26, 2011

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v2: ASoC: Add new Realtek ALC5632 CODEC driver.

This driver implements basic functionality, using I²C for the control channel.

---
v2: Free from checkpatch warnings
v1: Initial code drop
---

---
 sound/soc/codecs/Kconfig   |    4 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/alc5632.c | 1190 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/alc5632.h |  243 +++++++++
 4 files changed, 1439 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/alc5632.c
 create mode 100644 sound/soc/codecs/alc5632.h
sound/soc/codecs/Kconfig +4 -0
index 4584514..e78ece8 100644
@@ -26,6 +26,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_AK4642 if I2C
 	select SND_SOC_AK4671 if I2C
 	select SND_SOC_ALC5623 if I2C
+    select SND_SOC_ALC5632 if I2C
 	select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC
 	select SND_SOC_CS42L51 if I2C
 	select SND_SOC_CS4270 if I2C
@@ -169,6 +170,9 @@ config SND_SOC_AK4671
 config SND_SOC_ALC5623
        tristate
 
+config SND_SOC_ALC5632
+	tristate
+
 config SND_SOC_CQ0093VC
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index a2c7842..98bf1b6 100644
@@ -29,6 +29,7 @@ snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-sgtl5000-objs := sgtl5000.o
 snd-soc-alc5623-objs := alc5623.o
+snd-soc-alc5632-objs := alc5632.0
 snd-soc-sn95031-objs := sn95031.o
 snd-soc-spdif-objs := spdif_transciever.o
 snd-soc-ssm2602-objs := ssm2602.o
@@ -113,6 +114,7 @@ obj-$(CONFIG_SND_SOC_AK4641)	+= snd-soc-ak4641.o
 obj-$(CONFIG_SND_SOC_AK4642)	+= snd-soc-ak4642.o
 obj-$(CONFIG_SND_SOC_AK4671)	+= snd-soc-ak4671.o
 obj-$(CONFIG_SND_SOC_ALC5623)    += snd-soc-alc5623.o
+obj-$(CONFIG_SND_SOC_ALC5632)	+= snd-soc-alc5632.o
 obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o
 obj-$(CONFIG_SND_SOC_CS42L51)	+= snd-soc-cs42l51.o
 obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
sound/soc/codecs/alc5632.c new file +1190 -0

1,190 lines not on this page · raw message

sound/soc/codecs/alc5632.h new file +243 -0

243 lines not on this page · raw message

Signature · 6 lines
1.7.3.4

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw
Quoted 3 lines · Leon Romanovsky

This driver implements basic functionality, using I²C for the control channel.

This looks good overall, much better than the out of tree driver you pointed me at the other day! A couple of fairly minor points below, basically style issues.

sound/soc/codecs/Kconfig config SND_SOC_ALL_CODECS · line 31

Quoted 6 lines
sound/soc/codecs/Kconfig +1 -0
 	select SND_SOC_AK4642 if I2C
 	select SND_SOC_AK4671 if I2C
 	select SND_SOC_ALC5623 if I2C
+    select SND_SOC_ALC5632 if I2C
 	select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC
 	select SND_SOC_CS42L51 if I2C

Think there's a tab/space issue here.

Quoted 1 line

+/* #define DEBUG */

Better to drop this but it's very minor either way.

Quoted 1 line

+#define ALC5632_VERSION "0.1"

Drop the version number from the driver - once it's in manline git and the kernel versioning are enough, these versions never get updated anyway.

sound/soc/codecs/alc5632.c line 76

Quoted 3 lines
sound/soc/codecs/alc5632.c new file +3 -0
+static int caps_charge = 2000;
+module_param(caps_charge, int, 0);
+MODULE_PARM_DESC(caps_charge, "ALC5632 cap charge time (msecs)");

Ouch!

sound/soc/codecs/alc5632.c line 370

Quoted 2 lines
sound/soc/codecs/alc5632.c new file +2 -0
+SND_SOC_DAPM_MICBIAS("Mic Bias1", ALC5632_PWR_MANAG_ADD1, 3, 0),
+SND_SOC_DAPM_MICBIAS("Mic Bias2", ALC5632_PWR_MANAG_ADD1, 2, 0),

It's better to convert these to _SUPPLY() widgets - since the introduction of supplies there's really no need for the MICBIAS widgets and supplies are much easier to hook up in the boards. We really ought to go through and convert as many drivers to this model.

sound/soc/codecs/alc5632.c line 661

Quoted 2 lines
sound/soc/codecs/alc5632.c new file +2 -0
+/* choose MCLK/BCLK/VBCLK */
+	snd_soc_write(codec, ALC5632_GPCR2, gbl_clk);

Indent the comments with the code please.

sound/soc/codecs/alc5632.c line 850

Quoted 10 lines
sound/soc/codecs/alc5632.c new file +10 -0
+#define ALC5632_ADD1_POWER_EN \
+		(ALC5632_PWR_ADD1_SPK_AMP_EN \
+		| ALC5632_PWR_ADD1_DAC_REF \
+		| ALC5632_PWR_ADD1_DAC_L_EN \
+		| ALC5632_PWR_ADD1_DAC_R_EN \
+		| ALC5632_PWR_ADD1_SOFTGEN_EN \
+		| ALC5632_PWR_ADD1_MAIN_I2S_EN \
+		| ALC5632_PWR_ADD1_HP_OUT_AMP \
+		| ALC5632_PWR_ADD1_HP_OUT_ENH_AMP \
+		| ALC5632_PWR_ADD1_MAIN_BIAS)

This looks like it ought to go into DAPM but looking at the pop/click sequence you have I suspect that might not work so well.

sound/soc/codecs/alc5632.c line 918

Quoted 3 lines
sound/soc/codecs/alc5632.c new file +3 -0
+static struct snd_soc_dai_driver alc5632_dai = {
+	.name = "alc5632-hifi",
+	.playback = {

Based on the code above it looks like the same clock configuration is used for playback and record so I expect you need to set the symmetric_rates flags so that we don't get people trying to set different rates for playback and capture which would mean that the first one to get started would get disrupted.

sound/soc/codecs/alc5632.c line 951

Quoted 4 lines
sound/soc/codecs/alc5632.c new file +4 -0
+
+	/* Sync reg_cache with the hardware */
+	for (i = 2 ; i < codec->driver->reg_cache_size ; i += step)
+		snd_soc_write(codec, i, cache[i]);

snd_soc_cache_sync().

sound/soc/codecs/alc5632.c line 960

Quoted 5 lines
sound/soc/codecs/alc5632.c new file +5 -0
+	if (codec->dapm.suspend_bias_level == SND_SOC_BIAS_ON) {
+		alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+		codec->dapm.bias_level = SND_SOC_BIAS_ON;
+		alc5632_set_bias_level(codec, codec->dapm.bias_level);
+	}

This isn't needed, you'll never be in a state above _STANDBY before you go into suspend so it'll never actually get run.

sound/soc/codecs/alc5632.c line 1011

Quoted 3 lines
sound/soc/codecs/alc5632.c new file +3 -0
+	/* spk amp pwr enable 3A | 0x0400 @ 3A */
+	snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
+		0, ALC5632_PWR_ADD1_SPK_AMP_EN);

Should this be in DAPM?

sound/soc/codecs/alc5632.c line 1021

Quoted 2 lines
sound/soc/codecs/alc5632.c new file +2 -0
+	/* enable slave mode 0x8000 @ 34 */
+	snd_soc_write(codec, ALC5632_DAI_CONTROL, ALC5632_DAI_SDP_SLAVE_MODE);

Just leave this at default and let the machine driver configure the chip.

sound/soc/codecs/alc5632.c line 1039

Quoted 8 lines
sound/soc/codecs/alc5632.c new file +8 -0
+	snd_soc_add_controls(codec, alc5632_snd_controls,
+			ARRAY_SIZE(alc5632_snd_controls));
+
+	snd_soc_dapm_new_controls(dapm, alc5632_dapm_widgets,
+					ARRAY_SIZE(alc5632_dapm_widgets));
+
+	/* set up audio path interconnects */
+	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));

New code should just point to the tables from the codec driver structure and let the core do these calls.

sound/soc/codecs/alc5632.c line 1077

Quoted 1 line
sound/soc/codecs/alc5632.c new file +1 -0
+	dev_dbg(&client->dev, "in i2c probe...\n");

Drop this stuff for mainline.

sound/soc/codecs/alc5632.c line 1109

Quoted 3 lines
sound/soc/codecs/alc5632.c new file +3 -0
+	alc5632 = kzalloc(sizeof(struct alc5632_priv), GFP_KERNEL);
+	if (alc5632 == NULL)
+		return -ENOMEM;

Use devm_kzalloc() for this, device model code will then deal with calling kfree() for you.