ALSA: hda - power setting error check
PATCH 1/1 ALSA: hda - power setting error check
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.
--- sound/pci/hda/hda_codec.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/pci/hda/hda_codec.c +11 -0
@@ -3526,6 +3526,7 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fgstatic 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 ); } +again: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 ) { +/* repeat power states setting at most 10 times*/ +if (count++ >10 ) +snd_printk (KERN_WARNING "Power states transition reject!\n" ); +else + goto again; + } }/* modem wake on ring: transition from D2 to D0 in less than 2ms. For modems,
Signature · 1 line
1.7.9.5
At Thu, 7 Jun 2012 16:52:51 +0800,
Quoted 28 lines · 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 <[email protected]>--- sound/pci/hda/hda_codec.c | 11 +++++++++++ 1 file changed, 11 insertions(+)sound/pci/hda/hda_codec.c +2
-0@@ -3526,6 +3526,7 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fgstatic 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 ); } +again:snd_hda_codec_read (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state);
sound/pci/hda/hda_codec.c static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, · line 3553
Quoted 10 lines
sound/pci/hda/hda_codec.c +9
-0snd_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 ) { +/* repeat power states setting at most 10 times*/ +if (count++ >10 ) +snd_printk (KERN_WARNING "Power states transition reject!\n" ); +else + goto again; + }
For such a short block, better to use a proper loop instead of goto, IMO.
Takashi
2012/6/7 Takashi Iwai <[email protected]>:
Quoted 35 lines
At Thu, 7 Jun 2012 16:52:51 +0800,
Quoted 33 lines · 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 <[email protected]>---
sound/pci/hda/hda_codec.c | 11 +++++++++++1 file changed, 11 insertions(+)sound/pci/hda/hda_codec.c +6
-0@@ -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); } +again: 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) { + /* repeat power states setting at most 10 times*/
Quoted 9 lines
sound/pci/hda/hda_codec.c static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, · line 3553
Quoted 5 lines
sound/pci/hda/hda_codec.c +5
-0+ if (count++ > 10) + snd_printk(KERN_WARNING "Power states transition reject!\n"); + else + goto again; + }For such a short block, better to use a proper loop instead of goto, IMO.
Thanks for review, i'd update the patch and send it out again.
thanks
--xingchao