1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox X11 Additions graphics driver
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 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 | * X11 VESA driver
|
---|
21 | *
|
---|
22 | * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
---|
23 | *
|
---|
24 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
25 | * copy of this software and associated documentation files (the "Software"),
|
---|
26 | * to deal in the Software without restriction, including without limitation
|
---|
27 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
28 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
29 | * Software is furnished to do so, subject to the following conditions:
|
---|
30 | *
|
---|
31 | * The above copyright notice and this permission notice shall be included in
|
---|
32 | * all copies or substantial portions of the Software.
|
---|
33 | *
|
---|
34 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
35 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
36 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
37 | * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
38 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
---|
39 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
---|
40 | * SOFTWARE.
|
---|
41 | *
|
---|
42 | * Except as contained in this notice, the name of Conectiva Linux shall
|
---|
43 | * not be used in advertising or otherwise to promote the sale, use or other
|
---|
44 | * dealings in this Software without prior written authorization from
|
---|
45 | * Conectiva Linux.
|
---|
46 | *
|
---|
47 | * Authors: Paulo César Pereira de Andrade <[email protected]>
|
---|
48 | *
|
---|
49 | * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h,v 1.9 2001/05/04 19:05:49 dawes Exp $
|
---|
50 | */
|
---|
51 |
|
---|
52 | #ifndef _VBOXVIDEO_H_
|
---|
53 | #define _VBOXVIDEO_H_
|
---|
54 |
|
---|
55 | #ifdef DEBUG
|
---|
56 |
|
---|
57 | #define TRACE_ENTRY() \
|
---|
58 | do { \
|
---|
59 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
60 | xf86Msg(X_INFO, ": entering\n"); \
|
---|
61 | } while(0)
|
---|
62 | #define TRACE_EXIT() \
|
---|
63 | do { \
|
---|
64 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
65 | xf86Msg(X_INFO, ": leaving\n"); \
|
---|
66 | } while(0)
|
---|
67 | #define TRACE_LOG(...) \
|
---|
68 | do { \
|
---|
69 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
70 | xf86Msg(X_INFO, __VA_ARGS__); \
|
---|
71 | } while(0)
|
---|
72 | # define TRACE_LINE() do \
|
---|
73 | { \
|
---|
74 | ErrorF ("%s: line %d\n", __FUNCTION__, __LINE__); \
|
---|
75 | } while(0)
|
---|
76 | # define XF86ASSERT(expr, out) \
|
---|
77 | if (!(expr)) \
|
---|
78 | { \
|
---|
79 | ErrorF ("\nAssertion failed!\n\n"); \
|
---|
80 | ErrorF ("%s\n", #expr); \
|
---|
81 | ErrorF ("at %s (%s:%d)\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
|
---|
82 | ErrorF out; \
|
---|
83 | FatalError("Aborting"); \
|
---|
84 | }
|
---|
85 | #else /* !DEBUG */
|
---|
86 |
|
---|
87 | #define TRACE_ENTRY() do { } while (0)
|
---|
88 | #define TRACE_EXIT() do { } while (0)
|
---|
89 | #define TRACE_LOG(...) do { } while (0)
|
---|
90 | #define XF86ASSERT(expr, out) do { } while (0)
|
---|
91 |
|
---|
92 | #endif /* !DEBUG */
|
---|
93 |
|
---|
94 | #define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
|
---|
95 |
|
---|
96 | #include <VBox/VMMDev.h>
|
---|
97 |
|
---|
98 | /* All drivers should typically include these */
|
---|
99 | #include "xf86.h"
|
---|
100 | #include "xf86_OSproc.h"
|
---|
101 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
|
---|
102 | # include "xf86Resources.h"
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | #ifndef NO_ANSIC
|
---|
106 | /* All drivers need this */
|
---|
107 | # include "xf86_ansic.h"
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | #include "compiler.h"
|
---|
111 |
|
---|
112 | #ifndef PCIACCESS
|
---|
113 | /* Drivers for PCI hardware need this */
|
---|
114 | # include "xf86PciInfo.h"
|
---|
115 | /* Drivers that need to access the PCI config space directly need this */
|
---|
116 | # include "xf86Pci.h"
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | #include "vgaHW.h"
|
---|
120 |
|
---|
121 | /* VBE/DDC support */
|
---|
122 | #include "vbe.h"
|
---|
123 |
|
---|
124 | /* ShadowFB support */
|
---|
125 | #include "shadowfb.h"
|
---|
126 |
|
---|
127 | /* VBox video related defines */
|
---|
128 |
|
---|
129 | #define VBE_DISPI_IOPORT_INDEX 0x01CE
|
---|
130 | #define VBE_DISPI_IOPORT_DATA 0x01CF
|
---|
131 | #define VBE_DISPI_INDEX_ID 0x0
|
---|
132 | #define VBE_DISPI_INDEX_XRES 0x1
|
---|
133 | #define VBE_DISPI_INDEX_YRES 0x2
|
---|
134 | #define VBE_DISPI_INDEX_BPP 0x3
|
---|
135 | #define VBE_DISPI_INDEX_ENABLE 0x4
|
---|
136 | #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
---|
137 | #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
---|
138 | #define VBE_DISPI_ID2 0xB0C2
|
---|
139 | #define VBE_DISPI_ID_ANYX 0xBE02
|
---|
140 | #define VBE_DISPI_DISABLED 0x00
|
---|
141 | #define VBE_DISPI_ENABLED 0x01
|
---|
142 | #define VBE_DISPI_LFB_ENABLED 0x40
|
---|
143 |
|
---|
144 | /* Dga definitions */
|
---|
145 | #include "dgaproc.h"
|
---|
146 |
|
---|
147 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
|
---|
148 | # include "xf86RAC.h"
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | #include "fb.h"
|
---|
152 |
|
---|
153 | #define VBOX_VERSION 4000 /* Why? */
|
---|
154 | #include "xf86Cursor.h"
|
---|
155 | #define VBOX_NAME "VBoxVideo"
|
---|
156 | #define VBOX_DRIVER_NAME "vboxvideo"
|
---|
157 |
|
---|
158 | #ifdef VBOX_DRI
|
---|
159 | /* DRI support */
|
---|
160 | #define _XF86DRI_SERVER_
|
---|
161 | /* Hack to work around a libdrm header which is broken on Solaris */
|
---|
162 | #define u_int64_t uint64_t
|
---|
163 | /* Get rid of a warning due to a broken header file */
|
---|
164 | enum drm_bo_type { DRM_BO_TYPE };
|
---|
165 | #include "dri.h"
|
---|
166 | #undef u_int64_t
|
---|
167 | #include "sarea.h"
|
---|
168 | #include "GL/glxint.h"
|
---|
169 | #include "GL/glxtokens.h"
|
---|
170 |
|
---|
171 | /* For some reason this is not in the header files. */
|
---|
172 | extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
|
---|
173 | void **configprivs);
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | #define VBOX_VIDEO_MAJOR 1
|
---|
177 | #define VBOX_VIDEO_MINOR 0
|
---|
178 | #define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
|
---|
179 | #define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
|
---|
180 | #define VBOX_MAX_DRAWABLES 256 /* At random. */
|
---|
181 |
|
---|
182 | #define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
|
---|
183 |
|
---|
184 | /*XXX*/
|
---|
185 |
|
---|
186 | typedef struct _VBOXRec
|
---|
187 | {
|
---|
188 | vbeInfoPtr pVbe; /** @todo do the VBE bits ourselves? */
|
---|
189 | EntityInfoPtr pEnt;
|
---|
190 | #ifdef PCIACCESS
|
---|
191 | struct pci_device *pciInfo;
|
---|
192 | struct pci_device *vmmDevInfo;
|
---|
193 | #else
|
---|
194 | pciVideoPtr pciInfo;
|
---|
195 | PCITAG pciTag;
|
---|
196 | #endif
|
---|
197 | unsigned long mapSize; /* video memory */
|
---|
198 | void *base;
|
---|
199 | CARD8 *state, *pstate; /* SVGA state */
|
---|
200 | int statePage, stateSize, stateMode;
|
---|
201 | CARD32 *savedPal;
|
---|
202 | CARD8 *fonts;
|
---|
203 | vgaRegRec vgaRegs; /* Space for saving VGA information */
|
---|
204 | CloseScreenProcPtr CloseScreen;
|
---|
205 | /** Default X server procedure for enabling and disabling framebuffer access */
|
---|
206 | xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
|
---|
207 | /** Is access to the framebuffer currently allowed? */
|
---|
208 | Bool accessEnabled;
|
---|
209 | OptionInfoPtr Options;
|
---|
210 | /** @todo we never actually free this */
|
---|
211 | xf86CursorInfoPtr pCurs;
|
---|
212 | Bool useDevice;
|
---|
213 | Bool forceSWCursor;
|
---|
214 | /** Do we know that the guest can handle absolute co-ordinates? */
|
---|
215 | Bool guestCanAbsolute;
|
---|
216 | /** Are we currently switched to a virtual terminal? If so, it is not
|
---|
217 | * safe to touch the hardware. */
|
---|
218 | Bool vtSwitch;
|
---|
219 | Bool useVbva;
|
---|
220 | int viewportX, viewportY;
|
---|
221 | VMMDevMemory *pVMMDevMemory;
|
---|
222 | VBVAMEMORY *pVbvaMemory;
|
---|
223 | Bool fAnyX; /* Unrestricted horizontal resolution flag. */
|
---|
224 | #ifdef VBOX_DRI
|
---|
225 | Bool useDRI;
|
---|
226 | int cVisualConfigs;
|
---|
227 | __GLXvisualConfig *pVisualConfigs;
|
---|
228 | DRIInfoRec *pDRIInfo;
|
---|
229 | int drmFD;
|
---|
230 | #endif
|
---|
231 | } VBOXRec, *VBOXPtr;
|
---|
232 |
|
---|
233 | extern Bool vbox_init(int scrnIndex, VBOXPtr pVBox);
|
---|
234 | extern Bool vbox_cursor_init (ScreenPtr pScreen);
|
---|
235 | extern Bool vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
236 | extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
|
---|
237 | extern Bool vbox_device_available(VBOXPtr pVBox);
|
---|
238 |
|
---|
239 | extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
|
---|
240 | extern Bool vboxDisableVbva(ScrnInfoPtr pScrn);
|
---|
241 |
|
---|
242 | extern Bool vboxEnableGraphicsCap(VBOXPtr pVBox);
|
---|
243 | extern Bool vboxDisableGraphicsCap(VBOXPtr pVBox);
|
---|
244 | extern Bool vboxGuestIsSeamless(ScrnInfoPtr pScrn);
|
---|
245 |
|
---|
246 | extern Bool vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *pcx,
|
---|
247 | uint32_t *pcy, uint32_t *pcBits,
|
---|
248 | uint32_t *piDisplay);
|
---|
249 | extern Bool vboxHostLikesVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits);
|
---|
250 | extern Bool vboxSaveVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits);
|
---|
251 | extern Bool vboxRetrieveVideoMode(ScrnInfoPtr pScrn, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits);
|
---|
252 | extern void vboxGetPreferredMode(ScrnInfoPtr pScrn, uint32_t *pcx,
|
---|
253 | uint32_t *pcy, uint32_t *pcBits);
|
---|
254 | extern void vboxWriteHostModes(ScrnInfoPtr pScrn, DisplayModePtr pCurrent);
|
---|
255 | extern void vboxAddModes(ScrnInfoPtr pScrn, uint32_t cxInit,
|
---|
256 | uint32_t cyInit);
|
---|
257 |
|
---|
258 | /* DRI stuff */
|
---|
259 | extern Bool VBOXDRIScreenInit(int scrnIndex, ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
260 | extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
|
---|
261 | extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
|
---|
262 | extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
263 |
|
---|
264 | #endif /* _VBOXVIDEO_H_ */
|
---|
265 |
|
---|