VirtualBox

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

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

Additions/linux/drm: build on SLES 11 sp 3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/** @file $Id: vboxvideo_drm.c 48354 2013-09-06 12:52:27Z 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 <linux/version.h>
53#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
54# include <generated/autoconf.h>
55#else
56# ifndef AUTOCONF_INCLUDED
57# include <linux/autoconf.h>
58# endif
59#endif
60#include <linux/module.h>
61#include "version-generated.h"
62
63#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
64
65# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
66# ifdef RHEL_RELEASE_CODE
67# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 1)
68# define DRM_RHEL61
69# endif
70# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 3)
71# define DRM_FOPS_AS_POINTER
72# endif
73# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)
74# define DRM_NO_RECLAIM_BUFFERS
75# endif
76# endif
77# endif
78
79#include "drm/drmP.h"
80#include "vboxvideo_drm.h"
81
82# ifndef RHEL_RELEASE_CODE
83# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 39) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
84# if defined(DRM_MODE_OBJECT_PLANE) && defined(DRM_IOCTL_MODE_ADDFB2)
85# define DRM_FOPS_AS_POINTER
86# endif
87# endif
88# endif
89
90#ifdef CONFIG_SUSE_KERNEL
91/* This is to cover the SLES 11 SP3 kernel back-ports. */
92# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,61)
93# if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
94# define DRM_FOPS_AS_POINTER
95# define DRM_NO_RECLAIM_BUFFERS
96# endif
97# endif
98#endif
99
100static struct pci_device_id pciidlist[] = {
101 vboxvideo_PCI_IDS
102};
103
104MODULE_DEVICE_TABLE(pci, pciidlist);
105
106int vboxvideo_driver_load(struct drm_device * dev, unsigned long flags)
107{
108# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
109 return drm_vblank_init(dev, 1);
110#else
111 return 0;
112#endif
113}
114#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_FOPS_AS_POINTER)
115/* since linux-3.3.0-rc1 drm_driver::fops is pointer */
116static struct file_operations driver_fops =
117{
118 .owner = THIS_MODULE,
119 .open = drm_open,
120 .release = drm_release,
121 .unlocked_ioctl = drm_ioctl,
122 .mmap = drm_mmap,
123 .poll = drm_poll,
124 .fasync = drm_fasync,
125};
126#endif
127
128static struct drm_driver driver =
129{
130 /* .driver_features = DRIVER_USE_MTRR, */
131 .load = vboxvideo_driver_load,
132#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) && !defined(DRM_NO_RECLAIM_BUFFERS)
133 .reclaim_buffers = drm_core_reclaim_buffers,
134#endif
135 /* As of Linux 2.6.37, always the internal functions are used. */
136#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) && !defined(DRM_RHEL61)
137 .get_map_ofs = drm_core_get_map_ofs,
138 .get_reg_ofs = drm_core_get_reg_ofs,
139#endif
140# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && !defined(DRM_FOPS_AS_POINTER)
141 .fops =
142 {
143 .owner = THIS_MODULE,
144 .open = drm_open,
145 .release = drm_release,
146 /* This was changed with Linux 2.6.33 but Fedora backported this
147 * change to their 2.6.32 kernel. */
148#if defined(DRM_UNLOCKED) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
149 .unlocked_ioctl = drm_ioctl,
150#else
151 .ioctl = drm_ioctl,
152#endif
153 .mmap = drm_mmap,
154 .poll = drm_poll,
155 .fasync = drm_fasync,
156 },
157#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(DRM_FOPS_AS_POINTER) */
158 .fops = &driver_fops,
159#endif
160#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
161 .pci_driver =
162 {
163 .name = DRIVER_NAME,
164 .id_table = pciidlist,
165 },
166#endif
167 .name = DRIVER_NAME,
168 .desc = DRIVER_DESC,
169 .date = DRIVER_DATE,
170 .major = DRIVER_MAJOR,
171 .minor = DRIVER_MINOR,
172 .patchlevel = DRIVER_PATCHLEVEL,
173};
174
175#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) || defined(DRM_RHEL61)
176static struct pci_driver pci_driver =
177{
178 .name = DRIVER_NAME,
179 .id_table = pciidlist,
180};
181#endif
182
183static int __init vboxvideo_init(void)
184{
185#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
186 return drm_init(&driver);
187#else
188 return drm_pci_init(&driver, &pci_driver);
189#endif
190}
191
192static void __exit vboxvideo_exit(void)
193{
194#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(DRM_RHEL61)
195 drm_exit(&driver);
196#else
197 drm_pci_exit(&driver, &pci_driver);
198#endif
199}
200
201module_init(vboxvideo_init);
202module_exit(vboxvideo_exit);
203
204MODULE_AUTHOR(DRIVER_AUTHOR);
205MODULE_DESCRIPTION(DRIVER_DESC);
206
207#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
208
209#ifdef MODULE_VERSION
210MODULE_VERSION(VBOX_VERSION_STRING);
211#endif
212MODULE_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