1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox X11 Additions graphics driver
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | * --------------------------------------------------------------------
|
---|
21 | *
|
---|
22 | * This code is based on:
|
---|
23 | *
|
---|
24 | * X11 VESA driver
|
---|
25 | *
|
---|
26 | * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
---|
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 shall be included in
|
---|
36 | * all copies or substantial portions of the 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 | * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
42 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
---|
43 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
---|
44 | * SOFTWARE.
|
---|
45 | *
|
---|
46 | * Except as contained in this notice, the name of Conectiva Linux shall
|
---|
47 | * not be used in advertising or otherwise to promote the sale, use or other
|
---|
48 | * dealings in this Software without prior written authorization from
|
---|
49 | * Conectiva Linux.
|
---|
50 | *
|
---|
51 | * Authors: Paulo C�ar Pereira de Andrade <[email protected]>
|
---|
52 | *
|
---|
53 | * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h,v 1.9 2001/05/04 19:05:49 dawes Exp $
|
---|
54 | */
|
---|
55 |
|
---|
56 | #ifndef _VBOXVIDEO_H_
|
---|
57 | #define _VBOXVIDEO_H_
|
---|
58 |
|
---|
59 | #ifdef DEBUG_michael
|
---|
60 | # define DEBUG_VIDEO 1
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #ifdef DEBUG_VIDEO
|
---|
64 |
|
---|
65 | #define TRACE_ENTRY() \
|
---|
66 | do { \
|
---|
67 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
68 | xf86Msg(X_INFO, ": entering\n"); \
|
---|
69 | } while(0)
|
---|
70 | #define TRACE_EXIT() \
|
---|
71 | do { \
|
---|
72 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
73 | xf86Msg(X_INFO, ": leaving\n"); \
|
---|
74 | } while(0)
|
---|
75 | #define TRACE_LOG(...) \
|
---|
76 | do { \
|
---|
77 | xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
|
---|
78 | xf86Msg(X_INFO, __VA_ARGS__); \
|
---|
79 | } while(0)
|
---|
80 | # define TRACE_LINE() do \
|
---|
81 | { \
|
---|
82 | ErrorF ("%s: line %d\n", __FUNCTION__, __LINE__); \
|
---|
83 | } while(0)
|
---|
84 |
|
---|
85 | #else /* DEBUG_VIDEO not defined */
|
---|
86 |
|
---|
87 | #define TRACE_ENTRY() do { } while(0)
|
---|
88 | #define TRACE_EXIT() do { } while(0)
|
---|
89 | #define TRACE_LOG(...) do { } while(0)
|
---|
90 |
|
---|
91 | #endif /* DEBUG_VIDEO not defined */
|
---|
92 |
|
---|
93 | #define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
|
---|
94 |
|
---|
95 | #include <VBox/VBoxGuest.h>
|
---|
96 |
|
---|
97 | /* All drivers should typically include these */
|
---|
98 | #include "xf86.h"
|
---|
99 | #include "xf86_OSproc.h"
|
---|
100 | #include "xf86Resources.h"
|
---|
101 |
|
---|
102 | #ifndef NO_ANSIC
|
---|
103 | /* All drivers need this */
|
---|
104 | # include "xf86_ansic.h"
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | #include "compiler.h"
|
---|
108 |
|
---|
109 | #ifndef PCIACCESS
|
---|
110 | /* Drivers for PCI hardware need this */
|
---|
111 | # include "xf86PciInfo.h"
|
---|
112 | /* Drivers that need to access the PCI config space directly need this */
|
---|
113 | # include "xf86Pci.h"
|
---|
114 | #endif
|
---|
115 |
|
---|
116 | #include "vgaHW.h"
|
---|
117 |
|
---|
118 | /* VBE/DDC support */
|
---|
119 | #include "vbe.h"
|
---|
120 |
|
---|
121 | /* ShadowFB support */
|
---|
122 | #include "shadowfb.h"
|
---|
123 |
|
---|
124 | /* VBox video related defines */
|
---|
125 |
|
---|
126 | #define VBE_DISPI_IOPORT_INDEX 0x01CE
|
---|
127 | #define VBE_DISPI_IOPORT_DATA 0x01CF
|
---|
128 | #define VBE_DISPI_INDEX_ID 0x0
|
---|
129 | #define VBE_DISPI_INDEX_XRES 0x1
|
---|
130 | #define VBE_DISPI_INDEX_YRES 0x2
|
---|
131 | #define VBE_DISPI_INDEX_BPP 0x3
|
---|
132 | #define VBE_DISPI_INDEX_ENABLE 0x4
|
---|
133 | #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
---|
134 | #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
---|
135 | #define VBE_DISPI_ID2 0xB0C2
|
---|
136 | #define VBE_DISPI_DISABLED 0x00
|
---|
137 | #define VBE_DISPI_ENABLED 0x01
|
---|
138 | #define VBE_DISPI_LFB_ENABLED 0x40
|
---|
139 |
|
---|
140 | /* Dga definitions */
|
---|
141 | #include "dgaproc.h"
|
---|
142 |
|
---|
143 | #include "xf86RAC.h"
|
---|
144 |
|
---|
145 | #include "fb.h"
|
---|
146 |
|
---|
147 | #define VBOX_VERSION 4000 /* Why? */
|
---|
148 | #include "xf86Cursor.h"
|
---|
149 | #define VBOX_NAME "VBoxVideo"
|
---|
150 | #define VBOX_DRIVER_NAME "vboxvideo"
|
---|
151 |
|
---|
152 | #ifdef VBOX_DRI
|
---|
153 | /* DRI support */
|
---|
154 | #define _XF86DRI_SERVER_
|
---|
155 | /* Hack to work around a libdrm header which is broken on Solaris */
|
---|
156 | #define u_int64_t uint64_t
|
---|
157 | /* Get rid of a warning due to a broken header file */
|
---|
158 | enum drm_bo_type { DRM_BO_TYPE };
|
---|
159 | #include "dri.h"
|
---|
160 | #undef u_int64_t
|
---|
161 | #include "sarea.h"
|
---|
162 | #include "GL/glxint.h"
|
---|
163 | #include "GL/glxtokens.h"
|
---|
164 |
|
---|
165 | /* For some reason this is not in the header files. */
|
---|
166 | extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
|
---|
167 | void **configprivs);
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #define VBOX_VIDEO_MAJOR 1
|
---|
171 | #define VBOX_VIDEO_MINOR 0
|
---|
172 | #define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
|
---|
173 | #define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
|
---|
174 | #define VBOX_MAX_DRAWABLES 256 /* At random. */
|
---|
175 |
|
---|
176 | #define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
|
---|
177 |
|
---|
178 | /*XXX*/
|
---|
179 |
|
---|
180 | typedef struct _VBOXRec
|
---|
181 | {
|
---|
182 | vbeInfoPtr pVbe;
|
---|
183 | EntityInfoPtr pEnt;
|
---|
184 | VbeInfoBlock *vbeInfo;
|
---|
185 | #ifdef PCIACCESS
|
---|
186 | struct pci_device *pciInfo;
|
---|
187 | struct pci_device *vmmDevInfo;
|
---|
188 | #else
|
---|
189 | pciVideoPtr pciInfo;
|
---|
190 | PCITAG pciTag;
|
---|
191 | #endif
|
---|
192 | CARD16 maxBytesPerScanline;
|
---|
193 | unsigned long mapPhys, mapOff;
|
---|
194 | int mapSize; /* video memory */
|
---|
195 | void *base, *VGAbase;
|
---|
196 | CARD8 *state, *pstate; /* SVGA state */
|
---|
197 | int statePage, stateSize, stateMode;
|
---|
198 | CARD32 *savedPal;
|
---|
199 | CARD8 *fonts;
|
---|
200 | /* DGA info */
|
---|
201 | DGAModePtr pDGAMode;
|
---|
202 | int nDGAMode;
|
---|
203 | CloseScreenProcPtr CloseScreen;
|
---|
204 | /** Default X server procedure for enabling and disabling framebuffer access */
|
---|
205 | xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
|
---|
206 | /** Is access to the framebuffer currently allowed? */
|
---|
207 | Bool accessEnabled;
|
---|
208 | OptionInfoPtr Options;
|
---|
209 | IOADDRESS ioBase;
|
---|
210 | VMMDevReqMousePointer *reqp;
|
---|
211 | xf86CursorInfoPtr pCurs;
|
---|
212 | size_t pointerHeaderSize;
|
---|
213 | size_t pointerSize;
|
---|
214 | Bool useDevice;
|
---|
215 | Bool forceSWCursor;
|
---|
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 | #ifdef VBOX_DRI
|
---|
224 | Bool useDRI;
|
---|
225 | int cVisualConfigs;
|
---|
226 | __GLXvisualConfig *pVisualConfigs;
|
---|
227 | DRIInfoRec *pDRIInfo;
|
---|
228 | int drmFD;
|
---|
229 | #endif
|
---|
230 | } VBOXRec, *VBOXPtr;
|
---|
231 |
|
---|
232 | extern Bool vbox_init(int scrnIndex, VBOXPtr pVBox);
|
---|
233 | extern Bool vbox_cursor_init (ScreenPtr pScreen);
|
---|
234 | extern Bool vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
235 | extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
|
---|
236 | extern Bool vbox_device_available(VBOXPtr pVBox);
|
---|
237 |
|
---|
238 | extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
|
---|
239 | extern Bool vboxDisableVbva(ScrnInfoPtr pScrn);
|
---|
240 |
|
---|
241 | extern Bool vboxEnableGraphicsCap(VBOXPtr pVBox);
|
---|
242 | extern Bool vboxDisableGraphicsCap(VBOXPtr pVBox);
|
---|
243 |
|
---|
244 | extern Bool vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *pcx,
|
---|
245 | uint32_t *pcy, uint32_t *pcBits,
|
---|
246 | uint32_t *piDisplay);
|
---|
247 |
|
---|
248 | extern Bool vboxHostLikesVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits);
|
---|
249 | extern Bool vboxSaveVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits);
|
---|
250 | extern Bool vboxRetrieveVideoMode(ScrnInfoPtr pScrn, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits);
|
---|
251 |
|
---|
252 | /* DRI stuff */
|
---|
253 | extern Bool VBOXDRIScreenInit(int scrnIndex, ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
254 | extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
|
---|
255 | extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
|
---|
256 |
|
---|
257 | #endif /* _VBOXVIDEO_H_ */
|
---|
258 |
|
---|