VirtualBox

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

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

Additions/x11/vboxvideo: report monitor connected status to X11, based on the enabled state in the last mode hint.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 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#include <xf86.h>
61
62#define TRACE_ENTRY() \
63do { \
64 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
65 xf86Msg(X_INFO, ": entering\n"); \
66} while(0)
67#define TRACE_EXIT() \
68do { \
69 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
70 xf86Msg(X_INFO, ": leaving\n"); \
71} while(0)
72#define TRACE_LOG(...) \
73do { \
74 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
75 xf86Msg(X_INFO, __VA_ARGS__); \
76} while(0)
77# define TRACE_LINE() do \
78{ \
79 ErrorF ("%s: line %d\n", __FUNCTION__, __LINE__); \
80 } while(0)
81# define XF86ASSERT(expr, out) \
82if (!(expr)) \
83{ \
84 ErrorF ("\nAssertion failed!\n\n"); \
85 ErrorF ("%s\n", #expr); \
86 ErrorF ("at %s (%s:%d)\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
87 ErrorF out; \
88 FatalError("Aborting"); \
89}
90#else /* !DEBUG */
91
92#define TRACE_ENTRY() do { } while (0)
93#define TRACE_EXIT() do { } while (0)
94#define TRACE_LOG(...) do { } while (0)
95#define XF86ASSERT(expr, out) do { } while (0)
96
97#endif /* !DEBUG */
98
99#define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
100
101#include <VBox/Hardware/VBoxVideoVBE.h>
102
103#include "xf86str.h"
104#include "xf86Cursor.h"
105
106#define VBOX_VERSION 4000 /* Why? */
107#define VBOX_NAME "VBoxVideo"
108#define VBOX_DRIVER_NAME "vboxvideo"
109
110#ifdef VBOX_DRI_OLD
111/* DRI support */
112#define _XF86DRI_SERVER_
113/* Hack to work around a libdrm header which is broken on Solaris */
114#define u_int64_t uint64_t
115/* Get rid of a warning due to a broken header file */
116enum drm_bo_type { DRM_BO_TYPE };
117#include "dri.h"
118#undef u_int64_t
119#include "sarea.h"
120#include "GL/glxint.h"
121
122/* For some reason this is not in the header files. */
123extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
124 void **configprivs);
125#endif
126
127#define VBOX_VIDEO_MAJOR 1
128#define VBOX_VIDEO_MINOR 0
129#define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
130#define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
131#define VBOX_MAX_DRAWABLES 256 /* At random. */
132
133#define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
134
135/** Helper to work round different ways of getting the root window in different
136 * server versions. */
137#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 700000000 \
138 && XORG_VERSION_CURRENT >= 100900000
139# define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
140#else
141# define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
142#endif
143
144/** Structure containing all virtual monitor-specific information. */
145struct VBoxScreen
146{
147 /** Position information for each virtual screen for the purposes of
148 * sending dirty rectangle information to the right one. */
149 RTRECT2 aScreenLocation;
150 /** Has this screen been disabled by the guest? */
151 Bool afDisabled;
152#ifdef VBOXVIDEO_13
153 /** The virtual crtcs. */
154 struct _xf86Crtc *paCrtcs;
155 /** The virtual outputs, logically not distinct from crtcs. */
156 struct _xf86Output *paOutputs;
157#endif
158 /** Offsets of VBVA buffers in video RAM */
159 uint32_t aoffVBVABuffer;
160 /** Context information about the VBVA buffers for each screen */
161 struct VBVABUFFERCONTEXT aVbvaCtx;
162 /** The current preferred resolution for the screen */
163 RTRECTSIZE aPreferredSize;
164 /** Has this screen been enabled by the host? */
165 Bool afConnected;
166};
167
168typedef struct VBOXRec
169{
170 EntityInfoPtr pEnt;
171#ifdef PCIACCESS
172 struct pci_device *pciInfo;
173#else
174 pciVideoPtr pciInfo;
175 PCITAG pciTag;
176#endif
177 void *base;
178 /** The amount of VRAM available for use as a framebuffer */
179 unsigned long cbFBMax;
180 /** The size of the framebuffer and the VBVA buffers at the end of it. */
181 unsigned long cbView;
182 /** The current line size in bytes */
183 uint32_t cbLine;
184 /** Whether the pre-X-server mode was a VBE mode */
185 bool fSavedVBEMode;
186 /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
187 */
188 uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
189 CloseScreenProcPtr CloseScreen;
190 /** Default X server procedure for enabling and disabling framebuffer access */
191 xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
192 OptionInfoPtr Options;
193 /** @todo we never actually free this */
194 xf86CursorInfoPtr pCurs;
195 Bool useDevice;
196 Bool forceSWCursor;
197 /** Do we know that the guest can handle absolute co-ordinates? */
198 Bool guestCanAbsolute;
199 /** Number of screens attached */
200 uint32_t cScreens;
201 /** Information about each virtual screen. */
202 struct VBoxScreen *pScreens;
203 /** The last requested framebuffer size. */
204 RTRECTSIZE FBSize;
205#ifndef VBOXVIDEO_13
206 /** The original CreateScreenResources procedure which we wrap with our own.
207 */
208 CreateScreenResourcesProcPtr pfnCreateScreenResources;
209#endif
210 /** HGSMI guest heap context */
211 HGSMIGUESTCOMMANDCONTEXT guestCtx;
212 /** Unrestricted horizontal resolution flag. */
213 Bool fAnyX;
214#ifdef VBOX_DRI
215 Bool useDRI;
216#ifdef VBOX_DRI_OLD
217 int cVisualConfigs;
218 __GLXvisualConfig *pVisualConfigs;
219 DRIInfoRec *pDRIInfo;
220# endif
221 int drmFD;
222#endif
223} VBOXRec, *VBOXPtr;
224
225extern Bool vbox_init(int scrnIndex, VBOXPtr pVBox);
226extern Bool vbox_cursor_init (ScreenPtr pScreen);
227extern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
228extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
229extern Bool vbox_device_available(VBOXPtr pVBox);
230
231extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
232extern void vboxDisableVbva(ScrnInfoPtr pScrn);
233
234extern unsigned vboxNextStandardMode(ScrnInfoPtr pScrn, unsigned cIndex,
235 uint32_t *pcx, uint32_t *pcy);
236extern void vboxAddModes(ScrnInfoPtr pScrn);
237extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
238extern void VBoxUpdateSizeHints(ScrnInfoPtr pScrn);
239#ifndef VBOXVIDEO_13
240extern void VBoxSetUpRandR11(ScreenPtr pScreen);
241#endif
242
243/* DRI stuff */
244extern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
245 VBOXPtr pVBox);
246extern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
247extern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
248extern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
249
250/* EDID generation */
251#ifdef VBOXVIDEO_13
252extern Bool VBOXEDIDSet(struct _xf86Output *output, DisplayModePtr pmode);
253#endif
254
255/* Utilities */
256
257static inline VBOXPtr VBOXGetRec(ScrnInfoPtr pScrn)
258{
259 return ((VBOXPtr)pScrn->driverPrivate);
260}
261
262/** Calculate the BPP from the screen depth */
263static inline uint16_t vboxBPP(ScrnInfoPtr pScrn)
264{
265 return pScrn->depth == 24 ? 32 : 16;
266}
267
268/** Calculate the scan line length for a display width */
269static inline int32_t vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
270{
271 uint32_t cbLine = (cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
272 return cbLine < INT32_MAX ? cbLine : INT32_MAX;
273}
274
275/** Calculate the display pitch from the scan line length */
276static inline int32_t vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
277{
278 return cbLine * 8 / vboxBPP(pScrn);
279}
280
281extern void vboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY);
282extern Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
283 unsigned cHeight, int x, int y);
284extern Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
285
286#endif /* _VBOXVIDEO_H_ */
287
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