6c7b302
From d75ffcdbf8c1e3c8e0d46debcd533a9f2560f0a8 Mon Sep 17 00:00:00 2001
6c7b302
From: Hans De Goede <hdegoede@redhat.com>
6c7b302
Date: Mon, 12 Dec 2016 17:03:16 +0100
6c7b302
Subject: [PATCH xserver 5/6] xfree86: Allow overriding primary GPU detection
6c7b302
 from an OutputClass section
6c7b302
6c7b302
Allow using:
6c7b302
6c7b302
Option "PrimaryGPU" "yes"
6c7b302
6c7b302
In an OutputClass section to override the default primary GPU device
6c7b302
selection which selects the GPU used as output by the firmware.
6c7b302
6c7b302
If multiple output devices match an OutputClass section with
6c7b302
the PrimaryGPU option set, the first one enumerated becomes the
6c7b302
primary GPU.
6c7b302
6c7b302
Reviewed-by: Adam Jackson <ajax@redhat.com>
6c7b302
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6c7b302
---
6c7b302
 hw/xfree86/common/xf86platformBus.c | 19 +++++++++++++++++++
6c7b302
 hw/xfree86/man/xorg.conf.man        | 12 +++++++++++-
6c7b302
 2 files changed, 30 insertions(+), 1 deletion(-)
6c7b302
6c7b302
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
6c7b302
index 39b3248..fc17d15 100644
6c7b302
--- a/hw/xfree86/common/xf86platformBus.c
6c7b302
+++ b/hw/xfree86/common/xf86platformBus.c
6c7b302
@@ -286,6 +286,7 @@ xf86platformProbe(void)
6c7b302
 {
6c7b302
     int i;
6c7b302
     Bool pci = TRUE;
6c7b302
+    XF86ConfOutputClassPtr cl;
6c7b302
 
6c7b302
     config_odev_probe(xf86PlatformDeviceProbe);
6c7b302
 
6c7b302
@@ -301,6 +302,24 @@ xf86platformProbe(void)
6c7b302
         }
6c7b302
     }
6c7b302
 
6c7b302
+    /* First see if there is an OutputClass match marking a device as primary */
6c7b302
+    for (i = 0; i < xf86_num_platform_devices; i++) {
6c7b302
+        struct xf86_platform_device *dev = &xf86_platform_devices[i];
6c7b302
+        for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
6c7b302
+            if (!OutputClassMatches(cl, dev))
6c7b302
+                continue;
6c7b302
+
6c7b302
+            if (xf86CheckBoolOption(cl->option_lst, "PrimaryGPU", FALSE)) {
6c7b302
+                xf86Msg(X_CONFIG, "OutputClass \"%s\" setting %s as PrimaryGPU\n",
6c7b302
+                        cl->identifier, dev->attribs->path);
6c7b302
+                primaryBus.type = BUS_PLATFORM;
6c7b302
+                primaryBus.id.plat = dev;
6c7b302
+                return 0;
6c7b302
+            }
6c7b302
+        }
6c7b302
+    }
6c7b302
+
6c7b302
+    /* Then check for pci_device_is_boot_vga() */
6c7b302
     for (i = 0; i < xf86_num_platform_devices; i++) {
6c7b302
         struct xf86_platform_device *dev = &xf86_platform_devices[i];
6c7b302
 
6c7b302
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
6c7b302
index 8928a53..79b71a8 100644
6c7b302
--- a/hw/xfree86/man/xorg.conf.man
6c7b302
+++ b/hw/xfree86/man/xorg.conf.man
6c7b302
@@ -1285,11 +1285,21 @@ When an output device has been matched to the
6c7b302
 .B OutputClass
6c7b302
 section, any
6c7b302
 .B Option
6c7b302
-entries are applied to the device. See the
6c7b302
+entries are applied to the device. One
6c7b302
+.B OutputClass
6c7b302
+specific
6c7b302
+.B Option
6c7b302
+is recognized. See the
6c7b302
 .B Device
6c7b302
 section below for a description of the remaining
6c7b302
 .B Option
6c7b302
 entries.
6c7b302
+.TP 7
6c7b302
+.BI "Option \*qPrimaryGPU\*q \*q" boolean \*q
6c7b302
+This option specifies that the matched device should be treated as the
6c7b302
+primary GPU, replacing the selection of the GPU used as output by the
6c7b302
+firmware. If multiple output devices match an OutputClass section with
6c7b302
+the PrimaryGPU option set, the first one enumerated becomes the primary GPU.
6c7b302
 .SH "DEVICE SECTION"
6c7b302
 The config file may have multiple
6c7b302
 .B Device
6c7b302
-- 
6c7b302
2.9.3
6c7b302