1 | /** @file $Id: vboxvideo_drm.c 27248 2010-03-10 12:59:29Z vboxsync $
|
---|
2 | *
|
---|
3 | * VirtualBox Additions Linux kernel driver, DRM support
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | * --------------------------------------------------------------------
|
---|
21 | *
|
---|
22 | * This code is based on:
|
---|
23 | *
|
---|
24 | * tdfx_drv.c -- tdfx driver -*- linux-c -*-
|
---|
25 | * Created: Thu Oct 7 10:38:32 1999 by [email protected]
|
---|
26 | *
|
---|
27 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
---|
28 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
---|
29 | * All Rights Reserved.
|
---|
30 | *
|
---|
31 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
32 | * copy of this software and associated documentation files (the "Software"),
|
---|
33 | * to deal in the Software without restriction, including without limitation
|
---|
34 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
35 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
36 | * Software is furnished to do so, subject to the following conditions:
|
---|
37 | *
|
---|
38 | * The above copyright notice and this permission notice (including the next
|
---|
39 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
40 | * Software.
|
---|
41 | *
|
---|
42 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
43 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
44 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
45 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
46 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
47 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
48 | * DEALINGS IN THE SOFTWARE.
|
---|
49 | *
|
---|
50 | * Authors:
|
---|
51 | * Rickard E. (Rik) Faith <[email protected]>
|
---|
52 | * Daryll Strauss <[email protected]>
|
---|
53 | * Gareth Hughes <[email protected]>
|
---|
54 | */
|
---|
55 |
|
---|
56 | #ifndef AUTOCONF_INCLUDED
|
---|
57 | # include <linux/autoconf.h>
|
---|
58 | #endif
|
---|
59 | #include <linux/version.h>
|
---|
60 | #include <linux/module.h>
|
---|
61 |
|
---|
62 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
---|
63 |
|
---|
64 | #include "drm/drmP.h"
|
---|
65 | #include "vboxvideo_drm.h"
|
---|
66 |
|
---|
67 | static struct pci_device_id pciidlist[] = {
|
---|
68 | vboxvideo_PCI_IDS
|
---|
69 | };
|
---|
70 |
|
---|
71 | int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
|
---|
72 | {
|
---|
73 | # if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 28)
|
---|
74 | return drm_vblank_init(dev, 1);
|
---|
75 | #else
|
---|
76 | return 0;
|
---|
77 | #endif
|
---|
78 | }
|
---|
79 |
|
---|
80 | static struct drm_driver driver = {
|
---|
81 | /* .driver_features = DRIVER_USE_MTRR, */
|
---|
82 | .load = vboxvideo_driver_load,
|
---|
83 | .reclaim_buffers = drm_core_reclaim_buffers,
|
---|
84 | .get_map_ofs = drm_core_get_map_ofs,
|
---|
85 | .get_reg_ofs = drm_core_get_reg_ofs,
|
---|
86 | .fops = {
|
---|
87 | .owner = THIS_MODULE,
|
---|
88 | .open = drm_open,
|
---|
89 | .release = drm_release,
|
---|
90 | /* This was changed with Linux 2.6.33 but Fedora backported this
|
---|
91 | * change to their 2.6.32 kernel. */
|
---|
92 | #if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 33)
|
---|
93 | .unlocked_ioctl = drm_ioctl,
|
---|
94 | #else
|
---|
95 | .ioctl = drm_ioctl,
|
---|
96 | #endif
|
---|
97 | .mmap = drm_mmap,
|
---|
98 | .poll = drm_poll,
|
---|
99 | .fasync = drm_fasync,
|
---|
100 | },
|
---|
101 | .pci_driver = {
|
---|
102 | .name = DRIVER_NAME,
|
---|
103 | .id_table = pciidlist,
|
---|
104 | },
|
---|
105 |
|
---|
106 | .name = DRIVER_NAME,
|
---|
107 | .desc = DRIVER_DESC,
|
---|
108 | .date = DRIVER_DATE,
|
---|
109 | .major = DRIVER_MAJOR,
|
---|
110 | .minor = DRIVER_MINOR,
|
---|
111 | .patchlevel = DRIVER_PATCHLEVEL,
|
---|
112 | };
|
---|
113 |
|
---|
114 | static int __init vboxvideo_init(void)
|
---|
115 | {
|
---|
116 | return drm_init(&driver);
|
---|
117 | }
|
---|
118 |
|
---|
119 | static void __exit vboxvideo_exit(void)
|
---|
120 | {
|
---|
121 | drm_exit(&driver);
|
---|
122 | }
|
---|
123 |
|
---|
124 | module_init(vboxvideo_init);
|
---|
125 | module_exit(vboxvideo_exit);
|
---|
126 |
|
---|
127 | MODULE_AUTHOR(DRIVER_AUTHOR);
|
---|
128 | MODULE_DESCRIPTION(DRIVER_DESC);
|
---|
129 |
|
---|
130 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
|
---|
131 |
|
---|
132 | MODULE_LICENSE("GPL and additional rights");
|
---|