ASoC CODEC power management on reboot
I've run into a problem where when the system reboots the audio starts playing random data. I suspect that this is due to the CODEC being left powered and when the during/after the reset process the GPIO lines which form the I2S bus are left floating.
Should the ASoC (possibly DAPM) layer sort out powering down the CODEC before reboot, or should it be down to the codec or the mapping driver to do this?
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
Quoted 3 lines · Ben Dooks
Should the ASoC (possibly DAPM) layer sort out powering down the CODEC before reboot, or should it be down to the codec or the mapping driver to do this?
Core.
Quoted 7 lines · Mark Brown
Quoted 3 lines · Ben Dooks
Should the ASoC (possibly DAPM) layer sort out powering down the CODEC before reboot, or should it be down to the codec or the mapping driver to do this?
Core.
Please try this (completely untested) patch:
Quoted 1 line
From
506921be0ce5b96c3761c771a9356f2c53bd6628Mon Sep 17 00:00:00 2001
From: Mark Brown <[email protected]>
Date: Mon, 22 Jun 2009 13:16:51 +0100
Subject: [PATCH] ASoC: Add a shutdown callback
Ensure that the audio subsystem is powered down cleanly when the system shuts down by providing a shutdown operation. This ensures that all the components have been returned to an off state cleanly which should avoid audio issues from partially charged capacitors or noise on digital inputs if the system is restarted quickly.
--- include/sound/soc-dapm.h | 1 + sound/soc/soc-core.c | 16 ++++++++++++++++ sound/soc/soc-dapm.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 0 deletions(-)
include/sound/soc-dapm.h +1 -0
@@ -279,6 +279,7 @@ int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,/* dapm events */ int snd_soc_dapm_stream_event (struct snd_soc_codec *codec,char *stream,int event); +void snd_soc_dapm_shutdown (struct snd_soc_device *socdev);/* dapm sys fs - used by the core */ int snd_soc_dapm_sys_add (struct device *dev);
sound/soc/soc-core.c +16 -0
@@ -1020,6 +1020,21 @@ static int soc_remove(struct platform_device *pdev)return 0 ; } +static void soc_shutdown (struct platform_device *pdev) +{ +struct snd_soc_device *socdev =platform_get_drvdata (pdev); +struct snd_soc_card *card = socdev->card; + +if (!card->instantiated) +return ; + +/* Flush out pmdown_time work - we actually do want to run it +* now, we're shutting down so no imminent restart. */ +run_delayed_work (&card->delayed_work); + +snd_soc_dapm_shutdown (socdev); +} +/* ASoC platform driver */ static struct platform_driver soc_driver = { .driver = {
@@ -1030,6 +1045,7 @@ static struct platform_driver soc_driver = { .remove = soc_remove, .suspend = soc_suspend, .resume = soc_resume, + .shutdown = soc_shutdown, };/* create a new pcm */
sound/soc/soc-dapm.c +29 -0
@@ -2032,6 +2032,35 @@ void snd_soc_dapm_free(struct snd_soc_device *socdev) }EXPORT_SYMBOL_GPL (snd_soc_dapm_free); +/* +* snd_soc_dapm_shutdown - callback for system shutdown +*/ +void snd_soc_dapm_shutdown (struct snd_soc_device *socdev) +{ +struct snd_soc_codec *codec = socdev->card->codec; +struct snd_soc_dapm_widget *w; +LIST_HEAD (down_list); +int powerdown =0 ; + +list_for_each_entry (w, &codec->dapm_widgets, list) { +if (w->power) { +dapm_seq_insert (w, &down_list, dapm_down_seq); + powerdown =1 ; + } + } + +/* If there were no widgets to power down we're already in +* standby. +*/ +if (powerdown) { +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_PREPARE ); +dapm_seq_run (codec, &down_list,0 , dapm_down_seq); +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_STANDBY ); + } + +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_OFF ); +} +/* Module information */ MODULE_AUTHOR ("Liam Girdwood, [email protected]" );MODULE_DESCRIPTION ("Dynamic Audio Power Management core for ALSA SoC" );
Signature · 1 line
1.6.3.1
Ben Dooks
Tested-byQuoted 16 lines · Mark Brown
Quoted 7 lines · Mark Brown
Quoted 3 lines · Ben Dooks
Should the ASoC (possibly DAPM) layer sort out powering down the CODEC before reboot, or should it be down to the codec or the mapping driver to do this?
Core.
Please try this (completely untested) patch:
Quoted 1 line
From
506921be0ce5b96c3761c771a9356f2c53bd6628Mon Sep 17 00:00:00 2001From: Mark Brown <[email protected]>
Date: Mon, 22 Jun 2009 13:16:51 +0100
Subject: [PATCH] ASoC: Add a shutdown callback
Quoted 5 lines
Ensure that the audio subsystem is powered down cleanly when the system shuts down by providing a shutdown operation. This ensures that all the components have been returned to an off state cleanly which should avoid audio issues from partially charged capacitors or noise on digital inputs if the system is restarted quickly.
Right, so far this seems to have worked.
Quoted 1 line
Signed-off-by Mark Brown <[email protected]>
Quoted 99 lines
--- include/sound/soc-dapm.h | 1 + sound/soc/soc-core.c | 16 ++++++++++++++++ sound/soc/soc-dapm.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 0 deletions(-)include/sound/soc-dapm.h +1
-0@@ -279,6 +279,7 @@ int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,/* dapm events */ int snd_soc_dapm_stream_event (struct snd_soc_codec *codec,char *stream,int event); +void snd_soc_dapm_shutdown (struct snd_soc_device *socdev);/* dapm sys fs - used by the core */ int snd_soc_dapm_sys_add (struct device *dev);sound/soc/soc-core.c +16
-0@@ -1020,6 +1020,21 @@ static int soc_remove(struct platform_device *pdev)return 0 ; } +static void soc_shutdown (struct platform_device *pdev) +{ +struct snd_soc_device *socdev =platform_get_drvdata (pdev); +struct snd_soc_card *card = socdev->card; + +if (!card->instantiated) +return ; + +/* Flush out pmdown_time work - we actually do want to run it +* now, we're shutting down so no imminent restart. */ +run_delayed_work (&card->delayed_work); + +snd_soc_dapm_shutdown (socdev); +} +/* ASoC platform driver */ static struct platform_driver soc_driver = { .driver = {@@ -1030,6 +1045,7 @@ static struct platform_driver soc_driver = { .remove = soc_remove, .suspend = soc_suspend, .resume = soc_resume, + .shutdown = soc_shutdown, };/* create a new pcm */ sound/soc/soc-dapm.c +29
-0@@ -2032,6 +2032,35 @@ void snd_soc_dapm_free(struct snd_soc_device *socdev) }EXPORT_SYMBOL_GPL (snd_soc_dapm_free); +/* +* snd_soc_dapm_shutdown - callback for system shutdown +*/ +void snd_soc_dapm_shutdown (struct snd_soc_device *socdev) +{ +struct snd_soc_codec *codec = socdev->card->codec; +struct snd_soc_dapm_widget *w; +LIST_HEAD (down_list); +int powerdown =0 ; + +list_for_each_entry (w, &codec->dapm_widgets, list) { +if (w->power) { +dapm_seq_insert (w, &down_list, dapm_down_seq); + powerdown =1 ; + } + } + +/* If there were no widgets to power down we're already in +* standby. +*/ +if (powerdown) { +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_PREPARE ); +dapm_seq_run (codec, &down_list,0 , dapm_down_seq); +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_STANDBY ); + } + +snd_soc_dapm_set_bias_level (socdev,SND_SOC_BIAS_OFF ); +} +/* Module information */ MODULE_AUTHOR ("Liam Girdwood, [email protected]" );MODULE_DESCRIPTION ("Dynamic Audio Power Management core for ALSA SoC" );Signature · 6 lines
1.6.3.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Signature · 5 lines
-- Ben Q: What's a light-year? A: One-third less calories than a regular year.