Skip to content

Commit feea640

Browse files
morimotobroonie
authored andcommitted
ASoC: amd: acp-pcm-dma: add .delay support
Now ALSA SoC supports .delay for component. This patch uses it, and not update runtime->delay on .pointer directly / secretly. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/8735nwy25o.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 403f830 commit feea640

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

sound/soc/amd/acp-pcm-dma.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,
10031003

10041004
struct snd_pcm_runtime *runtime = substream->runtime;
10051005
struct audio_substream_data *rtd = runtime->private_data;
1006+
struct audio_drv_data *adata = dev_get_drvdata(component->dev);
10061007

10071008
if (!rtd)
10081009
return -EINVAL;
@@ -1023,7 +1024,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,
10231024
}
10241025
if (bytescount > 0) {
10251026
delay = do_div(bytescount, period_bytes);
1026-
runtime->delay = bytes_to_frames(runtime, delay);
1027+
adata->delay += bytes_to_frames(runtime, delay);
10271028
}
10281029
} else {
10291030
buffersize = frames_to_bytes(runtime, runtime->buffer_size);
@@ -1035,6 +1036,17 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,
10351036
return bytes_to_frames(runtime, pos);
10361037
}
10371038

1039+
static snd_pcm_sframes_t acp_dma_delay(struct snd_soc_component *component,
1040+
struct snd_pcm_substream *substream)
1041+
{
1042+
struct audio_drv_data *adata = dev_get_drvdata(component->dev);
1043+
snd_pcm_sframes_t delay = adata->delay;
1044+
1045+
adata->delay = 0;
1046+
1047+
return delay;
1048+
}
1049+
10381050
static int acp_dma_prepare(struct snd_soc_component *component,
10391051
struct snd_pcm_substream *substream)
10401052
{
@@ -1198,6 +1210,7 @@ static const struct snd_soc_component_driver acp_asoc_platform = {
11981210
.hw_params = acp_dma_hw_params,
11991211
.trigger = acp_dma_trigger,
12001212
.pointer = acp_dma_pointer,
1213+
.delay = acp_dma_delay,
12011214
.prepare = acp_dma_prepare,
12021215
.pcm_construct = acp_dma_new,
12031216
};

sound/soc/amd/acp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct audio_drv_data {
151151
struct snd_pcm_substream *capture_i2sbt_stream;
152152
void __iomem *acp_mmio;
153153
u32 asic_type;
154+
snd_pcm_sframes_t delay;
154155
};
155156

156157
/*

0 commit comments

Comments
 (0)