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

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