aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8750.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-05-19 06:31:28 -0400
committerJaroslav Kysela <perex@perex.cz>2008-05-19 11:28:43 -0400
commit0be9898adb6f58fee44f0fec0bbc0eac997ea9eb (patch)
tree61842c7381c7dcc4060280357a9a5fc08f4db023 /sound/soc/codecs/wm8750.c
parent1ef6ab75c7deef931d6308af282ed7d8e480e77f (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/wm8750.c')
-rw-r--r--sound/soc/codecs/wm8750.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 16cd5d4d5ad9..62423f4493b0 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -686,29 +686,29 @@ static int wm8750_mute(struct snd_soc_codec_dai *dai, int mute)
686 return 0; 686 return 0;
687} 687}
688 688
689static int wm8750_dapm_event(struct snd_soc_codec *codec, int event) 689static int wm8750_set_bias_level(struct snd_soc_codec *codec,
690 enum snd_soc_bias_level level)
690{ 691{
691 u16 pwr_reg = wm8750_read_reg_cache(codec, WM8750_PWR1) & 0xfe3e; 692 u16 pwr_reg = wm8750_read_reg_cache(codec, WM8750_PWR1) & 0xfe3e;
692 693
693 switch (event) { 694 switch (level) {
694 case SNDRV_CTL_POWER_D0: /* full On */ 695 case SND_SOC_BIAS_ON:
695 /* set vmid to 50k and unmute dac */ 696 /* set vmid to 50k and unmute dac */
696 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x00c0); 697 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x00c0);
697 break; 698 break;
698 case SNDRV_CTL_POWER_D1: /* partial On */ 699 case SND_SOC_BIAS_PREPARE:
699 case SNDRV_CTL_POWER_D2: /* partial On */
700 /* set vmid to 5k for quick power up */ 700 /* set vmid to 5k for quick power up */
701 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x01c1); 701 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x01c1);
702 break; 702 break;
703 case SNDRV_CTL_POWER_D3hot: /* Off, with power */ 703 case SND_SOC_BIAS_STANDBY:
704 /* mute dac and set vmid to 500k, enable VREF */ 704 /* mute dac and set vmid to 500k, enable VREF */
705 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x0141); 705 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x0141);
706 break; 706 break;
707 case SNDRV_CTL_POWER_D3cold: /* Off, without power */ 707 case SND_SOC_BIAS_OFF:
708 wm8750_write(codec, WM8750_PWR1, 0x0001); 708 wm8750_write(codec, WM8750_PWR1, 0x0001);
709 break; 709 break;
710 } 710 }
711 codec->dapm_state = event; 711 codec->bias_level = level;
712 return 0; 712 return 0;
713} 713}
714 714
@@ -748,7 +748,7 @@ static void wm8750_work(struct work_struct *work)
748{ 748{
749 struct snd_soc_codec *codec = 749 struct snd_soc_codec *codec =
750 container_of(work, struct snd_soc_codec, delayed_work.work); 750 container_of(work, struct snd_soc_codec, delayed_work.work);
751 wm8750_dapm_event(codec, codec->dapm_state); 751 wm8750_set_bias_level(codec, codec->bias_level);
752} 752}
753 753
754static int wm8750_suspend(struct platform_device *pdev, pm_message_t state) 754static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
@@ -756,7 +756,7 @@ static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
756 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 756 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
757 struct snd_soc_codec *codec = socdev->codec; 757 struct snd_soc_codec *codec = socdev->codec;
758 758
759 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold); 759 wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF);
760 return 0; 760 return 0;
761} 761}
762 762
@@ -777,12 +777,12 @@ static int wm8750_resume(struct platform_device *pdev)
777 codec->hw_write(codec->control_data, data, 2); 777 codec->hw_write(codec->control_data, data, 2);
778 } 778 }
779 779
780 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot); 780 wm8750_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
781 781
782 /* charge wm8750 caps */ 782 /* charge wm8750 caps */
783 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) { 783 if (codec->suspend_bias_level == SND_SOC_BIAS_ON) {
784 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); 784 wm8750_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
785 codec->dapm_state = SNDRV_CTL_POWER_D0; 785 codec->bias_level = SND_SOC_BIAS_ON;
786 schedule_delayed_work(&codec->delayed_work, 786 schedule_delayed_work(&codec->delayed_work,
787 msecs_to_jiffies(1000)); 787 msecs_to_jiffies(1000));
788 } 788 }
@@ -803,7 +803,7 @@ static int wm8750_init(struct snd_soc_device *socdev)
803 codec->owner = THIS_MODULE; 803 codec->owner = THIS_MODULE;
804 codec->read = wm8750_read_reg_cache; 804 codec->read = wm8750_read_reg_cache;
805 codec->write = wm8750_write; 805 codec->write = wm8750_write;
806 codec->dapm_event = wm8750_dapm_event; 806 codec->set_bias_level = wm8750_set_bias_level;
807 codec->dai = &wm8750_dai; 807 codec->dai = &wm8750_dai;
808 codec->num_dai = 1; 808 codec->num_dai = 1;
809 codec->reg_cache_size = sizeof(wm8750_reg); 809 codec->reg_cache_size = sizeof(wm8750_reg);
@@ -821,8 +821,8 @@ static int wm8750_init(struct snd_soc_device *socdev)
821 } 821 }
822 822
823 /* charge output caps */ 823 /* charge output caps */
824 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); 824 wm8750_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
825 codec->dapm_state = SNDRV_CTL_POWER_D3hot; 825 codec->bias_level = SND_SOC_BIAS_STANDBY;
826 schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000)); 826 schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000));
827 827
828 /* set the update bits */ 828 /* set the update bits */
@@ -1021,7 +1021,7 @@ static int wm8750_remove(struct platform_device *pdev)
1021 struct snd_soc_codec *codec = socdev->codec; 1021 struct snd_soc_codec *codec = socdev->codec;
1022 1022
1023 if (codec->control_data) 1023 if (codec->control_data)
1024 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold); 1024 wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF);
1025 run_delayed_work(&codec->delayed_work); 1025 run_delayed_work(&codec->delayed_work);
1026 snd_soc_free_pcms(socdev); 1026 snd_soc_free_pcms(socdev);
1027 snd_soc_dapm_free(socdev); 1027 snd_soc_dapm_free(socdev);