VirtualBox

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

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

Additions/x11/vboxvideo: separate Solaris absolute mouse calibration when setting the frame-buffer dimensions into a separate function.

  • 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#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 /** Has this screen been enabled by the host? */
166 Bool afConnected;
167 /** The last mode hint data read from the X11 property. */
168 int32_t lastModeHintFromProperty;
169};
170
171typedef struct VBOXRec
172{
173 EntityInfoPtr pEnt;
174#ifdef PCIACCESS
175 struct pci_device *pciInfo;
176#else
177 pciVideoPtr pciInfo;
178 PCITAG pciTag;
179#endif
180 void *base;
181 /** The amount of VRAM available for use as a framebuffer */
182 unsigned long cbFBMax;
183 /** The size of the framebuffer and the VBVA buffers at the end of it. */
184 unsigned long cbView;
185 /** The current line size in bytes */
186 uint32_t cbLine;
187 /** Whether the pre-X-server mode was a VBE mode */
188 bool fSavedVBEMode;
189 /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
190 */
191 uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
192 CloseScreenProcPtr CloseScreen;
193 /** Default X server procedure for enabling and disabling framebuffer access */
194 xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
195 OptionInfoPtr Options;
196 /** @todo we never actually free this */
197 xf86CursorInfoPtr pCurs;
198 /** Do we currently want to use the host cursor? */
199 Bool fUseHardwareCursor;
200 /** The last cursor capabilities data read from the X11 property. */
201 int32_t fLastCursorCapabilitiesFromProperty;
202 /** Number of screens attached */
203 uint32_t cScreens;
204 /** Information about each virtual screen. */
205 struct VBoxScreen *pScreens;
206 /** The last requested framebuffer size. */
207 RTRECTSIZE FBSize;
208#ifdef VBOXVIDEO_13
209 /** Array of structures for receiving mode hints. */
210 VBVAMODEHINT *paVBVAModeHints;
211# ifdef RT_OS_LINUX
212 /** Input device file descriptor for getting ACPI hot-plug events. */
213 int fdACPIDevices;
214 /** Input handler handle for ACPI hot-plug listener. */
215 void *hACPIEventHandler;
216# endif
217 /** Have we read all available HGSMI mode hint data? */
218 bool fHaveReadHGSMIModeHintData;
219#else
220 /** The original CreateScreenResources procedure which we wrap with our own.
221 */
222 CreateScreenResourcesProcPtr pfnCreateScreenResources;
223#endif
224 /** HGSMI guest heap context */
225 HGSMIGUESTCOMMANDCONTEXT guestCtx;
226 /** Unrestricted horizontal resolution flag. */
227 Bool fAnyX;
228#ifdef VBOX_DRI
229 Bool useDRI;
230#ifdef VBOX_DRI_OLD
231 int cVisualConfigs;
232 __GLXvisualConfig *pVisualConfigs;
233 DRIInfoRec *pDRIInfo;
234# endif
235 int drmFD;
236#endif
237} VBOXRec, *VBOXPtr;
238
239/* helpers.c */
240extern void vbvxMsg(const char *pszFormat, ...);
241extern void vbvxMsgV(const char *pszFormat, va_list args);
242extern void vbvxAbortServer(void);
243extern VBOXPtr vbvxGetRec(ScrnInfoPtr pScrn);
244#define VBOXGetRec vbvxGetRec /* Temporary */
245extern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
246extern void vbvxReprobeCursor(ScrnInfoPtr pScrn);
247
248/* setmode.c */
249extern void vbvxSetSolarisMouseRange(int width, int height);
250
251extern Bool vbox_cursor_init (ScreenPtr pScreen);
252extern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
253extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
254
255extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
256extern void vboxDisableVbva(ScrnInfoPtr pScrn);
257
258/* getmode.c */
259extern void vboxAddModes(ScrnInfoPtr pScrn);
260extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
261extern void VBoxUpdateSizeHints(ScrnInfoPtr pScrn);
262#ifndef VBOXVIDEO_13
263extern void VBoxSetUpRandR11(ScreenPtr pScreen);
264#else
265void VBoxSetUpLinuxACPI(ScreenPtr pScreen);
266void VBoxCleanUpLinuxACPI(ScreenPtr pScreen);
267#endif
268
269/* DRI stuff */
270extern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
271 VBOXPtr pVBox);
272extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
273extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
274extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
275
276/* Utilities */
277
278/** Calculate the BPP from the screen depth */
279static inline uint16_t vboxBPP(ScrnInfoPtr pScrn)
280{
281 return pScrn->depth == 24 ? 32 : 16;
282}
283
284/** Calculate the scan line length for a display width */
285static inline int32_t vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
286{
287 uint32_t cbLine = (cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
288 return cbLine < INT32_MAX ? cbLine : INT32_MAX;
289}
290
291/** Calculate the display pitch from the scan line length */
292static inline int32_t vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
293{
294 return cbLine * 8 / vboxBPP(pScrn);
295}
296
297extern void vboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY);
298extern Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
299 unsigned cHeight, int x, int y);
300extern Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
301
302#endif /* _VBOXVIDEO_H_ */
303
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