VirtualBox

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

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

wddm: more multi-monitor fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 82.0 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 = srcId;
999 pNewVidPnPresentPathInfo->VidPnTargetId = tgtId;
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 Assert(!!pPinnedVidPnSourceModeInfo == !!pPinnedVidPnTargetModeInfo);
1260 if (!pPinnedVidPnSourceModeInfo && !pPinnedVidPnTargetModeInfo)
1261 {
1262 /* just create and populate the new source mode set for now */
1263 Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1264 pNewVidPnPresentPathInfo->VidPnSourceId,
1265 pModes, cModes, iPreferredMode, NULL);
1266 Assert(Status == STATUS_SUCCESS);
1267 if (Status == STATUS_SUCCESS)
1268 {
1269 /* just create and populate a new target mode info for now */
1270 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1271 pNewVidPnPresentPathInfo->VidPnTargetId,
1272 pResolutions,
1273 cResolutions,
1274 pPreferredMode,
1275 0,
1276 NULL);
1277 Assert(Status == STATUS_SUCCESS);
1278 if (Status != STATUS_SUCCESS)
1279 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1280 }
1281 else
1282 drprintf((__FUNCTION__": vboxVidPnCreatePopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1283 }
1284 break;
1285 default:
1286 drprintf((__FUNCTION__": unknown EnumPivotType (%dx)\n", pCbContext->pEnumCofuncModalityArg->EnumPivotType));
1287 break;
1288 }
1289
1290 if (pPinnedVidPnTargetModeInfo)
1291 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1292 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
1293 }
1294 else
1295 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1296
1297 if (pPinnedVidPnSourceModeInfo)
1298 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1299 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1300 }
1301 else
1302 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1303
1304 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1305
1306 pCbContext->Status = Status;
1307 Assert(Status == STATUS_SUCCESS);
1308 return Status == STATUS_SUCCESS;
1309}
1310
1311NTSTATUS vboxVidPnEnumMonitorSourceModes(PDEVICE_EXTENSION pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
1312 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext)
1313{
1314 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI;
1315 NTSTATUS Status = pMonitorSMSIf->pfnAcquireFirstModeInfo(hMonitorSMS, &pMonitorSMI);
1316 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_DATASET_IS_EMPTY);
1317 if (Status == STATUS_SUCCESS)
1318 {
1319 Assert(pMonitorSMI);
1320 while (1)
1321 {
1322 CONST D3DKMDT_MONITOR_SOURCE_MODE *pNextMonitorSMI;
1323 Status = pMonitorSMSIf->pfnAcquireNextModeInfo(hMonitorSMS, pMonitorSMI, &pNextMonitorSMI);
1324 if (!pfnCallback(pDevExt, hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext))
1325 {
1326 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1327 if (Status == STATUS_SUCCESS)
1328 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pNextMonitorSMI);
1329 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1330 {
1331 Status = STATUS_SUCCESS;
1332 break;
1333 }
1334 else
1335 {
1336 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1337 Status = STATUS_SUCCESS;
1338 }
1339 break;
1340 }
1341 else if (Status == STATUS_SUCCESS)
1342 pMonitorSMI = pNextMonitorSMI;
1343 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1344 {
1345 Status = STATUS_SUCCESS;
1346 break;
1347 }
1348 else
1349 {
1350 AssertBreakpoint();
1351 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1352 pNextMonitorSMI = NULL;
1353 break;
1354 }
1355 }
1356 }
1357 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1358 Status = STATUS_SUCCESS;
1359 else
1360 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1361
1362 return Status;
1363}
1364
1365NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1366 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
1367 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
1368{
1369 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1370 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1371 if (Status == STATUS_SUCCESS)
1372 {
1373 Assert(pNewVidPnSourceModeInfo);
1374 while (1)
1375 {
1376 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
1377 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
1378 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1379 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
1380 pNewVidPnSourceModeInfo, pContext))
1381 {
1382 Assert(Status == STATUS_SUCCESS);
1383 if (Status == STATUS_SUCCESS)
1384 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
1385 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1386 {
1387 Status = STATUS_SUCCESS;
1388 break;
1389 }
1390 else
1391 {
1392 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1393 Status = STATUS_SUCCESS;
1394 }
1395
1396 break;
1397 }
1398 else if (Status == STATUS_SUCCESS)
1399 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
1400 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1401 {
1402 Status = STATUS_SUCCESS;
1403 break;
1404 }
1405 else
1406 {
1407 AssertBreakpoint();
1408 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1409 pNewVidPnSourceModeInfo = NULL;
1410 break;
1411 }
1412 }
1413 }
1414 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1415 Status = STATUS_SUCCESS;
1416 else
1417 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1418
1419 return Status;
1420}
1421
1422NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1423 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
1424 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
1425{
1426 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
1427 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
1428 if (Status == STATUS_SUCCESS)
1429 {
1430 Assert(pNewVidPnTargetModeInfo);
1431 while (1)
1432 {
1433 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
1434 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
1435 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1436 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
1437 pNewVidPnTargetModeInfo, pContext))
1438 {
1439 Assert(Status == STATUS_SUCCESS);
1440 if (Status == STATUS_SUCCESS)
1441 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
1442 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1443 {
1444 Status = STATUS_SUCCESS;
1445 break;
1446 }
1447 else
1448 {
1449 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1450 Status = STATUS_SUCCESS;
1451 }
1452
1453 break;
1454 }
1455 else if (Status == STATUS_SUCCESS)
1456 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
1457 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1458 {
1459 Status = STATUS_SUCCESS;
1460 break;
1461 }
1462 else
1463 {
1464 AssertBreakpoint();
1465 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1466 pNewVidPnTargetModeInfo = NULL;
1467 break;
1468 }
1469 }
1470 }
1471 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1472 Status = STATUS_SUCCESS;
1473 else
1474 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1475
1476 return Status;
1477}
1478
1479NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1480 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
1481 PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext)
1482{
1483 SIZE_T cTgtPaths;
1484 NTSTATUS Status = pVidPnTopologyInterface->pfnGetNumPathsFromSource(hVidPnTopology, VidPnSourceId, &cTgtPaths);
1485 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1486 if (Status == STATUS_SUCCESS)
1487 {
1488 for (SIZE_T i = 0; i < cTgtPaths; ++i)
1489 {
1490 D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId;
1491 Status = pVidPnTopologyInterface->pfnEnumPathTargetsFromSource(hVidPnTopology, VidPnSourceId, i, &VidPnTargetId);
1492 Assert(Status == STATUS_SUCCESS);
1493 if (Status == STATUS_SUCCESS)
1494 {
1495 if (!pfnCallback(pDevExt, hVidPnTopology, pVidPnTopologyInterface, VidPnSourceId, VidPnTargetId, cTgtPaths, pContext))
1496 break;
1497 }
1498 else
1499 {
1500 drprintf((__FUNCTION__": pfnEnumPathTargetsFromSource failed Status(0x%x)\n", Status));
1501 break;
1502 }
1503 }
1504 }
1505 else if (Status != STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1506 drprintf((__FUNCTION__": pfnGetNumPathsFromSource failed Status(0x%x)\n", Status));
1507
1508 return Status;
1509}
1510
1511NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1512 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1513 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
1514{
1515 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
1516 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1517 if (Status == STATUS_SUCCESS)
1518 {
1519 while (1)
1520 {
1521 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
1522 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
1523
1524 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
1525 {
1526 Assert(Status == STATUS_SUCCESS);
1527 if (Status == STATUS_SUCCESS)
1528 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
1529 else
1530 {
1531 Assert(Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1532 if (Status != STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1533 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1534 Status = STATUS_SUCCESS;
1535 }
1536
1537 break;
1538 }
1539 else if (Status == STATUS_SUCCESS)
1540 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
1541 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1542 {
1543 Status = STATUS_SUCCESS;
1544 break;
1545 }
1546 else
1547 {
1548 AssertBreakpoint();
1549 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
1550 pNewVidPnPresentPathInfo = NULL;
1551 break;
1552 }
1553 }
1554 }
1555 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1556 Status = STATUS_SUCCESS;
1557 else
1558 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1559
1560 return Status;
1561}
1562
1563NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1564{
1565 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, srcId);
1566 return STATUS_SUCCESS;
1567}
1568
1569NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1570{
1571 Assert(srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays);
1572 if (srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays)
1573 {
1574 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[srcId];
1575 return vboxVidPnSetupSourceInfo(pDevExt, srcId, pSource, pVidPnSourceModeInfo, pAllocation);
1576 }
1577
1578 drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, commonFromDeviceExt(pDevExt)->cDisplays));
1579 return STATUS_INVALID_PARAMETER;
1580}
1581
1582typedef struct VBOXVIDPNCOMMITTARGETMODE
1583{
1584 NTSTATUS Status;
1585 D3DKMDT_HVIDPN hVidPn;
1586 const DXGK_VIDPN_INTERFACE* pVidPnInterface;
1587} VBOXVIDPNCOMMITTARGETMODE;
1588
1589DECLCALLBACK(BOOLEAN) vboxVidPnCommitTargetModeEnum(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1590 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext)
1591{
1592 VBOXVIDPNCOMMITTARGETMODE *pInfo = (VBOXVIDPNCOMMITTARGETMODE*)pContext;
1593 Assert(cTgtPaths <= (SIZE_T)commonFromDeviceExt(pDevExt)->cDisplays);
1594 D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet;
1595 CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface;
1596 NTSTATUS Status = pInfo->pVidPnInterface->pfnAcquireTargetModeSet(pInfo->hVidPn, VidPnTargetId, &hVidPnTargetModeSet, &pVidPnTargetModeSetInterface);
1597 Assert(Status == STATUS_SUCCESS);
1598 if (Status == STATUS_SUCCESS)
1599 {
1600 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1601 Status = pVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1602 Assert(Status == STATUS_SUCCESS);
1603 if (Status == STATUS_SUCCESS)
1604 {
1605 VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[VidPnTargetId];
1606 if (pTarget->HeightVisible != pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy
1607 || pTarget->HeightTotal != pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
1608 {
1609 pTarget->HeightVisible = pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
1610 pTarget->HeightTotal = pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy;
1611 pTarget->ScanLineState = 0;
1612 }
1613 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1614 }
1615
1616 pInfo->pVidPnInterface->pfnReleaseTargetModeSet(pInfo->hVidPn, hVidPnTargetModeSet);
1617 }
1618 else
1619 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1620
1621 pInfo->Status = Status;
1622 return Status == STATUS_SUCCESS;
1623}
1624
1625NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
1626{
1627 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1628 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1629
1630 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1631 srcId,
1632 &hCurVidPnSourceModeSet,
1633 &pCurVidPnSourceModeSetInterface);
1634 Assert(Status == STATUS_SUCCESS);
1635 if (Status == STATUS_SUCCESS)
1636 {
1637 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1638 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1639 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1640 if (Status == STATUS_SUCCESS)
1641 {
1642 Assert(pPinnedVidPnSourceModeInfo);
1643 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, pPinnedVidPnSourceModeInfo, pAllocation);
1644 Assert(Status == STATUS_SUCCESS);
1645 if (Status == STATUS_SUCCESS)
1646 {
1647 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1648 CONST DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1649 Status = pVidPnInterface->pfnGetTopology(hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1650 Assert(Status == STATUS_SUCCESS);
1651 if (Status == STATUS_SUCCESS)
1652 {
1653 VBOXVIDPNCOMMITTARGETMODE TgtModeInfo = {0};
1654 TgtModeInfo.Status = STATUS_SUCCESS; /* <- to ensure we're succeeded if no targets are set */
1655 TgtModeInfo.hVidPn = hDesiredVidPn;
1656 TgtModeInfo.pVidPnInterface = pVidPnInterface;
1657 Status = vboxVidPnEnumTargetsForSource(pDevExt, hVidPnTopology, pVidPnTopologyInterface,
1658 srcId,
1659 vboxVidPnCommitTargetModeEnum, &TgtModeInfo);
1660 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1661 if (Status == STATUS_SUCCESS)
1662 {
1663 Status = TgtModeInfo.Status;
1664 Assert(Status == STATUS_SUCCESS);
1665 }
1666 else if (Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1667 {
1668 Status = STATUS_SUCCESS;
1669 }
1670 else
1671 drprintf((__FUNCTION__": vboxVidPnEnumTargetsForSource failed Status(0x%x)\n", Status));
1672 }
1673 else
1674 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1675 }
1676 else
1677 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
1678 /* release */
1679 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1680 }
1681 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1682 {
1683 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, NULL, pAllocation);
1684 Assert(Status == STATUS_SUCCESS);
1685 }
1686 else
1687 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1688
1689 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1690 }
1691 else
1692 {
1693 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1694 }
1695
1696 return Status;
1697}
1698
1699DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1700 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1701 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
1702{
1703 NTSTATUS Status = STATUS_SUCCESS;
1704 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
1705
1706 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
1707 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
1708 {
1709 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
1710 Assert(Status == STATUS_SUCCESS);
1711 if (Status != STATUS_SUCCESS)
1712 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
1713 }
1714
1715 pCommitInfo->Status = Status;
1716 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
1717 return Status == STATUS_SUCCESS;
1718}
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