Index: /trunk/src/VBox/Additions/linux/drm/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/Makefile.kmk	(revision 48363)
+++ /trunk/src/VBox/Additions/linux/drm/Makefile.kmk	(revision 48364)
@@ -79,14 +79,12 @@
  vboxvideo_drm_INCS           += ../../../Runtime/r0drv/linux
  vboxvideo_drm_SOURCES         = \
+   ../../common/VBoxVideo/HGSMIBase.cpp \
    ../../common/VBoxVideo/Modesetting.cpp \
- 	vboxvideo_crtc.c \
- 	vboxvideo_dac.c \
- 	vboxvideo_device.c \
- 	vboxvideo_display.c \
- 	vboxvideo_drv.c \
- 	vboxvideo_fbdev.c \
- 	vboxvideo_framebuffer.c \
- 	vboxvideo_kms.c \
- 	vboxvideo_vga.c
+   ../../common/VBoxVideo/VBVABase.cpp \
+ 	vbox_drv.c \
+ 	vbox_fb.c \
+ 	vbox_main.c \
+ 	vbox_mode.c \
+ 	vbox_ttm.c
 endif
 
Index: /trunk/src/VBox/Additions/linux/drm/Makefile.module.kms
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/Makefile.module.kms	(revision 48363)
+++ /trunk/src/VBox/Additions/linux/drm/Makefile.module.kms	(revision 48364)
@@ -21,7 +21,6 @@
 MOD_NAME   = vboxvideo
 
-MOD_OBJS   = Modesetting.o vboxvideo_crtc.o vboxvideo_dac.o vboxvideo_device.o \
-             vboxvideo_display.o vboxvideo_drv.o vboxvideo_fbdev.o \
-             vboxvideo_framebuffer.o vboxvideo_kms.o vboxvideo_vga.o
+MOD_OBJS   = HGSMIBase.o Modesetting.o VBVABase.o vbox_drv.o vbox_fb.o \
+             vbox_main.o vbox_mode.o vbox_ttm.o 
 
 ifneq ($(wildcard $(KBUILD_EXTMOD)/vboxvideo),)
Index: /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 48363)
+++ /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 48364)
@@ -47,17 +47,13 @@
     ${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/HGSMIBase.cpp=>HGSMIBase.c \
     ${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_fbdev.c=>vboxvideo_fbdev.c \
-    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vboxvideo_framebuffer.c=>vboxvideo_framebuffer.c \
-    ${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/Additions/common/VBoxVideo/VBVABase.cpp=>VBVABase.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_drv.c=>vbox_drv.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_drv.h=>vbox_drv.h \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_fb.c=>vbox_fb.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_main.c=>vbox_main.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_mode.c=>vbox_mode.c \
+    ${PATH_ROOT}/src/VBox/Additions/linux/drm/vbox_ttm.c=>vbox_ttm.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 \
Index: /trunk/src/VBox/Additions/linux/drm/vbox_drv.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vbox_drv.c	(revision 48364)
+++ /trunk/src/VBox/Additions/linux/drm/vbox_drv.c	(revision 48364)
@@ -0,0 +1,151 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2013 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
+ * ast_drv.c
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2012 Red Hat Inc.
+ *
+ * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ */
+/*
+ * Authors: Dave Airlie <airlied@redhat.com>
+ */
+#include "vbox_drv.h"
+
+#include <linux/module.h>
+#include <linux/console.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
+
+int vbox_modeset = -1;
+
+MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
+module_param_named(modeset, vbox_modeset, int, 0400);
+
+static struct drm_driver driver;
+
+static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
+	{0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0, 0, 0},
+};
+
+MODULE_DEVICE_TABLE(pci, pciidlist);
+
+static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+
+static void
+vbox_pci_remove(struct pci_dev *pdev)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+
+	drm_put_dev(dev);
+}
+
+
+static struct pci_driver vbox_pci_driver = {
+	.name = DRIVER_NAME,
+	.id_table = pciidlist,
+	.probe = vbox_pci_probe,
+	.remove = vbox_pci_remove,
+};
+
+static const struct file_operations vbox_fops = {
+	.owner = THIS_MODULE,
+	.open = drm_open,
+	.release = drm_release,
+	.unlocked_ioctl = drm_ioctl,
+	.mmap = vbox_mmap,
+	.poll = drm_poll,
+	.fasync = drm_fasync,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl = drm_compat_ioctl,
+#endif
+	.read = drm_read,
+};
+
+static struct drm_driver driver = {
+	.driver_features = DRIVER_USE_MTRR | DRIVER_MODESET | DRIVER_GEM,
+	.dev_priv_size = 0,
+
+	.load = vbox_driver_load,
+	.unload = vbox_driver_unload,
+
+	.fops = &vbox_fops,
+	.name = DRIVER_NAME,
+	.desc = DRIVER_DESC,
+	.date = DRIVER_DATE,
+	.major = DRIVER_MAJOR,
+	.minor = DRIVER_MINOR,
+	.patchlevel = DRIVER_PATCHLEVEL,
+
+	.gem_init_object = vbox_gem_init_object,
+	.gem_free_object = vbox_gem_free_object,
+	.dumb_create = vbox_dumb_create,
+	.dumb_map_offset = vbox_dumb_mmap_offset,
+	.dumb_destroy = vbox_dumb_destroy,
+
+};
+
+static int __init vbox_init(void)
+{
+#ifdef CONFIG_VGA_CONSOLE
+	if (vgacon_text_force() && vbox_modeset == -1)
+		return -EINVAL;
+#endif
+
+	if (vbox_modeset == 0)
+		return -EINVAL;
+	return drm_pci_init(&driver, &vbox_pci_driver);
+}
+static void __exit vbox_exit(void)
+{
+	drm_pci_exit(&driver, &vbox_pci_driver);
+}
+
+module_init(vbox_init);
+module_exit(vbox_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL and additional rights");
+
Index: /trunk/src/VBox/Additions/linux/drm/vbox_drv.h
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vbox_drv.h	(revision 48364)
+++ /trunk/src/VBox/Additions/linux/drm/vbox_drv.h	(revision 48364)
@@ -0,0 +1,225 @@
+/** @file $Id$
+ *
+ * VirtualBox Additions Linux kernel video driver
+ */
+
+/*
+ * Copyright (C) 2013 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
+ * ast_drv.h
+ * with the following copyright and permission notice:
+ *
+ * Copyright 2012 Red Hat Inc.
+ *
+ * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ */
+/*
+ * Authors: Dave Airlie <airlied@redhat.com>
+ */
+#ifndef __VBOX_DRV_H__
+#define __VBOX_DRV_H__
+
+#include <VBox/VBoxVideoGuest.h>
+
+#include "the-linux-kernel.h"
+
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+
+#include <drm/ttm/ttm_bo_api.h>
+#include <drm/ttm/ttm_bo_driver.h>
+#include <drm/ttm/ttm_placement.h>
+#include <drm/ttm/ttm_memory.h>
+#include <drm/ttm/ttm_module.h>
+
+/* #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         "20130823"
+
+#define DRIVER_MAJOR        1
+#define DRIVER_MINOR        0
+#define DRIVER_PATCHLEVEL   0
+
+struct vbox_fbdev;
+
+struct vbox_private {
+	struct drm_device *dev;
+
+	void __iomem *vram;
+    HGSMIGUESTCOMMANDCONTEXT Ctx;
+    bool fAnyX;
+    unsigned cCrtcs;
+	bool vga2_clone;
+	uint32_t vram_size;
+
+	struct vbox_fbdev *fbdev;
+
+	int fb_mtrr;
+
+	struct {
+		struct drm_global_reference mem_global_ref;
+		struct ttm_bo_global_ref bo_global_ref;
+		struct ttm_bo_device bdev;
+	} ttm;
+
+	struct drm_gem_object *cursor_cache;
+	uint64_t cursor_cache_gpu_addr;
+	struct ttm_bo_kmap_obj cache_kmap;
+	int next_cursor;
+};
+
+int vbox_driver_load(struct drm_device *dev, unsigned long flags);
+int vbox_driver_unload(struct drm_device *dev);
+
+struct vbox_gem_object;
+
+struct vbox_connector {
+	struct drm_connector base;
+};
+
+struct vbox_crtc {
+	struct drm_crtc base;
+	bool fBlanked;
+	unsigned crtc_id;
+	struct drm_gem_object *cursor_bo;
+	uint64_t cursor_addr;
+	int cursor_width, cursor_height;
+	u8 offset_x, offset_y;
+};
+
+struct vbox_encoder {
+	struct drm_encoder base;
+};
+
+struct vbox_framebuffer {
+	struct drm_framebuffer base;
+	struct drm_gem_object *obj;
+	uint64_t offBase;
+};
+
+struct vbox_fbdev {
+	struct drm_fb_helper helper;
+	struct vbox_framebuffer afb;
+	struct list_head fbdev_list;
+	void *sysram;
+	int size;
+	struct ttm_bo_kmap_obj mapping;
+	int x1, y1, x2, y2; /* dirty rect */
+	spinlock_t dirty_lock;
+};
+
+#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
+#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
+#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
+#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
+
+extern int vbox_mode_init(struct drm_device *dev);
+extern void vbox_mode_fini(struct drm_device *dev);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+# define DRM_MODE_FB_CMD drm_mode_fb_cmd
+#else
+# define DRM_MODE_FB_CMD drm_mode_fb_cmd2
+#endif
+
+int vbox_framebuffer_init(struct drm_device *dev,
+			 struct vbox_framebuffer *vbox_fb,
+			 struct DRM_MODE_FB_CMD *mode_cmd,
+			 struct drm_gem_object *obj);
+
+int vbox_fbdev_init(struct drm_device *dev);
+void vbox_fbdev_fini(struct drm_device *dev);
+void vbox_fbdev_set_suspend(struct drm_device *dev, int state);
+
+struct vbox_bo {
+	struct ttm_buffer_object bo;
+	struct ttm_placement placement;
+	struct ttm_bo_kmap_obj kmap;
+	struct drm_gem_object gem;
+	u32 placements[3];
+	int pin_count;
+};
+#define gem_to_vbox_bo(gobj) container_of((gobj), struct vbox_bo, gem)
+
+static inline struct vbox_bo *
+vbox_bo(struct ttm_buffer_object *bo)
+{
+	return container_of(bo, struct vbox_bo, bo);
+}
+
+
+#define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base)
+
+extern int vbox_dumb_create(struct drm_file *file,
+			   struct drm_device *dev,
+			   struct drm_mode_create_dumb *args);
+extern int vbox_dumb_destroy(struct drm_file *file,
+			    struct drm_device *dev,
+			    uint32_t handle);
+
+extern int vbox_gem_init_object(struct drm_gem_object *obj);
+extern void vbox_gem_free_object(struct drm_gem_object *obj);
+extern int vbox_dumb_mmap_offset(struct drm_file *file,
+				struct drm_device *dev,
+				uint32_t handle,
+				uint64_t *offset);
+
+#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
+
+int vbox_mm_init(struct vbox_private *vbox);
+void vbox_mm_fini(struct vbox_private *vbox);
+
+int vbox_bo_create(struct drm_device *dev, int size, int align,
+		  uint32_t flags, struct vbox_bo **pvboxbo);
+
+int vbox_gem_create(struct drm_device *dev,
+		   u32 size, bool iskernel,
+		   struct drm_gem_object **obj);
+
+int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int vbox_bo_unpin(struct vbox_bo *bo);
+
+int vbox_bo_reserve(struct vbox_bo *bo, bool no_wait);
+void vbox_bo_unreserve(struct vbox_bo *bo);
+void vbox_ttm_placement(struct vbox_bo *bo, int domain);
+int vbox_bo_push_sysram(struct vbox_bo *bo);
+int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
+
+/* vbox post */
+void vbox_post_gpu(struct drm_device *dev);
+#endif
Index: unk/src/VBox/Additions/linux/drm/vboxvideo.h
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo.h	(revision 48363)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2011-2013 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 <VBox/VBoxVideoGuest.h>
-#include "drm/drmP.h"
-
-struct vboxvideo_mc
-{
-    resource_size_t    vram_size;
-    resource_size_t    vram_base;
-};
-
-struct vboxvideo_device
-{
-    struct device      *dev;
-    struct drm_device  *ddev;
-    struct pci_dev     *pdev;
-    unsigned long       flags;
-    HGSMIGUESTCOMMANDCONTEXT Ctx;
-    bool                fAnyX;
-    bool                fHaveHGSMI;
-    size_t              offViewInfo;
-    size_t              offCommandBuffers;
-
-    drm_local_map_t    *framebuffer;
-
-    struct vboxvideo_mc mc;
-    struct vboxvideo_mode_info  mode_info;
-
-    int                 num_crtc;
-};
-
-#endif /* __DRM_VBOXVIDEO_H__ */
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_crtc.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_crtc.c	(revision 48363)
+++ 	(revision )
@@ -1,248 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver, KMS support
- */
-
-/*
- * Copyright (C) 2011-2012 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_crtc.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 <VBox/VBoxVideoGuest.h>
-
-#include "vboxvideo_drv.h"
-
-#include "drm/drm_crtc_helper.h"
-
-/** Set a graphics mode.  Poke any required values into registers, do an HGSMI
- * mode set and tell the host we support advanced graphics functions.
- */
-static void vboxvideo_do_modeset(struct drm_crtc *crtc)
-{
-    struct vboxvideo_crtc   *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
-    struct vboxvideo_device *gdev = crtc->dev->dev_private;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-    int pitch = crtc->fb.pitch;
-#else
-    int pitch = crtc->fb.pitches[0];
-#endif
-
-    if (vboxvideo_crtc->crtc_id == 0)
-        VBoxVideoSetModeRegisters(vboxvideo_crtc->last_width,
-                                  vboxvideo_crtc->last_height,
-                                  pitch,
-                                  crtc->fb.bits_per_pixel, 0,
-                                  vboxvideo_crtc->last_x,
-                                  vboxvideo_crtc->last_y);
-    if (gdev->fHaveHGSMI)
-    {
-        uint16_t fFlags = VBVA_SCREEN_F_ACTIVE;
-        fFlags |= (vboxvideo_crtc->enabled ? 0 : VBVA_SCREEN_F_DISABLED);
-        VBoxHGSMIProcessDisplayInfo(&gdev->Ctx, vboxvideo_crtc->crtc_id,
-                                    vboxvideo_crtc->last_x,
-                                    vboxvideo_crtc->last_y,
-                                        vboxvideo_crtc->last_x
-                                      * crtc->fb.bits_per_pixel
-                                    + vboxvideo_crtc->last_y * pitch,
-                                    pitch,
-                                    vboxvideo_crtc->last_width,
-                                    vboxvideo_crtc->last_height,
-                                    crtc->fb.bits_per_pixel, fFlags);
-    }
-}
-
-
-static void vboxvideo_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-    struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
-
-    if (mode == vboxvideo_crtc->last_dpms) /* Don't do unnecesary mode changes. */
-        return;
-
-    vboxvideo_crtc->last_dpms = mode;
-
-    switch (mode) {
-    case DRM_MODE_DPMS_STANDBY:
-    case DRM_MODE_DPMS_SUSPEND:
-    case DRM_MODE_DPMS_OFF:
-        vboxvideo_crtc->enabled = false;
-        break;
-    case DRM_MODE_DPMS_ON:
-        vboxvideo_crtc->enabled = true;
-        break;
-    }
-}
-
-static bool vboxvideo_crtc_mode_fixup(struct drm_crtc *crtc,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
-                                     const struct drm_display_mode *mode,
-#else
-                                     struct drm_display_mode *mode,
-#endif
-                                     struct drm_display_mode *adjusted_mode)
-{
-    return true;
-}
-
-static int vboxvideo_crtc_mode_set(struct drm_crtc *crtc,
-                                   struct drm_display_mode *mode,
-                                   struct drm_display_mode *adjusted_mode,
-                                   int x, int y, struct drm_framebuffer *old_fb)
-{
-    /*
-    struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
-
-    vboxvideo_crtc_set_base(crtc, x, y, old_fb);
-    vboxvideo_set_crtc_timing(crtc, adjusted_mode);
-    vboxvideo_set_pll(crtc, adjusted_mode);
-    */
-    return 0;
-}
-
-static void vboxvideo_crtc_prepare(struct drm_crtc *crtc)
-{
-    struct drm_device *dev = crtc->dev;
-    struct drm_crtc *crtci;
-
-    /*
-    list_for_each_entry(crtci, &dev->mode_config.crtc_list, head)
-        vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_OFF);
-    */
-}
-
-static void vboxvideo_crtc_commit(struct drm_crtc *crtc)
-{
-    struct drm_device *dev = crtc->dev;
-    struct drm_crtc *crtci;
-
-    /*
-    list_for_each_entry(crtci, &dev->mode_config.crtc_list, head) {
-        if (crtci->enabled)
-            vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_ON);
-    }
-    */
-}
-
-static void vboxvideo_crtc_load_lut(struct drm_crtc *crtc)
-{
-    /* Dummy */
-}
-
-static void vboxvideo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
-                                     u16 *green, u16 *blue,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
-                                     uint32_t start,
-#endif
-                                     uint32_t size)
-{
-    /* Dummy */
-}
-
-static void vboxvideo_crtc_destroy(struct drm_crtc *crtc)
-{
-    struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
-
-    drm_crtc_cleanup(crtc);
-    kfree(vboxvideo_crtc);
-}
-
-static const struct drm_crtc_funcs vboxvideo_crtc_funcs = {
-    /*
-    .cursor_set = vboxvideo_crtc_cursor_set,
-    .cursor_move = vboxvideo_crtc_cursor_move,
-    */
-    .cursor_set = NULL,
-    .cursor_move = NULL,
-    .gamma_set = vboxvideo_crtc_gamma_set,
-    .set_config = drm_crtc_helper_set_config,
-    .destroy = vboxvideo_crtc_destroy,
-};
-
-static const struct drm_crtc_helper_funcs vboxvideo_helper_funcs = {
-    .dpms = vboxvideo_crtc_dpms,
-    .mode_fixup = vboxvideo_crtc_mode_fixup,
-    .mode_set = vboxvideo_crtc_mode_set,
-    .prepare = vboxvideo_crtc_prepare,
-    .commit = vboxvideo_crtc_commit,
-    .load_lut = vboxvideo_crtc_load_lut,
-};
-
-void vboxvideo_crtc_init(struct drm_device *dev, int index)
-{
-    struct vboxvideo_device *gdev = dev->dev_private;
-    struct vboxvideo_crtc *vboxvideo_crtc;
-    int i;
-
-    vboxvideo_crtc = kzalloc(  sizeof(struct vboxvideo_crtc)
-                             + (VBOXVIDEOFB_CONN_LIMIT
-                                * sizeof(struct drm_connector *)),
-                             GFP_KERNEL);
-    if (vboxvideo_crtc == NULL)
-        return;
-
-    drm_crtc_init(dev, &vboxvideo_crtc->base, &vboxvideo_crtc_funcs);
-
-    vboxvideo_crtc->crtc_id = index;
-    if (gdev->fHaveHGSMI)
-    {
-        vboxvideo_crtc->offCommandBuffer =   gdev->offViewInfo
-                                           - (index + 1) * VBVA_MIN_BUFFER_SIZE;
-        VBoxVBVASetupBufferContext(&vboxvideo_crtc->VbvaCtx,
-                                   vboxvideo_crtc->offCommandBuffer,
-                                   VBVA_MIN_BUFFER_SIZE);
-    }
-    vboxvideo_crtc->last_dpms = VBOXVIDEO_DPMS_CLEARED;
-    gdev->mode_info.crtcs[index] = vboxvideo_crtc;
-
-    drm_crtc_helper_add(&vboxvideo_crtc->base, &vboxvideo_helper_funcs);
-}
-
-/** Sets the color ramps on behalf of fbcon */
-void vboxvideo_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                                 u16 blue, int regno)
-{
-
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void vboxvideo_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                 u16 *blue, int regno)
-{
-
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_dac.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_dac.c	(revision 48363)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver, DAC functions
- */
-
-/*
- * Copyright (C) 2011-2012 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_dac.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 "vboxvideo_drv.h"
-
-#include "drm/drm_crtc_helper.h"
-
-static void vboxvideo_dac_dpms(struct drm_encoder *encoder, int mode)
-{
-    struct drm_device *dev = encoder->dev;
-    struct vboxvideo_device *gdev = dev->dev_private;
-    struct vboxvideo_encoder *vboxvideo_encoder = to_vboxvideo_encoder(encoder);
-
-    if (mode == vboxvideo_encoder->last_dpms) /* Don't do unnecesary mode changes. */
-        return;
-
-    vboxvideo_encoder->last_dpms = mode;
-
-    switch (mode) {
-    case DRM_MODE_DPMS_STANDBY:
-    case DRM_MODE_DPMS_SUSPEND:
-    case DRM_MODE_DPMS_OFF:
-        /* Do nothing for now */
-        break;
-    case DRM_MODE_DPMS_ON:
-        /* Do nothing for now */
-        break;
-    }
-}
-
-static bool vboxvideo_dac_mode_fixup(struct drm_encoder *encoder,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
-                                     const struct drm_display_mode *mode,
-#else
-                                     struct drm_display_mode *mode,
-#endif
-                                     struct drm_display_mode *adjusted_mode)
-{
-    return true;
-}
-
-static void vboxvideo_dac_mode_set(struct drm_encoder *encoder,
-                                   struct drm_display_mode *mode,
-                                   struct drm_display_mode *adjusted_mode)
-{
-
-}
-
-static void vboxvideo_dac_prepare(struct drm_encoder *encoder)
-{
-
-}
-
-static void vboxvideo_dac_commit(struct drm_encoder *encoder)
-{
-
-}
-
-void vboxvideo_encoder_destroy(struct drm_encoder *encoder)
-{
-    struct vboxvideo_encoder *vboxvideo_encoder = to_vboxvideo_encoder(encoder);
-    drm_encoder_cleanup(encoder);
-    kfree(vboxvideo_encoder);
-}
-
-static const struct drm_encoder_helper_funcs vboxvideo_dac_helper_funcs = {
-    .dpms = vboxvideo_dac_dpms,
-    .mode_fixup = vboxvideo_dac_mode_fixup,
-    .mode_set = vboxvideo_dac_mode_set,
-    .prepare = vboxvideo_dac_prepare,
-    .commit = vboxvideo_dac_commit,
-};
-
-static const struct drm_encoder_funcs vboxvideo_dac_encoder_funcs = {
-    .destroy = vboxvideo_encoder_destroy,
-};
-
-struct drm_encoder *vboxvideo_dac_init(struct drm_device *dev)
-{
-    struct drm_encoder *encoder;
-    struct vboxvideo_encoder *vboxvideo_encoder;
-
-    vboxvideo_encoder = kzalloc(sizeof(struct vboxvideo_encoder), GFP_KERNEL);
-    if (!vboxvideo_encoder)
-        return NULL;
-
-    vboxvideo_encoder->last_dpms = VBOXVIDEO_DPMS_CLEARED;
-    encoder = &vboxvideo_encoder->base;
-    encoder->possible_crtcs = 0x1;
-
-    drm_encoder_init(dev, encoder, &vboxvideo_dac_encoder_funcs, DRM_MODE_ENCODER_DAC);
-    drm_encoder_helper_add(encoder, &vboxvideo_dac_helper_funcs);
-
-    return encoder;
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_device.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_device.c	(revision 48363)
+++ 	(revision )
@@ -1,164 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2011-2012 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>
-
-#include "the-linux-kernel.h"
-
-#include "vboxvideo_drv.h"
-
-#include <VBox/VBoxVideoGuest.h>
-
-static int vboxvideo_vram_init(struct vboxvideo_device *gdev)
-{
-    unsigned size;
-    int ret;
-    int rc = VINF_SUCCESS;
-    uint32_t offVRAMBaseMapping, offGuestHeapMemory, cbGuestHeapMemory;
-    void *pvGuestHeapMemory;
-
-    /* set accessible VRAM */
-    gdev->mc.vram_base = pci_resource_start(gdev->ddev->pdev, 1);
-    gdev->mc.vram_size = pci_resource_len(gdev->ddev->pdev, 1);
-
-    gdev->fAnyX        = VBoxVideoAnyWidthAllowed();
-    gdev->mc.vram_size = VBoxVideoGetVRAMSize();
-
-    if (!request_region(gdev->mc.vram_base, gdev->mc.vram_size, "vboxvideofb_vram")) {
-        VBOXVIDEO_ERROR("can't region_reserve VRAM\n");
-        return -ENXIO;
-    }
-
-    ret = drm_addmap(gdev->ddev, gdev->mc.vram_base, gdev->mc.vram_size,
-        _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING,
-        &gdev->framebuffer);
-    if (!pVBox->fHaveHGSMI)
-        return 0;
-    VBoxHGSMIGetBaseMappingInfo(gdev->mc.vram_size, &offVRAMBaseMapping,
-                                NULL, &offGuestHeapMemory, &cbGuestHeapMemory,
-                                NULL);
-    pvGuestHeapMemory =   ((uint8_t *)gdev->framebuffer->handle)
-                        + offVRAMBaseMapping + offGuestHeapMemory;
-    rc = VBoxHGSMISetupGuestContext(&gdev->Ctx, pvGuestHeapMemory,
-                                    cbGuestHeapMemory,
-                                    offVRAMBaseMapping + offGuestHeapMemory);
-    if (RT_FAILURE(rc))
-    {
-        gdev->fHaveHGSMI = false;
-        return 0;
-    }
-    gdev->offViewInfo = offVRAMBaseMapping;
-    return 0;
-}
-
-static void vboxvideo_vram_fini(struct vboxvideo_device *gdev)
-{
-    if (gdev->framebuffer)
-        drm_rmmap(gdev->ddev, gdev->framebuffer);
-    if (gdev->mc.vram_base)
-        release_region(gdev->mc.vram_base, gdev->mc.vram_size);
-}
-
-static int vboxvideo_command_buffers_init(struct vboxvideo_device *gdev)
-{
-    unsigned i;
-    gdev->offCommandBuffers =   gdev->offViewInfo
-                              - gdev->num_crtc * VBVA_MIN_BUFFER_SIZE;
-    for (i = 0; i < gdev->num_crtc; ++i)
-    {
-        gdev->offCommandBuffers -= VBVA_MIN_BUFFER_SIZE;
-        VBoxVBVASetupBufferContext(&pVBox->aVbvaCtx[i],
-                                   pVBox->aoffVBVABuffer[i],
-                                   VBVA_MIN_BUFFER_SIZE);
-    }
-    TRACE_LOG("Maximum framebuffer size: %lu (0x%lx)\n",
-              (unsigned long) pVBox->cbFBMax,
-              (unsigned long) pVBox->cbFBMax);
-    rc = VBoxHGSMISendViewInfo(&pVBox->guestCtx, pVBox->cScreens,
-                               vboxFillViewInfo, (void *)pVBox);
-    if (RT_FAILURE(rc))
-    {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to send the view information to the host, rc=%d\n", rc);
-        return FALSE;
-    }
-    return TRUE;
-
-}
-
-int vboxvideo_device_init(struct vboxvideo_device *gdev,
-              struct drm_device *ddev,
-              struct pci_dev *pdev,
-              uint32_t flags)
-{
-    int ret;
-
-    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->fHaveHGSMI = VBoxHGSMIIsSupported();
-    ret = vboxvideo_vram_init(gdev);
-    if (ret)
-        return ret;
-    if (!gdev->fHaveHGSMI)
-        return 0;
-    gdev->num_crtc = VBoxHGSMIGetMonitorCount(&gdev->Ctx);
-    ret = vboxvideo_command_buffers_init(gdev);
-    if (ret)
-    {
-        gdev->fHaveHGSMI = false;
-        return ret;
-    }
-    return 0;
-}
-
-void vboxvideo_device_fini(struct vboxvideo_device *gdev)
-{
-    vboxvideo_vram_fini(gdev);
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_display.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_display.c	(revision 48363)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2011-2012 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>
-
-#include "vboxvideo_drv.h"
-
-int vboxvideo_modeset_init(struct vboxvideo_device *gdev)
-{
-    struct drm_encoder *encoder;
-    struct drm_connector *connector;
-    int ret;
-    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.vram_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;
-    }
-
-    drm_mode_connector_attach_encoder(connector, encoder);
-
-    ret = vboxvideo_fbdev_init(gdev);
-    if (ret) {
-        VBOXVIDEO_ERROR("vboxvideo_fbdev_init failed\n");
-        return ret;
-    }
-
-    return 0;
-}
-
-void vboxvideo_modeset_fini(struct vboxvideo_device *gdev)
-{
-    vboxvideo_fbdev_fini(gdev);
-
-    if (gdev->mode_info.mode_config_initialized)
-    {
-        drm_mode_config_cleanup(gdev->ddev);
-        gdev->mode_info.mode_config_initialized = false;
-    }
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_drv.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.c	(revision 48363)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2011-2012 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"
-
-#ifndef __devinit
-#define __devinit
-#define __devinitdata
-#endif
-
-static struct drm_driver driver;
-
-static struct pci_device_id pciidlist[] = {
-        vboxvideo_PCI_IDS
-};
-
-MODULE_DEVICE_TABLE(pci, pciidlist);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
-# define drm_get_dev drm_get_pci_dev
-#endif
-
-static int __devinit
-vboxvideo_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-    return drm_get_dev(pdev, ent, &driver);
-}
-
-static void
-vboxvideo_pci_remove(struct pci_dev *pdev)
-{
-    struct drm_device *dev = pci_get_drvdata(pdev);
-
-    drm_put_dev(dev);
-}
-
-#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
-# define IOCTL_MEMBER unlocked_ioctl
-#else
-# define IOCTL_MEMBER ioctl
-#endif
-
-#define DRIVER_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. */ \
-        .IOCTL_MEMBER = drm_ioctl, \
-        .mmap = drm_mmap, \
-        .poll = drm_poll, \
-        .fasync = drm_fasync, \
-    }
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_RHEL63) || defined(DRM_DEBIAN_34ON32)
-/* since linux-3.3.0-rc1 drm_driver::fops is pointer */
-static struct file_operations driver_fops = DRIVER_FOPS;
-#endif
-
-#define PCI_DRIVER \
-    { \
-        .name = DRIVER_NAME, \
-        .id_table = pciidlist, \
-        .probe = vboxvideo_pci_probe, \
-        .remove = vboxvideo_pci_remove, \
-    }
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
-static struct pci_driver pci_driver = PCI_DRIVER;
-#endif
-
-static struct drm_driver driver =
-{
-    .driver_features = DRIVER_MODESET,
-    .load = vboxvideo_driver_load,
-    .unload = vboxvideo_driver_unload,
-    /* As of Linux 2.6.37, always the internal functions are used. */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 37) && !defined(DRM_RHEL61)
-    .reclaim_buffers = drm_core_reclaim_buffers,
-    .get_map_ofs = drm_core_get_map_ofs,
-    .get_reg_ofs = drm_core_get_reg_ofs,
-#endif
-    .ioctls = vboxvideo_ioctls,
-# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && !defined(DRM_RHEL63) && !defined(DRM_DEBIAN_34ON32)
-    .fops = DRIVER_FOPS,
-#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_RHEL63) || defined(DRM_DEBIAN_34ON32) */
-    .fops = &driver_fops,
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
-    .pci_driver = PCI_DRIVER,
-#endif
-    .name = DRIVER_NAME,
-    .desc = DRIVER_DESC,
-    .date = DRIVER_DATE,
-    .major = DRIVER_MAJOR,
-    .minor = DRIVER_MINOR,
-    .patchlevel = DRIVER_PATCHLEVEL,
-};
-
-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: unk/src/VBox/Additions/linux/drm/vboxvideo_drv.h
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.h	(revision 48363)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2011-2012 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)
-
-#define MB (1024 * 1024)
-
-#define VBOXVIDEOFB_CONN_LIMIT VBOX_VIDEO_MAX_SCREENS°°
-
-/* vboxvideo_crtc.c */
-void vboxvideo_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                                 u16 blue, int regno);
-void vboxvideo_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                 u16 *blue, int regno);
-void vboxvideo_crtc_init(struct drm_device *dev, int index);
-
-/* vboxvideo_dac.c */
-struct drm_encoder *vboxvideo_dac_init(struct drm_device *dev);
-
-/* vboxvideo_fbdev.c */
-int vboxvideo_fbdev_init(struct vboxvideo_device *gdev);
-void vboxvideo_fbdev_fini(struct vboxvideo_device *gdev);
-
-/* vboxvideo_framebuffer.c */
-int vboxvideo_framebuffer_init(struct drm_device *dev,
-                               struct vboxvideo_framebuffer *gfb,
-                               struct DRM_MODE_FB_CMD *mode_cmd);
-
-/* 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: unk/src/VBox/Additions/linux/drm/vboxvideo_fbdev.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_fbdev.c	(revision 48363)
+++ 	(revision )
@@ -1,264 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2013 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_fbdev.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 "drm/drmP.h"
-#include "drm/drm.h"
-#include "drm/drm_fb_helper.h"
-
-#include <linux/fb.h>
-
-#include "vboxvideo.h"
-#include "vboxvideo_drv.h"
-
-struct vboxvideo_fbdev {
-    struct drm_fb_helper helper;
-    struct vboxvideo_framebuffer gfb;
-    struct list_head fbdev_list;
-    struct vboxvideo_device *gdev;
-};
-
-static struct fb_ops vboxvideofb_ops = {
-    .owner = THIS_MODULE,
-    .fb_check_var = drm_fb_helper_check_var,
-    .fb_set_par = drm_fb_helper_set_par,
-    .fb_fillrect = cfb_fillrect,
-    .fb_copyarea = cfb_copyarea,
-    .fb_imageblit = cfb_imageblit,
-    .fb_pan_display = drm_fb_helper_pan_display,
-    .fb_blank = drm_fb_helper_blank,
-    .fb_setcmap = drm_fb_helper_setcmap,
-};
-
-static int vboxvideofb_create(struct vboxvideo_fbdev *gfbdev,
-              struct drm_fb_helper_surface_size *sizes)
-{
-    struct vboxvideo_device *gdev = gfbdev->gdev;
-    struct fb_info *info;
-    struct drm_framebuffer *fb;
-    struct drm_map_list *r_list, *list_t;
-    struct drm_local_map *map = NULL;
-    struct DRM_MODE_FB_CMD mode_cmd;
-    struct device *device = &gdev->pdev->dev;
-    __u32 pitch;
-    unsigned int fb_pitch;
-    int ret;
-
-    mode_cmd.width = sizes->surface_width;
-    mode_cmd.height = sizes->surface_height;
-    pitch = mode_cmd.width * ((sizes->surface_bpp + 7) / 8);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-    mode_cmd.bpp = sizes->surface_bpp;
-    mode_cmd.depth = sizes->surface_depth;
-    mode_cmd.pitch = mode_cmd.width * ((mode_cmd.bpp + 7) / 8);
-#else
-    mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
-                                                      sizes->surface_depth);
-    mode_cmd.pitches[0] = mode_cmd.width * ((sizes->surface_bpp + 7) / 8);
-#endif
-
-    info = framebuffer_alloc(0, device);
-    if (info == NULL)
-        return -ENOMEM;
-
-    info->par = gfbdev;
-
-    ret = vboxvideo_framebuffer_init(gdev->ddev, &gfbdev->gfb, &mode_cmd);
-    if (ret)
-        return ret;
-
-    fb = &gfbdev->gfb.base;
-    if (!fb) {
-        VBOXVIDEO_INFO("fb is NULL\n");
-    }
-
-    /* setup helper */
-    gfbdev->helper.fb = fb;
-    gfbdev->helper.fbdev = info;
-
-    strcpy(info->fix.id, "vboxvideodrmfb");
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-    fb_pitch = fb->pitch;
-#else
-    fb_pitch = fb->pitches[0];
-#endif
-    drm_fb_helper_fill_fix(info, fb_pitch, fb->depth);
-
-    info->flags = FBINFO_DEFAULT;
-    info->fbops = &vboxvideofb_ops;
-
-    drm_fb_helper_fill_var(info, &gfbdev->helper, sizes->fb_width, sizes->fb_height);
-
-    /* setup aperture base/size for vesafb takeover */
-    info->apertures = alloc_apertures(1);
-    if (!info->apertures) {
-        ret = -ENOMEM;
-        goto out_iounmap;
-    }
-    info->apertures->ranges[0].base = gdev->ddev->mode_config.fb_base;
-    info->apertures->ranges[0].size = gdev->mc.vram_size;
-
-    list_for_each_entry_safe(r_list, list_t, &gdev->ddev->maplist, head) {
-        map = r_list->map;
-        if (map->type == _DRM_FRAME_BUFFER) {
-            map->handle = ioremap_nocache(map->offset, map->size);
-            if (!map->handle) {
-                VBOXVIDEO_ERROR("fb: can't remap framebuffer\n");
-                return -1;
-            }
-            break;
-        }
-    }
-
-    info->fix.smem_start = map->offset;
-    info->fix.smem_len = map->size;
-    if (!info->fix.smem_len) {
-        VBOXVIDEO_ERROR("%s: can't count memory\n", info->fix.id);
-        goto out_iounmap;
-    }
-    info->screen_base = map->handle;
-    if (!info->screen_base) {
-        VBOXVIDEO_ERROR("%s: can't remap framebuffer\n", info->fix.id);
-        goto out_iounmap;
-    }
-
-    info->fix.mmio_start = 0;
-    info->fix.mmio_len = 0;
-
-    ret = fb_alloc_cmap(&info->cmap, 256, 0);
-    if (ret) {
-        VBOXVIDEO_ERROR("%s: can't allocate color map\n", info->fix.id);
-        ret = -ENOMEM;
-        goto out_iounmap;
-    }
-
-    DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
-    DRM_INFO("vram aper at 0x%lX\n",  (unsigned long)info->fix.smem_start);
-    DRM_INFO("size %lu\n", (unsigned long)info->fix.smem_len);
-    DRM_INFO("fb depth is %d\n", fb->depth);
-    DRM_INFO("   pitch is %d\n", fb_pitch);
-
-    return 0;
-out_iounmap:
-    iounmap(map->handle);
-    return ret;
-}
-
-static int vboxvideo_fb_find_or_create_single(struct drm_fb_helper *helper,
-                                              struct drm_fb_helper_surface_size *sizes)
-{
-    struct vboxvideo_fbdev *gfbdev = (struct vboxvideo_fbdev *)helper;
-    int new_fb = 0;
-    int ret;
-
-    if (!helper->fb) {
-        ret = vboxvideofb_create(gfbdev, sizes);
-        if (ret)
-            return ret;
-        new_fb = 1;
-    }
-    return new_fb;
-}
-
-static int vboxvideo_fbdev_destroy(struct drm_device *dev, struct vboxvideo_fbdev *gfbdev)
-{
-    struct fb_info *info;
-    struct vboxvideo_framebuffer *gfb = &gfbdev->gfb;
-
-    if (gfbdev->helper.fbdev) {
-        info = gfbdev->helper.fbdev;
-
-        unregister_framebuffer(info);
-        if (info->cmap.len)
-            fb_dealloc_cmap(&info->cmap);
-        framebuffer_release(info);
-    }
-
-    drm_fb_helper_fini(&gfbdev->helper);
-    drm_framebuffer_cleanup(&gfb->base);
-
-    return 0;
-}
-
-static struct drm_fb_helper_funcs vboxvideo_fb_helper_funcs = {
-    .gamma_set = vboxvideo_crtc_fb_gamma_set,
-    .gamma_get = vboxvideo_crtc_fb_gamma_get,
-    .fb_probe = vboxvideo_fb_find_or_create_single,
-};
-
-int vboxvideo_fbdev_init(struct vboxvideo_device *gdev)
-{
-    struct vboxvideo_fbdev *gfbdev;
-    int bpp_sel = 32;
-    int ret;
-
-    gfbdev = kzalloc(sizeof(struct vboxvideo_fbdev), GFP_KERNEL);
-    if (!gfbdev)
-        return -ENOMEM;
-
-    gfbdev->gdev = gdev;
-    gdev->mode_info.gfbdev = gfbdev;
-    gfbdev->helper.funcs = &vboxvideo_fb_helper_funcs;
-
-    ret = drm_fb_helper_init(gdev->ddev, &gfbdev->helper,
-                             gdev->num_crtc,
-                             VBOXVIDEOFB_CONN_LIMIT);
-    if (ret) {
-        kfree(gfbdev);
-        return ret;
-    }
-    drm_fb_helper_single_add_all_connectors(&gfbdev->helper);
-    drm_fb_helper_initial_config(&gfbdev->helper, bpp_sel);
-
-    return 0;
-}
-
-void vboxvideo_fbdev_fini(struct vboxvideo_device *gdev)
-{
-    if (!gdev->mode_info.gfbdev)
-        return;
-
-    vboxvideo_fbdev_destroy(gdev->ddev, gdev->mode_info.gfbdev);
-    kfree(gdev->mode_info.gfbdev);
-    gdev->mode_info.gfbdev = NULL;
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_framebuffer.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_framebuffer.c	(revision 48363)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver
- */
-
-/*
- * Copyright (C) 2013 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_framebuffer.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 "drm/drmP.h"
-#include "drm/drm.h"
-#include "drm/drm_crtc_helper.h"
-
-#include "vboxvideo.h"
-#include "vboxvideo_drv.h"
-
-static void vboxvideo_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-    drm_framebuffer_cleanup(fb);
-}
-
-static int vboxvideo_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-                                                    struct drm_file *file_priv,
-                                                    unsigned int *handle)
-{
-    return 0;
-}
-
-static const struct drm_framebuffer_funcs vboxvideo_fb_funcs = {
-    .destroy = vboxvideo_user_framebuffer_destroy,
-    .create_handle = vboxvideo_user_framebuffer_create_handle,
-};
-
-int vboxvideo_framebuffer_init(struct drm_device *dev,
-                               struct vboxvideo_framebuffer *gfb,
-                               struct DRM_MODE_FB_CMD *mode_cmd)
-{
-    int ret = drm_framebuffer_init(dev, &gfb->base, &vboxvideo_fb_funcs);
-    if (ret) {
-        VBOXVIDEO_ERROR("drm_framebuffer_init failed: %d\n", ret);
-        return ret;
-    }
-    drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
-
-    return 0;
-}
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_kms.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_kms.c	(revision 48363)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver, KMS support
- */
-
-/*
- * Copyright (C) 2011-2012 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>
-
-#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);
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_mode.h
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_mode.h	(revision 48363)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/** @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_mode.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_MODE_H__
-#define __DRM_VBOXVIDEO_MODE_H__
-
-#include <VBox/Hardware/VBoxVideoVBE.h>
-#include "drm/drmP.h"
-#include <linux/version.h>
-
-#define VBOXVIDEO_MAX_FB_HEIGHT VBE_DISPI_MAX_YRES
-#define VBOXVIDEO_MAX_FB_WIDTH  VBE_DISPI_MAX_XRES
-
-#define to_vboxvideo_crtc(x)    container_of(x, struct vboxvideo_crtc, base)
-#define to_vboxvideo_encoder(x) container_of(x, struct vboxvideo_encoder, base)
-#define to_vboxvideo_framebuffer(x) container_of(x, struct vboxvideo_framebuffer, base)
-
-#define VBOXVIDEO_DPMS_CLEARED (-1)
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-# define DRM_MODE_FB_CMD drm_mode_fb_cmd
-#else
-# define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-#endif
-
-struct vboxvideo_crtc
-{
-    struct drm_crtc   base;
-    int               crtc_id;
-    size_t            offCommandBuffer;
-    struct VBVABUFFERCONTEXT VbvaCtx;
-    int               last_dpms;
-    int               last_hdisplay;
-    int               last_vdisplay;
-    int               last_x;
-    int               last_y;
-    bool              enabled;
-};
-
-struct vboxvideo_mode_info
-{
-    bool                    mode_config_initialized;
-    struct vboxvideo_crtc  *crtcs[VBOX_VIDEO_MAX_SCREENS];
-    /* pointer to fbdev info structure */
-    struct vboxvideo_fbdev *gfbdev;
-};
-
-struct vboxvideo_encoder
-{
-    struct drm_encoder base;
-    int                last_dpms;
-};
-
-struct vboxvideo_connector {
-    struct drm_connector  base;
-};
-
-struct vboxvideo_framebuffer {
-    struct drm_framebuffer    base;
-};
-
-#endif                /* __DRM_VBOXVIDEO_H__ */
Index: unk/src/VBox/Additions/linux/drm/vboxvideo_vga.c
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/vboxvideo_vga.c	(revision 48363)
+++ 	(revision )
@@ -1,131 +1,0 @@
-/** @file $Id$
- *
- * VirtualBox Additions Linux kernel video driver, VGA functions
- */
-
-/*
- * Copyright (C) 2011-2012 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_vga.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 "vboxvideo_drv.h"
-#include "drm/drm_crtc_helper.h"
-
-static int vboxvideo_vga_get_modes(struct drm_connector *connector)
-{
-    /* return 0 modes, so that we don't have to implement DDC/I2C yet. */
-    return 0;
-}
-
-static int vboxvideo_vga_mode_valid(struct drm_connector *connector,
-                                    struct drm_display_mode *mode)
-{
-    /* XXX check mode bandwidth */
-    /* XXX verify against max DAC output frequency */
-    return MODE_OK;
-}
-
-struct drm_encoder *vboxvideo_connector_best_encoder(struct drm_connector
-                                                           *connector)
-{
-    int enc_id = connector->encoder_ids[0];
-    struct drm_mode_object *obj;
-    struct drm_encoder *encoder;
-
-    /* pick the encoder ids */
-    if (enc_id) {
-        obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
-        if (!obj)
-            return NULL;
-        encoder = obj_to_encoder(obj);
-        return encoder;
-    }
-    return NULL;
-}
-
-static enum drm_connector_status vboxvideo_vga_detect(struct drm_connector
-                                                            *connector
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
-                                                      , bool force
-#endif
-                                                      )
-{
-    return connector_status_connected;
-}
-
-static void vboxvideo_connector_destroy(struct drm_connector *connector)
-{
-    drm_connector_cleanup(connector);
-    kfree(connector);
-}
-
-struct drm_connector_helper_funcs vboxvideo_vga_connector_helper_funcs =
-{
-    .get_modes    = vboxvideo_vga_get_modes,
-    .mode_valid   = vboxvideo_vga_mode_valid,
-    .best_encoder = vboxvideo_connector_best_encoder,
-};
-
-struct drm_connector_funcs vboxvideo_vga_connector_funcs =
-{
-    .dpms       = drm_helper_connector_dpms,
-    .detect     = vboxvideo_vga_detect,
-    .fill_modes = drm_helper_probe_single_connector_modes,
-    .destroy    = vboxvideo_connector_destroy,
-};
-
-struct drm_connector *vboxvideo_vga_init(struct drm_device *dev)
-{
-    struct drm_connector *connector;
-    struct vboxvideo_connector *vboxvideo_connector;
-
-    vboxvideo_connector = kzalloc(sizeof(struct vboxvideo_connector),
-                                  GFP_KERNEL);
-    if (!vboxvideo_connector)
-        return NULL;
-
-    connector = &vboxvideo_connector->base;
-
-    drm_connector_init(dev, connector,
-        &vboxvideo_vga_connector_funcs, DRM_MODE_CONNECTOR_VGA);
-
-    drm_connector_helper_add(connector, &vboxvideo_vga_connector_helper_funcs);
-
-    return connector;
-}
