mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: <broonie@kernel.org>, <lgirdwood@gmail.com>, <tiwai@suse.com>,
	<perex@perex.cz>, <lars@metafoo.de>,
	<alsa-devel@alsa-project.org>, <vkoul@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: dmaengine_pcm: Consider DMA cache caused delay in pointer callback
Date: Mon, 10 Feb 2020 15:38:42 +0100	[thread overview]
Message-ID: <s5hk14ufqx9.wl-tiwai@suse.de> (raw)
In-Reply-To: <15c7df10-cf9f-109c-3cbf-e73af7f4f66a@ti.com>

On Mon, 10 Feb 2020 15:28:44 +0100,
Peter Ujfalusi wrote:
> 
> Hi Takashi,
> 
> >> --- a/sound/soc/soc-pcm.c
> >> +++ b/sound/soc/soc-pcm.c
> >> @@ -1151,7 +1151,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
> >>  	}
> >>  	delay += codec_delay;
> >>  
> >> -	runtime->delay = delay;
> >> +	runtime->delay += delay;
> > 
> > Is it correct?
> > delay already takes runtime->delay as its basis, so it'll result in a
> > double.
> 
> The delay here is coming from the DAI and the codec.
> The runtime->delay hold the PCM (DMA) caused delay.

Well, let's take a look at soc_pcm_pointer():

	/* clearing the previous total delay */
	runtime->delay = 0;

	offset = snd_soc_pcm_component_pointer(substream);

	/* base delay if assigned in pointer callback */
	delay = runtime->delay;

	delay += snd_soc_dai_delay(cpu_dai, substream);

	for_each_rtd_codec_dai(rtd, i, codec_dai) {
		codec_delay = max(codec_delay,
				  snd_soc_dai_delay(codec_dai, substream));
	}
	delay += codec_delay;

	runtime->delay = delay;

So, the code reads the current runtime->delay and saves it as delay
variable.  Then it adds the max delay from codec DAIs, and stores back
to runtime->delay.

If we change the last line to
	runtime->delay += delay;
it'll add to the already existing value again, so it'll be doubly if
runtime->delay was non-zero beforehand.

That said, judging from the code, I believe the current soc-pcm.c code
needs no change.


thanks,

Takashi

  parent reply	other threads:[~2020-02-10 14:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 14:04 Peter Ujfalusi
2020-02-10 14:21 ` Takashi Iwai
2020-02-10 14:28   ` Peter Ujfalusi
2020-02-10 14:37     ` Mark Brown
2020-02-10 14:59       ` Peter Ujfalusi
2020-02-10 14:38     ` Takashi Iwai [this message]
2020-02-10 15:01       ` Peter Ujfalusi

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=s5hk14ufqx9.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@ti.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®