Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1322163ybz; Thu, 16 Apr 2020 07:11:51 -0700 (PDT) X-Google-Smtp-Source: APiQypLyAbDeCptPA+y/UmitbsSOd/P2d/fcl0BGxED0Tztw2iH+2qBl61SxV+FmSz1m6wFrubjH X-Received: by 2002:a17:906:5608:: with SMTP id f8mr10222259ejq.190.1587046311800; Thu, 16 Apr 2020 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587046311; cv=none; d=google.com; s=arc-20160816; b=L6gjWHIIvhfN6Eo5si0BiaBu6oP2zAgPg75PRMGggsbNcC8crIUjXwAacl+xSkSnuV k3QXyDeZQ1vZqiju966Nyfo6QtVTNVghszfwQ51dt3tpbNVKkQVA9IuYTpr1brDJgZ/S WT33XhJF4txlzFIClXJjTQlzCdA4lx1rQy4SJQDU0GXRmlKaWw0vqkC1KUd3IJ/fJZO0 hEyNWjiMcovuYS1709WPLNxxmuMdP6J+69tm4BdYrBwxLh7818Rfya3HbVodQmn8deVb KBOtEqqeKNrAmcGQixoTkdFVX0JNpGeUt/OhakAyqsG2b8tlpKiYT9owhgrp5a3vrH3A gidQ== 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=fTEPpCfLGwk3PI0Vu5oc4iMyfh2m5UilrymqZREvPts=; b=SIFHEMlI1t+BDowy9Truh+H7mbA4peyrqirEuqeZ585sU9wkwxm7KC/vgJySrLsZBn MDlHKC4aMSzugxKX4DAXBSvbCw0dPQwDFG7Tg5+GhdTpQ+GecxLIVJedAnJc6SVbXDzN qdA6eRJ/kIdEQX5hp4cDYajl7vxFni93UWNzVsBiVTNMQUT9R0nqTzGQF2gooEE2jDBO O7/OS+GMxdhQHom53tZBystPtp/5Li2+6MlmNW9MdXrqUrmpLcFPWONfvpnCATVc93KT sIyEuun6Kx6NdFvj6ShrH1mALGOqtnlkfr8K5ZmvMv0QP2hS4d6zYzNgDwxZooDUAY2R v8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mP0c4mPQ; 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 i14si5643529edx.256.2020.04.16.07.11.22; Thu, 16 Apr 2020 07:11:51 -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=mP0c4mPQ; 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 S1732716AbgDPOIi (ORCPT + 99 others); Thu, 16 Apr 2020 10:08:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:59410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898543AbgDPNpt (ORCPT ); Thu, 16 Apr 2020 09:45:49 -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 3D97221734; Thu, 16 Apr 2020 13:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044747; bh=nJdRoDoxFz3pSFS9qZM5LkWIVbVtBTHPKmC7MDR6Yj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mP0c4mPQXQYyvA0NXk7ofxeKs7yBTaZT0sbLRBUrvAUI8roXFjr7uGbTTXRLdVGAj g5yYmdON69HrLUii4FiVoJzfIBEJ0h9E17xvRCZKocXKmaDM6YJTFClnxlAw/U0CTE ++E7+Wzlw4bemvfMS5rfDE+jfrdBasPN+CDKaHaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hebb , Takashi Iwai Subject: [PATCH 5.4 083/232] ALSA: hda/realtek - Set principled PC Beep configuration for ALC256 Date: Thu, 16 Apr 2020 15:22:57 +0200 Message-Id: <20200416131325.454220158@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@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 @@ -368,7 +368,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: @@ -380,11 +382,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; @@ -3371,7 +3368,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)