All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] ALSA: hda - power setting error check
@ 2012-06-07 10:21 Wang Xingchao
  2012-06-07 10:42 ` Fengguang Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Xingchao @ 2012-06-07 10:21 UTC (permalink / raw)
  To: tiwai, alsa-devel, fengguang.wu; +Cc: wangxingchao2011, Wang Xingchao

codec may reject power state transition requests(reporting PS-ERROR set),
in that case we re-issue a power state setting and check error bit again.

Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
---
 sound/pci/hda/hda_codec.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d0ca370..a93c7ca 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3526,6 +3526,7 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg
 static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 				unsigned int power_state)
 {
+	int state, count = 0;
 	if (codec->patch_ops.set_power_state) {
 		codec->patch_ops.set_power_state(codec, fg, power_state);
 		return;
@@ -3537,9 +3538,19 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 		bool epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);
 		msleep(epss? 10:100);
 	}
-	snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
-			    power_state);
-	snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
+
+	/* repeat power states setting at most 10 times*/
+	while (count++ > 10) {
+		snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
+				    power_state);
+		snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
+		state = snd_hda_codec_read(codec, fg, 0,
+					   AC_VERB_GET_POWER_STATE, 0);
+		if (!(state & AC_PWRST_ERROR))
+			break;
+	}
+	if (count > 10)
+		snd_printk(KERN_WARNING "Power states transition reject!\n");
 }
 
 /* modem wake on ring: transition from D2 to D0 in less than 2ms. For modems,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-07 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 10:21 [PATCH V2] ALSA: hda - power setting error check Wang Xingchao
2012-06-07 10:42 ` Fengguang Wu
2012-06-07 13:33   ` Fwd: " Wang Xingchao

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.