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

4724a4
From f374410a00145d1703633547e90f10d43b3ded9f Mon Sep 17 00:00:00 2001
4724a4
From: Ben Skeggs <bskeggs@redhat.com>
4724a4
Date: Thu, 27 Apr 2017 10:52:24 +1000
4724a4
Subject: [PATCH] xfree86: use modesetting driver by default on GeForce 8 and
4724a4
 newer
4724a4
4724a4
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4724a4
---
4724a4
 hw/xfree86/common/xf86pciBus.c | 22 ++++++++++++++++++++++
4724a4
 1 file changed, 22 insertions(+)
4724a4
4724a4
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
4724a4
index 682e723..2c36a3d 100644
4724a4
--- a/hw/xfree86/common/xf86pciBus.c
4724a4
+++ b/hw/xfree86/common/xf86pciBus.c
4724a4
@@ -37,6 +37,7 @@
4724a4
 #include <unistd.h>
4724a4
 #include <X11/X.h>
4724a4
 #include <pciaccess.h>
4724a4
+#include <xf86drm.h>
4724a4
 #include "os.h"
4724a4
 #include "Pci.h"
4724a4
 #include "xf86.h"
4724a4
@@ -1146,8 +1147,29 @@ xf86VideoPtrToDriverList(struct pci_device *dev,
4724a4
         break;
4724a4
     case 0x10de:
4724a4
     case 0x12d2:
4724a4
+    {
4724a4
+        char busid[32];
4724a4
+        int fd;
4724a4
+
4724a4
+        snprintf(busid, sizeof(busid), "pci:%04x:%02x:%02x.%d",
4724a4
+                 dev->domain, dev->bus, dev->dev, dev->func);
4724a4
+
4724a4
+	/* 'modesetting' is preferred for GeForce 8 and newer GPUs */
4724a4
+        fd = drmOpenWithType("nouveau", busid, DRM_NODE_RENDER);
4724a4
+        if (fd >= 0) {
4724a4
+            uint64_t args[] = { 11 /* NOUVEAU_GETPARAM_CHIPSET_ID */, 0 };
4724a4
+            int ret = drmCommandWriteRead(fd, 0 /* DRM_NOUVEAU_GETPARAM */,
4724a4
+                                          &args, sizeof(args));
4724a4
+            drmClose(fd);
4724a4
+            if (ret == 0) {
4724a4
+                if (args[1] == 0x050 || args[1] >= 0x80)
4724a4
+                    break;
4724a4
+            }
4724a4
+        }
4724a4
+
4724a4
         driverList[0] = "nouveau";
4724a4
         break;
4724a4
+    }
4724a4
     case 0x1106:
4724a4
         driverList[0] = "openchrome";
4724a4
         break;
4724a4
-- 
4724a4
1.8.3.1
4724a4