On 11/13/23 20:15, Pierre-Louis Bossart wrote:
Thanks for your time.
@@ -195,7 +196,11 @@ static int renoir_audio_probe(struct platform_device *pdev)
dev_set_drvdata(dev, adata);
acp_enable_interrupts(adata);
acp_platform_register(dev);
-
+ pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS);
+ pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_mark_last_busy(&pdev->dev);
+ pm_runtime_set_active(&pdev->dev);
+ pm_runtime_enable(&pdev->dev);
return 0;
}
@@ -208,11 +213,42 @@ static void renoir_audio_remove(struct platform_device *pdev)
acp_platform_unregister(dev);
}
+static int __maybe_unused rn_pcm_resume(struct device *dev)
+{
+ struct acp_dev_data *adata = dev_get_drvdata(dev);
+ struct acp_stream *stream;
+ struct snd_pcm_substream *substream;
+ snd_pcm_uframes_t buf_in_frames;
+ u64 buf_size;
+
+ spin_lock(&adata->acp_lock);
+ list_for_each_entry(stream, &adata->stream_list, list) {
+ substream = stream->substream;
+ if (substream && substream->runtime) {
+ buf_in_frames = (substream->runtime->buffer_size);
+ buf_size = frames_to_bytes(substream->runtime, buf_in_frames);
+ config_pte_for_stream(adata, stream);
+ config_acp_dma(adata, stream, buf_size);
+ if (stream->dai_id)
+ restore_acp_i2s_params(substream, adata, stream);
+ else
+ restore_acp_pdm_params(substream, adata);
when are those parameters saved...
We are saving adata in acp_i2s_hwparams
<https://elixir.bootlin.com/linux/v6.7-rc1/C/ident/acp_i2s_hwparams> and
acp_i2s_set_tdm_slot,
These are the parameters saving in adata struct tdm_tx_fmt, tdm_rx_fmt,
lrclk_div and bclk_div.
+ }
+ }
+ spin_unlock(&adata->acp_lock);
+ return 0;
+}
+
+static const struct dev_pm_ops rn_dma_pm_ops = {> + SET_SYSTEM_SLEEP_PM_OPS(NULL, rn_pcm_resume)
... since there's nothing done on suspend?
Also there's something weird here since the patch enables pm_runtime but
there's nothing related to pm_runtime here, i.e. SET_RUNTIME_PM_OPS()
is missing.
runtime pm ops are not required as this is a dma driver.
+};
+
static struct platform_driver renoir_driver = {
.probe = renoir_audio_probe,
.remove_new = renoir_audio_remove,
.driver = {
.name = "acp_asoc_renoir",
+ .pm = &rn_dma_pm_ops,
},
};