VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h@ 55262

Last change on this file since 55262 was 55262, checked in by vboxsync, 10 years ago

Additions/x11/vboxvideo: reverted temporary commit r99563.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1/** @file
2 *
3 * VirtualBox X11 Additions graphics driver
4 */
5
6/*
7 * Copyright (C) 2006-2013 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#include <VBox/VBoxVideoGuest.h>
56#include <VBox/VBoxVideo.h>
57
58#ifdef DEBUG
59
60#define TRACE_ENTRY() \
61do { \
62 vbvxMsg(__PRETTY_FUNCTION__); \
63 vbvxMsg(": entering\n"); \
64} while(0)
65#define TRACE_EXIT() \
66do { \
67 vbvxMsg(__PRETTY_FUNCTION__); \
68 vbvxMsg(": leaving\n"); \
69} while(0)
70#define TRACE_LOG(...) \
71do { \
72 vbvxMsg("%s: ", __PRETTY_FUNCTION__); \
73 vbvxMsg(__VA_ARGS__); \
74} while(0)
75# define TRACE_LINE() do \
76{ \
77 vbvxMsg("%s: line %d\n", __FUNCTION__, __LINE__); \
78} while(0)
79#else /* !DEBUG */
80
81#define TRACE_ENTRY() do { } while (0)
82#define TRACE_EXIT() do { } while (0)
83#define TRACE_LOG(...) do { } while (0)
84
85#endif /* !DEBUG */
86
87/* Not just for debug builds. If something is wrong we want to know at once. */
88#define VBVXASSERT(expr, out) \
89if (!(expr)) \
90{ \
91 vbvxMsg("\nAssertion failed!\n\n"); \
92 vbvxMsg("%s\n", #expr); \
93 vbvxMsg("at %s (%s:%d)\n", RT_GCC_EXTENSION __PRETTY_FUNCTION__, __FILE__, __LINE__); \
94 vbvxMsg out; \
95 vbvxAbortServer(); \
96}
97
98#define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
99
100#include <VBox/Hardware/VBoxVideoVBE.h>
101
102#include "xf86str.h"
103#include "xf86Cursor.h"
104
105#define VBOX_VERSION 4000 /* Why? */
106#define VBOX_NAME "VBoxVideo"
107#define VBOX_DRIVER_NAME "vboxvideo"
108
109#ifdef VBOX_DRI_OLD
110/* DRI support */
111#define _XF86DRI_SERVER_
112/* Hack to work around a libdrm header which is broken on Solaris */
113#define u_int64_t uint64_t
114/* Get rid of a warning due to a broken header file */
115enum drm_bo_type { DRM_BO_TYPE };
116#include "dri.h"
117#undef u_int64_t
118#include "sarea.h"
119#include "GL/glxint.h"
120
121/* For some reason this is not in the header files. */
122extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
123 void **configprivs);
124#endif
125
126#define VBOX_VIDEO_MAJOR 1
127#define VBOX_VIDEO_MINOR 0
128#define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
129#define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
130#define VBOX_MAX_DRAWABLES 256 /* At random. */
131
132#define VBOX_VIDEO_MIN_SIZE 64
133#define VBOX_VIDEO_MAX_VIRTUAL (INT16_MAX - 1)
134
135#define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
136
137/** Helper to work round different ways of getting the root window in different
138 * server versions. */
139#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
140 && XORG_VERSION_CURRENT >= 10900000
141# define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
142#else
143# define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
144#endif
145
146/** Structure containing all virtual monitor-specific information. */
147struct VBoxScreen
148{
149 /** Position information for each virtual screen for the purposes of
150 * sending dirty rectangle information to the right one. */
151 RTRECT2 aScreenLocation;
152 /** Is this CRTC enabled or in DPMS off state? */
153 Bool fCrtcEnabled;
154 /** Is this output enabled or in DPMS low power state? */
155 Bool fOutputEnabled;
156#ifdef VBOXVIDEO_13
157 /** The virtual crtcs. */
158 struct _xf86Crtc *paCrtcs;
159 /** The virtual outputs, logically not distinct from crtcs. */
160 struct _xf86Output *paOutputs;
161#endif
162 /** Offsets of VBVA buffers in video RAM */
163 uint32_t aoffVBVABuffer;
164 /** Context information about the VBVA buffers for each screen */
165 struct VBVABUFFERCONTEXT aVbvaCtx;
166 /** The current preferred resolution for the screen */
167 RTRECTSIZE aPreferredSize;
168 /** The current preferred location for the screen. */
169 RTPOINT aPreferredLocation;
170 /** Has this screen been enabled by the host? */
171 Bool afConnected;
172 /** The last mode hint data read from the X11 property. */
173 int32_t lastModeHintFromProperty;
174 /** Does this screen have a preferred location? */
175 Bool afHaveLocation;
176};
177
178typedef struct VBOXRec
179{
180 EntityInfoPtr pEnt;
181#ifdef PCIACCESS
182 struct pci_device *pciInfo;
183#else
184 pciVideoPtr pciInfo;
185 PCITAG pciTag;
186#endif
187 void *base;
188 /** The amount of VRAM available for use as a framebuffer */
189 unsigned long cbFBMax;
190 /** The size of the framebuffer and the VBVA buffers at the end of it. */
191 unsigned long cbView;
192 /** The current line size in bytes */
193 uint32_t cbLine;
194 /** Whether the pre-X-server mode was a VBE mode */
195 bool fSavedVBEMode;
196 /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
197 */
198 uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
199 CloseScreenProcPtr CloseScreen;
200 /** Default X server procedure for enabling and disabling framebuffer access */
201 xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
202 OptionInfoPtr Options;
203 /** @todo we never actually free this */
204 xf86CursorInfoPtr pCurs;
205 /** Do we currently want to use the host cursor? */
206 Bool fUseHardwareCursor;
207 /** The last cursor capabilities data read from the X11 property. */
208 int32_t fLastCursorCapabilitiesFromProperty;
209 /** Number of screens attached */
210 uint32_t cScreens;
211 /** Information about each virtual screen. */
212 struct VBoxScreen *pScreens;
213 /** The last requested framebuffer size. */
214 RTRECTSIZE FBSize;
215 /** Can we get mode hint and cursor integration information from HGSMI? */
216 bool fHaveHGSMIModeHints;
217 /** Does the host support the screen blanking flag? */
218 bool fHostHasScreenBlankingFlag;
219 /** Array of structures for receiving mode hints. */
220 VBVAMODEHINT *paVBVAModeHints;
221#ifdef VBOXVIDEO_13
222# ifdef RT_OS_LINUX
223 /** Input device file descriptor for getting ACPI hot-plug events. */
224 int fdACPIDevices;
225 /** Input handler handle for ACPI hot-plug listener. */
226 void *hACPIEventHandler;
227# endif
228 /** Have we read all available HGSMI mode hint data? */
229 bool fHaveReadHGSMIModeHintData;
230#else
231 /** The original CreateScreenResources procedure which we wrap with our own.
232 */
233 CreateScreenResourcesProcPtr pfnCreateScreenResources;
234#endif
235 /** HGSMI guest heap context */
236 HGSMIGUESTCOMMANDCONTEXT guestCtx;
237 /** Unrestricted horizontal resolution flag. */
238 Bool fAnyX;
239#ifdef VBOX_DRI
240 Bool useDRI;
241#ifdef VBOX_DRI_OLD
242 int cVisualConfigs;
243 __GLXvisualConfig *pVisualConfigs;
244 DRIInfoRec *pDRIInfo;
245# endif
246 int drmFD;
247#endif
248} VBOXRec, *VBOXPtr;
249
250/* helpers.c */
251extern void vbvxMsg(const char *pszFormat, ...);
252extern void vbvxMsgV(const char *pszFormat, va_list args);
253extern void vbvxAbortServer(void);
254extern VBOXPtr vbvxGetRec(ScrnInfoPtr pScrn);
255#define VBOXGetRec vbvxGetRec /* Temporary */
256extern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
257extern void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent);
258extern void vbvxReprobeCursor(ScrnInfoPtr pScrn);
259
260/* setmode.c */
261
262/** Structure describing the virtual frame buffer. It starts at the beginning
263 * of the video RAM. */
264struct vbvxFrameBuffer {
265 /** X offset of first screen in frame buffer. */
266 int x0;
267 /** Y offset of first screen in frame buffer. */
268 int y0;
269 /** Frame buffer virtual width. */
270 unsigned cWidth;
271 /** Frame buffer virtual height. */
272 unsigned cHeight;
273 /** Bits per pixel. */
274 unsigned cBPP;
275};
276
277extern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, bool fEnabled,
278 bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
279extern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
280extern void vbvxSetSolarisMouseRange(int width, int height);
281
282extern Bool vbox_cursor_init (ScreenPtr pScreen);
283extern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
284extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
285
286extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
287extern void vboxDisableVbva(ScrnInfoPtr pScrn);
288
289/* getmode.c */
290extern void vboxAddModes(ScrnInfoPtr pScrn);
291extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
292extern void VBoxUpdateSizeHints(ScrnInfoPtr pScrn);
293#ifndef VBOXVIDEO_13
294extern void VBoxSetUpRandR11(ScreenPtr pScreen);
295#else
296void VBoxSetUpLinuxACPI(ScreenPtr pScreen);
297void VBoxCleanUpLinuxACPI(ScreenPtr pScreen);
298#endif
299
300/* DRI stuff */
301extern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
302 VBOXPtr pVBox);
303extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
304extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
305extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
306
307/* Utilities */
308
309/** Calculate the BPP from the screen depth */
310static inline uint16_t vboxBPP(ScrnInfoPtr pScrn)
311{
312 return pScrn->depth == 24 ? 32 : 16;
313}
314
315/** Calculate the scan line length for a display width */
316static inline int32_t vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
317{
318 uint32_t cbLine = (cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
319 return cbLine < INT32_MAX ? cbLine : INT32_MAX;
320}
321
322/** Calculate the display pitch from the scan line length */
323static inline int32_t vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
324{
325 return cbLine * 8 / vboxBPP(pScrn);
326}
327
328extern void vboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY);
329extern Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
330 unsigned cHeight, int x, int y);
331extern Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
332
333#endif /* _VBOXVIDEO_H_ */
334
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