VirtualBox

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

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

Additions/linux/drm: Linux 3.18 warning fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/** @file $Id: vboxvideo_drm.c 54171 2015-02-12 10:56:53Z 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#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
107 /* If this is missing a warning gets printed to dmesg. We will not
108 * attempt to make kernels work to which the change (915b4d11b) got back-
109 * ported, as the problem is only cosmetic. */
110 .set_busid = drm_pci_set_busid,
111#endif
112# ifndef DRM_FOPS_AS_POINTER
113 .fops =
114 {
115 .owner = THIS_MODULE,
116 .open = drm_open,
117 .release = drm_release,
118 /* This was changed with Linux 2.6.33 but Fedora backported this
119 * change to their 2.6.32 kernel. */
120#if defined(DRM_UNLOCKED)
121 .unlocked_ioctl = drm_ioctl,
122#else
123 .ioctl = drm_ioctl,
124#endif
125 .mmap = drm_mmap,
126 .poll = drm_poll,
127 },
128#else /* defined(DRM_FOPS_AS_POINTER) */
129 .fops = &driver_fops,
130#endif
131#ifndef DRM_NEW_BUS_INIT
132 .pci_driver =
133 {
134 .name = DRIVER_NAME,
135 .id_table = pciidlist,
136 },
137#endif
138 .name = DRIVER_NAME,
139 .desc = DRIVER_DESC,
140 .date = DRIVER_DATE,
141 .major = DRIVER_MAJOR,
142 .minor = DRIVER_MINOR,
143 .patchlevel = DRIVER_PATCHLEVEL,
144};
145
146#ifdef DRM_NEW_BUS_INIT
147static struct pci_driver pci_driver =
148{
149 .name = DRIVER_NAME,
150 .id_table = pciidlist,
151};
152#endif
153
154static int __init vboxvideo_init(void)
155{
156#ifndef DRM_NEW_BUS_INIT
157 return drm_init(&driver);
158#else
159 return drm_pci_init(&driver, &pci_driver);
160#endif
161}
162
163static void __exit vboxvideo_exit(void)
164{
165#ifndef DRM_NEW_BUS_INIT
166 drm_exit(&driver);
167#else
168 drm_pci_exit(&driver, &pci_driver);
169#endif
170}
171
172module_init(vboxvideo_init);
173module_exit(vboxvideo_exit);
174
175MODULE_AUTHOR(DRIVER_AUTHOR);
176MODULE_DESCRIPTION(DRIVER_DESC);
177#ifdef MODULE_VERSION
178MODULE_VERSION(VBOX_VERSION_STRING);
179#endif
180MODULE_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