All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Andreas Heider <andreas@meetr.de>,
	Bruno Bierbaumer <bruno@bierbaumer.net>,
	Seth Forshee <seth.forshee@canonical.com>,
	dri-devel@lists.freedesktop.org, Dave Airlie <airlied@redhat.com>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 00/11] Enable gpu switching on the MacBook Pro
Date: Sat, 25 Apr 2015 16:20:04 +0200	[thread overview]
Message-ID: <20150425142004.GA1108@wunner.de> (raw)
In-Reply-To: <20150421194935.GA13517@srcf.ucam.org>

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;
 }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-04-25 14:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21  9:58 [PATCH 00/11] Enable gpu switching on the MacBook Pro Lukas Wunner
2012-09-07 15:22 ` [PATCH 01/11] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2012-09-07 15:22 ` [PATCH 02/11] vga_switcheroo: Add helper function to get the active client Lukas Wunner
2012-09-07 15:22 ` [PATCH 03/11] apple-gmux: Add switch_ddc support Lukas Wunner
2012-09-07 15:22 ` [PATCH 04/11] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2012-12-22  2:52 ` [PATCH 05/11] vga_switcheroo: Lock/unlock DDC lines Lukas Wunner
2014-03-05 22:34 ` [PATCH 09/11] apple-gmux: Assign apple_gmux_data before registering Lukas Wunner
2015-03-27 11:29 ` [PATCH 06/11] vga_switcheroo: Lock/unlock DDC lines harder Lukas Wunner
2015-04-19 15:01 ` [PATCH 10/11] drm/i915: Reprobe connectors if vga_switcheroo handler registers late Lukas Wunner
2015-04-21 11:50   ` Chris Wilson
2015-04-21 12:16     ` Lukas Wunner
2015-04-21 12:37       ` Chris Wilson
2015-04-19 15:18 ` [PATCH 11/11] drm/nouveau: Pause between setting gpu to D3hot and cutting the power Lukas Wunner
2015-04-20 10:08 ` [PATCH 08/11] vga_switcheroo: Reprobe connectors if handler registers late Lukas Wunner
2015-04-21  8:39 ` [PATCH 07/11] Revert "vga_switcheroo: Add helper function to get the active client" Lukas Wunner
2015-04-21 19:49 ` [PATCH 00/11] Enable gpu switching on the MacBook Pro Matthew Garrett
2015-04-22 13:48   ` Lukas Wunner
2015-04-25 14:20   ` Lukas Wunner [this message]
2015-05-02 19:03     ` Lu, Ran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150425142004.GA1108@wunner.de \
    --to=lukas@wunner.de \
    --cc=airlied@redhat.com \
    --cc=andreas@meetr.de \
    --cc=bruno@bierbaumer.net \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=seth.forshee@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.