summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2010-02-11 22:04:53 +0100
committerJakob Bornecrantz <jakob@vmware.com>2010-02-11 22:14:14 +0100
commitc4f5bf8ea45b80c2ac4a5eec65ff58f148fb2807 (patch)
treeff65550002c3e21d0e1d403ac8ae58b59448e108
parent0d9d1724dbe113dcc02736a8ca80ab540057cb5e (diff)
Add a chain loading module to load new vmwgfx driver if kernel module is loaded
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am53
-rw-r--r--src/vmware.c23
-rw-r--r--src/vmwaremodule.c142
4 files changed, 185 insertions, 34 deletions
diff --git a/configure.ac b/configure.ac
index 0f13a9e..9099398 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
# Checks for pkg-config packages
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.1 xproto fontsproto $REQUIRED_MODULES])
+PKG_CHECK_MODULES(DRM, [libdrm])
PKG_CHECK_EXISTS([xorg-server >= 1.1.0],
[AC_DEFINE([HAVE_XORG_SERVER_1_1_0], 1,
diff --git a/src/Makefile.am b/src/Makefile.am
index 48ec1b0..17677f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,31 +23,38 @@
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
-AM_CFLAGS = @XORG_CFLAGS@
+AM_CFLAGS = @XORG_CFLAGS@ @DRM_CFLAGS@
+
+vmwlegacy_drv_la_LTLIBRARIES = vmwlegacy_drv.la
+vmwlegacy_drv_la_LDFLAGS = -module -avoid-version
+vmwlegacy_drv_ladir = @moduledir@/drivers
+
+vmwlegacy_drv_la_SOURCES = \
+ bits2pixels.c \
+ bits2pixels.h \
+ guest_os.h \
+ includeCheck.h \
+ svga_escape.h \
+ svga_limits.h \
+ svga_modes.h \
+ svga_overlay.h \
+ svga_reg.h \
+ svga_struct.h \
+ vm_basic_types.h \
+ vm_device_version.h \
+ vmware.c \
+ vmwarecurs.c \
+ vmware.h \
+ vmwarectrl.c \
+ vmwarectrl.h \
+ vmwarectrlproto.h \
+ vmwarexinerama.c \
+ vmwarevideo.c \
+ vmwaremodes.c
+
vmware_drv_la_LTLIBRARIES = vmware_drv.la
vmware_drv_la_LDFLAGS = -module -avoid-version
vmware_drv_ladir = @moduledir@/drivers
vmware_drv_la_SOURCES = \
- bits2pixels.c \
- bits2pixels.h \
- guest_os.h \
- includeCheck.h \
- svga_escape.h \
- svga_limits.h \
- svga_modes.h \
- svga_overlay.h \
- svga_reg.h \
- svga_struct.h \
- vm_basic_types.h \
- vm_device_version.h \
- vmware.c \
- vmwarecurs.c \
- vmware.h \
- vmwarectrl.c \
- vmwarectrl.h \
- vmwarectrlproto.h \
- vmwarexinerama.c \
- vmwarevideo.c \
- vmwaremodes.c
-
+ vmwaremodule.c
diff --git a/src/vmware.c b/src/vmware.c
index bae2d56..0785456 100644
--- a/src/vmware.c
+++ b/src/vmware.c
@@ -81,8 +81,8 @@ char rcsId_vmware[] =
#define VMW_INNERSTRINGIFY(s) #s
#define VMW_STRING(str) VMW_INNERSTRINGIFY(str)
-#define VMWARE_NAME "VMWARE"
-#define VMWARE_DRIVER_NAME "vmware"
+#define VMWARE_NAME "vmwlegacy"
+#define VMWARE_DRIVER_NAME "vmwlegacy"
#define VMWARE_MAJOR_VERSION 10
#define VMWARE_MINOR_VERSION 16
#define VMWARE_PATCHLEVEL 9
@@ -188,8 +188,8 @@ static const char *shadowfbSymbols[] = {
#endif /* HAVE_XORG_SERVER_1_7_0 */
#ifdef XFree86LOADER
-static XF86ModuleVersionInfo vmwareVersRec = {
- "vmware",
+static XF86ModuleVersionInfo vmwlegacyVersRec = {
+ VMWARE_DRIVER_NAME,
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
@@ -2021,7 +2021,7 @@ VMWAREProbe(DriverPtr drv, int flags)
#endif
-_X_EXPORT DriverRec VMWARE = {
+_X_EXPORT DriverRec vmwlegacy = {
VMWARE_DRIVER_VERSION,
VMWARE_DRIVER_NAME,
VMWAREIdentify,
@@ -2043,22 +2043,23 @@ _X_EXPORT DriverRec VMWARE = {
};
#ifdef XFree86LOADER
-static MODULESETUPPROTO(vmwareSetup);
+static MODULESETUPPROTO(vmwlegacySetup);
-_X_EXPORT XF86ModuleData vmwareModuleData = {
- &vmwareVersRec,
- vmwareSetup,
+_X_EXPORT XF86ModuleData vmwlegacyModuleData = {
+ &vmwlegacyVersRec,
+ vmwlegacySetup,
NULL
};
static pointer
-vmwareSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+vmwlegacySetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
static Bool setupDone = FALSE;
if (!setupDone) {
setupDone = TRUE;
- xf86AddDriver(&VMWARE, module, VMWARE_DRIVER_FUNC);
+
+ xf86AddDriver(&vmwlegacy, module, VMWARE_DRIVER_FUNC);
LoaderRefSymLists(vgahwSymbols, fbSymbols, ramdacSymbols,
shadowfbSymbols, NULL);
diff --git a/src/vmwaremodule.c b/src/vmwaremodule.c
new file mode 100644
index 0000000..826310b
--- /dev/null
+++ b/src/vmwaremodule.c
@@ -0,0 +1,142 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#include <xorg-server.h>
+#include <xf86.h>
+#include <xf86drm.h>
+
+
+/*
+ * Defines and exported module info.
+ */
+
+#define VMWARE_DRIVER_NAME "vmware"
+#define VMWGFX_DRIVER_NAME "vmwgfx"
+#define VMWLEGACY_DRIVER_NAME "vmwlegacy"
+
+#define VMWARE_VERSION_MAJOR 10
+#define VMWARE_VERSION_MINOR 16
+#define VMWARE_VERSION_PATCH 9
+
+static XF86ModuleVersionInfo vmware_version;
+static MODULESETUPPROTO(vmware_setup);
+
+_X_EXPORT XF86ModuleData vmwareModuleData = {
+ &vmware_version,
+ vmware_setup,
+ NULL
+};
+
+
+/*
+ * Chain loading functions
+ */
+
+static Bool
+vmware_check_kernel_module()
+{
+ /* Super simple way of knowing if the kernel driver is loaded */
+ int ret = drmOpen("vmwgfx", NULL);
+ if (ret < 0)
+ return FALSE;
+
+ drmClose(ret);
+
+ return TRUE;
+}
+
+static Bool
+vmware_chain_module(pointer opts)
+{
+ int vmwlegacy_devices;
+ int vmwgfx_devices;
+ int vmware_devices;
+ int matched;
+ char *driver_name;
+ GDevPtr *gdevs;
+ GDevPtr gdev;
+ int i;
+
+ vmware_devices = xf86MatchDevice(VMWARE_DRIVER_NAME, &gdevs);
+ vmwgfx_devices = xf86MatchDevice(VMWGFX_DRIVER_NAME, NULL);
+ vmwlegacy_devices = xf86MatchDevice(VMWLEGACY_DRIVER_NAME, NULL);
+
+ if (vmware_check_kernel_module()) {
+ driver_name = VMWGFX_DRIVER_NAME;
+ matched = vmwgfx_devices;
+ } else {
+ driver_name = VMWLEGACY_DRIVER_NAME;
+ matched = vmwlegacy_devices;
+ }
+
+ for (i = 0; i < vmware_devices; i++) {
+ gdev = gdevs[i];
+ gdev->driver = driver_name;
+ }
+
+ xfree(gdevs);
+
+ if (!matched)
+ xf86LoadOneModule(driver_name, opts);
+}
+
+
+/*
+ * Module info
+ */
+
+static XF86ModuleVersionInfo vmware_version = {
+ VMWARE_DRIVER_NAME,
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ VMWARE_VERSION_MAJOR, VMWARE_VERSION_MINOR, VMWARE_VERSION_PATCH,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+static pointer
+vmware_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+ int ret;
+
+ /* This module should be loaded only once, but check to be sure. */
+ if (!setupDone) {
+ setupDone = 1;
+
+ /* Chain load the real driver */
+ vmware_chain_module(opts);
+
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}