VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vboxvideo_drv.c@ 45203

Last change on this file since 45203 was 44529, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/** @file $Id: vboxvideo_drv.c 44529 2013-02-04 15:54:15Z vboxsync $
2 *
3 * VirtualBox Additions Linux kernel video driver
4 */
5
6/*
7 * Copyright (C) 2011-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 * glint_drv.c
20 * with the following copyright and permission notice:
21 *
22 * Copyright 2010 Matt Turner.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included in
32 * all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
38 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
39 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 * OTHER DEALINGS IN THE SOFTWARE.
41 *
42 * Authors: Matt Turner
43 */
44
45#include <linux/version.h>
46#include <linux/module.h>
47#include "version-generated.h"
48
49#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
50
51# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
52# ifdef RHEL_RELEASE_CODE
53# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,1)
54# define DRM_RHEL61
55# endif
56# endif
57# endif
58
59#include "vboxvideo_drv.h"
60
61static struct pci_device_id pciidlist[] = {
62 vboxvideo_PCI_IDS
63};
64
65static struct drm_driver driver =
66{
67 .driver_features = 0,
68 .load = vboxvideo_driver_load,
69 .unload = vboxvideo_driver_unload,
70 .reclaim_buffers = drm_core_reclaim_buffers,
71 /* As of Linux 2.6.37, always the internal functions are used. */
72#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) && !defined(DRM_RHEL61)
73 .get_map_ofs = drm_core_get_map_ofs,
74 .get_reg_ofs = drm_core_get_reg_ofs,
75#endif
76 .ioctls = vboxvideo_ioctls,
77 .fops =
78 {
79 .owner = THIS_MODULE,
80 .open = drm_open,
81 .release = drm_release,
82 /* This was changed with Linux 2.6.33 but Fedora backported this
83 * change to their 2.6.32 kernel. */
84#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
85 .unlocked_ioctl = drm_ioctl,
86#else
87 .ioctl = drm_ioctl,
88#endif
89 .mmap = drm_mmap,
90 .poll = drm_poll,
91 .fasync = drm_fasync,
92 },
93#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
94 .pci_driver =
95 {
96 .name = DRIVER_NAME,
97 .id_table = pciidlist,
98 },
99#endif
100 .name = DRIVER_NAME,
101 .desc = DRIVER_DESC,
102 .date = DRIVER_DATE,
103 .major = DRIVER_MAJOR,
104 .minor = DRIVER_MINOR,
105 .patchlevel = DRIVER_PATCHLEVEL,
106};
107
108#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
109static struct pci_driver pci_driver =
110{
111 .name = DRIVER_NAME,
112 .id_table = pciidlist,
113};
114#endif
115
116static int __init vboxvideo_init(void)
117{
118 printk(KERN_INFO "vboxvideo initializing\n");
119 driver.num_ioctls = vboxvideo_max_ioctl;
120#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
121 return drm_init(&driver);
122#else
123 return drm_pci_init(&driver, &pci_driver);
124#endif
125}
126
127static void __exit vboxvideo_exit(void)
128{
129 printk(KERN_INFO "vboxvideo exiting\n");
130#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
131 drm_exit(&driver);
132#else
133 drm_pci_exit(&driver, &pci_driver);
134#endif
135}
136
137module_init(vboxvideo_init);
138module_exit(vboxvideo_exit);
139
140MODULE_AUTHOR(DRIVER_AUTHOR);
141MODULE_DESCRIPTION(DRIVER_DESC);
142
143#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
144
145#ifdef MODULE_VERSION
146MODULE_VERSION(VBOX_VERSION_STRING);
147#endif
148MODULE_LICENSE("GPL and additional rights");
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette