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

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