All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface
@ 2010-12-02  7:29 Peter Ujfalusi
  2010-12-02  9:56 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Ujfalusi @ 2010-12-02  7:29 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

The use of DAPM widgets, and extra routing can cause ordering
problems in the system.
Machine drivers should use the exported direct interface with
SND_SOC_DAPM_HP's event callback to manage the state of the
amplifier.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
---

Hello,

Changes since v1:
- DAPM routing removed from the driver
- tpa6130a2_stereo_enable takes snd_soc_codec as argument

Peter

 sound/soc/codecs/tpa6130a2.c |   69 +++++++-----------------------------------
 sound/soc/codecs/tpa6130a2.h |    1 +
 2 files changed, 12 insertions(+), 58 deletions(-)

diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index c97badf..0a99f31 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -317,65 +317,24 @@ static void tpa6130a2_channel_enable(u8 channel, int enable)
 	}
 }
 
-static int tpa6130a2_pga_event(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
-{
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
-		tpa6130a2_channel_enable(w->shift, 1);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
-		tpa6130a2_channel_enable(w->shift, 0);
-		break;
-	}
-	return 0;
-}
-
-static int tpa6130a2_supply_event(struct snd_soc_dapm_widget *w,
-		struct snd_kcontrol *kcontrol, int event)
+int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable)
 {
 	int ret = 0;
-
-	switch (event) {
-	case SND_SOC_DAPM_POST_PMU:
+	if (enable) {
 		ret = tpa6130a2_power(1);
-		break;
-	case SND_SOC_DAPM_POST_PMD:
+		if (ret < 0)
+			return ret;
+		tpa6130a2_channel_enable(TPA6130A2_HP_EN_R | TPA6130A2_HP_EN_L,
+					 1);
+	} else {
+		tpa6130a2_channel_enable(TPA6130A2_HP_EN_R | TPA6130A2_HP_EN_L,
+					 0);
 		ret = tpa6130a2_power(0);
-		break;
 	}
+
 	return ret;
 }
-
-static const struct snd_soc_dapm_widget tpa6130a2_dapm_widgets[] = {
-	SND_SOC_DAPM_PGA_E("TPA6130A2 Left", SND_SOC_NOPM,
-			TPA6130A2_HP_EN_L, 0, NULL, 0, tpa6130a2_pga_event,
-			SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("TPA6130A2 Right", SND_SOC_NOPM,
-			TPA6130A2_HP_EN_R, 0, NULL, 0, tpa6130a2_pga_event,
-			SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_PGA_E("TPA6130A2 Stereo", SND_SOC_NOPM,
-			TPA6130A2_HP_EN_L | TPA6130A2_HP_EN_R, 0, NULL, 0,
-			tpa6130a2_pga_event,
-			SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
-	SND_SOC_DAPM_SUPPLY("TPA6130A2 Enable", SND_SOC_NOPM,
-			0, 0, tpa6130a2_supply_event,
-			SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
-	/* Outputs */
-	SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Left"),
-	SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Right"),
-	SND_SOC_DAPM_OUTPUT("TPA6130A2 Headphone Stereo"),
-};
-
-static const struct snd_soc_dapm_route audio_map[] = {
-	{"TPA6130A2 Headphone Left", NULL, "TPA6130A2 Left"},
-	{"TPA6130A2 Headphone Right", NULL, "TPA6130A2 Right"},
-	{"TPA6130A2 Headphone Stereo", NULL, "TPA6130A2 Stereo"},
-
-	{"TPA6130A2 Headphone Left", NULL, "TPA6130A2 Enable"},
-	{"TPA6130A2 Headphone Right", NULL, "TPA6130A2 Enable"},
-	{"TPA6130A2 Headphone Stereo", NULL, "TPA6130A2 Enable"},
-};
+EXPORT_SYMBOL_GPL(tpa6130a2_stereo_enable);
 
 int tpa6130a2_add_controls(struct snd_soc_codec *codec)
 {
@@ -387,18 +346,12 @@ int tpa6130a2_add_controls(struct snd_soc_codec *codec)
 
 	data = i2c_get_clientdata(tpa6130a2_client);
 
-	snd_soc_dapm_new_controls(dapm, tpa6130a2_dapm_widgets,
-				ARRAY_SIZE(tpa6130a2_dapm_widgets));
-
-	snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
-
 	if (data->id == TPA6140A2)
 		return snd_soc_add_controls(codec, tpa6140a2_controls,
 						ARRAY_SIZE(tpa6140a2_controls));
 	else
 		return snd_soc_add_controls(codec, tpa6130a2_controls,
 						ARRAY_SIZE(tpa6130a2_controls));
-
 }
 EXPORT_SYMBOL_GPL(tpa6130a2_add_controls);
 
diff --git a/sound/soc/codecs/tpa6130a2.h b/sound/soc/codecs/tpa6130a2.h
index 57e867f..5df49c8 100644
--- a/sound/soc/codecs/tpa6130a2.h
+++ b/sound/soc/codecs/tpa6130a2.h
@@ -57,5 +57,6 @@
 #define TPA6130A2_VERSION_MASK		(0x0f)
 
 extern int tpa6130a2_add_controls(struct snd_soc_codec *codec);
+extern int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable);
 
 #endif /* __TPA6130A2_H__ */
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface
  2010-12-02  7:29 [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface Peter Ujfalusi
@ 2010-12-02  9:56 ` Mark Brown
  2010-12-02 10:16   ` Peter Ujfalusi
  2010-12-02 11:50   ` Liam Girdwood
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2010-12-02  9:56 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood

On Thu, Dec 02, 2010 at 09:29:56AM +0200, Peter Ujfalusi wrote:
> The use of DAPM widgets, and extra routing can cause ordering
> problems in the system.
> Machine drivers should use the exported direct interface with
> SND_SOC_DAPM_HP's event callback to manage the state of the
> amplifier.

> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>

I thought we'd decided that adding a HP widget in the driver was the
most straightforward thing here?  Still...

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface
  2010-12-02  9:56 ` Mark Brown
@ 2010-12-02 10:16   ` Peter Ujfalusi
  2010-12-02 11:50   ` Liam Girdwood
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2010-12-02 10:16 UTC (permalink / raw)
  To: alsa-devel; +Cc: ext Mark Brown, Liam Girdwood

On Thursday 02 December 2010 11:56:26 ext Mark Brown wrote:
> I thought we'd decided that adding a HP widget in the driver was the
> most straightforward thing here?  Still...

At least with my device I need to add some delay before enabling the amp, so 
anyway I need to ahve the DAPM_HP in the machine driver.
We do not have users for this amp, and the n900 support is still partial (that 
uses the tpa on the headset path, which is not yet there).
How ever I can add back a support to register the DAPM_HP in the amp driver 
which can be used by machine drivers without special needs (in a separate 
patch).
 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Thanks,
Péter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface
  2010-12-02  9:56 ` Mark Brown
  2010-12-02 10:16   ` Peter Ujfalusi
@ 2010-12-02 11:50   ` Liam Girdwood
  1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-12-02 11:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Peter Ujfalusi

On Thu, 2010-12-02 at 09:56 +0000, Mark Brown wrote:
> On Thu, Dec 02, 2010 at 09:29:56AM +0200, Peter Ujfalusi wrote:
> > The use of DAPM widgets, and extra routing can cause ordering
> > problems in the system.
> > Machine drivers should use the exported direct interface with
> > SND_SOC_DAPM_HP's event callback to manage the state of the
> > amplifier.
> 
> > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
> 
> I thought we'd decided that adding a HP widget in the driver was the
> most straightforward thing here?  Still...
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Applied.

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-02 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02  7:29 [PATCH v2] ASoC: tpa6130a2: Replace DAPM code with direct interface Peter Ujfalusi
2010-12-02  9:56 ` Mark Brown
2010-12-02 10:16   ` Peter Ujfalusi
2010-12-02 11:50   ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.