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

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