From 29df6b972c8bc9812e503caf414f273165ae54f9 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Fri, 10 Jan 2020 14:04:40 +0200 Subject: [PATCH] ASoC: SOF: Intel: hda: call snd_hda_set_power_save from SOF code SOF sets its own pm_runtime suspend delay, but never calls snd_hda_set_power_save for the HDA codec. This means that HDA codec will have no pm_runtime suspend delay at all, so it will suspend very fast after idle. This is not very common "mode" for the codec PM as for example legacy HDA is always setting some pm_runtime suspend delay or disabling the PM altogether. If SOF is in suspend and there's a jack event, SOF will wake up, but the HDA codec will go immediately to suspend. We noticed that with some codecs (like ALC285) the quick suspend after wake up is messing up the jack detection as the codec might need some time for the detect measurement. So set the pm_runtime suspend delay time in HDA codec to same value as SOF sets itself. Signed-off-by: Jaska Uimonen --- sound/soc/sof/intel/hda.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 426f6698f968c6..46291e984938ca 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -597,6 +597,15 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) /* set default mailbox offset for FW ready message */ sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; + /* + * set pm suspend delay for the hda codec. Use the same value as SOF + * uses. If this is not set, HDA codec will suspend with 0ms suspend + * delay i.e. very quickly after idle. Very quick wakeup/suspend might + * cause for example jack inserts not being detected as the codec setup + * and jack connection measurement need some time. + */ + snd_hda_set_power_save(sof_to_hbus(sdev), SND_SOF_SUSPEND_DELAY_MS); + INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); return 0;