VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use