public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: David Henningsson <david.henningsson@canonical.com>
Cc: Hui Wang <hui.wang@canonical.com>, alsa-devel@alsa-project.org
Subject: Re: [PATCH 0/4] More aggressive PM for HD-audio
Date: Fri, 20 Mar 2015 18:18:08 +0100	[thread overview]
Message-ID: <s5h384zziy7.wl-tiwai@suse.de> (raw)
In-Reply-To: <s5h7fubzl9g.wl-tiwai@suse.de>

At Fri, 20 Mar 2015 17:28:11 +0100,
Takashi Iwai wrote:
> 
> At Fri, 20 Mar 2015 17:20:59 +0100,
> David Henningsson wrote:
> > 
> > Anyhow, after reading through the code, I have a question about LEDs. It 
> > could be that if vref is used for controlling a LED, maybe that pin 
> > needs to stay in D0 for the LED to stay lit. Is this correctly handled? 
> > I couldn't find any code specific to that issue, but maybe I just missed it.
> 
> Good point.  As far as I know, IDT codecs keep pinctl value no matter
> whether the widget power state is.  So, it should be OK, judging only
> from the spec.  But we need testing with the actual machine.  Maybe
> it's really need a power up.
> 
> The VREF pins have to be constantly powered on, the fix shouldn't be
> too difficult.

I'm convinced that it's safer to power them up, so added the patch
below.  For some HP laptops with Realtek need the similar call.

Also, I'm going to rename codec->power_mgmt with
codec->power_save_node, too.


thanks,

Takashi

-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: hda - Fix power of pins used for mute LED with vrefs

Some pins are used for controlling the LED with the VREF value.
This patch changes the power behavior of such pins to be constantly
up.  A new state, pin_fixed, is introduced to nid_path to indicate
that the path contains the fixed pin.  This improves also the
readability a bit for other static routes, too.

Then a helper function snd_hda_gen_fix_pin_power() is called from the
codec driver for such fixed pins, and it will create fake paths
containing only these pins with pin_fixed=1 flag.

Reported-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_generic.c    | 38 ++++++++++++++++++++++++++++++--------
 sound/pci/hda/hda_generic.h    |  2 ++
 sound/pci/hda/patch_sigmatel.c |  6 ++++++
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index d7ca388651da..94c7f43ad182 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -662,10 +662,10 @@ static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid,
 		if (!path->active)
 			continue;
 		if (codec->power_mgmt) {
-			if (!path->stream_enabled)
+			if (!path->stream_enabled && !path->pin_fixed)
 				continue;
 			/* ignore unplugged paths except for DAC/ADC */
-			if (!path->pin_enabled &&
+			if (!(path->pin_enabled || path->pin_fixed) &&
 			    type != AC_WID_AUD_OUT && type != AC_WID_AUD_IN)
 				continue;
 		}
@@ -1607,7 +1607,7 @@ static int check_aamix_out_path(struct hda_codec *codec, int path_idx)
 		return 0;
 	/* print_nid_path(codec, "output-aamix", path); */
 	path->active = false; /* unused as default */
-	path->pin_enabled = true; /* static route */
+	path->pin_fixed = true; /* static route */
 	return snd_hda_get_path_idx(codec, path);
 }
 
@@ -3044,7 +3044,7 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
 		if (path) {
 			print_nid_path(codec, "loopback-merge", path);
 			path->active = true;
-			path->pin_enabled = true; /* static route */
+			path->pin_fixed = true; /* static route */
 			path->stream_enabled = true; /* no DAC/ADC involved */
 			spec->loopback_merge_path =
 				snd_hda_get_path_idx(codec, path);
@@ -3847,7 +3847,7 @@ static void parse_digital(struct hda_codec *codec)
 			continue;
 		print_nid_path(codec, "digout", path);
 		path->active = true;
-		path->pin_enabled = true; /* no jack detection */
+		path->pin_fixed = true; /* no jack detection */
 		spec->digout_paths[i] = snd_hda_get_path_idx(codec, path);
 		set_pin_target(codec, pin, PIN_OUT, false);
 		if (!nums) {
@@ -3875,7 +3875,7 @@ static void parse_digital(struct hda_codec *codec)
 			if (path) {
 				print_nid_path(codec, "digin", path);
 				path->active = true;
-				path->pin_enabled = true; /* no jack */
+				path->pin_fixed = true; /* no jack */
 				spec->dig_in_nid = dig_nid;
 				spec->digin_path = snd_hda_get_path_idx(codec, path);
 				set_pin_target(codec, pin, PIN_IN, false);
@@ -3959,8 +3959,8 @@ static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid,
 				path->pin_enabled = pin_state;
 			if (stream_state >= 0)
 				path->stream_enabled = stream_state;
-			if (path->pin_enabled != pin_old ||
-			    path->stream_enabled != stream_old) {
+			if ((!path->pin_fixed && path->pin_enabled != pin_old)
+			    || path->stream_enabled != stream_old) {
 				last = path_power_update(codec, path, true);
 				if (last)
 					changed = last;
@@ -4136,6 +4136,28 @@ static void beep_power_hook(struct hda_beep *beep, bool on)
 	set_path_power(beep->codec, beep->nid, -1, on);
 }
 
+/**
+ * snd_hda_gen_fix_pin_power - Fix the power of the given pin widget to D0
+ * @codec: the HDA codec
+ * @pin: NID of pin to fix
+ */
+int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin)
+{
+	struct hda_gen_spec *spec = codec->spec;
+	struct nid_path *path;
+
+	path = snd_array_new(&spec->paths);
+	if (!path)
+		return -ENOMEM;
+	memset(path, 0, sizeof(*path));
+	path->depth = 1;
+	path->path[0] = pin;
+	path->active = true;
+	path->pin_fixed = true;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hda_gen_fix_pin_power);
+
 /*
  * Jack detections for HP auto-mute and mic-switch
  */
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
index 54659b51fe16..56e4139b9032 100644
--- a/sound/pci/hda/hda_generic.h
+++ b/sound/pci/hda/hda_generic.h
@@ -48,6 +48,7 @@ struct nid_path {
 	unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */
 	bool active:1;		/* activated by driver */
 	bool pin_enabled:1;	/* pins are enabled */
+	bool pin_fixed:1;	/* path with fixed pin */
 	bool stream_enabled:1;	/* stream is active */
 };
 
@@ -343,5 +344,6 @@ unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
 					   hda_nid_t nid,
 					   unsigned int power_state);
 void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on);
+int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin);
 
 #endif /* __SOUND_HDA_GENERIC_H */
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 86b944a6b0ed..7e531d5cde51 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4225,6 +4225,12 @@ static int stac_parse_auto_config(struct hda_codec *codec)
 	if (err < 0)
 		return err;
 
+	if (spec->vref_mute_led_nid) {
+		err = snd_hda_gen_fix_pin_power(codec, spec->vref_mute_led_nid);
+		if (err < 0)
+			return err;
+	}
+
 	/* setup analog beep controls */
 	if (spec->anabeep_nid > 0) {
 		err = stac_auto_create_beep_ctls(codec,
-- 
2.3.3

  reply	other threads:[~2015-03-20 17:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  8:50 [PATCH 0/4] More aggressive PM for HD-audio Takashi Iwai
2015-03-18  8:50 ` [PATCH 1/4] ALSA: hda - Simplify PCM setup overrides Takashi Iwai
2015-03-18  8:50 ` [PATCH 2/4] ALSA: hda - Support advanced power state controls Takashi Iwai
2015-03-18  8:50 ` [PATCH 3/4] ALSA: hda - Use the new power control for VIA codecs Takashi Iwai
2015-03-18  8:50 ` [PATCH 4/4] ALSA: hda - Adjust power of beep widget and outputs Takashi Iwai
2015-03-18 19:34 ` [PATCH 0/4] More aggressive PM for HD-audio David Henningsson
2015-03-18 20:02   ` Takashi Iwai
2015-03-20 16:20 ` David Henningsson
2015-03-20 16:28   ` Takashi Iwai
2015-03-20 17:18     ` Takashi Iwai [this message]
2015-03-20 17:33       ` Takashi Iwai
2015-03-21  6:38   ` Hui Wang
     [not found]     ` <5513FA8B.402@canonical.com>
2015-03-26 13:10       ` Takashi Iwai
2015-03-26 13:52         ` Takashi Iwai
2015-03-27  0:11           ` Hui Wang
2015-03-30  6:53             ` hwang4
2015-04-04 10:31               ` Takashi Iwai
2015-04-09  6:54               ` hwang4
2015-04-09  6:56                 ` Takashi Iwai
2015-04-09  6:59                   ` David Henningsson
2015-04-09  8:35                     ` Takashi Iwai

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=s5h384zziy7.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=david.henningsson@canonical.com \
    --cc=hui.wang@canonical.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox