Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2926375pxj; Sun, 23 May 2021 15:58:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+Mmgwfrcm+LT94gv4jbeTvbhxOtzzCEMxw0lRbl2dCGFXEjVC4YsigufnRXz9tHHKQDpG X-Received: by 2002:aa7:d818:: with SMTP id v24mr21820203edq.290.1621810722312; Sun, 23 May 2021 15:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621810722; cv=none; d=google.com; s=arc-20160816; b=0nEF4zpo/zq+si8qVv8XXtgI5oBqQ9jKNFPMnm0np3CFhLEHL8wFTS0y4r+52uDwGv 6fc1wKlUu+nZGWuUq+xZrbaZ8u7v6VkI/0NrNNmlnNRd1dZPbyazejgYwFv4uiZpNh/S iq0UiOItbfpsBqhpceQQRlD1wrzyW5BnjP3ja6TCYW24Dv0ok6bfsX28SA5uVa8GclW1 bIpG3rKTSq4O2Z35L+haMERnTCBgjcTwMlkvCVq9Xv98Y210cXwpNXTWQcRAf18CqtZZ 0oDVldkG6cpMICIt83lYAEaBH4VDkfTDUhtFJRwW9K4pG3iLeuQHhjV4vA+FRT/PziKx IVSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=1K/Zf6qVFEuzf3LeeUWAQu7y8CgaCqs3dPr1inenPpI=; b=A4GCrfZ6s3Jb9gb/ojLRm0FKVNWc1pwWjr4/ENw/3Fvcz8TAenZeuxSBBQiPVOZcL+ GKfc6SSuPNvkaFbuPsmFQBqNnTVGRjDu1jtsGUsXM6FD7Xy4w6o6HZpCd6VJ55TFCgyi r7kUY1FQDOx9y6M2herBGNBGwtkxtGblQ4iVWHhHybKE0fUOVdY2vsD7QEC+cqU846Xy z51WLsfEXXKBIBFCt63yCp+4db3jThZ0Lq9BEt5r7oHyKwO/LVNp2m8kWKoidh7WBRKh 9BTtSiNUZr4F1fPlt5fUR7arvJgyZMP5dgZNdx7K9lqw+q3dBNfO28ZVJ/zA1RtH95aF m63w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bYyk8FSf; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si14226644ejq.486.2021.05.23.15.58.08; Sun, 23 May 2021 15:58:42 -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=@chromium.org header.s=google header.b=bYyk8FSf; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbhEWWzp (ORCPT + 99 others); Sun, 23 May 2021 18:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232003AbhEWWzo (ORCPT ); Sun, 23 May 2021 18:55:44 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9983EC061756 for ; Sun, 23 May 2021 15:54:16 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id v19-20020a0568301413b0290304f00e3d88so23488041otp.4 for ; Sun, 23 May 2021 15:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to; bh=1K/Zf6qVFEuzf3LeeUWAQu7y8CgaCqs3dPr1inenPpI=; b=bYyk8FSfT1TV7UPs81TdtN0954QCJeCRzD7K0EVI+uGfyiPaYKGqlEg9VcNPFobDZT K7yUNwmnlXYrwbHLyx7KXSi0kufc2cCzDekTyd3wgQMi6NT4/zuHNPGL/5EumWXT2Lnr qtVK+3VcB4PdJWIvq5vjekqXuQzzkAXFQaoxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to; bh=1K/Zf6qVFEuzf3LeeUWAQu7y8CgaCqs3dPr1inenPpI=; b=DlNpT326VE3BcVEAKe+vdVvRTCLuTecB8epTYKxhxBydpxBntsAHy4RS3xc4CyoOkR bhAxp97nRaeBEl2u9NEUlK4vCfC+kc32FsLmuqkFGB9DvyZvvpHj2ma4iKD4Sb9pU0wy R+lC2xCkeFtu3KWfhOCynVVoqOtCyPvraC6Na+PYAnsYhVQotuZhCbE4DPNQxcwDQbAA cbYWhSNQChVK0/Si03A37tkmAFZhSyjnFkMxfkARBhcqjACgN3X3Bqwx5yCci2nlr1cU Ee2R8O5JSYXbrB3omHNPCX6GGIq20YJDKNvPaeoyIlO++Cc2/j9nqYbSTGWnAH/aULul 8eJA== X-Gm-Message-State: AOAM532vnNxjtkJ7Z4RPkiGmFEz9y0VIDSagrJLJLvJNM+v+UshN/Y86 MqGTeFHq7wc2hfAyVn46Vih8MhLDAk1tYtFy509JLw== X-Received: by 2002:a05:6830:1f51:: with SMTP id u17mr3389243oth.25.1621810455819; Sun, 23 May 2021 15:54:15 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 23 May 2021 15:54:15 -0700 MIME-Version: 1.0 In-Reply-To: <20210520142432.29869-1-srivasam@codeaurora.org> References: <20210520142432.29869-1-srivasam@codeaurora.org> From: Stephen Boyd User-Agent: alot/0.9.1 Date: Sun, 23 May 2021 15:54:15 -0700 Message-ID: Subject: Re: [PATCH v2] ASoC: qcom: lpass-cpu: Fix pop noise during audio capture begin To: Srinivasa Rao Mandadapu , agross@kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, bjorn.andersson@linaro.org, broonie@kernel.org, devicetree@vger.kernel.org, judyhsiao@chromium.org, lgirdwood@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, perex@perex.cz, plai@codeaurora.org, robh+dt@kernel.org, rohitkr@codeaurora.org, srinivas.kandagatla@linaro.org, tiwai@suse.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Srinivasa Rao Mandadapu (2021-05-20 07:24:32) > 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. > > Signed-off-by: Judy Hsiao > Signed-off-by: Srinivasa Rao Mandadapu The SoB chain is weird. If Judy is first then Judy should show up with a From: Judy Hsiao initially. Otherwise, it's a Co-developed-by: tag that should be after the SoB line. > --- > Changes Since V1: > -- Enableed BCLK and LRCLK in dai ops prepare API instead of startup API > -- Added comments > > sound/soc/qcom/lpass-cpu.c | 48 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 46 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c > index c62d2612e8f5..c5bb3f16d25f 100644 > --- a/sound/soc/qcom/lpass-cpu.c > +++ b/sound/soc/qcom/lpass-cpu.c > @@ -93,9 +93,18 @@ 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 trigger suspend */ /* * Can you use proper kernel doc multi-line notation please? */ And also, can we point to the function that is not impacted by "trigger suspend"? Is that lpass_cpu_daiops_trigger()? > + 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 +284,8 @@ 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 prepare */ > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > ret = regmap_fields_write(i2sctl->spken, id, > LPAIF_I2SCTL_SPKEN_ENABLE); > @@ -296,6 +307,8 @@ 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); > @@ -308,19 +321,50 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, > ret); > > clk_disable(drvdata->mi2s_bit_clk[dai->driver->id]); > - > + break; > + default: It confuses me that we're adding 'default' now. Why? Is some define not handled already? Why not use that define instead of 'default' so it is explicit what is being handled? How is it even related to this patch? > break; > } > > return ret; > } > > +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 = -EINVAL; ret will be assigned in the else though? Why assign it and then reassign it? > + /* 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); Why do we keep trying here instead of returning an error? > + > + 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; Could be return ret; > +} > + > + Nitpick: Why two newlines? > 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, > };