VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vbox_drv.c@ 59236

Last change on this file since 59236 was 58129, checked in by vboxsync, 9 years ago

linux/drm: Fixed incorrect file headers. (copy + past is difficult, apparently)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: vbox_drv.c 58129 2015-10-08 22:29:48Z vboxsync $ */
2/** @file
3 * VirtualBox Additions Linux kernel video driver
4 */
5
6/*
7 * Copyright (C) 2013 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 * ast_drv.c
20 * with the following copyright and permission notice:
21 *
22 * Copyright 2012 Red Hat Inc.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the
26 * "Software"), to deal in the Software without restriction, including
27 * without limitation the rights to use, copy, modify, merge, publish,
28 * distribute, sub license, and/or sell copies of the Software, and to
29 * permit persons to whom the Software is furnished to do so, subject to
30 * the following conditions:
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
35 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
36 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
37 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
38 * USE OR OTHER DEALINGS IN THE SOFTWARE.
39 *
40 * The above copyright notice and this permission notice (including the
41 * next paragraph) shall be included in all copies or substantial portions
42 * of the Software.
43 *
44 */
45/*
46 * Authors: Dave Airlie <[email protected]>
47 */
48#include "vbox_drv.h"
49
50#include <VBox/VBoxGuest.h>
51
52#include <linux/module.h>
53#include <linux/console.h>
54
55#include <drm/drmP.h>
56#include <drm/drm_crtc_helper.h>
57
58int vbox_modeset = -1;
59
60MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
61module_param_named(modeset, vbox_modeset, int, 0400);
62
63static struct drm_driver driver;
64
65static DEFINE_PCI_DEVICE_TABLE(pciidlist) =
66{
67 {0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
68 {0, 0, 0},
69};
70
71MODULE_DEVICE_TABLE(pci, pciidlist);
72
73static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
74{
75 return drm_get_pci_dev(pdev, ent, &driver);
76}
77
78
79static void vbox_pci_remove(struct pci_dev *pdev)
80{
81 struct drm_device *dev = pci_get_drvdata(pdev);
82
83 drm_put_dev(dev);
84}
85
86
87static struct pci_driver vbox_pci_driver =
88{
89 .name = DRIVER_NAME,
90 .id_table = pciidlist,
91 .probe = vbox_pci_probe,
92 .remove = vbox_pci_remove,
93};
94
95
96static const struct file_operations vbox_fops =
97{
98 .owner = THIS_MODULE,
99 .open = drm_open,
100 .release = drm_release,
101 .unlocked_ioctl = drm_ioctl,
102 .mmap = vbox_mmap,
103 .poll = drm_poll,
104#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
105 .fasync = drm_fasync,
106#endif
107#ifdef CONFIG_COMPAT
108 .compat_ioctl = drm_compat_ioctl,
109#endif
110 .read = drm_read,
111};
112
113static struct drm_driver driver =
114{
115 .driver_features = DRIVER_MODESET | DRIVER_GEM,
116 .dev_priv_size = 0,
117
118 .load = vbox_driver_load,
119 .unload = vbox_driver_unload,
120 .lastclose = vbox_driver_lastclose,
121
122 .fops = &vbox_fops,
123 .name = DRIVER_NAME,
124 .desc = DRIVER_DESC,
125 .date = DRIVER_DATE,
126 .major = DRIVER_MAJOR,
127 .minor = DRIVER_MINOR,
128 .patchlevel = DRIVER_PATCHLEVEL,
129
130 .gem_free_object = vbox_gem_free_object,
131 .dumb_create = vbox_dumb_create,
132 .dumb_map_offset = vbox_dumb_mmap_offset,
133 .dumb_destroy = vbox_dumb_destroy,
134
135};
136
137static int __init vbox_init(void)
138{
139#ifdef CONFIG_VGA_CONSOLE
140 if (vgacon_text_force() && vbox_modeset == -1)
141 return -EINVAL;
142#endif
143
144 if (vbox_modeset == 0)
145 return -EINVAL;
146 return drm_pci_init(&driver, &vbox_pci_driver);
147}
148static void __exit vbox_exit(void)
149{
150 drm_pci_exit(&driver, &vbox_pci_driver);
151}
152
153module_init(vbox_init);
154module_exit(vbox_exit);
155
156MODULE_AUTHOR(DRIVER_AUTHOR);
157MODULE_DESCRIPTION(DRIVER_DESC);
158MODULE_LICENSE("GPL and additional rights");
159
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