VirtualBox

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

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

HGSMI: post host VBVA commands to display; Video HW Accel: mechanism for passing/processing commands to framebuffer

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.3 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
167 HVBOXVIDEOHGSMI hMpHGSMI; /* context handler passed to miniport HGSMI callbacks */
168 PFNVBOXVIDEOHGSMICOMPLETION pfnHGSMICommandComplete; /* called to complete the command we receive from the miniport */
169#endif /* VBOX_WITH_HGSMI */
170
171#ifdef VBOX_WITH_VIDEOHWACCEL
172 BOOLEAN bVHWAEnabled;
173#endif
174};
175
176#ifdef VBOX_WITH_OPENGL
177typedef struct
178{
179 DWORD dwVersion;
180 DWORD dwDriverVersion;
181 WCHAR szDriverName[256];
182} OPENGL_INFO, *POPENGL_INFO;
183#endif
184
185#ifndef VBOX_WITH_HGSMI
186/* The global semaphore handle for all driver instances. */
187extern HSEMAPHORE ghsemHwBuffer;
188#endif /* !VBOX_WITH_HGSMI */
189
190
191#ifdef VBOX_WITH_HGSMI
192#define VBE_DISPI_IOPORT_INDEX 0x01CE
193#define VBE_DISPI_IOPORT_DATA 0x01CF
194#define VBE_DISPI_INDEX_VBVA_GUEST 0xc
195#endif /* VBOX_WITH_HGSMI */
196
197extern BOOL g_bOnNT40;
198
199DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
200BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
201BOOL bInitSURF(PPDEV, BOOL);
202BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
203BOOL bInitPointer(PPDEV, DEVINFO *);
204BOOL bInit256ColorPalette(PPDEV);
205BOOL bInitNotificationThread(PPDEV);
206VOID vStopNotificationThread (PPDEV);
207VOID vDisablePalette(PPDEV);
208VOID vDisableSURF(PPDEV);
209
210#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
211
212//
213// Determines the size of the DriverExtra information in the DEVMODE
214// structure passed to and from the display driver.
215//
216
217#define DRIVER_EXTRA_SIZE 0
218
219#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
220#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
221#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
222 // reverse order) used for memory
223 // allocations
224
225// VBOX
226typedef struct _CLIPRECTS {
227 ULONG c;
228 RECTL arcl[64];
229} CLIPRECTS;
230
231typedef struct _VRDPCLIPRECTS
232{
233 RECTL rclDstOrig; /* Original bounding rectancle. */
234 RECTL rclDst; /* Bounding rectangle of all rects. */
235 CLIPRECTS rects; /* Rectangles to update. */
236} VRDPCLIPRECTS;
237
238
239BOOL vboxVbvaEnable (PPDEV ppdev);
240void vboxVbvaDisable (PPDEV ppdev);
241
242BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
243void vboxHwBufferEndUpdate (PPDEV ppdev);
244
245BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
246
247BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
248
249void VBoxProcessDisplayInfo(PPDEV ppdev);
250void VBoxUpdateDisplayInfo (PPDEV ppdev);
251
252void drvLoadEng (void);
253
254#ifdef VBOX_WITH_HGSMI
255DECLCALLBACK(int) vboxVHWACommandHanlder(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer);
256
257 #ifdef VBOX_WITH_VIDEOHWACCEL
258VBOXVHWACMD* vboxVHWACreateCommand (PPDEV ppdev, VBOXVHWACMD_LENGTH cbCmd);
259void vboxVHWAFreeCommand (PPDEV ppdev, VBOXVHWACMD* pCmd);
260void vboxVHWASubmitCommand (PPDEV ppdev, VBOXVHWACMD* pCmd);
261 #endif
262#endif
263
264BOOL bIsScreenSurface (SURFOBJ *pso);
265
266__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
267{
268 if (pso)
269 {
270 PPDEV ppdev = (PPDEV)pso->dhpdev;
271
272 if (ppdev)
273 {
274 if (ppdev->psoScreenBitmap && pso->hsurf == ppdev->hsurfScreen)
275 {
276 /* Convert the device PSO to the bitmap PSO which can be passed to Eng*. */
277 pso = ppdev->psoScreenBitmap;
278 }
279 }
280 }
281
282 return pso;
283}
284
285#define CONV_SURF(_pso) getSurfObj (_pso)
286
287__inline int format2BytesPerPixel(const SURFOBJ *pso)
288{
289 switch (pso->iBitmapFormat)
290 {
291 case BMF_16BPP: return 2;
292 case BMF_24BPP: return 3;
293 case BMF_32BPP: return 4;
294 }
295
296 return 0;
297}
298
299#ifdef VBOX_VBVA_ADJUST_RECT
300void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
301BOOL vbvaFindChangedRect (SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
302#endif /* VBOX_VBVA_ADJUST_RECT */
303
304void vrdpReportDirtyRect (PPDEV ppdev, RECTL *prcl);
305void vbvaReportDirtyRect (PPDEV ppdev, RECTL *prcl);
306
307#define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
308#define VRDP_TEXT_MAX_GLYPHS 0xfe
309
310BOOL vboxReportText (PPDEV ppdev,
311 VRDPCLIPRECTS *pClipRects,
312 STROBJ *pstro,
313 FONTOBJ *pfo,
314 RECTL *prclOpaque,
315 ULONG ulForeRGB,
316 ULONG ulBackRGB
317 );
318
319BOOL vrdpReportOrderGeneric (PPDEV ppdev,
320 const VRDPCLIPRECTS *pClipRects,
321 const void *pvOrder,
322 unsigned cbOrder,
323 unsigned code);
324
325
326#include <iprt/assert.h>
327
328#define VBVA_ASSERT(expr) \
329 do { \
330 if (!(expr)) \
331 { \
332 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
333 AssertMsg2("!!!\n"); \
334 } \
335 } while (0)
336
337#ifdef STAT_sunlover
338extern ULONG gStatCopyBitsOffscreenToScreen;
339extern ULONG gStatCopyBitsScreenToScreen;
340extern ULONG gStatBitBltOffscreenToScreen;
341extern ULONG gStatBitBltScreenToScreen;
342extern ULONG gStatUnchangedOffscreenToScreen;
343extern ULONG gStatUnchangedOffscreenToScreenCRC;
344extern ULONG gStatNonTransientEngineBitmaps;
345extern ULONG gStatTransientEngineBitmaps;
346extern ULONG gStatUnchangedBitmapsCRC;
347extern ULONG gStatUnchangedBitmapsDeviceCRC;
348extern ULONG gStatBitmapsCRC;
349extern ULONG gStatBitBltScreenPattern;
350extern ULONG gStatBitBltScreenSquare;
351extern ULONG gStatBitBltScreenPatternReported;
352extern ULONG gStatBitBltScreenSquareReported;
353extern ULONG gStatCopyBitsScreenSquare;
354
355extern ULONG gStatEnablePDEV;
356extern ULONG gStatCompletePDEV;
357extern ULONG gStatDisablePDEV;
358extern ULONG gStatEnableSurface;
359extern ULONG gStatDisableSurface;
360extern ULONG gStatAssertMode;
361extern ULONG gStatDisableDriver;
362extern ULONG gStatCreateDeviceBitmap;
363extern ULONG gStatDeleteDeviceBitmap;
364extern ULONG gStatDitherColor;
365extern ULONG gStatStrokePath;
366extern ULONG gStatFillPath;
367extern ULONG gStatStrokeAndFillPath;
368extern ULONG gStatPaint;
369extern ULONG gStatBitBlt;
370extern ULONG gStatCopyBits;
371extern ULONG gStatStretchBlt;
372extern ULONG gStatSetPalette;
373extern ULONG gStatTextOut;
374extern ULONG gStatSetPointerShape;
375extern ULONG gStatMovePointer;
376extern ULONG gStatLineTo;
377extern ULONG gStatSynchronize;
378extern ULONG gStatGetModes;
379extern ULONG gStatGradientFill;
380extern ULONG gStatStretchBltROP;
381extern ULONG gStatPlgBlt;
382extern ULONG gStatAlphaBlend;
383extern ULONG gStatTransparentBlt;
384
385void statPrint (void);
386
387#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
388#define STATPRINT do { statPrint (); } while (0)
389#else
390#define STATDRVENTRY(a, b)
391#define STATPRINT
392#endif /* STAT_sunlover */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette