All of lore.kernel.org
 help / color / mirror / Atom feed
From: Judy Hsiao <judyhsiao@google.com>
To: Doug Anderson <dianders@chromium.org>
Cc: Taniya Das <tdas@codeaurora.org>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Banajit Goswami <bgoswami@codeaurora.org>,
	Takashi Iwai <tiwai@suse.com>,
	Rohit kumar <rohitkr@codeaurora.org>,
	Patrick Lai <plai@codeaurora.org>, Andy Gross <agross@kernel.org>,
	Dylan Reid <dgreid@chromium.org>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
	<devicetree@vger.kernel.org>,
	Tzung-Bi Shih <tzungbi@chromium.org>,
	Srinivasa Rao Mandadapu <srivasam@codeaurora.org>,
	Stephan Gerhold <stephan@gerhold.net>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Rob Herring <robh+dt@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Jimmy Cheng-Yi Chiang <cychiang@google.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Judy Hsiao <judyhsiao@chromium.org>
Subject: Re: [v5] ASoC: qcom: lpass-cpu: Fix pop noise during audio capture begin
Date: Fri, 4 Jun 2021 14:43:34 +0800	[thread overview]
Message-ID: <CAJaago9842xqpHHfF2=6PJ3SfpzuYoQAicC5BJrTpB44SYBBuQ@mail.gmail.com> (raw)
In-Reply-To: <CAD=FV=VzBgbhhVQvG+UGD2yaLJkwiq0qQHdFNQ2Ey8RKmV+qTg@mail.gmail.com>

On Fri, Jun 4, 2021 at 6:41 AM Doug Anderson <dianders@chromium.org> wrote:

> Judy,
>
> On Thu, Jun 3, 2021 at 8:08 AM Judy Hsiao <judyhsiao@chromium.org> wrote:
> >
> > @@ -315,12 +353,54 @@ static int lpass_cpu_daiops_trigger(struct
> snd_pcm_substream *substream,
> >         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;
> > +       /*
> > +        * Ensure lpass BCLK/LRCLK is enabled bit before playback/capture
> > +        * data flow starts. This allows other codec to have some delay
> before
> > +        * the data flow.
> > +        * (ex: to drop start up pop noise before capture starts).
> > +        */
>
> nit: there's usually a blank line between the variable declarations
> and the first line of code, even if the first line of code is a
> comment.
> Thanks, noted.
>
> > +       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;
> > +       }
> > +
> > +       /*
> > +        * Check mi2s_was_prepared before enabling BCLK as
> lpass_cpu_daiops_prepare can
> > +        * be called multiple times. It's paired with the clk_disable in
> > +        * lpass_cpu_daiops_shutdown.
> > +        */
> > +       if (!drvdata->mi2s_was_prepared[dai->driver->id]) {
> > +               drvdata->mi2s_was_prepared[dai->driver->id] = true;
> > +               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]);
>
> Can you explain why this clk_disable() is here? Your function didn't
> turn this clock on, so why should it be turning it off in the error
> case?
>
The OSR CLK is disabled in the error case, not the BCLK.

>
>
> > +                       drvdata->mi2s_was_prepared[dai->driver->id] =
> false;
> > +                       return ret;
> > +               }
>
> Why not put the `drvdata->mi2s_was_prepared[dai->driver->id] = true;`
> _after_ you check for errors. Then you don't need to undo it in the
> error case.

Noted, thanks.

> I presume that your prepare() function isn't reentrant and
> can't be called at the same time as your shutdown (right?).
>
https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-pcm.c#L658
https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-pcm.c#L825
I think yes,
snd_soc_pcm_dai_prepare and snd_soc_dai_shutdown are both guard by
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);

>
> Other than that, I don't have any objections to this patch anymore. I
> probably won't add a formal "Reviewed-by", though, since I _really_
> don't know anything about the issue at hand or the code. I just
> stumbled upon this because I was getting the clock splat at bootup. If
> someone feels like this needs me to spin up enough to understand /
> really review this patch then please yell.
>
> -Doug
>

      reply	other threads:[~2021-06-04  9:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 15:08 [v5] ASoC: qcom: lpass-cpu: Fix pop noise during audio capture begin Judy Hsiao
2021-06-03 15:08 ` Judy Hsiao
2021-06-03 15:08 ` Judy Hsiao
2021-06-03 22:40 ` Doug Anderson
2021-06-03 22:40   ` Doug Anderson
2021-06-03 22:40   ` Doug Anderson
2021-06-04  6:43   ` Judy Hsiao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJaago9842xqpHHfF2=6PJ3SfpzuYoQAicC5BJrTpB44SYBBuQ@mail.gmail.com' \
    --to=judyhsiao@google.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=cychiang@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dgreid@chromium.org \
    --cc=dianders@chromium.org \
    --cc=judyhsiao@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=plai@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=rohitkr@codeaurora.org \
    --cc=srivasam@codeaurora.org \
    --cc=stephan@gerhold.net \
    --cc=swboyd@chromium.org \
    --cc=tdas@codeaurora.org \
    --cc=tiwai@suse.com \
    --cc=tzungbi@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.