Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>,
	lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com,
	ranjani.sridharan@linux.intel.com,
	pierre-louis.bossart@linux.intel.com, rander.wang@intel.com,
	yung-chuan.liao@linux.intel.com
Subject: Re: [PATCH 9/9] ASoC: SOF: ipc4-pcm: add delay function support
Date: Thu, 2 Feb 2023 11:31:28 +0200	[thread overview]
Message-ID: <0392c6bf-39e4-e9ef-99f3-728dbc3e35b6@linux.intel.com> (raw)
In-Reply-To: <d5f6aa34-4fff-9e23-0811-de1ee6d8a2e9@perex.cz>



On 01/02/2023 14:44, Jaroslav Kysela wrote:
> On 01. 02. 23 13:32, Peter Ujfalusi wrote:
> 
>> +static snd_pcm_sframes_t sof_ipc4_pcm_delay(struct snd_soc_component
>> *component,
>> +                        struct snd_pcm_substream *substream)
>> +{
> 
> ...
> 
>> +
>> +    /*
>> +     * Handle 32-bit counter wrap around, which would happen
>> +     * for a 48khz 2ch stream in 24.855 hours
>> +     */
>> +    link_ptr = tmp_ptr & UINT_MAX;
>> +
>> +    host_ptr = substream->runtime->status->hw_ptr;
>> +
>> +    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
>> +        return host_ptr - link_ptr;
>> +
>> +    return link_ptr - host_ptr;
> 
> I don't think that this calculation is fine for the wrap point. The
> hw_ptr is in range 0..pcm_boundary not UINT_MAX.

That is true. Our link counter is u64 (and it is counting the bytes, not
a real DMA position) so I can
tmp_ptr %= substream->runtime->boundary;

then handle the wrap of both later.

> Also, you should consider the underrun/overrun situations.

>The simple substraction is not enough to handle this correctly.

Yes, you are right. I will send v2 right away(ish)

Thanks,
Péter

  reply	other threads:[~2023-02-02  9:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 12:32 [PATCH 0/9] ASoC: SOF: core/ipc4/mtl: Add support for PCM delay reporting Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 1/9] ASoC: SOF: add ipc4_fw_reg header file Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 2/9] ASoC: SOF: add fw_info_box support Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 3/9] ASoC: SOF: add time info structure for ipc4 path Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 4/9] ASoC: SOF: ipc4-pcm: allocate time info for pcm delay feature Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 5/9] ASoC: SOF: ipc4-pcm: add hw_params Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 6/9] ASoC: SOF: add delay function support in sof framework Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 7/9] ASoC: SOF: add get_stream_position ops for pcm delay Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 8/9] ASoC: SOF: Intel: mtl: add get_stream_position support Peter Ujfalusi
2023-02-01 12:32 ` [PATCH 9/9] ASoC: SOF: ipc4-pcm: add delay function support Peter Ujfalusi
2023-02-01 12:44   ` Jaroslav Kysela
2023-02-02  9:31     ` Péter Ujfalusi [this message]
2023-02-03 15:07 ` [PATCH 0/9] ASoC: SOF: core/ipc4/mtl: Add support for PCM delay reporting Mark Brown

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=0392c6bf-39e4-e9ef-99f3-728dbc3e35b6@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rander.wang@intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /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