Skip to content

Commit c95a2a0

Browse files
saba-kareembroonie
authored andcommitted
ASoC: amd: acp: add pm ops support for renoir platform.
Add pm ops for renoir platform. Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://msgid.link/r/20231215130300.1247475-1-Syed.SabaKareem@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c27032b commit c95a2a0

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

sound/soc/amd/acp/acp-renoir.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <sound/soc.h>
2121
#include <sound/soc-dai.h>
2222
#include <linux/dma-mapping.h>
23+
#include <linux/pm_runtime.h>
2324

2425
#include "amd.h"
2526
#include "acp-mach.h"
@@ -196,6 +197,11 @@ static int renoir_audio_probe(struct platform_device *pdev)
196197
acp_enable_interrupts(adata);
197198
acp_platform_register(dev);
198199

200+
pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS);
201+
pm_runtime_use_autosuspend(&pdev->dev);
202+
pm_runtime_mark_last_busy(&pdev->dev);
203+
pm_runtime_set_active(&pdev->dev);
204+
pm_runtime_enable(&pdev->dev);
199205
return 0;
200206
}
201207

@@ -208,11 +214,42 @@ static void renoir_audio_remove(struct platform_device *pdev)
208214
acp_platform_unregister(dev);
209215
}
210216

217+
static int __maybe_unused rn_pcm_resume(struct device *dev)
218+
{
219+
struct acp_dev_data *adata = dev_get_drvdata(dev);
220+
struct acp_stream *stream;
221+
struct snd_pcm_substream *substream;
222+
snd_pcm_uframes_t buf_in_frames;
223+
u64 buf_size;
224+
225+
spin_lock(&adata->acp_lock);
226+
list_for_each_entry(stream, &adata->stream_list, list) {
227+
substream = stream->substream;
228+
if (substream && substream->runtime) {
229+
buf_in_frames = (substream->runtime->buffer_size);
230+
buf_size = frames_to_bytes(substream->runtime, buf_in_frames);
231+
config_pte_for_stream(adata, stream);
232+
config_acp_dma(adata, stream, buf_size);
233+
if (stream->dai_id)
234+
restore_acp_i2s_params(substream, adata, stream);
235+
else
236+
restore_acp_pdm_params(substream, adata);
237+
}
238+
}
239+
spin_unlock(&adata->acp_lock);
240+
return 0;
241+
}
242+
243+
static const struct dev_pm_ops rn_dma_pm_ops = {
244+
SET_SYSTEM_SLEEP_PM_OPS(NULL, rn_pcm_resume)
245+
};
246+
211247
static struct platform_driver renoir_driver = {
212248
.probe = renoir_audio_probe,
213249
.remove_new = renoir_audio_remove,
214250
.driver = {
215251
.name = "acp_asoc_renoir",
252+
.pm = &rn_dma_pm_ops,
216253
},
217254
};
218255

0 commit comments

Comments
 (0)