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/tlv320aic3x.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/tlv320aic3x.c')
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index cb8365ac0c02..dc8a38d9e53a 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -847,13 +847,14 @@ static int aic3x_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, | |||
847 | return 0; | 847 | return 0; |
848 | } | 848 | } |
849 | 849 | ||
850 | static int aic3x_dapm_event(struct snd_soc_codec *codec, int event) | 850 | static int aic3x_set_bias_level(struct snd_soc_codec *codec, |
851 | enum snd_soc_bias_level level) | ||
851 | { | 852 | { |
852 | struct aic3x_priv *aic3x = codec->private_data; | 853 | struct aic3x_priv *aic3x = codec->private_data; |
853 | u8 reg; | 854 | u8 reg; |
854 | 855 | ||
855 | switch (event) { | 856 | switch (level) { |
856 | case SNDRV_CTL_POWER_D0: | 857 | case SND_SOC_BIAS_ON: |
857 | /* all power is driven by DAPM system */ | 858 | /* all power is driven by DAPM system */ |
858 | if (aic3x->master) { | 859 | if (aic3x->master) { |
859 | /* enable pll */ | 860 | /* enable pll */ |
@@ -862,10 +863,9 @@ static int aic3x_dapm_event(struct snd_soc_codec *codec, int event) | |||
862 | reg | PLL_ENABLE); | 863 | reg | PLL_ENABLE); |
863 | } | 864 | } |
864 | break; | 865 | break; |
865 | case SNDRV_CTL_POWER_D1: | 866 | case SND_SOC_BIAS_PREPARE: |
866 | case SNDRV_CTL_POWER_D2: | ||
867 | break; | 867 | break; |
868 | case SNDRV_CTL_POWER_D3hot: | 868 | case SND_SOC_BIAS_STANDBY: |
869 | /* | 869 | /* |
870 | * all power is driven by DAPM system, | 870 | * all power is driven by DAPM system, |
871 | * so output power is safe if bypass was set | 871 | * so output power is safe if bypass was set |
@@ -877,7 +877,7 @@ static int aic3x_dapm_event(struct snd_soc_codec *codec, int event) | |||
877 | reg & ~PLL_ENABLE); | 877 | reg & ~PLL_ENABLE); |
878 | } | 878 | } |
879 | break; | 879 | break; |
880 | case SNDRV_CTL_POWER_D3cold: | 880 | case SND_SOC_BIAS_OFF: |
881 | /* force all power off */ | 881 | /* force all power off */ |
882 | reg = aic3x_read_reg_cache(codec, LINE1L_2_LADC_CTRL); | 882 | reg = aic3x_read_reg_cache(codec, LINE1L_2_LADC_CTRL); |
883 | aic3x_write(codec, LINE1L_2_LADC_CTRL, reg & ~LADC_PWR_ON); | 883 | aic3x_write(codec, LINE1L_2_LADC_CTRL, reg & ~LADC_PWR_ON); |
@@ -913,7 +913,7 @@ static int aic3x_dapm_event(struct snd_soc_codec *codec, int event) | |||
913 | } | 913 | } |
914 | break; | 914 | break; |
915 | } | 915 | } |
916 | codec->dapm_state = event; | 916 | codec->bias_level = level; |
917 | 917 | ||
918 | return 0; | 918 | return 0; |
919 | } | 919 | } |
@@ -979,7 +979,7 @@ static int aic3x_suspend(struct platform_device *pdev, pm_message_t state) | |||
979 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 979 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
980 | struct snd_soc_codec *codec = socdev->codec; | 980 | struct snd_soc_codec *codec = socdev->codec; |
981 | 981 | ||
982 | aic3x_dapm_event(codec, SNDRV_CTL_POWER_D3cold); | 982 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
983 | 983 | ||
984 | return 0; | 984 | return 0; |
985 | } | 985 | } |
@@ -999,7 +999,7 @@ static int aic3x_resume(struct platform_device *pdev) | |||
999 | codec->hw_write(codec->control_data, data, 2); | 999 | codec->hw_write(codec->control_data, data, 2); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | aic3x_dapm_event(codec, codec->suspend_dapm_state); | 1002 | aic3x_set_bias_level(codec, codec->suspend_bias_level); |
1003 | 1003 | ||
1004 | return 0; | 1004 | return 0; |
1005 | } | 1005 | } |
@@ -1018,7 +1018,7 @@ static int aic3x_init(struct snd_soc_device *socdev) | |||
1018 | codec->owner = THIS_MODULE; | 1018 | codec->owner = THIS_MODULE; |
1019 | codec->read = aic3x_read_reg_cache; | 1019 | codec->read = aic3x_read_reg_cache; |
1020 | codec->write = aic3x_write; | 1020 | codec->write = aic3x_write; |
1021 | codec->dapm_event = aic3x_dapm_event; | 1021 | codec->set_bias_level = aic3x_set_bias_level; |
1022 | codec->dai = &aic3x_dai; | 1022 | codec->dai = &aic3x_dai; |
1023 | codec->num_dai = 1; | 1023 | codec->num_dai = 1; |
1024 | codec->reg_cache_size = sizeof(aic3x_reg); | 1024 | codec->reg_cache_size = sizeof(aic3x_reg); |
@@ -1100,7 +1100,7 @@ static int aic3x_init(struct snd_soc_device *socdev) | |||
1100 | aic3x_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); | 1100 | aic3x_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); |
1101 | 1101 | ||
1102 | /* off, with power on */ | 1102 | /* off, with power on */ |
1103 | aic3x_dapm_event(codec, SNDRV_CTL_POWER_D3hot); | 1103 | aic3x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1104 | 1104 | ||
1105 | /* setup GPIO functions */ | 1105 | /* setup GPIO functions */ |
1106 | aic3x_write(codec, AIC3X_GPIO1_REG, (setup->gpio_func[0] & 0xf) << 4); | 1106 | aic3x_write(codec, AIC3X_GPIO1_REG, (setup->gpio_func[0] & 0xf) << 4); |
@@ -1271,7 +1271,7 @@ static int aic3x_remove(struct platform_device *pdev) | |||
1271 | 1271 | ||
1272 | /* power down chip */ | 1272 | /* power down chip */ |
1273 | if (codec->control_data) | 1273 | if (codec->control_data) |
1274 | aic3x_dapm_event(codec, SNDRV_CTL_POWER_D3); | 1274 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1275 | 1275 | ||
1276 | snd_soc_free_pcms(socdev); | 1276 | snd_soc_free_pcms(socdev); |
1277 | snd_soc_dapm_free(socdev); | 1277 | snd_soc_dapm_free(socdev); |