Forked from anonymous/0001-apple-gmux-Restore-switch-registers-on-suspend-resum.patch.txt
Created
July 10, 2012 13:28
-
-
Save shadeslayer/3083222 to your computer and use it in GitHub Desktop.
0001-apple-gmux-Restore-switch-registers-on-suspend-resum.patch
This file contains hidden or 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
From a2f5c540b903143e5a0b025cd2f81a69ad809072 Mon Sep 17 00:00:00 2001 | |
From: Arun Raghavan <[email protected]> | |
Date: Tue, 10 Jul 2012 08:55:58 +0530 | |
Subject: [PATCH] apple-gmux: Restore switch registers on suspend/resume | |
After suspend and resume, the values of these registers seem to change | |
from what they were at suspend time, potentially preventing the actual | |
output lines from being enabled post-resume. This saves relevant state | |
at suspend and restores it when resumed. | |
This is at least required on the MacBook Pro 8.2 when the Intel GPU is | |
manually selected in GRUB config before the kernel is loaded. | |
Signed-off-by: Arun Raghavan <[email protected]> | |
--- | |
drivers/platform/x86/apple-gmux.c | 29 ++++++++++++++++++++++++++++- | |
1 files changed, 28 insertions(+), 1 deletions(-) | |
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c | |
index 694a15a..5a5d005 100644 | |
--- a/drivers/platform/x86/apple-gmux.c | |
+++ b/drivers/platform/x86/apple-gmux.c | |
@@ -26,6 +26,11 @@ struct apple_gmux_data { | |
unsigned long iolen; | |
struct backlight_device *bdev; | |
+ | |
+ bool was_suspended; | |
+ u8 save_switch_ddc; | |
+ u8 save_switch_disp; | |
+ u8 save_switch_ext; | |
}; | |
/* | |
@@ -87,8 +92,30 @@ static int gmux_update_status(struct backlight_device *bd) | |
struct apple_gmux_data *gmux_data = bl_get_data(bd); | |
u32 brightness = bd->props.brightness; | |
- if (bd->props.state & BL_CORE_SUSPENDED) | |
+ if (bd->props.state & BL_CORE_SUSPENDED) { | |
+ /* Save mux settings for output lines since they get reset on | |
+ * suspend */ | |
+ gmux_data->was_suspended = TRUE; | |
+ gmux_data->save_switch_ddc = gmux_read8(gmux_data, | |
+ GMUX_PORT_SWITCH_DDC); | |
+ gmux_data->save_switch_disp = gmux_read8(gmux_data, | |
+ GMUX_PORT_SWITCH_DISPLAY); | |
+ gmux_data->save_switch_ext = gmux_read8(gmux_data, | |
+ GMUX_PORT_SWITCH_EXTERNAL); | |
+ | |
return 0; | |
+ } | |
+ | |
+ if (gmux_data->was_suspended) { | |
+ /* Restore pre-suspend values for output lines */ | |
+ gmux_data->was_suspended = FALSE; | |
+ gmux_write8(gmux_data, GMUX_PORT_SWITCH_DDC, | |
+ gmux_data->save_switch_ddc); | |
+ gmux_write8(gmux_data, GMUX_PORT_SWITCH_DISPLAY, | |
+ gmux_data->save_switch_disp); | |
+ gmux_write8(gmux_data, GMUX_PORT_SWITCH_EXTERNAL, | |
+ gmux_data->save_switch_ext); | |
+ } | |
/* | |
* Older gmux versions require writing out lower bytes first then | |
-- | |
1.7.8.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment