Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp538031ybz; Wed, 22 Apr 2020 03:14:23 -0700 (PDT) X-Google-Smtp-Source: APiQypIiq/uaZZ/1eHy2tfy71XLB/mL5KKUd6lBbXLZlnLdzf9l44meXnyNzBEAo7G40VNYro2B0 X-Received: by 2002:a17:907:11de:: with SMTP id va30mr25498269ejb.121.1587550463825; Wed, 22 Apr 2020 03:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587550463; cv=none; d=google.com; s=arc-20160816; b=DYJsd//LKWdAnpfwN2AYWD3d9MhqRU0yBoNpjhKF4ssRq2VpNVhfRy4FiXdnY9opDo 8D2p/lvgdX3YnoHzqD4t8HEfaxvMbtGWPyYAnVzBZEhLIV881Rn8FEtjM1DTU/kDOBkk rL5rLUX0wfp4i80a0RgoYtn1A15xgSZrZJbccPnqeZFRB4gPn0ZL/qYAg4HHneZQ/fPv 7F4WOomSkZ8Lo345/GzgD9e61+zynsrKpJTWxvNfxYYwjMxkjDONBTlLCvLeWIUXMa2w 2+oKVe23qVui5CyODu/CYkq3zTXmiSsSXtJ/D8uo3+4FNYAbyQwwB41j5b1nzuLNc1rO fQag== 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=k0K0GP0k4hRwS5ayb511Y5q8xhBrL0MaM4MiTkOvHws=; b=DV+ThQhgpssOqOgXHIEqD6U4squL4hOg9M1bjtgt6AJOdxmJ//4Pvk/+eO87ynjMSb ppEVJAA+kLwUQ2yuLbaONb5/MDVqPz1B1kAQqfgK3THvJTjde9Xc37XpiEzDcDrOdoxE QM/5wJeu4WVZZ5yUQv/1eAV7NG4iI6XO68LYQ04JiJmOoB0BLIzDTa2h1z5FfOk1Qj6T 8PHZ5ktYJzMNpJNtwpBmhbGGKdNb/aGjYCSgszWBVT4/BIn5Odk95+gQ3tIIzzEfKgdm UCthqNqjmQpa36T5sPIvu/S8EzG1bq6Lxy+hzP8DOsN/tRUlW2JXFUSyIrgRA315rQ1j voPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bj0yE5wG; 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 n8si3202341eju.329.2020.04.22.03.14.00; Wed, 22 Apr 2020 03:14:23 -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=bj0yE5wG; 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 S1728923AbgDVKJy (ORCPT + 99 others); Wed, 22 Apr 2020 06:09:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728910AbgDVKJu (ORCPT ); Wed, 22 Apr 2020 06:09:50 -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 4EE3F20575; Wed, 22 Apr 2020 10:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587550189; bh=6q4OAloMiXQpA7u3d14ReQ3KM8lmt0J112lT/o4l9Qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj0yE5wGnTwjYrXCMMiUT/d+gt8ezbAHTnx+FwCIKiu7LVEqQwmGzBflO7F9nMtyf gBg/GgMvbW9eoPxzik7aq6iJErMo7zUcsMb1b6Nrp1Co/LF6jAsJLf9ifkXWPvhBBI RpNFp6eTjlvpjdmORbLfJy3xnHo6mzJjv26J5qmY= 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.14 044/199] ALSA: hda/realtek - Set principled PC Beep configuration for ALC256 Date: Wed, 22 Apr 2020 11:56:10 +0200 Message-Id: <20200422095102.361238297@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095057.806111593@linuxfoundation.org> References: <20200422095057.806111593@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 @@ -333,7 +333,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: @@ -345,11 +347,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; @@ -3122,7 +3119,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)