Skip to contentSkip to conversation

ASoC: SOF: mediatek: mt8195: Add dsp_ops callback

PATCH In review Chunxu Li 3 participants 6 messages Sep 24, 2022 – Sep 27, 2022

Subsystems (4)
lore
Share & tools
lore

Chunxu Li

author
#0 lore raw

cover ASoC: SOF: mediatek: mt8195: Add dsp_ops callback

ASoC: SOF: mediatek: mt8195: Add pcm_{hw_params,pointer} callback

Chunxu Li (2):
ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback
ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback

 sound/soc/sof/mediatek/mt8195/mt8195.c | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/2 ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback

Add pcm_hw_params callback for mt8195 to support continue update dma host position

---
 sound/soc/sof/mediatek/mt8195/mt8195.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
sound/soc/sof/mediatek/mt8195/mt8195.c +11 -0
index c12192c8a6f8..882fde741cf5 100644
@@ -496,6 +496,16 @@ 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 void mt8195_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
 {
 	u32 dbg_pc, dbg_data, dbg_bus0, dbg_bus1, dbg_inst;
@@ -588,6 +598,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_close	= sof_stream_pcm_close,
 
 	/* firmware loading */
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 2/2 ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback

In reply to Chunxu Li

Add pcm_pointer callback for mt8195 to support read host position from DSP

---
 sound/soc/sof/mediatek/mt8195/mt8195.c | 33 ++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
sound/soc/sof/mediatek/mt8195/mt8195.c +33 -0
index 882fde741cf5..3c81e84fcecf 100644
@@ -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 */
Signature · 1 line
2.25.1
maintainer
#5 lore raw
In reply to Chunxu Li
Quoted 10 lines · Chunxu Li

ASoC: SOF: mediatek: mt8195: Add pcm_{hw_params,pointer} callback

Chunxu Li (2):
ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback
ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback

sound/soc/sof/mediatek/mt8195/mt8195.c | 44 ++++++++++++++++++++++++++

 1 file changed, 44 insertions(+)

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback

      commit: 978a7144ae8497b40d833a3c0110b18810499f95
[2/2] ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback
      commit: f7c91bf65388547f61888b7a67169966fc698ce1

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark