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

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