[Nouveau] [PATCH] nv: improve KMS detection

Ben Skeggs skeggsb at gmail.com
Sun May 23 15:37:03 PDT 2010


On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> 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.
An alternative, which we use in Fedora for nv/vesa is to use
pci_device_has_kernel_driver() from libpciaccess.

Ben.

> 
> 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);
>  }




More information about the Nouveau mailing list