All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Hui Wang <hui.wang@canonical.com>,
	David Henningsson <david.henningsson@canonical.com>
Subject: [PATCH 2/5] ALSA: hda/generic - Fix wrong initial power state for fixed pins
Date: Thu,  9 Apr 2015 10:40:35 +0200	[thread overview]
Message-ID: <1428568838-21550-3-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1428568838-21550-1-git-send-email-tiwai@suse.de>

When the widget power-saving is enabled, the first automute hook
invocation checks through the whole pins and it also tries to
synchronize the power state.  However, this results in a wrong state
because it calls unconditionally snd_hda_jack_detect_state().
This patch adds a check of jack detectability before the actual jack
detection call.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_generic.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index afc6b1b0898c..46b559832d2c 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -3959,6 +3959,14 @@ static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid,
 	return changed;
 }
 
+/* check the jack status for power control */
+static bool detect_pin_state(struct hda_codec *codec, hda_nid_t pin)
+{
+	if (!is_jack_detectable(codec, pin))
+		return true;
+	return snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT;
+}
+
 /* power up/down the paths of the given pin according to the jack state;
  * power = 0/1 : only power up/down if it matches with the jack state,
  *       < 0   : force power up/down to follow the jack sate
@@ -3973,7 +3981,8 @@ static hda_nid_t set_pin_power_jack(struct hda_codec *codec, hda_nid_t pin,
 	if (!codec->power_save_node)
 		return 0;
 
-	on = snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT;
+	on = detect_pin_state(codec, pin);
+
 	if (power >= 0 && on != power)
 		return 0;
 	return set_path_power(codec, pin, on, -1);
@@ -4225,8 +4234,7 @@ static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
 		if (codec->power_save_node) {
 			bool on = !mute;
 			if (on)
-				on = snd_hda_jack_detect_state(codec, nid)
-					!= HDA_JACK_NOT_PRESENT;
+				on = detect_pin_state(codec, nid);
 			set_path_power(codec, nid, on, -1);
 		}
 	}
-- 
2.3.5

  parent reply	other threads:[~2015-04-09  8:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09  8:40 [PATCH 0/5] HD-audio widget power-save fixes Takashi Iwai
2015-04-09  8:40 ` [PATCH 1/5] ALSA: hda/generic - Check power state cap at updating the widget power Takashi Iwai
2015-04-09  8:40 ` Takashi Iwai [this message]
2015-04-10  8:51   ` [PATCH 2/5] ALSA: hda/generic - Fix wrong initial power state for fixed pins Raymond Yau
2015-04-10  9:36     ` Takashi Iwai
2015-04-09  8:40 ` [PATCH 3/5] ALSA: hda/generic - Make snd_hda_gen_path_power_filter() always applicable Takashi Iwai
2015-04-09  8:40 ` [PATCH 4/5] ALSA: hda/generic - Don't override power_filter when power_save_node is set Takashi Iwai
2015-04-09  8:40 ` [PATCH 5/5] ALSA: hda/realtek - Fix the regression by widget power-saving Takashi Iwai
     [not found] ` <55264288.4020807@canonical.com>
2015-04-09 10:45   ` [PATCH 0/5] HD-audio widget power-save fixes 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=1428568838-21550-3-git-send-email-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 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.