VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp@ 33868

Last change on this file since 33868 was 33868, checked in by vboxsync, 14 years ago

wddm: multi-monitor fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 81.7 KB
Line 
1/*
2 * Copyright (C) 2010 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.virtualbox.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 */
12#include "../VBoxVideo.h"
13#include "../Helper.h"
14
15NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
16 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
17 BOOLEAN *pbSupported)
18{
19 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
20 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
21 BOOLEAN bSupported = TRUE;
22
23 if (Status == STATUS_SUCCESS)
24 {
25 while (1)
26 {
27 /* @todo: which paths do we support? no matter for now
28 pNewVidPnPresentPathInfo->VidPnSourceId
29 pNewVidPnPresentPathInfo->VidPnTargetId
30
31 ImportanceOrdinal does not matter for now
32 pNewVidPnPresentPathInfo->ImportanceOrdinal
33 */
34
35 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
36 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
37 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
38 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
39 {
40 dprintf(("unsupported Scaling (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Scaling));
41 AssertBreakpoint();
42 bSupported = FALSE;
43 break;
44 }
45
46 if (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched)
47 {
48 dprintf(("unsupported Scaling support (Stretched)\n"));
49 AssertBreakpoint();
50 bSupported = FALSE;
51 break;
52 }
53
54 if (!pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity
55 && !pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered)
56 {
57 dprintf(("\"Identity\" or \"Centered\" Scaling support not set\n"));
58 AssertBreakpoint();
59 bSupported = FALSE;
60 break;
61 }
62
63 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED
64 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY)
65 {
66 dprintf(("unsupported rotation (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Rotation));
67 AssertBreakpoint();
68 bSupported = FALSE;
69 break;
70 }
71
72 if (pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180
73 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270
74 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90)
75 {
76 dprintf(("unsupported RotationSupport\n"));
77 AssertBreakpoint();
78 bSupported = FALSE;
79 break;
80 }
81
82 if (!pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity)
83 {
84 dprintf(("\"Identity\" RotationSupport not set\n"));
85 AssertBreakpoint();
86 bSupported = FALSE;
87 break;
88 }
89
90 if (pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx
91 || pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy)
92 {
93 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
94 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx,
95 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy));
96 AssertBreakpoint();
97 bSupported = FALSE;
98 break;
99 }
100
101 if (pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx
102 || pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy)
103 {
104 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
105 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx,
106 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy));
107 AssertBreakpoint();
108 bSupported = FALSE;
109 break;
110 }
111
112 if (pNewVidPnPresentPathInfo->VidPnTargetColorBasis != D3DKMDT_CB_SRGB
113 && pNewVidPnPresentPathInfo->VidPnTargetColorBasis != D3DKMDT_CB_UNINITIALIZED)
114 {
115 dprintf(("unsupported VidPnTargetColorBasis (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorBasis));
116 AssertBreakpoint();
117 bSupported = FALSE;
118 break;
119 }
120
121 /* channels?
122 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel;
123 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel;
124 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel;
125 we definitely not support fourth channel
126 */
127 if (pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel)
128 {
129 dprintf(("Non-zero FourthChannel (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel));
130 AssertBreakpoint();
131 bSupported = FALSE;
132 break;
133 }
134
135 /* Content (D3DKMDT_VPPC_GRAPHICS, _NOTSPECIFIED, _VIDEO), does not matter for now
136 pNewVidPnPresentPathInfo->Content
137 */
138 /* not support copy protection for now */
139 if (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType != D3DKMDT_VPPMT_NOPROTECTION
140 && pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType != D3DKMDT_VPPMT_UNINITIALIZED)
141 {
142 dprintf(("Copy protection not supported CopyProtectionType(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType));
143 AssertBreakpoint();
144 bSupported = FALSE;
145 break;
146 }
147
148 if (pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits)
149 {
150 dprintf(("Copy protection not supported APSTriggerBits(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits));
151 AssertBreakpoint();
152 bSupported = FALSE;
153 break;
154 }
155
156 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_SUPPORT tstCPSupport = {0};
157 tstCPSupport.NoProtection = 1;
158 if (memcmp(&tstCPSupport, &pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, sizeof(tstCPSupport)))
159 {
160 dprintf(("Copy protection support (0x%x)\n", *((UINT*)&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport)));
161 AssertBreakpoint();
162 bSupported = FALSE;
163 break;
164 }
165
166 if (pNewVidPnPresentPathInfo->GammaRamp.Type != D3DDDI_GAMMARAMP_DEFAULT
167 && pNewVidPnPresentPathInfo->GammaRamp.Type != D3DDDI_GAMMARAMP_UNINITIALIZED)
168 {
169 dprintf(("Unsupported GammaRamp.Type (%d)\n", pNewVidPnPresentPathInfo->GammaRamp.Type));
170 AssertBreakpoint();
171 bSupported = FALSE;
172 break;
173 }
174
175 if (pNewVidPnPresentPathInfo->GammaRamp.DataSize != 0)
176 {
177 dprintf(("Warning: non-zero GammaRamp.DataSize (%d), treating as supported\n", pNewVidPnPresentPathInfo->GammaRamp.DataSize));
178 }
179
180 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
181
182 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
183 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
184 if (Status == STATUS_SUCCESS)
185 {
186 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
187 }
188 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
189 {
190 Status = STATUS_SUCCESS;
191 pNewVidPnPresentPathInfo = NULL;
192 break;
193 }
194 else
195 {
196 AssertBreakpoint();
197 dprintf(("pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
198 pNewVidPnPresentPathInfo = NULL;
199 break;
200 }
201 }
202
203 if (pNewVidPnPresentPathInfo)
204 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
205
206 }
207 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
208 Status = STATUS_SUCCESS;
209 else
210 drprintf((__FUNCTION__": pfnAcquireFirstPathInfo failed Status(0x%x)\n", Status));
211
212 *pbSupported = bSupported;
213
214 return Status;
215}
216
217NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
218 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
219 BOOLEAN *pbSupported)
220{
221 BOOLEAN bSupported = TRUE;
222 /* we support both GRAPHICS and TEXT modes */
223 switch (pNewVidPnSourceModeInfo->Type)
224 {
225 case D3DKMDT_RMT_GRAPHICS:
226 /* any primary surface size actually
227 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
228 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy
229 */
230 if (pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
231 || pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy)
232 {
233 dprintf(("VisibleRegionSize(%d, %d) != PrimSurfSize(%d, %d)\n",
234 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx,
235 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy,
236 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx,
237 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy));
238 AssertBreakpoint();
239 bSupported = FALSE;
240 break;
241 }
242
243 /*
244 pNewVidPnSourceModeInfo->Format.Graphics.Stride
245 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat
246 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis
247 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode
248 */
249
250 break;
251 case D3DKMDT_RMT_TEXT:
252 break;
253 default:
254 AssertBreakpoint();
255 dprintf(("Warning: Unknown Src mode Type (%d)\n", pNewVidPnSourceModeInfo->Type));
256 break;
257 }
258
259 *pbSupported = bSupported;
260 return STATUS_SUCCESS;
261}
262
263NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
264 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
265 BOOLEAN *pbSupported)
266{
267 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
268 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
269 BOOLEAN bSupported = TRUE;
270 if (Status == STATUS_SUCCESS)
271 {
272 while (1)
273 {
274 Status = vboxVidPnCheckSourceModeInfo(hDesiredVidPn, pNewVidPnSourceModeInfo, &bSupported);
275 if (Status == STATUS_SUCCESS && bSupported)
276 {
277 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
278 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
279 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
280 if (Status == STATUS_SUCCESS)
281 {
282 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
283 }
284 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
285 {
286 Status = STATUS_SUCCESS;
287 break;
288 }
289 else
290 {
291 drprintf(("pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
292 break;
293 }
294 }
295 else
296 {
297 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
298 break;
299 }
300 }
301 }
302 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
303 Status = STATUS_SUCCESS;
304 else
305 drprintf(("VBoxVideoWddm: pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
306
307 *pbSupported = bSupported;
308 return Status;
309}
310
311NTSTATUS vboxVidPnPopulateVideoSignalInfo(D3DKMDT_VIDEO_SIGNAL_INFO *pVsi,
312 D3DKMDT_2DREGION *pResolution,
313 ULONG VSync)
314{
315 NTSTATUS Status = STATUS_SUCCESS;
316
317 pVsi->VideoStandard = D3DKMDT_VSS_VESA_DMT;
318 pVsi->ActiveSize = *pResolution;
319 pVsi->VSyncFreq.Numerator = VSync * 1000;
320 pVsi->VSyncFreq.Denominator = 1000;
321 pVsi->TotalSize.cx = pVsi->ActiveSize.cx + VBOXVDPN_C_DISPLAY_HBLANK_SIZE;
322 pVsi->TotalSize.cy = pVsi->ActiveSize.cy + VBOXVDPN_C_DISPLAY_VBLANK_SIZE;
323 pVsi->PixelRate = pVsi->TotalSize.cx * pVsi->TotalSize.cy * VSync;
324 pVsi->HSyncFreq.Numerator = (UINT)((pVsi->PixelRate / pVsi->TotalSize.cy) * 1000);
325 pVsi->HSyncFreq.Denominator = 1000;
326 pVsi->ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
327
328 return Status;
329}
330
331BOOLEAN vboxVidPnMatchVideoSignal(const D3DKMDT_VIDEO_SIGNAL_INFO *pVsi1, const D3DKMDT_VIDEO_SIGNAL_INFO *pVsi2)
332{
333 if (pVsi1->VideoStandard != pVsi2->VideoStandard)
334 return FALSE;
335 if (pVsi1->TotalSize.cx != pVsi2->TotalSize.cx)
336 return FALSE;
337 if (pVsi1->TotalSize.cy != pVsi2->TotalSize.cy)
338 return FALSE;
339 if (pVsi1->ActiveSize.cx != pVsi2->ActiveSize.cx)
340 return FALSE;
341 if (pVsi1->ActiveSize.cy != pVsi2->ActiveSize.cy)
342 return FALSE;
343 if (pVsi1->VSyncFreq.Numerator != pVsi2->VSyncFreq.Numerator)
344 return FALSE;
345 if (pVsi1->VSyncFreq.Denominator != pVsi2->VSyncFreq.Denominator)
346 return FALSE;
347 if (pVsi1->HSyncFreq.Numerator != pVsi2->HSyncFreq.Numerator)
348 return FALSE;
349 if (pVsi1->HSyncFreq.Denominator != pVsi2->HSyncFreq.Denominator)
350 return FALSE;
351 if (pVsi1->PixelRate != pVsi2->PixelRate)
352 return FALSE;
353 if (pVsi1->ScanLineOrdering != pVsi2->ScanLineOrdering)
354 return FALSE;
355
356 return TRUE;
357}
358
359NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
360 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
361 BOOLEAN *pbSupported)
362{
363 BOOLEAN bSupported = TRUE;
364 D3DKMDT_VIDEO_SIGNAL_INFO CmpVsi;
365 D3DKMDT_2DREGION CmpRes;
366 CmpRes.cx = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cx;
367 CmpRes.cy = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
368 NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(&CmpVsi,
369 &CmpRes,
370 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator/pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator);
371 Assert(Status == STATUS_SUCCESS);
372 if (Status != STATUS_SUCCESS)
373 {
374 drprintf((__FUNCTION__": vboxVidPnPopulateVideoSignalInfo error Status (0x%x)\n", Status));
375 return Status;
376 }
377
378 if (!vboxVidPnMatchVideoSignal(&CmpVsi, &pNewVidPnTargetModeInfo->VideoSignalInfo))
379 {
380 dfprintf((__FUNCTION__": VideoSignalInfos do not match!!!\n"));
381 AssertBreakpoint();
382 bSupported = FALSE;
383 }
384
385 *pbSupported = bSupported;
386 return STATUS_SUCCESS;
387}
388
389NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
390 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
391 BOOLEAN *pbSupported)
392{
393 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
394 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
395 BOOLEAN bSupported = TRUE;
396 if (Status == STATUS_SUCCESS)
397 {
398 Assert(pNewVidPnTargetModeInfo);
399 while (1)
400 {
401 Status = vboxVidPnCheckTargetModeInfo(hDesiredVidPn, pNewVidPnTargetModeInfo, &bSupported);
402 if (Status == STATUS_SUCCESS && bSupported)
403 {
404 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
405 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
406 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
407 if (Status == STATUS_SUCCESS)
408 {
409 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
410 }
411 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
412 {
413 Status = STATUS_SUCCESS;
414 break;
415 }
416 else
417 {
418 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
419 break;
420 }
421 }
422 else
423 {
424 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
425 break;
426 }
427 }
428 }
429 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
430 Status = STATUS_SUCCESS;
431 else
432 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
433
434 *pbSupported = bSupported;
435 return Status;
436}
437
438#if 0
439DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeCheck(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
440 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
441 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
442{
443 NTSTATUS Status = STATUS_SUCCESS;
444 PVBOXVIDPN_NEW_SRCMODESET_CHECK pCbContext = (PVBOXVIDPN_NEW_SRCMODESET_CHECK)pContext;
445 pCbContext->CommonInfo.Status = STATUS_SUCCESS;
446
447 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
448
449 pCbContext->CommonInfo.Status = Status;
450 return Status == STATUS_SUCCESS;
451}
452
453DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
454 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
455 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
456{
457 NTSTATUS Status = STATUS_SUCCESS;
458 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
459 pCbContext->Status = STATUS_SUCCESS;
460
461 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
462
463 pCbContext->Status = Status;
464 return Status == STATUS_SUCCESS;
465}
466
467DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityTargetModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
468 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
469 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
470{
471 NTSTATUS Status = STATUS_SUCCESS;
472 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
473 pCbContext->Status = STATUS_SUCCESS;
474
475 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
476
477 pCbContext->Status = Status;
478 return Status == STATUS_SUCCESS;
479}
480#endif
481
482NTSTATUS vboxVidPnPopulateSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
483 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
484 VIDEO_MODE_INFORMATION *pMode)
485{
486 NTSTATUS Status = STATUS_SUCCESS;
487 if (pMode->AttributeFlags & VIDEO_MODE_GRAPHICS)
488 {
489 /* this is a graphics mode */
490 pNewVidPnSourceModeInfo->Type = D3DKMDT_RMT_GRAPHICS;
491 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx = pMode->VisScreenWidth;
492 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy = pMode->VisScreenHeight;
493 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
494 pNewVidPnSourceModeInfo->Format.Graphics.Stride = pMode->ScreenStride;
495 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat = vboxWddmCalcPixelFormat(pMode);
496 Assert(pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN);
497 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN)
498 {
499 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis = D3DKMDT_CB_SRGB;
500 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat == D3DDDIFMT_P8)
501 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_SETTABLEPALETTE;
502 else
503 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_DIRECT;
504 }
505 else
506 {
507 drprintf((__FUNCTION__": vboxWddmCalcPixelFormat failed\n"));
508 Status = STATUS_INVALID_PARAMETER;
509 }
510 }
511 else
512 {
513 /* @todo: XPDM driver does not seem to return text modes, should we? */
514 drprintf((__FUNCTION__": text mode not supported currently\n"));
515 AssertBreakpoint();
516 Status = STATUS_INVALID_PARAMETER;
517 }
518
519 return Status;
520}
521
522NTSTATUS vboxVidPnPopulateSourceModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
523 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet,
524 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface,
525 VIDEO_MODE_INFORMATION *pModes,
526 uint32_t cModes,
527 int iPreferredMode,
528 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID *pPreferredModeId)
529{
530 NTSTATUS Status = STATUS_SUCCESS;
531 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID PreferredModeId = D3DDDI_ID_UNINITIALIZED;
532 for (uint32_t i = 0; i < cModes; ++i)
533 {
534 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
535 /* disable 24 bpp for now */
536 if (pModes[i].BitsPerPlane == 24)
537 continue;
538
539 Status = pNewVidPnSourceModeSetInterface->pfnCreateNewModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
540 Assert(Status == STATUS_SUCCESS);
541 if (Status == STATUS_SUCCESS)
542 {
543 Status = vboxVidPnPopulateSourceModeInfoFromLegacy(pDevExt, pNewVidPnSourceModeInfo, &pModes[i]);
544 Assert(Status == STATUS_SUCCESS);
545 if (Status == STATUS_SUCCESS)
546 {
547 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnSourceModeInfo->Id;
548 Status = pNewVidPnSourceModeSetInterface->pfnAddMode(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
549 Assert(Status == STATUS_SUCCESS);
550 if (Status == STATUS_SUCCESS)
551 {
552 if (iPreferredMode == i)
553 {
554 PreferredModeId = modeId;
555// AssertBreakpoint();
556// Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, modeId);
557// Assert(Status == STATUS_SUCCESS);
558// if (Status != STATUS_SUCCESS)
559// {
560// drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
561// /* don't treat it as fatal */
562// Status = STATUS_SUCCESS;
563// }
564 }
565 }
566 else
567 {
568 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
569 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
570 break;
571 }
572 }
573 else
574 {
575 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
576 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
577 break;
578 }
579 }
580 }
581
582 if (pPreferredModeId)
583 *pPreferredModeId = PreferredModeId;
584
585 return Status;
586}
587
588NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
589 D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
590 D3DKMDT_2DREGION *pResolution,
591 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
592 BOOLEAN bPreferred)
593{
594 NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(&pMonitorSourceMode->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
595 Assert(Status == STATUS_SUCCESS);
596 if (Status == STATUS_SUCCESS)
597 {
598 pMonitorSourceMode->ColorBasis = D3DKMDT_CB_SRGB;
599 pMonitorSourceMode->ColorCoeffDynamicRanges.FirstChannel = 8;
600 pMonitorSourceMode->ColorCoeffDynamicRanges.SecondChannel = 8;
601 pMonitorSourceMode->ColorCoeffDynamicRanges.ThirdChannel = 8;
602 pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0;
603 pMonitorSourceMode->Origin = enmOrigin;
604 pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
605 }
606
607 return Status;
608}
609
610NTSTATUS vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
611 CONST D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS,
612 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
613 D3DKMDT_2DREGION *pResolution,
614 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
615 BOOLEAN bPreferred)
616{
617 D3DKMDT_MONITOR_SOURCE_MODE * pMonitorSMI;
618 NTSTATUS Status = pMonitorSMSIf->pfnCreateNewModeInfo(hMonitorSMS, &pMonitorSMI);
619 Assert(Status == STATUS_SUCCESS);
620 if (Status == STATUS_SUCCESS)
621 {
622 do
623 {
624 Status = vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(pDevExt,
625 pMonitorSMI,
626 pResolution,
627 enmOrigin,
628 bPreferred);
629 Assert(Status == STATUS_SUCCESS);
630 if (Status == STATUS_SUCCESS)
631 {
632 Status = pMonitorSMSIf->pfnAddMode(hMonitorSMS, pMonitorSMI);
633 Assert(Status == STATUS_SUCCESS);
634 if (Status == STATUS_SUCCESS)
635 break;
636 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
637 }
638 else
639 drprintf((__FUNCTION__": vboxVidPnPopulateMonitorSourceModeInfoFromLegacy failed, Status(0x%x)", Status));
640
641 Assert (Status != STATUS_SUCCESS);
642 /* we're here because of a failure */
643 NTSTATUS tmpStatus = pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI);
644 Assert(tmpStatus == STATUS_SUCCESS);
645 if (tmpStatus != STATUS_SUCCESS)
646 drprintf((__FUNCTION__": pfnReleaseModeInfo failed tmpStatus(0x%x)\n", tmpStatus));
647 } while (0);
648 }
649 else
650 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
651
652 return Status;
653}
654
655NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
656 D3DKMDT_2DREGION *pResolution,
657 BOOLEAN bPreferred)
658{
659 Assert(!bPreferred);
660 pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
661
662 return vboxVidPnPopulateVideoSignalInfo(&pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
663}
664
665#define VBOXVIDPN_MODESET_NO_PIN_PREFERRED 0x00000001
666#define VBOXVIDPN_MODESET_MARK_PREFERRED 0x00000002
667
668NTSTATUS vboxVidPnPopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
669 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet,
670 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface,
671 D3DKMDT_2DREGION *pResolutions,
672 uint32_t cResolutions,
673 VIDEO_MODE_INFORMATION *pPreferredMode,
674 uint32_t fFlags,
675 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID *pPreferredModeId)
676{
677 NTSTATUS Status = STATUS_SUCCESS;
678 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID PreferredModeId = D3DDDI_ID_UNINITIALIZED;
679 for (uint32_t i = 0; i < cResolutions; ++i)
680 {
681 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
682 Status = pNewVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
683 Assert(Status == STATUS_SUCCESS);
684 if (Status == STATUS_SUCCESS)
685 {
686 bool bPreferred = pPreferredMode ? pPreferredMode->VisScreenWidth == pResolutions[i].cx
687 && pPreferredMode->VisScreenHeight == pResolutions[i].cy : FALSE;
688 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, &pResolutions[i], bPreferred && (fFlags & VBOXVIDPN_MODESET_MARK_PREFERRED));
689 Assert(Status == STATUS_SUCCESS);
690 if (Status == STATUS_SUCCESS)
691 {
692 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnTargetModeInfo->Id;
693 Status = pNewVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
694 Assert(Status == STATUS_SUCCESS);
695 if (Status == STATUS_SUCCESS)
696 {
697 if (bPreferred) // && !(fFlags & VBOXVIDPN_MODESET_NO_PIN_PREFERRED))
698 {
699 PreferredModeId = modeId;
700// AssertBreakpoint();
701// Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
702// Assert(Status == STATUS_SUCCESS);
703// if (Status != STATUS_SUCCESS)
704// {
705// drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
706// /* don't treat it as fatal */
707// Status = STATUS_SUCCESS;
708// }
709 }
710 }
711 else
712 {
713 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
714 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
715 break;
716 }
717 }
718 else
719 {
720 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
721 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
722 break;
723 }
724 }
725 }
726
727 if (pPreferredModeId)
728 *pPreferredModeId = PreferredModeId;
729 return Status;
730}
731
732NTSTATUS vboxVidPnCreatePopulateSourceModeSetFromLegacy(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
733 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId,
734 VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, int iPreferredMode, D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID *pPreferredModeId)
735{
736 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
737 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
738 NTSTATUS Status = pVidPnInterface->pfnCreateNewSourceModeSet(hDesiredVidPn,
739 srcId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
740 &hNewVidPnSourceModeSet,
741 &pNewVidPnSourceModeSetInterface);
742 Assert(Status == STATUS_SUCCESS);
743 if (Status == STATUS_SUCCESS)
744 {
745 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
746 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
747 pModes, cModes, iPreferredMode, pPreferredModeId);
748 Assert(Status == STATUS_SUCCESS);
749 if (Status == STATUS_SUCCESS)
750 {
751 Status = pVidPnInterface->pfnAssignSourceModeSet(hDesiredVidPn,
752 srcId,
753 hNewVidPnSourceModeSet);
754 Assert(Status == STATUS_SUCCESS);
755 if(Status != STATUS_SUCCESS)
756 {
757 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
758 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
759 }
760 }
761 else
762 {
763 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
764 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
765 }
766 }
767 else
768 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
769 return Status;
770}
771
772NTSTATUS vboxVidPnCreatePopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
773 D3DDDI_VIDEO_PRESENT_TARGET_ID tgtId,
774 D3DKMDT_2DREGION *pResolutions,
775 uint32_t cResolutions,
776 VIDEO_MODE_INFORMATION *pPreferredMode, uint32_t fFlags,
777 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID *pPreferredModeId)
778{
779 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
780 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
781 NTSTATUS Status = pVidPnInterface->pfnCreateNewTargetModeSet(hDesiredVidPn,
782 tgtId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
783 &hNewVidPnTargetModeSet,
784 &pNewVidPnTargetModeSetInterface);
785 Assert(Status == STATUS_SUCCESS);
786 if (Status == STATUS_SUCCESS)
787 {
788 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
789 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
790 pResolutions, cResolutions, pPreferredMode, fFlags, pPreferredModeId);
791 Assert(Status == STATUS_SUCCESS);
792 if (Status == STATUS_SUCCESS)
793 {
794 Status = pVidPnInterface->pfnAssignTargetModeSet(hDesiredVidPn,
795 tgtId,
796 hNewVidPnTargetModeSet);
797 Assert(Status == STATUS_SUCCESS);
798 if(Status != STATUS_SUCCESS)
799 {
800 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
801 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
802 }
803 }
804 else
805 {
806 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
807 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
808 }
809 }
810 else
811 drprintf((__FUNCTION__": pfnCreateNewTargetModeSet failed Status(0x%x)\n", Status));
812 return Status;
813
814}
815
816typedef struct VBOXVIDPNCHECKADDMONITORMODES
817{
818 NTSTATUS Status;
819 D3DKMDT_2DREGION *pResolutions;
820 uint32_t cResolutions;
821} VBOXVIDPNCHECKADDMONITORMODES, *PVBOXVIDPNCHECKADDMONITORMODES;
822
823static DECLCALLBACK(BOOLEAN) vboxVidPnCheckAddMonitorModesEnum(struct _DEVICE_EXTENSION* pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
824 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI, PVOID pContext)
825{
826 PVBOXVIDPNCHECKADDMONITORMODES pData = (PVBOXVIDPNCHECKADDMONITORMODES)pContext;
827 NTSTATUS Status = STATUS_SUCCESS;
828
829 for (uint32_t i = 0; i < pData->cResolutions; ++i)
830 {
831 D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
832 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &pData->pResolutions[i], FALSE);
833 Assert(Status == STATUS_SUCCESS);
834 if (Status == STATUS_SUCCESS)
835 {
836 if (vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pMonitorSMI->VideoSignalInfo))
837 {
838 /* mark it as unneeded */
839 pData->pResolutions[i].cx = 0;
840 break;
841 }
842 }
843 else
844 {
845 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x)\n", Status));
846 break;
847 }
848 }
849
850 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI);
851
852 pData->Status = Status;
853
854 return Status == STATUS_SUCCESS;
855}
856
857NTSTATUS vboxVidPnCheckAddMonitorModes(PDEVICE_EXTENSION pDevExt,
858 D3DDDI_VIDEO_PRESENT_TARGET_ID targetId, D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
859 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, int32_t iPreferred)
860{
861 NTSTATUS Status;
862 D3DKMDT_2DREGION *pResolutionsCopy = (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cResolutions * sizeof (D3DKMDT_2DREGION));
863 if (pResolutionsCopy)
864 {
865 memcpy(pResolutionsCopy, pResolutions, cResolutions * sizeof (D3DKMDT_2DREGION));
866 CONST DXGK_MONITOR_INTERFACE *pMonitorInterface;
867 Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface);
868 Assert(Status == STATUS_SUCCESS);
869 if (Status == STATUS_SUCCESS)
870 {
871 D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
872 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
873 Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
874 targetId,
875 &hMonitorSMS,
876 &pMonitorSMSIf);
877 Assert(Status == STATUS_SUCCESS);
878 if (Status == STATUS_SUCCESS)
879 {
880 VBOXVIDPNCHECKADDMONITORMODES EnumData = {0};
881 EnumData.cResolutions = cResolutions;
882 EnumData.pResolutions = pResolutionsCopy;
883 Status = vboxVidPnEnumMonitorSourceModes(pDevExt, hMonitorSMS, pMonitorSMSIf,
884 vboxVidPnCheckAddMonitorModesEnum, &EnumData);
885 Assert(Status == STATUS_SUCCESS);
886 if (Status == STATUS_SUCCESS)
887 {
888 Assert(EnumData.Status == STATUS_SUCCESS);
889 if (EnumData.Status == STATUS_SUCCESS)
890 {
891 for (uint32_t i = 0; i < cResolutions; ++i)
892 {
893 D3DKMDT_2DREGION *pRes = &pResolutionsCopy[i];
894 if (pRes->cx)
895 {
896 Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt,
897 hMonitorSMS,
898 pMonitorSMSIf,
899 pRes,
900 enmOrigin,
901 i == (uint32_t)iPreferred);
902 Assert(Status == STATUS_SUCCESS);
903 if (Status != STATUS_SUCCESS)
904 {
905 drprintf((__FUNCTION__": vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)\n", Status));
906 break;
907 }
908 }
909 }
910 }
911 }
912
913 NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
914 Assert(tmpStatus == STATUS_SUCCESS);
915 if (tmpStatus != STATUS_SUCCESS)
916 drprintf((__FUNCTION__": pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)\n", tmpStatus));
917 }
918 else
919 drprintf((__FUNCTION__": pfnAcquireMonitorSourceModeSet failed Status(0x%x)\n", Status));
920 }
921 else
922 drprintf((__FUNCTION__": DxgkCbQueryMonitorInterface failed Status(0x%x)\n", Status));
923
924 vboxWddmMemFree(pResolutionsCopy);
925 }
926 else
927 {
928 drprintf((__FUNCTION__": failed to allocate resolution copy of size (%d)\n", cResolutions));
929 Status = STATUS_NO_MEMORY;
930 }
931
932 return Status;
933}
934
935NTSTATUS vboxVidPnCreatePopulateVidPnFromLegacy(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
936 VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, int iPreferredMode,
937 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions,
938 const D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, const D3DDDI_VIDEO_PRESENT_TARGET_ID tgtId)
939{
940 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
941 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
942 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
943 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID PreferredSrcModeId = D3DDDI_ID_UNINITIALIZED;
944 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
945 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
946
947 NTSTATUS Status = pVidPnInterface->pfnCreateNewSourceModeSet(hVidPn,
948 srcId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
949 &hNewVidPnSourceModeSet,
950 &pNewVidPnSourceModeSetInterface);
951 Assert(Status == STATUS_SUCCESS);
952 if (Status == STATUS_SUCCESS)
953 {
954 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
955 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
956 pModes, cModes, iPreferredMode, &PreferredSrcModeId);
957 Assert(Status == STATUS_SUCCESS);
958 if (Status == STATUS_SUCCESS)
959 {
960 Status = pVidPnInterface->pfnAssignSourceModeSet(hVidPn,
961 srcId,
962 hNewVidPnSourceModeSet);
963 Assert(Status == STATUS_SUCCESS);
964 if(Status == STATUS_SUCCESS)
965 {
966 Assert(PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED);
967 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID PreferredTrgModeId = D3DDDI_ID_UNINITIALIZED;
968 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
969 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
970 NTSTATUS Status = pVidPnInterface->pfnCreateNewTargetModeSet(hVidPn,
971 tgtId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
972 &hNewVidPnTargetModeSet,
973 &pNewVidPnTargetModeSetInterface);
974 Assert(Status == STATUS_SUCCESS);
975 if (Status == STATUS_SUCCESS)
976 {
977 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
978 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
979 pResolutions, cResolutions, pPreferredMode, 0, &PreferredTrgModeId);
980 Assert(Status == STATUS_SUCCESS);
981 if (Status == STATUS_SUCCESS)
982 {
983 Status = pVidPnInterface->pfnAssignTargetModeSet(hVidPn,
984 tgtId,
985 hNewVidPnTargetModeSet);
986 Assert(Status == STATUS_SUCCESS);
987 if(Status == STATUS_SUCCESS)
988 {
989
990 Assert(PreferredTrgModeId != D3DDDI_ID_UNINITIALIZED);
991 Status = pVidPnInterface->pfnGetTopology(hVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
992 if (Status == STATUS_SUCCESS)
993 {
994 D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo;
995 Status = pVidPnTopologyInterface->pfnCreateNewPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
996 if (Status == STATUS_SUCCESS)
997 {
998 pNewVidPnPresentPathInfo->VidPnSourceId = 0;
999 pNewVidPnPresentPathInfo->VidPnTargetId = 0;
1000 pNewVidPnPresentPathInfo->ImportanceOrdinal = D3DKMDT_VPPI_PRIMARY;
1001 pNewVidPnPresentPathInfo->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
1002 memset(&pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport,
1003 0, sizeof (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport));
1004 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity = 1;
1005 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered = 0;
1006 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched = 0;
1007 pNewVidPnPresentPathInfo->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
1008 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity = 1;
1009 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180 = 0;
1010 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270 = 0;
1011 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90 = 0;
1012 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx = 0;
1013 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy = 0;
1014 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx = 0;
1015 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy = 0;
1016 pNewVidPnPresentPathInfo->VidPnTargetColorBasis = D3DKMDT_CB_SRGB; /* @todo: how does it matters? */
1017 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel = 8;
1018 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel = 8;
1019 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel = 8;
1020 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel = 0;
1021 pNewVidPnPresentPathInfo->Content = D3DKMDT_VPPC_GRAPHICS;
1022 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_UNINITIALIZED;
1023 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_NOPROTECTION;
1024 pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits = 0;
1025 memset(&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, 0, sizeof (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport));
1026 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport.NoProtection = 1;
1027 memset (&pNewVidPnPresentPathInfo->GammaRamp, 0, sizeof (pNewVidPnPresentPathInfo->GammaRamp));
1028 // pNewVidPnPresentPathInfo->GammaRamp.Type = D3DDDI_GAMMARAMP_DEFAULT;
1029 // pNewVidPnPresentPathInfo->GammaRamp.DataSize = 0;
1030 Status = pVidPnTopologyInterface->pfnAddPath(hVidPnTopology, pNewVidPnPresentPathInfo);
1031 Assert(Status == STATUS_SUCCESS);
1032 if (Status == STATUS_SUCCESS)
1033 {
1034 if (PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED)
1035 {
1036 Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, PreferredSrcModeId);
1037 Assert(Status == STATUS_SUCCESS);
1038 if (Status == STATUS_SUCCESS)
1039 {
1040 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, PreferredTrgModeId);
1041 Assert(Status == STATUS_SUCCESS);
1042 if (Status != STATUS_SUCCESS)
1043 drprintf((__FUNCTION__": TRG pfnPinMode failed Status(0x%x)\n", Status));
1044 }
1045 else
1046 drprintf((__FUNCTION__": SRC pfnPinMode failed Status(0x%x)\n", Status));
1047 }
1048 }
1049 else
1050 {
1051 drprintf((__FUNCTION__": pfnAddPath failed Status(0x%x)\n", Status));
1052 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1053 pNewVidPnPresentPathInfo = NULL;
1054 }
1055 }
1056 else
1057 drprintf((__FUNCTION__": pfnCreateNewPathInfo failed Status(0x%x)\n", Status));
1058 }
1059 else
1060 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1061 }
1062 else
1063 {
1064 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
1065 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1066 }
1067 }
1068 else
1069 {
1070 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1071 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1072 }
1073 }
1074 else
1075 drprintf((__FUNCTION__": pfnCreateNewTargetModeSet failed Status(0x%x)\n", Status));
1076 }
1077 else
1078 {
1079 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
1080 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1081 }
1082 }
1083 else
1084 {
1085 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1086 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1087 }
1088 }
1089 else
1090 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
1091
1092 return Status;
1093}
1094
1095DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1096 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1097 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
1098{
1099 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
1100 NTSTATUS Status = STATUS_SUCCESS;
1101 pCbContext->Status = STATUS_SUCCESS;
1102 PVBOXWDDM_VIDEOMODES_INFO pInfo = &pCbContext->pInfos[pNewVidPnPresentPathInfo->VidPnTargetId];
1103 VIDEO_MODE_INFORMATION *pModes = pInfo->aModes;
1104 uint32_t cModes = pInfo->cModes;
1105 /* we do not want the mode to be pinned */
1106 int iPreferredMode = -1; /* pInfo->iPreferredMode; */
1107 uint32_t cResolutions = pInfo->cResolutions;
1108 D3DKMDT_2DREGION * pResolutions = pInfo->aResolutions;
1109
1110
1111 /* adjust scaling */
1112 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
1113 {
1114 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
1115 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
1116 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED
1117 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
1118 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
1119 {
1120 AssertBreakpoint();
1121 /* todo: create a new path (if not done already) and assign a proper info */
1122 }
1123 }
1124
1125 /* adjust rotation */
1126 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
1127 {
1128 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
1129 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
1130 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
1131 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270
1132 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED)
1133 {
1134 AssertBreakpoint();
1135 /* todo: create a new path (if not done already) and assign a proper info */
1136 }
1137 }
1138
1139 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1140 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1141 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
1142
1143 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1144 pNewVidPnPresentPathInfo->VidPnSourceId,
1145 &hCurVidPnSourceModeSet,
1146 &pCurVidPnSourceModeSetInterface);
1147 Assert(Status == STATUS_SUCCESS);
1148 if (Status == STATUS_SUCCESS)
1149 {
1150 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1151 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1152 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1153 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1154 {
1155 pPinnedVidPnSourceModeInfo = NULL;
1156 Status = STATUS_SUCCESS;
1157 }
1158 else if (Status != STATUS_SUCCESS)
1159 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1160
1161 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
1162 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
1163 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn,
1164 pNewVidPnPresentPathInfo->VidPnTargetId,
1165 &hCurVidPnTargetModeSet,
1166 &pCurVidPnTargetModeSetInterface);
1167 Assert(Status == STATUS_SUCCESS);
1168 if (Status == STATUS_SUCCESS)
1169 {
1170 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1171 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1172 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1173 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1174 {
1175 pPinnedVidPnTargetModeInfo = NULL;
1176 Status = STATUS_SUCCESS;
1177 }
1178 else if (Status != STATUS_SUCCESS)
1179 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1180
1181 switch (pCbContext->pEnumCofuncModalityArg->EnumPivotType)
1182 {
1183 case D3DKMDT_EPT_VIDPNSOURCE:
1184 if (!pPinnedVidPnTargetModeInfo)
1185 {
1186 if (pPinnedVidPnSourceModeInfo)
1187 {
1188 SIZE_T cModes;
1189 Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cModes);
1190 Assert(Status == STATUS_SUCCESS);
1191 if (Status == STATUS_SUCCESS)
1192 {
1193 D3DKMDT_2DREGION Resolution;
1194 Resolution.cx = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx;
1195 Resolution.cy = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy;
1196 BOOLEAN bCreateTrg = FALSE;
1197 if (cModes == 1)
1198 {
1199 const D3DKMDT_VIDPN_TARGET_MODE *pVidPnTargetModeInfo;
1200 Status = pCurVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hCurVidPnTargetModeSet, &pVidPnTargetModeInfo);
1201 Assert(Status == STATUS_SUCCESS);
1202 if (Status == STATUS_SUCCESS)
1203 {
1204 D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
1205 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &Resolution, FALSE);
1206 Assert(Status == STATUS_SUCCESS);
1207 if (Status == STATUS_SUCCESS)
1208 {
1209 if (!vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pVidPnTargetModeInfo->VideoSignalInfo))
1210 bCreateTrg = TRUE;
1211 else
1212 {
1213 /* do we need to check pVidPnTargetModeInfo->Preference; ? */
1214 }
1215 }
1216 else
1217 {
1218 drprintf((__FUNCTION__": trg vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x), pretending success\n", Status));
1219 Status = STATUS_SUCCESS;
1220 bCreateTrg = TRUE;
1221 }
1222 }
1223 else
1224 drprintf((__FUNCTION__": trg pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1225 }
1226 else
1227 bCreateTrg = TRUE;
1228
1229 if (bCreateTrg)
1230 {
1231 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1232 pNewVidPnPresentPathInfo->VidPnTargetId,
1233 &Resolution,
1234 1,
1235 pPreferredMode,
1236 0,
1237 NULL);
1238 Assert(Status == STATUS_SUCCESS);
1239 if (Status != STATUS_SUCCESS)
1240 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy for pinned source failed Status(0x%x)\n", Status)); }
1241 }
1242 else
1243 drprintf((__FUNCTION__": trg pfnGetNumModes failed Status(0x%x)\n", Status));
1244 }
1245 else
1246 {
1247 dprintf((__FUNCTION__": source pivot w/o pinned source mode\n"));
1248// AssertBreakpoint();
1249 }
1250 }
1251 break;
1252 case D3DKMDT_EPT_VIDPNTARGET:
1253 break;
1254 case D3DKMDT_EPT_SCALING:
1255 break;
1256 case D3DKMDT_EPT_ROTATION:
1257 break;
1258 case D3DKMDT_EPT_NOPIVOT:
1259 /* just create and populate the new source mode set for now */
1260 Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1261 pNewVidPnPresentPathInfo->VidPnSourceId,
1262 pModes, cModes, iPreferredMode, NULL);
1263 Assert(Status == STATUS_SUCCESS);
1264 if (Status == STATUS_SUCCESS)
1265 {
1266 /* just create and populate a new target mode info for now */
1267 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1268 pNewVidPnPresentPathInfo->VidPnTargetId,
1269 pResolutions,
1270 cResolutions,
1271 pPreferredMode,
1272 0,
1273 NULL);
1274 Assert(Status == STATUS_SUCCESS);
1275 if (Status != STATUS_SUCCESS)
1276 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1277 }
1278 else
1279 drprintf((__FUNCTION__": vboxVidPnCreatePopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1280
1281 break;
1282 default:
1283 drprintf((__FUNCTION__": unknown EnumPivotType (%dx)\n", pCbContext->pEnumCofuncModalityArg->EnumPivotType));
1284 break;
1285 }
1286
1287 if (pPinnedVidPnTargetModeInfo)
1288 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1289 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
1290 }
1291 else
1292 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1293
1294 if (pPinnedVidPnSourceModeInfo)
1295 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1296 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1297 }
1298 else
1299 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1300
1301 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1302
1303 pCbContext->Status = Status;
1304 Assert(Status == STATUS_SUCCESS);
1305 return Status == STATUS_SUCCESS;
1306}
1307
1308NTSTATUS vboxVidPnEnumMonitorSourceModes(PDEVICE_EXTENSION pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
1309 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext)
1310{
1311 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI;
1312 NTSTATUS Status = pMonitorSMSIf->pfnAcquireFirstModeInfo(hMonitorSMS, &pMonitorSMI);
1313 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_DATASET_IS_EMPTY);
1314 if (Status == STATUS_SUCCESS)
1315 {
1316 Assert(pMonitorSMI);
1317 while (1)
1318 {
1319 CONST D3DKMDT_MONITOR_SOURCE_MODE *pNextMonitorSMI;
1320 Status = pMonitorSMSIf->pfnAcquireNextModeInfo(hMonitorSMS, pMonitorSMI, &pNextMonitorSMI);
1321 if (!pfnCallback(pDevExt, hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext))
1322 {
1323 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1324 if (Status == STATUS_SUCCESS)
1325 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pNextMonitorSMI);
1326 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1327 {
1328 Status = STATUS_SUCCESS;
1329 break;
1330 }
1331 else
1332 {
1333 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1334 Status = STATUS_SUCCESS;
1335 }
1336 break;
1337 }
1338 else if (Status == STATUS_SUCCESS)
1339 pMonitorSMI = pNextMonitorSMI;
1340 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1341 {
1342 Status = STATUS_SUCCESS;
1343 break;
1344 }
1345 else
1346 {
1347 AssertBreakpoint();
1348 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1349 pNextMonitorSMI = NULL;
1350 break;
1351 }
1352 }
1353 }
1354 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1355 Status = STATUS_SUCCESS;
1356 else
1357 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1358
1359 return Status;
1360}
1361
1362NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1363 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
1364 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
1365{
1366 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1367 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1368 if (Status == STATUS_SUCCESS)
1369 {
1370 Assert(pNewVidPnSourceModeInfo);
1371 while (1)
1372 {
1373 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
1374 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
1375 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1376 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
1377 pNewVidPnSourceModeInfo, pContext))
1378 {
1379 Assert(Status == STATUS_SUCCESS);
1380 if (Status == STATUS_SUCCESS)
1381 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
1382 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1383 {
1384 Status = STATUS_SUCCESS;
1385 break;
1386 }
1387 else
1388 {
1389 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1390 Status = STATUS_SUCCESS;
1391 }
1392
1393 break;
1394 }
1395 else if (Status == STATUS_SUCCESS)
1396 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
1397 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1398 {
1399 Status = STATUS_SUCCESS;
1400 break;
1401 }
1402 else
1403 {
1404 AssertBreakpoint();
1405 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1406 pNewVidPnSourceModeInfo = NULL;
1407 break;
1408 }
1409 }
1410 }
1411 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1412 Status = STATUS_SUCCESS;
1413 else
1414 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1415
1416 return Status;
1417}
1418
1419NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1420 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
1421 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
1422{
1423 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
1424 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
1425 if (Status == STATUS_SUCCESS)
1426 {
1427 Assert(pNewVidPnTargetModeInfo);
1428 while (1)
1429 {
1430 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
1431 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
1432 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1433 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
1434 pNewVidPnTargetModeInfo, pContext))
1435 {
1436 Assert(Status == STATUS_SUCCESS);
1437 if (Status == STATUS_SUCCESS)
1438 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
1439 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1440 {
1441 Status = STATUS_SUCCESS;
1442 break;
1443 }
1444 else
1445 {
1446 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1447 Status = STATUS_SUCCESS;
1448 }
1449
1450 break;
1451 }
1452 else if (Status == STATUS_SUCCESS)
1453 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
1454 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1455 {
1456 Status = STATUS_SUCCESS;
1457 break;
1458 }
1459 else
1460 {
1461 AssertBreakpoint();
1462 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1463 pNewVidPnTargetModeInfo = NULL;
1464 break;
1465 }
1466 }
1467 }
1468 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1469 Status = STATUS_SUCCESS;
1470 else
1471 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1472
1473 return Status;
1474}
1475
1476NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1477 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
1478 PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext)
1479{
1480 SIZE_T cTgtPaths;
1481 NTSTATUS Status = pVidPnTopologyInterface->pfnGetNumPathsFromSource(hVidPnTopology, VidPnSourceId, &cTgtPaths);
1482 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1483 if (Status == STATUS_SUCCESS)
1484 {
1485 for (SIZE_T i = 0; i < cTgtPaths; ++i)
1486 {
1487 D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId;
1488 Status = pVidPnTopologyInterface->pfnEnumPathTargetsFromSource(hVidPnTopology, VidPnSourceId, i, &VidPnTargetId);
1489 Assert(Status == STATUS_SUCCESS);
1490 if (Status == STATUS_SUCCESS)
1491 {
1492 if (!pfnCallback(pDevExt, hVidPnTopology, pVidPnTopologyInterface, VidPnSourceId, VidPnTargetId, cTgtPaths, pContext))
1493 break;
1494 }
1495 else
1496 {
1497 drprintf((__FUNCTION__": pfnEnumPathTargetsFromSource failed Status(0x%x)\n", Status));
1498 break;
1499 }
1500 }
1501 }
1502 else if (Status != STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1503 drprintf((__FUNCTION__": pfnGetNumPathsFromSource failed Status(0x%x)\n", Status));
1504
1505 return Status;
1506}
1507
1508NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1509 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1510 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
1511{
1512 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
1513 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1514 if (Status == STATUS_SUCCESS)
1515 {
1516 while (1)
1517 {
1518 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
1519 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
1520
1521 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
1522 {
1523 Assert(Status == STATUS_SUCCESS);
1524 if (Status == STATUS_SUCCESS)
1525 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
1526 else
1527 {
1528 Assert(Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1529 if (Status != STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1530 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1531 Status = STATUS_SUCCESS;
1532 }
1533
1534 break;
1535 }
1536 else if (Status == STATUS_SUCCESS)
1537 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
1538 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1539 {
1540 Status = STATUS_SUCCESS;
1541 break;
1542 }
1543 else
1544 {
1545 AssertBreakpoint();
1546 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
1547 pNewVidPnPresentPathInfo = NULL;
1548 break;
1549 }
1550 }
1551 }
1552 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1553 Status = STATUS_SUCCESS;
1554 else
1555 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1556
1557 return Status;
1558}
1559
1560NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1561{
1562 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, srcId);
1563 return STATUS_SUCCESS;
1564}
1565
1566NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1567{
1568 Assert(srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays);
1569 if (srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays)
1570 {
1571 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[srcId];
1572 return vboxVidPnSetupSourceInfo(pDevExt, srcId, pSource, pVidPnSourceModeInfo, pAllocation);
1573 }
1574
1575 drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, commonFromDeviceExt(pDevExt)->cDisplays));
1576 return STATUS_INVALID_PARAMETER;
1577}
1578
1579typedef struct VBOXVIDPNCOMMITTARGETMODE
1580{
1581 NTSTATUS Status;
1582 D3DKMDT_HVIDPN hVidPn;
1583 const DXGK_VIDPN_INTERFACE* pVidPnInterface;
1584} VBOXVIDPNCOMMITTARGETMODE;
1585
1586DECLCALLBACK(BOOLEAN) vboxVidPnCommitTargetModeEnum(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1587 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext)
1588{
1589 VBOXVIDPNCOMMITTARGETMODE *pInfo = (VBOXVIDPNCOMMITTARGETMODE*)pContext;
1590 Assert(cTgtPaths <= (SIZE_T)commonFromDeviceExt(pDevExt)->cDisplays);
1591 D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet;
1592 CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface;
1593 NTSTATUS Status = pInfo->pVidPnInterface->pfnAcquireTargetModeSet(pInfo->hVidPn, VidPnTargetId, &hVidPnTargetModeSet, &pVidPnTargetModeSetInterface);
1594 Assert(Status == STATUS_SUCCESS);
1595 if (Status == STATUS_SUCCESS)
1596 {
1597 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1598 Status = pVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1599 Assert(Status == STATUS_SUCCESS);
1600 if (Status == STATUS_SUCCESS)
1601 {
1602 VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[VidPnTargetId];
1603 if (pTarget->HeightVisible != pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy
1604 || pTarget->HeightTotal != pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
1605 {
1606 pTarget->HeightVisible = pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
1607 pTarget->HeightTotal = pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy;
1608 pTarget->ScanLineState = 0;
1609 }
1610 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1611 }
1612
1613 pInfo->pVidPnInterface->pfnReleaseTargetModeSet(pInfo->hVidPn, hVidPnTargetModeSet);
1614 }
1615 else
1616 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1617
1618 pInfo->Status = Status;
1619 return Status == STATUS_SUCCESS;
1620}
1621
1622NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
1623{
1624 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1625 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1626
1627 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1628 srcId,
1629 &hCurVidPnSourceModeSet,
1630 &pCurVidPnSourceModeSetInterface);
1631 Assert(Status == STATUS_SUCCESS);
1632 if (Status == STATUS_SUCCESS)
1633 {
1634 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1635 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1636 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1637 if (Status == STATUS_SUCCESS)
1638 {
1639 Assert(pPinnedVidPnSourceModeInfo);
1640 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, pPinnedVidPnSourceModeInfo, pAllocation);
1641 Assert(Status == STATUS_SUCCESS);
1642 if (Status == STATUS_SUCCESS)
1643 {
1644 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1645 CONST DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1646 Status = pVidPnInterface->pfnGetTopology(hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1647 Assert(Status == STATUS_SUCCESS);
1648 if (Status == STATUS_SUCCESS)
1649 {
1650 VBOXVIDPNCOMMITTARGETMODE TgtModeInfo = {0};
1651 TgtModeInfo.Status = STATUS_SUCCESS; /* <- to ensure we're succeeded if no targets are set */
1652 TgtModeInfo.hVidPn = hDesiredVidPn;
1653 TgtModeInfo.pVidPnInterface = pVidPnInterface;
1654 Status = vboxVidPnEnumTargetsForSource(pDevExt, hVidPnTopology, pVidPnTopologyInterface,
1655 srcId,
1656 vboxVidPnCommitTargetModeEnum, &TgtModeInfo);
1657 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1658 if (Status == STATUS_SUCCESS)
1659 {
1660 Status = TgtModeInfo.Status;
1661 Assert(Status == STATUS_SUCCESS);
1662 }
1663 else if (Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1664 {
1665 Status = STATUS_SUCCESS;
1666 }
1667 else
1668 drprintf((__FUNCTION__": vboxVidPnEnumTargetsForSource failed Status(0x%x)\n", Status));
1669 }
1670 else
1671 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1672 }
1673 else
1674 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
1675 /* release */
1676 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1677 }
1678 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1679 {
1680 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, NULL, pAllocation);
1681 Assert(Status == STATUS_SUCCESS);
1682 }
1683 else
1684 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1685
1686 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1687 }
1688 else
1689 {
1690 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1691 }
1692
1693 return Status;
1694}
1695
1696DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1697 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1698 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
1699{
1700 NTSTATUS Status = STATUS_SUCCESS;
1701 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
1702
1703 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
1704 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
1705 {
1706 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
1707 Assert(Status == STATUS_SUCCESS);
1708 if (Status != STATUS_SUCCESS)
1709 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
1710 }
1711
1712 pCommitInfo->Status = Status;
1713 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
1714 return Status == STATUS_SUCCESS;
1715}
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