All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org
Cc: Darren Hart <dvhart@infradead.org>
Subject: [PATCH v5 09/12] apple-gmux: Add helper for presence detect
Date: Mon, 11 Jan 2016 20:09:20 +0100	[thread overview]
Message-ID: <89c23769058a340e5e11d4a7102f3793d3b0c94c.1452525860.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1452525860.git.lukas@wunner.de>

Centralize gmux' ACPI HID in a header file and add apple_gmux_present().
This can be used by other drivers to activate quirks specific to dual
GPU MacBook Pros & Mac Pros. The alternative would be to hardcode DMI
or PCI IDs and amend them whenever Apple introduces a new machine.

Tested-by: Lukas Wunner <lukas@wunner.de>
    [MBP  9,1 2012  intel IVB + nvidia GK107  pre-retina  15"]
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 Documentation/DocBook/gpu.tmpl    |  4 ++++
 drivers/platform/x86/apple-gmux.c |  3 ++-
 include/linux/apple-gmux.h        | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/apple-gmux.h

diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl
index 88e7c39..a5e6e3c 100644
--- a/Documentation/DocBook/gpu.tmpl
+++ b/Documentation/DocBook/gpu.tmpl
@@ -3677,6 +3677,10 @@ int num_ioctls;</synopsis>
         <title>Backlight control</title>
 !Pdrivers/platform/x86/apple-gmux.c Backlight control
       </sect2>
+      <sect2>
+        <title>Public functions</title>
+!Iinclude/linux/apple-gmux.h
+      </sect2>
     </sect1>
   </chapter>
 
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 1384a39..4034d2d 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -19,6 +19,7 @@
 #include <linux/acpi.h>
 #include <linux/pnp.h>
 #include <linux/apple_bl.h>
+#include <linux/apple-gmux.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
@@ -828,7 +829,7 @@ static void gmux_remove(struct pnp_dev *pnp)
 }
 
 static const struct pnp_device_id gmux_device_ids[] = {
-	{"APP000B", 0},
+	{GMUX_ACPI_HID, 0},
 	{"", 0}
 };
 
diff --git a/include/linux/apple-gmux.h b/include/linux/apple-gmux.h
new file mode 100644
index 0000000..feebc28
--- /dev/null
+++ b/include/linux/apple-gmux.h
@@ -0,0 +1,39 @@
+/*
+ * apple-gmux.h - microcontroller built into dual GPU MacBook Pro & Mac Pro
+ * Copyright (C) 2015 Lukas Wunner <lukas@wunner.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LINUX_APPLE_GMUX_H
+#define LINUX_APPLE_GMUX_H
+
+#include <linux/acpi.h>
+
+#define GMUX_ACPI_HID "APP000B"
+
+/**
+ * apple_gmux_present() - detect if gmux is built into the machine
+ *
+ * Drivers may use this to activate quirks specific to dual GPU MacBook Pros
+ * and Mac Pros, e.g. for deferred probing, runtime pm and backlight.
+ *
+ * Return: %true if gmux is present and the kernel was configured
+ * with CONFIG_APPLE_GMUX, %false otherwise.
+ */
+static inline bool apple_gmux_present(void)
+{
+	return IS_ENABLED(CONFIG_APPLE_GMUX) && acpi_dev_present(GMUX_ACPI_HID);
+}
+
+#endif /* LINUX_APPLE_GMUX_H */
-- 
1.8.5.2 (Apple Git-48)

  parent reply	other threads:[~2016-01-11 19:11 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 19:09 [PATCH v5 00/12] Enable GPU switching on pre-retina MacBook Pro Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 05/12] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 07/12] drm/nouveau: " Lukas Wunner
2016-01-11 19:09 ` Lukas Wunner [this message]
2016-01-11 19:09 ` [PATCH v5 06/12] drm/i915: " Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 10/12] drm/i915: Defer probe if gmux is present but its driver isn't Lukas Wunner
2016-02-09  9:04   ` Daniel Vetter
2016-02-14 12:10     ` Lukas Wunner
2016-02-14 12:46       ` Daniel Vetter
2016-02-16 15:58         ` Lukas Wunner
2016-02-16 16:08           ` Daniel Vetter
2016-02-18 20:34             ` Lukas Wunner
2016-02-18 21:39               ` Daniel Vetter
2016-02-18 22:20                 ` Lukas Wunner
2016-02-18 23:11                   ` Daniel Vetter
2016-02-18 23:53                     ` Deucher, Alexander
2016-01-11 19:09 ` [PATCH v5 02/12] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 03/12] apple-gmux: Track switch state Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 01/12] vga_switcheroo: Add handler flags infrastructure Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 04/12] apple-gmux: Add switch_ddc support Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 11/12] drm/nouveau: Defer probe if gmux is present but its driver isn't Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 12/12] drm/radeon: " Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 08/12] drm/radeon: Switch DDC when reading the EDID Lukas Wunner
     [not found] ` <cover.1452525860.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-02-01 22:49   ` [PATCH v5 00/12] Enable GPU switching on pre-retina MacBook Pro Lukas Wunner
2016-02-02  1:10     ` Dave Airlie
2016-02-02  1:19       ` Dave Airlie
2016-02-02 15:03       ` Lukas Wunner
     [not found]     ` <20160201224944.GA12944-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-02-02  6:33       ` Pierre Moreau
2016-02-08 18:10 ` Darren Hart
     [not found]   ` <20160208181000.GL1779-Z5kFBHtJu+EzCVHREhWfF0EOCMrvLtNR@public.gmane.org>
2016-02-09  9:01     ` Daniel Vetter
2016-03-04 16:12 ` Bastien Nocera
2016-03-05 14:16   ` [Intel-gfx] [PATCH v5 00/12] Enable GPU switching on pre-retina?MacBook Pro Lukas Wunner
2016-03-05 16:31     ` Bastien Nocera
2016-03-09 23:30       ` Dave Airlie
2016-03-10 15:29         ` Bastien Nocera
2016-03-10 15:33           ` Bastien Nocera
2016-03-14 12:41       ` [Intel-gfx] " Lukas Wunner
2016-03-14 13:37         ` Bastien Nocera
2016-03-15  7:51           ` Daniel Vetter
2016-03-15 11:10           ` [Intel-gfx] " Dave Airlie
2016-03-15 11:55             ` Bastien Nocera
2016-04-05 16:59         ` Bastien Nocera
2016-04-05 17:43           ` Lukas Wunner
2016-03-05 17:28     ` [Intel-gfx] " Bastien Nocera
2016-03-05 18:10     ` Alex Deucher
2016-03-15 17:54       ` Lukas Wunner
2016-03-15 18:33         ` Alex Deucher
2016-03-15 20:41           ` Lukas Wunner

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=89c23769058a340e5e11d4a7102f3793d3b0c94c.1452525860.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvhart@infradead.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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.