All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Levitsky <maximlevitsky@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, mranostay@embeddedalley.com
Subject: [PATCH 2/6] Fix resume logic, when dynamic power managment is on
Date: Mon, 3 Sep 2007 15:17:06 +0300	[thread overview]
Message-ID: <200709031517.07008.maximlevitsky@gmail.com> (raw)
In-Reply-To: <200709031514.57875.maximlevitsky@gmail.com>

>From 3d4f5b6dcf586277ca6ca4ea86068e01566c58c0 Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <maximlevitsky@gmail.com>
Date: Mon, 3 Sep 2007 14:10:11 +0300
Subject: [PATCH] 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 <maximlevitsky@gmail.com>
---
 pci/hda/hda_codec.c |   16 +++++++++++++---
 pci/hda/hda_codec.h |    4 ++++
 pci/hda/hda_intel.c |    8 ++++----
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/pci/hda/hda_codec.c b/pci/hda/hda_codec.c
index 08104e2..e594de0 100644
--- a/pci/hda/hda_codec.c
+++ b/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/pci/hda/hda_codec.h b/pci/hda/hda_codec.h
index ca157e5..2bce925 100644
--- a/pci/hda/hda_codec.h
+++ b/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/pci/hda/hda_intel.c b/pci/hda/hda_intel.c
index 3d06ecc..72fd345 100644
--- a/pci/hda/hda_intel.c
+++ b/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;
 }
-- 
1.5.2.3

  parent reply	other threads:[~2007-09-03 13:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-03 12:14 HDA: STAC92xx: [PATCH v2] : add support for missing features + fix two bugs in new dynamic powersave mode Maxim Levitsky
2007-09-03 12:16 ` [PATCH 001] fix a race in dynamic power managment Maxim Levitsky
2007-09-03 12:17 ` Maxim Levitsky [this message]
2007-09-03 12:18 ` [PATCH 3/6] add support for swapping center/LFE channels Maxim Levitsky
2007-09-03 12:19 ` [PATCH 4/6] add support for analog loopback to STAC9204/9205/922x/927x Maxim Levitsky
2007-09-03 12:20 ` [PATCH 5/6] make volume knob, the master volume for sigmatel codecs that support it Maxim Levitsky
2007-09-03 12:21 ` [PATCH 6/6] Fix support for sigmatel codecs that have 2 or more ADCs Maxim Levitsky
2007-09-03 13:34 ` HDA: STAC92xx: [PATCH v2] : add support for missing features + fix two bugs in new dynamic powersave mode Takashi Iwai
2007-09-03 12:48   ` Maxim Levitsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200709031517.07008.maximlevitsky@gmail.com \
    --to=maximlevitsky@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=mranostay@embeddedalley.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.