Index: trunk/src/VBox/Additions/linux/drm/Makefile.module.kms
===================================================================
--- trunk/src/VBox/Additions/linux/drm/Makefile.module.kms	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/Makefile.module.kms	(revision 43113)
@@ -0,0 +1,47 @@
+#
+# VirtualBox Guest Additions Module Makefile.
+#
+# (For 2.6.x this file must be 'Makefile'!)
+#
+# Copyright (C) 2006-2010 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+# Linux kbuild sets this to our source directory if we are called from there
+obj ?= $(CURDIR)
+include $(obj)/Makefile.include.header
+
+MOD_NAME   = vboxvideo
+
+MOD_OBJS   = Modesetting.o vboxvideo_crtc.o vboxvideo_dac.o vboxvideo_device.o \
+             vboxvideo_display.o vboxvideo_drv.o vboxvideo_kms.o vboxvideo_vga.o
+
+ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxvideo),)
+ MANGLING := $(KBUILD_EXTMOD)/vboxvideo/include/VBox/VBoxGuestMangling.h
+else
+ MANGLING := $(KBUILD_EXTMOD)/include/VBox/VBoxGuestMangling.h
+endif
+MOD_CFLAGS = -fshort-wchar -include $(MANGLING)
+MOD_INCL   = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
+# What on earth is this?
+MOD_INCL  += $(addprefix -I$(KBUILD_EXTMOD)/vboxvideo,/ /include /r0drv/linux)
+MOD_DEFS  := -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
+	     -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DLOG_TO_BACKDOOR -DIN_MODULE \
+	     -DIN_GUEST_R0
+# our module does not export any symbol
+MOD_DEFS  += -DRT_NO_EXPORT_SYMBOL
+ifeq ($(BUILD_TARGET_ARCH),amd64)
+ MOD_DEFS += -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS
+else
+ MOD_DEFS += -DRT_ARCH_X86
+endif
+MOD_CLEAN  = . linux r0drv r0drv/linux
+
+include $(obj)/Makefile.include.footer
Index: trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv
===================================================================
--- trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 43113)
@@ -0,0 +1,67 @@
+#!/bin/sh
+# $Id$
+## @file
+# Shared file between Makefile.kmk and export_modules
+#
+
+#
+# Copyright (C) 2011 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+FILES_VBOXVIDEO_DRM_NOBIN=" \
+    ${PATH_OUT}/version-generated.h=>version-generated.h \
+    ${PATH_OUT}/product-generated.h=>product-generated.h \
+    ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \
+    ${PATH_ROOT}/include/iprt/asm-amd64-x86.h=>include/iprt/asm-amd64-x86.h \
+    ${PATH_ROOT}/include/iprt/assert.h=>include/iprt/assert.h \
+    ${PATH_ROOT}/include/iprt/cdefs.h=>include/iprt/cdefs.h \
+    ${PATH_ROOT}/include/iprt/err.h=>include/iprt/err.h \
+    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
+    ${PATH_ROOT}/include/iprt/param.h=>include/iprt/param.h \
+    ${PATH_ROOT}/include/iprt/stdarg.h=>include/iprt/stdarg.h \
+    ${PATH_ROOT}/include/iprt/stdint.h=>include/iprt/stdint.h \
+    ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
+    ${PATH_ROOT}/include/iprt/mangling.h=>include/iprt/mangling.h \
+    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
+    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
+    ${PATH_ROOT}/include/VBox/ostypes.h=>include/VBox/ostypes.h \
+    ${PATH_ROOT}/include/VBox/param.h=>include/VBox/param.h \
+    ${PATH_ROOT}/include/VBox/types.h=>include/VBox/types.h \
+    ${PATH_ROOT}/include/VBox/VBoxGuestMangling.h=>include/VBox/VBoxGuestMangling.h \
+    ${PATH_ROOT}/include/VBox/VBoxGuest.h=>include/VBox/VBoxGuest.h \
+    ${PATH_ROOT}/include/VBox/VBoxGuest2.h=>include/VBox/VBoxGuest2.h \
+    ${PATH_ROOT}/include/VBox/VBoxVideo.h=>include/VBox/VBoxVideo.h \
+    ${PATH_ROOT}/include/VBox/VBoxVideoGuest.h=>include/VBox/VBoxVideoGuest.h \
+    ${PATH_ROOT}/include/VBox/VMMDev.h=>include/VBox/VMMDev.h \
+    ${PATH_ROOT}/include/VBox/VMMDev2.h=>include/VBox/VMMDev2.h \
+    ${PATH_ROOT}/include/VBox/HGSMI/HGSMI.h=>include/VBox/HGSMI/HGSMI.h \
+    ${PATH_ROOT}/include/VBox/HGSMI/HGSMIChannels.h=>include/VBox/HGSMI/HGSMIChannels.h \
+    ${PATH_ROOT}/include/VBox/HGSMI/HGSMIChSetup.h=>include/VBox/HGSMI/HGSMIChSetup.h \
+    ${PATH_ROOT}/include/VBox/Hardware/VBoxVideoVBE.h=>include/VBox/Hardware/VBoxVideoVBE.h \
+    ${PATH_ROOT}/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp=>Modesetting.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo.h=>vboxvideo.h \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_crtc.c=>vboxvideo_crtc.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_dac.c=>vboxvideo_dac.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_device.c=>vboxvideo_device.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_display.c=>vboxvideo_display.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_drv.c=>vboxvideo_drv.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_drv.h=>vboxvideo_drv.h \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_kms.c=>vboxvideo_kms.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_mode.h=>vboxvideo_mode.h \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_vga.c=>vboxvideo_vga.c \
+    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h=>r0drv/linux/the-linux-kernel.h \
+    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header=>Makefile.include.header \
+    ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.footer=>Makefile.include.footer \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/Makefile.module.kms=>Makefile \
+"
+
+FILES_VBOXVIDEO_DRM_BIN=" \
+"
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo.h
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo.h	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo.h	(revision 43113)
@@ -0,0 +1,73 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * glint.h
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#ifndef __DRM_VBOXVIDEO_H__
+#define __DRM_VBOXVIDEO_H__
+
+#include "vboxvideo_mode.h"
+#include "drm/drmP.h"
+
+struct vboxvideo_mc
+{
+    resource_size_t    aper_size;
+    resource_size_t    aper_base;
+    u32                vram_size;
+};
+
+struct vboxvideo_device
+{
+    struct device      *dev;
+    struct drm_device  *ddev;
+    struct pci_dev     *pdev;
+    unsigned long       flags;
+    /** @todo move this into flags */
+    bool                fAnyX;
+
+    struct vboxvideo_mc mc;
+    struct vboxvideo_mode_info  mode_info;
+
+    int				    num_crtc;
+};
+
+#endif                /* __DRM_VBOXVIDEO_H__ */
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo_device.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo_device.c	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo_device.c	(revision 43113)
@@ -0,0 +1,79 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * vboxvideo_device.c
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
+
+#include "the-linux-kernel.h"
+
+#include "vboxvideo_drv.h"
+
+#include <VBox/VBoxVideoGuest.h>
+
+int vboxvideo_device_init(struct vboxvideo_device *gdev,
+              struct drm_device *ddev,
+              struct pci_dev *pdev,
+              uint32_t flags)
+{
+    gdev->dev      = &pdev->dev;
+    gdev->ddev     = ddev;
+    gdev->pdev     = pdev;
+    gdev->flags    = flags;
+    gdev->num_crtc = 1;
+
+    /** @todo hardware initialisation goes here once we start doing more complex
+     *        stuff.
+     */
+    gdev->fAnyX        = VBoxVideoAnyWidthAllowed();
+    gdev->mc.vram_size = VBoxVideoGetVRAMSize();
+
+    return 0;
+}
+
+void vboxvideo_device_fini(struct vboxvideo_device *gdev)
+{
+
+}
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo_display.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo_display.c	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo_display.c	(revision 43113)
@@ -0,0 +1,93 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * vboxvideo_device.c
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
+
+#include "vboxvideo_drv.h"
+
+int vboxvideo_modeset_init(struct vboxvideo_device *gdev)
+{
+    struct drm_encoder *encoder;
+    struct drm_connector *connector;
+    int i;
+
+    drm_mode_config_init(gdev->ddev);
+    gdev->mode_info.mode_config_initialized = true;
+
+    gdev->ddev->mode_config.max_width = VBOXVIDEO_MAX_FB_WIDTH;
+    gdev->ddev->mode_config.max_height = VBOXVIDEO_MAX_FB_HEIGHT;
+
+    gdev->ddev->mode_config.fb_base = gdev->mc.aper_base;
+
+    /* allocate crtcs */
+    for (i = 0; i < gdev->num_crtc; i++)
+    {
+        vboxvideo_crtc_init(gdev->ddev, i);
+    }
+
+    encoder = vboxvideo_dac_init(gdev->ddev);
+    if (!encoder) {
+        VBOXVIDEO_ERROR("vboxvideo_dac_init failed\n");
+        return -1;
+    }
+
+    connector = vboxvideo_vga_init(gdev->ddev);
+    if (!connector) {
+        VBOXVIDEO_ERROR("vboxvideo_vga_init failed\n");
+        return -1;
+    }
+    return 0;
+}
+
+void vboxvideo_modeset_fini(struct vboxvideo_device *gdev)
+{
+    if (gdev->mode_info.mode_config_initialized)
+    {
+        drm_mode_config_cleanup(gdev->ddev);
+        gdev->mode_info.mode_config_initialized = false;
+    }
+}
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.c	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.c	(revision 43113)
@@ -0,0 +1,148 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * glint_drv.c
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include "version-generated.h"
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
+
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+#  ifdef RHEL_RELEASE_CODE
+#   if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,1)
+#    define DRM_RHEL61
+#   endif
+#  endif
+# endif
+
+#include "vboxvideo_drv.h"
+
+static struct pci_device_id pciidlist[] = {
+        vboxvideo_PCI_IDS
+};
+
+static struct drm_driver driver =
+{
+    .driver_features = 0,
+    .load = vboxvideo_driver_load,
+    .unload = vboxvideo_driver_unload,
+    .reclaim_buffers = drm_core_reclaim_buffers,
+    /* As of Linux 2.6.37, always the internal functions are used. */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) && !defined(DRM_RHEL61)
+    .get_map_ofs = drm_core_get_map_ofs,
+    .get_reg_ofs = drm_core_get_reg_ofs,
+#endif
+    .ioctls = vboxvideo_ioctls,
+    .fops =
+    {
+        .owner = THIS_MODULE,
+        .open = drm_open,
+        .release = drm_release,
+        /* This was changed with Linux 2.6.33 but Fedora backported this
+         * change to their 2.6.32 kernel. */
+#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
+        .unlocked_ioctl = drm_ioctl,
+#else
+        .ioctl = drm_ioctl,
+#endif
+        .mmap = drm_mmap,
+        .poll = drm_poll,
+        .fasync = drm_fasync,
+    },
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
+    .pci_driver =
+    {
+        .name = DRIVER_NAME,
+        .id_table = pciidlist,
+    },
+#endif
+    .name = DRIVER_NAME,
+    .desc = DRIVER_DESC,
+    .date = DRIVER_DATE,
+    .major = DRIVER_MAJOR,
+    .minor = DRIVER_MINOR,
+    .patchlevel = DRIVER_PATCHLEVEL,
+};
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
+static struct pci_driver pci_driver =
+{
+    .name = DRIVER_NAME,
+    .id_table = pciidlist,
+};
+#endif
+
+static int __init vboxvideo_init(void)
+{
+     printk(KERN_INFO "vboxvideo initializing\n");
+    driver.num_ioctls = vboxvideo_max_ioctl;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
+    return drm_init(&driver);
+#else
+    return drm_pci_init(&driver, &pci_driver);
+#endif
+}
+
+static void __exit vboxvideo_exit(void)
+{
+     printk(KERN_INFO "vboxvideo exiting\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
+    drm_exit(&driver);
+#else
+    drm_pci_exit(&driver, &pci_driver);
+#endif
+}
+
+module_init(vboxvideo_init);
+module_exit(vboxvideo_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
+
+#ifdef MODULE_VERSION
+MODULE_VERSION(VBOX_VERSION_STRING);
+#endif
+MODULE_LICENSE("GPL and additional rights");
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.h
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.h	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.h	(revision 43113)
@@ -0,0 +1,101 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * glint_drv.h
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#ifndef __DRM_VBOXVIDEO_DRV_H__
+#define __DRM_VBOXVIDEO_DRV_H__
+
+/* General customization:
+ */
+
+#include "vboxvideo.h"
+
+#include "product-generated.h"
+
+#define DRIVER_AUTHOR       VBOX_VENDOR
+
+#define DRIVER_NAME         "vboxvideo"
+#define DRIVER_DESC         VBOX_PRODUCT " Graphics Card"
+#define DRIVER_DATE         "20090303"
+
+#define DRIVER_MAJOR        1
+#define DRIVER_MINOR        0
+#define DRIVER_PATCHLEVEL   0
+
+#define VBOXVIDEO_INFO(fmt, arg...)  DRM_INFO(DRIVER_NAME ": " fmt, ##arg)
+#define VBOXVIDEO_ERROR(fmt, arg...) DRM_ERROR(DRIVER_NAME ": " fmt, ##arg)
+
+/** @todo does this make sense?  What exactly is this connector? */
+#define VBOXVIDEOFB_CONN_LIMIT VBOX_VIDEO_MAX_SCREENS
+
+/* vboxvideo_crtc.c */
+void vboxvideo_crtc_init(struct drm_device *dev, int index);
+
+/* vboxvideo_dac.c */
+struct drm_encoder *vboxvideo_dac_init(struct drm_device *dev);
+
+/* vboxvideo_device.c */
+int vboxvideo_device_init(struct vboxvideo_device *gdev,
+                          struct drm_device *ddev,
+                          struct pci_dev *pdev,
+                          uint32_t flags);
+void vboxvideo_device_fini(struct vboxvideo_device *gdev);
+
+/* vboxvideo_display.c */
+int vboxvideo_modeset_init(struct vboxvideo_device *gdev);
+void vboxvideo_modeset_fini(struct vboxvideo_device *gdev);
+
+/* vboxvideo_kms.c */
+int vboxvideo_driver_load(struct drm_device *dev, unsigned long flags);
+int vboxvideo_driver_unload(struct drm_device *dev);
+extern struct drm_ioctl_desc vboxvideo_ioctls[];
+extern int vboxvideo_max_ioctl;
+
+/* vboxvideo_vga.c */
+struct drm_connector *vboxvideo_vga_init(struct drm_device *dev);
+
+#define vboxvideo_PCI_IDS \
+    {0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
+    {0, 0, 0}
+
+#endif  /* __DRM_VBOXVIDEO_DRV_H__ */
Index: trunk/src/VBox/Additions/linux/drm/vboxvideo_kms.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vboxvideo_kms.c	(revision 43113)
+++ trunk/src/VBox/Additions/linux/drm/vboxvideo_kms.c	(revision 43113)
@@ -0,0 +1,100 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver, KMS support
+ */
+
+/*
+ * Copyright (C) 2011 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ * --------------------------------------------------------------------
+ *
+ * This code is based on
+ * glint_kms.c
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2010 Matt Turner.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Authors: Matt Turner
+ */
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
+
+#include "vboxvideo_drv.h"
+
+int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
+{
+    struct vboxvideo_device *gdev;
+    int r;
+
+    gdev = kzalloc(sizeof(struct vboxvideo_device), GFP_KERNEL);
+    if (gdev == NULL) {
+        return -ENOMEM;
+    }
+    dev->dev_private = (void *)gdev;
+
+    r = vboxvideo_device_init(gdev, dev, dev->pdev, flags);
+    if (r) {
+        dev_err(&dev->pdev->dev, "Fatal error during GPU init\n");
+        goto out;
+    }
+
+    r = vboxvideo_modeset_init(gdev);
+    if (r) {
+        dev_err(&dev->pdev->dev, "Fatal error during modeset init\n");
+        goto out;
+    }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
+    r = drm_vblank_init(dev, 1);
+    if (r)
+        dev_err(&dev->pdev->dev, "Fatal error during vblank init\n");
+#endif
+out:
+    if (r)
+        vboxvideo_driver_unload(dev);
+    return r;
+}
+
+int vboxvideo_driver_unload(struct drm_device * dev)
+{
+    struct vboxvideo_device *gdev = dev->dev_private;
+
+    if (gdev == NULL)
+        return 0;
+    vboxvideo_modeset_fini(gdev);
+    vboxvideo_device_fini(gdev);
+    kfree(gdev);
+    dev->dev_private = NULL;
+    return 0;
+}
+
+struct drm_ioctl_desc vboxvideo_ioctls[] = {
+};
+int vboxvideo_max_ioctl = DRM_ARRAY_SIZE(vboxvideo_ioctls);
+
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
