VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h@ 17610

Last change on this file since 17610 was 17610, checked in by vboxsync, 16 years ago

HGSMI for the graphics device: the windows guest display driver prototype code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.5 KB
Line 
1/******************************Module*Header*******************************\
2*
3* Copyright (C) 2006-2007 Sun Microsystems, Inc.
4*
5* This file is part of VirtualBox Open Source Edition (OSE), as
6* available from http://www.virtualbox.org. This file is free software;
7* you can redistribute it and/or modify it under the terms of the GNU
8* General Public License (GPL) as published by the Free Software
9* Foundation, in version 2 as it comes in the "COPYING" file of the
10* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12*
13* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14* Clara, CA 95054 USA or visit http://www.sun.com if you need
15* additional information or have any questions.
16*/
17/*
18* Based in part on Microsoft DDK sample code
19*
20* *******************
21* * GDI SAMPLE CODE *
22* *******************
23*
24* Module Name: driver.h
25*
26* contains prototypes for the frame buffer driver.
27*
28* Copyright (c) 1992-1998 Microsoft Corporation
29\**************************************************************************/
30
31#include "stddef.h"
32#include <stdarg.h>
33#include "windef.h"
34#include "wingdi.h"
35#include "winddi.h"
36#include "devioctl.h"
37#include "ntddvdeo.h"
38#include "debug.h"
39
40#include "../Miniport/vboxioctl.h"
41
42#include <VBox/VBoxVideo.h>
43
44/* Forward declaration. */
45struct _PDEV;
46typedef struct _PDEV PDEV;
47typedef PDEV *PPDEV;
48
49typedef struct _VBOXDISPLAYINFO
50{
51 VBOXVIDEOINFOHDR hdrLink;
52 VBOXVIDEOINFOLINK link;
53 VBOXVIDEOINFOHDR hdrScreen;
54 VBOXVIDEOINFOSCREEN screen;
55 VBOXVIDEOINFOHDR hdrHostEvents;
56 VBOXVIDEOINFOHOSTEVENTS hostEvents;
57 VBOXVIDEOINFOHDR hdrEnd;
58} VBOXDISPLAYINFO;
59
60#include "vbvavrdp.h"
61#include "vrdpbmp.h"
62
63/* Saved screen bits information. */
64typedef struct _SSB
65{
66 ULONG ident; /* 1 based index in the stack = the handle returned by DrvSaveScreenBits (SS_SAVE) */
67 BYTE *pBuffer; /* Buffer where screen bits are saved. */
68} SSB;
69
70/* VRAM
71 * | | | | |
72 * 0+framebuffer+ddraw heap+VBVA buffer+displayinfo=cScreenSize
73 */
74typedef struct _VRAMLAYOUT
75{
76 ULONG cbVRAM;
77
78 ULONG offFrameBuffer;
79 ULONG cbFrameBuffer;
80
81 ULONG offDDRAWHeap; //@todo
82 ULONG cbDDRAWHeap;
83
84 ULONG offVBVABuffer;
85 ULONG cbVBVABuffer;
86
87 ULONG offDisplayInformation;
88 ULONG cbDisplayInformation;
89} VRAMLAYOUT;
90
91typedef struct
92{
93 PPDEV ppdev;
94} VBOXSURF, *PVBOXSURF;
95
96struct _PDEV
97{
98 HANDLE hDriver; // Handle to \Device\Screen
99 HDEV hdevEng; // Engine's handle to PDEV
100 HSURF hsurfScreenBitmap; // Engine's handle to VRAM screen bitmap surface
101 SURFOBJ *psoScreenBitmap; // VRAM screen bitmap surface
102 HSURF hsurfScreen; // Engine's handle to VRAM screen device surface
103 ULONG ulBitmapType;
104 HPALETTE hpalDefault; // Handle to the default palette for device.
105 PBYTE pjScreen; // This is pointer to base screen address
106 ULONG cxScreen; // Visible screen width
107 ULONG cyScreen; // Visible screen height
108 POINTL ptlOrg; // Where this display is anchored in
109 // the virtual desktop.
110 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view).
111 ULONG ulMode; // Mode the mini-port driver is in.
112 LONG lDeltaScreen; // Distance from one scan to the next.
113
114 PVOID pOffscreenList; // linked list of DCI offscreen surfaces.
115 FLONG flRed; // For bitfields device, Red Mask
116 FLONG flGreen; // For bitfields device, Green Mask
117 FLONG flBlue; // For bitfields device, Blue Mask
118 ULONG cPaletteShift; // number of bits the 8-8-8 palette must
119 // be shifted by to fit in the hardware
120 // palette.
121 ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
122 POINTL ptlHotSpot; // adjustment for pointer hot spot
123 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
124 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
125 DWORD cjPointerAttributes; // Size of buffer allocated
126 BOOL fHwCursorActive; // Are we currently using the hw cursor
127 PALETTEENTRY *pPal; // If this is pal managed, this is the pal
128 BOOL bSupportDCI; // Does the miniport support DCI?
129 FLONG flHooks;
130
131#ifndef VBOX_WITH_HGSMI
132 VBVAENABLERESULT vbva;
133 uint32_t u32VRDPResetFlag;
134#endif /* !VBOX_WITH_HGSMI */
135 BOOL fHwBufferOverflow;
136 VBVARECORD *pRecord;
137 VRDPBC cache;
138
139 ULONG cSSB; // Number of active saved screen bits records in the following array.
140 SSB aSSB[4]; // LIFO type stack for saved screen areas.
141
142#ifndef VBOX_WITH_HGSMI
143 VBOXDISPLAYINFO *pInfo;
144 BOOLEAN bVBoxVideoSupported;
145#endif /* !VBOX_WITH_HGSMI */
146 ULONG iDevice;
147 VRAMLAYOUT layout;
148
149 PVBOXSURF pdsurfScreen;
150
151#ifdef VBOX_WITH_DDRAW
152 BOOL bDdExclusiveMode;
153 DWORD dwNewDDSurfaceOffset;
154 DWORD cHeaps;
155 VIDEOMEMORY* pvmList;
156 struct {
157 DWORD bLocked;
158 RECTL rArea;
159 } ddLock;
160#endif /* VBOX_WITH_DDRAW */
161
162#ifdef VBOX_WITH_HGSMI
163 BOOLEAN bHGSMISupported;
164 HGSMIHEAP hgsmiDisplayHeap;
165 VBVABUFFER *pVBVA; /* Pointer to the pjScreen + layout->offVBVABuffer. NULL if VBVA is not enabled. */
166#endif /* VBOX_WITH_HGSMI */
167};
168
169#ifdef VBOX_WITH_OPENGL
170typedef struct
171{
172 DWORD dwVersion;
173 DWORD dwDriverVersion;
174 WCHAR szDriverName[256];
175} OPENGL_INFO, *POPENGL_INFO;
176#endif
177
178#ifndef VBOX_WITH_HGSMI
179/* The global semaphore handle for all driver instances. */
180extern HSEMAPHORE ghsemHwBuffer;
181#endif /* !VBOX_WITH_HGSMI */
182
183extern BOOL g_bOnNT40;
184
185DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
186BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
187BOOL bInitSURF(PPDEV, BOOL);
188BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
189BOOL bInitPointer(PPDEV, DEVINFO *);
190BOOL bInit256ColorPalette(PPDEV);
191BOOL bInitNotificationThread(PPDEV);
192VOID vStopNotificationThread (PPDEV);
193VOID vDisablePalette(PPDEV);
194VOID vDisableSURF(PPDEV);
195
196#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
197
198//
199// Determines the size of the DriverExtra information in the DEVMODE
200// structure passed to and from the display driver.
201//
202
203#define DRIVER_EXTRA_SIZE 0
204
205#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
206#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
207#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
208 // reverse order) used for memory
209 // allocations
210
211// VBOX
212typedef struct _CLIPRECTS {
213 ULONG c;
214 RECTL arcl[64];
215} CLIPRECTS;
216
217typedef struct _VRDPCLIPRECTS
218{
219 RECTL rclDstOrig; /* Original bounding rectancle. */
220 RECTL rclDst; /* Bounding rectangle of all rects. */
221 CLIPRECTS rects; /* Rectangles to update. */
222} VRDPCLIPRECTS;
223
224
225BOOL vboxVbvaEnable (PPDEV ppdev);
226void vboxVbvaDisable (PPDEV ppdev);
227
228BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
229void vboxHwBufferEndUpdate (PPDEV ppdev);
230
231BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
232
233BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
234
235void VBoxProcessDisplayInfo(PPDEV ppdev);
236void VBoxUpdateDisplayInfo (PPDEV ppdev);
237
238void drvLoadEng (void);
239
240BOOL bIsScreenSurface (SURFOBJ *pso);
241
242__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
243{
244 if (pso)
245 {
246 PPDEV ppdev = (PPDEV)pso->dhpdev;
247
248 if (ppdev)
249 {
250 if (ppdev->psoScreenBitmap && pso->hsurf == ppdev->hsurfScreen)
251 {
252 /* Convert the device PSO to the bitmap PSO which can be passed to Eng*. */
253 pso = ppdev->psoScreenBitmap;
254 }
255 }
256 }
257
258 return pso;
259}
260
261#define CONV_SURF(_pso) getSurfObj (_pso)
262
263__inline int format2BytesPerPixel(const SURFOBJ *pso)
264{
265 switch (pso->iBitmapFormat)
266 {
267 case BMF_16BPP: return 2;
268 case BMF_24BPP: return 3;
269 case BMF_32BPP: return 4;
270 }
271
272 return 0;
273}
274
275#ifdef VBOX_VBVA_ADJUST_RECT
276void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
277BOOL vbvaFindChangedRect (SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
278#endif /* VBOX_VBVA_ADJUST_RECT */
279
280void vrdpReportDirtyRect (PPDEV ppdev, RECTL *prcl);
281void vbvaReportDirtyRect (PPDEV ppdev, RECTL *prcl);
282
283#define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
284#define VRDP_TEXT_MAX_GLYPHS 0xfe
285
286BOOL vboxReportText (PPDEV ppdev,
287 VRDPCLIPRECTS *pClipRects,
288 STROBJ *pstro,
289 FONTOBJ *pfo,
290 RECTL *prclOpaque,
291 ULONG ulForeRGB,
292 ULONG ulBackRGB
293 );
294
295BOOL vrdpReportOrderGeneric (PPDEV ppdev,
296 const VRDPCLIPRECTS *pClipRects,
297 const void *pvOrder,
298 unsigned cbOrder,
299 unsigned code);
300
301
302#include <iprt/assert.h>
303
304#define VBVA_ASSERT(expr) \
305 do { \
306 if (!(expr)) \
307 { \
308 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
309 AssertMsg2("!!!\n"); \
310 } \
311 } while (0)
312
313#ifdef STAT_sunlover
314extern ULONG gStatCopyBitsOffscreenToScreen;
315extern ULONG gStatCopyBitsScreenToScreen;
316extern ULONG gStatBitBltOffscreenToScreen;
317extern ULONG gStatBitBltScreenToScreen;
318extern ULONG gStatUnchangedOffscreenToScreen;
319extern ULONG gStatUnchangedOffscreenToScreenCRC;
320extern ULONG gStatNonTransientEngineBitmaps;
321extern ULONG gStatTransientEngineBitmaps;
322extern ULONG gStatUnchangedBitmapsCRC;
323extern ULONG gStatUnchangedBitmapsDeviceCRC;
324extern ULONG gStatBitmapsCRC;
325extern ULONG gStatBitBltScreenPattern;
326extern ULONG gStatBitBltScreenSquare;
327extern ULONG gStatBitBltScreenPatternReported;
328extern ULONG gStatBitBltScreenSquareReported;
329extern ULONG gStatCopyBitsScreenSquare;
330
331extern ULONG gStatEnablePDEV;
332extern ULONG gStatCompletePDEV;
333extern ULONG gStatDisablePDEV;
334extern ULONG gStatEnableSurface;
335extern ULONG gStatDisableSurface;
336extern ULONG gStatAssertMode;
337extern ULONG gStatDisableDriver;
338extern ULONG gStatCreateDeviceBitmap;
339extern ULONG gStatDeleteDeviceBitmap;
340extern ULONG gStatDitherColor;
341extern ULONG gStatStrokePath;
342extern ULONG gStatFillPath;
343extern ULONG gStatStrokeAndFillPath;
344extern ULONG gStatPaint;
345extern ULONG gStatBitBlt;
346extern ULONG gStatCopyBits;
347extern ULONG gStatStretchBlt;
348extern ULONG gStatSetPalette;
349extern ULONG gStatTextOut;
350extern ULONG gStatSetPointerShape;
351extern ULONG gStatMovePointer;
352extern ULONG gStatLineTo;
353extern ULONG gStatSynchronize;
354extern ULONG gStatGetModes;
355extern ULONG gStatGradientFill;
356extern ULONG gStatStretchBltROP;
357extern ULONG gStatPlgBlt;
358extern ULONG gStatAlphaBlend;
359extern ULONG gStatTransparentBlt;
360
361void statPrint (void);
362
363#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
364#define STATPRINT do { statPrint (); } while (0)
365#else
366#define STATDRVENTRY(a, b)
367#define STATPRINT
368#endif /* STAT_sunlover */
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