Blame SOURCES/0001-xfree86-use-modesetting-driver-by-default-on-GeForce.patch

f34ecf
From aa2f34d80ef3118eae0cce73b610c36cdcb978fe Mon Sep 17 00:00:00 2001
f34ecf
From: Ben Skeggs <bskeggs@redhat.com>
f34ecf
Date: Sat, 22 Apr 2017 02:26:28 +1000
f34ecf
Subject: [PATCH xserver] xfree86: use modesetting driver by default on GeForce
f34ecf
 8 and newer
f34ecf
f34ecf
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f34ecf
---
f34ecf
 hw/xfree86/common/xf86pciBus.c | 20 ++++++++++++++++++++
f34ecf
 1 file changed, 20 insertions(+)
f34ecf
f34ecf
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
f34ecf
index 8158c2b62..78d1c947d 100644
f34ecf
--- a/hw/xfree86/common/xf86pciBus.c
f34ecf
+++ b/hw/xfree86/common/xf86pciBus.c
f34ecf
@@ -37,6 +37,7 @@
f34ecf
 #include <unistd.h>
f34ecf
 #include <X11/X.h>
f34ecf
 #include <pciaccess.h>
f34ecf
+#include <xf86drm.h>
f34ecf
 #include "os.h"
f34ecf
 #include "Pci.h"
f34ecf
 #include "xf86.h"
f34ecf
@@ -1190,6 +1191,25 @@ xf86VideoPtrToDriverList(struct pci_device *dev,
f34ecf
         int idx = 0;
f34ecf
 
61240a
 #if defined(__linux__) || defined(__NetBSD__)
f34ecf
+        char busid[32];
f34ecf
+        int fd;
f34ecf
+
f34ecf
+        snprintf(busid, sizeof(busid), "pci:%04x:%02x:%02x.%d",
f34ecf
+                 dev->domain, dev->bus, dev->dev, dev->func);
f34ecf
+
f34ecf
+	/* 'modesetting' is preferred for GeForce 8 and newer GPUs */
f34ecf
+        fd = drmOpenWithType("nouveau", busid, DRM_NODE_RENDER);
f34ecf
+        if (fd >= 0) {
f34ecf
+            uint64_t args[] = { 11 /* NOUVEAU_GETPARAM_CHIPSET_ID */, 0 };
f34ecf
+            int ret = drmCommandWriteRead(fd, 0 /* DRM_NOUVEAU_GETPARAM */,
f34ecf
+                                          &args, sizeof(args));
f34ecf
+            drmClose(fd);
f34ecf
+            if (ret == 0) {
f34ecf
+                if (args[1] == 0x050 || args[1] >= 0x80)
f34ecf
+                    break;
f34ecf
+            }
f34ecf
+        }
f34ecf
+
f34ecf
         driverList[idx++] = "nouveau";
f34ecf
 #endif
f34ecf
         driverList[idx++] = "nv";
f34ecf
-- 
f34ecf
2.12.2
f34ecf