Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anonymous/3083214 to your computer and use it in GitHub Desktop.
Save anonymous/3083214 to your computer and use it in GitHub Desktop.
0001-apple-gmux-Restore-switch-registers-on-suspend-resum.patch
From a2f5c540b903143e5a0b025cd2f81a69ad809072 Mon Sep 17 00:00:00 2001
From: Arun Raghavan <arun.raghavan@collabora.co.uk>
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 <arun.raghavan@collabora.co.uk>
---
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