aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/hda/hda_codec.c10
-rw-r--r--sound/pci/hda/hda_codec.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 0b9029436bb4..b1eee9a044fe 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1664,6 +1664,7 @@ static void hda_call_codec_suspend(struct hda_codec *codec)
1664#ifdef CONFIG_SND_HDA_POWER_SAVE 1664#ifdef CONFIG_SND_HDA_POWER_SAVE
1665 cancel_delayed_work(&codec->power_work); 1665 cancel_delayed_work(&codec->power_work);
1666 codec->power_on = 0; 1666 codec->power_on = 0;
1667 codec->power_transition = 0;
1667#endif 1668#endif
1668} 1669}
1669 1670
@@ -2211,7 +2212,7 @@ static void hda_keep_power_on(struct hda_codec *codec)
2211void snd_hda_power_up(struct hda_codec *codec) 2212void snd_hda_power_up(struct hda_codec *codec)
2212{ 2213{
2213 codec->power_count++; 2214 codec->power_count++;
2214 if (codec->power_on) 2215 if (codec->power_on || codec->power_transition)
2215 return; 2216 return;
2216 2217
2217 codec->power_on = 1; 2218 codec->power_on = 1;
@@ -2219,16 +2220,19 @@ void snd_hda_power_up(struct hda_codec *codec)
2219 codec->bus->ops.pm_notify(codec); 2220 codec->bus->ops.pm_notify(codec);
2220 hda_call_codec_resume(codec); 2221 hda_call_codec_resume(codec);
2221 cancel_delayed_work(&codec->power_work); 2222 cancel_delayed_work(&codec->power_work);
2223 codec->power_transition = 0;
2222} 2224}
2223 2225
2224void snd_hda_power_down(struct hda_codec *codec) 2226void snd_hda_power_down(struct hda_codec *codec)
2225{ 2227{
2226 --codec->power_count; 2228 --codec->power_count;
2227 if (!codec->power_on || codec->power_count) 2229 if (!codec->power_on || codec->power_count || codec->power_transition)
2228 return; 2230 return;
2229 if (power_save) 2231 if (power_save) {
2232 codec->power_transition = 1; /* avoid reentrance */
2230 schedule_delayed_work(&codec->power_work, 2233 schedule_delayed_work(&codec->power_work,
2231 msecs_to_jiffies(power_save * 1000)); 2234 msecs_to_jiffies(power_save * 1000));
2235 }
2232} 2236}
2233 2237
2234int snd_hda_check_amp_list_power(struct hda_codec *codec, 2238int snd_hda_check_amp_list_power(struct hda_codec *codec,
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 1ffffaa3a30d..ca157e5100c9 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -586,7 +586,8 @@ struct hda_codec {
586 struct snd_hwdep *hwdep; /* assigned hwdep device */ 586 struct snd_hwdep *hwdep; /* assigned hwdep device */
587 587
588#ifdef CONFIG_SND_HDA_POWER_SAVE 588#ifdef CONFIG_SND_HDA_POWER_SAVE
589 int power_on; /* current (global) power-state */ 589 unsigned int power_on :1; /* current (global) power-state */
590 unsigned int power_transition :1; /* power-state in transition */
590 int power_count; /* current (global) power refcount */ 591 int power_count; /* current (global) power refcount */
591 struct delayed_work power_work; /* delayed task for powerdown */ 592 struct delayed_work power_work; /* delayed task for powerdown */
592#endif 593#endif