[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220817080529.10864-5-daniel.baluta@oss.nxp.com>
Date: Wed, 17 Aug 2022 11:05:29 +0300
From: Daniel Baluta <daniel.baluta@....nxp.com>
To: broonie@...nel.org, alsa-devel@...a-project.org
Cc: linux-kernel@...r.kernel.org, peter.ujfalusi@...ux.intel.com,
yung-chuan.liao@...ux.intel.com, ranjani.sridharan@...ux.intel.com,
kai.vehmanen@...ux.intel.com, lgirdwood@...il.com,
pierre-louis.bossart@...ux.intel.com, daniel.baluta@...il.com,
laurentiu.mihalcea@....com, Paul Olaru <paul.olaru@....nxp.com>,
Daniel Baluta <daniel.baluta@....com>
Subject: [PATCH 4/4] ASoC: SOF: compress: Add support for computing timestamps
From: Laurentiu Mihalcea <laurentiu.mihalcea@....com>
We compute the number of pcm_io_frames by dividing the
dai position to size of a frame (channels * sample size).
Reviewed-by: Paul Olaru <paul.olaru@....nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@....com>
Signed-off-by: Daniel Baluta <daniel.baluta@....com>
---
sound/soc/sof/compress.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index ac79b46ce3b9..174b3d8e67dd 100644
--- a/sound/soc/sof/compress.c
+++ b/sound/soc/sof/compress.c
@@ -327,10 +327,21 @@ static int sof_compr_pointer(struct snd_soc_component *component,
struct snd_compr_stream *cstream,
struct snd_compr_tstamp *tstamp)
{
+ u64 dai_posn;
+ struct snd_sof_pcm *spcm;
+ struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct sof_compr_stream *sstream = cstream->runtime->private_data;
+ spcm = snd_sof_find_spcm_dai(component, rtd);
+ if (!spcm)
+ return -EINVAL;
+
+ dai_posn = spcm->stream[cstream->direction].posn.dai_posn;
+
tstamp->sampling_rate = sstream->sampling_rate;
tstamp->copied_total = sstream->copied_total;
+ tstamp->pcm_io_frames = div_u64(spcm->stream[cstream->direction].posn.dai_posn,
+ sstream->channels * sstream->sample_container_bytes);
return 0;
}
--
2.27.0
Powered by blists - more mailing lists