aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2022-09-27 12:07:27 +0100
committerMark Brown <broonie@kernel.org>2022-09-27 12:07:27 +0100
commit5445e5db29fc5ac917ee4b5def62b5cf20e1ee9e (patch)
tree76a8c99a1efc20adf3b492f8399bd11d799848c0 /sound/soc
parentASoC: MAINTAINERS: add bindings and APR to Qualcomm Audio entry (diff)
parentASoC: SOF: mediatek: mt8195: Add pcm_pointer callback (diff)
downloadlinux-dev-5445e5db29fc5ac917ee4b5def62b5cf20e1ee9e.tar.xz
linux-dev-5445e5db29fc5ac917ee4b5def62b5cf20e1ee9e.zip
ASoC: SOF: mediatek: mt8195: Add dsp_ops callback
Merge series from Chunxu Li <chunxu.li@mediatek.com>: Support more operations for MediaTek DSPs using SOF.
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/sof/mediatek/mt8195/mt8195.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index c12192c8a6f8..3c81e84fcecf 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -496,6 +496,48 @@ static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type)
return type;
}
+static int mt8195_pcm_hw_params(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_sof_platform_stream_params *platform_params)
+{
+ platform_params->cont_update_posn = 1;
+
+ return 0;
+}
+
+static snd_pcm_uframes_t mt8195_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 void mt8195_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
{
u32 dbg_pc, dbg_data, dbg_bus0, dbg_bus1, dbg_inst;
@@ -588,6 +630,8 @@ static struct snd_sof_dsp_ops sof_mt8195_ops = {
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
+ .pcm_hw_params = mt8195_pcm_hw_params,
+ .pcm_pointer = mt8195_pcm_pointer,
.pcm_close = sof_stream_pcm_close,
/* firmware loading */