VirtualBox

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

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

wddm: vidpn more logging + cosmetics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 107.7 KB
Line 
1/*
2 * Copyright (C) 2010 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.virtualbox.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 */
12#include "../VBoxVideo.h"
13#include "../Helper.h"
14
15NTSTATUS vboxVidPnCheckTopology(PDEVICE_EXTENSION pDevExt, 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 BOOLEAN bFoundPrimary = FALSE;
26
27 while (1)
28 {
29 if (pNewVidPnPresentPathInfo->VidPnSourceId != pNewVidPnPresentPathInfo->VidPnTargetId)
30 {
31 dprintf(("unsupported source(%d)->target(%d) pare\n", pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId));
32 AssertBreakpoint();
33 bSupported = FALSE;
34 break;
35 }
36
37 if (pNewVidPnPresentPathInfo->VidPnSourceId == 0)
38 {
39 bFoundPrimary = TRUE;
40 }
41
42 /*
43 ImportanceOrdinal does not matter for now
44 pNewVidPnPresentPathInfo->ImportanceOrdinal
45 */
46
47 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
48 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
49 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
50 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
51 {
52 dprintf(("unsupported Scaling (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Scaling));
53 AssertBreakpoint();
54 bSupported = FALSE;
55 break;
56 }
57
58 if (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched)
59 {
60 dprintf(("unsupported Scaling support (Stretched)\n"));
61 AssertBreakpoint();
62 bSupported = FALSE;
63 break;
64 }
65
66 if (!pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity
67 && !pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered)
68 {
69 dprintf(("\"Identity\" or \"Centered\" Scaling support not set\n"));
70 AssertBreakpoint();
71 bSupported = FALSE;
72 break;
73 }
74
75 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED
76 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY)
77 {
78 dprintf(("unsupported rotation (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Rotation));
79 AssertBreakpoint();
80 bSupported = FALSE;
81 break;
82 }
83
84 if (pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180
85 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270
86 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90)
87 {
88 dprintf(("unsupported RotationSupport\n"));
89 AssertBreakpoint();
90 bSupported = FALSE;
91 break;
92 }
93
94 if (!pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity)
95 {
96 dprintf(("\"Identity\" RotationSupport not set\n"));
97 AssertBreakpoint();
98 bSupported = FALSE;
99 break;
100 }
101
102 if (pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx
103 || pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy)
104 {
105 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
106 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx,
107 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy));
108 AssertBreakpoint();
109 bSupported = FALSE;
110 break;
111 }
112
113 if (pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx
114 || pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy)
115 {
116 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
117 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx,
118 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy));
119 AssertBreakpoint();
120 bSupported = FALSE;
121 break;
122 }
123
124 if (pNewVidPnPresentPathInfo->VidPnTargetColorBasis != D3DKMDT_CB_SRGB
125 && pNewVidPnPresentPathInfo->VidPnTargetColorBasis != D3DKMDT_CB_UNINITIALIZED)
126 {
127 dprintf(("unsupported VidPnTargetColorBasis (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorBasis));
128 AssertBreakpoint();
129 bSupported = FALSE;
130 break;
131 }
132
133 /* channels?
134 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel;
135 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel;
136 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel;
137 we definitely not support fourth channel
138 */
139 if (pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel)
140 {
141 dprintf(("Non-zero FourthChannel (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel));
142 AssertBreakpoint();
143 bSupported = FALSE;
144 break;
145 }
146
147 /* Content (D3DKMDT_VPPC_GRAPHICS, _NOTSPECIFIED, _VIDEO), does not matter for now
148 pNewVidPnPresentPathInfo->Content
149 */
150 /* not support copy protection for now */
151 if (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType != D3DKMDT_VPPMT_NOPROTECTION
152 && pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType != D3DKMDT_VPPMT_UNINITIALIZED)
153 {
154 dprintf(("Copy protection not supported CopyProtectionType(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType));
155 AssertBreakpoint();
156 bSupported = FALSE;
157 break;
158 }
159
160 if (pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits)
161 {
162 dprintf(("Copy protection not supported APSTriggerBits(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits));
163 AssertBreakpoint();
164 bSupported = FALSE;
165 break;
166 }
167
168 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_SUPPORT tstCPSupport = {0};
169 tstCPSupport.NoProtection = 1;
170 if (memcmp(&tstCPSupport, &pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, sizeof(tstCPSupport)))
171 {
172 dprintf(("Copy protection support (0x%x)\n", *((UINT*)&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport)));
173 AssertBreakpoint();
174 bSupported = FALSE;
175 break;
176 }
177
178 if (pNewVidPnPresentPathInfo->GammaRamp.Type != D3DDDI_GAMMARAMP_DEFAULT
179 && pNewVidPnPresentPathInfo->GammaRamp.Type != D3DDDI_GAMMARAMP_UNINITIALIZED)
180 {
181 dprintf(("Unsupported GammaRamp.Type (%d)\n", pNewVidPnPresentPathInfo->GammaRamp.Type));
182 AssertBreakpoint();
183 bSupported = FALSE;
184 break;
185 }
186
187 if (pNewVidPnPresentPathInfo->GammaRamp.DataSize != 0)
188 {
189 dprintf(("Warning: non-zero GammaRamp.DataSize (%d), treating as supported\n", pNewVidPnPresentPathInfo->GammaRamp.DataSize));
190 }
191
192 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
193
194 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
195 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
196 if (Status == STATUS_SUCCESS)
197 {
198 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
199 }
200 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
201 {
202 Status = STATUS_SUCCESS;
203 pNewVidPnPresentPathInfo = NULL;
204 break;
205 }
206 else
207 {
208 AssertBreakpoint();
209 dprintf(("pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
210 pNewVidPnPresentPathInfo = NULL;
211 break;
212 }
213 }
214
215 bSupported &= bFoundPrimary;
216
217 if (pNewVidPnPresentPathInfo)
218 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
219
220 }
221 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
222 Status = STATUS_SUCCESS;
223 else
224 drprintf((__FUNCTION__": pfnAcquireFirstPathInfo failed Status(0x%x)\n", Status));
225
226 *pbSupported = bSupported;
227
228 return Status;
229}
230
231NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
232 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
233 BOOLEAN *pbSupported)
234{
235 BOOLEAN bSupported = TRUE;
236 /* we support both GRAPHICS and TEXT modes */
237 switch (pNewVidPnSourceModeInfo->Type)
238 {
239 case D3DKMDT_RMT_GRAPHICS:
240 /* any primary surface size actually
241 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
242 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy
243 */
244 if (pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
245 || pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy)
246 {
247 dprintf(("VisibleRegionSize(%d, %d) != PrimSurfSize(%d, %d)\n",
248 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx,
249 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy,
250 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx,
251 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy));
252 AssertBreakpoint();
253 bSupported = FALSE;
254 break;
255 }
256
257 /*
258 pNewVidPnSourceModeInfo->Format.Graphics.Stride
259 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat
260 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis
261 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode
262 */
263
264 break;
265 case D3DKMDT_RMT_TEXT:
266 break;
267 default:
268 AssertBreakpoint();
269 dprintf(("Warning: Unknown Src mode Type (%d)\n", pNewVidPnSourceModeInfo->Type));
270 break;
271 }
272
273 *pbSupported = bSupported;
274 return STATUS_SUCCESS;
275}
276
277NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
278 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
279 BOOLEAN *pbSupported)
280{
281 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
282 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
283 BOOLEAN bSupported = TRUE;
284 if (Status == STATUS_SUCCESS)
285 {
286 while (1)
287 {
288 Status = vboxVidPnCheckSourceModeInfo(hDesiredVidPn, pNewVidPnSourceModeInfo, &bSupported);
289 if (Status == STATUS_SUCCESS && bSupported)
290 {
291 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
292 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
293 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
294 if (Status == STATUS_SUCCESS)
295 {
296 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
297 }
298 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
299 {
300 Status = STATUS_SUCCESS;
301 break;
302 }
303 else
304 {
305 drprintf(("pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
306 break;
307 }
308 }
309 else
310 {
311 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
312 break;
313 }
314 }
315 }
316 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
317 Status = STATUS_SUCCESS;
318 else
319 drprintf(("VBoxVideoWddm: pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
320
321 *pbSupported = bSupported;
322 return Status;
323}
324
325NTSTATUS vboxVidPnPopulateVideoSignalInfo(D3DKMDT_VIDEO_SIGNAL_INFO *pVsi,
326 D3DKMDT_2DREGION *pResolution,
327 ULONG VSync)
328{
329 NTSTATUS Status = STATUS_SUCCESS;
330
331 pVsi->VideoStandard = D3DKMDT_VSS_VESA_DMT;
332 pVsi->ActiveSize = *pResolution;
333 pVsi->VSyncFreq.Numerator = VSync * 1000;
334 pVsi->VSyncFreq.Denominator = 1000;
335 pVsi->TotalSize.cx = pVsi->ActiveSize.cx + VBOXVDPN_C_DISPLAY_HBLANK_SIZE;
336 pVsi->TotalSize.cy = pVsi->ActiveSize.cy + VBOXVDPN_C_DISPLAY_VBLANK_SIZE;
337 pVsi->PixelRate = pVsi->TotalSize.cx * pVsi->TotalSize.cy * VSync;
338 pVsi->HSyncFreq.Numerator = (UINT)((pVsi->PixelRate / pVsi->TotalSize.cy) * 1000);
339 pVsi->HSyncFreq.Denominator = 1000;
340 pVsi->ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
341
342 return Status;
343}
344
345BOOLEAN vboxVidPnMatchVideoSignal(const D3DKMDT_VIDEO_SIGNAL_INFO *pVsi1, const D3DKMDT_VIDEO_SIGNAL_INFO *pVsi2)
346{
347 if (pVsi1->VideoStandard != pVsi2->VideoStandard)
348 return FALSE;
349 if (pVsi1->TotalSize.cx != pVsi2->TotalSize.cx)
350 return FALSE;
351 if (pVsi1->TotalSize.cy != pVsi2->TotalSize.cy)
352 return FALSE;
353 if (pVsi1->ActiveSize.cx != pVsi2->ActiveSize.cx)
354 return FALSE;
355 if (pVsi1->ActiveSize.cy != pVsi2->ActiveSize.cy)
356 return FALSE;
357 if (pVsi1->VSyncFreq.Numerator != pVsi2->VSyncFreq.Numerator)
358 return FALSE;
359 if (pVsi1->VSyncFreq.Denominator != pVsi2->VSyncFreq.Denominator)
360 return FALSE;
361 if (pVsi1->HSyncFreq.Numerator != pVsi2->HSyncFreq.Numerator)
362 return FALSE;
363 if (pVsi1->HSyncFreq.Denominator != pVsi2->HSyncFreq.Denominator)
364 return FALSE;
365 if (pVsi1->PixelRate != pVsi2->PixelRate)
366 return FALSE;
367 if (pVsi1->ScanLineOrdering != pVsi2->ScanLineOrdering)
368 return FALSE;
369
370 return TRUE;
371}
372
373NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
374 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
375 BOOLEAN *pbSupported)
376{
377 BOOLEAN bSupported = TRUE;
378 D3DKMDT_VIDEO_SIGNAL_INFO CmpVsi;
379 D3DKMDT_2DREGION CmpRes;
380 CmpRes.cx = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cx;
381 CmpRes.cy = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
382 NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(&CmpVsi,
383 &CmpRes,
384 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator/pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator);
385 Assert(Status == STATUS_SUCCESS);
386 if (Status != STATUS_SUCCESS)
387 {
388 drprintf((__FUNCTION__": vboxVidPnPopulateVideoSignalInfo error Status (0x%x)\n", Status));
389 return Status;
390 }
391
392 if (!vboxVidPnMatchVideoSignal(&CmpVsi, &pNewVidPnTargetModeInfo->VideoSignalInfo))
393 {
394 dfprintf((__FUNCTION__": VideoSignalInfos do not match!!!\n"));
395 AssertBreakpoint();
396 bSupported = FALSE;
397 }
398
399 *pbSupported = bSupported;
400 return STATUS_SUCCESS;
401}
402
403NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
404 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
405 BOOLEAN *pbSupported)
406{
407 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
408 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
409 BOOLEAN bSupported = TRUE;
410 if (Status == STATUS_SUCCESS)
411 {
412 Assert(pNewVidPnTargetModeInfo);
413 while (1)
414 {
415 Status = vboxVidPnCheckTargetModeInfo(hDesiredVidPn, pNewVidPnTargetModeInfo, &bSupported);
416 if (Status == STATUS_SUCCESS && bSupported)
417 {
418 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
419 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
420 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
421 if (Status == STATUS_SUCCESS)
422 {
423 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
424 }
425 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
426 {
427 Status = STATUS_SUCCESS;
428 break;
429 }
430 else
431 {
432 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
433 break;
434 }
435 }
436 else
437 {
438 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
439 break;
440 }
441 }
442 }
443 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
444 Status = STATUS_SUCCESS;
445 else
446 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
447
448 *pbSupported = bSupported;
449 return Status;
450}
451
452#if 0
453DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeCheck(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 PVBOXVIDPN_NEW_SRCMODESET_CHECK pCbContext = (PVBOXVIDPN_NEW_SRCMODESET_CHECK)pContext;
459 pCbContext->CommonInfo.Status = STATUS_SUCCESS;
460
461 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
462
463 pCbContext->CommonInfo.Status = Status;
464 return Status == STATUS_SUCCESS;
465}
466
467DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
468 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
469 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
470{
471 NTSTATUS Status = STATUS_SUCCESS;
472 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
473 pCbContext->Status = STATUS_SUCCESS;
474
475 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
476
477 pCbContext->Status = Status;
478 return Status == STATUS_SUCCESS;
479}
480
481DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityTargetModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
482 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
483 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
484{
485 NTSTATUS Status = STATUS_SUCCESS;
486 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
487 pCbContext->Status = STATUS_SUCCESS;
488
489 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
490
491 pCbContext->Status = Status;
492 return Status == STATUS_SUCCESS;
493}
494#endif
495
496NTSTATUS vboxVidPnPopulateSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
497 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
498 VIDEO_MODE_INFORMATION *pMode)
499{
500 NTSTATUS Status = STATUS_SUCCESS;
501 if (pMode->AttributeFlags & VIDEO_MODE_GRAPHICS)
502 {
503 /* this is a graphics mode */
504 pNewVidPnSourceModeInfo->Type = D3DKMDT_RMT_GRAPHICS;
505 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx = pMode->VisScreenWidth;
506 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy = pMode->VisScreenHeight;
507 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
508 pNewVidPnSourceModeInfo->Format.Graphics.Stride = pMode->ScreenStride;
509 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat = vboxWddmCalcPixelFormat(pMode);
510 Assert(pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN);
511 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN)
512 {
513 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis = D3DKMDT_CB_SRGB;
514 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat == D3DDDIFMT_P8)
515 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_SETTABLEPALETTE;
516 else
517 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_DIRECT;
518 }
519 else
520 {
521 drprintf((__FUNCTION__": vboxWddmCalcPixelFormat failed\n"));
522 Status = STATUS_INVALID_PARAMETER;
523 }
524 }
525 else
526 {
527 /* @todo: XPDM driver does not seem to return text modes, should we? */
528 drprintf((__FUNCTION__": text mode not supported currently\n"));
529 AssertBreakpoint();
530 Status = STATUS_INVALID_PARAMETER;
531 }
532
533 return Status;
534}
535
536NTSTATUS vboxVidPnPopulateSourceModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
537 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet,
538 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface,
539 VIDEO_MODE_INFORMATION *pModes,
540 uint32_t cModes,
541 int iPreferredMode,
542 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID *pPreferredModeId)
543{
544 NTSTATUS Status = STATUS_SUCCESS;
545 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID PreferredModeId = D3DDDI_ID_UNINITIALIZED;
546 for (uint32_t i = 0; i < cModes; ++i)
547 {
548 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
549 /* disable 24 bpp for now */
550 if (pModes[i].BitsPerPlane == 24)
551 continue;
552
553 Status = pNewVidPnSourceModeSetInterface->pfnCreateNewModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
554 Assert(Status == STATUS_SUCCESS);
555 if (Status == STATUS_SUCCESS)
556 {
557 Status = vboxVidPnPopulateSourceModeInfoFromLegacy(pDevExt, pNewVidPnSourceModeInfo, &pModes[i]);
558 Assert(Status == STATUS_SUCCESS);
559 if (Status == STATUS_SUCCESS)
560 {
561 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnSourceModeInfo->Id;
562 Status = pNewVidPnSourceModeSetInterface->pfnAddMode(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
563 Assert(Status == STATUS_SUCCESS);
564 if (Status == STATUS_SUCCESS)
565 {
566 if (iPreferredMode == i)
567 {
568 PreferredModeId = modeId;
569// AssertBreakpoint();
570// Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, modeId);
571// Assert(Status == STATUS_SUCCESS);
572// if (Status != STATUS_SUCCESS)
573// {
574// drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
575// /* don't treat it as fatal */
576// Status = STATUS_SUCCESS;
577// }
578 }
579 }
580 else
581 {
582 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
583 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
584 break;
585 }
586 }
587 else
588 {
589 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
590 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
591 break;
592 }
593 }
594 }
595
596 if (pPreferredModeId)
597 *pPreferredModeId = PreferredModeId;
598
599 return Status;
600}
601
602NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
603 D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
604 D3DKMDT_2DREGION *pResolution,
605 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
606 BOOLEAN bPreferred)
607{
608 NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(&pMonitorSourceMode->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
609 Assert(Status == STATUS_SUCCESS);
610 if (Status == STATUS_SUCCESS)
611 {
612 pMonitorSourceMode->ColorBasis = D3DKMDT_CB_SRGB;
613 pMonitorSourceMode->ColorCoeffDynamicRanges.FirstChannel = 8;
614 pMonitorSourceMode->ColorCoeffDynamicRanges.SecondChannel = 8;
615 pMonitorSourceMode->ColorCoeffDynamicRanges.ThirdChannel = 8;
616 pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0;
617 pMonitorSourceMode->Origin = enmOrigin;
618 pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
619 }
620
621 return Status;
622}
623
624NTSTATUS vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
625 CONST D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS,
626 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
627 D3DKMDT_2DREGION *pResolution,
628 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
629 BOOLEAN bPreferred)
630{
631 D3DKMDT_MONITOR_SOURCE_MODE * pMonitorSMI;
632 NTSTATUS Status = pMonitorSMSIf->pfnCreateNewModeInfo(hMonitorSMS, &pMonitorSMI);
633 Assert(Status == STATUS_SUCCESS);
634 if (Status == STATUS_SUCCESS)
635 {
636 do
637 {
638 Status = vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(pDevExt,
639 pMonitorSMI,
640 pResolution,
641 enmOrigin,
642 bPreferred);
643 Assert(Status == STATUS_SUCCESS);
644 if (Status == STATUS_SUCCESS)
645 {
646 Status = pMonitorSMSIf->pfnAddMode(hMonitorSMS, pMonitorSMI);
647 Assert(Status == STATUS_SUCCESS);
648 if (Status == STATUS_SUCCESS)
649 break;
650 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
651 }
652 else
653 drprintf((__FUNCTION__": vboxVidPnPopulateMonitorSourceModeInfoFromLegacy failed, Status(0x%x)", Status));
654
655 Assert (Status != STATUS_SUCCESS);
656 /* we're here because of a failure */
657 NTSTATUS tmpStatus = pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI);
658 Assert(tmpStatus == STATUS_SUCCESS);
659 if (tmpStatus != STATUS_SUCCESS)
660 drprintf((__FUNCTION__": pfnReleaseModeInfo failed tmpStatus(0x%x)\n", tmpStatus));
661 } while (0);
662 }
663 else
664 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
665
666 return Status;
667}
668
669NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
670 D3DKMDT_2DREGION *pResolution,
671 BOOLEAN bPreferred)
672{
673 Assert(!bPreferred);
674 pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
675
676 return vboxVidPnPopulateVideoSignalInfo(&pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
677}
678
679#define VBOXVIDPN_MODESET_NO_PIN_PREFERRED 0x00000001
680#define VBOXVIDPN_MODESET_MARK_PREFERRED 0x00000002
681
682NTSTATUS vboxVidPnPopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
683 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet,
684 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface,
685 D3DKMDT_2DREGION *pResolutions,
686 uint32_t cResolutions,
687 VIDEO_MODE_INFORMATION *pPreferredMode,
688 uint32_t fFlags,
689 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID *pPreferredModeId)
690{
691 NTSTATUS Status = STATUS_SUCCESS;
692 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID PreferredModeId = D3DDDI_ID_UNINITIALIZED;
693 for (uint32_t i = 0; i < cResolutions; ++i)
694 {
695 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
696 Status = pNewVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
697 Assert(Status == STATUS_SUCCESS);
698 if (Status == STATUS_SUCCESS)
699 {
700 bool bPreferred = pPreferredMode ? pPreferredMode->VisScreenWidth == pResolutions[i].cx
701 && pPreferredMode->VisScreenHeight == pResolutions[i].cy : FALSE;
702 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, &pResolutions[i], bPreferred && (fFlags & VBOXVIDPN_MODESET_MARK_PREFERRED));
703 Assert(Status == STATUS_SUCCESS);
704 if (Status == STATUS_SUCCESS)
705 {
706 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnTargetModeInfo->Id;
707 Status = pNewVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
708 Assert(Status == STATUS_SUCCESS);
709 if (Status == STATUS_SUCCESS)
710 {
711 if (bPreferred) // && !(fFlags & VBOXVIDPN_MODESET_NO_PIN_PREFERRED))
712 {
713 PreferredModeId = modeId;
714// AssertBreakpoint();
715// Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
716// Assert(Status == STATUS_SUCCESS);
717// if (Status != STATUS_SUCCESS)
718// {
719// drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
720// /* don't treat it as fatal */
721// Status = STATUS_SUCCESS;
722// }
723 }
724 }
725 else
726 {
727 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
728 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
729 break;
730 }
731 }
732 else
733 {
734 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
735 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
736 break;
737 }
738 }
739 }
740
741 if (pPreferredModeId)
742 *pPreferredModeId = PreferredModeId;
743 return Status;
744}
745
746NTSTATUS vboxVidPnCreatePopulateSourceModeSetFromLegacy(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
747 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId,
748 VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, int iPreferredMode, D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID *pPreferredModeId)
749{
750 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
751 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
752 NTSTATUS Status = pVidPnInterface->pfnCreateNewSourceModeSet(hDesiredVidPn,
753 srcId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
754 &hNewVidPnSourceModeSet,
755 &pNewVidPnSourceModeSetInterface);
756 Assert(Status == STATUS_SUCCESS);
757 if (Status == STATUS_SUCCESS)
758 {
759 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
760 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
761 pModes, cModes, iPreferredMode, pPreferredModeId);
762 Assert(Status == STATUS_SUCCESS);
763 if (Status == STATUS_SUCCESS)
764 {
765 Status = pVidPnInterface->pfnAssignSourceModeSet(hDesiredVidPn,
766 srcId,
767 hNewVidPnSourceModeSet);
768 Assert(Status == STATUS_SUCCESS);
769 if(Status != STATUS_SUCCESS)
770 {
771 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
772 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
773 }
774 }
775 else
776 {
777 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
778 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
779 }
780 }
781 else
782 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
783 return Status;
784}
785
786NTSTATUS vboxVidPnCreatePopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
787 D3DDDI_VIDEO_PRESENT_TARGET_ID tgtId,
788 D3DKMDT_2DREGION *pResolutions,
789 uint32_t cResolutions,
790 VIDEO_MODE_INFORMATION *pPreferredMode, uint32_t fFlags,
791 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID *pPreferredModeId)
792{
793 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
794 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
795 NTSTATUS Status = pVidPnInterface->pfnCreateNewTargetModeSet(hDesiredVidPn,
796 tgtId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
797 &hNewVidPnTargetModeSet,
798 &pNewVidPnTargetModeSetInterface);
799 Assert(Status == STATUS_SUCCESS);
800 if (Status == STATUS_SUCCESS)
801 {
802 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
803 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
804 pResolutions, cResolutions, pPreferredMode, fFlags, pPreferredModeId);
805 Assert(Status == STATUS_SUCCESS);
806 if (Status == STATUS_SUCCESS)
807 {
808 Status = pVidPnInterface->pfnAssignTargetModeSet(hDesiredVidPn,
809 tgtId,
810 hNewVidPnTargetModeSet);
811 Assert(Status == STATUS_SUCCESS);
812 if(Status != STATUS_SUCCESS)
813 {
814 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
815 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
816 }
817 }
818 else
819 {
820 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
821 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
822 }
823 }
824 else
825 drprintf((__FUNCTION__": pfnCreateNewTargetModeSet failed Status(0x%x)\n", Status));
826 return Status;
827
828}
829
830typedef struct VBOXVIDPNCHECKADDMONITORMODES
831{
832 NTSTATUS Status;
833 D3DKMDT_2DREGION *pResolutions;
834 uint32_t cResolutions;
835} VBOXVIDPNCHECKADDMONITORMODES, *PVBOXVIDPNCHECKADDMONITORMODES;
836
837static DECLCALLBACK(BOOLEAN) vboxVidPnCheckAddMonitorModesEnum(struct _DEVICE_EXTENSION* pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
838 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI, PVOID pContext)
839{
840 PVBOXVIDPNCHECKADDMONITORMODES pData = (PVBOXVIDPNCHECKADDMONITORMODES)pContext;
841 NTSTATUS Status = STATUS_SUCCESS;
842
843 for (uint32_t i = 0; i < pData->cResolutions; ++i)
844 {
845 D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
846 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &pData->pResolutions[i], FALSE);
847 Assert(Status == STATUS_SUCCESS);
848 if (Status == STATUS_SUCCESS)
849 {
850 if (vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pMonitorSMI->VideoSignalInfo))
851 {
852 /* mark it as unneeded */
853 pData->pResolutions[i].cx = 0;
854 break;
855 }
856 }
857 else
858 {
859 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x)\n", Status));
860 break;
861 }
862 }
863
864 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI);
865
866 pData->Status = Status;
867
868 return Status == STATUS_SUCCESS;
869}
870
871NTSTATUS vboxVidPnCheckAddMonitorModes(PDEVICE_EXTENSION pDevExt,
872 D3DDDI_VIDEO_PRESENT_TARGET_ID targetId, D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
873 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, int32_t iPreferred)
874{
875 NTSTATUS Status;
876#if 0
877 D3DKMDT_2DREGION *pResolutionsCopy = (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cResolutions * sizeof (D3DKMDT_2DREGION));
878 if (pResolutionsCopy)
879 {
880 memcpy(pResolutionsCopy, pResolutions, cResolutions * sizeof (D3DKMDT_2DREGION));
881#endif
882 CONST DXGK_MONITOR_INTERFACE *pMonitorInterface;
883 Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface);
884 Assert(Status == STATUS_SUCCESS);
885 if (Status == STATUS_SUCCESS)
886 {
887 D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
888 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
889 Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
890 targetId,
891 &hMonitorSMS,
892 &pMonitorSMSIf);
893 Assert(Status == STATUS_SUCCESS);
894 if (Status == STATUS_SUCCESS)
895 {
896#if 0
897 VBOXVIDPNCHECKADDMONITORMODES EnumData = {0};
898 EnumData.cResolutions = cResolutions;
899 EnumData.pResolutions = pResolutionsCopy;
900 Status = vboxVidPnEnumMonitorSourceModes(pDevExt, hMonitorSMS, pMonitorSMSIf,
901 vboxVidPnCheckAddMonitorModesEnum, &EnumData);
902 Assert(Status == STATUS_SUCCESS);
903 if (Status == STATUS_SUCCESS)
904 {
905 Assert(EnumData.Status == STATUS_SUCCESS);
906 if (EnumData.Status == STATUS_SUCCESS)
907 {
908#endif
909 for (uint32_t i = 0; i < cResolutions; ++i)
910 {
911#if 0
912 D3DKMDT_2DREGION *pRes = &pResolutionsCopy[i];
913#else
914 D3DKMDT_2DREGION *pRes = &pResolutions[i];
915#endif
916 if (pRes->cx)
917 {
918 Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt,
919 hMonitorSMS,
920 pMonitorSMSIf,
921 pRes,
922 enmOrigin,
923 i == (uint32_t)iPreferred);
924 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET);
925 if (Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET)
926 {
927 Status = STATUS_SUCCESS;
928 }
929 else if (Status != STATUS_SUCCESS)
930 {
931 drprintf((__FUNCTION__": vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)\n", Status));
932 break;
933 }
934 }
935 }
936#if 0
937 }
938 }
939#endif
940 NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
941 Assert(tmpStatus == STATUS_SUCCESS);
942 if (tmpStatus != STATUS_SUCCESS)
943 drprintf((__FUNCTION__": pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)\n", tmpStatus));
944 }
945 else
946 drprintf((__FUNCTION__": pfnAcquireMonitorSourceModeSet failed Status(0x%x)\n", Status));
947 }
948 else
949 drprintf((__FUNCTION__": DxgkCbQueryMonitorInterface failed Status(0x%x)\n", Status));
950#if 0
951 vboxWddmMemFree(pResolutionsCopy);
952 }
953 else
954 {
955 drprintf((__FUNCTION__": failed to allocate resolution copy of size (%d)\n", cResolutions));
956 Status = STATUS_NO_MEMORY;
957 }
958#endif
959
960 return Status;
961}
962
963NTSTATUS vboxVidPnCreatePopulateVidPnFromLegacy(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
964 VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, int iPreferredMode,
965 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions,
966 const D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, const D3DDDI_VIDEO_PRESENT_TARGET_ID tgtId)
967{
968 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
969 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
970 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
971 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID PreferredSrcModeId = D3DDDI_ID_UNINITIALIZED;
972 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
973 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
974
975 NTSTATUS Status = pVidPnInterface->pfnCreateNewSourceModeSet(hVidPn,
976 srcId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
977 &hNewVidPnSourceModeSet,
978 &pNewVidPnSourceModeSetInterface);
979 Assert(Status == STATUS_SUCCESS);
980 if (Status == STATUS_SUCCESS)
981 {
982 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
983 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
984 pModes, cModes, iPreferredMode, &PreferredSrcModeId);
985 Assert(Status == STATUS_SUCCESS);
986 if (Status == STATUS_SUCCESS)
987 {
988 Status = pVidPnInterface->pfnAssignSourceModeSet(hVidPn,
989 srcId,
990 hNewVidPnSourceModeSet);
991 Assert(Status == STATUS_SUCCESS);
992 if(Status == STATUS_SUCCESS)
993 {
994 Assert(PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED);
995 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID PreferredTrgModeId = D3DDDI_ID_UNINITIALIZED;
996 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
997 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
998 NTSTATUS Status = pVidPnInterface->pfnCreateNewTargetModeSet(hVidPn,
999 tgtId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
1000 &hNewVidPnTargetModeSet,
1001 &pNewVidPnTargetModeSetInterface);
1002 Assert(Status == STATUS_SUCCESS);
1003 if (Status == STATUS_SUCCESS)
1004 {
1005 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
1006 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
1007 pResolutions, cResolutions, pPreferredMode, 0, &PreferredTrgModeId);
1008 Assert(Status == STATUS_SUCCESS);
1009 if (Status == STATUS_SUCCESS)
1010 {
1011 Status = pVidPnInterface->pfnAssignTargetModeSet(hVidPn,
1012 tgtId,
1013 hNewVidPnTargetModeSet);
1014 Assert(Status == STATUS_SUCCESS);
1015 if(Status == STATUS_SUCCESS)
1016 {
1017
1018 Assert(PreferredTrgModeId != D3DDDI_ID_UNINITIALIZED);
1019 Status = pVidPnInterface->pfnGetTopology(hVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1020 if (Status == STATUS_SUCCESS)
1021 {
1022 D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo;
1023 Status = pVidPnTopologyInterface->pfnCreateNewPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1024 if (Status == STATUS_SUCCESS)
1025 {
1026 pNewVidPnPresentPathInfo->VidPnSourceId = srcId;
1027 pNewVidPnPresentPathInfo->VidPnTargetId = tgtId;
1028 pNewVidPnPresentPathInfo->ImportanceOrdinal = D3DKMDT_VPPI_PRIMARY;
1029 pNewVidPnPresentPathInfo->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
1030 memset(&pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport,
1031 0, sizeof (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport));
1032 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity = 1;
1033 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered = 0;
1034 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched = 0;
1035 pNewVidPnPresentPathInfo->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
1036 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity = 1;
1037 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180 = 0;
1038 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270 = 0;
1039 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90 = 0;
1040 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx = 0;
1041 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy = 0;
1042 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx = 0;
1043 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy = 0;
1044 pNewVidPnPresentPathInfo->VidPnTargetColorBasis = D3DKMDT_CB_SRGB; /* @todo: how does it matters? */
1045 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel = 8;
1046 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel = 8;
1047 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel = 8;
1048 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel = 0;
1049 pNewVidPnPresentPathInfo->Content = D3DKMDT_VPPC_GRAPHICS;
1050 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_UNINITIALIZED;
1051 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_NOPROTECTION;
1052 pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits = 0;
1053 memset(&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, 0, sizeof (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport));
1054 // pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport.NoProtection = 1;
1055 memset (&pNewVidPnPresentPathInfo->GammaRamp, 0, sizeof (pNewVidPnPresentPathInfo->GammaRamp));
1056 // pNewVidPnPresentPathInfo->GammaRamp.Type = D3DDDI_GAMMARAMP_DEFAULT;
1057 // pNewVidPnPresentPathInfo->GammaRamp.DataSize = 0;
1058 Status = pVidPnTopologyInterface->pfnAddPath(hVidPnTopology, pNewVidPnPresentPathInfo);
1059 Assert(Status == STATUS_SUCCESS);
1060 if (Status == STATUS_SUCCESS)
1061 {
1062 if (PreferredSrcModeId != D3DDDI_ID_UNINITIALIZED)
1063 {
1064 Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, PreferredSrcModeId);
1065 Assert(Status == STATUS_SUCCESS);
1066 if (Status == STATUS_SUCCESS)
1067 {
1068 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, PreferredTrgModeId);
1069 Assert(Status == STATUS_SUCCESS);
1070 if (Status != STATUS_SUCCESS)
1071 drprintf((__FUNCTION__": TRG pfnPinMode failed Status(0x%x)\n", Status));
1072 }
1073 else
1074 drprintf((__FUNCTION__": SRC pfnPinMode failed Status(0x%x)\n", Status));
1075 }
1076 }
1077 else
1078 {
1079 drprintf((__FUNCTION__": pfnAddPath failed Status(0x%x)\n", Status));
1080 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1081 pNewVidPnPresentPathInfo = NULL;
1082 }
1083 }
1084 else
1085 drprintf((__FUNCTION__": pfnCreateNewPathInfo failed Status(0x%x)\n", Status));
1086 }
1087 else
1088 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1089 }
1090 else
1091 {
1092 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
1093 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1094 }
1095 }
1096 else
1097 {
1098 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1099 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
1100 }
1101 }
1102 else
1103 drprintf((__FUNCTION__": pfnCreateNewTargetModeSet failed Status(0x%x)\n", Status));
1104 }
1105 else
1106 {
1107 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
1108 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1109 }
1110 }
1111 else
1112 {
1113 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1114 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
1115 }
1116 }
1117 else
1118 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
1119
1120 return Status;
1121}
1122
1123DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1124 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1125 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
1126{
1127 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
1128 NTSTATUS Status = STATUS_SUCCESS;
1129 pCbContext->Status = STATUS_SUCCESS;
1130 PVBOXWDDM_VIDEOMODES_INFO pInfo = &pCbContext->pInfos[pNewVidPnPresentPathInfo->VidPnTargetId];
1131 VIDEO_MODE_INFORMATION *pModes = pInfo->aModes;
1132 uint32_t cModes = pInfo->cModes;
1133 /* we do not want the mode to be pinned */
1134 int iPreferredMode = -1; /* pInfo->iPreferredMode; */
1135 uint32_t cResolutions = pInfo->cResolutions;
1136 D3DKMDT_2DREGION * pResolutions = pInfo->aResolutions;
1137
1138
1139 /* adjust scaling */
1140 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
1141 {
1142 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
1143 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
1144 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED
1145 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_UNPINNED
1146 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_NOTSPECIFIED)
1147 {
1148 AssertBreakpoint();
1149 /* todo: create a new path (if not done already) and assign a proper info */
1150 }
1151 }
1152
1153 /* adjust rotation */
1154 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
1155 {
1156 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
1157 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
1158 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
1159 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270
1160 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_UNPINNED)
1161 {
1162 AssertBreakpoint();
1163 /* todo: create a new path (if not done already) and assign a proper info */
1164 }
1165 }
1166
1167 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1168 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1169 VIDEO_MODE_INFORMATION *pPreferredMode = iPreferredMode >= 0 ? &pModes[iPreferredMode] : NULL;
1170
1171 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1172 pNewVidPnPresentPathInfo->VidPnSourceId,
1173 &hCurVidPnSourceModeSet,
1174 &pCurVidPnSourceModeSetInterface);
1175 Assert(Status == STATUS_SUCCESS);
1176 if (Status == STATUS_SUCCESS)
1177 {
1178 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1179 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1180 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1181 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1182 {
1183 pPinnedVidPnSourceModeInfo = NULL;
1184 Status = STATUS_SUCCESS;
1185 }
1186 else if (Status != STATUS_SUCCESS)
1187 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1188
1189 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
1190 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
1191 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn,
1192 pNewVidPnPresentPathInfo->VidPnTargetId,
1193 &hCurVidPnTargetModeSet,
1194 &pCurVidPnTargetModeSetInterface);
1195 Assert(Status == STATUS_SUCCESS);
1196 if (Status == STATUS_SUCCESS)
1197 {
1198 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1199 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1200 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1201 if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1202 {
1203 pPinnedVidPnTargetModeInfo = NULL;
1204 Status = STATUS_SUCCESS;
1205 }
1206 else if (Status != STATUS_SUCCESS)
1207 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1208
1209 switch (pCbContext->pEnumCofuncModalityArg->EnumPivotType)
1210 {
1211 case D3DKMDT_EPT_VIDPNSOURCE:
1212 if (!pPinnedVidPnTargetModeInfo)
1213 {
1214 if (pPinnedVidPnSourceModeInfo)
1215 {
1216 SIZE_T cModes;
1217 Status = pCurVidPnTargetModeSetInterface->pfnGetNumModes(hCurVidPnTargetModeSet, &cModes);
1218 Assert(Status == STATUS_SUCCESS);
1219 if (Status == STATUS_SUCCESS)
1220 {
1221 D3DKMDT_2DREGION Resolution;
1222 Resolution.cx = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx;
1223 Resolution.cy = pPinnedVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy;
1224 BOOLEAN bCreateTrg = FALSE;
1225 if (cModes == 1)
1226 {
1227 const D3DKMDT_VIDPN_TARGET_MODE *pVidPnTargetModeInfo;
1228 Status = pCurVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hCurVidPnTargetModeSet, &pVidPnTargetModeInfo);
1229 Assert(Status == STATUS_SUCCESS);
1230 if (Status == STATUS_SUCCESS)
1231 {
1232 D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
1233 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &Resolution, FALSE);
1234 Assert(Status == STATUS_SUCCESS);
1235 if (Status == STATUS_SUCCESS)
1236 {
1237 if (!vboxVidPnMatchVideoSignal(&dummyMode.VideoSignalInfo, &pVidPnTargetModeInfo->VideoSignalInfo))
1238 bCreateTrg = TRUE;
1239 else
1240 {
1241 /* do we need to check pVidPnTargetModeInfo->Preference; ? */
1242 }
1243 }
1244 else
1245 {
1246 drprintf((__FUNCTION__": trg vboxVidPnPopulateTargetModeInfoFromLegacy failed Status(0x%x), pretending success\n", Status));
1247 Status = STATUS_SUCCESS;
1248 bCreateTrg = TRUE;
1249 }
1250 }
1251 else
1252 drprintf((__FUNCTION__": trg pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1253 }
1254 else
1255 bCreateTrg = TRUE;
1256
1257 if (bCreateTrg)
1258 {
1259 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1260 pNewVidPnPresentPathInfo->VidPnTargetId,
1261 &Resolution,
1262 1,
1263 pPreferredMode,
1264 0,
1265 NULL);
1266 Assert(Status == STATUS_SUCCESS);
1267 if (Status != STATUS_SUCCESS)
1268 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy for pinned source failed Status(0x%x)\n", Status)); }
1269 }
1270 else
1271 drprintf((__FUNCTION__": trg pfnGetNumModes failed Status(0x%x)\n", Status));
1272 }
1273 else
1274 {
1275 dprintf((__FUNCTION__": source pivot w/o pinned source mode\n"));
1276// AssertBreakpoint();
1277 }
1278 }
1279 break;
1280 case D3DKMDT_EPT_VIDPNTARGET:
1281 break;
1282 case D3DKMDT_EPT_SCALING:
1283 break;
1284 case D3DKMDT_EPT_ROTATION:
1285 break;
1286 case D3DKMDT_EPT_NOPIVOT:
1287 Assert(!!pPinnedVidPnSourceModeInfo == !!pPinnedVidPnTargetModeInfo);
1288 if (!pPinnedVidPnSourceModeInfo && !pPinnedVidPnTargetModeInfo)
1289 {
1290 /* just create and populate the new source mode set for now */
1291 Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1292 pNewVidPnPresentPathInfo->VidPnSourceId,
1293 pModes, cModes, iPreferredMode, NULL);
1294 Assert(Status == STATUS_SUCCESS);
1295 if (Status == STATUS_SUCCESS)
1296 {
1297 /* just create and populate a new target mode info for now */
1298 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface,
1299 pNewVidPnPresentPathInfo->VidPnTargetId,
1300 pResolutions,
1301 cResolutions,
1302 pPreferredMode,
1303 0,
1304 NULL);
1305 Assert(Status == STATUS_SUCCESS);
1306 if (Status != STATUS_SUCCESS)
1307 drprintf((__FUNCTION__": vboxVidPnCreatePopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
1308 }
1309 else
1310 drprintf((__FUNCTION__": vboxVidPnCreatePopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
1311 }
1312 break;
1313 default:
1314 drprintf((__FUNCTION__": unknown EnumPivotType (%dx)\n", pCbContext->pEnumCofuncModalityArg->EnumPivotType));
1315 break;
1316 }
1317
1318 if (pPinnedVidPnTargetModeInfo)
1319 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1320 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
1321 }
1322 else
1323 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1324
1325 if (pPinnedVidPnSourceModeInfo)
1326 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1327 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1328 }
1329 else
1330 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1331
1332 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1333
1334 pCbContext->Status = Status;
1335 Assert(Status == STATUS_SUCCESS);
1336 return Status == STATUS_SUCCESS;
1337}
1338
1339NTSTATUS vboxVidPnEnumMonitorSourceModes(PDEVICE_EXTENSION pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
1340 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext)
1341{
1342 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI;
1343 NTSTATUS Status = pMonitorSMSIf->pfnAcquireFirstModeInfo(hMonitorSMS, &pMonitorSMI);
1344 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_DATASET_IS_EMPTY);
1345 if (Status == STATUS_SUCCESS)
1346 {
1347 Assert(pMonitorSMI);
1348 while (1)
1349 {
1350 CONST D3DKMDT_MONITOR_SOURCE_MODE *pNextMonitorSMI;
1351 Status = pMonitorSMSIf->pfnAcquireNextModeInfo(hMonitorSMS, pMonitorSMI, &pNextMonitorSMI);
1352 if (!pfnCallback(pDevExt, hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext))
1353 {
1354 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1355 if (Status == STATUS_SUCCESS)
1356 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pNextMonitorSMI);
1357 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1358 {
1359 Status = STATUS_SUCCESS;
1360 break;
1361 }
1362 else
1363 {
1364 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1365 Status = STATUS_SUCCESS;
1366 }
1367 break;
1368 }
1369 else if (Status == STATUS_SUCCESS)
1370 pMonitorSMI = pNextMonitorSMI;
1371 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1372 {
1373 Status = STATUS_SUCCESS;
1374 break;
1375 }
1376 else
1377 {
1378 AssertBreakpoint();
1379 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1380 pNextMonitorSMI = NULL;
1381 break;
1382 }
1383 }
1384 }
1385 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1386 Status = STATUS_SUCCESS;
1387 else
1388 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1389
1390 return Status;
1391}
1392
1393NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1394 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
1395 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
1396{
1397 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1398 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1399 if (Status == STATUS_SUCCESS)
1400 {
1401 Assert(pNewVidPnSourceModeInfo);
1402 while (1)
1403 {
1404 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
1405 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
1406 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1407 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
1408 pNewVidPnSourceModeInfo, pContext))
1409 {
1410 Assert(Status == STATUS_SUCCESS);
1411 if (Status == STATUS_SUCCESS)
1412 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
1413 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1414 {
1415 Status = STATUS_SUCCESS;
1416 break;
1417 }
1418 else
1419 {
1420 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1421 Status = STATUS_SUCCESS;
1422 }
1423
1424 break;
1425 }
1426 else if (Status == STATUS_SUCCESS)
1427 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
1428 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1429 {
1430 Status = STATUS_SUCCESS;
1431 break;
1432 }
1433 else
1434 {
1435 AssertBreakpoint();
1436 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1437 pNewVidPnSourceModeInfo = NULL;
1438 break;
1439 }
1440 }
1441 }
1442 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1443 Status = STATUS_SUCCESS;
1444 else
1445 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1446
1447 return Status;
1448}
1449
1450NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1451 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
1452 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
1453{
1454 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
1455 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
1456 if (Status == STATUS_SUCCESS)
1457 {
1458 Assert(pNewVidPnTargetModeInfo);
1459 while (1)
1460 {
1461 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
1462 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
1463 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
1464 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
1465 pNewVidPnTargetModeInfo, pContext))
1466 {
1467 Assert(Status == STATUS_SUCCESS);
1468 if (Status == STATUS_SUCCESS)
1469 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
1470 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1471 {
1472 Status = STATUS_SUCCESS;
1473 break;
1474 }
1475 else
1476 {
1477 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1478 Status = STATUS_SUCCESS;
1479 }
1480
1481 break;
1482 }
1483 else if (Status == STATUS_SUCCESS)
1484 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
1485 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1486 {
1487 Status = STATUS_SUCCESS;
1488 break;
1489 }
1490 else
1491 {
1492 AssertBreakpoint();
1493 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
1494 pNewVidPnTargetModeInfo = NULL;
1495 break;
1496 }
1497 }
1498 }
1499 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1500 Status = STATUS_SUCCESS;
1501 else
1502 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1503
1504 return Status;
1505}
1506
1507NTSTATUS vboxVidPnEnumTargetsForSource(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1508 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
1509 PFNVBOXVIDPNENUMTARGETSFORSOURCE pfnCallback, PVOID pContext)
1510{
1511 SIZE_T cTgtPaths;
1512 NTSTATUS Status = pVidPnTopologyInterface->pfnGetNumPathsFromSource(hVidPnTopology, VidPnSourceId, &cTgtPaths);
1513 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1514 if (Status == STATUS_SUCCESS)
1515 {
1516 for (SIZE_T i = 0; i < cTgtPaths; ++i)
1517 {
1518 D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId;
1519 Status = pVidPnTopologyInterface->pfnEnumPathTargetsFromSource(hVidPnTopology, VidPnSourceId, i, &VidPnTargetId);
1520 Assert(Status == STATUS_SUCCESS);
1521 if (Status == STATUS_SUCCESS)
1522 {
1523 if (!pfnCallback(pDevExt, hVidPnTopology, pVidPnTopologyInterface, VidPnSourceId, VidPnTargetId, cTgtPaths, pContext))
1524 break;
1525 }
1526 else
1527 {
1528 drprintf((__FUNCTION__": pfnEnumPathTargetsFromSource failed Status(0x%x)\n", Status));
1529 break;
1530 }
1531 }
1532 }
1533 else if (Status != STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1534 drprintf((__FUNCTION__": pfnGetNumPathsFromSource failed Status(0x%x)\n", Status));
1535
1536 return Status;
1537}
1538
1539NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1540 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1541 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
1542{
1543 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
1544 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1545 if (Status == STATUS_SUCCESS)
1546 {
1547 while (1)
1548 {
1549 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
1550 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
1551
1552 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
1553 {
1554 Assert(Status == STATUS_SUCCESS);
1555 if (Status == STATUS_SUCCESS)
1556 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
1557 else
1558 {
1559 Assert(Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET);
1560 if (Status != STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1561 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
1562 Status = STATUS_SUCCESS;
1563 }
1564
1565 break;
1566 }
1567 else if (Status == STATUS_SUCCESS)
1568 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
1569 else if (Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET)
1570 {
1571 Status = STATUS_SUCCESS;
1572 break;
1573 }
1574 else
1575 {
1576 AssertBreakpoint();
1577 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
1578 pNewVidPnPresentPathInfo = NULL;
1579 break;
1580 }
1581 }
1582 }
1583 else if (Status == STATUS_GRAPHICS_DATASET_IS_EMPTY)
1584 Status = STATUS_SUCCESS;
1585 else
1586 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
1587
1588 return Status;
1589}
1590
1591NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1592{
1593 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, srcId);
1594 return STATUS_SUCCESS;
1595}
1596
1597NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
1598{
1599 Assert(srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays);
1600 if (srcId < (UINT)commonFromDeviceExt(pDevExt)->cDisplays)
1601 {
1602 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[srcId];
1603 return vboxVidPnSetupSourceInfo(pDevExt, srcId, pSource, pVidPnSourceModeInfo, pAllocation);
1604 }
1605
1606 drprintf((__FUNCTION__": invalid srcId (%d), cSources(%d)\n", srcId, commonFromDeviceExt(pDevExt)->cDisplays));
1607 return STATUS_INVALID_PARAMETER;
1608}
1609
1610typedef struct VBOXVIDPNCOMMITTARGETMODE
1611{
1612 NTSTATUS Status;
1613 D3DKMDT_HVIDPN hVidPn;
1614 const DXGK_VIDPN_INTERFACE* pVidPnInterface;
1615} VBOXVIDPNCOMMITTARGETMODE;
1616
1617DECLCALLBACK(BOOLEAN) vboxVidPnCommitTargetModeEnum(PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1618 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, SIZE_T cTgtPaths, PVOID pContext)
1619{
1620 VBOXVIDPNCOMMITTARGETMODE *pInfo = (VBOXVIDPNCOMMITTARGETMODE*)pContext;
1621 Assert(cTgtPaths <= (SIZE_T)commonFromDeviceExt(pDevExt)->cDisplays);
1622 D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet;
1623 CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface;
1624 NTSTATUS Status = pInfo->pVidPnInterface->pfnAcquireTargetModeSet(pInfo->hVidPn, VidPnTargetId, &hVidPnTargetModeSet, &pVidPnTargetModeSetInterface);
1625 Assert(Status == STATUS_SUCCESS);
1626 if (Status == STATUS_SUCCESS)
1627 {
1628 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
1629 Status = pVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
1630 Assert(Status == STATUS_SUCCESS);
1631 if (Status == STATUS_SUCCESS)
1632 {
1633 VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[VidPnTargetId];
1634 if (pTarget->HeightVisible != pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy
1635 || pTarget->HeightTotal != pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
1636 {
1637 pTarget->HeightVisible = pPinnedVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy;
1638 pTarget->HeightTotal = pPinnedVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy;
1639 pTarget->ScanLineState = 0;
1640 }
1641 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
1642 }
1643
1644 pInfo->pVidPnInterface->pfnReleaseTargetModeSet(pInfo->hVidPn, hVidPnTargetModeSet);
1645 }
1646 else
1647 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
1648
1649 pInfo->Status = Status;
1650 return Status == STATUS_SUCCESS;
1651}
1652
1653NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
1654{
1655 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
1656 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
1657
1658 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
1659 srcId,
1660 &hCurVidPnSourceModeSet,
1661 &pCurVidPnSourceModeSetInterface);
1662 Assert(Status == STATUS_SUCCESS);
1663 if (Status == STATUS_SUCCESS)
1664 {
1665 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
1666 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
1667 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
1668 if (Status == STATUS_SUCCESS)
1669 {
1670 Assert(pPinnedVidPnSourceModeInfo);
1671 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, pPinnedVidPnSourceModeInfo, pAllocation);
1672 Assert(Status == STATUS_SUCCESS);
1673 if (Status == STATUS_SUCCESS)
1674 {
1675 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1676 CONST DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1677 Status = pVidPnInterface->pfnGetTopology(hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1678 Assert(Status == STATUS_SUCCESS);
1679 if (Status == STATUS_SUCCESS)
1680 {
1681 VBOXVIDPNCOMMITTARGETMODE TgtModeInfo = {0};
1682 TgtModeInfo.Status = STATUS_SUCCESS; /* <- to ensure we're succeeded if no targets are set */
1683 TgtModeInfo.hVidPn = hDesiredVidPn;
1684 TgtModeInfo.pVidPnInterface = pVidPnInterface;
1685 Status = vboxVidPnEnumTargetsForSource(pDevExt, hVidPnTopology, pVidPnTopologyInterface,
1686 srcId,
1687 vboxVidPnCommitTargetModeEnum, &TgtModeInfo);
1688 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY);
1689 if (Status == STATUS_SUCCESS)
1690 {
1691 Status = TgtModeInfo.Status;
1692 Assert(Status == STATUS_SUCCESS);
1693 }
1694 else if (Status == STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY)
1695 {
1696 Status = STATUS_SUCCESS;
1697 }
1698 else
1699 drprintf((__FUNCTION__": vboxVidPnEnumTargetsForSource failed Status(0x%x)\n", Status));
1700 }
1701 else
1702 drprintf((__FUNCTION__": pfnGetTopology failed Status(0x%x)\n", Status));
1703 }
1704 else
1705 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
1706 /* release */
1707 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
1708 }
1709 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
1710 {
1711 Status = vboxVidPnCommitSourceMode(pDevExt, srcId, NULL, pAllocation);
1712 Assert(Status == STATUS_SUCCESS);
1713 }
1714 else
1715 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
1716
1717 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
1718 }
1719 else
1720 {
1721 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
1722 }
1723
1724 return Status;
1725}
1726
1727DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
1728 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
1729 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
1730{
1731 NTSTATUS Status = STATUS_SUCCESS;
1732 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
1733
1734 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
1735 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
1736 {
1737 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
1738 Assert(Status == STATUS_SUCCESS);
1739 if (Status != STATUS_SUCCESS)
1740 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
1741 }
1742
1743 pCommitInfo->Status = Status;
1744 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
1745 return Status == STATUS_SUCCESS;
1746}
1747
1748#define VBOXVIDPNDUMP_STRCASE(_t) \
1749 case _t: return #_t;
1750#define VBOXVIDPNDUMP_STRCASE_UNKNOWN() \
1751 default: Assert(0); return "Unknown";
1752
1753#define VBOXVIDPNDUMP_STRFLAGS(_v, _t) \
1754 if ((_v)._t return #_t;
1755
1756const char* vboxVidPnDumpStrImportance(D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE ImportanceOrdinal)
1757{
1758 switch (ImportanceOrdinal)
1759 {
1760 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_UNINITIALIZED);
1761 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_PRIMARY);
1762 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_SECONDARY);
1763 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_TERTIARY);
1764 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_QUATERNARY);
1765 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_QUINARY);
1766 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_SENARY);
1767 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_SEPTENARY);
1768 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_OCTONARY);
1769 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_NONARY);
1770 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPI_DENARY);
1771 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1772 }
1773}
1774
1775const char* vboxVidPnDumpStrScaling(D3DKMDT_VIDPN_PRESENT_PATH_SCALING Scaling)
1776{
1777 switch (Scaling)
1778 {
1779 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_UNINITIALIZED);
1780 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_IDENTITY);
1781 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_CENTERED);
1782 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_STRETCHED);
1783 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_UNPINNED);
1784 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPS_NOTSPECIFIED);
1785 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1786 }
1787}
1788
1789const char* vboxVidPnDumpStrRotation(D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation)
1790{
1791 switch (Rotation)
1792 {
1793 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_UNINITIALIZED);
1794 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_IDENTITY);
1795 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_ROTATE90);
1796 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_ROTATE180);
1797 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_ROTATE270);
1798 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_UNPINNED);
1799 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPR_NOTSPECIFIED);
1800 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1801 }
1802}
1803
1804const char* vboxVidPnDumpStrColorBasis(const D3DKMDT_COLOR_BASIS ColorBasis)
1805{
1806 switch (ColorBasis)
1807 {
1808 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_UNINITIALIZED);
1809 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_INTENSITY);
1810 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_SRGB);
1811 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_SCRGB);
1812 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_YCBCR);
1813 VBOXVIDPNDUMP_STRCASE(D3DKMDT_CB_YPBPR);
1814 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1815 }
1816}
1817
1818const char* vboxVidPnDumpStrPvam(D3DKMDT_PIXEL_VALUE_ACCESS_MODE PixelValueAccessMode)
1819{
1820 switch (PixelValueAccessMode)
1821 {
1822 VBOXVIDPNDUMP_STRCASE(D3DKMDT_PVAM_UNINITIALIZED);
1823 VBOXVIDPNDUMP_STRCASE(D3DKMDT_PVAM_DIRECT);
1824 VBOXVIDPNDUMP_STRCASE(D3DKMDT_PVAM_PRESETPALETTE);
1825 VBOXVIDPNDUMP_STRCASE(D3DKMDT_PVAM_SETTABLEPALETTE);
1826 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1827 }
1828}
1829
1830
1831
1832const char* vboxVidPnDumpStrContent(D3DKMDT_VIDPN_PRESENT_PATH_CONTENT Content)
1833{
1834 switch (Content)
1835 {
1836 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPC_UNINITIALIZED);
1837 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPC_GRAPHICS);
1838 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPC_VIDEO);
1839 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPC_NOTSPECIFIED);
1840 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1841 }
1842}
1843
1844const char* vboxVidPnDumpStrCopyProtectionType(D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE CopyProtectionType)
1845{
1846 switch (CopyProtectionType)
1847 {
1848 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPMT_UNINITIALIZED);
1849 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPMT_NOPROTECTION);
1850 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPMT_MACROVISION_APSTRIGGER);
1851 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VPPMT_MACROVISION_FULLSUPPORT);
1852 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1853 }
1854}
1855
1856const char* vboxVidPnDumpStrGammaRampType(D3DDDI_GAMMARAMP_TYPE Type)
1857{
1858 switch (Type)
1859 {
1860 VBOXVIDPNDUMP_STRCASE(D3DDDI_GAMMARAMP_UNINITIALIZED);
1861 VBOXVIDPNDUMP_STRCASE(D3DDDI_GAMMARAMP_DEFAULT);
1862 VBOXVIDPNDUMP_STRCASE(D3DDDI_GAMMARAMP_RGB256x3x16);
1863 VBOXVIDPNDUMP_STRCASE(D3DDDI_GAMMARAMP_DXGI_1);
1864 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1865 }
1866}
1867
1868const char* vboxVidPnDumpStrSourceModeType(D3DKMDT_VIDPN_SOURCE_MODE_TYPE Type)
1869{
1870 switch (Type)
1871 {
1872 VBOXVIDPNDUMP_STRCASE(D3DKMDT_RMT_UNINITIALIZED);
1873 VBOXVIDPNDUMP_STRCASE(D3DKMDT_RMT_GRAPHICS);
1874 VBOXVIDPNDUMP_STRCASE(D3DKMDT_RMT_TEXT);
1875 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1876 }
1877}
1878
1879const char* vboxVidPnDumpStrScanLineOrdering(D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING ScanLineOrdering)
1880{
1881 switch (ScanLineOrdering)
1882 {
1883 VBOXVIDPNDUMP_STRCASE(D3DDDI_VSSLO_UNINITIALIZED);
1884 VBOXVIDPNDUMP_STRCASE(D3DDDI_VSSLO_PROGRESSIVE);
1885 VBOXVIDPNDUMP_STRCASE(D3DDDI_VSSLO_INTERLACED_UPPERFIELDFIRST);
1886 VBOXVIDPNDUMP_STRCASE(D3DDDI_VSSLO_INTERLACED_LOWERFIELDFIRST);
1887 VBOXVIDPNDUMP_STRCASE(D3DDDI_VSSLO_OTHER);
1888 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1889 }
1890}
1891
1892const char* vboxVidPnDumpStrCFMPivotType(D3DKMDT_ENUMCOFUNCMODALITY_PIVOT_TYPE EnumPivotType)
1893{
1894 switch (EnumPivotType)
1895 {
1896 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_UNINITIALIZED);
1897 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_VIDPNSOURCE);
1898 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_VIDPNTARGET);
1899 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_SCALING);
1900 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_ROTATION);
1901 VBOXVIDPNDUMP_STRCASE(D3DKMDT_EPT_NOPIVOT);
1902 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1903 }
1904}
1905
1906const char* vboxVidPnDumpStrModePreference(D3DKMDT_MODE_PREFERENCE Preference)
1907{
1908 switch (Preference)
1909 {
1910 VBOXVIDPNDUMP_STRCASE(D3DKMDT_MP_UNINITIALIZED);
1911 VBOXVIDPNDUMP_STRCASE(D3DKMDT_MP_PREFERRED);
1912 VBOXVIDPNDUMP_STRCASE(D3DKMDT_MP_NOTPREFERRED);
1913 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1914 }
1915}
1916
1917const char* vboxVidPnDumpStrSignalStandard(D3DKMDT_VIDEO_SIGNAL_STANDARD VideoStandard)
1918{
1919 switch (VideoStandard)
1920 {
1921 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_UNINITIALIZED);
1922 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_VESA_DMT);
1923 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_VESA_GTF);
1924 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_VESA_CVT);
1925 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_IBM);
1926 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_APPLE);
1927 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_NTSC_M);
1928 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_NTSC_J);
1929 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_NTSC_443);
1930 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_B);
1931 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_B1);
1932 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_G);
1933 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_H);
1934 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_I);
1935 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_D);
1936 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_N);
1937 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_NC);
1938 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_B);
1939 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_D);
1940 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_G);
1941 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_H);
1942 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_K);
1943 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_K1);
1944 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_L);
1945 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_SECAM_L1);
1946 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_EIA_861);
1947 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_EIA_861A);
1948 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_EIA_861B);
1949 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_K);
1950 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_K1);
1951 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_L);
1952 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_PAL_M);
1953 VBOXVIDPNDUMP_STRCASE(D3DKMDT_VSS_OTHER);
1954 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
1955 }
1956}
1957
1958const char* vboxVidPnDumpStrPixFormat(D3DDDIFORMAT PixelFormat)
1959{
1960 switch (PixelFormat)
1961 {
1962 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_UNKNOWN);
1963 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R8G8B8);
1964 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8R8G8B8);
1965 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X8R8G8B8);
1966 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R5G6B5);
1967 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X1R5G5B5);
1968 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A1R5G5B5);
1969 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A4R4G4B4);
1970 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R3G3B2);
1971 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8);
1972 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8R3G3B2);
1973 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X4R4G4B4);
1974 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A2B10G10R10);
1975 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8B8G8R8);
1976 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X8B8G8R8);
1977 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_G16R16);
1978 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A2R10G10B10);
1979 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A16B16G16R16);
1980 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8P8);
1981 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R32F);
1982 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_G32R32F);
1983 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A32B32G32R32F);
1984 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_CxV8U8);
1985 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A1);
1986 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_BINARYBUFFER);
1987 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_VERTEXDATA);
1988 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_INDEX16);
1989 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_INDEX32);
1990 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_Q16W16V16U16);
1991 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_MULTI2_ARGB8);
1992 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R16F);
1993 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_G16R16F);
1994 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A16B16G16R16F);
1995 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D32F_LOCKABLE);
1996 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D24FS8);
1997 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D32_LOCKABLE);
1998 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_S8_LOCKABLE);
1999 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_S1D15);
2000 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_S8D24);
2001 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X8D24);
2002 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X4S4D24);
2003 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_L16);
2004 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_UYVY);
2005 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_R8G8_B8G8);
2006 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_YUY2);
2007 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_G8R8_G8B8);
2008 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_DXT1);
2009 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_DXT2);
2010 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_DXT3);
2011 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_DXT4);
2012 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_DXT5);
2013 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D16_LOCKABLE);
2014 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D32);
2015 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D15S1);
2016 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D24S8);
2017 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D24X8);
2018 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D24X4S4);
2019 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_D16);
2020 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_P8);
2021 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_L8);
2022 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A8L8);
2023 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A4L4);
2024 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_V8U8);
2025 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_L6V5U5);
2026 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_X8L8V8U8);
2027 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_Q8W8V8U8);
2028 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_V16U16);
2029 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_W11V11U10);
2030 VBOXVIDPNDUMP_STRCASE(D3DDDIFMT_A2W10V10U10);
2031 VBOXVIDPNDUMP_STRCASE_UNKNOWN();
2032 }
2033}
2034
2035void vboxVidPnDumpCopyProtectoin(const D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION *pCopyProtection)
2036{
2037 drprintf(("CopyProtection: CopyProtectionType(%s), TODO: Dump All the rest\n",
2038 vboxVidPnDumpStrCopyProtectionType(pCopyProtection->CopyProtectionType)));
2039}
2040
2041
2042void vboxVidPnDumpPathTransformation(const D3DKMDT_VIDPN_PRESENT_PATH_TRANSFORMATION *pContentTransformation)
2043{
2044 drprintf(("Transformation: Scaling(%s), ScalingSupport(%d), Rotation(%s), RotationSupport(%d)\n",
2045 vboxVidPnDumpStrScaling(pContentTransformation->Scaling), pContentTransformation->ScalingSupport,
2046 vboxVidPnDumpStrRotation(pContentTransformation->Rotation), pContentTransformation->RotationSupport));
2047}
2048
2049void vboxVidPnDumpRegion(const char *pPrefix, const D3DKMDT_2DREGION *pRegion, const char *pSuffix)
2050{
2051 drprintf(("%s%dX%d%s", pPrefix, pRegion->cx, pRegion->cy, pSuffix));
2052}
2053
2054void vboxVidPnDumpRational(const char *pPrefix, const D3DDDI_RATIONAL *pRational, const char *pSuffix)
2055{
2056 drprintf(("%s%d/%d=%d%s", pPrefix, pRational->Numerator, pRational->Denominator, pRational->Numerator/pRational->Denominator, pSuffix));
2057}
2058
2059void vboxVidPnDumpRanges(const char *pPrefix, const D3DKMDT_COLOR_COEFF_DYNAMIC_RANGES *pDynamicRanges, const char *pSuffix)
2060{
2061 drprintf(("%sFirstChannel(%d), SecondChannel(%d), ThirdChannel(%d), FourthChannel(%d)%s", pPrefix,
2062 pDynamicRanges->FirstChannel,
2063 pDynamicRanges->SecondChannel,
2064 pDynamicRanges->ThirdChannel,
2065 pDynamicRanges->FourthChannel,
2066 pSuffix));
2067}
2068
2069void vboxVidPnDumpGammaRamp(const char *pPrefix, const D3DKMDT_GAMMA_RAMP *pGammaRamp, const char *pSuffix)
2070{
2071 drprintf(("%sType(%s), DataSize(%d), TODO: dump the rest%s", pPrefix,
2072 vboxVidPnDumpStrGammaRampType(pGammaRamp->Type), pGammaRamp->DataSize,
2073 pSuffix));
2074}
2075
2076void vboxVidPnDumpSourceMode(const char *pPrefix, const D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, const char *pSuffix)
2077{
2078 drprintf(("%sType(%s), ", pPrefix, vboxVidPnDumpStrSourceModeType(pVidPnSourceModeInfo->Type)));
2079 vboxVidPnDumpRegion("surf(", &pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize, "), ");
2080 vboxVidPnDumpRegion("vis(", &pVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize, "), ");
2081 drprintf(("stride(%d), ", pVidPnSourceModeInfo->Format.Graphics.Stride));
2082 drprintf(("format(%s), ", vboxVidPnDumpStrPixFormat(pVidPnSourceModeInfo->Format.Graphics.PixelFormat)));
2083 drprintf(("clrBasis(%s), ", vboxVidPnDumpStrColorBasis(pVidPnSourceModeInfo->Format.Graphics.ColorBasis)));
2084 drprintf(("pvam(%s)%s", vboxVidPnDumpStrPvam(pVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode), pSuffix));
2085}
2086
2087void vboxVidPnDumpSignalInfo(const char *pPrefix, const D3DKMDT_VIDEO_SIGNAL_INFO *pVideoSignalInfo, const char *pSuffix)
2088{
2089 drprintf(("%sVStd(%s), ", pPrefix, vboxVidPnDumpStrSignalStandard(pVideoSignalInfo->VideoStandard)));
2090 vboxVidPnDumpRegion("totSize(", &pVideoSignalInfo->TotalSize, "), ");
2091 vboxVidPnDumpRegion("activeSize(", &pVideoSignalInfo->ActiveSize, "), ");
2092 vboxVidPnDumpRational("VSynch(", &pVideoSignalInfo->VSyncFreq, "), ");
2093 drprintf(("PixelRate(%d), ScanLineOrdering(%s)%s\n", pVideoSignalInfo->PixelRate, vboxVidPnDumpStrScanLineOrdering(pVideoSignalInfo->ScanLineOrdering), pSuffix));
2094}
2095
2096void vboxVidPnDumpTargetMode(const char *pPrefix, const D3DKMDT_VIDPN_TARGET_MODE* CONST pVidPnTargetModeInfo, const char *pSuffix)
2097{
2098 drprintf(("%s", pPrefix));
2099 vboxVidPnDumpSignalInfo("VSI: ", &pVidPnTargetModeInfo->VideoSignalInfo, ", ");
2100 drprintf(("Preference(%s)%s", vboxVidPnDumpStrModePreference(pVidPnTargetModeInfo->Preference), pPrefix));
2101}
2102
2103void vboxVidPnDumpPinnedSourceMode(const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
2104{
2105 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
2106 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
2107
2108 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hVidPn,
2109 VidPnSourceId,
2110 &hCurVidPnSourceModeSet,
2111 &pCurVidPnSourceModeSetInterface);
2112 Assert(Status == STATUS_SUCCESS);
2113 if (Status == STATUS_SUCCESS)
2114 {
2115 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
2116
2117 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
2118 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
2119 if (Status == STATUS_SUCCESS)
2120 {
2121 vboxVidPnDumpSourceMode("Source Pinned: ", pPinnedVidPnSourceModeInfo, "\n");
2122 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
2123 }
2124 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
2125 {
2126 drprintf(("Source NOT Pinned\n"));
2127 }
2128 else
2129 {
2130 drprintf(("ERROR getting piined Source Mode(0x%x)\n", Status));
2131 }
2132 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hCurVidPnSourceModeSet);
2133 }
2134 else
2135 {
2136 drprintf(("ERROR getting SourceModeSet(0x%x)\n", Status));
2137 }
2138}
2139
2140
2141static DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
2142 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
2143 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
2144{
2145 vboxVidPnDumpSourceMode("SourceMode: ", pNewVidPnSourceModeInfo, "\n");
2146 return TRUE;
2147}
2148
2149void vboxVidPnDumpSourceModeSet(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
2150{
2151 drprintf((" >>>+++SourceMode Set for Source(%d)+++\n", VidPnSourceId));
2152 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
2153 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
2154
2155 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hVidPn,
2156 VidPnSourceId,
2157 &hCurVidPnSourceModeSet,
2158 &pCurVidPnSourceModeSetInterface);
2159 Assert(Status == STATUS_SUCCESS);
2160 if (Status == STATUS_SUCCESS)
2161 {
2162
2163 Status = vboxVidPnEnumSourceModes(pDevExt, hVidPn, pVidPnInterface, hCurVidPnSourceModeSet, pCurVidPnSourceModeSetInterface,
2164 vboxVidPnDumpSourceModeSetEnum, NULL);
2165 Assert(Status == STATUS_SUCCESS);
2166 if (Status != STATUS_SUCCESS)
2167 {
2168 drprintf(("ERROR enumerating Source Modes(0x%x)\n", Status));
2169 }
2170 pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hCurVidPnSourceModeSet);
2171 }
2172 else
2173 {
2174 drprintf(("ERROR getting SourceModeSet for Source(%d), Status(0x%x)\n", VidPnSourceId, Status));
2175 }
2176
2177 drprintf((" <<<+++End Of SourceMode Set for Source(%d)+++\n", VidPnSourceId));
2178}
2179
2180DECLCALLBACK(BOOLEAN) vboxVidPnDumpTargetModeSetEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
2181 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
2182 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
2183{
2184 vboxVidPnDumpTargetMode("TargetMode: ", pNewVidPnTargetModeInfo, "\n");
2185 return TRUE;
2186}
2187
2188void vboxVidPnDumpTargetModeSet(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
2189{
2190 drprintf((" >>>---TargetMode Set for Target(%d)---\n", VidPnTargetId));
2191 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
2192 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
2193
2194 NTSTATUS Status = pVidPnInterface->pfnAcquireTargetModeSet(hVidPn,
2195 VidPnTargetId,
2196 &hCurVidPnTargetModeSet,
2197 &pCurVidPnTargetModeSetInterface);
2198 Assert(Status == STATUS_SUCCESS);
2199 if (Status == STATUS_SUCCESS)
2200 {
2201
2202 Status = vboxVidPnEnumTargetModes(pDevExt, hVidPn, pVidPnInterface, hCurVidPnTargetModeSet, pCurVidPnTargetModeSetInterface,
2203 vboxVidPnDumpTargetModeSetEnum, NULL);
2204 Assert(Status == STATUS_SUCCESS);
2205 if (Status != STATUS_SUCCESS)
2206 {
2207 drprintf(("ERROR enumerating Target Modes(0x%x)\n", Status));
2208 }
2209 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hCurVidPnTargetModeSet);
2210 }
2211 else
2212 {
2213 drprintf(("ERROR getting TargetModeSet for Target(%d), Status(0x%x)\n", VidPnTargetId, Status));
2214 }
2215
2216 drprintf((" <<<---End Of TargetMode Set for Target(%d)---\n", VidPnTargetId));
2217}
2218
2219
2220void vboxVidPnDumpPinnedTargetMode(const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
2221{
2222 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
2223 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
2224
2225 NTSTATUS Status = pVidPnInterface->pfnAcquireTargetModeSet(hVidPn,
2226 VidPnTargetId,
2227 &hCurVidPnTargetModeSet,
2228 &pCurVidPnTargetModeSetInterface);
2229 Assert(Status == STATUS_SUCCESS);
2230 if (Status == STATUS_SUCCESS)
2231 {
2232 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
2233
2234 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
2235 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_NOT_PINNED);
2236 if (Status == STATUS_SUCCESS)
2237 {
2238 vboxVidPnDumpTargetMode("Target Pinned: ", pPinnedVidPnTargetModeInfo, "\n");
2239 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
2240 }
2241 else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
2242 {
2243 drprintf(("Target NOT Pinned\n"));
2244 }
2245 else
2246 {
2247 drprintf(("ERROR getting piined Target Mode(0x%x)\n", Status));
2248 }
2249 pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hCurVidPnTargetModeSet);
2250 }
2251 else
2252 {
2253 drprintf(("ERROR getting TargetModeSet(0x%x)\n", Status));
2254 }
2255}
2256
2257void vboxVidPnDumpCofuncModalityArg(const char *pPrefix, CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModalityArg, const char *pSuffix)
2258{
2259 drprintf(("%sPivotType(%s), SourceId(0x%x), TargetId(0x%x),%s", pPrefix, vboxVidPnDumpStrCFMPivotType(pEnumCofuncModalityArg->EnumPivotType),
2260 pEnumCofuncModalityArg->EnumPivot.VidPnSourceId, pEnumCofuncModalityArg->EnumPivot.VidPnTargetId, pSuffix));
2261}
2262
2263void vboxVidPnDumpPath(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
2264 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo)
2265{
2266 drprintf((" >>**** Start Dump VidPn Path ****>>\n"));
2267 drprintf(("VidPnSourceId(%d), VidPnTargetId(%d)\n",
2268 pVidPnPresentPathInfo->VidPnSourceId, pVidPnPresentPathInfo->VidPnTargetId));
2269
2270 vboxVidPnDumpPinnedSourceMode(hVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId);
2271 vboxVidPnDumpPinnedTargetMode(hVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnTargetId);
2272
2273 drprintf(("ImportanceOrdinal(%s), VidPnTargetColorBasis(%s), Content(%s)\n",
2274 vboxVidPnDumpStrImportance(pVidPnPresentPathInfo->ImportanceOrdinal),
2275 vboxVidPnDumpStrColorBasis(pVidPnPresentPathInfo->VidPnTargetColorBasis),
2276 vboxVidPnDumpStrContent(pVidPnPresentPathInfo->Content)));
2277 vboxVidPnDumpPathTransformation(&pVidPnPresentPathInfo->ContentTransformation);
2278 vboxVidPnDumpRegion("VisibleFromActiveTLOffset(", &pVidPnPresentPathInfo->VisibleFromActiveTLOffset, ")\n");
2279 vboxVidPnDumpRegion("VisibleFromActiveBROffset(", &pVidPnPresentPathInfo->VisibleFromActiveBROffset, ")\n");
2280 vboxVidPnDumpRanges("VidPnTargetColorCoeffDynamicRanges: ", &pVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges, "\n");
2281 vboxVidPnDumpCopyProtectoin(&pVidPnPresentPathInfo->CopyProtection);
2282 vboxVidPnDumpGammaRamp("GammaRamp: ", &pVidPnPresentPathInfo->GammaRamp, "\n");
2283
2284 drprintf((" <<**** Stop Dump VidPn Path ****<<\n"));
2285}
2286
2287static DECLCALLBACK(BOOLEAN) vboxVidPnDumpPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
2288 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
2289 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
2290{
2291 vboxVidPnDumpPath(pDevExt, hVidPn, pVidPnInterface, pVidPnPresentPathInfo);
2292
2293 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
2294 return TRUE;
2295}
2296
2297void vboxVidPnDumpVidPn(const char * pPrefix, PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const char * pSuffix)
2298{
2299 drprintf (("%s", pPrefix));
2300
2301 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
2302 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
2303 NTSTATUS Status = pVidPnInterface->pfnGetTopology(hVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
2304 Assert(Status == STATUS_SUCCESS);
2305 if (Status == STATUS_SUCCESS)
2306 {
2307 Status = vboxVidPnEnumPaths(pDevExt, hVidPn, pVidPnInterface,
2308 hVidPnTopology, pVidPnTopologyInterface,
2309 vboxVidPnDumpPathEnum, NULL);
2310 Assert(Status == STATUS_SUCCESS);
2311 }
2312
2313 for (int i = 0; i < commonFromDeviceExt(pDevExt)->cDisplays; ++i)
2314 {
2315 vboxVidPnDumpSourceModeSet(pDevExt, hVidPn, pVidPnInterface, (D3DDDI_VIDEO_PRESENT_SOURCE_ID)i);
2316 vboxVidPnDumpTargetModeSet(pDevExt, hVidPn, pVidPnInterface, (D3DDDI_VIDEO_PRESENT_TARGET_ID)i);
2317 }
2318
2319 drprintf (("%s", pSuffix));
2320}
Note: See TracBrowser for help on using the repository browser.

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