VirtualBox

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

Last change on this file since 69496 was 69496, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: vboxvideo_drm.c 69496 2017-10-28 14:55:58Z vboxsync $ */
2/** @file
3 * VirtualBox Guest Additions - vboxvideo DRM module.
4 * FreeBSD kernel OpenGL module.
5 */
6
7/*
8 * Copyright (C) 2006-2017 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 * 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
53#include <sys/cdefs.h>
54__FBSDID("$FreeBSD$");
55
56#include "dev/drm/drmP.h"
57#include "dev/drm/drm_pciids.h"
58
59#define DRIVER_AUTHOR "Oracle Corporation"
60#define DRIVER_NAME "vboxvideo"
61#define DRIVER_DESC "VirtualBox DRM"
62#define DRIVER_DATE "20090317"
63#define DRIVER_MAJOR 1
64#define DRIVER_MINOR 0
65#define DRIVER_PATCHLEVEL 0
66
67/** @todo Take PCI IDs from VBox/param.h; VBOX_VESA_VENDORID,
68 * VBOX_VESA_DEVICEID. */
69#define vboxvideo_PCI_IDS { 0x80ee, 0xbeef, 0, "VirtualBox Video" }, \
70 { 0, 0, 0, NULL }
71
72static drm_pci_id_list_t vboxvideo_pciidlist[] = {
73 vboxvideo_PCI_IDS
74};
75
76static void vboxvideo_configure(struct drm_device *dev)
77{
78#if __FreeBSD_version >= 702000
79 dev->driver->buf_priv_size = 1; /* No dev_priv */
80
81 dev->driver->max_ioctl = 0;
82
83 dev->driver->name = DRIVER_NAME;
84 dev->driver->desc = DRIVER_DESC;
85 dev->driver->date = DRIVER_DATE;
86 dev->driver->major = DRIVER_MAJOR;
87 dev->driver->minor = DRIVER_MINOR;
88 dev->driver->patchlevel = DRIVER_PATCHLEVEL;
89#else
90 dev->driver.buf_priv_size = 1; /* No dev_priv */
91
92 dev->driver.max_ioctl = 0;
93
94 dev->driver.name = DRIVER_NAME;
95 dev->driver.desc = DRIVER_DESC;
96 dev->driver.date = DRIVER_DATE;
97 dev->driver.major = DRIVER_MAJOR;
98 dev->driver.minor = DRIVER_MINOR;
99 dev->driver.patchlevel = DRIVER_PATCHLEVEL;
100#endif
101}
102
103static int
104vboxvideo_probe(device_t kdev)
105{
106 return drm_probe(kdev, vboxvideo_pciidlist);
107}
108
109static int
110vboxvideo_attach(device_t kdev)
111{
112 struct drm_device *dev = device_get_softc(kdev);
113
114#if __FreeBSD_version >= 702000
115 dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
116 M_WAITOK | M_ZERO);
117#else
118 bzero(&dev->driver, sizeof(struct drm_driver_info));
119#endif
120
121 vboxvideo_configure(dev);
122
123 return drm_attach(kdev, vboxvideo_pciidlist);
124}
125
126static int
127vboxvideo_detach(device_t kdev)
128{
129 struct drm_device *dev = device_get_softc(kdev);
130 int ret;
131
132 ret = drm_detach(kdev);
133
134#if __FreeBSD_version >= 702000
135 free(dev->driver, DRM_MEM_DRIVER);
136#endif
137
138 return ret;
139}
140
141static device_method_t vboxvideo_methods[] = {
142 /* Device interface */
143 DEVMETHOD(device_probe, vboxvideo_probe),
144 DEVMETHOD(device_attach, vboxvideo_attach),
145 DEVMETHOD(device_detach, vboxvideo_detach),
146
147 { 0, 0 }
148};
149
150static driver_t vboxvideo_driver = {
151 "drm",
152 vboxvideo_methods,
153 sizeof(struct drm_device)
154};
155
156extern devclass_t drm_devclass;
157#if __FreeBSD_version >= 700010
158DRIVER_MODULE(vboxvideo, vgapci, vboxvideo_driver, drm_devclass, 0, 0);
159#else
160DRIVER_MODULE(vboxvideo, pci, vboxvideo_driver, drm_devclass, 0, 0);
161#endif
162MODULE_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