Skip to contentSkip to conversation

ASoC: t5325 audio support

PATCH In review Arnaud Patard (Rtp) 2 participants 9 messages Sep 7, 2010 – Sep 8, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: t5325 audio support

Hi,

This patchset is the first try to get merged audio support for HP t5325 thinclient. This board is using a ALC5621 so the major part of this series is made of the ALC5623 driver. It's supporting ALC5621/22/23 but has been tested only with a ALC5621.

Arnaud

#1 lore raw

PATCH 1/3 ASoC: add support for alc562[123] codecs

This patch is adding support for alc562[123] codecs. It's based on the source code available in HP source code and other places.

sound/soc/codecs/Kconfig +4 -0
Index: sound-2.6/sound/soc/codecs/Kconfig
===================================================================
@@ -159,6 +159,9 @@
 config SND_SOC_PCM3008
        tristate
 
+config SND_SOC_ALC5623
+       tristate
+
 config SND_SOC_SPDIF
 	tristate
 
@@ -305,3 +308,4 @@
 
 config SND_SOC_WM9090
 	tristate
+
sound/soc/codecs/Makefile +2 -0
Index: sound-2.6/sound/soc/codecs/Makefile
===================================================================
@@ -16,6 +16,7 @@
 snd-soc-da7210-objs := da7210.o
 snd-soc-l3-objs := l3.o
 snd-soc-pcm3008-objs := pcm3008.o
+snd-soc-alc5623-objs := alc5623.o
 snd-soc-spdif-objs := spdif_transciever.o
 snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-stac9766-objs := stac9766.o
@@ -88,6 +89,7 @@
 obj-$(CONFIG_SND_SOC_L3)	+= snd-soc-l3.o
 obj-$(CONFIG_SND_SOC_JZ4740_CODEC)	+= snd-soc-jz4740-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
+obj-$(CONFIG_SND_SOC_ALC5623)    += snd-soc-alc5623.o
 obj-$(CONFIG_SND_SOC_SPDIF)	+= snd-soc-spdif.o
 obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
 obj-$(CONFIG_SND_SOC_STAC9766)	+= snd-soc-stac9766.o
sound/soc/codecs/alc5623.c new file +1161 -0

1,161 lines not on this page · raw message

sound/soc/codecs/alc5623.h new file +161 -0

161 lines not on this page · raw message

include/linux/alc5623.h new file +8 -0
Index: sound-2.6/include/linux/alc5623.h
===================================================================
@@ -0,0 +1,8 @@
+#ifndef _INCLUDE_LINUX_ALC5623_H
+#define _INCLUDE_LINUX_ALC5623_H
+struct alc5623_platform_data {
+	unsigned int add_ctrl;
+	unsigned int jack_det_ctrl;
+};
+#endif
+
#2 lore raw

Re: [patch 1/3] ASoC: add support for alc562[123] codecs

sound/soc/codecs/Kconfig line 164

Quoted 13 lines · Arnaud Patard

This patch is adding support for alc562[123] codecs. It's based on the source code available in HP source code and other places.

+++ sound-2.6/sound/soc/codecs/Kconfig 2010-09-06 23:29:31.000000000 +0200

sound/soc/codecs/Kconfig +3 -0
@@ -159,6 +159,9 @@
 config SND_SOC_PCM3008
        tristate
 
+config SND_SOC_ALC5623
+       tristate
+

Keep this and the Makefile sorted. Also remember to add this to SND_SOC_ALL_CODECS.

sound/soc/codecs/alc5623.c line 37

Quoted 1 line
sound/soc/codecs/alc5623.c new file +1 -0
+#define ALC5623_VERSION "0.01"

git should provide enough tracking for version numbers.

sound/soc/codecs/alc5623.c line 66

Quoted 6 lines
sound/soc/codecs/alc5623.c new file +5 -0
+static int caps_charge = 2000;
+module_param(caps_charge, int, 0);
+MODULE_PARM_DESC(caps_charge, "ALC5623 cap charge time (msecs)");
 
+static int alc5623_write_mask(struct snd_soc_codec *codec, unsigned int reg,
+		unsigned int value, unsigned int mask)

This is snd_soc_update_bits().

Quoted 9 lines
sound/soc/codecs/alc5623.c new file +9 -0
+/*
+ * problem is :
+ * - hp mixer has 2 bits in PM reg 0x3C
+ * - adc input of the hp mixer has 2 mute bits
+ * - all the other inputs of the hp mixer have 1 bit
+ * =>  the bits for adc and pm can't be used separately
+ */
+static int hp_mixer_event(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event)

sound/soc/codecs/alc5623.c line 103

Quoted 10 lines
sound/soc/codecs/alc5623.c new file +10 -0
+{
+	u16 reg;
+	u16 mask = ALC5623_PWR_ADD2_L_HP_MIXER|ALC5623_PWR_ADD2_R_HP_MIXER;
+
+	reg = snd_soc_read(w->codec, ALC5623_PWR_MANAG_ADD2);
+	reg &= ~mask;
+	if (event == SND_SOC_DAPM_POST_PMU)
+		reg |= mask;
+	return snd_soc_write(w->codec, ALC5623_PWR_MANAG_ADD2, reg);
+}

It looks like it'd be simpler to do something like:

	{ "HPL", NULL, "HP" },
	{ "HPR", NULL, "HP" },

then have the two ADC channels feed into the left and right channels of the headphone while having the single switches feed into the HP widget (which would be a NOPM dummy widget for routing purposes).

sound/soc/codecs/alc5623.c line 115

Quoted 11 lines
sound/soc/codecs/alc5623.c new file +11 -0
+static int amp_mixer_event(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event)
+{
+	/* index 0x46: class-d internal register */
+	snd_soc_write(w->codec, ALC5623_HID_CTRL_INDEX, 0x46);
+	if (event == SND_SOC_DAPM_PRE_PMU)
+		snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0xFFFF);
+	else
+		snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0);
+	return 0;
+}

A switch statement would be more idiomatic here.

sound/soc/codecs/alc5623.c line 253

Quoted 3 lines
sound/soc/codecs/alc5623.c new file +3 -0
+static const struct soc_enum alc5623_enum[] = {
+SOC_ENUM_SINGLE(ALC5623_OUTPUT_MIXER_CTRL, 14, 4, alc5623_spk_n_sour_sel),
+SOC_ENUM_SINGLE(ALC5623_OUTPUT_MIXER_CTRL, 9, 2, alc5623_hpl_out_input_sel),

Don't put your enums in an array, declare them as variables. The enum arrays are harder to read and vastly more error prone.

sound/soc/codecs/alc5623.c line 592

Quoted 9 lines
sound/soc/codecs/alc5623.c new file +9 -0
+	if (pll_div) {
+		snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
+		snd_soc_write(codec, ALC5623_PLL_CTRL, pll_div);
+		alc5623_write_mask(codec, ALC5623_PWR_MANAG_ADD2,
+					ALC5623_PWR_ADD2_PLL,
+					ALC5623_PWR_ADD2_PLL);
+		gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL;
+		snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
+	}

Should complain if we fail to find a configuration.

sound/soc/codecs/alc5623.c line 779

Quoted 13 lines
sound/soc/codecs/alc5623.c new file +11 -0
+#define ALC5623_ADD3_POWER_EN (ALC5623_PWR_ADD3_MAIN_BIAS \
+	| ALC5623_PWR_ADD3_MIC1_BOOST_AD)
 
+#define ALC5623_ADD1_POWER_EN \
+	(ALC5623_PWR_ADD1_MAIN_I2S_EN | ALC5623_PWR_ADD1_MIC1_BIAS_EN \
+	| ALC5623_PWR_ADD1_SHORT_CURR_DET_EN | ALC5623_PWR_ADD1_SOFTGEN_EN \
+	| ALC5623_PWR_ADD1_DEPOP_BUF_HP | ALC5623_PWR_ADD1_HP_OUT_AMP \
+	| ALC5623_PWR_ADD1_HP_OUT_ENH_AMP)
 
+#define ALC5623_ADD1_POWER_EN_5622 \
+	(ALC5623_PWR_ADD1_MAIN_I2S_EN | ALC5623_PWR_ADD1_MIC1_BIAS_EN \
+	| ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \
+	| ALC5623_PWR_ADD1_HP_OUT_AMP)

Most of the stuff in here looks like it ought to be managed by DAPM?

sound/soc/codecs/alc5623.c line 928

Quoted 8 lines
sound/soc/codecs/alc5623.c new file +8 -0
+static int alc5623_probe(struct snd_soc_codec *codec)
+{
+	struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
+	int ret;
+
+	INIT_DELAYED_WORK(&codec->delayed_work, alc5623_work);
+	schedule_delayed_work(&codec->delayed_work,
+				msecs_to_jiffies(caps_charge));

Since we now support out of line resume for ASoC devices (so we don't hold up the rest of the system) it should be possible to just do this stuff in the set_bias_level() function rather than faffing around with delayed work like this. This is less racy.

sound/soc/codecs/alc5623.c line 937

Quoted 2 lines
sound/soc/codecs/alc5623.c new file +2 -0
+	alc5623_reset(codec);
+	alc5623_fill_cache(codec);

Don't we know the defaults for the device?

sound/soc/codecs/alc5623.c line 945

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if (alc5623->add_ctrl) {
+		snd_soc_write(codec, ALC5623_ADD_CTRL_REG,
+				alc5623->add_ctrl);
+	}

Hrm?

sound/soc/codecs/alc5623.c line 950

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if (alc5623->jack_det_ctrl) {
+		snd_soc_write(codec, ALC5623_JACK_DET_CTRL,
+				alc5623->jack_det_ctrl);
+	}

I didn't see any jack detection support in the driver, and I wouldn't expect to see anything exported to userspace for it?

sound/soc/codecs/alc5623.c line 1062

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) {
+		dev_err(&client->dev, "unknown or wrong codec\n");
+		return -ENODEV;
+	}

Better to say what the IDs you were looking at are, especially for id2.

include/linux/alc5623.h

Quoted 2 lines
include/linux/alc5623.h new file +0 -0

include/sound

include/linux/alc5623.h line 6

Quoted 7 lines
include/linux/alc5623.h new file +6 -0
@@ -0,0 +1,8 @@
+#ifndef _INCLUDE_LINUX_ALC5623_H
+#define _INCLUDE_LINUX_ALC5623_H
+struct alc5623_platform_data {
+	unsigned int add_ctrl;
+	unsigned int jack_det_ctrl;
+};

Some documentation explaining what these are would probably be useful.

#3 lore raw

Re: [patch 1/3] ASoC: add support for alc562[123] codecs

Quoted 11 lines · Mark Brown
Quoted 10 lines · Arnaud Patard

This patch is adding support for alc562[123] codecs. It's based on the source code available in HP source code and other places.

+++ sound-2.6/sound/soc/codecs/Kconfig 2010-09-06 23:29:31.000000000 +0200

sound/soc/codecs/Kconfig +0 -0
@@ -159,6 +159,9 @@
 config SND_SOC_PCM3008
        tristate
 
Quoted 6 lines

sound/soc/codecs/Kconfig line 164

Quoted 3 lines
sound/soc/codecs/Kconfig +3 -0
+config SND_SOC_ALC5623
+       tristate
+

Keep this and the Makefile sorted. Also remember to add this to SND_SOC_ALL_CODECS.

ok

Quoted 4 lines

sound/soc/codecs/alc5623.c line 37

Quoted 2 lines
sound/soc/codecs/alc5623.c new file +1 -0
+#define ALC5623_VERSION "0.01"

git should provide enough tracking for version numbers.

oops. forgot to kill it. It's unused.

Quoted 9 lines

sound/soc/codecs/alc5623.c line 66

Quoted 7 lines
sound/soc/codecs/alc5623.c new file +5 -0
+static int caps_charge = 2000;
+module_param(caps_charge, int, 0);
+MODULE_PARM_DESC(caps_charge, "ALC5623 cap charge time (msecs)");
 
+static int alc5623_write_mask(struct snd_soc_codec *codec, unsigned int reg,
+		unsigned int value, unsigned int mask)

This is snd_soc_update_bits().

great. will use it.

Quoted 23 lines
Quoted 10 lines
sound/soc/codecs/alc5623.c new file +9 -0
+/*
+ * problem is :
+ * - hp mixer has 2 bits in PM reg 0x3C
+ * - adc input of the hp mixer has 2 mute bits
+ * - all the other inputs of the hp mixer have 1 bit
+ * =>  the bits for adc and pm can't be used separately
+ */
+static int hp_mixer_event(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event)

sound/soc/codecs/alc5623.c line 103

Quoted 10 lines
sound/soc/codecs/alc5623.c new file +10 -0
+{
+	u16 reg;
+	u16 mask = ALC5623_PWR_ADD2_L_HP_MIXER|ALC5623_PWR_ADD2_R_HP_MIXER;
+
+	reg = snd_soc_read(w->codec, ALC5623_PWR_MANAG_ADD2);
+	reg &= ~mask;
+	if (event == SND_SOC_DAPM_POST_PMU)
+		reg |= mask;
+	return snd_soc_write(w->codec, ALC5623_PWR_MANAG_ADD2, reg);
+}

It looks like it'd be simpler to do something like:

Quoted 6 lines
	{ "HPL", NULL, "HP" },
	{ "HPR", NULL, "HP" },

then have the two ADC channels feed into the left and right channels of the headphone while having the single switches feed into the HP widget (which would be a NOPM dummy widget for routing purposes).

hmm... I'm not sure to understand correctly. The two bits ALC5623_PWR_ADD2_?_HP_MIXER are for the HP mixers. There are 2 mixers but I'm doing like there's only 1 mixer due to the single bit inputs. Can you please give more details about your suggestion ?

Quoted 15 lines

sound/soc/codecs/alc5623.c line 115

Quoted 12 lines
sound/soc/codecs/alc5623.c new file +11 -0
+static int amp_mixer_event(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event)
+{
+	/* index 0x46: class-d internal register */
+	snd_soc_write(w->codec, ALC5623_HID_CTRL_INDEX, 0x46);
+	if (event == SND_SOC_DAPM_PRE_PMU)
+		snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0xFFFF);
+	else
+		snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0);
+	return 0;
+}

A switch statement would be more idiomatic here.

ok

Quoted 7 lines

sound/soc/codecs/alc5623.c line 253

Quoted 3 lines
sound/soc/codecs/alc5623.c new file +3 -0
+static const struct soc_enum alc5623_enum[] = {
+SOC_ENUM_SINGLE(ALC5623_OUTPUT_MIXER_CTRL, 14, 4, alc5623_spk_n_sour_sel),
+SOC_ENUM_SINGLE(ALC5623_OUTPUT_MIXER_CTRL, 9, 2, alc5623_hpl_out_input_sel),

Don't put your enums in an array, declare them as variables. The enum arrays are harder to read and vastly more error prone.

ok

Quoted 21 lines

sound/soc/codecs/alc5623.c line 592

Quoted 9 lines
sound/soc/codecs/alc5623.c new file +9 -0
+	if (pll_div) {
+		snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
+		snd_soc_write(codec, ALC5623_PLL_CTRL, pll_div);
+		alc5623_write_mask(codec, ALC5623_PWR_MANAG_ADD2,
+					ALC5623_PWR_ADD2_PLL,
+					ALC5623_PWR_ADD2_PLL);
+		gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL;
+		snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
+	}

Should complain if we fail to find a configuration.

Quoted 8 lines
sound/soc/codecs/alc5623.c new file +7 -0
+#define ALC5623_ADD3_POWER_EN (ALC5623_PWR_ADD3_MAIN_BIAS \
+	| ALC5623_PWR_ADD3_MIC1_BOOST_AD)
 
+#define ALC5623_ADD1_POWER_EN \
+	(ALC5623_PWR_ADD1_MAIN_I2S_EN | ALC5623_PWR_ADD1_MIC1_BIAS_EN \
+	| ALC5623_PWR_ADD1_SHORT_CURR_DET_EN | ALC5623_PWR_ADD1_SOFTGEN_EN \
+	| ALC5623_PWR_ADD1_DEPOP_BUF_HP | ALC5623_PWR_ADD1_HP_OUT_AMP \
+	| ALC5623_PWR_ADD1_HP_OUT_ENH_AMP)
Quoted 6 lines

sound/soc/codecs/alc5623.c line 779

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+#define ALC5623_ADD1_POWER_EN_5622 \
+	(ALC5623_PWR_ADD1_MAIN_I2S_EN | ALC5623_PWR_ADD1_MIC1_BIAS_EN \
+	| ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \
+	| ALC5623_PWR_ADD1_HP_OUT_AMP)

Most of the stuff in here looks like it ought to be managed by DAPM?

hmm... I thought it was easier/better done like this. Is it a hard requirement ?

Quoted 15 lines

sound/soc/codecs/alc5623.c line 928

Quoted 9 lines
sound/soc/codecs/alc5623.c new file +8 -0
+static int alc5623_probe(struct snd_soc_codec *codec)
+{
+	struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
+	int ret;
+
+	INIT_DELAYED_WORK(&codec->delayed_work, alc5623_work);
+	schedule_delayed_work(&codec->delayed_work,
+				msecs_to_jiffies(caps_charge));

Since we now support out of line resume for ASoC devices (so we don't hold up the rest of the system) it should be possible to just do this stuff in the set_bias_level() function rather than faffing around with delayed work like this. This is less racy.

I was even wondering about removing that stuff but as it was there in original driver, I choose to keep it. WDYT ?

Quoted 4 lines

sound/soc/codecs/alc5623.c line 937

Quoted 2 lines
sound/soc/codecs/alc5623.c new file +2 -0
+	alc5623_reset(codec);
+	alc5623_fill_cache(codec);

Don't we know the defaults for the device?

as this driver is handling 3 codec with some small differencies, instead of having to hunt for the changes between the default values, I prefered reading them from the device.

Quoted 7 lines

sound/soc/codecs/alc5623.c line 945

Quoted 5 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if (alc5623->add_ctrl) {
+		snd_soc_write(codec, ALC5623_ADD_CTRL_REG,
+				alc5623->add_ctrl);
+	}

Hrm?

this register contains some board specific values and I didn't see how it could be handled except by using platform_data.

Quoted 8 lines

sound/soc/codecs/alc5623.c line 950

Quoted 5 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if (alc5623->jack_det_ctrl) {
+		snd_soc_write(codec, ALC5623_JACK_DET_CTRL,
+				alc5623->jack_det_ctrl);
+	}

I didn't see any jack detection support in the driver, and I wouldn't expect to see anything exported to userspace for it?

the jack detection is handled by the codec itself. The pin are connected to gpio on it and the codec is switching channels on/off without user intervention. Nothing to do on driver side except configuring this register.

Quoted 13 lines

sound/soc/codecs/alc5623.c line 1062

Quoted 5 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) {
+		dev_err(&client->dev, "unknown or wrong codec\n");
+		return -ENODEV;
+	}

Better to say what the IDs you were looking at are, especially for id2.

include/linux/alc5623.h

Quoted 2 lines
include/linux/alc5623.h new file +0 -0

include/sound

Quoted 9 lines

include/linux/alc5623.h line 6

Quoted 7 lines
include/linux/alc5623.h new file +6 -0
@@ -0,0 +1,8 @@
+#ifndef _INCLUDE_LINUX_ALC5623_H
+#define _INCLUDE_LINUX_ALC5623_H
+struct alc5623_platform_data {
+	unsigned int add_ctrl;
+	unsigned int jack_det_ctrl;
+};

Some documentation explaining what these are would probably be useful.

The names are really near to the names in the specs. As you need to look at the specs to have their values, I thought it would be enough.

Arnaud

#4 lore raw

Re: [patch 1/3] ASoC: add support for alc562[123] codecs

Quoted 7 lines · Arnaud Patard
Quoted 4 lines · Mark Brown

It looks like it'd be simpler to do something like:

	{ "HPL", NULL, "HP" },
	{ "HPR", NULL, "HP" },
Quoted 8 lines
Quoted 3 lines

then have the two ADC channels feed into the left and right channels of the headphone while having the single switches feed into the HP widget (which would be a NOPM dummy widget for routing purposes).

hmm... I'm not sure to understand correctly. The two bits ALC5623_PWR_ADD2_?_HP_MIXER are for the HP mixers. There are 2 mixers but I'm doing like there's only 1 mixer due to the single bit inputs. Can you please give more details about your suggestion ?

Add on to the above things like this:

	{ "HPL", "ADC Switch", "ADCL" },
	{ "HPR", "ADC Switch", "ADCR" },

	{ "HP", "AUX Switch", "Aux" },

so you get separate left/right control where you have stereo control while still getting the mono control on the virtual mono HP widget.

Quoted 9 lines
Quoted 6 lines

sound/soc/codecs/alc5623.c line 779

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+#define ALC5623_ADD1_POWER_EN_5622 \
+	(ALC5623_PWR_ADD1_MAIN_I2S_EN | ALC5623_PWR_ADD1_MIC1_BIAS_EN \
+	| ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \
+	| ALC5623_PWR_ADD1_HP_OUT_AMP)

Most of the stuff in here looks like it ought to be managed by DAPM?

hmm... I thought it was easier/better done like this. Is it a hard requirement ?

Given that you're already defining widgets for things like the I2S (the AIF widgets) it seems silly not to. For the micbias I'd say it's a hard requirement since driving the micbias when not needed is potenially harmful.

Quoted 7 lines
Quoted 4 lines

Since we now support out of line resume for ASoC devices (so we don't hold up the rest of the system) it should be possible to just do this stuff in the set_bias_level() function rather than faffing around with delayed work like this. This is less racy.

I was even wondering about removing that stuff but as it was there in original driver, I choose to keep it. WDYT ?

If you look at the current WM8753 driver you'll see that it's been removed from there.

Quoted 9 lines
Quoted 6 lines

sound/soc/codecs/alc5623.c line 945

Quoted 4 lines
sound/soc/codecs/alc5623.c new file +4 -0
+	if (alc5623->add_ctrl) {
+		snd_soc_write(codec, ALC5623_ADD_CTRL_REG,
+				alc5623->add_ctrl);
+	}

Hrm?

this register contains some board specific values and I didn't see how it could be handled except by using platform_data.

What are they?

Quoted 11 lines
Quoted 8 lines

include/linux/alc5623.h line 6

Quoted 6 lines
include/linux/alc5623.h new file +6 -0
+#ifndef _INCLUDE_LINUX_ALC5623_H
+#define _INCLUDE_LINUX_ALC5623_H
+struct alc5623_platform_data {
+	unsigned int add_ctrl;
+	unsigned int jack_det_ctrl;
+};

Some documentation explaining what these are would probably be useful.

The names are really near to the names in the specs. As you need to look at the specs to have their values, I thought it would be enough.

So saying something like "Values to be written to the add_ctrl and jack_det_ctrl registers" would cover it. Remember, if a software engineer is picking up a preexisting driver they may never even look at the datasheet.

#5 lore raw

PATCH 2/3 kirkwood: Add audio support to hp t5325 thin clients

In reply to Arnaud Patard (Rtp)

This patch is adding support for hp t5325 thin clients. There's a alc5623 codec connected to the i2s interface.

sound/soc/kirkwood/Kconfig +10 -0
Index: sound-2.6/sound/soc/kirkwood/Kconfig
===================================================================
@@ -18,3 +18,13 @@
 	  Say Y if you want to add support for SoC audio on
 	  Openrd Client.
 
+config SND_KIRKWOOD_SOC_T5325
+	tristate "SoC Audio support for HP t5325"
+	#depends on SND_KIRKWOOD_SOC && MACH_T5325
+	depends on SND_KIRKWOOD_SOC
+	select SND_KIRKWOOD_SOC_I2S
+	select SND_SOC_ALC5623
+	help
+	  Say Y if you want to add support for SoC audio on
+	  the HP t5325 thin client.
+
sound/soc/kirkwood/Makefile +2 -0
Index: sound-2.6/sound/soc/kirkwood/Makefile
===================================================================
@@ -5,5 +5,7 @@
 obj-$(CONFIG_SND_KIRKWOOD_SOC_I2S) += snd-soc-kirkwood-i2s.o
 
 snd-soc-openrd-objs := kirkwood-openrd.o
+snd-soc-t5325-objs := kirkwood-t5325.o
 
 obj-$(CONFIG_SND_KIRKWOOD_SOC_OPENRD) += snd-soc-openrd.o
+obj-$(CONFIG_SND_KIRKWOOD_SOC_T5325) += snd-soc-t5325.o
sound/soc/kirkwood/kirkwood-t5325.c new file +155 -0

155 lines not on this page · raw message

#6 lore raw

Re: [patch 2/3] kirkwood: Add audio support to hp t5325 thin clients

Quoted 4 lines · Arnaud Patard

This patch is adding support for hp t5325 thin clients. There's a alc5623 codec connected to the i2s interface.

This looks OK, though if you could move the module_init()/module_exit() next to the functions that'd be better.

#7 lore raw

PATCH 3/3 t5325: add audio support

In reply to Arnaud Patard (Rtp)

This patch declares the i2c audio codec and initialise audio.

arch/arm/mach-kirkwood/t5325-setup.c +17 -0
Index: sound-2.6/arch/arm/mach-kirkwood/t5325-setup.c
===================================================================
@@ -23,6 +23,7 @@
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/alc5623.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
@@ -134,6 +135,7 @@
 	MPP33_GE1_TXCTL,
 	MPP39_AU_I2SBCLK,
 	MPP40_AU_I2SDO,
+	MPP43_AU_I2SDI,
 	MPP41_AU_I2SLRCLK,
 	MPP42_AU_I2SMCLK,
 	MPP45_GPIO,		/* Power button */
@@ -141,6 +143,18 @@
 	0
 };
 
+static struct alc5623_platform_data alc5621_data = {
+	.add_ctrl = 0x3700,
+	.jack_det_ctrl = 0x4810,
+};
+
+static struct i2c_board_info i2c_board_info[] __initdata = {
+	{
+		I2C_BOARD_INFO("alc5621", 0x1a),
+		.platform_data = &alc5621_data,
+	},
+};
+
 #define HP_T5325_GPIO_POWER_OFF		48
 
 static void hp_t5325_power_off(void)
@@ -166,6 +180,9 @@
 	kirkwood_ehci_init();
 	platform_device_register(&hp_t5325_button_device);
 
+	i2c_register_board_info(0, i2c_board_info, ARRAY_SIZE(i2c_board_info));
+	kirkwood_audio_init();
+
 	if (gpio_request(HP_T5325_GPIO_POWER_OFF, "power-off") == 0 &&
 	    gpio_direction_output(HP_T5325_GPIO_POWER_OFF, 0) == 0)
 		pm_power_off = hp_t5325_power_off;
#8 lore raw

Re: [patch 3/3] t5325: add audio support

Quoted 3 lines · Arnaud Patard

This patch declares the i2c audio codec and initialise audio.

This is going to depend on the ASoC CODEC driver for the device so will need to be merged along with that - if it's OK to do that can the Kirkwood guys please ack it?