VirtualBox

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

Last change on this file since 26794 was 26794, checked in by vboxsync, 15 years ago

wddm: more impl + bugfix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.5 KB
Line 
1/*
2 * Copyright (C) 2010 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
13 * Clara, CA 95054 USA or visit http://www.sun.com if you need
14 * additional information or have any questions.
15 */
16#include "../VBoxVideo.h"
17#include "../Helper.h"
18
19NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
20 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
21 BOOLEAN *pbSupported)
22{
23 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
24 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
25 BOOLEAN bSupported = TRUE;
26
27 while (pNewVidPnPresentPathInfo)
28 {
29 /* @todo: which paths do we support? no matter for now
30 pNewVidPnPresentPathInfo->VidPnSourceId
31 pNewVidPnPresentPathInfo->VidPnTargetId
32
33 ImportanceOrdinal does not matter for now
34 pNewVidPnPresentPathInfo->ImportanceOrdinal
35 */
36
37 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
38 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED)
39 {
40 dprintf(("unsupported Scaling (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Scaling));
41 bSupported = FALSE;
42 break;
43 }
44
45 if (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched)
46 {
47 dprintf(("unsupported Scaling support (Stretched)\n"));
48 bSupported = FALSE;
49 break;
50 }
51
52 if (!pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity
53 && !pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered)
54 {
55 dprintf(("\"Identity\" or \"Centered\" Scaling support not set\n"));
56 bSupported = FALSE;
57 break;
58 }
59
60 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY)
61 {
62 dprintf(("unsupported rotation (%d)\n", pNewVidPnPresentPathInfo->ContentTransformation.Rotation));
63 bSupported = FALSE;
64 break;
65 }
66
67 if (pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180
68 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270
69 || pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90)
70 {
71 dprintf(("unsupported RotationSupport\n"));
72 bSupported = FALSE;
73 break;
74 }
75
76 if (!pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity)
77 {
78 dprintf(("\"Identity\" RotationSupport not set\n"));
79 bSupported = FALSE;
80 break;
81 }
82
83 if (pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx
84 || pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy)
85 {
86 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
87 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx,
88 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy));
89 bSupported = FALSE;
90 break;
91 }
92
93 if (pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx
94 || pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy)
95 {
96 dprintf(("Non-zero TLOffset: cx(%d), cy(%d)\n",
97 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx,
98 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy));
99 bSupported = FALSE;
100 break;
101 }
102
103 if (pNewVidPnPresentPathInfo->VidPnTargetColorBasis != D3DKMDT_CB_SRGB)
104 {
105 dprintf(("unsupported VidPnTargetColorBasis (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorBasis));
106 bSupported = FALSE;
107 break;
108 }
109
110 /* channels?
111 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel;
112 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel;
113 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel;
114 we definitely not support fourth channel
115 */
116 if (pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel)
117 {
118 dprintf(("Non-zero FourthChannel (%d)\n", pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel));
119 bSupported = FALSE;
120 break;
121 }
122
123 /* Content (D3DKMDT_VPPC_GRAPHICS, _NOTSPECIFIED, _VIDEO), does not matter for now
124 pNewVidPnPresentPathInfo->Content
125 */
126 /* not support copy protection for now */
127 if (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType != D3DKMDT_VPPMT_NOPROTECTION)
128 {
129 dprintf(("Copy protection not supported CopyProtectionType(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType));
130 bSupported = FALSE;
131 break;
132 }
133
134 if (pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits)
135 {
136 dprintf(("Copy protection not supported APSTriggerBits(%d)\n", pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits));
137 bSupported = FALSE;
138 break;
139 }
140
141 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_SUPPORT tstCPSupport = {0};
142 tstCPSupport.NoProtection = 1;
143 if (memcmp(&tstCPSupport, &pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, sizeof(tstCPSupport)))
144 {
145 dprintf(("Copy protection support (0x%x)\n", *((UINT*)&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport)));
146 bSupported = FALSE;
147 break;
148 }
149
150 if (pNewVidPnPresentPathInfo->GammaRamp.Type != D3DDDI_GAMMARAMP_DEFAULT)
151 {
152 dprintf(("Unsupported GammaRamp.Type (%d)\n", pNewVidPnPresentPathInfo->GammaRamp.Type));
153 bSupported = FALSE;
154 break;
155 }
156
157 if (pNewVidPnPresentPathInfo->GammaRamp.DataSize != 0)
158 {
159 dprintf(("Warning: non-zero GammaRamp.DataSize (%d), treating as supported\n", pNewVidPnPresentPathInfo->GammaRamp.DataSize));
160 }
161
162 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
163
164 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
165 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
166 if (Status == STATUS_SUCCESS)
167 {
168 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
169 }
170 else
171 {
172 AssertBreakpoint();
173 dprintf(("pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
174 pNewVidPnPresentPathInfo = NULL;
175 break;
176 }
177 }
178
179 if (pNewVidPnPresentPathInfo)
180 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
181
182 *pbSupported = bSupported;
183
184 return Status;
185}
186
187NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
188 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
189 BOOLEAN *pbSupported)
190{
191 BOOLEAN bSupported = TRUE;
192 /* we support both GRAPHICS and TEXT modes */
193 switch (pNewVidPnSourceModeInfo->Type)
194 {
195 case D3DKMDT_RMT_GRAPHICS:
196 /* any primary surface size actually
197 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
198 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy
199 */
200 if (pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx
201 || pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy != pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy)
202 {
203 dprintf(("VisibleRegionSize(%d, %d) != PrimSurfSize(%d, %d)\n",
204 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cx,
205 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy,
206 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx,
207 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy));
208 bSupported = FALSE;
209 break;
210 }
211
212 /*
213 pNewVidPnSourceModeInfo->Format.Graphics.Stride
214 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat
215 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis
216 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode
217 */
218
219 break;
220 case D3DKMDT_RMT_TEXT:
221 break;
222 default:
223 AssertBreakpoint();
224 dprintf(("Warning: Unknown Src mode Type (%d)\n", pNewVidPnSourceModeInfo->Type));
225 break;
226 }
227
228 *pbSupported = bSupported;
229 return STATUS_SUCCESS;
230}
231
232NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
233 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
234 BOOLEAN *pbSupported)
235{
236 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
237 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
238 BOOLEAN bSupported = TRUE;
239 if (Status == STATUS_SUCCESS)
240 {
241 while (pNewVidPnSourceModeInfo)
242 {
243 Status = vboxVidPnCheckSourceModeInfo(hDesiredVidPn, pNewVidPnSourceModeInfo, &bSupported);
244 if (Status == STATUS_SUCCESS && bSupported)
245 {
246 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
247 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
248 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
249 if (Status == STATUS_SUCCESS)
250 {
251 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
252 }
253 else
254 {
255 drprintf(("pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
256 break;
257 }
258 }
259 else
260 {
261 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
262 break;
263 }
264 }
265 }
266 else
267 {
268 drprintf(("VBoxVideoWddm: pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
269 }
270
271 *pbSupported = bSupported;
272 return Status;
273}
274
275NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
276 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
277 BOOLEAN *pbSupported)
278{
279 BOOLEAN bSupported = TRUE;
280 do
281 {
282 /* video standatd does not matter ??
283 pNewVidPnTargetModeInfo->VideoSignalInfo.VideoStandard
284
285 we support any total size??
286 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cx
287 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy
288 */
289 /* ActualSize should be same as total size??*/
290 if (pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cx != pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cx
291 || pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy != pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy)
292 {
293 dprintf(("ActiveSize(%d, %d) != TotalSize(%d, %d)\n",
294 pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cx,
295 pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy,
296 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cx,
297 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy));
298 bSupported = FALSE;
299 break;
300 }
301
302 /* we do not care about those
303 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator
304 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator
305 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator
306 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator
307 pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate
308 pNewVidPnTargetModeInfo->VideoSignalInfo.ScanLineOrdering
309 pNewVidPnTargetModeInfo->Preference
310 */
311 } while (1);
312
313 *pbSupported = bSupported;
314 return STATUS_SUCCESS;
315}
316
317NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
318 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
319 BOOLEAN *pbSupported)
320{
321 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
322 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
323 BOOLEAN bSupported = TRUE;
324 if (Status == STATUS_SUCCESS)
325 {
326 while (pNewVidPnTargetModeInfo)
327 {
328 Status = vboxVidPnCheckTargetModeInfo(hDesiredVidPn, pNewVidPnTargetModeInfo, &bSupported);
329 if (Status == STATUS_SUCCESS && bSupported)
330 {
331 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
332 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
333 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
334 if (Status == STATUS_SUCCESS)
335 {
336 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
337 }
338 else
339 {
340 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
341 break;
342 }
343 }
344 else
345 {
346 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
347 break;
348 }
349 }
350 }
351 else
352 {
353 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
354 }
355
356 *pbSupported = bSupported;
357 return Status;
358}
359
360#if 0
361DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeCheck(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
362 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
363 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
364{
365 NTSTATUS Status = STATUS_SUCCESS;
366 PVBOXVIDPN_NEW_SRCMODESET_CHECK pCbContext = (PVBOXVIDPN_NEW_SRCMODESET_CHECK)pContext;
367 pCbContext->CommonInfo.Status = STATUS_SUCCESS;
368
369 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
370
371 pCbContext->CommonInfo.Status = Status;
372 return Status == STATUS_SUCCESS;
373}
374
375DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
376 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
377 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
378{
379 NTSTATUS Status = STATUS_SUCCESS;
380 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
381 pCbContext->Status = STATUS_SUCCESS;
382
383 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
384
385 pCbContext->Status = Status;
386 return Status == STATUS_SUCCESS;
387}
388
389DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityTargetModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
390 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
391 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext)
392{
393 NTSTATUS Status = STATUS_SUCCESS;
394 PVBOXVIDPNCMCONTEXT pCbContext = (PVBOXVIDPNCMCONTEXT)pContext;
395 pCbContext->Status = STATUS_SUCCESS;
396
397 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
398
399 pCbContext->Status = Status;
400 return Status == STATUS_SUCCESS;
401}
402#endif
403
404NTSTATUS vboxVidPnPopulateSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
405 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
406 VIDEO_MODE_INFORMATION *pMode)
407{
408 NTSTATUS Status = STATUS_SUCCESS;
409 if (pMode->AttributeFlags & VIDEO_MODE_GRAPHICS)
410 {
411 /* this is a graphics mode */
412 pNewVidPnSourceModeInfo->Type = D3DKMDT_RMT_GRAPHICS;
413 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx = pMode->VisScreenWidth;
414 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy = pMode->VisScreenHeight;
415 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
416 pNewVidPnSourceModeInfo->Format.Graphics.Stride = pMode->ScreenStride;
417 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat = vboxWddmCalcPixelFormat(pMode);
418 Assert(pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN);
419 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat != D3DDDIFMT_UNKNOWN)
420 {
421 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis = D3DKMDT_CB_SRGB;
422 if (pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat == D3DDDIFMT_P8)
423 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_SETTABLEPALETTE;
424 else
425 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_DIRECT;
426 }
427 else
428 {
429 drprintf((__FUNCTION__": vboxWddmCalcPixelFormat failed\n"));
430 Status = STATUS_INVALID_PARAMETER;
431 }
432 }
433 else
434 {
435 /* @todo: XPDM driver does not seem to return text modes, should we? */
436 drprintf((__FUNCTION__": text mode not supported currently\n"));
437 AssertBreakpoint();
438 Status = STATUS_INVALID_PARAMETER;
439 }
440
441 return Status;
442}
443
444NTSTATUS vboxVidPnPopulateSourceModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
445 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet,
446 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface,
447 VIDEO_MODE_INFORMATION *pModes,
448 uint32_t cModes,
449 uint32_t iPreferredMomde)
450{
451 NTSTATUS Status = STATUS_SUCCESS;
452 for (uint32_t i = 0; i < cModes; ++i)
453 {
454 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
455 Status = pNewVidPnSourceModeSetInterface->pfnCreateNewModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
456 Assert(Status == STATUS_SUCCESS);
457 if (Status == STATUS_SUCCESS)
458 {
459 Status = vboxVidPnPopulateSourceModeInfoFromLegacy(pDevExt, pNewVidPnSourceModeInfo, &pModes[i]);
460 Assert(Status == STATUS_SUCCESS);
461 if (Status == STATUS_SUCCESS)
462 {
463 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnSourceModeInfo->Id;
464 Status = pNewVidPnSourceModeSetInterface->pfnAddMode(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
465 Assert(Status == STATUS_SUCCESS);
466 if (Status == STATUS_SUCCESS)
467 {
468 if (iPreferredMomde == i)
469 {
470 Status = pNewVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, modeId);
471 Assert(Status == STATUS_SUCCESS);
472 if (Status != STATUS_SUCCESS)
473 {
474 drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
475 /* don't treat it as fatal */
476 Status = STATUS_SUCCESS;
477 }
478 }
479 }
480 else
481 {
482 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
483 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
484 break;
485 }
486 }
487 else
488 {
489 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
490 pNewVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
491 break;
492 }
493 }
494 }
495 return Status;
496}
497
498NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
499 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
500 D3DKMDT_2DREGION *pResolution,
501 BOOLEAN bPreferred)
502{
503 NTSTATUS Status = STATUS_SUCCESS;
504
505 pNewVidPnTargetModeInfo->VideoSignalInfo.VideoStandard = D3DKMDT_VSS_VESA_DMT;
506 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize = *pResolution;
507 pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize = pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize;
508 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60000;
509 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1000;
510 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 63; /* 63 is (60 * 1.05)*/
511 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
512 pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* @todo: ? */
513 pNewVidPnTargetModeInfo->VideoSignalInfo.ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
514 pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
515
516 return Status;
517}
518
519NTSTATUS vboxVidPnPopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
520 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet,
521 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface,
522 D3DKMDT_2DREGION *pResolutions,
523 uint32_t cResolutions,
524 VIDEO_MODE_INFORMATION *pPreferredMode)
525{
526 NTSTATUS Status = STATUS_SUCCESS;
527 for (uint32_t i = 0; i < cResolutions; ++i)
528 {
529 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
530 Status = pNewVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
531 Assert(Status == STATUS_SUCCESS);
532 if (Status == STATUS_SUCCESS)
533 {
534 bool bPreferred = pPreferredMode->VisScreenHeight == pResolutions[i].cx
535 && pPreferredMode->VisScreenWidth == pResolutions[i].cy;
536 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pDevExt, pNewVidPnTargetModeInfo, &pResolutions[i], bPreferred);
537 Assert(Status == STATUS_SUCCESS);
538 if (Status == STATUS_SUCCESS)
539 {
540 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnTargetModeInfo->Id;
541 Status = pNewVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
542 Assert(Status == STATUS_SUCCESS);
543 if (Status == STATUS_SUCCESS)
544 {
545 if (bPreferred)
546 {
547 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
548 Assert(Status == STATUS_SUCCESS);
549 if (Status != STATUS_SUCCESS)
550 {
551 drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
552 /* don't treat it as fatal */
553 Status = STATUS_SUCCESS;
554 }
555 }
556 }
557 else
558 {
559 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
560 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
561 break;
562 }
563 }
564 else
565 {
566 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
567 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
568 break;
569 }
570 }
571 }
572 return Status;
573}
574
575
576DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
577 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
578 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
579{
580 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
581 NTSTATUS Status = STATUS_SUCCESS;
582 pCbContext->Status = STATUS_SUCCESS;
583 VIDEO_MODE_INFORMATION *pModes = pCbContext->pModes;
584 uint32_t cModes = pCbContext->cModes;
585 uint32_t iPreferredMode = pCbContext->iPreferredMode;
586 uint32_t cResolutions = pCbContext->cResolutions;
587 D3DKMDT_2DREGION * pResolutions = pCbContext->pResolutions;
588
589
590 /* adjust scaling */
591 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
592 {
593 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
594 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
595 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED)
596 {
597 const_cast<D3DKMDT_VIDPN_PRESENT_PATH*>(pNewVidPnPresentPathInfo)->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
598 }
599 }
600
601 /* adjust rotation */
602 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
603 {
604 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
605 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
606 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
607 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270)
608 {
609 const_cast<D3DKMDT_VIDPN_PRESENT_PATH*>(pNewVidPnPresentPathInfo)->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
610 }
611 }
612
613 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_VIDPNSOURCE
614 || pNewVidPnPresentPathInfo->VidPnSourceId != pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId)
615 {
616 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
617 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
618
619 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
620 pNewVidPnPresentPathInfo->VidPnSourceId,
621 &hCurVidPnSourceModeSet,
622 &pCurVidPnSourceModeSetInterface);
623 Assert(Status == STATUS_SUCCESS);
624 if (Status == STATUS_SUCCESS)
625 {
626 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
627 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
628 Assert(Status == STATUS_SUCCESS);
629 if (Status == STATUS_SUCCESS)
630 {
631 if (!pPinnedVidPnSourceModeInfo)
632 {
633 /* just create and populate the new source mode set for now */
634 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
635 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
636 Status = pVidPnInterface->pfnCreateNewSourceModeSet(hDesiredVidPn,
637 pNewVidPnPresentPathInfo->VidPnSourceId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
638 &hNewVidPnSourceModeSet,
639 &pNewVidPnSourceModeSetInterface);
640 Assert(Status == STATUS_SUCCESS);
641 if (Status == STATUS_SUCCESS)
642 {
643 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
644 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
645 pModes, cModes, iPreferredMode);
646 Assert(Status == STATUS_SUCCESS);
647 if (Status == STATUS_SUCCESS)
648 {
649 Status = pVidPnInterface->pfnAssignSourceModeSet(hDesiredVidPn,
650 pNewVidPnPresentPathInfo->VidPnSourceId,
651 hNewVidPnSourceModeSet);
652 Assert(Status == STATUS_SUCCESS);
653 if(Status != STATUS_SUCCESS)
654 {
655 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
656 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
657 }
658 }
659 else
660 {
661 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
662 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
663 }
664 }
665 else
666 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
667 }
668 else
669 {
670 /* release */
671 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
672 }
673 }
674 else
675 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
676
677 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
678 }
679 else
680 {
681 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
682 }
683 }
684
685 /* ensure we didn't fail earlier */
686 if (Status == STATUS_SUCCESS)
687 {
688 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_VIDPNTARGET
689 || pNewVidPnPresentPathInfo->VidPnTargetId != pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId)
690 {
691 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
692 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
693 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn,
694 pNewVidPnPresentPathInfo->VidPnTargetId,
695 &hCurVidPnTargetModeSet,
696 &pCurVidPnTargetModeSetInterface);
697 Assert(Status == STATUS_SUCCESS);
698 if (Status == STATUS_SUCCESS)
699 {
700 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
701 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
702 Assert(Status == STATUS_SUCCESS);
703 if (Status == STATUS_SUCCESS)
704 {
705 if (!pPinnedVidPnTargetModeInfo)
706 {
707 /* just create and populate a new target mode info for now */
708 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
709 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
710 Status = pVidPnInterface->pfnCreateNewTargetModeSet(hDesiredVidPn,
711 pNewVidPnPresentPathInfo->VidPnTargetId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
712 &hNewVidPnTargetModeSet,
713 &pNewVidPnTargetModeSetInterface);
714 Assert(Status == STATUS_SUCCESS);
715 if (Status == STATUS_SUCCESS)
716 {
717 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
718 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
719 pResolutions, cResolutions, &pModes[iPreferredMode]);
720 Assert(Status == STATUS_SUCCESS);
721 if (Status == STATUS_SUCCESS)
722 {
723 Status = pVidPnInterface->pfnAssignTargetModeSet(hDesiredVidPn,
724 pNewVidPnPresentPathInfo->VidPnTargetId,
725 hNewVidPnTargetModeSet);
726 Assert(Status == STATUS_SUCCESS);
727 if(Status != STATUS_SUCCESS)
728 {
729 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
730 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
731 }
732 }
733 else
734 {
735 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
736 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
737 }
738 }
739 }
740 else
741 {
742 /* nothing to be done here, just release */
743 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
744 }
745 }
746 else
747 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
748
749 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
750 }
751 else
752 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
753 }
754 }
755
756 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
757
758 pCbContext->Status = Status;
759 return Status == STATUS_SUCCESS;
760}
761
762NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
763 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
764 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
765{
766 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
767 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
768 if (Status == STATUS_SUCCESS)
769 {
770 while (pNewVidPnSourceModeInfo)
771 {
772 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
773 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
774 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
775 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
776 pNewVidPnSourceModeInfo, pContext))
777 {
778 Assert(Status == STATUS_SUCCESS);
779 if (Status == STATUS_SUCCESS)
780 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
781 else
782 {
783 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
784 Status = STATUS_SUCCESS;
785 }
786
787 break;
788 }
789 else if (Status == STATUS_SUCCESS)
790 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
791 else
792 {
793 AssertBreakpoint();
794 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
795 pNewVidPnSourceModeInfo = NULL;
796 break;
797 }
798 }
799 }
800 else
801 {
802 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
803 }
804
805 return Status;
806}
807
808NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
809 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
810 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
811{
812 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
813 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
814 if (Status == STATUS_SUCCESS)
815 {
816 while (pNewVidPnTargetModeInfo)
817 {
818 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
819 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
820 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
821 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
822 pNewVidPnTargetModeInfo, pContext))
823 {
824 Assert(Status == STATUS_SUCCESS);
825 if (Status == STATUS_SUCCESS)
826 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
827 else
828 {
829 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
830 Status = STATUS_SUCCESS;
831 }
832
833 break;
834 }
835 else if (Status == STATUS_SUCCESS)
836 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
837 else
838 {
839 AssertBreakpoint();
840 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
841 pNewVidPnTargetModeInfo = NULL;
842 break;
843 }
844 }
845 }
846 else
847 {
848 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
849 }
850
851 return Status;
852}
853
854
855NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
856 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
857 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
858{
859 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
860 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
861 if (Status == STATUS_SUCCESS)
862 {
863 while (pNewVidPnPresentPathInfo)
864 {
865 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
866 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
867
868 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
869 {
870 Assert(Status == STATUS_SUCCESS);
871 if (Status == STATUS_SUCCESS)
872 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
873 else
874 {
875 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
876 Status = STATUS_SUCCESS;
877 }
878
879 break;
880 }
881 else if (Status == STATUS_SUCCESS)
882 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
883 else
884 {
885 AssertBreakpoint();
886 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
887 pNewVidPnPresentPathInfo = NULL;
888 break;
889 }
890 }
891 }
892
893 return Status;
894}
895
896NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
897{
898 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, pVidPnSourceModeInfo->Id);
899 return STATUS_SUCCESS;
900}
901
902NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
903{
904 Assert(pVidPnSourceModeInfo->Id < pDevExt->cSources);
905 if (pVidPnSourceModeInfo->Id < pDevExt->cSources)
906 {
907 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pVidPnSourceModeInfo->Id];
908 return vboxVidPnSetupSourceInfo(pDevExt, pSource, pVidPnSourceModeInfo, pAllocation);
909 }
910
911 drprintf((__FUNCTION__": invalid mode id (%d), cSources(%d)\n", pVidPnSourceModeInfo->Id, pDevExt->cSources));
912 return STATUS_INVALID_PARAMETER;
913}
914
915NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
916{
917 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
918 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
919
920 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
921 srcId,
922 &hCurVidPnSourceModeSet,
923 &pCurVidPnSourceModeSetInterface);
924 Assert(Status == STATUS_SUCCESS);
925 if (Status == STATUS_SUCCESS)
926 {
927 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
928 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
929 Assert(Status == STATUS_SUCCESS);
930 if (Status == STATUS_SUCCESS)
931 {
932 Assert(pPinnedVidPnSourceModeInfo);
933 if (pPinnedVidPnSourceModeInfo)
934 {
935 Status = vboxVidPnCommitSourceMode(pDevExt, pPinnedVidPnSourceModeInfo, pAllocation);
936 Assert(Status == STATUS_SUCCESS);
937 if (Status != STATUS_SUCCESS)
938 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
939 /* release */
940 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
941 }
942 else
943 drprintf((__FUNCTION__": no pPinnedVidPnSourceModeInfo available for source id (%d)\n", srcId));
944 }
945 else
946 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
947
948 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
949 }
950 else
951 {
952 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
953 }
954
955 return Status;
956}
957
958DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
959 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
960 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
961{
962 NTSTATUS Status = STATUS_SUCCESS;
963 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
964
965 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
966 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
967 {
968 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
969 Assert(Status == STATUS_SUCCESS);
970 if (Status != STATUS_SUCCESS)
971 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
972 }
973
974 pCommitInfo->Status = Status;
975 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
976 return Status == STATUS_SUCCESS;
977}
Note: See TracBrowser for help on using the repository browser.

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