mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: alsa-devel@alsa-project.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: regression: from 3.8 to 3.9: headphones output no sound on Intel HDA, codec VIA VT1802
Date: Mon, 03 Jun 2013 12:05:12 +0200	[thread overview]
Message-ID: <s5h8v2rzezr.wl%tiwai@suse.de> (raw)
In-Reply-To: <CALxABCZVDrLMH+Y=b6CP8rehM5q7vikjoGNgi=S5jHKZuSSGsw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

At Fri, 31 May 2013 21:36:45 +0200,
Alex Riesen wrote:
> 
> On Fri, May 31, 2013 at 8:00 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > At Fri, 31 May 2013 17:32:16 +0200, Alex Riesen wrote:
> >> On Fri, May 31, 2013 at 3:05 PM, Takashi Iwai <tiwai@suse.de> wrote:
> >> > Below is a series of patches.  For simplicity, I just attach them, not
> >> > inlining to the mail.  They should be applicable cleanly to 3.9.4 as
> >> > well.  Let me know if this works.  If this still doesn't work, I need
> >> > to rewrite the patch to correct the pin-ctl / EAPD of the headphone
> >> > pin after changing the speaker pin.
> >>
> >> Still does not work. The results are for 3.9.4 + patches:
> >>
> >>   http://familie-riesen.de/~raa/public/test/dpc-automute-vol-pinctl.tar.bz2
> >>
> >
> > Grrr, EAPD on 0x25 seems reset by EAPD on 0x24 being turned off.
> > We need to apply the patch of the last week again in the end.
> > The revised one is below.  Please apply it on the top of the previous
> > three patches.
> 
> Nope. Logs:
> 
>   http://familie-riesen.de/~raa/public/test/keep_eapd_on.tar.bz2

Thanks.  I think I found the culprit of the problem with the pin ctl
value now.  This happens only when the power save is used or
suspended, and it happens only on VT1802.  That's why I couldn't
reproduce the issue with the emulator, and it wasn't reported from
users of other VIA codecs.

In anyway, the patch series below are the fixes.  Scratch the whole
previous patches and apply them on clean 3.9 (or 3.10-rc) tree.
Hopefully we sorted out all issues now.


thanks,

Takashi


[-- Attachment #2: 0001-ALSA-hda-via-Disable-broken-dynamic-power-control.patch --]
[-- Type: application/octet-stream, Size: 1459 bytes --]

>From 087c2e3b4e062573dbbc8a50b9208992e3768dcf Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 31 May 2013 13:54:10 +0200
Subject: [PATCH 1/4] ALSA: hda/via - Disable broken dynamic power control

Since the transition to the generic parser, the actual routes used
there don't match always with the assumed static paths in some
set_widgets_power_state callbacks.  This results in the wrong power
setup in the end.  As a temporary workaround, we need to disable the
calls together with the non-functional dynamic power control enum.

Reported-by: Alex Riesen <raa.lkml@gmail.com>
Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/patch_via.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index e0dadcf..75fdb51 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -231,9 +231,14 @@ static void vt1708_update_hp_work(struct hda_codec *codec)
 
 static void set_widgets_power_state(struct hda_codec *codec)
 {
+#if 0 /* FIXME: the assumed connections don't match always with the
+       * actual routes by the generic parser, so better to disable
+       * the control for safety.
+       */
 	struct via_spec *spec = codec->spec;
 	if (spec->set_widgets_power_state)
 		spec->set_widgets_power_state(codec);
+#endif
 }
 
 static void update_power_state(struct hda_codec *codec, hda_nid_t nid,
-- 
1.8.3


[-- Attachment #3: 0002-ALSA-hda-Allow-setting-automute-automic-hooks-after-.patch --]
[-- Type: application/octet-stream, Size: 3413 bytes --]

>From 77afe0e94884ae40de29cd813a1fb7ddee583591 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 31 May 2013 14:10:03 +0200
Subject: [PATCH 2/4] ALSA: hda - Allow setting automute/automic hooks after
 parsing

Some codec drivers (VIA codecs and some Realtek fixups) set the
automute and automic hooks after calling
snd_hda_gen_parse_auto_config().  In the current code, the hook
pointers are referred only in snd_hda_gen_parse_auto_config() and
passed to snd_hda_jack_detect_enable_callback(), thus changing the
hook values won't change the actually called callbacks properly.

This patch fixes this bug by setting the static functions as the
primary callback functions for the jack detection, and let them
calling the appropriate hooks dynamically.

Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_generic.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index ae85bbd2..fbc10b6 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -3875,6 +3875,36 @@ static void update_automute_all(struct hda_codec *codec)
 		snd_hda_gen_mic_autoswitch(codec, NULL);
 }
 
+/* call appropriate hooks */
+static void call_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack)
+{
+	struct hda_gen_spec *spec = codec->spec;
+	if (spec->hp_automute_hook)
+		spec->hp_automute_hook(codec, jack);
+	else
+		snd_hda_gen_hp_automute(codec, jack);
+}
+
+static void call_line_automute(struct hda_codec *codec,
+			       struct hda_jack_tbl *jack)
+{
+	struct hda_gen_spec *spec = codec->spec;
+	if (spec->line_automute_hook)
+		spec->line_automute_hook(codec, jack);
+	else
+		snd_hda_gen_line_automute(codec, jack);
+}
+
+static void call_mic_autoswitch(struct hda_codec *codec,
+				struct hda_jack_tbl *jack)
+{
+	struct hda_gen_spec *spec = codec->spec;
+	if (spec->mic_autoswitch_hook)
+		spec->mic_autoswitch_hook(codec, jack);
+	else
+		snd_hda_gen_mic_autoswitch(codec, jack);
+}
+
 /*
  * Auto-Mute mode mixer enum support
  */
@@ -4009,9 +4039,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
 		snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n",
 			    nid);
 		snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
-						    spec->hp_automute_hook ?
-						    spec->hp_automute_hook :
-						    snd_hda_gen_hp_automute);
+						    call_hp_automute);
 		spec->detect_hp = 1;
 	}
 
@@ -4024,9 +4052,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
 				snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid);
 				snd_hda_jack_detect_enable_callback(codec, nid,
 								    HDA_GEN_FRONT_EVENT,
-								    spec->line_automute_hook ?
-								    spec->line_automute_hook :
-								    snd_hda_gen_line_automute);
+								    call_line_automute);
 				spec->detect_lo = 1;
 			}
 		spec->automute_lo_possible = spec->detect_hp;
@@ -4068,9 +4094,7 @@ static bool auto_mic_check_imux(struct hda_codec *codec)
 		snd_hda_jack_detect_enable_callback(codec,
 						    spec->am_entry[i].pin,
 						    HDA_GEN_MIC_EVENT,
-						    spec->mic_autoswitch_hook ?
-						    spec->mic_autoswitch_hook :
-						    snd_hda_gen_mic_autoswitch);
+						    call_mic_autoswitch);
 	return true;
 }
 
-- 
1.8.3


[-- Attachment #4: 0003-ALSA-hda-Add-keep_eapd_on-flag-to-generic-parser.patch --]
[-- Type: application/octet-stream, Size: 2368 bytes --]

>From 05909d5c679cf7c9a8a5bc663677c066a546894f Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 31 May 2013 19:55:54 +0200
Subject: [PATCH 3/4] ALSA: hda - Add keep_eapd_on flag to generic parser

VT1802 codec seems to reset EAPD of other pins in the hardware level,
and this was another reason of the silent headphone output on some
machines.  As a workaround, introduce a new flag indicating to keep
the EPAD on to the generic parser, and set it in patch_via.c.

Reported-by: Alex Riesen <raa.lkml@gmail.com>
Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_generic.c | 2 ++
 sound/pci/hda/hda_generic.h | 1 +
 sound/pci/hda/patch_via.c   | 1 +
 3 files changed, 4 insertions(+)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index fbc10b6..cfdb917 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -788,6 +788,8 @@ static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable)
 		return;
 	if (codec->inv_eapd)
 		enable = !enable;
+	if (spec->keep_eapd_on && !enable)
+		return;
 	snd_hda_codec_update_cache(codec, pin, 0,
 				   AC_VERB_SET_EAPD_BTLENABLE,
 				   enable ? 0x02 : 0x00);
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
index 54e6651..7620031 100644
--- a/sound/pci/hda/hda_generic.h
+++ b/sound/pci/hda/hda_generic.h
@@ -222,6 +222,7 @@ struct hda_gen_spec {
 	unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */
 	unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */
 	unsigned int own_eapd_ctl:1; /* set EAPD by own function */
+	unsigned int keep_eapd_on:1; /* don't turn off EAPD automatically */
 	unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */
 	unsigned int indep_hp:1; /* independent HP supported */
 	unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 75fdb51..a6c3856 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -136,6 +136,7 @@ static struct via_spec *via_new_spec(struct hda_codec *codec)
 		spec->codec_type = VT1708S;
 	spec->no_pin_power_ctl = 1;
 	spec->gen.indep_hp = 1;
+	spec->gen.keep_eapd_on = 1;
 	spec->gen.pcm_playback_hook = via_playback_pcm_hook;
 	return spec;
 }
-- 
1.8.3


[-- Attachment #5: 0004-ALSA-hda-via-Fix-wrongly-cleared-pins-after-suspend-.patch --]
[-- Type: application/octet-stream, Size: 1472 bytes --]

>From 5a6f294e87974e6ec68d7113553ffd975d83bf15 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 3 Jun 2013 11:17:38 +0200
Subject: [PATCH 4/4] ALSA: hda/via - Fix wrongly cleared pins after suspend on
 VT1802

VIA driver has a special suspend handling only for VT1802 to reduce
the pop noise.  During the transition to the generic parser, the
behavior of snd_hda_set_pin_ctl() was also changed to modify the
cached values, too.  And this caused a regression where the pin is
still cleared even after the resume (including the resume from power
save), resulting in the silent output.

The fix is simply to replace snd_hda_set_pin_ctl() with the explicit
call of snd_hda_codec_write() again.

Reported-by: Alex Riesen <raa.lkml@gmail.com>
Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/patch_via.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index a6c3856..e524554 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -484,7 +484,9 @@ static int via_suspend(struct hda_codec *codec)
 		/* Fix pop noise on headphones */
 		int i;
 		for (i = 0; i < spec->gen.autocfg.hp_outs; i++)
-			snd_hda_set_pin_ctl(codec, spec->gen.autocfg.hp_pins[i], 0);
+			snd_hda_codec_write(codec, spec->gen.autocfg.hp_pins[i],
+					    0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+					    0x00);
 	}
 
 	return 0;
-- 
1.8.3


  reply	other threads:[~2013-06-03 10:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-12  9:53 Alex Riesen
2013-05-13 15:26 ` Takashi Iwai
2013-05-13 15:53   ` Takashi Iwai
2013-05-13 18:24     ` Alex Riesen
2013-05-14  5:59       ` Takashi Iwai
2013-05-14 10:58         ` Takashi Iwai
2013-05-14 19:55           ` Alex Riesen
2013-05-15  5:20             ` Takashi Iwai
2013-05-15 20:17               ` Alex Riesen
2013-05-16 11:00                 ` Takashi Iwai
2013-05-16 20:10                   ` Alex Riesen
2013-05-17  6:04                     ` Takashi Iwai
2013-05-18 20:29                       ` Alex Riesen
2013-05-22 21:06                         ` Alex Riesen
2013-05-23 16:34                           ` Takashi Iwai
2013-05-23 18:38                             ` Alex Riesen
2013-05-24 13:29                         ` Takashi Iwai
2013-05-24 16:36                           ` Alex Riesen
2013-05-24 17:22                             ` Takashi Iwai
2013-05-24 21:32                               ` Alex Riesen
2013-05-29 15:42                                 ` Takashi Iwai
2013-05-31 10:31                                   ` Alex Riesen
2013-05-31 13:05                                     ` Takashi Iwai
2013-05-31 15:32                                       ` Alex Riesen
2013-05-31 18:00                                         ` Takashi Iwai
2013-05-31 19:36                                           ` Alex Riesen
2013-06-03 10:05                                             ` Takashi Iwai [this message]
2013-06-03 18:49                                               ` Alex Riesen
2013-06-04  9:48                                                 ` Takashi Iwai
2013-05-14 19:54         ` Alex Riesen

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=s5h8v2rzezr.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raa.lkml@gmail.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

all inboxes | Powered by JetHome®