VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vboxvideo_drm.c@ 53034

Last change on this file since 53034 was 52017, checked in by vboxsync, 11 years ago

Additions/linux/drm: small fix to work with Linux 3.16.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/** @file $Id: vboxvideo_drm.c 52017 2014-07-14 19:20:14Z vboxsync $
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 [email protected]
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 <[email protected]>
48 * Daryll Strauss <[email protected]>
49 * Gareth Hughes <[email protected]>
50 */
51
52#include "version-generated.h"
53
54#include <linux/module.h>
55#include <drm/drmP.h>
56#include "vboxvideo_drm.h"
57
58/* This definition and the file-operations-as-pointer change were both added in
59 * kernel 3.3. All back-ports of the structure change to distribution kernels
60 * that I have checked also back-ported the definition at the same time. */
61#ifdef DRM_IOCTL_MODE_ADDFB2
62# define DRM_FOPS_AS_POINTER
63#endif
64
65/* The first of these was introduced when drm was generalised to work with
66 * non-PCI buses, but was removed between 3.15 and 3.16. The second is a
67 * random definition introduced in the mean-time. */
68#if defined(DRIVER_BUS_PCI) || defined(DRIVER_PRIME)
69# define DRM_NEW_BUS_INIT 1
70#endif
71
72static struct pci_device_id pciidlist[] = {
73 vboxvideo_PCI_IDS
74};
75
76MODULE_DEVICE_TABLE(pci, pciidlist);
77
78int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
79{
80 return 0;
81}
82
83#ifdef DRM_FOPS_AS_POINTER
84/* since linux-3.3.0-rc1 drm_driver::fops is pointer */
85static struct file_operations driver_fops =
86{
87 .owner = THIS_MODULE,
88 .open = drm_open,
89 .release = drm_release,
90 .unlocked_ioctl = drm_ioctl,
91 .mmap = drm_mmap,
92 .poll = drm_poll,
93};
94#endif
95
96static struct drm_driver driver =
97{
98 /* .driver_features = DRIVER_USE_MTRR, */
99 .load = vboxvideo_driver_load,
100# ifndef DRM_FOPS_AS_POINTER
101 .fops =
102 {
103 .owner = THIS_MODULE,
104 .open = drm_open,
105 .release = drm_release,
106 /* This was changed with Linux 2.6.33 but Fedora backported this
107 * change to their 2.6.32 kernel. */
108#if defined(DRM_UNLOCKED)
109 .unlocked_ioctl = drm_ioctl,
110#else
111 .ioctl = drm_ioctl,
112#endif
113 .mmap = drm_mmap,
114 .poll = drm_poll,
115 },
116#else /* defined(DRM_FOPS_AS_POINTER) */
117 .fops = &driver_fops,
118#endif
119#ifndef DRM_NEW_BUS_INIT
120 .pci_driver =
121 {
122 .name = DRIVER_NAME,
123 .id_table = pciidlist,
124 },
125#endif
126 .name = DRIVER_NAME,
127 .desc = DRIVER_DESC,
128 .date = DRIVER_DATE,
129 .major = DRIVER_MAJOR,
130 .minor = DRIVER_MINOR,
131 .patchlevel = DRIVER_PATCHLEVEL,
132};
133
134#ifdef DRM_NEW_BUS_INIT
135static struct pci_driver pci_driver =
136{
137 .name = DRIVER_NAME,
138 .id_table = pciidlist,
139};
140#endif
141
142static int __init vboxvideo_init(void)
143{
144#ifndef DRM_NEW_BUS_INIT
145 return drm_init(&driver);
146#else
147 return drm_pci_init(&driver, &pci_driver);
148#endif
149}
150
151static void __exit vboxvideo_exit(void)
152{
153#ifndef DRM_NEW_BUS_INIT
154 drm_exit(&driver);
155#else
156 drm_pci_exit(&driver, &pci_driver);
157#endif
158}
159
160module_init(vboxvideo_init);
161module_exit(vboxvideo_exit);
162
163MODULE_AUTHOR(DRIVER_AUTHOR);
164MODULE_DESCRIPTION(DRIVER_DESC);
165#ifdef MODULE_VERSION
166MODULE_VERSION(VBOX_VERSION_STRING);
167#endif
168MODULE_LICENSE("GPL and additional rights");
Note: See TracBrowser for help on using the repository browser.

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