From patchwork Fri Oct 1 07:41:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RGVyZWsgW+aWueW+t+e+qV0=?= X-Patchwork-Id: 12529823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA79CC433F5 for ; Fri, 1 Oct 2021 07:42:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E75D61A55 for ; Fri, 1 Oct 2021 07:42:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0E75D61A55 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E02DA16C9; Fri, 1 Oct 2021 09:41:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E02DA16C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633074153; bh=I4VjGsGJ1T+JnBTUww/bt/4tBWDGPpaJxP3s1O9CDRQ=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Zkt/788zcsiIyqm6Yrzf6tUVmxXrypkhhy6slG8ZtKu8Tvh6CvRgPMemG6mNXHJID hJGQwZTTO2XSwCK8Hbh4A8ps8l7ZmbepnijxuLnaFsZwcmKUyGmSPTTUo4AMhQvKbZ M6x2SKY2B3Of6SNNMNs58roHof23DkdqyqlhmPIg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A89D2F80227; Fri, 1 Oct 2021 09:41:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0EA14F8026D; Fri, 1 Oct 2021 09:41:39 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C0BA8F801F7 for ; Fri, 1 Oct 2021 09:41:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C0BA8F801F7 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 1917fJnT5009139, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36503.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.71/5.88) with ESMTPS id 1917fJnT5009139 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 1 Oct 2021 15:41:19 +0800 Received: from RTEXMBS01.realtek.com.tw (172.21.6.94) by RTEXH36503.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 1 Oct 2021 15:41:19 +0800 Received: from localhost.localdomain (172.22.234.227) by RTEXMBS01.realtek.com.tw (172.21.6.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 1 Oct 2021 15:41:18 +0800 From: To: , Subject: [PATCH 1/2] ASoC: rt5682s: Enable ASRC auto-disable to fix pop during jack plug-in while playback Date: Fri, 1 Oct 2021 15:41:12 +0800 Message-ID: <20211001074113.2223-1-derek.fang@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [172.22.234.227] X-ClientProxiedBy: RTEXH36503.realtek.com.tw (172.21.6.25) To RTEXMBS01.realtek.com.tw (172.21.6.94) X-KSE-ServerInfo: RTEXMBS01.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: trusted connection X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Deterministic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 10/01/2021 07:26:00 X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: =?big5_tw?b?Q2xlYW4sIGJhc2VzOiAyMDIxLzEwLzEgpFekyCAwNjow?= =?big5_tw?b?MTowMA==?= X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-ServerInfo: RTEXH36503.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback Cc: oder_chiou@realtek.com, jack.yu@realtek.com, alsa-devel@alsa-project.org, lars@metafoo.de, albertchen@realtek.com, Derek Fang , kevin_chen_ym@realtek.com, shumingf@realtek.com, flove@realtek.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Derek Fang When codec's ASRC was enabled, the DA and AD filters use the reference clk which tracks the I2S clks. And if the I2S clks' timing of open and close are not expected, this patch allows the filters to switch to use sysclk if ASRC's ref clks disappeared and could fix the below possible issues: 1. Avoid DA filter to keep surplus samples. 2. Avoid that AD filter works failed during dapm's power on. For example, if I2S clks were closed before dacdat during playback off due to jack unplug, it causes ref clks disappeared and DA filter remained some samples which will produce pop noise on the next HP playback. ASRC auto-disable could clear the samples during the playback off. Signed-off-by: Derek Fang --- sound/soc/codecs/rt5682s.c | 3 +++ sound/soc/codecs/rt5682s.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index 122adeb7beb1..5ae54a51ff9e 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -1061,6 +1061,9 @@ int rt5682s_sel_asrc_clk_src(struct snd_soc_component *component, RT5682S_FILTER_CLK_SEL_MASK, clk_src << RT5682S_FILTER_CLK_SEL_SFT); } + snd_soc_component_update_bits(component, RT5682S_PLL_TRACK_11, + RT5682S_ASRCIN_AUTO_CLKOUT_MASK, RT5682S_ASRCIN_AUTO_CLKOUT_EN); + return 0; } EXPORT_SYMBOL_GPL(rt5682s_sel_asrc_clk_src); diff --git a/sound/soc/codecs/rt5682s.h b/sound/soc/codecs/rt5682s.h index 55f1febb81e9..59ba4ea3b062 100644 --- a/sound/soc/codecs/rt5682s.h +++ b/sound/soc/codecs/rt5682s.h @@ -994,6 +994,19 @@ #define RT5682S_ASRCIN_FTK_M2_MASK (0x7 << 4) #define RT5682S_ASRCIN_FTK_M2_SFT 4 +/* ASRC Control 11 (0x008c) */ +#define RT5682S_ASRCIN_AUTO_CLKOUT_MASK (0x1 << 5) +#define RT5682S_ASRCIN_AUTO_CLKOUT_EN (0x1 << 5) +#define RT5682S_ASRCIN_AUTO_CLKOUT_DIS (0x0 << 5) +#define RT5682S_ASRCIN_AUTO_RST_MASK (0x1 << 4) +#define RT5682S_ASRCIN_AUTO_RST_EN (0x1 << 4) +#define RT5682S_ASRCIN_AUTO_RST_DIS (0x0 << 4) +#define RT5682S_SEL_LRCK_DET_MASK (0x3) +#define RT5682S_SEL_LRCK_DET_DIV8 (0x3) +#define RT5682S_SEL_LRCK_DET_DIV4 (0x2) +#define RT5682S_SEL_LRCK_DET_DIV2 (0x1) +#define RT5682S_SEL_LRCK_DET_DIV1 (0x0) + /* Depop Mode Control 1 (0x008e) */ #define RT5682S_OUT_HP_L_EN (0x1 << 6) #define RT5682S_OUT_HP_R_EN (0x1 << 5) From patchwork Fri Oct 1 07:41:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RGVyZWsgW+aWueW+t+e+qV0=?= X-Patchwork-Id: 12529825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D759EC433EF for ; Fri, 1 Oct 2021 07:43:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37D6461A7B for ; Fri, 1 Oct 2021 07:43:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 37D6461A7B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9C71E16DE; Fri, 1 Oct 2021 09:42:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9C71E16DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633074197; bh=y0cA86dh0WXypVKo9VP8Phrf8u3gkxQHIrb3ssKox6Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OcEzMR7k00G0uSBYyMmrqvSlC8yourPBLSMv5k5b1G45giO3l7VI+FM6f8qEqMoCl vhJFQgZYNv+FRtF5wQtjNrgBiTUhKlyS+GxdfMCMoG8k5CVza7FNBw5AME9Ciu3TP5 +4MI4xPJplj11OWlAHCH+a+xqPzxDMDPx8XjAHVg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1B901F80272; Fri, 1 Oct 2021 09:41:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3DD36F80165; Fri, 1 Oct 2021 09:41:40 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9E4F7F80165 for ; Fri, 1 Oct 2021 09:41:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E4F7F80165 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 1917fJvM5009143, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36503.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.71/5.88) with ESMTPS id 1917fJvM5009143 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 1 Oct 2021 15:41:19 +0800 Received: from RTEXMBS01.realtek.com.tw (172.21.6.94) by RTEXH36503.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 1 Oct 2021 15:41:19 +0800 Received: from localhost.localdomain (172.22.234.227) by RTEXMBS01.realtek.com.tw (172.21.6.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 1 Oct 2021 15:41:18 +0800 From: To: , Subject: [PATCH 2/2] ASoC: rt5682s: Fix HP noise caused by SAR mode switch when the system resumes Date: Fri, 1 Oct 2021 15:41:13 +0800 Message-ID: <20211001074113.2223-2-derek.fang@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211001074113.2223-1-derek.fang@realtek.com> References: <20211001074113.2223-1-derek.fang@realtek.com> MIME-Version: 1.0 X-Originating-IP: [172.22.234.227] X-ClientProxiedBy: RTEXH36503.realtek.com.tw (172.21.6.25) To RTEXMBS01.realtek.com.tw (172.21.6.94) X-KSE-ServerInfo: RTEXMBS01.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: trusted connection X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Deterministic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 10/01/2021 07:26:00 X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: =?big5_tw?b?Q2xlYW4sIGJhc2VzOiAyMDIxLzEwLzEgpFekyCAwNjow?= =?big5_tw?b?MTowMA==?= X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-ServerInfo: RTEXH36503.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback Cc: oder_chiou@realtek.com, jack.yu@realtek.com, alsa-devel@alsa-project.org, lars@metafoo.de, albertchen@realtek.com, Derek Fang , kevin_chen_ym@realtek.com, shumingf@realtek.com, flove@realtek.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Derek Fang When the system resumes from S3, if the system plays a beep, there is continuous "Zizi.." noise from HP that could be heard. It is caused by the SAR mode switch during the combo jack re-detection which be executed parallelly in a workqueue after the system resumes. This patch changes the behavior of SAR mode switch to avoid this issue. Signed-off-by: Derek Fang --- sound/soc/codecs/rt5682s.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index 5ae54a51ff9e..639a50fa95e2 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -779,7 +779,8 @@ static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_ RT5682S_FAST_OFF_MASK, RT5682S_FAST_OFF_EN); snd_soc_component_update_bits(component, RT5682S_SAR_IL_CMD_1, RT5682S_SAR_SEL_MB1_2_MASK, val << RT5682S_SAR_SEL_MB1_2_SFT); - rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1); + if (!snd_soc_dapm_get_pin_status(&component->dapm, "SAR")) + rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1); rt5682s_enable_push_button_irq(component); break; default: @@ -1313,18 +1314,6 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, } } -static int is_headset_type(struct snd_soc_dapm_widget *w, - struct snd_soc_dapm_widget *sink) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); - - if ((rt5682s->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) - return 1; - - return 0; -} - static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -1372,6 +1361,10 @@ static int sar_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); + + if ((rt5682s->jack_type & SND_JACK_HEADSET) != SND_JACK_HEADSET) + return 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1784,7 +1777,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { {"CLKDET SYS", NULL, "MCLK0 DET PWR"}, {"BST1 CBJ", NULL, "IN1P"}, - {"BST1 CBJ", NULL, "SAR", is_headset_type}, + {"BST1 CBJ", NULL, "SAR"}, {"RECMIX1L", "CBJ Switch", "BST1 CBJ"}, {"RECMIX1L", NULL, "RECMIX1L Power"}, @@ -1890,7 +1883,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { {"HP Amp", NULL, "DAC L1"}, {"HP Amp", NULL, "DAC R1"}, {"HP Amp", NULL, "CLKDET SYS"}, - {"HP Amp", NULL, "SAR", is_headset_type}, + {"HP Amp", NULL, "SAR"}, {"HPOL", NULL, "HP Amp"}, {"HPOR", NULL, "HP Amp"}, @@ -2823,8 +2816,9 @@ static int rt5682s_resume(struct snd_soc_component *component) if (rt5682s->hs_jack) { rt5682s->jack_type = 0; + rt5682s_sar_power_mode(component, SAR_PWR_NORMAL, 0); mod_delayed_work(system_power_efficient_wq, - &rt5682s->jack_detect_work, msecs_to_jiffies(250)); + &rt5682s->jack_detect_work, msecs_to_jiffies(0)); } return 0;