Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1633189ybz; Thu, 16 Apr 2020 12:39:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJE5Ah1phH5u7IYWrpnt2+h/OrUbixXSAb2RmvXsRm8Qm60xEbzxsxlq/YxSFoWy7vPEPzx X-Received: by 2002:aa7:d794:: with SMTP id s20mr19559455edq.141.1587065966654; Thu, 16 Apr 2020 12:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587065966; cv=none; d=google.com; s=arc-20160816; b=EYSjE1UETBUF1icMjstdKAA71GuOnPTrjD35c5/cjU30ILRFOPB4jzSVOLwVaj6fic ACaRhpLiOD2djpR37mBr/g0K3rUh0n1t/guG/kYwJPHFCqXrbyyuMMsbDdDfY/4uS+7j tw24XoAdrHpIXObEyFr9waFv8+V7Mcd/PVNukC0gbbE3ObZfQ+/rqAM4jeWLbi3esEbt RXr5d2X9eMd9ng6PzhSFZcAyOyF5ESbTlJ2qsA/HK2a84AJ4xoxJIghiR4qdQLfMCQ5i ezgQsPPUBNW+k1RFfvpBitU7Amh+Eg+0fRnsg93BE1IUHB463Lu6aPTiaE03ITnDJoBY 0xNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8/VbOfBFaCwDUwKZZAcq/LfWKv+Ev8Rui8snAcqwljI=; b=Rep+IdOSeKGRoHnFthnAtocSm4lvLg85bIMW4Nd7s9C2kYE+IfOCsR0vurMvMyHx/w IL30tt4MQdOHiBics6uUFM30lS2pfaWgW7iWwvysGRhIl7ntaEujIMed4eK38mfz4Es7 5izAWGkfhvHPN6ZwuPfK6ZZ/vBHCSP2vE2T+PkOJkhuV8bpZFgLtXIyHULMJJ93D3ib1 F9pkybaw5x/D3uZrRnuree4FEcMy5VDe7vcfS5fKjkJKT1SiMe+wsBDag1ZBExhK9zVN gLuCCVHDmpyxzYxJbDNMjvMugb3fKKDVdFuhtL34q0OhxYBCUx+GAIJ+wyOBSaMDgUwq Egqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K0kTEB9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si5524229ejq.460.2020.04.16.12.39.03; Thu, 16 Apr 2020 12:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K0kTEB9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896249AbgDPNab (ORCPT + 99 others); Thu, 16 Apr 2020 09:30:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:36806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2895662AbgDPN2C (ORCPT ); Thu, 16 Apr 2020 09:28:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99C1221BE5; Thu, 16 Apr 2020 13:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587043681; bh=ZoXdcEmcQ1RwgthyQjDT9hIpwmYyb5aoD+aUunKYaxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0kTEB9kXdLAWBIxcJ3AX3GzP0HMYZ0oDRGon+rLDdXFXkTzaqMQpVs/4XlRRKK3H ZvXr3KnV3B+beIjlA9BzeFQ3cuYzNdkpvOLnthni6bV2RvrZvIk+um97S6Ibv4Sgck WDE0Er43Tk3SsHZTJ7cCq+lrwByc9oN/a73LRBJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hebb , Takashi Iwai Subject: [PATCH 4.19 056/146] ALSA: hda/realtek - Set principled PC Beep configuration for ALC256 Date: Thu, 16 Apr 2020 15:23:17 +0200 Message-Id: <20200416131250.559681370@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131242.353444678@linuxfoundation.org> References: <20200416131242.353444678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hebb commit c44737449468a0bdc50e09ec75e530f208391561 upstream. The Realtek PC Beep Hidden Register[1] is currently set by patch_realtek.c in two different places: In alc_fill_eapd_coef(), it's set to the value 0x5757, corresponding to non-beep input on 1Ah and no 1Ah loopback to either headphones or speakers. (Although, curiously, the loopback amp is still enabled.) This write was added fairly recently by commit e3743f431143 ("ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236") and is a safe default. However, it happens in the wrong place: alc_fill_eapd_coef() runs on module load and cold boot but not on S3 resume, meaning the register loses its value after suspend. Conversely, in alc256_init(), the register is updated to unset bit 13 (disable speaker loopback) and set bit 5 (set non-beep input on 1Ah). Although this write does run on S3 resume, it's not quite enough to fix up the register's default value of 0x3717. What's missing is a set of bit 14 to disable headphone loopback. Without that, we end up with a feedback loop where the headphone jack is being driven by amplified samples of itself[2]. This change eliminates the update in alc256_init() and replaces it with the 0x5757 write from alc_fill_eapd_coef(). Kailang says that 0x5757 is supposed to be the codec's default value, so using it will make debugging easier for Realtek. Affects the ALC255, ALC256, ALC257, ALC235, and ALC236 codecs. [1] Newly documented in Documentation/sound/hd-audio/realtek-pc-beep.rst [2] Setting the "Headphone Mic Boost" control from userspace changes this feedback loop and has been a widely-shared workaround for headphone noise on laptops like the Dell XPS 13 9350. This commit eliminates the feedback loop and makes the workaround unnecessary. Fixes: e1e8c1fdce8b ("ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236") Cc: stable@vger.kernel.org Signed-off-by: Thomas Hebb Link: https://lore.kernel.org/r/bf22b417d1f2474b12011c2a39ed6cf8b06d3bf5.1585584498.git.tommyhebb@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/patch_realtek.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -379,7 +379,9 @@ static void alc_fill_eapd_coef(struct hd case 0x10ec0215: case 0x10ec0233: case 0x10ec0235: + case 0x10ec0236: case 0x10ec0255: + case 0x10ec0256: case 0x10ec0257: case 0x10ec0282: case 0x10ec0283: @@ -391,11 +393,6 @@ static void alc_fill_eapd_coef(struct hd case 0x10ec0300: alc_update_coef_idx(codec, 0x10, 1<<9, 0); break; - case 0x10ec0236: - case 0x10ec0256: - alc_write_coef_idx(codec, 0x36, 0x5757); - alc_update_coef_idx(codec, 0x10, 1<<9, 0); - break; case 0x10ec0275: alc_update_coef_idx(codec, 0xe, 0, 1<<0); break; @@ -3249,7 +3246,13 @@ static void alc256_init(struct hda_codec alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */ alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */ alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15); - alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/ + /* + * Expose headphone mic (or possibly Line In on some machines) instead + * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See + * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of + * this register. + */ + alc_write_coef_idx(codec, 0x36, 0x5757); } static void alc256_shutup(struct hda_codec *codec)