~ubuntu-branches/ubuntu/vivid/virtualbox/vivid

« back to all changes in this revision

Viewing changes to .pc/37-wheezy-kernel-drm.patch/src/VBox/Additions/linux/drm/vboxvideo_drm.c

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-03-31 23:25:01 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20130331232501-l72jhvixkeyyz6xc
Tags: 4.2.10-dfsg-0ubuntu1
* Start the virtualbox-guest-x11 init script earlier.
  The vboxvideo module needs to be loaded before X starts.
* Change runlevels of virtualbox-guest-x11 init script on upgrade.
* Fix build failure with the Debian wheezy kernel which backports the drm
  subsystem from Linux 3.4. (Closes: #703358)
* Drop build-dependency on bcc as it's not needed anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file $Id: vboxvideo_drm.c $
 
2
 *
 
3
 * VirtualBox Additions Linux kernel driver, DRM support
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 2006-2012 Oracle Corporation
 
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
 *
 
18
 * This code is based on:
 
19
 *
 
20
 * tdfx_drv.c -- tdfx driver -*- linux-c -*-
 
21
 * Created: Thu Oct  7 10:38:32 1999 by faith@precisioninsight.com
 
22
 *
 
23
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
 
24
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 
25
 * All Rights Reserved.
 
26
 *
 
27
 * Permission is hereby granted, free of charge, to any person obtaining a
 
28
 * copy of this software and associated documentation files (the "Software"),
 
29
 * to deal in the Software without restriction, including without limitation
 
30
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
31
 * and/or sell copies of the Software, and to permit persons to whom the
 
32
 * Software is furnished to do so, subject to the following conditions:
 
33
 *
 
34
 * The above copyright notice and this permission notice (including the next
 
35
 * paragraph) shall be included in all copies or substantial portions of the
 
36
 * Software.
 
37
 *
 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
39
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
40
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
41
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
42
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
43
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
44
 * DEALINGS IN THE SOFTWARE.
 
45
 *
 
46
 * Authors:
 
47
 *    Rickard E. (Rik) Faith <faith@valinux.com>
 
48
 *    Daryll Strauss <daryll@valinux.com>
 
49
 *    Gareth Hughes <gareth@valinux.com>
 
50
 */
 
51
 
 
52
#include <linux/version.h>
 
53
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
 
54
# include <generated/autoconf.h>
 
55
#else
 
56
# ifndef AUTOCONF_INCLUDED
 
57
#  include <linux/autoconf.h>
 
58
# endif
 
59
#endif
 
60
#include <linux/module.h>
 
61
#include "version-generated.h"
 
62
 
 
63
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
 
64
 
 
65
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
 
66
#  ifdef RHEL_RELEASE_CODE
 
67
#   if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,1)
 
68
#    define DRM_RHEL61
 
69
#   endif
 
70
#   if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,3)
 
71
#    define DRM_RHEL63
 
72
#   endif
 
73
#  endif
 
74
# endif
 
75
 
 
76
#include "drm/drmP.h"
 
77
#include "vboxvideo_drm.h"
 
78
 
 
79
static struct pci_device_id pciidlist[] = {
 
80
        vboxvideo_PCI_IDS
 
81
};
 
82
 
 
83
int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
 
84
{
 
85
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
 
86
    return drm_vblank_init(dev, 1);
 
87
#else
 
88
    return 0;
 
89
#endif
 
90
}
 
91
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_RHEL63)
 
92
/* since linux-3.3.0-rc1 drm_driver::fops is pointer */
 
93
static struct file_operations driver_fops =
 
94
{
 
95
        .owner = THIS_MODULE,
 
96
        .open = drm_open,
 
97
        .release = drm_release,
 
98
        .unlocked_ioctl = drm_ioctl,
 
99
        .mmap = drm_mmap,
 
100
        .poll = drm_poll,
 
101
        .fasync = drm_fasync,
 
102
};
 
103
#endif
 
104
 
 
105
static struct drm_driver driver =
 
106
{
 
107
    /* .driver_features = DRIVER_USE_MTRR, */
 
108
    .load = vboxvideo_driver_load,
 
109
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
 
110
    .reclaim_buffers = drm_core_reclaim_buffers,
 
111
#endif
 
112
    /* As of Linux 2.6.37, always the internal functions are used. */
 
113
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) && !defined(DRM_RHEL61)
 
114
    .get_map_ofs = drm_core_get_map_ofs,
 
115
    .get_reg_ofs = drm_core_get_reg_ofs,
 
116
#endif
 
117
# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && !defined(DRM_RHEL63)
 
118
    .fops =
 
119
    {
 
120
        .owner = THIS_MODULE,
 
121
        .open = drm_open,
 
122
        .release = drm_release,
 
123
        /* This was changed with Linux 2.6.33 but Fedora backported this
 
124
         * change to their 2.6.32 kernel. */
 
125
#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
 
126
        .unlocked_ioctl = drm_ioctl,
 
127
#else
 
128
        .ioctl = drm_ioctl,
 
129
#endif
 
130
        .mmap = drm_mmap,
 
131
        .poll = drm_poll,
 
132
        .fasync = drm_fasync,
 
133
    },
 
134
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_RHEL63) */
 
135
    .fops = &driver_fops,
 
136
#endif
 
137
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
 
138
    .pci_driver =
 
139
    {
 
140
        .name = DRIVER_NAME,
 
141
        .id_table = pciidlist,
 
142
    },
 
143
#endif
 
144
    .name = DRIVER_NAME,
 
145
    .desc = DRIVER_DESC,
 
146
    .date = DRIVER_DATE,
 
147
    .major = DRIVER_MAJOR,
 
148
    .minor = DRIVER_MINOR,
 
149
    .patchlevel = DRIVER_PATCHLEVEL,
 
150
};
 
151
 
 
152
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) || defined(DRM_RHEL61)
 
153
static struct pci_driver pci_driver =
 
154
{
 
155
    .name = DRIVER_NAME,
 
156
    .id_table = pciidlist,
 
157
};
 
158
#endif
 
159
 
 
160
static int __init vboxvideo_init(void)
 
161
{
 
162
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
 
163
    return drm_init(&driver);
 
164
#else
 
165
    return drm_pci_init(&driver, &pci_driver);
 
166
#endif
 
167
}
 
168
 
 
169
static void __exit vboxvideo_exit(void)
 
170
{
 
171
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
 
172
    drm_exit(&driver);
 
173
#else
 
174
    drm_pci_exit(&driver, &pci_driver);
 
175
#endif
 
176
}
 
177
 
 
178
module_init(vboxvideo_init);
 
179
module_exit(vboxvideo_exit);
 
180
 
 
181
MODULE_AUTHOR(DRIVER_AUTHOR);
 
182
MODULE_DESCRIPTION(DRIVER_DESC);
 
183
 
 
184
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
 
185
 
 
186
#ifdef MODULE_VERSION
 
187
MODULE_VERSION(VBOX_VERSION_STRING);
 
188
#endif
 
189
MODULE_LICENSE("GPL and additional rights");