]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ALSA: hda: fix jack detection with Realtek codecs when in D3
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Mon, 12 Oct 2020 10:27:04 +0000 (13:27 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:10:52 +0000 (10:10 +0100)
commit a6e7d0a4bdb02a7a3ffe0b44aaa8842b7efdd056 upstream.

In case HDA controller becomes active, but codec is runtime suspended,
jack detection is not successful and no interrupt is raised. This has
been observed with multiple Realtek codecs and HDA controllers from
different vendors. Bug does not occur if both codec and controller are
active, or both are in suspend. Bug can be easily hit on desktop systems
with no built-in speaker.

The problem can be fixed by powering up the codec once after every
controller runtime resume. Even if codec goes back to suspend later, the
jack detection will continue to work. Add a flag to 'hda_codec' to
describe codecs that require this flow from the controller driver.
Modify __azx_runtime_resume() to use pm_request_resume() to make the
intent clearer.

Mark all Realtek codecs with the new forced_resume flag.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209379
Cc: Kailang Yang <kailang@realtek.com>
Co-developed-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201012102704.794423-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/sound/hda_codec.h
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_realtek.c

index 0fea49bfc5e8641080971f69897e32ebc1921ac1..73827b7d17e008d70cfaf0edc0888756bf0d3edd 100644 (file)
@@ -253,6 +253,7 @@ struct hda_codec {
        unsigned int force_pin_prefix:1; /* Add location prefix */
        unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
        unsigned int relaxed_resume:1;  /* don't resume forcibly for jack */
+       unsigned int forced_resume:1; /* forced resume for jack */
        unsigned int mst_no_extra_pcms:1; /* no backup PCMs for DP-MST */
 
 #ifdef CONFIG_PM
index 36a9dbc33aa01f798aeebefabf29564bdcacec9a..476a8b871daa1a033185a262f7db7f8d329f6ba7 100644 (file)
@@ -1001,12 +1001,14 @@ static void __azx_runtime_resume(struct azx *chip, bool from_rt)
        azx_init_pci(chip);
        hda_intel_init_chip(chip, true);
 
-       if (status && from_rt) {
-               list_for_each_codec(codec, &chip->bus)
-                       if (!codec->relaxed_resume &&
-                           (status & (1 << codec->addr)))
-                               schedule_delayed_work(&codec->jackpoll_work,
-                                                     codec->jackpoll_interval);
+       if (from_rt) {
+               list_for_each_codec(codec, &chip->bus) {
+                       if (codec->relaxed_resume)
+                               continue;
+
+                       if (codec->forced_resume || (status & (1 << codec->addr)))
+                               pm_request_resume(hda_codec_dev(codec));
+               }
        }
 
        /* power down again for link-controlled chips */
index d4f17b46589271621bc9f49cb1aa8ad94c2db4d1..88aea388670320409076b36a9bbc26d2c542e3f5 100644 (file)
@@ -1150,6 +1150,7 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
        codec->single_adc_amp = 1;
        /* FIXME: do we need this for all Realtek codec models? */
        codec->spdif_status_reset = 1;
+       codec->forced_resume = 1;
        codec->patch_ops = alc_patch_ops;
 
        err = alc_codec_rename_from_preset(codec);