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

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