From patchwork Fri Oct 27 10:57:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 739085 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D4B20C25B67 for ; Fri, 27 Oct 2023 11:00:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 002A7A4D; Fri, 27 Oct 2023 12:59:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 002A7A4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698404411; bh=Lu2PJetzLbuTwsyEbZUs5w16F02PpIxjpeR63OofwJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=H/dLukYw4kfAPNX5ArSwSkf+ETyxRu5aeX2Ih4SMfoPQzEpjTatVeNXLEaz6Y/EAL /neYiPEY2OyxCH6aIm/uPtXZpjfBXmpkMXGkMaybAWOd6vIxByiOzizCi7VdZ3sVWQ 0arhMQZoKeGB2gru1R81eWd6I77zyQvbrbAPrPc8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 65ABCF8057A; Fri, 27 Oct 2023 12:58:18 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C2FB9F80571; Fri, 27 Oct 2023 12:58:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6B864F8019B; Fri, 27 Oct 2023 12:58:12 +0200 (CEST) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 772FDF8010B for ; Fri, 27 Oct 2023 12:58:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 772FDF8010B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=U9PrFfpb Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40839652b97so14064935e9.3 for ; Fri, 27 Oct 2023 03:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698404286; x=1699009086; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9XkBdStWyOQZPgBS6S/Ka3+9ogTtzOlDV9P3Ay7BAQI=; b=U9PrFfpbtvD8DRQ/fuMmcy7xTQlzAtsCFmH7zlALAidEdDzy5i543YYGzm73Vknwv1 9DZuMmC70gZaDesoL1rcAH6tw142J5kmObbimxgCtL24U1W3EFa2S/zdFsMgpWIiTxNw EKQgwx3fBvaE5uf4S9LLtU8SoayaaLeDJkIGSXhNhq1ZzTj46CLYdKKRbOlnxpZC1Qh1 v/nLDkftIlfENJjkQ9VGg6R0ZZbuCX/0+kTx8dwOubqhgPSvXinsVvUY+7/TqpPtmS9L Uff10U0+x1Ep0CD5RFEUWFWp6Avjjm2JjsPvjs1NpsqDD+Xk5f6detL/jaqyqnxHX0zX /1CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698404286; x=1699009086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XkBdStWyOQZPgBS6S/Ka3+9ogTtzOlDV9P3Ay7BAQI=; b=qygm0p8P5Uspauk3B21USgOiNuXKMIKUfqBsUDlnbF1gXnr3otO1/9K4ucLT967cqU w2w9fEDPrK/9duUUYjw7doGGjAq1VBOMF5YeiET1v69tEH1BuLy8sR3K8qGC+sN3Oego uq++ic+pl6LBH3eGO858336lG82SBvo0f+ck5CZzXK/2mO4AufKlQp60Os8pKvOfGN5Y Ne7o2lc9ukvevU+9bQNo0Nlees6eF0Y55H/4Sld3JX5/a5zgVD9DL/SicS4sPBLRaaKo zXD35xw+qfzP0WzlMei9jYEaP7KnXVNIr5NAtWcCSYLyqqZkD4PLNAdWetiT7hhBtK2w xLiw== X-Gm-Message-State: AOJu0YyJVUUOKTzWBRW3ezT9cWb2VLshQC3c6kEcYd4b5tnNxBZEWxPe 0SH4TULNhQk4QWNTHpj+uKqx0Q== X-Google-Smtp-Source: AGHT+IE3n/7ZTwMVhcJx5Pj0MGRIdZXTm5/giEYVamfl4WpRmVJi152Yyfa8zz62tvthZTBvwdHjVA== X-Received: by 2002:a05:600c:3d9a:b0:408:5ba9:d707 with SMTP id bi26-20020a05600c3d9a00b004085ba9d707mr2017805wmb.16.1698404286317; Fri, 27 Oct 2023 03:58:06 -0700 (PDT) Received: from srini-hackbox.lan ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ay32-20020a05600c1e2000b004065daba6casm4819626wmb.46.2023.10.27.03.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 03:58:05 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: johan@kernel.org, perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [RFC PATCH 1/2] ASoC: soc-dai: add flag to mute and unmute stream during trigger Date: Fri, 27 Oct 2023 11:57:46 +0100 Message-Id: <20231027105747.32450-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20231027105747.32450-1-srinivas.kandagatla@linaro.org> References: <20231027105747.32450-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: T4UPHSHY6EMPTPDU2VRIZ4ODNR2IGLQJ X-Message-ID-Hash: T4UPHSHY6EMPTPDU2VRIZ4ODNR2IGLQJ X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In some setups like Speaker amps which are very sensitive, ex: keeping them unmute without actual data stream for very short duration results in a static charge and results in pop and clicks. To minimize this, provide a way to mute and unmute such codecs during trigger callbacks. Signed-off-by: Srinivas Kandagatla --- include/sound/soc-dai.h | 1 + sound/soc/soc-dai.c | 7 +++++++ sound/soc/soc-pcm.c | 12 ++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index e3906ecda740..5827b4d882fc 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -355,6 +355,7 @@ struct snd_soc_dai_ops { /* bit field */ unsigned int no_capture_mute:1; + unsigned int mute_unmute_on_trigger:1; }; struct snd_soc_cdai_ops { diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 02dd64dea179..28d8c6c3d3b2 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -641,6 +641,10 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, ret = soc_dai_trigger(dai, substream, cmd); if (ret < 0) break; + + if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 0, substream->stream); + soc_dai_mark_push(dai, substream, trigger); } break; @@ -651,6 +655,9 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, if (rollback && !soc_dai_mark_match(dai, substream, trigger)) continue; + if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 1, substream->stream); + r = soc_dai_trigger(dai, substream, cmd); if (r < 0) ret = r; /* use last ret */ diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 3aa6b988cb4b..0f9f4da25158 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -703,8 +703,10 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd, if (snd_soc_dai_active(dai) == 0) soc_pcm_set_dai_params(dai, NULL); - if (snd_soc_dai_stream_active(dai, substream->stream) == 0) - snd_soc_dai_digital_mute(dai, 1, substream->stream); + if (snd_soc_dai_stream_active(dai, substream->stream) == 0) { + if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 1, substream->stream); + } } } @@ -898,8 +900,10 @@ static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd, snd_soc_dapm_stream_event(rtd, substream->stream, SND_SOC_DAPM_STREAM_START); - for_each_rtd_dais(rtd, i, dai) - snd_soc_dai_digital_mute(dai, 0, substream->stream); + for_each_rtd_dais(rtd, i, dai) { + if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 0, substream->stream); + } out: return soc_pcm_ret(rtd, ret); From patchwork Fri Oct 27 10:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 738717 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4D005C25B47 for ; Fri, 27 Oct 2023 10:59:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AA113DED; Fri, 27 Oct 2023 12:59:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AA113DED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698404395; bh=sF9D0JCTLYXdS4i8IZaSR3Q2EKQCyuGcuEHmOF/AsQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EkWNDP34haFGewAHjLzCJ6He5RtDf5/dB62a67I0zMxvA9YSfbGVT+Volkx7SKydk CQkjTto1vLknM/ZRmseUuGGLv96qZb+hsqQAomuHRd8jsqJ9GmyAU/kajqNvqfqVHm xru2WpR68hvnAhIrqbeJwK6aPg5oAcpRiX74iWV8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B508FF80568; Fri, 27 Oct 2023 12:58:16 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 25269F8055B; Fri, 27 Oct 2023 12:58:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 70503F8020D; Fri, 27 Oct 2023 12:58:11 +0200 (CEST) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C465AF8012B for ; Fri, 27 Oct 2023 12:58:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C465AF8012B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Fjb+XeaS Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4083cd39188so14030965e9.2 for ; Fri, 27 Oct 2023 03:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698404288; x=1699009088; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bnRkBO9T7mpu/9qbQ4qd8eFU+MMR5Opxp/fD1o8ihl0=; b=Fjb+XeaSn9gK203xRTnFPj5LfaWDZzkbkYoxPAsV9SuvbQpP0x7emy/E6VZ7VMcHoM Tw++/2yiLenI+VWmQyzW63F1U7gP2eN+AgIITso45xsBeQSDtvvrAko12nLbxbe/K9Zw kySCmvz+mAMPyVMGYWw1fxQnIKj+AP8N/M2z0S5nUZ/MYD2Yiacu/5kpYHimtMVWMPbR flYQpXNQ6cSFJymEUwHux/dZwGlCb+gmc+sKpVA11FkTQnTmem+WHwVVpYAbxfNR1eYR gJYGxSVGNcXu4Kkc9K1c1WPC1dSqdygN48E4zft1AMNCHqc6WQiAi40d6mnI+7SwFFe5 m94Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698404288; x=1699009088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bnRkBO9T7mpu/9qbQ4qd8eFU+MMR5Opxp/fD1o8ihl0=; b=KUUzUAdy08ebGvHxeSwH6pW5+Wcc2jy6cEVcmAD98RZWznXNwpmzT6B8YhrgL+9SFN PVTxR46gnJSgiAPLDRFgETimIFVkvYUjjPqBw8//uOBBM9onQ/cbqqySLS4D/h3pQWCI b1kfAAY8CLjLDPV1WiHuBqF/40YM2TQ7yUGXuDkf9g3S2FDGQ1FDix8LAds1nIu0cP19 Tz1chuB08R4qQBsmOgWpu5NsMzAj3SVTMZm7K21FQuXiMOT6WD1mHBqtMXiQrErzwpFU yWOvS4cITElAbeNPYjeqMihhhYl9oyEIV4SiEY40Qs/9lid7v7cOjmjjV1krExvIuVAp 3W6A== X-Gm-Message-State: AOJu0Yzzf7mgZopSis9i+Nzrb0KTIL6iS0A6Odg4dUXWax74IAiEmDqR tFN7ybzLpOGAQGm90UMYnDkbzg== X-Google-Smtp-Source: AGHT+IGebDNbdDKX/IZobIxUnkODGsr9PdTVtrGQ1bCRfn1/ZgdLC1oMrxdvfJdXxEp3U1pvkCGVew== X-Received: by 2002:a05:600c:19d1:b0:405:3955:5881 with SMTP id u17-20020a05600c19d100b0040539555881mr1831887wmq.36.1698404287889; Fri, 27 Oct 2023 03:58:07 -0700 (PDT) Received: from srini-hackbox.lan ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ay32-20020a05600c1e2000b004065daba6casm4819626wmb.46.2023.10.27.03.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 03:58:06 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: johan@kernel.org, perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [RFC PATCH 2/2] ASoC: codecs: wsa883x: make use of new mute_unmute_on_trigger flag Date: Fri, 27 Oct 2023 11:57:47 +0100 Message-Id: <20231027105747.32450-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20231027105747.32450-1-srinivas.kandagatla@linaro.org> References: <20231027105747.32450-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: EONBUGGW4MJHNR5ZLU7R73HAGEXOBQXK X-Message-ID-Hash: EONBUGGW4MJHNR5ZLU7R73HAGEXOBQXK X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In the current setup the PA is left unmuted even when the Soundwire ports are not started streaming. This can lead to click and pop sounds during start. There is a same issue in the reverse order where in the PA is left unmute even after the data stream is stopped, the time between data stream stopping and port closing is long enough to accumulate DC on the line resulting in Click/Pop noise during end of stream. making use of new mute_unmute_on_trigger flag is helping a lot with this Click/Pop issues reported on this Codec Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wsa883x.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index e40d583a1ce6..4ea550b0601b 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1203,9 +1203,6 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, break; } - snd_soc_component_write_field(component, WSA883X_DRE_CTL_1, - WSA883X_DRE_GAIN_EN_MASK, - WSA883X_DRE_GAIN_FROM_CSR); if (wsa883x->port_enable[WSA883X_PORT_COMP]) snd_soc_component_write_field(component, WSA883X_DRE_CTL_0, WSA883X_DRE_OFFSET_MASK, @@ -1218,9 +1215,6 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, snd_soc_component_write_field(component, WSA883X_PDM_WD_CTL, WSA883X_PDM_EN_MASK, WSA883X_PDM_ENABLE); - snd_soc_component_write_field(component, WSA883X_PA_FSM_CTL, - WSA883X_GLOBAL_PA_EN_MASK, - WSA883X_GLOBAL_PA_ENABLE); break; case SND_SOC_DAPM_PRE_PMD: @@ -1346,6 +1340,7 @@ static const struct snd_soc_dai_ops wsa883x_dai_ops = { .hw_free = wsa883x_hw_free, .mute_stream = wsa883x_digital_mute, .set_stream = wsa883x_set_sdw_stream, + .mute_unmute_on_trigger = true, }; static struct snd_soc_dai_driver wsa883x_dais[] = {