diff options
author | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-11-05 09:53:46 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-11-06 11:28:29 -0400 |
commit | ce6120cca2589ede530200c7cfe11ac9f144333c (patch) | |
tree | 6ea7c26ce64dd4753e7cf9a3b048e74614b169dc /sound/soc/codecs/wm8753.c | |
parent | 22e2fda5660cdf62513acabdb5c82a5af415f838 (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/wm8753.c')
-rw-r--r-- | sound/soc/codecs/wm8753.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 8f679a13f2bc..26096b47a493 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -670,10 +670,11 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
670 | 670 | ||
671 | static int wm8753_add_widgets(struct snd_soc_codec *codec) | 671 | static int wm8753_add_widgets(struct snd_soc_codec *codec) |
672 | { | 672 | { |
673 | snd_soc_dapm_new_controls(codec, wm8753_dapm_widgets, | 673 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
674 | ARRAY_SIZE(wm8753_dapm_widgets)); | ||
675 | 674 | ||
676 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | 675 | snd_soc_dapm_new_controls(dapm, wm8753_dapm_widgets, |
676 | ARRAY_SIZE(wm8753_dapm_widgets)); | ||
677 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
677 | 678 | ||
678 | return 0; | 679 | return 0; |
679 | } | 680 | } |
@@ -1292,7 +1293,7 @@ static int wm8753_set_bias_level(struct snd_soc_codec *codec, | |||
1292 | wm8753_write(codec, WM8753_PWR1, 0x0001); | 1293 | wm8753_write(codec, WM8753_PWR1, 0x0001); |
1293 | break; | 1294 | break; |
1294 | } | 1295 | } |
1295 | codec->bias_level = level; | 1296 | codec->dapm.bias_level = level; |
1296 | return 0; | 1297 | return 0; |
1297 | } | 1298 | } |
1298 | 1299 | ||
@@ -1482,9 +1483,11 @@ static void wm8753_set_dai_mode(struct snd_soc_codec *codec, | |||
1482 | 1483 | ||
1483 | static void wm8753_work(struct work_struct *work) | 1484 | static void wm8753_work(struct work_struct *work) |
1484 | { | 1485 | { |
1485 | struct snd_soc_codec *codec = | 1486 | struct snd_soc_dapm_context *dapm = |
1486 | container_of(work, struct snd_soc_codec, delayed_work.work); | 1487 | container_of(work, struct snd_soc_dapm_context, |
1487 | wm8753_set_bias_level(codec, codec->bias_level); | 1488 | delayed_work.work); |
1489 | struct snd_soc_codec *codec = dapm->codec; | ||
1490 | wm8753_set_bias_level(codec, dapm->bias_level); | ||
1488 | } | 1491 | } |
1489 | 1492 | ||
1490 | static int wm8753_suspend(struct snd_soc_codec *codec, pm_message_t state) | 1493 | static int wm8753_suspend(struct snd_soc_codec *codec, pm_message_t state) |
@@ -1516,10 +1519,10 @@ static int wm8753_resume(struct snd_soc_codec *codec) | |||
1516 | wm8753_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1519 | wm8753_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1517 | 1520 | ||
1518 | /* charge wm8753 caps */ | 1521 | /* charge wm8753 caps */ |
1519 | if (codec->suspend_bias_level == SND_SOC_BIAS_ON) { | 1522 | if (codec->dapm.suspend_bias_level == SND_SOC_BIAS_ON) { |
1520 | wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); | 1523 | wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); |
1521 | codec->bias_level = SND_SOC_BIAS_ON; | 1524 | codec->dapm.bias_level = SND_SOC_BIAS_ON; |
1522 | schedule_delayed_work(&codec->delayed_work, | 1525 | schedule_delayed_work(&codec->dapm.delayed_work, |
1523 | msecs_to_jiffies(caps_charge)); | 1526 | msecs_to_jiffies(caps_charge)); |
1524 | } | 1527 | } |
1525 | 1528 | ||
@@ -1550,7 +1553,7 @@ static int wm8753_probe(struct snd_soc_codec *codec) | |||
1550 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); | 1553 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); |
1551 | int ret = 0, reg; | 1554 | int ret = 0, reg; |
1552 | 1555 | ||
1553 | INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work); | 1556 | INIT_DELAYED_WORK(&codec->dapm.delayed_work, wm8753_work); |
1554 | 1557 | ||
1555 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8753->control_type); | 1558 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8753->control_type); |
1556 | if (ret < 0) { | 1559 | if (ret < 0) { |
@@ -1569,7 +1572,7 @@ static int wm8753_probe(struct snd_soc_codec *codec) | |||
1569 | 1572 | ||
1570 | /* charge output caps */ | 1573 | /* charge output caps */ |
1571 | wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); | 1574 | wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); |
1572 | schedule_delayed_work(&codec->delayed_work, | 1575 | schedule_delayed_work(&codec->dapm.delayed_work, |
1573 | msecs_to_jiffies(caps_charge)); | 1576 | msecs_to_jiffies(caps_charge)); |
1574 | 1577 | ||
1575 | /* set the update bits */ | 1578 | /* set the update bits */ |
@@ -1604,7 +1607,7 @@ static int wm8753_probe(struct snd_soc_codec *codec) | |||
1604 | /* power down chip */ | 1607 | /* power down chip */ |
1605 | static int wm8753_remove(struct snd_soc_codec *codec) | 1608 | static int wm8753_remove(struct snd_soc_codec *codec) |
1606 | { | 1609 | { |
1607 | run_delayed_work(&codec->delayed_work); | 1610 | run_delayed_work(&codec->dapm.delayed_work); |
1608 | wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1611 | wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1609 | 1612 | ||
1610 | return 0; | 1613 | return 0; |