VirtualBox

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

Last change on this file since 53340 was 53340, checked in by vboxsync, 10 years ago

Additions/linux/drm: make it compile with Linux >= 3.18

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