]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/alsa-hda-record-the-current-power-state-before-suspend-resume-calls.patch
Linux 4.19.32
[thirdparty/kernel/stable-queue.git] / queue-5.0 / alsa-hda-record-the-current-power-state-before-suspend-resume-calls.patch
1 From 98081ca62cbac31fb0f7efaf90b2e7384ce22257 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Tue, 29 Jan 2019 14:03:33 +0100
4 Subject: ALSA: hda - Record the current power state before suspend/resume calls
5
6 From: Takashi Iwai <tiwai@suse.de>
7
8 commit 98081ca62cbac31fb0f7efaf90b2e7384ce22257 upstream.
9
10 Currently we deal with single codec and suspend codec callbacks for
11 all S3, S4 and runtime PM handling. But it turned out that we want
12 distinguish the call patterns sometimes, e.g. for applying some init
13 sequence only at probing and restoring from hibernate.
14
15 This patch slightly modifies the common PM callbacks for HD-audio
16 codec and stores the currently processed PM event in power_state of
17 the codec's device.power field, which is currently unused. The codec
18 callback can take a look at this event value and judges which purpose
19 it's being called.
20
21 Signed-off-by: Takashi Iwai <tiwai@suse.de>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24 ---
25 sound/pci/hda/hda_codec.c | 43 +++++++++++++++++++++++++++++++++++++++++--
26 1 file changed, 41 insertions(+), 2 deletions(-)
27
28 --- a/sound/pci/hda/hda_codec.c
29 +++ b/sound/pci/hda/hda_codec.c
30 @@ -2917,6 +2917,7 @@ static void hda_call_codec_resume(struct
31 hda_jackpoll_work(&codec->jackpoll_work.work);
32 else
33 snd_hda_jack_report_sync(codec);
34 + codec->core.dev.power.power_state = PMSG_ON;
35 snd_hdac_leave_pm(&codec->core);
36 }
37
38 @@ -2950,10 +2951,48 @@ static int hda_codec_runtime_resume(stru
39 }
40 #endif /* CONFIG_PM */
41
42 +#ifdef CONFIG_PM_SLEEP
43 +static int hda_codec_pm_suspend(struct device *dev)
44 +{
45 + dev->power.power_state = PMSG_SUSPEND;
46 + return pm_runtime_force_suspend(dev);
47 +}
48 +
49 +static int hda_codec_pm_resume(struct device *dev)
50 +{
51 + dev->power.power_state = PMSG_RESUME;
52 + return pm_runtime_force_resume(dev);
53 +}
54 +
55 +static int hda_codec_pm_freeze(struct device *dev)
56 +{
57 + dev->power.power_state = PMSG_FREEZE;
58 + return pm_runtime_force_suspend(dev);
59 +}
60 +
61 +static int hda_codec_pm_thaw(struct device *dev)
62 +{
63 + dev->power.power_state = PMSG_THAW;
64 + return pm_runtime_force_resume(dev);
65 +}
66 +
67 +static int hda_codec_pm_restore(struct device *dev)
68 +{
69 + dev->power.power_state = PMSG_RESTORE;
70 + return pm_runtime_force_resume(dev);
71 +}
72 +#endif /* CONFIG_PM_SLEEP */
73 +
74 /* referred in hda_bind.c */
75 const struct dev_pm_ops hda_codec_driver_pm = {
76 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
77 - pm_runtime_force_resume)
78 +#ifdef CONFIG_PM_SLEEP
79 + .suspend = hda_codec_pm_suspend,
80 + .resume = hda_codec_pm_resume,
81 + .freeze = hda_codec_pm_freeze,
82 + .thaw = hda_codec_pm_thaw,
83 + .poweroff = hda_codec_pm_suspend,
84 + .restore = hda_codec_pm_restore,
85 +#endif /* CONFIG_PM_SLEEP */
86 SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume,
87 NULL)
88 };