aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8350.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/wm8350.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/wm8350.c')
-rw-r--r--sound/soc/codecs/wm8350.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index f4f1fba38eb9..4c6c81e11544 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -230,8 +230,9 @@ static inline int wm8350_out2_ramp_step(struct snd_soc_codec *codec)
230 */ 230 */
231static void wm8350_pga_work(struct work_struct *work) 231static void wm8350_pga_work(struct work_struct *work)
232{ 232{
233 struct snd_soc_codec *codec = 233 struct snd_soc_dapm_context *dapm =
234 container_of(work, struct snd_soc_codec, delayed_work.work); 234 container_of(work, struct snd_soc_dapm_context, delayed_work.work);
235 struct snd_soc_codec *codec = dapm->codec;
235 struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); 236 struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
236 struct wm8350_output *out1 = &wm8350_data->out1, 237 struct wm8350_output *out1 = &wm8350_data->out1,
237 *out2 = &wm8350_data->out2; 238 *out2 = &wm8350_data->out2;
@@ -302,8 +303,8 @@ static int pga_event(struct snd_soc_dapm_widget *w,
302 out->ramp = WM8350_RAMP_UP; 303 out->ramp = WM8350_RAMP_UP;
303 out->active = 1; 304 out->active = 1;
304 305
305 if (!delayed_work_pending(&codec->delayed_work)) 306 if (!delayed_work_pending(&codec->dapm.delayed_work))
306 schedule_delayed_work(&codec->delayed_work, 307 schedule_delayed_work(&codec->dapm.delayed_work,
307 msecs_to_jiffies(1)); 308 msecs_to_jiffies(1));
308 break; 309 break;
309 310
@@ -311,8 +312,8 @@ static int pga_event(struct snd_soc_dapm_widget *w,
311 out->ramp = WM8350_RAMP_DOWN; 312 out->ramp = WM8350_RAMP_DOWN;
312 out->active = 0; 313 out->active = 0;
313 314
314 if (!delayed_work_pending(&codec->delayed_work)) 315 if (!delayed_work_pending(&codec->dapm.delayed_work))
315 schedule_delayed_work(&codec->delayed_work, 316 schedule_delayed_work(&codec->dapm.delayed_work,
316 msecs_to_jiffies(1)); 317 msecs_to_jiffies(1));
317 break; 318 break;
318 } 319 }
@@ -786,9 +787,10 @@ static const struct snd_soc_dapm_route audio_map[] = {
786 787
787static int wm8350_add_widgets(struct snd_soc_codec *codec) 788static int wm8350_add_widgets(struct snd_soc_codec *codec)
788{ 789{
790 struct snd_soc_dapm_context *dapm = &codec->dapm;
789 int ret; 791 int ret;
790 792
791 ret = snd_soc_dapm_new_controls(codec, 793 ret = snd_soc_dapm_new_controls(dapm,
792 wm8350_dapm_widgets, 794 wm8350_dapm_widgets,
793 ARRAY_SIZE(wm8350_dapm_widgets)); 795 ARRAY_SIZE(wm8350_dapm_widgets));
794 if (ret != 0) { 796 if (ret != 0) {
@@ -797,7 +799,7 @@ static int wm8350_add_widgets(struct snd_soc_codec *codec)
797 } 799 }
798 800
799 /* set up audio paths */ 801 /* set up audio paths */
800 ret = snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 802 ret = snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
801 if (ret != 0) { 803 if (ret != 0) {
802 dev_err(codec->dev, "DAPM route register failed\n"); 804 dev_err(codec->dev, "DAPM route register failed\n");
803 return ret; 805 return ret;
@@ -1184,7 +1186,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec,
1184 break; 1186 break;
1185 1187
1186 case SND_SOC_BIAS_STANDBY: 1188 case SND_SOC_BIAS_STANDBY:
1187 if (codec->bias_level == SND_SOC_BIAS_OFF) { 1189 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1188 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), 1190 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies),
1189 priv->supplies); 1191 priv->supplies);
1190 if (ret != 0) 1192 if (ret != 0)
@@ -1317,7 +1319,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec,
1317 priv->supplies); 1319 priv->supplies);
1318 break; 1320 break;
1319 } 1321 }
1320 codec->bias_level = level; 1322 codec->dapm.bias_level = level;
1321 return 0; 1323 return 0;
1322} 1324}
1323 1325
@@ -1550,7 +1552,7 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
1550 /* Put the codec into reset if it wasn't already */ 1552 /* Put the codec into reset if it wasn't already */
1551 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); 1553 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
1552 1554
1553 INIT_DELAYED_WORK(&codec->delayed_work, wm8350_pga_work); 1555 INIT_DELAYED_WORK(&codec->dapm.delayed_work, wm8350_pga_work);
1554 1556
1555 /* Enable the codec */ 1557 /* Enable the codec */
1556 wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); 1558 wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
@@ -1635,12 +1637,12 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
1635 priv->mic.jack = NULL; 1637 priv->mic.jack = NULL;
1636 1638
1637 /* cancel any work waiting to be queued. */ 1639 /* cancel any work waiting to be queued. */
1638 ret = cancel_delayed_work(&codec->delayed_work); 1640 ret = cancel_delayed_work(&codec->dapm.delayed_work);
1639 1641
1640 /* if there was any work waiting then we run it now and 1642 /* if there was any work waiting then we run it now and
1641 * wait for its completion */ 1643 * wait for its completion */
1642 if (ret) { 1644 if (ret) {
1643 schedule_delayed_work(&codec->delayed_work, 0); 1645 schedule_delayed_work(&codec->dapm.delayed_work, 0);
1644 flush_scheduled_work(); 1646 flush_scheduled_work();
1645 } 1647 }
1646 1648