From: Chunxu Li <chunxu.li@mediatek.com>
To: <broonie@kernel.org>, <pierre-louis.bossart@linux.intel.com>,
<peter.ujfalusi@linux.intel.com>, <lgirdwood@gmail.com>,
<angelogioacchino.delregno@collabora.com>,
<daniel.baluta@nxp.com>
Cc: <matthias.bgg@gmail.com>, <yc.hung@mediatek.com>,
<linux-kernel@vger.kernel.org>, <alsa-devel@alsa-project.org>,
<sound-open-firmware@alsa-project.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<project_global_chrome_upstream_group@mediatek.com>,
Chunxu Li <chunxu.li@mediatek.com>
Subject: [PATCH 2/2] ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback
Date: Sat, 24 Sep 2022 11:35:59 +0800 [thread overview]
Message-ID: <20220924033559.26599-3-chunxu.li@mediatek.com> (raw)
In-Reply-To: <20220924033559.26599-1-chunxu.li@mediatek.com>
Add pcm_pointer callback for mt8195 to support read
host position from DSP
Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
---
sound/soc/sof/mediatek/mt8195/mt8195.c | 33 ++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index 882fde741cf5..3c81e84fcecf 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -506,6 +506,38 @@ static int mt8195_pcm_hw_params(struct snd_sof_dev *sdev,
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;
@@ -599,6 +631,7 @@ 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 */
--
2.25.1
next prev parent reply other threads:[~2022-09-24 3:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 3:35 [PATCH 0/2] ASoC: SOF: mediatek: mt8195: Add dsp_ops callback Chunxu Li
2022-09-24 3:35 ` [PATCH 1/2] ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback Chunxu Li
2022-09-26 8:23 ` AngeloGioacchino Del Regno
2022-09-24 3:35 ` Chunxu Li [this message]
2022-09-26 8:23 ` [PATCH 2/2] ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback AngeloGioacchino Del Regno
2022-09-27 11:20 ` [PATCH 0/2] ASoC: SOF: mediatek: mt8195: Add dsp_ops callback 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=20220924033559.26599-3-chunxu.li@mediatek.com \
--to=chunxu.li@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=project_global_chrome_upstream_group@mediatek.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=yc.hung@mediatek.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
all inboxes | Powered by JetHome®