VirtualBox

source: vbox/trunk/src/VBox/Additions/freebsd/drm/vboxvideo_drm.c@ 28516

Last change on this file since 28516 was 27901, checked in by vboxsync, 15 years ago

OSE header fixes

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