From a4692ac2d639a4a2a32e979ed0c47cbeb0800ada Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 28 Oct 2009 23:47:10 +0100 Subject: Make compilation of KMS parts optional Configure with --enable-kms to enable the KMS parts. With this option, the driver will include both traditional (fbdev-based) and KMS drivers, and will choose between the two at runtime depending on the kernel. Without this option, the driver will be exactly as the traditional driver. --- configure.ac | 26 ++++++++++++++++++++++++-- src/Makefile.am | 19 +++++++++++-------- src/glamo-driver.c | 8 ++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index d9b08a9..f7fac57 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,7 @@ AC_ARG_ENABLE(engine-ioctls, AS_HELP_STRING([--enable-engine-ioctls], ioctls to enable/disable engines. This requires kernel support. (default: disabled)]), [HAVE_ENGINE_IOCTLS=$enableval], [HAVE_ENGINE_IOCTLS=no]) + # Checks for extensions XORG_DRIVER_CHECK_EXT(RANDR, randrproto) XORG_DRIVER_CHECK_EXT(RENDER, renderproto) @@ -81,9 +82,28 @@ if test "x$HAVE_ENGINE_IOCTLS" = xyes; then AC_DEFINE(HAVE_ENGINE_IOCTLS, 1, [Use ioctls to enable/disable engines]) fi +# Check if KMS is to be included +AC_MSG_CHECKING([whether to use KMS]) +AC_DEFINE(ENABLE_KMS, 1, [Define to 1 if KMS is to be supported]) +AC_ARG_ENABLE(kms, +[ --enable-kms Include support for kernel modesetting (KMS)], +[case "${enableval}" in + yes) kms=true + AC_MSG_RESULT([yes]) ;; + no) kms=false + AC_MSG_RESULT([no]) ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-kms) ;; +esac], +[kms=false +AC_MSG_RESULT([no])]) +AM_CONDITIONAL([ENABLE_KMS], test x$kms = xtrue) +AC_SUBST([ENABLE_KMS]) + # Checks for libraries. -PKG_CHECK_MODULES(DRI, [libdrm xf86driproto]) -CFLAGS="$XORG_CFLAGS $DRI_CFLAGS" +if test x$kms = xtrue; then + PKG_CHECK_MODULES(DRI, [libdrm xf86driproto]) + AC_SUBST([LIBDRM_LIBS]) +fi # Checks for header files. AC_HEADER_STDC @@ -97,6 +117,8 @@ AC_SUBST([DRIVER_NAME]) XORG_MANPAGE_SECTIONS XORG_RELEASE_VERSION +CFLAGS="$XORG_CFLAGS $DRI_CFLAGS" + AC_OUTPUT([ Makefile src/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index a1e8d0a..59e88a9 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 = @XORG_CFLAGS@ @DRI_CFLAGS@ -pedantic -Wall -Werror -std=gnu99 glamo_drv_la_LTLIBRARIES = glamo_drv.la -glamo_drv_la_LDFLAGS = -module -avoid-version -ldrm -ldrm_glamo +glamo_drv_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ glamo_drv_ladir = @moduledir@/drivers glamo_drv_la_SOURCES = \ @@ -35,10 +35,13 @@ glamo_drv_la_SOURCES = \ glamo-draw.c \ glamo-display.c \ glamo-output.c \ - glamo-engine.c \ - glamo-kms-driver.c \ - glamo-kms-crtc.c \ - glamo-kms-output.c \ - glamo-dri2.c \ - glamo-kms-exa.c \ - glamo-drm.c + glamo-engine.c + +if ENABLE_KMS +glamo_drv_la_SOURCES += glamo-kms-driver.c \ + glamo-kms-crtc.c \ + glamo-kms-output.c \ + glamo-dri2.c \ + glamo-kms-exa.c \ + glamo-drm.c +endif diff --git a/src/glamo-driver.c b/src/glamo-driver.c index 17b661e..283825e 100644 --- a/src/glamo-driver.c +++ b/src/glamo-driver.c @@ -325,6 +325,8 @@ GlamoFbdevProbe(DriverPtr drv, GDevPtr *devSections, int numDevSections) return foundScreen; } +#ifdef ENABLE_KMS + static Bool GlamoKMSProbe(DriverPtr drv, GDevPtr *devSections, int numDevSections) { @@ -367,6 +369,8 @@ GlamoKMSProbe(DriverPtr drv, GDevPtr *devSections, int numDevSections) return foundScreen; } +#endif /* ENABLE_KMS */ + static Bool GlamoProbe(DriverPtr drv, int flags) { @@ -384,11 +388,15 @@ GlamoProbe(DriverPtr drv, int flags) if (numDevSections <= 0) return FALSE; /* Is today a good day to use KMS? */ +#ifdef ENABLE_KMS if ( GlamoKernelModesettingAvailable() ) { foundScreen = GlamoKMSProbe(drv, devSections, numDevSections); } else { foundScreen = GlamoFbdevProbe(drv, devSections, numDevSections); } +#else /* ENABLE_KMS */ + foundScreen = GlamoFbdevProbe(drv, devSections, numDevSections); +#endif /* ENABLE_KMS */ xfree(devSections); TRACE("probe done"); -- cgit v1.2.3