[Nouveau] [PATCH] nv: improve KMS detection

Marcin Slusarz marcin.slusarz at gmail.com
Sun May 23 12:46:45 PDT 2010


1) DRICreatePCIBusID belongs to xserver dri module, so when it's
   unavailable we can't format string for drmCheckModesettingSupported.
   (This situation happened to me with KMS enabled and dri module moved
   somewhere else by Gentoo's "eselect opengl set nvidia" switcher)
   Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm),
   we have to link directly to libdrm.

Signed-off-by: Marcin Slusarz <marcin.slusarz at gmail.com>
---
 src/Makefile.am |    2 +-
 src/nv_driver.c |   11 +++--------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 5d57010..8b23e21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,7 +25,7 @@
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 AM_CFLAGS = @XMODES_CFLAGS@ @XORG_CFLAGS@ $(LIBDRM_CFLAGS)
 nv_drv_la_LTLIBRARIES = nv_drv.la
-nv_drv_la_LDFLAGS = -module -avoid-version
+nv_drv_la_LDFLAGS = -module -avoid-version $(LIBDRM_LIBS)
 nv_drv_ladir = @moduledir@/drivers
 
 nv_drv_la_SOURCES = $(nv_sources) $(riva_sources) $(g80_sources)
diff --git a/src/nv_driver.c b/src/nv_driver.c
index e10ae0c..6651cd4 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -836,18 +836,13 @@ NVIsSupported(CARD32 id)
 }
 
 #ifdef HAVE_KMS
-static Bool NVKernelModesettingEnabled(struct pci_device *device)
+static Bool NVKernelModesettingEnabled(struct pci_device *dev)
 {
-    char *busIdString;
+    char busIdString[20];
     int ret;
 
-    if (!xf86LoaderCheckSymbol("DRICreatePCIBusID"))
-        return FALSE;
-
-    busIdString = DRICreatePCIBusID(device);
-
+    snprintf(busIdString, 20, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus, dev->dev, dev->func);
     ret = drmCheckModesettingSupported(busIdString);
-    xfree(busIdString);
 
     return (ret == 0);
 }
-- 
1.7.1



More information about the Nouveau mailing list