forked from SteamFork/distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
256 additions
and
1 deletion.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
PKGBUILD/linux/0053-add-support-for-screen-off-and-screen-on.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
From 8ca27ffa9b97e14cf771c5d1c887072e30bdb268 Mon Sep 17 00:00:00 2001 | ||
From: Mario Limonciello <mario.limonciello@amd.com> | ||
Date: Wed, 14 Aug 2024 12:50:25 -0500 | ||
Subject: [PATCH] acpi/x86: s2idle: add support for screen off and screen on | ||
callbacks | ||
|
||
All the _DSM methods for the LPS0 method are called back to back | ||
currently. The intended use of the screen off and screen on calls is | ||
supposed to be matching the screen being turned on or off though. | ||
Add support for other parts of the kernel to call such a callback. | ||
|
||
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> | ||
--- | ||
include/linux/suspend.h | 8 ++++++++ | ||
kernel/power/suspend.c | 12 ++++++++++++ | ||
2 files changed, 20 insertions(+) | ||
|
||
diff --git a/include/linux/suspend.h b/include/linux/suspend.h | ||
index da6ebca3ff774c..4535ae82363c1f 100644 | ||
--- a/include/linux/suspend.h | ||
+++ b/include/linux/suspend.h | ||
@@ -133,6 +133,8 @@ struct platform_suspend_ops { | ||
|
||
struct platform_s2idle_ops { | ||
int (*begin)(void); | ||
+ int (*screen_off)(void); | ||
+ int (*screen_on)(void); | ||
int (*prepare)(void); | ||
int (*prepare_late)(void); | ||
void (*check)(void); | ||
@@ -160,6 +162,9 @@ extern unsigned int pm_suspend_global_flags; | ||
#define PM_SUSPEND_FLAG_FW_RESUME BIT(1) | ||
#define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2) | ||
|
||
+int platform_suspend_screen_off(void); | ||
+int platform_suspend_screen_on(void); | ||
+ | ||
static inline void pm_suspend_clear_flags(void) | ||
{ | ||
pm_suspend_global_flags = 0; | ||
@@ -296,6 +301,9 @@ static inline bool idle_should_enter_s2idle(void) { return false; } | ||
static inline void __init pm_states_init(void) {} | ||
static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {} | ||
static inline void s2idle_wake(void) {} | ||
+static inline int platform_suspend_screen_off(void) { return -ENODEV }; | ||
+static inline int platform_suspend_screen_on(void) { return -ENODEV }; | ||
+ | ||
#endif /* !CONFIG_SUSPEND */ | ||
|
||
/* struct pbe is used for creating lists of pages that should be restored | ||
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c | ||
index 09f8397bae15fb..19734b297527c2 100644 | ||
--- a/kernel/power/suspend.c | ||
+++ b/kernel/power/suspend.c | ||
@@ -254,6 +254,18 @@ static bool sleep_state_supported(suspend_state_t state) | ||
(valid_state(state) && !cxl_mem_active()); | ||
} | ||
|
||
+int platform_suspend_screen_off(void) | ||
+{ | ||
+ return s2idle_ops && s2idle_ops->screen_off ? s2idle_ops->screen_off() : 0; | ||
+} | ||
+EXPORT_SYMBOL_GPL(platform_suspend_screen_off); | ||
+ | ||
+int platform_suspend_screen_on(void) | ||
+{ | ||
+ return s2idle_ops && s2idle_ops->screen_on ? s2idle_ops->screen_on() : 0; | ||
+} | ||
+EXPORT_SYMBOL_GPL(platform_suspend_screen_on); | ||
+ | ||
static int platform_suspend_prepare(suspend_state_t state) | ||
{ | ||
return state != PM_SUSPEND_TO_IDLE && suspend_ops->prepare ? |
53 changes: 53 additions & 0 deletions
53
PKGBUILD/linux/0054-Notify-the-suspend-core-when-displays-are-changed-at.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From 85bbc00e7ffdb0a799f4ce8f4a4fa8fb560d3046 Mon Sep 17 00:00:00 2001 | ||
From: Mario Limonciello <mario.limonciello@amd.com> | ||
Date: Wed, 14 Aug 2024 20:19:09 -0500 | ||
Subject: [PATCH] drm: Notify the suspend core when displays are changed at | ||
suspend | ||
|
||
This allows notifying the BIOS with the LPS0 _DSM for "Screen off" | ||
and "Screen on". | ||
|
||
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> | ||
--- | ||
drivers/gpu/drm/drm_atomic_helper.c | 13 +++++++++++++ | ||
1 file changed, 13 insertions(+) | ||
|
||
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c | ||
index 39ef0a6addeba8..8afabbfe4c1b6f 100644 | ||
--- a/drivers/gpu/drm/drm_atomic_helper.c | ||
+++ b/drivers/gpu/drm/drm_atomic_helper.c | ||
@@ -27,6 +27,7 @@ | ||
|
||
#include <linux/dma-fence.h> | ||
#include <linux/ktime.h> | ||
+#include <linux/suspend.h> | ||
|
||
#include <drm/drm_atomic.h> | ||
#include <drm/drm_atomic_helper.h> | ||
@@ -3526,6 +3527,13 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev) | ||
goto unlock; | ||
} | ||
|
||
+ err = platform_suspend_screen_off(); | ||
+ if (err < 0) { | ||
+ drm_atomic_state_put(state); | ||
+ state = ERR_PTR(err); | ||
+ goto unlock; | ||
+ } | ||
+ | ||
unlock: | ||
DRM_MODESET_LOCK_ALL_END(dev, ctx, err); | ||
if (err) | ||
@@ -3607,7 +3615,12 @@ int drm_atomic_helper_resume(struct drm_device *dev, | ||
DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, err); | ||
|
||
err = drm_atomic_helper_commit_duplicated_state(state, &ctx); | ||
+ if (err < 0) | ||
+ goto unlock; | ||
|
||
+ err = platform_suspend_screen_on(); | ||
+ | ||
+unlock: | ||
DRM_MODESET_LOCK_ALL_END(dev, ctx, err); | ||
drm_atomic_state_put(state); | ||
|
123 changes: 123 additions & 0 deletions
123
PKGBUILD/linux/0055-Move-screen-off_on-code-into-dedicated.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
From 9217190b15982ba259576eb0a605f806113b1f50 Mon Sep 17 00:00:00 2001 | ||
From: Mario Limonciello <mario.limonciello@amd.com> | ||
Date: Wed, 14 Aug 2024 20:20:13 -0500 | ||
Subject: [PATCH] acpi/x86: s2idle: Move screen off/on code into dedicated | ||
callbacks | ||
|
||
This lets the DRM core notify on screen events instead of calling | ||
them back to back. | ||
|
||
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> | ||
--- | ||
drivers/acpi/x86/s2idle.c | 75 ++++++++++++++++++++++++++++++--------- | ||
1 file changed, 59 insertions(+), 16 deletions(-) | ||
|
||
diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c | ||
index dd0b40b9bbe8be..e7f9748937d68e 100644 | ||
--- a/drivers/acpi/x86/s2idle.c | ||
+++ b/drivers/acpi/x86/s2idle.c | ||
@@ -539,17 +539,21 @@ static struct acpi_scan_handler lps0_handler = { | ||
.attach = lps0_device_attach, | ||
}; | ||
|
||
-int acpi_s2idle_prepare_late(void) | ||
+static int acpi_s2idle_screen_off(void) | ||
{ | ||
- struct acpi_s2idle_dev_ops *handler; | ||
- | ||
if (!lps0_device_handle || sleep_no_lps0) | ||
return 0; | ||
|
||
- if (pm_debug_messages_on) | ||
- lpi_check_constraints(); | ||
+ switch (lps0_dsm_state) { | ||
+ case ACPI_LPS0_SCREEN_OFF_AMD: | ||
+ case ACPI_LPS0_SCREEN_OFF: | ||
+ if (pm_debug_messages_on) | ||
+ acpi_handle_info(lps0_device_handle, | ||
+ "already in %s\n", | ||
+ acpi_sleep_dsm_state_to_str(lps0_dsm_state)); | ||
+ return 0; | ||
+ } | ||
|
||
- /* Screen off */ | ||
if (lps0_dsm_func_mask > 0) | ||
acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? | ||
ACPI_LPS0_SCREEN_OFF_AMD : | ||
@@ -560,6 +564,47 @@ int acpi_s2idle_prepare_late(void) | ||
acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF, | ||
lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); | ||
|
||
+ return 0; | ||
+} | ||
+ | ||
+static int acpi_s2idle_screen_on(void) | ||
+{ | ||
+ if (!lps0_device_handle || sleep_no_lps0) | ||
+ return 0; | ||
+ | ||
+ switch (lps0_dsm_state) { | ||
+ case ACPI_LPS0_SCREEN_ON_AMD: | ||
+ case ACPI_LPS0_SCREEN_ON: | ||
+ if (pm_debug_messages_on) | ||
+ acpi_handle_info(lps0_device_handle, | ||
+ "already in %s\n", | ||
+ acpi_sleep_dsm_state_to_str(lps0_dsm_state)); | ||
+ return 0; | ||
+ } | ||
+ | ||
+ if (lps0_dsm_func_mask_microsoft > 0) | ||
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, | ||
+ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); | ||
+ | ||
+ if (lps0_dsm_func_mask > 0) | ||
+ acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? | ||
+ ACPI_LPS0_SCREEN_ON_AMD : | ||
+ ACPI_LPS0_SCREEN_ON, | ||
+ lps0_dsm_func_mask, lps0_dsm_guid); | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+int acpi_s2idle_prepare_late(void) | ||
+{ | ||
+ struct acpi_s2idle_dev_ops *handler; | ||
+ | ||
+ if (!lps0_device_handle || sleep_no_lps0) | ||
+ return 0; | ||
+ | ||
+ if (pm_debug_messages_on) | ||
+ lpi_check_constraints(); | ||
+ | ||
/* LPS0 entry */ | ||
if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd()) | ||
acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD, | ||
@@ -623,20 +668,18 @@ void acpi_s2idle_restore_early(void) | ||
acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, | ||
lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); | ||
} | ||
+} | ||
|
||
- /* Screen on */ | ||
- if (lps0_dsm_func_mask_microsoft > 0) | ||
- acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, | ||
- lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); | ||
- if (lps0_dsm_func_mask > 0) | ||
- acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? | ||
- ACPI_LPS0_SCREEN_ON_AMD : | ||
- ACPI_LPS0_SCREEN_ON, | ||
- lps0_dsm_func_mask, lps0_dsm_guid); | ||
+static int acpi_x86_s2idle_begin(void) | ||
+{ | ||
+ lps0_dsm_state = -1; | ||
+ return acpi_s2idle_begin(); | ||
} | ||
|
||
static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = { | ||
- .begin = acpi_s2idle_begin, | ||
+ .begin = acpi_x86_s2idle_begin, | ||
+ .screen_off = acpi_s2idle_screen_off, | ||
+ .screen_on = acpi_s2idle_screen_on, | ||
.prepare = acpi_s2idle_prepare, | ||
.prepare_late = acpi_s2idle_prepare_late, | ||
.check = acpi_s2idle_check, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters