aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa/tosa.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-11-05 09:53:46 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-06 11:28:29 -0400
commitce6120cca2589ede530200c7cfe11ac9f144333c (patch)
tree6ea7c26ce64dd4753e7cf9a3b048e74614b169dc /sound/soc/pxa/tosa.c
parent22e2fda5660cdf62513acabdb5c82a5af415f838 (diff)
ASoC: Decouple DAPM from CODECs
Decoupling Dynamic Audio Power Management (DAPM) from codec devices is required when developing ASoC further. Such as for other ASoC components to have DAPM widgets or when extending DAPM to handle cross-device paths. This patch decouples DAPM related variables from struct snd_soc_codec and moves them to new struct snd_soc_dapm_context that is used to encapsulate DAPM context of a device. ASoC core and API of DAPM functions are modified to use DAPM context instead of codec. This patch does not change current functionality and a large part of changes come because of structure and internal API changes. Core implementation is from Liam Girdwood <lrg@slimlogic.co.uk> with some minor core changes, codecs and machine driver conversions from Jarkko Nikula <jhnikula@gmail.com>. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Manuel Lauss <manuel.lauss@googlemail.com> Cc: Mike Frysinger <vapier.adi@gmail.com> Cc: Cliff Cai <cliff.cai@analog.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> Cc: Ryan Mallon <ryan@bluewatersys.com> Cc: Timur Tabi <timur@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> Cc: Wan ZongShun <mcuos.com@gmail.com> Cc: Eric Miao <eric.y.miao@gmail.com> Cc: Jassi Brar <jassi.brar@samsung.com> Cc: Daniel Gloeckner <dg@emlix.com> Cc: Kuninori Morimoto <morimoto.kuninori@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/pxa/tosa.c')
-rw-r--r--sound/soc/pxa/tosa.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index 73d0edd8ded9..0a9bd68ef749 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -49,31 +49,33 @@ static int tosa_spk_func;
49 49
50static void tosa_ext_control(struct snd_soc_codec *codec) 50static void tosa_ext_control(struct snd_soc_codec *codec)
51{ 51{
52 struct snd_soc_dapm_context *dapm = &codec->dapm;
53
52 /* set up jack connection */ 54 /* set up jack connection */
53 switch (tosa_jack_func) { 55 switch (tosa_jack_func) {
54 case TOSA_HP: 56 case TOSA_HP:
55 snd_soc_dapm_disable_pin(codec, "Mic (Internal)"); 57 snd_soc_dapm_disable_pin(dapm, "Mic (Internal)");
56 snd_soc_dapm_enable_pin(codec, "Headphone Jack"); 58 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
57 snd_soc_dapm_disable_pin(codec, "Headset Jack"); 59 snd_soc_dapm_disable_pin(dapm, "Headset Jack");
58 break; 60 break;
59 case TOSA_MIC_INT: 61 case TOSA_MIC_INT:
60 snd_soc_dapm_enable_pin(codec, "Mic (Internal)"); 62 snd_soc_dapm_enable_pin(dapm, "Mic (Internal)");
61 snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 63 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
62 snd_soc_dapm_disable_pin(codec, "Headset Jack"); 64 snd_soc_dapm_disable_pin(dapm, "Headset Jack");
63 break; 65 break;
64 case TOSA_HEADSET: 66 case TOSA_HEADSET:
65 snd_soc_dapm_disable_pin(codec, "Mic (Internal)"); 67 snd_soc_dapm_disable_pin(dapm, "Mic (Internal)");
66 snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 68 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
67 snd_soc_dapm_enable_pin(codec, "Headset Jack"); 69 snd_soc_dapm_enable_pin(dapm, "Headset Jack");
68 break; 70 break;
69 } 71 }
70 72
71 if (tosa_spk_func == TOSA_SPK_ON) 73 if (tosa_spk_func == TOSA_SPK_ON)
72 snd_soc_dapm_enable_pin(codec, "Speaker"); 74 snd_soc_dapm_enable_pin(dapm, "Speaker");
73 else 75 else
74 snd_soc_dapm_disable_pin(codec, "Speaker"); 76 snd_soc_dapm_disable_pin(dapm, "Speaker");
75 77
76 snd_soc_dapm_sync(codec); 78 snd_soc_dapm_sync(dapm);
77} 79}
78 80
79static int tosa_startup(struct snd_pcm_substream *substream) 81static int tosa_startup(struct snd_pcm_substream *substream)
@@ -186,10 +188,11 @@ static const struct snd_kcontrol_new tosa_controls[] = {
186static int tosa_ac97_init(struct snd_soc_pcm_runtime *rtd) 188static int tosa_ac97_init(struct snd_soc_pcm_runtime *rtd)
187{ 189{
188 struct snd_soc_codec *codec = rtd->codec; 190 struct snd_soc_codec *codec = rtd->codec;
191 struct snd_soc_dapm_context *dapm = &codec->dapm;
189 int err; 192 int err;
190 193
191 snd_soc_dapm_nc_pin(codec, "OUT3"); 194 snd_soc_dapm_nc_pin(dapm, "OUT3");
192 snd_soc_dapm_nc_pin(codec, "MONOOUT"); 195 snd_soc_dapm_nc_pin(dapm, "MONOOUT");
193 196
194 /* add tosa specific controls */ 197 /* add tosa specific controls */
195 err = snd_soc_add_controls(codec, tosa_controls, 198 err = snd_soc_add_controls(codec, tosa_controls,
@@ -198,13 +201,13 @@ static int tosa_ac97_init(struct snd_soc_pcm_runtime *rtd)
198 return err; 201 return err;
199 202
200 /* add tosa specific widgets */ 203 /* add tosa specific widgets */
201 snd_soc_dapm_new_controls(codec, tosa_dapm_widgets, 204 snd_soc_dapm_new_controls(dapm, tosa_dapm_widgets,
202 ARRAY_SIZE(tosa_dapm_widgets)); 205 ARRAY_SIZE(tosa_dapm_widgets));
203 206
204 /* set up tosa specific audio path audio_map */ 207 /* set up tosa specific audio path audio_map */
205 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 208 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
206 209
207 snd_soc_dapm_sync(codec); 210 snd_soc_dapm_sync(dapm);
208 return 0; 211 return 0;
209} 212}
210 213