ASoC: SOF: amd: Add pcm pointer callback for amd platforms.
authorV sujith kumar Reddy <Vsujithkumar.Reddy@amd.com>
Wed, 8 Mar 2023 08:45:08 +0000 (14:15 +0530)
committerMark Brown <broonie@kernel.org>
Wed, 8 Mar 2023 15:05:43 +0000 (15:05 +0000)
Add pcm pointer callback for amd platforms to read host position
update from stream box.

Signed-off-by: V sujith kumar Reddy <Vsujithkumar.Reddy@amd.com>
Link: https://lore.kernel.org/r/20230308084509.1496256-2-Vsujithkumar.Reddy@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/amd/acp-common.c
sound/soc/sof/amd/acp-pcm.c
sound/soc/sof/amd/acp.h

index bd6c1b198736c031b1454e49206653c6bd5603e6..8ce4c89569338d1b483c7ee18c73f55aed7d605b 100644 (file)
@@ -187,6 +187,7 @@ struct snd_sof_dsp_ops sof_acp_common_ops = {
        .pcm_open               = acp_pcm_open,
        .pcm_close              = acp_pcm_close,
        .pcm_hw_params          = acp_pcm_hw_params,
+       .pcm_pointer            = acp_pcm_pointer,
 
        .hw_info                = SNDRV_PCM_INFO_MMAP |
                                  SNDRV_PCM_INFO_MMAP_VALID |
index 727c3a784a204f105c185c704b23c7c95933c9a2..f342f0bac4a37335fc0da57f13f2d5ed9a4fe3db 100644 (file)
@@ -84,3 +84,36 @@ int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
        return acp_dsp_stream_put(sdev, stream);
 }
 EXPORT_SYMBOL_NS(acp_pcm_close, SND_SOC_SOF_AMD_COMMON);
+
+snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev,
+                                 struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+       struct snd_soc_component *scomp = sdev->component;
+       struct snd_sof_pcm_stream *stream;
+       struct sof_ipc_stream_posn posn;
+       struct snd_sof_pcm *spcm;
+       snd_pcm_uframes_t pos;
+       int ret;
+
+       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, &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;
+}
+EXPORT_SYMBOL_NS(acp_pcm_pointer, SND_SOC_SOF_AMD_COMMON);
index 39165ebf684b68e6f9a37a46b12d1b4e59dfd1c7..acad579476165d81d0f89628be512557395f5441 100644 (file)
@@ -238,6 +238,8 @@ int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
 int acp_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);
+snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev,
+                                 struct snd_pcm_substream *substream);
 
 extern struct snd_sof_dsp_ops sof_acp_common_ops;