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/codecs/wm8731.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/codecs/wm8731.c')
-rw-r--r-- | sound/soc/codecs/wm8731.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 0cf9265fca8f..0f28aa4bcccb 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -435,29 +435,29 @@ static int wm8731_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, | |||
435 | return 0; | 435 | return 0; |
436 | } | 436 | } |
437 | 437 | ||
438 | static int wm8731_dapm_event(struct snd_soc_codec *codec, int event) | 438 | static int wm8731_set_bias_level(struct snd_soc_codec *codec, |
439 | enum snd_soc_bias_level level) | ||
439 | { | 440 | { |
440 | u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f; | 441 | u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f; |
441 | 442 | ||
442 | switch (event) { | 443 | switch (level) { |
443 | case SNDRV_CTL_POWER_D0: /* full On */ | 444 | case SND_SOC_BIAS_ON: |
444 | /* vref/mid, osc on, dac unmute */ | 445 | /* vref/mid, osc on, dac unmute */ |
445 | wm8731_write(codec, WM8731_PWR, reg); | 446 | wm8731_write(codec, WM8731_PWR, reg); |
446 | break; | 447 | break; |
447 | case SNDRV_CTL_POWER_D1: /* partial On */ | 448 | case SND_SOC_BIAS_PREPARE: |
448 | case SNDRV_CTL_POWER_D2: /* partial On */ | ||
449 | break; | 449 | break; |
450 | case SNDRV_CTL_POWER_D3hot: /* Off, with power */ | 450 | case SND_SOC_BIAS_STANDBY: |
451 | /* everything off except vref/vmid, */ | 451 | /* everything off except vref/vmid, */ |
452 | wm8731_write(codec, WM8731_PWR, reg | 0x0040); | 452 | wm8731_write(codec, WM8731_PWR, reg | 0x0040); |
453 | break; | 453 | break; |
454 | case SNDRV_CTL_POWER_D3cold: /* Off, without power */ | 454 | case SND_SOC_BIAS_OFF: |
455 | /* everything off, dac mute, inactive */ | 455 | /* everything off, dac mute, inactive */ |
456 | wm8731_write(codec, WM8731_ACTIVE, 0x0); | 456 | wm8731_write(codec, WM8731_ACTIVE, 0x0); |
457 | wm8731_write(codec, WM8731_PWR, 0xffff); | 457 | wm8731_write(codec, WM8731_PWR, 0xffff); |
458 | break; | 458 | break; |
459 | } | 459 | } |
460 | codec->dapm_state = event; | 460 | codec->bias_level = level; |
461 | return 0; | 461 | return 0; |
462 | } | 462 | } |
463 | 463 | ||
@@ -503,7 +503,7 @@ static int wm8731_suspend(struct platform_device *pdev, pm_message_t state) | |||
503 | struct snd_soc_codec *codec = socdev->codec; | 503 | struct snd_soc_codec *codec = socdev->codec; |
504 | 504 | ||
505 | wm8731_write(codec, WM8731_ACTIVE, 0x0); | 505 | wm8731_write(codec, WM8731_ACTIVE, 0x0); |
506 | wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold); | 506 | wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); |
507 | return 0; | 507 | return 0; |
508 | } | 508 | } |
509 | 509 | ||
@@ -521,8 +521,8 @@ static int wm8731_resume(struct platform_device *pdev) | |||
521 | data[1] = cache[i] & 0x00ff; | 521 | data[1] = cache[i] & 0x00ff; |
522 | codec->hw_write(codec->control_data, data, 2); | 522 | codec->hw_write(codec->control_data, data, 2); |
523 | } | 523 | } |
524 | wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot); | 524 | wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
525 | wm8731_dapm_event(codec, codec->suspend_dapm_state); | 525 | wm8731_set_bias_level(codec, codec->suspend_bias_level); |
526 | return 0; | 526 | return 0; |
527 | } | 527 | } |
528 | 528 | ||
@@ -539,7 +539,7 @@ static int wm8731_init(struct snd_soc_device *socdev) | |||
539 | codec->owner = THIS_MODULE; | 539 | codec->owner = THIS_MODULE; |
540 | codec->read = wm8731_read_reg_cache; | 540 | codec->read = wm8731_read_reg_cache; |
541 | codec->write = wm8731_write; | 541 | codec->write = wm8731_write; |
542 | codec->dapm_event = wm8731_dapm_event; | 542 | codec->set_bias_level = wm8731_set_bias_level; |
543 | codec->dai = &wm8731_dai; | 543 | codec->dai = &wm8731_dai; |
544 | codec->num_dai = 1; | 544 | codec->num_dai = 1; |
545 | codec->reg_cache_size = sizeof(wm8731_reg); | 545 | codec->reg_cache_size = sizeof(wm8731_reg); |
@@ -557,7 +557,7 @@ static int wm8731_init(struct snd_soc_device *socdev) | |||
557 | } | 557 | } |
558 | 558 | ||
559 | /* power on device */ | 559 | /* power on device */ |
560 | wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot); | 560 | wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
561 | 561 | ||
562 | /* set the update bits */ | 562 | /* set the update bits */ |
563 | reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); | 563 | reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); |
@@ -730,7 +730,7 @@ static int wm8731_remove(struct platform_device *pdev) | |||
730 | struct snd_soc_codec *codec = socdev->codec; | 730 | struct snd_soc_codec *codec = socdev->codec; |
731 | 731 | ||
732 | if (codec->control_data) | 732 | if (codec->control_data) |
733 | wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold); | 733 | wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); |
734 | 734 | ||
735 | snd_soc_free_pcms(socdev); | 735 | snd_soc_free_pcms(socdev); |
736 | snd_soc_dapm_free(socdev); | 736 | snd_soc_dapm_free(socdev); |