diff options
author | Chunxu Li <chunxu.li@mediatek.com> | 2022-09-21 14:02:39 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-09-21 18:29:20 +0200 |
commit | a921986f445ad611b441c8ee7749dc6dfc770481 (patch) | |
tree | 685586b521dfd3dc0cba5e8633888add35f70492 /sound/soc/sof/mediatek | |
parent | ASoC: ts3a227e control debounce times (diff) | |
download | linux-a921986f445ad611b441c8ee7749dc6dfc770481.tar.xz linux-a921986f445ad611b441c8ee7749dc6dfc770481.zip |
ASoC: SOF: mediatek: add pcm_pointer callback for mt8186
add pcm_pointer callback for mt8186 to support read
host position from DSP
Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220921120239.31934-1-chunxu.li@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/mediatek')
-rw-r--r-- | sound/soc/sof/mediatek/mt8186/mt8186.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 9ec89fc7fec0..181189e00e02 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -470,6 +470,38 @@ static int mt8186_pcm_hw_params(struct snd_sof_dev *sdev, return 0; } +static snd_pcm_uframes_t mt8186_pcm_pointer(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream) +{ + int ret; + snd_pcm_uframes_t pos; + struct snd_sof_pcm *spcm; + struct sof_ipc_stream_posn posn; + struct snd_sof_pcm_stream *stream; + struct snd_soc_component *scomp = sdev->component; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + spcm = snd_sof_find_spcm_dai(scomp, rtd); + if (!spcm) { + dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", + rtd->dai_link->id); + return 0; + } + + stream = &spcm->stream[substream->stream]; + ret = snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn)); + if (ret < 0) { + dev_warn(sdev->dev, "failed to read stream position: %d\n", ret); + return 0; + } + + memcpy(&stream->posn, &posn, sizeof(posn)); + pos = spcm->stream[substream->stream].posn.host_posn; + pos = bytes_to_frames(substream->runtime, pos); + + return pos; +} + static struct snd_soc_dai_driver mt8186_dai[] = { { .name = "SOF_DL1", @@ -537,6 +569,7 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = { /* stream callbacks */ .pcm_open = sof_stream_pcm_open, .pcm_hw_params = mt8186_pcm_hw_params, + .pcm_pointer = mt8186_pcm_pointer, .pcm_close = sof_stream_pcm_close, /* firmware loading */ |