aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8962.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/wm8962.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/wm8962.c')
-rw-r--r--sound/soc/codecs/wm8962.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 3fc63b43c6a1..80986105f52e 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2682,6 +2682,7 @@ static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = {
2682static int wm8962_add_widgets(struct snd_soc_codec *codec) 2682static int wm8962_add_widgets(struct snd_soc_codec *codec)
2683{ 2683{
2684 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); 2684 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
2685 struct snd_soc_dapm_context *dapm = &codec->dapm;
2685 2686
2686 snd_soc_add_controls(codec, wm8962_snd_controls, 2687 snd_soc_add_controls(codec, wm8962_snd_controls,
2687 ARRAY_SIZE(wm8962_snd_controls)); 2688 ARRAY_SIZE(wm8962_snd_controls));
@@ -2693,26 +2694,26 @@ static int wm8962_add_widgets(struct snd_soc_codec *codec)
2693 ARRAY_SIZE(wm8962_spk_stereo_controls)); 2694 ARRAY_SIZE(wm8962_spk_stereo_controls));
2694 2695
2695 2696
2696 snd_soc_dapm_new_controls(codec, wm8962_dapm_widgets, 2697 snd_soc_dapm_new_controls(dapm, wm8962_dapm_widgets,
2697 ARRAY_SIZE(wm8962_dapm_widgets)); 2698 ARRAY_SIZE(wm8962_dapm_widgets));
2698 if (pdata && pdata->spk_mono) 2699 if (pdata && pdata->spk_mono)
2699 snd_soc_dapm_new_controls(codec, wm8962_dapm_spk_mono_widgets, 2700 snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_mono_widgets,
2700 ARRAY_SIZE(wm8962_dapm_spk_mono_widgets)); 2701 ARRAY_SIZE(wm8962_dapm_spk_mono_widgets));
2701 else 2702 else
2702 snd_soc_dapm_new_controls(codec, wm8962_dapm_spk_stereo_widgets, 2703 snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_stereo_widgets,
2703 ARRAY_SIZE(wm8962_dapm_spk_stereo_widgets)); 2704 ARRAY_SIZE(wm8962_dapm_spk_stereo_widgets));
2704 2705
2705 snd_soc_dapm_add_routes(codec, wm8962_intercon, 2706 snd_soc_dapm_add_routes(dapm, wm8962_intercon,
2706 ARRAY_SIZE(wm8962_intercon)); 2707 ARRAY_SIZE(wm8962_intercon));
2707 if (pdata && pdata->spk_mono) 2708 if (pdata && pdata->spk_mono)
2708 snd_soc_dapm_add_routes(codec, wm8962_spk_mono_intercon, 2709 snd_soc_dapm_add_routes(dapm, wm8962_spk_mono_intercon,
2709 ARRAY_SIZE(wm8962_spk_mono_intercon)); 2710 ARRAY_SIZE(wm8962_spk_mono_intercon));
2710 else 2711 else
2711 snd_soc_dapm_add_routes(codec, wm8962_spk_stereo_intercon, 2712 snd_soc_dapm_add_routes(dapm, wm8962_spk_stereo_intercon,
2712 ARRAY_SIZE(wm8962_spk_stereo_intercon)); 2713 ARRAY_SIZE(wm8962_spk_stereo_intercon));
2713 2714
2714 2715
2715 snd_soc_dapm_disable_pin(codec, "Beep"); 2716 snd_soc_dapm_disable_pin(dapm, "Beep");
2716 2717
2717 return 0; 2718 return 0;
2718} 2719}
@@ -2819,7 +2820,7 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
2819 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2820 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
2820 int ret; 2821 int ret;
2821 2822
2822 if (level == codec->bias_level) 2823 if (level == codec->dapm.bias_level)
2823 return 0; 2824 return 0;
2824 2825
2825 switch (level) { 2826 switch (level) {
@@ -2833,7 +2834,7 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
2833 break; 2834 break;
2834 2835
2835 case SND_SOC_BIAS_STANDBY: 2836 case SND_SOC_BIAS_STANDBY:
2836 if (codec->bias_level == SND_SOC_BIAS_OFF) { 2837 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
2837 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), 2838 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
2838 wm8962->supplies); 2839 wm8962->supplies);
2839 if (ret != 0) { 2840 if (ret != 0) {
@@ -2883,7 +2884,7 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
2883 wm8962->supplies); 2884 wm8962->supplies);
2884 break; 2885 break;
2885 } 2886 }
2886 codec->bias_level = level; 2887 codec->dapm.bias_level = level;
2887 return 0; 2888 return 0;
2888} 2889}
2889 2890
@@ -3441,6 +3442,7 @@ static void wm8962_beep_work(struct work_struct *work)
3441 struct wm8962_priv *wm8962 = 3442 struct wm8962_priv *wm8962 =
3442 container_of(work, struct wm8962_priv, beep_work); 3443 container_of(work, struct wm8962_priv, beep_work);
3443 struct snd_soc_codec *codec = wm8962->codec; 3444 struct snd_soc_codec *codec = wm8962->codec;
3445 struct snd_soc_dapm_context *dapm = &codec->dapm;
3444 int i; 3446 int i;
3445 int reg = 0; 3447 int reg = 0;
3446 int best = 0; 3448 int best = 0;
@@ -3457,16 +3459,16 @@ static void wm8962_beep_work(struct work_struct *work)
3457 3459
3458 reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT); 3460 reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT);
3459 3461
3460 snd_soc_dapm_enable_pin(codec, "Beep"); 3462 snd_soc_dapm_enable_pin(dapm, "Beep");
3461 } else { 3463 } else {
3462 dev_dbg(codec->dev, "Disabling beep\n"); 3464 dev_dbg(codec->dev, "Disabling beep\n");
3463 snd_soc_dapm_disable_pin(codec, "Beep"); 3465 snd_soc_dapm_disable_pin(dapm, "Beep");
3464 } 3466 }
3465 3467
3466 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, 3468 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1,
3467 WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg); 3469 WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg);
3468 3470
3469 snd_soc_dapm_sync(codec); 3471 snd_soc_dapm_sync(dapm);
3470} 3472}
3471 3473
3472/* For usability define a way of injecting beep events for the device - 3474/* For usability define a way of injecting beep events for the device -
@@ -3713,7 +3715,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3713 INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work); 3715 INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work);
3714 3716
3715 codec->cache_sync = 1; 3717 codec->cache_sync = 1;
3716 codec->idle_bias_off = 1; 3718 codec->dapm.idle_bias_off = 1;
3717 3719
3718 ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_I2C); 3720 ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_I2C);
3719 if (ret != 0) { 3721 if (ret != 0) {