[PATCH] apple-gmux: Restore switch registers on suspend/resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux