VirtualBox

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

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

Additions/x11: temporary check-in of new X11 Additions resizing code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 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#ifndef VBVA_SCREEN_F_BLANK
59# define VBVA_SCREEN_F_BLANK 0x0004
60#endif
61
62#ifdef DEBUG
63
64#define TRACE_ENTRY() \
65do { \
66 vbvxMsg(__PRETTY_FUNCTION__); \
67 vbvxMsg(": entering\n"); \
68} while(0)
69#define TRACE_EXIT() \
70do { \
71 vbvxMsg(__PRETTY_FUNCTION__); \
72 vbvxMsg(": leaving\n"); \
73} while(0)
74#define TRACE_LOG(...) \
75do { \
76 vbvxMsg("%s: ", __PRETTY_FUNCTION__); \
77 vbvxMsg(__VA_ARGS__); \
78} while(0)
79# define TRACE_LINE() do \
80{ \
81 vbvxMsg("%s: line %d\n", __FUNCTION__, __LINE__); \
82} while(0)
83#else /* !DEBUG */
84
85#define TRACE_ENTRY() do { } while (0)
86#define TRACE_EXIT() do { } while (0)
87#define TRACE_LOG(...) do { } while (0)
88
89#endif /* !DEBUG */
90
91/* Not just for debug builds. If something is wrong we want to know at once. */
92#define VBVXASSERT(expr, out) \
93if (!(expr)) \
94{ \
95 vbvxMsg("\nAssertion failed!\n\n"); \
96 vbvxMsg("%s\n", #expr); \
97 vbvxMsg("at %s (%s:%d)\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
98 vbvxMsg out; \
99 vbvxAbortServer(); \
100}
101
102#define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
103
104#include <VBox/Hardware/VBoxVideoVBE.h>
105
106#include "xf86str.h"
107#include "xf86Cursor.h"
108
109#define VBOX_VERSION 4000 /* Why? */
110#define VBOX_NAME "VBoxVideo"
111#define VBOX_DRIVER_NAME "vboxvideo"
112
113#ifdef VBOX_DRI_OLD
114/* DRI support */
115#define _XF86DRI_SERVER_
116/* Hack to work around a libdrm header which is broken on Solaris */
117#define u_int64_t uint64_t
118/* Get rid of a warning due to a broken header file */
119enum drm_bo_type { DRM_BO_TYPE };
120#include "dri.h"
121#undef u_int64_t
122#include "sarea.h"
123#include "GL/glxint.h"
124
125/* For some reason this is not in the header files. */
126extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
127 void **configprivs);
128#endif
129
130#define VBOX_VIDEO_MAJOR 1
131#define VBOX_VIDEO_MINOR 0
132#define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
133#define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
134#define VBOX_MAX_DRAWABLES 256 /* At random. */
135
136#define VBOX_VIDEO_MIN_SIZE 64
137#define VBOX_VIDEO_MAX_VIRTUAL (INT16_MAX - 1)
138
139#define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
140
141/** Helper to work round different ways of getting the root window in different
142 * server versions. */
143#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
144 && XORG_VERSION_CURRENT >= 10900000
145# define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
146#else
147# define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
148#endif
149
150/** Structure containing all virtual monitor-specific information. */
151struct VBoxScreen
152{
153 /** Position information for each virtual screen for the purposes of
154 * sending dirty rectangle information to the right one. */
155 RTRECT2 aScreenLocation;
156 /** Is this CRTC enabled or in DPMS off state? */
157 Bool fPowerOn;
158#ifdef VBOXVIDEO_13
159 /** The virtual crtcs. */
160 struct _xf86Crtc *paCrtcs;
161 /** The virtual outputs, logically not distinct from crtcs. */
162 struct _xf86Output *paOutputs;
163#endif
164 /** Offsets of VBVA buffers in video RAM */
165 uint32_t aoffVBVABuffer;
166 /** Context information about the VBVA buffers for each screen */
167 struct VBVABUFFERCONTEXT aVbvaCtx;
168 /** The current preferred resolution for the screen */
169 RTRECTSIZE aPreferredSize;
170 /** The current preferred location for the screen. */
171 RTPOINT aPreferredLocation;
172 /** Has this screen been enabled by the host? */
173 Bool afConnected;
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 /** Whether the pre-X-server mode was a VBE mode */
193 bool fSavedVBEMode;
194 /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
195 */
196 uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
197 CloseScreenProcPtr CloseScreen;
198 /** Default X server procedure for enabling and disabling framebuffer access */
199 xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
200 OptionInfoPtr Options;
201 /** @todo we never actually free this */
202 xf86CursorInfoPtr pCurs;
203 /** Do we currently want to use the host cursor? */
204 Bool fUseHardwareCursor;
205 /** Number of screens attached */
206 uint32_t cScreens;
207 /** Information about each virtual screen. */
208 struct VBoxScreen *pScreens;
209 /** Can we get mode hint and cursor integration information from HGSMI? */
210 bool fHaveHGSMIModeHints;
211 /** Does the host support the screen blanking flag? */
212 bool fHostHasScreenBlankingFlag;
213 /** Array of structures for receiving mode hints. */
214 VBVAMODEHINT *paVBVAModeHints;
215#ifdef VBOXVIDEO_13
216# ifdef RT_OS_LINUX
217 /** Input device file descriptor for getting ACPI hot-plug events. */
218 int fdACPIDevices;
219 /** Input handler handle for ACPI hot-plug listener. */
220 void *hACPIEventHandler;
221# endif
222#endif
223 /** HGSMI guest heap context */
224 HGSMIGUESTCOMMANDCONTEXT guestCtx;
225 /** Unrestricted horizontal resolution flag. */
226 Bool fAnyX;
227#ifdef VBOX_DRI
228 Bool useDRI;
229#ifdef VBOX_DRI_OLD
230 int cVisualConfigs;
231 __GLXvisualConfig *pVisualConfigs;
232 DRIInfoRec *pDRIInfo;
233# endif
234 int drmFD;
235#endif
236} VBOXRec, *VBOXPtr;
237
238/* helpers.c */
239extern void vbvxMsg(const char *pszFormat, ...);
240extern void vbvxMsgV(const char *pszFormat, va_list args);
241extern void vbvxAbortServer(void);
242extern VBOXPtr vbvxGetRec(ScrnInfoPtr pScrn);
243#define VBOXGetRec vbvxGetRec /* Temporary */
244extern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
245extern void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent);
246extern void vbvxReprobeCursor(ScrnInfoPtr pScrn);
247
248/* setmode.c */
249
250/** Structure describing the virtual frame buffer. It starts at the beginning
251 * of the video RAM. */
252struct vbvxFrameBuffer {
253 /** X offset of first screen in frame buffer. */
254 int x0;
255 /** Y offset of first screen in frame buffer. */
256 int y0;
257 /** Frame buffer virtual width. */
258 unsigned cWidth;
259 /** Frame buffer virtual height. */
260 unsigned cHeight;
261 /** Bits per pixel. */
262 unsigned cBPP;
263};
264
265extern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
266extern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, bool fEnabled,
267 bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
268extern void vbvxSetSolarisMouseRange(int width, int height);
269
270/* pointer.c */
271extern Bool vbox_cursor_init (ScreenPtr pScreen);
272extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
273
274/* vbva.c */
275extern void vbvxHandleDirtyRect(ScrnInfoPtr pScrn, int iRects, BoxPtr aRects);
276extern void vbvxSetUpHGSMIHeapInGuest(VBOXPtr pVBox, uint32_t cbVRAM);
277extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
278extern void vboxDisableVbva(ScrnInfoPtr pScrn);
279
280/* getmode.c */
281extern void vboxAddModes(ScrnInfoPtr pScrn);
282extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
283extern void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, bool *pfNeedUpdate);
284extern void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, bool *pfNeedUpdate);
285extern void vbvxSetUpLinuxACPI(ScreenPtr pScreen);
286extern void vbvxCleanUpLinuxACPI(ScreenPtr pScreen);
287
288/* DRI stuff */
289extern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
290 VBOXPtr pVBox);
291extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
292extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
293extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
294
295/* EDID generation */
296#ifdef VBOXVIDEO_13
297extern Bool VBOXEDIDSet(struct _xf86Output *output, DisplayModePtr pmode);
298#endif
299
300#endif /* _VBOXVIDEO_H_ */
301
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