aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.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/soc-dapm.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/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8a3192bcee78..728f3ac2f304 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -763,21 +763,18 @@ static ssize_t dapm_widget_show(struct device *dev,
763 } 763 }
764 } 764 }
765 765
766 switch(codec->dapm_state){ 766 switch (codec->bias_level) {
767 case SNDRV_CTL_POWER_D0: 767 case SND_SOC_BIAS_ON:
768 state = "D0"; 768 state = "On";
769 break; 769 break;
770 case SNDRV_CTL_POWER_D1: 770 case SND_SOC_BIAS_PREPARE:
771 state = "D1"; 771 state = "Prepare";
772 break; 772 break;
773 case SNDRV_CTL_POWER_D2: 773 case SND_SOC_BIAS_STANDBY:
774 state = "D2"; 774 state = "Standby";
775 break; 775 break;
776 case SNDRV_CTL_POWER_D3hot: 776 case SND_SOC_BIAS_OFF:
777 state = "D3hot"; 777 state = "Off";
778 break;
779 case SNDRV_CTL_POWER_D3cold:
780 state = "D3cold";
781 break; 778 break;
782 } 779 }
783 count += sprintf(buf + count, "PM State: %s\n", state); 780 count += sprintf(buf + count, "PM State: %s\n", state);
@@ -1358,27 +1355,28 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
1358EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); 1355EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
1359 1356
1360/** 1357/**
1361 * snd_soc_dapm_device_event - send a device event to the dapm core 1358 * snd_soc_dapm_set_bias_level - set the bias level for the system
1362 * @socdev: audio device 1359 * @socdev: audio device
1363 * @event: device event 1360 * @level: level to configure
1364 * 1361 *
1365 * Sends a device event to the dapm core. The core then makes any 1362 * Configure the bias (power) levels for the SoC audio device.
1366 * necessary machine or codec power changes..
1367 * 1363 *
1368 * Returns 0 for success else error. 1364 * Returns 0 for success else error.
1369 */ 1365 */
1370int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event) 1366int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1367 enum snd_soc_bias_level level)
1371{ 1368{
1372 struct snd_soc_codec *codec = socdev->codec; 1369 struct snd_soc_codec *codec = socdev->codec;
1373 struct snd_soc_machine *machine = socdev->machine; 1370 struct snd_soc_machine *machine = socdev->machine;
1371 int ret = 0;
1374 1372
1375 if (machine->dapm_event) 1373 if (machine->set_bias_level)
1376 machine->dapm_event(machine, event); 1374 ret = machine->set_bias_level(machine, level);
1377 if (codec->dapm_event) 1375 if (ret == 0 && codec->set_bias_level)
1378 codec->dapm_event(codec, event); 1376 ret = codec->set_bias_level(codec, level);
1379 return 0; 1377
1378 return ret;
1380} 1379}
1381EXPORT_SYMBOL_GPL(snd_soc_dapm_device_event);
1382 1380
1383/** 1381/**
1384 * snd_soc_dapm_set_endpoint - set audio endpoint status 1382 * snd_soc_dapm_set_endpoint - set audio endpoint status