aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8960.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/codecs/wm8960.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/codecs/wm8960.c')
-rw-r--r--sound/soc/codecs/wm8960.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 8d5efb333c33..0ea578815003 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -388,27 +388,28 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
388{ 388{
389 struct wm8960_data *pdata = codec->dev->platform_data; 389 struct wm8960_data *pdata = codec->dev->platform_data;
390 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 390 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
391 struct snd_soc_dapm_context *dapm = &codec->dapm;
391 struct snd_soc_dapm_widget *w; 392 struct snd_soc_dapm_widget *w;
392 393
393 snd_soc_dapm_new_controls(codec, wm8960_dapm_widgets, 394 snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets,
394 ARRAY_SIZE(wm8960_dapm_widgets)); 395 ARRAY_SIZE(wm8960_dapm_widgets));
395 396
396 snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); 397 snd_soc_dapm_add_routes(dapm, audio_paths, ARRAY_SIZE(audio_paths));
397 398
398 /* In capless mode OUT3 is used to provide VMID for the 399 /* In capless mode OUT3 is used to provide VMID for the
399 * headphone outputs, otherwise it is used as a mono mixer. 400 * headphone outputs, otherwise it is used as a mono mixer.
400 */ 401 */
401 if (pdata && pdata->capless) { 402 if (pdata && pdata->capless) {
402 snd_soc_dapm_new_controls(codec, wm8960_dapm_widgets_capless, 403 snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets_capless,
403 ARRAY_SIZE(wm8960_dapm_widgets_capless)); 404 ARRAY_SIZE(wm8960_dapm_widgets_capless));
404 405
405 snd_soc_dapm_add_routes(codec, audio_paths_capless, 406 snd_soc_dapm_add_routes(dapm, audio_paths_capless,
406 ARRAY_SIZE(audio_paths_capless)); 407 ARRAY_SIZE(audio_paths_capless));
407 } else { 408 } else {
408 snd_soc_dapm_new_controls(codec, wm8960_dapm_widgets_out3, 409 snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets_out3,
409 ARRAY_SIZE(wm8960_dapm_widgets_out3)); 410 ARRAY_SIZE(wm8960_dapm_widgets_out3));
410 411
411 snd_soc_dapm_add_routes(codec, audio_paths_out3, 412 snd_soc_dapm_add_routes(dapm, audio_paths_out3,
412 ARRAY_SIZE(audio_paths_out3)); 413 ARRAY_SIZE(audio_paths_out3));
413 } 414 }
414 415
@@ -417,7 +418,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
417 * list each time to find the desired power state do so now 418 * list each time to find the desired power state do so now
418 * and save the result. 419 * and save the result.
419 */ 420 */
420 list_for_each_entry(w, &codec->dapm_widgets, list) { 421 list_for_each_entry(w, &codec->dapm.widgets, list) {
421 if (strcmp(w->name, "LOUT1 PGA") == 0) 422 if (strcmp(w->name, "LOUT1 PGA") == 0)
422 wm8960->lout1 = w; 423 wm8960->lout1 = w;
423 if (strcmp(w->name, "ROUT1 PGA") == 0) 424 if (strcmp(w->name, "ROUT1 PGA") == 0)
@@ -572,7 +573,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
572 break; 573 break;
573 574
574 case SND_SOC_BIAS_STANDBY: 575 case SND_SOC_BIAS_STANDBY:
575 if (codec->bias_level == SND_SOC_BIAS_OFF) { 576 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
576 /* Enable anti-pop features */ 577 /* Enable anti-pop features */
577 snd_soc_write(codec, WM8960_APOP1, 578 snd_soc_write(codec, WM8960_APOP1,
578 WM8960_POBCTRL | WM8960_SOFT_ST | 579 WM8960_POBCTRL | WM8960_SOFT_ST |
@@ -610,7 +611,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
610 break; 611 break;
611 } 612 }
612 613
613 codec->bias_level = level; 614 codec->dapm.bias_level = level;
614 615
615 return 0; 616 return 0;
616} 617}
@@ -626,7 +627,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
626 break; 627 break;
627 628
628 case SND_SOC_BIAS_PREPARE: 629 case SND_SOC_BIAS_PREPARE:
629 switch (codec->bias_level) { 630 switch (codec->dapm.bias_level) {
630 case SND_SOC_BIAS_STANDBY: 631 case SND_SOC_BIAS_STANDBY:
631 /* Enable anti pop mode */ 632 /* Enable anti pop mode */
632 snd_soc_update_bits(codec, WM8960_APOP1, 633 snd_soc_update_bits(codec, WM8960_APOP1,
@@ -681,7 +682,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
681 break; 682 break;
682 683
683 case SND_SOC_BIAS_STANDBY: 684 case SND_SOC_BIAS_STANDBY:
684 switch (codec->bias_level) { 685 switch (codec->dapm.bias_level) {
685 case SND_SOC_BIAS_PREPARE: 686 case SND_SOC_BIAS_PREPARE:
686 /* Disable HP discharge */ 687 /* Disable HP discharge */
687 snd_soc_update_bits(codec, WM8960_APOP2, 688 snd_soc_update_bits(codec, WM8960_APOP2,
@@ -705,7 +706,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
705 break; 706 break;
706 } 707 }
707 708
708 codec->bias_level = level; 709 codec->dapm.bias_level = level;
709 710
710 return 0; 711 return 0;
711} 712}