Skip to content

Commit 77165bd

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: sof-pcm: Add pointer callback to sof_ipc_pcm_ops
The IPC specific pointer callback can be used when additional or custom handling is needed during the pointer calculation, like executing a delay calculation at the same time to minimize drift between the reported pointer and the calculated delay. Cc: [email protected] # 6.8 Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3ce3bc3 commit 77165bd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sound/soc/sof/pcm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,21 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component,
388388
{
389389
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
390390
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
391+
const struct sof_ipc_pcm_ops *pcm_ops = sof_ipc_get_ops(sdev, pcm);
391392
struct snd_sof_pcm *spcm;
392393
snd_pcm_uframes_t host, dai;
394+
int ret = -EOPNOTSUPP;
393395

394396
/* nothing to do for BE */
395397
if (rtd->dai_link->no_pcm)
396398
return 0;
397399

400+
if (pcm_ops && pcm_ops->pointer)
401+
ret = pcm_ops->pointer(component, substream, &host);
402+
403+
if (ret != -EOPNOTSUPP)
404+
return ret ? ret : host;
405+
398406
/* use dsp ops pointer callback directly if set */
399407
if (sof_ops(sdev)->pcm_pointer)
400408
return sof_ops(sdev)->pcm_pointer(sdev, substream);

sound/soc/sof/sof-audio.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ struct snd_sof_dai_config_data {
103103
* additional memory in the SOF PCM stream structure
104104
* @pcm_free: Function pointer for PCM free that can be used for freeing any
105105
* additional memory in the SOF PCM stream structure
106-
* @delay: Function pointer for pcm delay calculation
106+
* @pointer: Function pointer for pcm pointer
107+
* Note: the @pointer callback may return -EOPNOTSUPP which should be
108+
* handled in a same way as if the callback is not provided
109+
* @delay: Function pointer for pcm delay reporting
107110
* @reset_hw_params_during_stop: Flag indicating whether the hw_params should be reset during the
108111
* STOP pcm trigger
109112
* @ipc_first_on_start: Send IPC before invoking platform trigger during
@@ -124,6 +127,9 @@ struct sof_ipc_pcm_ops {
124127
int (*dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
125128
int (*pcm_setup)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
126129
void (*pcm_free)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
130+
int (*pointer)(struct snd_soc_component *component,
131+
struct snd_pcm_substream *substream,
132+
snd_pcm_uframes_t *pointer);
127133
snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
128134
struct snd_pcm_substream *substream);
129135
bool reset_hw_params_during_stop;

0 commit comments

Comments
 (0)