From b33115bd05afda6fe16fdd142779a9ff95d63317 Mon Sep 17 00:00:00 2001 From: Mohan Kumar Date: Mon, 11 Apr 2022 13:02:09 +0530 Subject: ALSA: hda: Jack detection poll in suspend state HDA Jack detection logic doesn't work when the HDACODEC in runtime suspended state as unsol event won't be triggered during D3 state. As pulseaudio server in userspace rely on the jack mixer control status to show the audio devices in gui and any display sink device hotplug event during D3 state will never updates the jack status which will result in no audio device option available in userspace settings. The possible option available to resolve this issue is to run Jack polling worker thread even after codec suspend state. The choice can be made based on compromise between power saving or Jack detection in suspend state. Signed-off-by: Mohan Kumar Link: https://lore.kernel.org/r/20220411073210.23445-2-mkumard@nvidia.com Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sound/pci/hda/hda_codec.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 5cbac315dbe1..7579a6982f47 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2935,7 +2935,9 @@ static int hda_codec_runtime_suspend(struct device *dev) if (!codec->card) return 0; - cancel_delayed_work_sync(&codec->jackpoll_work); + if (!codec->bus->jackpoll_in_suspend) + cancel_delayed_work_sync(&codec->jackpoll_work); + state = hda_call_codec_suspend(codec); if (codec->link_down_at_suspend || (codec_has_clkstop(codec) && codec_has_epss(codec) && @@ -2984,6 +2986,9 @@ static void hda_codec_pm_complete(struct device *dev) static int hda_codec_pm_suspend(struct device *dev) { + struct hda_codec *codec = dev_to_hda_codec(dev); + + cancel_delayed_work_sync(&codec->jackpoll_work); dev->power.power_state = PMSG_SUSPEND; return pm_runtime_force_suspend(dev); } @@ -2996,6 +3001,9 @@ static int hda_codec_pm_resume(struct device *dev) static int hda_codec_pm_freeze(struct device *dev) { + struct hda_codec *codec = dev_to_hda_codec(dev); + + cancel_delayed_work_sync(&codec->jackpoll_work); dev->power.power_state = PMSG_FREEZE; return pm_runtime_force_suspend(dev); } @@ -3038,6 +3046,7 @@ void snd_hda_codec_shutdown(struct hda_codec *codec) if (!codec->registered) return; + cancel_delayed_work_sync(&codec->jackpoll_work); list_for_each_entry(cpcm, &codec->pcm_list_head, list) snd_pcm_suspend_all(cpcm->pcm); -- cgit v1.2.3-59-g8ed1b