VirtualBox

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

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

wddm: vidpn handling bugfix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 81.6 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 else
925 {
926 drprintf((__FUNCTION__": failed to allocate resolution copy of size (%d)\n", cResolutions));
927 Status = STATUS_NO_MEMORY;
928 }
929
930 return Status;
931}
932
933NTSTATUS vboxVidPnCreatePopulateVidPnFromLegacy(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
934 VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, int iPreferredMode,
935 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions)
936{
937 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
938 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
939 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
940 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID PreferredSrcModeId = D3DDDI_ID_UNINITIALIZED;
941 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
942 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
943 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId = 0;
944 D3DDDI_VIDEO_PRESENT_TARGET_ID tgtId = 0;
945 NTSTATUS Status = pVidPnInterface->pfnCreateNewSourceModeSet(hVidPn,
946 srcId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
947 &hNewVidPnSourceModeSet,
948 &pNewVidPnSourceModeSetInterface);
949 Assert(Status == STATUS_SUCCESS);
950 if (Status == STATUS_SUCCESS)
951 {
952 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
953 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
954 pModes, cModes, iPreferredMode, &PreferredSrcModeId);
955 Assert(Status == STATUS_SUCCESS);
956 if (Status == STATUS_SUCCESS)
957 {
958 Status = pVidPnInterface->pfnAssignSourceModeSet(hVidPn,
959 srcId,
960 hNewVidPnSourceModeSet);
961 Assert(Status == STATUS_SUCCESS);
962 if(Status == STATUS_SUCCESS)
963 {
964 Assert(PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED);
965 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID PreferredTrgModeId = D3DDDI_ID_UNINITIALIZED;
966 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
967 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
968 NTSTATUS Status = pVidPnInterface->pfnCreateNewTargetModeSet(hVidPn,
969 tgtId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
970 &hNewVidPnTargetModeSet,
971 &pNewVidPnTargetModeSetInterface);
972 Assert(Status == STATUS_SUCCESS);
973 if (Status == STATUS_SUCCESS)
974 {
975 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
976 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
977 pResolutions, cResolutions, pPreferredMode, 0, &PreferredTrgModeId);
978 Assert(Status == STATUS_SUCCESS);
979 if (Status == STATUS_SUCCESS)
980 {
981 Status = pVidPnInterface->pfnAssignTargetModeSet(hVidPn,
982 tgtId,
983 hNewVidPnTargetModeSet);
984 Assert(Status == STATUS_SUCCESS);
985 if(Status == STATUS_SUCCESS)
986 {
987
988 Assert(PreferredTrgModeId != D3DDDI_ID_UNINITIALIZED);
989 Status = pVidPnInterface->pfnGetTopology(hVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
990 if (Status == STATUS_SUCCESS)
991 {
992 D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo;
993 Status = pVidPnTopologyInterface->pfnCreateNewPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
994 if (Status == STATUS_SUCCESS)
995 {
996 pNewVidPnPresentPathInfo->VidPnSourceId = 0;
997 pNewVidPnPresentPathInfo->VidPnTargetId = 0;
998 pNewVidPnPresentPathInfo->ImportanceOrdinal = D3DKMDT_VPPI_PRIMARY;
999 pNewVidPnPresentPathInfo->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
1000 memset(&pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport,
1001 0, sizeof (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport));
1002 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity = 1;
1003 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered = 0;
1004 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched = 0;
1005 pNewVidPnPresentPathInfo->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
1006 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity = 1;
1007 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180 = 0;
1008 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270 = 0;
1009 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90 = 0;
1010 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx = 0;
1011 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy = 0;
1012 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx = 0;
1013 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy = 0;
1014 pNewVidPnPresentPathInfo->VidPnTargetColorBasis = D3DKMDT_CB_SRGB; /* @todo: how does it matters? */
1015 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel = 8;
1016 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel = 8;
1017 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel = 8;
1018 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel = 0;
1019 pNewVidPnPresentPathInfo->Content = D3DKMDT_VPPC_GRAPHICS;
1020 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_UNINITIALIZED;
1021 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_NOPROTECTION;
1022 pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits = 0;
1023 memset(&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, 0, sizeof (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport));
1024 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport.NoProtection = 1;
1025 memset (&pNewVidPnPresentPathInfo->GammaRamp, 0, sizeof (pNewVidPnPresentPathInfo->GammaRamp));
1026 // pNewVidPnPresentPathInfo->GammaRamp.Type = D3DDDI_GAMMARAMP_DEFAULT;
1027 // pNewVidPnPresentPathInfo->GammaRamp.DataSize = 0;
1028 Status = pVidPnTopologyInterface->pfnAddPath(hVidPnTopology, pNewVidPnPresentPathInfo);
1029 Assert(Status == STATUS_SUCCESS);
1030 if (Status == STATUS_SUCCESS)
1031 {
1032 if (PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED)
1033 {
1034 Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, PreferredSrcModeId);
1035 Assert(Status == STATUS_SUCCESS);
1036 if (Status == STATUS_SUCCESS)
1037 {
1038 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, PreferredTrgModeId);
1039 Assert(Status == STATUS_SUCCESS);
1040 if (Status != STATUS_SUCCESS)
1041 drprintf((__FUNCTION__": TRG pfnPinMode failed Status(0x%x)\n", Status));
1042 }
1043 else
1044 drprintf((__FUNCTION__": SRC pfnPinMode failed Status(0x%x)\n", Status));
1045 }
1046 }
1047 else
1048 {
1049 drprintf((__FUNCTION__": pfnAddPath failed Status(0x%x)\n", Status));
1050 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1051 pNewVidPnPresentPathInfo = NULL;
1052 }
1053 }
1054 else
1055 drprintf((__FUNCTION__": pfnCreateNewPathInfo failed Status(0x%x)\n", Status));
1056 }
1057 else
1058 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1059 }
1060 else
1061 {
1062 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
1063 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1064 }
1065 }
1066 else
1067 {
1068 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1069 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1070 }
1071 }
1072 else
1073 drprintf((__FUNCTION__": pfnCreateNewTargetModeSet failed Status(0x%x)\n", Status));
1074 }
1075 else
1076 {
1077 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
1078 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1079 }
1080 }
1081 else
1082 {
1083 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1084 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1085 }
1086 }
1087 else
1088 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
1089
1090 return Status;
1091}
1092
1093DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1094 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1095 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
1096{
1097 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
1098 NTSTATUS Status = STATUS_SUCCESS;
1099 pCbContext->Status = STATUS_SUCCESS;
1100 VIDEO_MODE_INFORMATION *pModes = pCbContext->pModes;
1101 uint32_t cModes = pCbContext->cModes;
1102 int iPreferredMode = pCbContext->iPreferredMode;
1103 uint32_t cResolutions = pCbContext->cResolutions;
1104 D3DKMDT_2DREGION * pResolutions = pCbContext->pResolutions;
1105
1106
1107 /* adjust scaling */
1108 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
1109 {
1110 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
1111 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
1112 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED
1113 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
1114 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
1115 {
1116 AssertBreakpoint();
1117 /* todo: create a new path (if not done already) and assign a proper info */
1118 }
1119 }
1120
1121 /* adjust rotation */
1122 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
1123 {
1124 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
1125 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
1126 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
1127 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270
1128 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED)
1129 {
1130 AssertBreakpoint();
1131 /* todo: create a new path (if not done already) and assign a proper info */
1132 }
1133 }
1134
1135 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1136 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1137 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
1138
1139 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1140 pNewVidPnPresentPathInfo->VidPnSourceId,
1141 &hCurVidPnSourceModeSet,
1142 &pCurVidPnSourceModeSetInterface);
1143 Assert(Status == STATUS_SUCCESS);
1144 if (Status == STATUS_SUCCESS)
1145 {
1146 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1147 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1148 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1149 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1150 {
1151 pPinnedVidPnSourceModeInfo = NULL;
1152 Status = STATUS_SUCCESS;
1153 }
1154 else if (Status != STATUS_SUCCESS)
1155 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1156
1157 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
1158 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
1159 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn,
1160 pNewVidPnPresentPathInfo->VidPnTargetId,
1161 &hCurVidPnTargetModeSet,
1162 &pCurVidPnTargetModeSetInterface);
1163 Assert(Status == STATUS_SUCCESS);
1164 if (Status == STATUS_SUCCESS)
1165 {
1166 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1167 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1168 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1169 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1170 {
1171 pPinnedVidPnTargetModeInfo = NULL;
1172 Status = STATUS_SUCCESS;
1173 }
1174 else if (Status != STATUS_SUCCESS)
1175 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1176
1177 switch (pCbContext->pEnumCofuncModalityArg->EnumPivotType)
1178 {
1179 case D3DKMDT_EPT_VIDPNSOURCE:
1180 if (!pPinnedVidPnTargetModeInfo)
1181 {
1182 if (pPinnedVidPnSourceModeInfo)
1183 {
1184 SIZE_T cModes;
1185 Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cModes);
1186 Assert(Status == STATUS_SUCCESS);
1187 if (Status == STATUS_SUCCESS)
1188 {
1189 D3DKMDT_2DREGION Resolution;
1190 Resolution.cx = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx;
1191 Resolution.cy = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy;
1192 BOOLEAN bCreateTrg = FALSE;
1193 if (cModes == 1)
1194 {
1195 const D3DKMDT_VIDPN_TARGET_MODE *pVidPnTargetModeInfo;
1196 Status = pCurVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hCurVidPnTargetModeSet, &pVidPnTargetModeInfo);
1197 Assert(Status == STATUS_SUCCESS);
1198 if (Status == STATUS_SUCCESS)
1199 {
1200 D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
1201 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &Resolution, FALSE);
1202 Assert(Status == STATUS_SUCCESS);
1203 if (Status == STATUS_SUCCESS)
1204 {
1205 if (!vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pVidPnTargetModeInfo->VideoSignalInfo))
1206 bCreateTrg = TRUE;
1207 else
1208 {
1209 /* do we need to check pVidPnTargetModeInfo->Preference; ? */
1210 }
1211 }
1212 else
1213 {
1214 drprintf((__FUNCTION__": trg vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x), pretending success\n", Status));
1215 Status = STATUS_SUCCESS;
1216 bCreateTrg = TRUE;
1217 }
1218 }
1219 else
1220 drprintf((__FUNCTION__": trg pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1221 }
1222 else
1223 bCreateTrg = TRUE;
1224
1225 if (bCreateTrg)
1226 {
1227 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1228 pNewVidPnPresentPathInfo->VidPnTargetId,
1229 &Resolution,
1230 1,
1231 pPreferredMode,
1232 0,
1233 NULL);
1234 Assert(Status == STATUS_SUCCESS);
1235 if (Status != STATUS_SUCCESS)
1236 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy for pinned source failed Status(0x%x)\n", Status)); }
1237 }
1238 else
1239 drprintf((__FUNCTION__": trg pfnGetNumModes failed Status(0x%x)\n", Status));
1240 }
1241 else
1242 {
1243 dprintf((__FUNCTION__": source pivot w/o pinned source mode\n"));
1244// AssertBreakpoint();
1245 }
1246 }
1247 break;
1248 case D3DKMDT_EPT_VIDPNTARGET:
1249 break;
1250 case D3DKMDT_EPT_SCALING:
1251 break;
1252 case D3DKMDT_EPT_ROTATION:
1253 break;
1254 case D3DKMDT_EPT_NOPIVOT:
1255 /* just create and populate the new source mode set for now */
1256 Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1257 pNewVidPnPresentPathInfo->VidPnSourceId,
1258 pModes, cModes, iPreferredMode, NULL);
1259 Assert(Status == STATUS_SUCCESS);
1260 if (Status == STATUS_SUCCESS)
1261 {
1262 /* just create and populate a new target mode info for now */
1263 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1264 pNewVidPnPresentPathInfo->VidPnTargetId,
1265 pResolutions,
1266 cResolutions,
1267 pPreferredMode,
1268 0,
1269 NULL);
1270 Assert(Status == STATUS_SUCCESS);
1271 if (Status != STATUS_SUCCESS)
1272 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1273 }
1274 else
1275 drprintf((__FUNCTION__": vboxVidPnCreatePopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1276
1277 break;
1278 default:
1279 drprintf((__FUNCTION__": unknown EnumPivotType (%dx)\n", pCbContext->pEnumCofuncModalityArg->EnumPivotType));
1280 break;
1281 }
1282
1283 if (pPinnedVidPnTargetModeInfo)
1284 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1285 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
1286 }
1287 else
1288 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1289
1290 if (pPinnedVidPnSourceModeInfo)
1291 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1292 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1293 }
1294 else
1295 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1296
1297 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1298
1299 pCbContext->Status = Status;
1300 Assert(Status == STATUS_SUCCESS);
1301 return Status == STATUS_SUCCESS;
1302}
1303
1304NTSTATUS vboxVidPnEnumMonitorSourceModes(PDEVICE_EXTENSION pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
1305 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext)
1306{
1307 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI;
1308 NTSTATUS Status = pMonitorSMSIf->pfnAcquireFirstModeInfo(hMonitorSMS, &pMonitorSMI);
1309 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_DATASET_IS_EMPTY);
1310 if (Status == STATUS_SUCCESS)
1311 {
1312 Assert(pMonitorSMI);
1313 while (1)
1314 {
1315 CONST D3DKMDT_MONITOR_SOURCE_MODE *pNextMonitorSMI;
1316 Status = pMonitorSMSIf->pfnAcquireNextModeInfo(hMonitorSMS, pMonitorSMI, &pNextMonitorSMI);
1317 if (!pfnCallback(pDevExt, hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext))
1318 {
1319 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1320 if (Status == STATUS_SUCCESS)
1321 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pNextMonitorSMI);
1322 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1323 {
1324 Status = STATUS_SUCCESS;
1325 break;
1326 }
1327 else
1328 {
1329 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1330 Status = STATUS_SUCCESS;
1331 }
1332 break;
1333 }
1334 else if (Status == STATUS_SUCCESS)
1335 pMonitorSMI = pNextMonitorSMI;
1336 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1337 {
1338 Status = STATUS_SUCCESS;
1339 break;
1340 }
1341 else
1342 {
1343 AssertBreakpoint();
1344 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1345 pNextMonitorSMI = NULL;
1346 break;
1347 }
1348 }
1349 }
1350 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1351 Status = STATUS_SUCCESS;
1352 else
1353 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1354
1355 return Status;
1356}
1357
1358NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1359 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
1360 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
1361{
1362 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1363 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1364 if (Status == STATUS_SUCCESS)
1365 {
1366 Assert(pNewVidPnSourceModeInfo);
1367 while (1)
1368 {
1369 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
1370 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
1371 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1372 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
1373 pNewVidPnSourceModeInfo, pContext))
1374 {
1375 Assert(Status == STATUS_SUCCESS);
1376 if (Status == STATUS_SUCCESS)
1377 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
1378 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1379 {
1380 Status = STATUS_SUCCESS;
1381 break;
1382 }
1383 else
1384 {
1385 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1386 Status = STATUS_SUCCESS;
1387 }
1388
1389 break;
1390 }
1391 else if (Status == STATUS_SUCCESS)
1392 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
1393 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1394 {
1395 Status = STATUS_SUCCESS;
1396 break;
1397 }
1398 else
1399 {
1400 AssertBreakpoint();
1401 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1402 pNewVidPnSourceModeInfo = NULL;
1403 break;
1404 }
1405 }
1406 }
1407 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1408 Status = STATUS_SUCCESS;
1409 else
1410 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1411
1412 return Status;
1413}
1414
1415NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1416 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
1417 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
1418{
1419 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
1420 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
1421 if (Status == STATUS_SUCCESS)
1422 {
1423 Assert(pNewVidPnTargetModeInfo);
1424 while (1)
1425 {
1426 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
1427 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
1428 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1429 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
1430 pNewVidPnTargetModeInfo, pContext))
1431 {
1432 Assert(Status == STATUS_SUCCESS);
1433 if (Status == STATUS_SUCCESS)
1434 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
1435 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1436 {
1437 Status = STATUS_SUCCESS;
1438 break;
1439 }
1440 else
1441 {
1442 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1443 Status = STATUS_SUCCESS;
1444 }
1445
1446 break;
1447 }
1448 else if (Status == STATUS_SUCCESS)
1449 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
1450 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1451 {
1452 Status = STATUS_SUCCESS;
1453 break;
1454 }
1455 else
1456 {
1457 AssertBreakpoint();
1458 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1459 pNewVidPnTargetModeInfo = NULL;
1460 break;
1461 }
1462 }
1463 }
1464 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1465 Status = STATUS_SUCCESS;
1466 else
1467 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1468
1469 return Status;
1470}
1471
1472NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1473 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
1474 PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext)
1475{
1476 SIZE_T cTgtPaths;
1477 NTSTATUS Status = pVidPnTopologyInterface->pfnGetNumPathsFromSource(hVidPnTopology, VidPnSourceId, &cTgtPaths);
1478 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1479 if (Status == STATUS_SUCCESS)
1480 {
1481 for (SIZE_T i = 0; i < cTgtPaths; ++i)
1482 {
1483 D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId;
1484 Status = pVidPnTopologyInterface->pfnEnumPathTargetsFromSource(hVidPnTopology, VidPnSourceId, i, &VidPnTargetId);
1485 Assert(Status == STATUS_SUCCESS);
1486 if (Status == STATUS_SUCCESS)
1487 {
1488 if (!pfnCallback(pDevExt, hVidPnTopology, pVidPnTopologyInterface, VidPnSourceId, VidPnTargetId, cTgtPaths, pContext))
1489 break;
1490 }
1491 else
1492 {
1493 drprintf((__FUNCTION__": pfnEnumPathTargetsFromSource failed Status(0x%x)\n", Status));
1494 break;
1495 }
1496 }
1497 }
1498 else if (Status != STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1499 drprintf((__FUNCTION__": pfnGetNumPathsFromSource failed Status(0x%x)\n", Status));
1500
1501 return Status;
1502}
1503
1504NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1505 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1506 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
1507{
1508 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
1509 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1510 if (Status == STATUS_SUCCESS)
1511 {
1512 while (1)
1513 {
1514 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
1515 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
1516
1517 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
1518 {
1519 Assert(Status == STATUS_SUCCESS);
1520 if (Status == STATUS_SUCCESS)
1521 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
1522 else
1523 {
1524 Assert(Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1525 if (Status != STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1526 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1527 Status = STATUS_SUCCESS;
1528 }
1529
1530 break;
1531 }
1532 else if (Status == STATUS_SUCCESS)
1533 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
1534 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1535 {
1536 Status = STATUS_SUCCESS;
1537 break;
1538 }
1539 else
1540 {
1541 AssertBreakpoint();
1542 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
1543 pNewVidPnPresentPathInfo = NULL;
1544 break;
1545 }
1546 }
1547 }
1548 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1549 Status = STATUS_SUCCESS;
1550 else
1551 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1552
1553 return Status;
1554}
1555
1556NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1557{
1558 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, srcId);
1559 return STATUS_SUCCESS;
1560}
1561
1562NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1563{
1564 Assert(srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays);
1565 if (srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays)
1566 {
1567 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[srcId];
1568 return vboxVidPnSetupSourceInfo(pDevExt, srcId, pSource, pVidPnSourceModeInfo, pAllocation);
1569 }
1570
1571 drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, commonFromDeviceExt(pDevExt)->cDisplays));
1572 return STATUS_INVALID_PARAMETER;
1573}
1574
1575typedef struct VBOXVIDPNCOMMITTARGETMODE
1576{
1577 NTSTATUS Status;
1578 D3DKMDT_HVIDPN hVidPn;
1579 const DXGK_VIDPN_INTERFACE* pVidPnInterface;
1580} VBOXVIDPNCOMMITTARGETMODE;
1581
1582DECLCALLBACK(BOOLEAN) vboxVidPnCommitTargetModeEnum(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1583 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext)
1584{
1585 VBOXVIDPNCOMMITTARGETMODE *pInfo = (VBOXVIDPNCOMMITTARGETMODE*)pContext;
1586 Assert(cTgtPaths <= (SIZE_T)commonFromDeviceExt(pDevExt)->cDisplays);
1587 D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet;
1588 CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface;
1589 NTSTATUS Status = pInfo->pVidPnInterface->pfnAcquireTargetModeSet(pInfo->hVidPn, VidPnTargetId, &hVidPnTargetModeSet, &pVidPnTargetModeSetInterface);
1590 Assert(Status == STATUS_SUCCESS);
1591 if (Status == STATUS_SUCCESS)
1592 {
1593 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1594 Status = pVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1595 Assert(Status == STATUS_SUCCESS);
1596 if (Status == STATUS_SUCCESS)
1597 {
1598 VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[VidPnTargetId];
1599 if (pTarget->HeightVisible != pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy
1600 || pTarget->HeightTotal != pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
1601 {
1602 pTarget->HeightVisible = pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
1603 pTarget->HeightTotal = pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy;
1604 pTarget->ScanLineState = 0;
1605 }
1606 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1607 }
1608
1609 pInfo->pVidPnInterface->pfnReleaseTargetModeSet(pInfo->hVidPn, hVidPnTargetModeSet);
1610 }
1611 else
1612 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1613
1614 pInfo->Status = Status;
1615 return Status == STATUS_SUCCESS;
1616}
1617
1618NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
1619{
1620 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1621 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1622
1623 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1624 srcId,
1625 &hCurVidPnSourceModeSet,
1626 &pCurVidPnSourceModeSetInterface);
1627 Assert(Status == STATUS_SUCCESS);
1628 if (Status == STATUS_SUCCESS)
1629 {
1630 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1631 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1632 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1633 if (Status == STATUS_SUCCESS)
1634 {
1635 Assert(pPinnedVidPnSourceModeInfo);
1636 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, pPinnedVidPnSourceModeInfo, pAllocation);
1637 Assert(Status == STATUS_SUCCESS);
1638 if (Status == STATUS_SUCCESS)
1639 {
1640 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1641 CONST DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1642 Status = pVidPnInterface->pfnGetTopology(hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1643 Assert(Status == STATUS_SUCCESS);
1644 if (Status == STATUS_SUCCESS)
1645 {
1646 VBOXVIDPNCOMMITTARGETMODE TgtModeInfo = {0};
1647 TgtModeInfo.Status = STATUS_SUCCESS; /* <- to ensure we're succeeded if no targets are set */
1648 TgtModeInfo.hVidPn = hDesiredVidPn;
1649 TgtModeInfo.pVidPnInterface = pVidPnInterface;
1650 Status = vboxVidPnEnumTargetsForSource(pDevExt, hVidPnTopology, pVidPnTopologyInterface,
1651 srcId,
1652 vboxVidPnCommitTargetModeEnum, &TgtModeInfo);
1653 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1654 if (Status == STATUS_SUCCESS)
1655 {
1656 Status = TgtModeInfo.Status;
1657 Assert(Status == STATUS_SUCCESS);
1658 }
1659 else if (Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1660 {
1661 Status = STATUS_SUCCESS;
1662 }
1663 else
1664 drprintf((__FUNCTION__": vboxVidPnEnumTargetsForSource failed Status(0x%x)\n", Status));
1665 }
1666 else
1667 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1668 }
1669 else
1670 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
1671 /* release */
1672 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1673 }
1674 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1675 {
1676 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, NULL, pAllocation);
1677 Assert(Status == STATUS_SUCCESS);
1678 }
1679 else
1680 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1681
1682 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1683 }
1684 else
1685 {
1686 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1687 }
1688
1689 return Status;
1690}
1691
1692DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1693 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1694 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
1695{
1696 NTSTATUS Status = STATUS_SUCCESS;
1697 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
1698
1699 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
1700 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
1701 {
1702 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
1703 Assert(Status == STATUS_SUCCESS);
1704 if (Status != STATUS_SUCCESS)
1705 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
1706 }
1707
1708 pCommitInfo->Status = Status;
1709 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
1710 return Status == STATUS_SUCCESS;
1711}
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