VirtualBox

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

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

Additions/x11/vboxvideo: new functions for getting mode hint information from HGSMI and from VBoxClient via X11 properties.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.7 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 VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
133
134/** Helper to work round different ways of getting the root window in different
135 * server versions. */
136#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
137 && XORG_VERSION_CURRENT >= 10900000
138# define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
139#else
140# define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
141#endif
142
143/** Structure containing all virtual monitor-specific information. */
144struct VBoxScreen
145{
146 /** Position information for each virtual screen for the purposes of
147 * sending dirty rectangle information to the right one. */
148 RTRECT2 aScreenLocation;
149 /** Is this CRTC enabled or in DPMS off state? */
150 Bool fCrtcEnabled;
151 /** Is this output enabled or in DPMS low power state? */
152 Bool fOutputEnabled;
153#ifdef VBOXVIDEO_13
154 /** The virtual crtcs. */
155 struct _xf86Crtc *paCrtcs;
156 /** The virtual outputs, logically not distinct from crtcs. */
157 struct _xf86Output *paOutputs;
158#endif
159 /** Offsets of VBVA buffers in video RAM */
160 uint32_t aoffVBVABuffer;
161 /** Context information about the VBVA buffers for each screen */
162 struct VBVABUFFERCONTEXT aVbvaCtx;
163 /** The current preferred resolution for the screen */
164 RTRECTSIZE aPreferredSize;
165 /** The current preferred location for the screen. */
166 RTPOINT aPreferredLocation;
167 /** Has this screen been enabled by the host? */
168 Bool afConnected;
169 /** The last mode hint data read from the X11 property. */
170 int32_t lastModeHintFromProperty;
171 /** Does this screen have a preferred location? */
172 Bool afHaveLocation;
173};
174
175typedef struct VBOXRec
176{
177 EntityInfoPtr pEnt;
178#ifdef PCIACCESS
179 struct pci_device *pciInfo;
180#else
181 pciVideoPtr pciInfo;
182 PCITAG pciTag;
183#endif
184 void *base;
185 /** The amount of VRAM available for use as a framebuffer */
186 unsigned long cbFBMax;
187 /** The size of the framebuffer and the VBVA buffers at the end of it. */
188 unsigned long cbView;
189 /** The current line size in bytes */
190 uint32_t cbLine;
191 /** Whether the pre-X-server mode was a VBE mode */
192 bool fSavedVBEMode;
193 /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
194 */
195 uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
196 CloseScreenProcPtr CloseScreen;
197 /** Default X server procedure for enabling and disabling framebuffer access */
198 xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
199 OptionInfoPtr Options;
200 /** @todo we never actually free this */
201 xf86CursorInfoPtr pCurs;
202 /** Do we currently want to use the host cursor? */
203 Bool fUseHardwareCursor;
204 /** The last cursor capabilities data read from the X11 property. */
205 int32_t fLastCursorCapabilitiesFromProperty;
206 /** Number of screens attached */
207 uint32_t cScreens;
208 /** Information about each virtual screen. */
209 struct VBoxScreen *pScreens;
210 /** The last requested framebuffer size. */
211 RTRECTSIZE FBSize;
212 /** Can we get mode hint and cursor integration information from HGSMI? */
213 bool fHaveHGSMIModeHints;
214 /** Array of structures for receiving mode hints. */
215 VBVAMODEHINT *paVBVAModeHints;
216#ifdef VBOXVIDEO_13
217# ifdef RT_OS_LINUX
218 /** Input device file descriptor for getting ACPI hot-plug events. */
219 int fdACPIDevices;
220 /** Input handler handle for ACPI hot-plug listener. */
221 void *hACPIEventHandler;
222# endif
223 /** Have we read all available HGSMI mode hint data? */
224 bool fHaveReadHGSMIModeHintData;
225#else
226 /** The original CreateScreenResources procedure which we wrap with our own.
227 */
228 CreateScreenResourcesProcPtr pfnCreateScreenResources;
229#endif
230 /** HGSMI guest heap context */
231 HGSMIGUESTCOMMANDCONTEXT guestCtx;
232 /** Unrestricted horizontal resolution flag. */
233 Bool fAnyX;
234#ifdef VBOX_DRI
235 Bool useDRI;
236#ifdef VBOX_DRI_OLD
237 int cVisualConfigs;
238 __GLXvisualConfig *pVisualConfigs;
239 DRIInfoRec *pDRIInfo;
240# endif
241 int drmFD;
242#endif
243} VBOXRec, *VBOXPtr;
244
245/* helpers.c */
246extern void vbvxMsg(const char *pszFormat, ...);
247extern void vbvxMsgV(const char *pszFormat, va_list args);
248extern void vbvxAbortServer(void);
249extern VBOXPtr vbvxGetRec(ScrnInfoPtr pScrn);
250#define VBOXGetRec vbvxGetRec /* Temporary */
251extern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
252extern void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent);
253extern void vbvxReprobeCursor(ScrnInfoPtr pScrn);
254
255/* setmode.c */
256extern void vbvxSetSolarisMouseRange(int width, int height);
257
258extern Bool vbox_cursor_init (ScreenPtr pScreen);
259extern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
260extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
261
262extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
263extern void vboxDisableVbva(ScrnInfoPtr pScrn);
264
265/* getmode.c */
266extern void vboxAddModes(ScrnInfoPtr pScrn);
267extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
268extern void VBoxUpdateSizeHints(ScrnInfoPtr pScrn);
269#ifndef VBOXVIDEO_13
270extern void VBoxSetUpRandR11(ScreenPtr pScreen);
271#else
272void VBoxSetUpLinuxACPI(ScreenPtr pScreen);
273void VBoxCleanUpLinuxACPI(ScreenPtr pScreen);
274#endif
275
276/* DRI stuff */
277extern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
278 VBOXPtr pVBox);
279extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
280extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
281extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
282
283/* Utilities */
284
285/** Calculate the BPP from the screen depth */
286static inline uint16_t vboxBPP(ScrnInfoPtr pScrn)
287{
288 return pScrn->depth == 24 ? 32 : 16;
289}
290
291/** Calculate the scan line length for a display width */
292static inline int32_t vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
293{
294 uint32_t cbLine = (cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
295 return cbLine < INT32_MAX ? cbLine : INT32_MAX;
296}
297
298/** Calculate the display pitch from the scan line length */
299static inline int32_t vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
300{
301 return cbLine * 8 / vboxBPP(pScrn);
302}
303
304extern void vboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY);
305extern Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
306 unsigned cHeight, int x, int y);
307extern Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
308
309#endif /* _VBOXVIDEO_H_ */
310
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