From nobody Wed Dec 17 08:10:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FA98C25B67 for ; Fri, 27 Oct 2023 10:58:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345725AbjJ0K6P (ORCPT ); Fri, 27 Oct 2023 06:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbjJ0K6K (ORCPT ); Fri, 27 Oct 2023 06:58:10 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3E32196 for ; Fri, 27 Oct 2023 03:58:07 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40790b0a224so14184375e9.0 for ; Fri, 27 Oct 2023 03:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698404286; x=1699009086; darn=vger.kernel.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=DrZB9rR9N44MHZTVCkAT9mN0+vIM9/W7I89j1vwwkU4+ACc4OMvAjWdZssoQEsv/wr 09BkJk7HAaP56doSuE9L+zmExeeO7f0HdyDZ9y77/J80T57oCQ+qZxbEG9DFplo3LCfX PwbveLuOHg75kx6L3DaKHky1MFhk36R7RfDlA9eSBxjLUfRMbS5euLaLXOBdovVCq2Xl 6CBT2kLyx7d/B9yuO1T9DGYAs4P7nmbACCdBwTsXT343A65zlsRE8QeNMGGimTVKbCEr jvhAg7UcKsjRCKs9s7C3Vfc7OfJqcGBbYxwlpGq9NKf06iKlDs1ZLS2flqaTIkfKGTec RvvQ== 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=vy7S5oqKJ1fp1ywCUQ3jv/euiINumZRS4dlKrSJpgbNXWd5mTlt7nVrBT+8kmHN6/Y XfXVkBiRD1xJn5DLv2JmxkVZmygFznMM9yBQrAOTrM8ROE7mAIcwOKLsOvFONwiX3yC8 Bm0XWjdz2fnNLcpZJ1TzzjNr+ot9Gg5NJqCqvE7xegvZ1GwhQBYbWiUzURNOVdtGwFdP b2x+/oN8u+M1F50k6EFQ0bZ+9wxFKlNoXenUxA7U2wYYkF5ho9QnBopm8vOTjhEez92g dPaMb7oAfQBB2Lgyk/ilOQSYvae3kR/quy0zWAu3CFvhQI9RbKklH3rAStNUa58l0igH Jrig== X-Gm-Message-State: AOJu0Yxev6e6gukA69ovsQmWeIhBOdDZEhrsu9afLi0amZybcxhk/iL7 Cmvtd3cBLZ6YlA6y8UpFrma0+A== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Tested-by: Johan Hovold --- 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 { =20 /* bit field */ unsigned int no_capture_mute:1; + unsigned int mute_unmute_on_trigger:1; }; =20 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 =3D 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 *s= ubstream, if (rollback && !soc_dai_mark_match(dai, substream, trigger)) continue; =20 + if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 1, substream->stream); + r =3D soc_dai_trigger(dai, substream, cmd); if (r < 0) ret =3D 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 *r= td, if (snd_soc_dai_active(dai) =3D=3D 0) soc_pcm_set_dai_params(dai, NULL); =20 - if (snd_soc_dai_stream_active(dai, substream->stream) =3D=3D 0) - snd_soc_dai_digital_mute(dai, 1, substream->stream); + if (snd_soc_dai_stream_active(dai, substream->stream) =3D=3D 0) { + if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) + snd_soc_dai_digital_mute(dai, 1, substream->stream); + } } } =20 @@ -898,8 +900,10 @@ static int __soc_pcm_prepare(struct snd_soc_pcm_runtim= e *rtd, snd_soc_dapm_stream_event(rtd, substream->stream, SND_SOC_DAPM_STREAM_START); =20 - 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); + } =20 out: return soc_pcm_ret(rtd, ret); --=20 2.21.0 From nobody Wed Dec 17 08:10:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FF5CC25B67 for ; Fri, 27 Oct 2023 10:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345714AbjJ0K6S (ORCPT ); Fri, 27 Oct 2023 06:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345705AbjJ0K6M (ORCPT ); Fri, 27 Oct 2023 06:58:12 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F6D18F for ; Fri, 27 Oct 2023 03:58:09 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40839652b97so14065115e9.3 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=vger.kernel.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=tTGEbMgGo14cjFdrj+vbbt48kF5PZMQgAnAwFpzNOORnHHbASE2AxcmWdT58jLGBlA 1CuT9Viv9KZNjn5XdjCB8DBRRADE5K6Ep8IScP9mi7vMj//TnfUdxhKq2i1CjRtg3Z3Q M+JJjtTRoQkK2/STw5mH0PHDp+FzGuoub4tTGNa8mjfTnwMb+jLPpmperB806jscGPv/ 6D3FLw6Qphv9wDiRr5v4kj/f3ThxWezueOa9JCjB4W7edQR6NicqeLGkFXRYuTakJnMC N7SKinQTVKGQbRibfe2h3Vgeg9Iy0oS8KJgHmEqnZQEUqJdvA+Tbg0yymZMGnIrNskUo zsWQ== 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=ioRhJcFRXXLcZG6iTqBASuXCUWDxIRcYzVp2mjR4KCbCfzgaWMg1qUL2YCsv8/4pSr t2YbW5TQmj2G602DfGQu8SmkbidrSoH5LyA/48tVpV4rekfTpTV6WqOlb0QP6Fwwoouk 6Lo/hCFYGaUI6MurODyf/T02nMJd2gC0Kj9UhSmcgyL1kG8Nozhs/XIKfevISpDG/8qG B/lRoqXuzpfWYlRqt9Tvcd3E6kCxat6agbmocXXmN1mwP78j7xvGWKIixXA0Pc8ywf3a YiY3pgZNf2MT1ZaO3BB1zNiBRhNHcmPzy3zKzoXkWZxuFj0XObFhzo7xXmN0uqlL0oCP H8Kw== X-Gm-Message-State: AOJu0YzpSwXcxel0XZKla7VajKH2EEFnLi25fDh6GQ4Pi23SOD3Ap5Rn 88u8NK8hBzOIIP5A0OBa3Cw+fw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Tested-by: Johan Hovold --- 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_wid= get *w, break; } =20 - 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_wid= get *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); =20 break; case SND_SOC_DAPM_PRE_PMD: @@ -1346,6 +1340,7 @@ static const struct snd_soc_dai_ops wsa883x_dai_ops = =3D { .hw_free =3D wsa883x_hw_free, .mute_stream =3D wsa883x_digital_mute, .set_stream =3D wsa883x_set_sdw_stream, + .mute_unmute_on_trigger =3D true, }; =20 static struct snd_soc_dai_driver wsa883x_dais[] =3D { --=20 2.21.0