1 | /* $Id: VBoxDispIf.h 55401 2015-04-23 10:03:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxTray - Display Settings Interface abstraction for XPDM & WDDM
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 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 | #include <iprt/cdefs.h>
|
---|
18 |
|
---|
19 | #ifdef VBOX_WITH_WDDM
|
---|
20 | # define D3DKMDT_SPECIAL_MULTIPLATFORM_TOOL
|
---|
21 | # include <d3dkmthk.h>
|
---|
22 | # include "../Graphics/Video/disp/wddm/VBoxDispKmt.h"
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | #include <VBoxDisplay.h>
|
---|
26 |
|
---|
27 | typedef enum
|
---|
28 | {
|
---|
29 | VBOXDISPIF_MODE_UNKNOWN = 0,
|
---|
30 | VBOXDISPIF_MODE_XPDM_NT4 = 1,
|
---|
31 | VBOXDISPIF_MODE_XPDM
|
---|
32 | #ifdef VBOX_WITH_WDDM
|
---|
33 | , VBOXDISPIF_MODE_WDDM
|
---|
34 | , VBOXDISPIF_MODE_WDDM_W7
|
---|
35 | #endif
|
---|
36 | } VBOXDISPIF_MODE;
|
---|
37 | /* display driver interface abstraction for XPDM & WDDM
|
---|
38 | * with WDDM we can not use ExtEscape to communicate with our driver
|
---|
39 | * because we do not have XPDM display driver any more, i.e. escape requests are handled by cdd
|
---|
40 | * that knows nothing about us
|
---|
41 | * NOTE: DispIf makes no checks whether the display driver is actually a VBox driver,
|
---|
42 | * it just switches between using different backend OS API based on the VBoxDispIfSwitchMode call
|
---|
43 | * It's caller's responsibility to initiate it to work in the correct mode */
|
---|
44 | typedef struct VBOXDISPIF
|
---|
45 | {
|
---|
46 | VBOXDISPIF_MODE enmMode;
|
---|
47 | /* with WDDM the approach is to call into WDDM miniport driver via PFND3DKMT API provided by the GDI,
|
---|
48 | * The PFND3DKMT is supposed to be used by the OpenGL ICD according to MSDN, so this approach is a bit hacky */
|
---|
49 | union
|
---|
50 | {
|
---|
51 | struct
|
---|
52 | {
|
---|
53 | LONG (WINAPI * pfnChangeDisplaySettingsEx)(LPCSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam);
|
---|
54 | } xpdm;
|
---|
55 | #ifdef VBOX_WITH_WDDM
|
---|
56 | struct
|
---|
57 | {
|
---|
58 | /* ChangeDisplaySettingsEx does not exist in NT. ResizeDisplayDevice uses the function. */
|
---|
59 | LONG (WINAPI * pfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam);
|
---|
60 |
|
---|
61 | /* EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */
|
---|
62 | BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags);
|
---|
63 |
|
---|
64 | VBOXDISPKMT_CALLBACKS KmtCallbacks;
|
---|
65 | } wddm;
|
---|
66 | #endif
|
---|
67 | } modeData;
|
---|
68 | } VBOXDISPIF, *PVBOXDISPIF;
|
---|
69 | typedef const struct VBOXDISPIF *PCVBOXDISPIF;
|
---|
70 |
|
---|
71 | /* initializes the DispIf
|
---|
72 | * Initially the DispIf is configured to work in XPDM mode
|
---|
73 | * call VBoxDispIfSwitchMode to switch the mode to WDDM */
|
---|
74 | DWORD VBoxDispIfInit(PVBOXDISPIF pIf);
|
---|
75 | DWORD VBoxDispIfSwitchMode(PVBOXDISPIF pIf, VBOXDISPIF_MODE enmMode, VBOXDISPIF_MODE *penmOldMode);
|
---|
76 | DECLINLINE(VBOXDISPIF_MODE) VBoxDispGetMode(PVBOXDISPIF pIf) { return pIf->enmMode; }
|
---|
77 | DWORD VBoxDispIfTerm(PVBOXDISPIF pIf);
|
---|
78 | DWORD VBoxDispIfEscape(PCVBOXDISPIF const pIf, PVBOXDISPIFESCAPE pEscape, int cbData);
|
---|
79 | DWORD VBoxDispIfEscapeInOut(PCVBOXDISPIF const pIf, PVBOXDISPIFESCAPE pEscape, int cbData);
|
---|
80 | DWORD VBoxDispIfResizeModes(PCVBOXDISPIF const pIf, UINT iChangedMode, BOOL fEnable, BOOL fExtDispSup, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes);
|
---|
81 | DWORD VBoxDispIfCancelPendingResize(PCVBOXDISPIF const pIf);
|
---|
82 |
|
---|
83 | DWORD VBoxDispIfResizeStarted(PCVBOXDISPIF const pIf);
|
---|
84 |
|
---|
85 |
|
---|
86 | typedef struct VBOXDISPIF_SEAMLESS
|
---|
87 | {
|
---|
88 | PCVBOXDISPIF pIf;
|
---|
89 |
|
---|
90 | union
|
---|
91 | {
|
---|
92 | #ifdef VBOX_WITH_WDDM
|
---|
93 | struct
|
---|
94 | {
|
---|
95 | VBOXDISPKMT_ADAPTER Adapter;
|
---|
96 | # ifdef VBOX_DISPIF_WITH_OPCONTEXT
|
---|
97 | VBOXDISPKMT_DEVICE Device;
|
---|
98 | VBOXDISPKMT_CONTEXT Context;
|
---|
99 | # endif
|
---|
100 | } wddm;
|
---|
101 | #endif
|
---|
102 | } modeData;
|
---|
103 | } VBOXDISPIF_SEAMLESS;
|
---|
104 |
|
---|
105 | DECLINLINE(bool) VBoxDispIfSeamlesIsValid(VBOXDISPIF_SEAMLESS *pSeamless)
|
---|
106 | {
|
---|
107 | return !!pSeamless->pIf;
|
---|
108 | }
|
---|
109 |
|
---|
110 | DWORD VBoxDispIfSeamlesCreate(PCVBOXDISPIF const pIf, VBOXDISPIF_SEAMLESS *pSeamless, HANDLE hEvent);
|
---|
111 | DWORD VBoxDispIfSeamlesTerm(VBOXDISPIF_SEAMLESS *pSeamless);
|
---|
112 | DWORD VBoxDispIfSeamlesSubmit(VBOXDISPIF_SEAMLESS *pSeamless, VBOXDISPIFESCAPE *pData, int cbData);
|
---|