1 | /* $Id: vboxvideo_drm.c 44528 2013-02-04 14:27:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Guest Additions - vboxvideo DRM module.
|
---|
4 | * FreeBSD kernel OpenGL module.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | * --------------------------------------------------------------------
|
---|
18 | *
|
---|
19 | * This code is based on:
|
---|
20 | *
|
---|
21 | * tdfx_drv.c -- tdfx driver -*- linux-c -*-
|
---|
22 | * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
|
---|
23 | *
|
---|
24 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
---|
25 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
---|
26 | * All Rights Reserved.
|
---|
27 | *
|
---|
28 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
29 | * copy of this software and associated documentation files (the "Software"),
|
---|
30 | * to deal in the Software without restriction, including without limitation
|
---|
31 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
32 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
33 | * Software is furnished to do so, subject to the following conditions:
|
---|
34 | *
|
---|
35 | * The above copyright notice and this permission notice (including the next
|
---|
36 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
37 | * Software.
|
---|
38 | *
|
---|
39 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
40 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
41 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
42 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
43 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
44 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
45 | * DEALINGS IN THE SOFTWARE.
|
---|
46 | *
|
---|
47 | * Authors:
|
---|
48 | * Rickard E. (Rik) Faith <faith@valinux.com>
|
---|
49 | * Daryll Strauss <daryll@valinux.com>
|
---|
50 | * Gareth Hughes <gareth@valinux.com>
|
---|
51 | *
|
---|
52 | */
|
---|
53 |
|
---|
54 | #include <sys/cdefs.h>
|
---|
55 | __FBSDID("$FreeBSD$");
|
---|
56 |
|
---|
57 | #include "dev/drm/drmP.h"
|
---|
58 | #include "dev/drm/drm_pciids.h"
|
---|
59 |
|
---|
60 | #define DRIVER_AUTHOR "Oracle Corporation"
|
---|
61 | #define DRIVER_NAME "vboxvideo"
|
---|
62 | #define DRIVER_DESC "VirtualBox DRM"
|
---|
63 | #define DRIVER_DATE "20090317"
|
---|
64 | #define DRIVER_MAJOR 1
|
---|
65 | #define DRIVER_MINOR 0
|
---|
66 | #define DRIVER_PATCHLEVEL 0
|
---|
67 |
|
---|
68 | /** @todo Take PCI IDs from VBox/param.h; VBOX_VESA_VENDORID,
|
---|
69 | * VBOX_VESA_DEVICEID. */
|
---|
70 | #define vboxvideo_PCI_IDS { 0x80ee, 0xbeef, 0, "VirtualBox Video" }, \
|
---|
71 | { 0, 0, 0, NULL }
|
---|
72 |
|
---|
73 | static drm_pci_id_list_t vboxvideo_pciidlist[] = {
|
---|
74 | vboxvideo_PCI_IDS
|
---|
75 | };
|
---|
76 |
|
---|
77 | static void vboxvideo_configure(struct drm_device *dev)
|
---|
78 | {
|
---|
79 | #if __FreeBSD_version >= 702000
|
---|
80 | dev->driver->buf_priv_size = 1; /* No dev_priv */
|
---|
81 |
|
---|
82 | dev->driver->max_ioctl = 0;
|
---|
83 |
|
---|
84 | dev->driver->name = DRIVER_NAME;
|
---|
85 | dev->driver->desc = DRIVER_DESC;
|
---|
86 | dev->driver->date = DRIVER_DATE;
|
---|
87 | dev->driver->major = DRIVER_MAJOR;
|
---|
88 | dev->driver->minor = DRIVER_MINOR;
|
---|
89 | dev->driver->patchlevel = DRIVER_PATCHLEVEL;
|
---|
90 | #else
|
---|
91 | dev->driver.buf_priv_size = 1; /* No dev_priv */
|
---|
92 |
|
---|
93 | dev->driver.max_ioctl = 0;
|
---|
94 |
|
---|
95 | dev->driver.name = DRIVER_NAME;
|
---|
96 | dev->driver.desc = DRIVER_DESC;
|
---|
97 | dev->driver.date = DRIVER_DATE;
|
---|
98 | dev->driver.major = DRIVER_MAJOR;
|
---|
99 | dev->driver.minor = DRIVER_MINOR;
|
---|
100 | dev->driver.patchlevel = DRIVER_PATCHLEVEL;
|
---|
101 | #endif
|
---|
102 | }
|
---|
103 |
|
---|
104 | static int
|
---|
105 | vboxvideo_probe(device_t kdev)
|
---|
106 | {
|
---|
107 | return drm_probe(kdev, vboxvideo_pciidlist);
|
---|
108 | }
|
---|
109 |
|
---|
110 | static int
|
---|
111 | vboxvideo_attach(device_t kdev)
|
---|
112 | {
|
---|
113 | struct drm_device *dev = device_get_softc(kdev);
|
---|
114 |
|
---|
115 | #if __FreeBSD_version >= 702000
|
---|
116 | dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
|
---|
117 | M_WAITOK | M_ZERO);
|
---|
118 | #else
|
---|
119 | bzero(&dev->driver, sizeof(struct drm_driver_info));
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | vboxvideo_configure(dev);
|
---|
123 |
|
---|
124 | return drm_attach(kdev, vboxvideo_pciidlist);
|
---|
125 | }
|
---|
126 |
|
---|
127 | static int
|
---|
128 | vboxvideo_detach(device_t kdev)
|
---|
129 | {
|
---|
130 | struct drm_device *dev = device_get_softc(kdev);
|
---|
131 | int ret;
|
---|
132 |
|
---|
133 | ret = drm_detach(kdev);
|
---|
134 |
|
---|
135 | #if __FreeBSD_version >= 702000
|
---|
136 | free(dev->driver, DRM_MEM_DRIVER);
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | return ret;
|
---|
140 | }
|
---|
141 |
|
---|
142 | static device_method_t vboxvideo_methods[] = {
|
---|
143 | /* Device interface */
|
---|
144 | DEVMETHOD(device_probe, vboxvideo_probe),
|
---|
145 | DEVMETHOD(device_attach, vboxvideo_attach),
|
---|
146 | DEVMETHOD(device_detach, vboxvideo_detach),
|
---|
147 |
|
---|
148 | { 0, 0 }
|
---|
149 | };
|
---|
150 |
|
---|
151 | static driver_t vboxvideo_driver = {
|
---|
152 | "drm",
|
---|
153 | vboxvideo_methods,
|
---|
154 | sizeof(struct drm_device)
|
---|
155 | };
|
---|
156 |
|
---|
157 | extern devclass_t drm_devclass;
|
---|
158 | #if __FreeBSD_version >= 700010
|
---|
159 | DRIVER_MODULE(vboxvideo, vgapci, vboxvideo_driver, drm_devclass, 0, 0);
|
---|
160 | #else
|
---|
161 | DRIVER_MODULE(vboxvideo, pci, vboxvideo_driver, drm_devclass, 0, 0);
|
---|
162 | #endif
|
---|
163 | MODULE_DEPEND(vboxvideo, drm, 1, 1, 1);
|
---|