diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-05-19 06:31:28 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-05-19 11:28:43 -0400 |
commit | 0be9898adb6f58fee44f0fec0bbc0eac997ea9eb (patch) | |
tree | 61842c7381c7dcc4060280357a9a5fc08f4db023 /sound/soc/soc-core.c | |
parent | 1ef6ab75c7deef931d6308af282ed7d8e480e77f (diff) |
[ALSA] ASoC: Clarify API for bias configuration
Currently the ASoC core configures the bias levels in the system using
a callback on codecs and machines called 'dapm_event', passing it PCI
style power levels as SNDRV_CTL_POWER_ constants. This is more obscure
than it needs to be and has caused confusion to driver authors,
especially given that DAPM is also performing power management.
Address this by renaming the callback function to 'set_bias_level' and
using constants explicitly representing the off, standby, pre-on and on
states which DAPM transitions through.
Also unexport the API for setting bias level: there are currently no
in-tree users of this API other than the core itself and it is likely
that the core would need to be extended to cater for any users.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Jarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0318d8abe3e8..a05b3450aee8 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -283,12 +283,12 @@ static void close_delayed_work(struct work_struct *work) | |||
283 | /* are we waiting on this codec DAI stream */ | 283 | /* are we waiting on this codec DAI stream */ |
284 | if (codec_dai->pop_wait == 1) { | 284 | if (codec_dai->pop_wait == 1) { |
285 | 285 | ||
286 | /* power down the codec to D1 if no longer active */ | 286 | /* Reduce power if no longer active */ |
287 | if (codec->active == 0) { | 287 | if (codec->active == 0) { |
288 | dbg("pop wq D1 %s %s\n", codec->name, | 288 | dbg("pop wq D1 %s %s\n", codec->name, |
289 | codec_dai->playback.stream_name); | 289 | codec_dai->playback.stream_name); |
290 | snd_soc_dapm_device_event(socdev, | 290 | snd_soc_dapm_set_bias_level(socdev, |
291 | SNDRV_CTL_POWER_D1); | 291 | SND_SOC_BIAS_PREPARE); |
292 | } | 292 | } |
293 | 293 | ||
294 | codec_dai->pop_wait = 0; | 294 | codec_dai->pop_wait = 0; |
@@ -296,12 +296,12 @@ static void close_delayed_work(struct work_struct *work) | |||
296 | codec_dai->playback.stream_name, | 296 | codec_dai->playback.stream_name, |
297 | SND_SOC_DAPM_STREAM_STOP); | 297 | SND_SOC_DAPM_STREAM_STOP); |
298 | 298 | ||
299 | /* power down the codec power domain if no longer active */ | 299 | /* Fall into standby if no longer active */ |
300 | if (codec->active == 0) { | 300 | if (codec->active == 0) { |
301 | dbg("pop wq D3 %s %s\n", codec->name, | 301 | dbg("pop wq D3 %s %s\n", codec->name, |
302 | codec_dai->playback.stream_name); | 302 | codec_dai->playback.stream_name); |
303 | snd_soc_dapm_device_event(socdev, | 303 | snd_soc_dapm_set_bias_level(socdev, |
304 | SNDRV_CTL_POWER_D3hot); | 304 | SND_SOC_BIAS_STANDBY); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
@@ -361,8 +361,8 @@ static int soc_codec_close(struct snd_pcm_substream *substream) | |||
361 | SND_SOC_DAPM_STREAM_STOP); | 361 | SND_SOC_DAPM_STREAM_STOP); |
362 | 362 | ||
363 | if (codec->active == 0 && codec_dai->pop_wait == 0) | 363 | if (codec->active == 0 && codec_dai->pop_wait == 0) |
364 | snd_soc_dapm_device_event(socdev, | 364 | snd_soc_dapm_set_bias_level(socdev, |
365 | SNDRV_CTL_POWER_D3hot); | 365 | SND_SOC_BIAS_STANDBY); |
366 | } | 366 | } |
367 | 367 | ||
368 | mutex_unlock(&pcm_mutex); | 368 | mutex_unlock(&pcm_mutex); |
@@ -435,9 +435,10 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
435 | } | 435 | } |
436 | } else { | 436 | } else { |
437 | /* no delayed work - do we need to power up codec */ | 437 | /* no delayed work - do we need to power up codec */ |
438 | if (codec->dapm_state != SNDRV_CTL_POWER_D0) { | 438 | if (codec->bias_level != SND_SOC_BIAS_ON) { |
439 | 439 | ||
440 | snd_soc_dapm_device_event(socdev, SNDRV_CTL_POWER_D1); | 440 | snd_soc_dapm_set_bias_level(socdev, |
441 | SND_SOC_BIAS_PREPARE); | ||
441 | 442 | ||
442 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 443 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
443 | snd_soc_dapm_stream_event(codec, | 444 | snd_soc_dapm_stream_event(codec, |
@@ -448,7 +449,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
448 | codec_dai->capture.stream_name, | 449 | codec_dai->capture.stream_name, |
449 | SND_SOC_DAPM_STREAM_START); | 450 | SND_SOC_DAPM_STREAM_START); |
450 | 451 | ||
451 | snd_soc_dapm_device_event(socdev, SNDRV_CTL_POWER_D0); | 452 | snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON); |
452 | if (codec_dai->dai_ops.digital_mute) | 453 | if (codec_dai->dai_ops.digital_mute) |
453 | codec_dai->dai_ops.digital_mute(codec_dai, 0); | 454 | codec_dai->dai_ops.digital_mute(codec_dai, 0); |
454 | 455 | ||
@@ -658,7 +659,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state) | |||
658 | 659 | ||
659 | /* close any waiting streams and save state */ | 660 | /* close any waiting streams and save state */ |
660 | run_delayed_work(&socdev->delayed_work); | 661 | run_delayed_work(&socdev->delayed_work); |
661 | codec->suspend_dapm_state = codec->dapm_state; | 662 | codec->suspend_bias_level = codec->bias_level; |
662 | 663 | ||
663 | for(i = 0; i < codec->num_dai; i++) { | 664 | for(i = 0; i < codec->num_dai; i++) { |
664 | char *stream = codec->dai[i].playback.stream_name; | 665 | char *stream = codec->dai[i].playback.stream_name; |