[PATCH 00/11] Enable gpu switching on the MacBook Pro

Lukas Wunner lukas at wunner.de
Sat Apr 25 07:20:04 PDT 2015


Hi,

On Tue, Apr 21, 2015 at 08:49:35PM +0100, Matthew Garrett wrote:
> My testing suggested that changing the DDC lines didn't change auxch, so
> this approach doesn't work for eDP. Have you found otherwise?

Disassembling the OS X gmux driver (AppleMuxControl 3.6.22) revealed
that register 0x7F is set prior to accessing the eDP connector.
It seems plausible that this register switches the AUX channel
between GPUs.

More specifically, there's a method AppleMuxControl::TickleStateMachine()
which puts the gmux into various states. The code to switch only the
DDC lines starts at address d4bc and sets register 0x7F, then calls
AppleMuxControl::copyEDPConfig(), then sets register 0x28 (DDC).

Likewise, the code to switch the entire display starts at address db6a,
it sets registers 0x10 (DISPLAY), 0x28 (DDC), 0x40 (EXTERNAL) and 0x7F,
then calls calling AppleMuxControl::fbDoEDPLinkConfig().

Included below is a tentative patch to set register 0x7F when switching
the DDC lines. It would be great if someone with a retina could test
the patchset I've posted plus this tentative patch since I can't test it
myself.

Here's the lowdown on which patches are needed for each MBP generation:

* MacBookPro6 / 8 / 9 (pre-retina):
  The patchset I've posted plus this one to enable dual channel LVDS:
  http://lists.freedesktop.org/archives/intel-gfx/2015-April/064850.html
  (This obviates the need to specify i915.lvds_channel_mode=2)

* MacBookPro10 (first-gen retina):
  The patchset I've posted plus the tentative patch below.

* MacBookPro11 (second-gen retina):
  The patchset I've posted plus the tentative patch below.
  Fellow gmux hackers Andreas Heider and Bruno Bierbaumer tell me that
  additionally, this patch is needed otherwise the i915 gpu is turned off:
  https://www.marc.info/?l=grub-deavel&m=141586614924917&w=2

Kind regards,

Lukas

-- >8 --

diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 05bba92..719cfd3 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -60,6 +60,7 @@ static struct apple_gmux_data *apple_gmux_data;
 #define GMUX_PORT_DISCRETE_POWER	0x50
 #define GMUX_PORT_MAX_BRIGHTNESS	0x70
 #define GMUX_PORT_BRIGHTNESS		0x74
+#define GMUX_PORT_SWITCH_AUXCH		0x7F
 #define GMUX_PORT_VALUE			0xc2
 #define GMUX_PORT_READ			0xd0
 #define GMUX_PORT_WRITE			0xd4
@@ -285,10 +286,13 @@ static int gmux_switch_ddc(enum vga_switcheroo_client_id id)
 	if (id == old_ddc_owner)
 		return old_ddc_owner;
 
-	if (id == VGA_SWITCHEROO_IGD)
+	if (id == VGA_SWITCHEROO_IGD) {
+		gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_AUXCH, 1);
 		gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 1);
-	else
+	} else {
+		gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_AUXCH, 2);
 		gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 2);
+	}
 
 	return old_ddc_owner;
 }


More information about the dri-devel mailing list