From patchwork Sat Apr 25 14:20:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 6274631 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C07049F389 for ; Sat, 25 Apr 2015 14:20:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C86FC2018E for ; Sat, 25 Apr 2015 14:20:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2FDA9200DB for ; Sat, 25 Apr 2015 14:20:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 475176E157; Sat, 25 Apr 2015 07:20:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.hostsharing.net (mailout3.hostsharing.net [176.9.242.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 77CCC6E157 for ; Sat, 25 Apr 2015 07:20:10 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout3.hostsharing.net (Postfix) with ESMTPS id 16EB61040CB6B; Sat, 25 Apr 2015 16:20:08 +0200 (CEST) Received: from localhost (5-38-90-81.adsl.cmo.de [81.90.38.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 5BBF1600067F; Sat, 25 Apr 2015 16:20:06 +0200 (CEST) Date: Sat, 25 Apr 2015 16:20:04 +0200 From: Lukas Wunner To: Matthew Garrett Subject: Re: [PATCH 00/11] Enable gpu switching on the MacBook Pro Message-ID: <20150425142004.GA1108@wunner.de> References: <20150421194935.GA13517@srcf.ucam.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150421194935.GA13517@srcf.ucam.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Andreas Heider , Bruno Bierbaumer , Seth Forshee , dri-devel@lists.freedesktop.org, Dave Airlie , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }