Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d804ad9258c1460916a5e5854655a0dc543fd8a5
Commit:     d804ad9258c1460916a5e5854655a0dc543fd8a5
Parent:     2e4924628ad957f702631a7a049c586a780f00f8
Author:     Maxim Levitsky <[EMAIL PROTECTED]>
AuthorDate: Mon Sep 3 15:28:04 2007 +0200
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 15:59:47 2007 +0200

    [ALSA] hda-intel - Fix resume logic, when dynamic power managment is on
    
    Comment in hda_intel.c states that 'the explicit resume is needed only
    when POWER_SAVE isn't set', but this is not true.
    There is no code that will automaticly power up the codec on resume,
    but only code that powers it up when user accesses it. So if user
    leaves a sound playing, codec will not be powered
    To fix that I check if there are any codecs that should be powered
    codec->power_count, and if so I power them up together with main
    controller.
    
    Signed-off-by: Maxim Levitsky <[EMAIL PROTECTED]>
    Signed-off-by: Takashi Iwai <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/pci/hda/hda_codec.c |   16 +++++++++++++---
 sound/pci/hda/hda_codec.h |    4 ++++
 sound/pci/hda/hda_intel.c |    8 ++++----
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 08104e2..e594de0 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2787,7 +2787,6 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t 
state)
        return 0;
 }
 
-#ifndef CONFIG_SND_HDA_POWER_SAVE
 /**
  * snd_hda_resume - resume the codecs
  * @bus: the HDA bus
@@ -2803,10 +2802,21 @@ int snd_hda_resume(struct hda_bus *bus)
        struct hda_codec *codec;
 
        list_for_each_entry(codec, &bus->codec_list, list) {
-               hda_call_codec_resume(codec);
+               if (snd_hda_codec_needs_resume(codec))
+                       hda_call_codec_resume(codec);
        }
        return 0;
 }
-#endif /* !CONFIG_SND_HDA_POWER_SAVE */
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+int snd_hda_codecs_inuse(struct hda_bus *bus)
+{
+       struct hda_codec *codec;
 
+       list_for_each_entry(codec, &bus->codec_list, list) {
+               if (snd_hda_codec_needs_resume(codec))
+                       return 1;
+       }
+       return 0;
+}
+#endif
 #endif
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index ca157e5..2bce925 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -686,9 +686,13 @@ int snd_hda_resume(struct hda_bus *bus);
 #ifdef CONFIG_SND_HDA_POWER_SAVE
 void snd_hda_power_up(struct hda_codec *codec);
 void snd_hda_power_down(struct hda_codec *codec);
+#define snd_hda_codec_needs_resume(codec) codec->power_count
+int snd_hda_codecs_inuse(struct hda_bus *bus);
 #else
 static inline void snd_hda_power_up(struct hda_codec *codec) {}
 static inline void snd_hda_power_down(struct hda_codec *codec) {}
+#define snd_hda_codec_needs_resume(codec) 1
+#define snd_hda_codecs_inuse(bus) 1
 #endif
 
 #endif /* __SOUND_HDA_CODEC_H */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 3d06ecc..72fd345 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1586,11 +1586,11 @@ static int azx_resume(struct pci_dev *pci)
        if (azx_acquire_irq(chip, 1) < 0)
                return -EIO;
        azx_init_pci(chip);
-#ifndef CONFIG_SND_HDA_POWER_SAVE
-       /* the explicit resume is needed only when POWER_SAVE isn't set */
-       azx_init_chip(chip);
+
+       if (snd_hda_codecs_inuse(chip->bus))
+               azx_init_chip(chip);
+
        snd_hda_resume(chip->bus);
-#endif
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to