1From aa2f34d80ef3118eae0cce73b610c36cdcb978fe Mon Sep 17 00:00:00 2001 2From: Ben Skeggs <bskeggs@redhat.com> 3Date: Sat, 22 Apr 2017 02:26:28 +1000 4Subject: [PATCH xserver] xfree86: use modesetting driver by default on GeForce 5 8 and newer 6 7Signed-off-by: Ben Skeggs <bskeggs@redhat.com> 8--- 9 hw/xfree86/common/xf86pciBus.c | 20 ++++++++++++++++++++ 10 1 file changed, 20 insertions(+) 11 12--- a/hw/xfree86/common/xf86pciBus.c 13+++ b/hw/xfree86/common/xf86pciBus.c 14@@ -37,6 +37,9 @@ 15 #include <unistd.h> 16 #include <X11/X.h> 17 #include <pciaccess.h> 18+#if defined(__linux__) || defined(__NetBSD__) 19+#include <xf86drm.h> 20+#endif 21 #include "os.h" 22 #include "Pci.h" 23 #include "xf86.h" 24@@ -1207,6 +1210,25 @@ xf86VideoPtrToDriverList(struct pci_devi 25 int idx = 0; 26 27 #if defined(__linux__) || defined(__NetBSD__) 28+ char busid[32]; 29+ int fd; 30+ 31+ snprintf(busid, sizeof(busid), "pci:%04x:%02x:%02x.%d", 32+ dev->domain, dev->bus, dev->dev, dev->func); 33+ 34+ /* 'modesetting' is preferred for GeForce 8 and newer GPUs */ 35+ fd = drmOpenWithType("nouveau", busid, DRM_NODE_RENDER); 36+ if (fd >= 0) { 37+ uint64_t args[] = { 11 /* NOUVEAU_GETPARAM_CHIPSET_ID */, 0 }; 38+ int ret = drmCommandWriteRead(fd, 0 /* DRM_NOUVEAU_GETPARAM */, 39+ &args, sizeof(args)); 40+ drmClose(fd); 41+ if (ret == 0) { 42+ if (args[1] == 0x050 || args[1] >= 0x80) 43+ break; 44+ } 45+ } 46+ 47 driverList[idx++] = "nouveau"; 48 #endif 49 driverList[idx++] = "nv"; 50