Skip to contentSkip to conversation

ALSA: hda - check supported power states

PATCH In review Wang Xingchao 4 participants 5 messages Jun 6, 2012 – Jun 7, 2012 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ALSA: hda - check supported power states

Add function to check whether power states supported by specific codec node.

---
 sound/pci/hda/hda_codec.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/pci/hda/hda_codec.c +16 -0
index 41ca803..b89c8ec 100644
@@ -3505,6 +3505,22 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
 EXPORT_SYMBOL_HDA(snd_hda_codec_set_power_to_all);
 
 /*
+ *  supported power states check
+ */
+static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg,
+				unsigned int power_state)
+{
+	int sup = snd_hda_param_read(codec, fg, AC_PAR_POWER_STATE);
+
+	if (sup < 0)
+		return false;
+	if (sup & power_state)
+		return true;
+	else
+		return false;
+}
+
+/*
  * set power state of the codec
  */
 static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 ALSA: hda - reduce msleep time if EPSS power states supported

if EPSS supported, transition from D3 state to D0 state in less than 10ms

---
 sound/pci/hda/hda_codec.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +5 -1
index b89c8ec..5298ba1 100644
@@ -3526,14 +3526,18 @@ 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)
 {
+	bool epss;
 	if (codec->patch_ops.set_power_state) {
 		codec->patch_ops.set_power_state(codec, fg, power_state);
 		return;
 	}
 
+	epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);
 	/* this delay seems necessary to avoid click noise at power-down */
-	if (power_state == AC_PWRST_D3)
+	if ((power_state == AC_PWRST_D3) && !epss)
 		msleep(100);
+	else
+		msleep(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);
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/2] ALSA: hda - reduce msleep time if EPSS power states supported

Quoted 19 lines · Wang Xingchao

if EPSS supported, transition from D3 state to D0 state in less than 10ms

---
  sound/pci/hda/hda_codec.c |    6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +1 -0
index b89c8ec..5298ba1 100644
@@ -3526,14 +3526,18 @@ 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)
  {
+	bool epss;
  	if (codec->patch_ops.set_power_state) {
  		codec->patch_ops.set_power_state(codec, fg, power_state);

sound/pci/hda/hda_codec.c static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg · line 3540

Quoted 10 lines
sound/pci/hda/hda_codec.c +4 -1
  		return;
  	}
 
+	epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);
  	/* this delay seems necessary to avoid click noise at power-down */
-	if (power_state == AC_PWRST_D3)
+	if ((power_state == AC_PWRST_D3)&&  !epss)
  		msleep(100);
+	else
+		msleep(10);

Hi Wang,

You seem to have increased the delay from 0 to 10 ms on all cases when power_state != AC_PWRST_D3, is this intentional?

Or did you mean to write like this:

	if (power_state == AC_PWRST_D3) {
		bool epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);
		msleep(epss ? 10 : 100);
	}
Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
#3 lore raw

Re: [PATCH 2/2] ALSA: hda - reduce msleep time if EPSS power states supported

Hi David,

2012/6/7 David Henningsson <[email protected]>:

Quoted 37 lines · Wang Xingchao
Quoted 24 lines

if EPSS supported, transition from D3 state to D0 state in less than 10ms

---
 sound/pci/hda/hda_codec.c |    6 +++++-

 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +0 -0
index b89c8ec..5298ba1 100644
@@ -3526,14 +3526,18 @@ 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)
 {
+       bool epss;
       if (codec->patch_ops.set_power_state) { codec->patch_ops.set_power_state(codec, fg, power_state); return;
       }

Quoted 8 lines

+       epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS); /* this delay seems necessary to avoid click noise at power-down */
-       if (power_state == AC_PWRST_D3)
+       if ((power_state == AC_PWRST_D3)&&  !epss)

               msleep(100);
+       else
+               msleep(10);

Hi Wang,

Quoted 2 lines

You seem to have increased the delay from 0 to 10 ms on all cases when power_state != AC_PWRST_D3, is this intentional?

Thanks for clarification, it's a mistake here. Only transition from D0 to D3 need the delay to avoid click noise, there's no limitation during power up.
i will update the patch based on your suggestion.

thanks
--xingchao

Quoted 13 lines

Or did you mean to write like this:

       if (power_state == AC_PWRST_D3) {
               bool epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS);
               msleep(epss ? 10 : 100);
       }

--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic

#4 lore raw
In reply to Wang Xingchao

At Wed, 6 Jun 2012 22:02:48 +0800,

Quoted 5 lines · Wang Xingchao

Add function to check whether power states supported by specific codec node.

Applied together with v2 patch. Thanks.

Takashi

Quoted 34 lines
---
 sound/pci/hda/hda_codec.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/pci/hda/hda_codec.c +16 -0
index 41ca803..b89c8ec 100644
@@ -3505,6 +3505,22 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
 EXPORT_SYMBOL_HDA(snd_hda_codec_set_power_to_all);
 
 /*
+ *  supported power states check
+ */
+static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg,
+				unsigned int power_state)
+{
+	int sup = snd_hda_param_read(codec, fg, AC_PAR_POWER_STATE);
+
+	if (sup < 0)
+		return false;
+	if (sup & power_state)
+		return true;
+	else
+		return false;
+}
+
+/*
  * set power state of the codec
  */
 static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
Signature · 1 line
1.7.9.5