Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp216159pxj; Fri, 28 May 2021 02:10:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5hwlBUq6Y1DiW+AT8+AO1fFiwIFEhx7a5OVD4v+cCCG2223jxvHktZwAM0dD7d0plJ1XK X-Received: by 2002:a05:6638:b84:: with SMTP id b4mr7542243jad.122.1622193022176; Fri, 28 May 2021 02:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622193022; cv=none; d=google.com; s=arc-20160816; b=WC/FtCM234hZNYIjVaYRDQV+nbHG2eWy5fSrq2ISY3atephDu0wVTZWRHYga04V2HK O/IAao00lGctk6ntRzW/CHoIrpBAmVX+6BdjwswozF2f/dPB6o/LqMZGeRSQVpNvxa0f 3Q/5EfXUJIXpkb/J03jYpMT9IEcuD2+GphNxnIXVXWYxU489GY46JyTXmgJua/D9u53Q fLdY2t3uxfAkQtxbWitJ47lIb9BDUG5v96MA4sOSQy11zuaqotDJ9hZAbbAATpjt8di1 kMVCZPK34DIWE8ixIgORZT1IpjilTiJBnBr7zdA+A9Mf8ML2p0Psv/iPwnk7h65Wgtdq uHNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=WikFeXUsmrrkxHoqNQkeIN24f6mCbXXF6hqcFhk6uOo=; b=PAf7aCYlVTUxuB5I8yrT31sJLGwRIc2c2PceF0gsn/12yvX5KploWd8aeUCfRZ8Z2a m421Gli2bgbdRntqnpXXlDV+2eX0iPpXX9adZdUP3LzBb4bAbj7Lbi3fnxQgN1CWekz+ jr/MqAyTL/3+dv8OaDNu2bldAX0m+Ufbley6kvao1VKMfQcME/pKco0X9kFeiyVK/UoH XecINGE9LmFScDgoy8Sm3SmmdaVJ2TgSYebI9Tt1OJfwlnTBav6OBi7JjHUs123lq8qc 80JmGs8A/ZGhHCkWYY8Cos/vNak8kiA9OwxqG3wkFtlWW1384SICDOOBT/o6MN6xPWbU 3Zow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m3WX96qI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r188si5736226jac.90.2021.05.28.02.10.08; Fri, 28 May 2021 02:10:22 -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=@linaro.org header.s=google header.b=m3WX96qI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbhE1Itg (ORCPT + 99 others); Fri, 28 May 2021 04:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233054AbhE1Itf (ORCPT ); Fri, 28 May 2021 04:49:35 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB2CC061760 for ; Fri, 28 May 2021 01:47:59 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id f17so239879wmf.2 for ; Fri, 28 May 2021 01:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=WikFeXUsmrrkxHoqNQkeIN24f6mCbXXF6hqcFhk6uOo=; b=m3WX96qICHaTwGdy1NTiEy0Bor5LJzIqd0AP7gvFdxjoHxm2NxhtUULDF+9lQOSw3Y wm4U2se5OJH6V8mzypZm1OGQngILCHudP6E82dzKt1S1V5RcsTTE/k4kgMZz4caIIhET Ob9PhEEtEAQYiFx7Z/Sq2yj5GedDe7Px/ozVUTDyZkuGMhGy+jxnlhG6ROQMVvdsWSmp IT2kPqeKN14BTJdDze23+I0GigtrfJ2WrDQE3A1wtx8tzMIIY0iH+GEgVUTcjr/YQ6X/ YIRmEy2wgLbQT4CNB9MC6NxyRFy6dATRINmmsosVlGlX6L+7d14bBW4AO7nEJXN3giaj RH8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WikFeXUsmrrkxHoqNQkeIN24f6mCbXXF6hqcFhk6uOo=; b=DTLItmO9EIcbWWYINgDKGupAUJlncjJp5tncPA+/YK9mdW0HD3P0mhlBg2b3AvUhZb 7h1l5jhcuQeAkL6iyJLy8JxmIKAhbBntg8aDp0GP3y9ND4yQnif9fjxyCwd2xkJ0itNX 7uqKQdV8aMlhRMAE2PWOfaFzgBLYH4oP68UuXbPUH+l2CFKk8JhTtVBzNe24i6UjqLrk vHaCzwCZfkkt3t60YavPBZRFvquAoary2ZsSxjSde3ZeofZmNLz/b02ocq3XwoEb9jKv 3NCzKcJ1epsyxyzPWy5aD/FAFRIXKgkRYRo3DhJmZ3/n+KNuapXGD4yRIgYzNEViRKFa fn5w== X-Gm-Message-State: AOAM532IQKERGAEI+j/Ah1Us1CtsSrA4i74BYUgJqcPq0B74Mj4fJUj8 gQEwvkzEB2yeWH0d5z3NTbr4Lw== X-Received: by 2002:a05:600c:2219:: with SMTP id z25mr7450903wml.78.1622191677970; Fri, 28 May 2021 01:47:57 -0700 (PDT) Received: from [192.168.86.34] (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.googlemail.com with ESMTPSA id f8sm5547546wmg.43.2021.05.28.01.47.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 May 2021 01:47:57 -0700 (PDT) Subject: Re: [PATCH v3] ASoC: qcom: lpass-cpu: Fix pop noise during audio capture begin To: Srinivasa Rao Mandadapu , agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, rohitkr@codeaurora.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, judyhsiao@chromium.org References: <20210524142114.18676-1-srivasam@codeaurora.org> From: Srinivas Kandagatla Message-ID: <9a4bbab8-91a2-f195-b77a-5234d46a2c0a@linaro.org> Date: Fri, 28 May 2021 09:47:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20210524142114.18676-1-srivasam@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/05/2021 15:21, Srinivasa Rao Mandadapu wrote: > This patch fixes PoP noise of around 15ms observed during audio capture begin. > Enables BCLK and LRCLK in snd_soc_dai_ops prepare call for introducing some delay > before capture start and clock enable. > > Co-developed-by: Judy Hsiao > Signed-off-by: Judy Hsiao > Signed-off-by: Srinivasa Rao Mandadapu > --- > Changes Since V2: > -- Updated comments as per linux style > -- Removed unrelated changes. > Changes Since V1: > -- Enableed BCLK and LRCLK in dai ops prepare API instead of startup API > -- Added comments > > sound/soc/qcom/lpass-cpu.c | 54 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c > index 28c7497344e3..1855eae22aad 100644 > --- a/sound/soc/qcom/lpass-cpu.c > +++ b/sound/soc/qcom/lpass-cpu.c > @@ -93,9 +93,21 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, > struct snd_soc_dai *dai) > { > struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); > + struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; > + unsigned int id = dai->driver->id; > > clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]); > - clk_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); > + /* > + * To ensure BCLK/LRCLK disabled even in device node validation > + * Will not impact if disabled in lpass_cpu_daiops_trigger() > + * suspend. > + */ > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > + regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_DISABLE); > + else > + regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_DISABLE); > + > + clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); > } > > static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, > @@ -275,6 +287,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, > case SNDRV_PCM_TRIGGER_START: > case SNDRV_PCM_TRIGGER_RESUME: > case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: > + /* > + * To ensure lpass BCLK/LRCLK is enabled during > + * device resume. Will not impact if enabled in lpass_cpu_daiops_prepare(). > + */ prepare should have already ensured that isn't it? > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > ret = regmap_fields_write(i2sctl->spken, id, > LPAIF_I2SCTL_SPKEN_ENABLE); > @@ -296,6 +312,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, > case SNDRV_PCM_TRIGGER_STOP: > case SNDRV_PCM_TRIGGER_SUSPEND: > case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > + /* > + * To ensure lpass BCLK/LRCLK is disabled during > + * device suspend. > + */ > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > ret = regmap_fields_write(i2sctl->spken, id, > LPAIF_I2SCTL_SPKEN_DISABLE); > @@ -315,12 +335,44 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, > return ret; > } > [Snip ... > +static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, > + struct snd_soc_dai *dai) > +{ > + struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); > + struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; > + unsigned int id = dai->driver->id; > + int ret; > + /* > + * To ensure lpass BCLK/LRCLK is enabled bit before > + * playback/capture data flow starts. > + */ > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > + ret = regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_ENABLE); > + else > + ret = regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_ENABLE); > + > + if (ret) { > + dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret); > + return ret; > + } > + > + ret = clk_enable(drvdata->mi2s_bit_clk[id]); > + > + if (ret) { > + dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret); > + clk_disable(drvdata->mi2s_osr_clk[id]); > + return ret; > + } > + return 0; > +} > + ----] If prepare is enabling the clk and the i2s enable bits, then why do we need to do the same thing in trigger? Also the clk enable count is going up twice (once in prepare and trigger) and we can never be able to disable the clk as there is is no corresponding disable for this prepare path. Also note that prepare can be called multiple times. --srini > const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { > .set_sysclk = lpass_cpu_daiops_set_sysclk, > .startup = lpass_cpu_daiops_startup, > .shutdown = lpass_cpu_daiops_shutdown, > .hw_params = lpass_cpu_daiops_hw_params, > .trigger = lpass_cpu_daiops_trigger, > + .prepare = lpass_cpu_daiops_prepare, > }; > EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); > >