Commit 39646871 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Liam Girdwood

ASoC: tpa6130a2: Replace DAPM code with direct interface

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: default avatarPeter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 1bb5ec6a
...@@ -317,65 +317,24 @@ static void tpa6130a2_channel_enable(u8 channel, int enable) ...@@ -317,65 +317,24 @@ static void tpa6130a2_channel_enable(u8 channel, int enable)
} }
} }
static int tpa6130a2_pga_event(struct snd_soc_dapm_widget *w, int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable)
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 ret = 0; int ret = 0;
if (enable) {
switch (event) {
case SND_SOC_DAPM_POST_PMU:
ret = tpa6130a2_power(1); ret = tpa6130a2_power(1);
break; if (ret < 0)
case SND_SOC_DAPM_POST_PMD: 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); ret = tpa6130a2_power(0);
break;
} }
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(tpa6130a2_stereo_enable);
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"},
};
int tpa6130a2_add_controls(struct snd_soc_codec *codec) int tpa6130a2_add_controls(struct snd_soc_codec *codec)
{ {
...@@ -387,18 +346,12 @@ 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); 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) if (data->id == TPA6140A2)
return snd_soc_add_controls(codec, tpa6140a2_controls, return snd_soc_add_controls(codec, tpa6140a2_controls,
ARRAY_SIZE(tpa6140a2_controls)); ARRAY_SIZE(tpa6140a2_controls));
else else
return snd_soc_add_controls(codec, tpa6130a2_controls, return snd_soc_add_controls(codec, tpa6130a2_controls,
ARRAY_SIZE(tpa6130a2_controls)); ARRAY_SIZE(tpa6130a2_controls));
} }
EXPORT_SYMBOL_GPL(tpa6130a2_add_controls); EXPORT_SYMBOL_GPL(tpa6130a2_add_controls);
......
...@@ -57,5 +57,6 @@ ...@@ -57,5 +57,6 @@
#define TPA6130A2_VERSION_MASK (0x0f) #define TPA6130A2_VERSION_MASK (0x0f)
extern int tpa6130a2_add_controls(struct snd_soc_codec *codec); 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__ */ #endif /* __TPA6130A2_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment