VirtualBox

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

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

wddm: bugfix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 45.6 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 vboxVidPnPopulateVideoSignalInfo(PDEVICE_EXTENSION pDevExt,
499 D3DKMDT_VIDEO_SIGNAL_INFO *pVsi,
500 D3DKMDT_2DREGION *pResolution,
501 ULONG VSync)
502{
503 NTSTATUS Status = STATUS_SUCCESS;
504
505 pVsi->VideoStandard = D3DKMDT_VSS_VESA_DMT;
506 pVsi->ActiveSize = *pResolution;
507 pVsi->VSyncFreq.Numerator = VSync * 1000;
508 pVsi->VSyncFreq.Denominator = 1000;
509 pVsi->TotalSize.cx = pVsi->ActiveSize.cx + VBOXVDPN_C_DISPLAY_HBLANK_SIZE;
510 pVsi->TotalSize.cy = pVsi->ActiveSize.cy + VBOXVDPN_C_DISPLAY_VBLANK_SIZE;
511 pVsi->PixelRate = pVsi->TotalSize.cx * pVsi->TotalSize.cy * VSync;
512 pVsi->HSyncFreq.Numerator = (UINT)((pVsi->PixelRate / pVsi->TotalSize.cy) * 1000);
513 pVsi->HSyncFreq.Denominator = 1000;
514 pVsi->ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
515
516 return Status;
517}
518
519NTSTATUS vboxVidPnPopulateMonitorSourceModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
520 D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSourceMode,
521 D3DKMDT_2DREGION *pResolution,
522 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
523 BOOLEAN bPreferred)
524{
525 NTSTATUS Status = vboxVidPnPopulateVideoSignalInfo(pDevExt, &pMonitorSourceMode->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
526 Assert(Status == STATUS_SUCCESS);
527 if (Status == STATUS_SUCCESS)
528 {
529 pMonitorSourceMode->ColorBasis = D3DKMDT_CB_SRGB;
530 pMonitorSourceMode->ColorCoeffDynamicRanges.FirstChannel = 8;
531 pMonitorSourceMode->ColorCoeffDynamicRanges.SecondChannel = 8;
532 pMonitorSourceMode->ColorCoeffDynamicRanges.ThirdChannel = 8;
533 pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0;
534 pMonitorSourceMode->Origin = enmOrigin;
535 pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
536 }
537
538 return Status;
539}
540
541NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(PDEVICE_EXTENSION pDevExt,
542 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
543 D3DKMDT_2DREGION *pResolution,
544 BOOLEAN bPreferred)
545{
546 pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
547
548 return vboxVidPnPopulateVideoSignalInfo(pDevExt, &pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
549}
550
551NTSTATUS vboxVidPnPopulateTargetModeSetFromLegacy(PDEVICE_EXTENSION pDevExt,
552 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet,
553 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface,
554 D3DKMDT_2DREGION *pResolutions,
555 uint32_t cResolutions,
556 VIDEO_MODE_INFORMATION *pPreferredMode)
557{
558 NTSTATUS Status = STATUS_SUCCESS;
559 for (uint32_t i = 0; i < cResolutions; ++i)
560 {
561 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
562 Status = pNewVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
563 Assert(Status == STATUS_SUCCESS);
564 if (Status == STATUS_SUCCESS)
565 {
566 bool bPreferred = pPreferredMode->VisScreenHeight == pResolutions[i].cx
567 && pPreferredMode->VisScreenWidth == pResolutions[i].cy;
568 Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pDevExt, pNewVidPnTargetModeInfo, &pResolutions[i], bPreferred);
569 Assert(Status == STATUS_SUCCESS);
570 if (Status == STATUS_SUCCESS)
571 {
572 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnTargetModeInfo->Id;
573 Status = pNewVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
574 Assert(Status == STATUS_SUCCESS);
575 if (Status == STATUS_SUCCESS)
576 {
577 if (bPreferred)
578 {
579 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
580 Assert(Status == STATUS_SUCCESS);
581 if (Status != STATUS_SUCCESS)
582 {
583 drprintf((__FUNCTION__": pfnPinMode failed, Status(0x%x)", Status));
584 /* don't treat it as fatal */
585 Status = STATUS_SUCCESS;
586 }
587 }
588 }
589 else
590 {
591 drprintf((__FUNCTION__": pfnAddMode failed, Status(0x%x)", Status));
592 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
593 break;
594 }
595 }
596 else
597 {
598 drprintf((__FUNCTION__": pfnCreateNewModeInfo failed, Status(0x%x)", Status));
599 pNewVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
600 break;
601 }
602 }
603 }
604 return Status;
605}
606
607
608DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
609 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
610 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)
611{
612 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext;
613 NTSTATUS Status = STATUS_SUCCESS;
614 pCbContext->Status = STATUS_SUCCESS;
615 VIDEO_MODE_INFORMATION *pModes = pCbContext->pModes;
616 uint32_t cModes = pCbContext->cModes;
617 uint32_t iPreferredMode = pCbContext->iPreferredMode;
618 uint32_t cResolutions = pCbContext->cResolutions;
619 D3DKMDT_2DREGION * pResolutions = pCbContext->pResolutions;
620
621
622 /* adjust scaling */
623 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_SCALING)
624 {
625 if (pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_IDENTITY
626 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_CENTERED
627 && pNewVidPnPresentPathInfo->ContentTransformation.Scaling != D3DKMDT_VPPS_STRETCHED)
628 {
629 const_cast<D3DKMDT_VIDPN_PRESENT_PATH*>(pNewVidPnPresentPathInfo)->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
630 }
631 }
632
633 /* adjust rotation */
634 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_ROTATION)
635 {
636 if (pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_IDENTITY
637 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE90
638 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE180
639 && pNewVidPnPresentPathInfo->ContentTransformation.Rotation != D3DKMDT_VPPR_ROTATE270)
640 {
641 const_cast<D3DKMDT_VIDPN_PRESENT_PATH*>(pNewVidPnPresentPathInfo)->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
642 }
643 }
644
645 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_VIDPNSOURCE
646 || pNewVidPnPresentPathInfo->VidPnSourceId != pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId)
647 {
648 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
649 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
650
651 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
652 pNewVidPnPresentPathInfo->VidPnSourceId,
653 &hCurVidPnSourceModeSet,
654 &pCurVidPnSourceModeSetInterface);
655 Assert(Status == STATUS_SUCCESS);
656 if (Status == STATUS_SUCCESS)
657 {
658 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
659 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
660 Assert(Status == STATUS_SUCCESS);
661 if (Status == STATUS_SUCCESS)
662 {
663 if (!pPinnedVidPnSourceModeInfo)
664 {
665 /* just create and populate the new source mode set for now */
666 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
667 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
668 Status = pVidPnInterface->pfnCreateNewSourceModeSet(hDesiredVidPn,
669 pNewVidPnPresentPathInfo->VidPnSourceId, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
670 &hNewVidPnSourceModeSet,
671 &pNewVidPnSourceModeSetInterface);
672 Assert(Status == STATUS_SUCCESS);
673 if (Status == STATUS_SUCCESS)
674 {
675 Status = vboxVidPnPopulateSourceModeSetFromLegacy(pDevExt,
676 hNewVidPnSourceModeSet, pNewVidPnSourceModeSetInterface,
677 pModes, cModes, iPreferredMode);
678 Assert(Status == STATUS_SUCCESS);
679 if (Status == STATUS_SUCCESS)
680 {
681 Status = pVidPnInterface->pfnAssignSourceModeSet(hDesiredVidPn,
682 pNewVidPnPresentPathInfo->VidPnSourceId,
683 hNewVidPnSourceModeSet);
684 Assert(Status == STATUS_SUCCESS);
685 if(Status != STATUS_SUCCESS)
686 {
687 drprintf((__FUNCTION__": pfnAssignSourceModeSet failed Status(0x%x)\n", Status));
688 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
689 }
690 }
691 else
692 {
693 drprintf((__FUNCTION__": vboxVidPnPopulateSourceModeSetFromLegacy failed Status(0x%x)\n", Status));
694 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hNewVidPnSourceModeSet);
695 }
696 }
697 else
698 drprintf((__FUNCTION__": pfnCreateNewSourceModeSet failed Status(0x%x)\n", Status));
699 }
700 else
701 {
702 /* release */
703 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
704 }
705 }
706 else
707 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
708
709 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
710 }
711 else
712 {
713 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
714 }
715 }
716
717 /* ensure we didn't fail earlier */
718 if (Status == STATUS_SUCCESS)
719 {
720 if (pCbContext->pEnumCofuncModalityArg->EnumPivotType != D3DKMDT_EPT_VIDPNTARGET
721 || pNewVidPnPresentPathInfo->VidPnTargetId != pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId)
722 {
723 D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
724 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
725 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn,
726 pNewVidPnPresentPathInfo->VidPnTargetId,
727 &hCurVidPnTargetModeSet,
728 &pCurVidPnTargetModeSetInterface);
729 Assert(Status == STATUS_SUCCESS);
730 if (Status == STATUS_SUCCESS)
731 {
732 CONST D3DKMDT_VIDPN_TARGET_MODE* pPinnedVidPnTargetModeInfo;
733 Status = pCurVidPnTargetModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnTargetModeSet, &pPinnedVidPnTargetModeInfo);
734 Assert(Status == STATUS_SUCCESS);
735 if (Status == STATUS_SUCCESS)
736 {
737 if (!pPinnedVidPnTargetModeInfo)
738 {
739 /* just create and populate a new target mode info for now */
740 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
741 const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
742 Status = pVidPnInterface->pfnCreateNewTargetModeSet(hDesiredVidPn,
743 pNewVidPnPresentPathInfo->VidPnTargetId, /*__in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
744 &hNewVidPnTargetModeSet,
745 &pNewVidPnTargetModeSetInterface);
746 Assert(Status == STATUS_SUCCESS);
747 if (Status == STATUS_SUCCESS)
748 {
749 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt,
750 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface,
751 pResolutions, cResolutions, &pModes[iPreferredMode]);
752 Assert(Status == STATUS_SUCCESS);
753 if (Status == STATUS_SUCCESS)
754 {
755 Status = pVidPnInterface->pfnAssignTargetModeSet(hDesiredVidPn,
756 pNewVidPnPresentPathInfo->VidPnTargetId,
757 hNewVidPnTargetModeSet);
758 Assert(Status == STATUS_SUCCESS);
759 if(Status != STATUS_SUCCESS)
760 {
761 drprintf((__FUNCTION__": pfnAssignTargetModeSet failed Status(0x%x)\n", Status));
762 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
763 }
764 }
765 else
766 {
767 drprintf((__FUNCTION__": vboxVidPnPopulateTargetModeSetFromLegacy failed Status(0x%x)\n", Status));
768 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hNewVidPnTargetModeSet);
769 }
770 }
771 }
772 else
773 {
774 /* nothing to be done here, just release */
775 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo);
776 }
777 }
778 else
779 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
780
781 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet);
782 }
783 else
784 drprintf((__FUNCTION__": pfnAcquireTargetModeSet failed Status(0x%x)\n", Status));
785 }
786 }
787
788 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
789
790 pCbContext->Status = Status;
791 return Status == STATUS_SUCCESS;
792}
793
794NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
795 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
796 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext)
797{
798 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
799 NTSTATUS Status = pVidPnSourceModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
800 if (Status == STATUS_SUCCESS)
801 {
802 while (pNewVidPnSourceModeInfo)
803 {
804 const D3DKMDT_VIDPN_SOURCE_MODE *pNextVidPnSourceModeInfo;
805 Status = pVidPnSourceModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo, &pNextVidPnSourceModeInfo);
806 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
807 hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface,
808 pNewVidPnSourceModeInfo, pContext))
809 {
810 Assert(Status == STATUS_SUCCESS);
811 if (Status == STATUS_SUCCESS)
812 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNextVidPnSourceModeInfo);
813 else
814 {
815 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
816 Status = STATUS_SUCCESS;
817 }
818
819 break;
820 }
821 else if (Status == STATUS_SUCCESS)
822 pNewVidPnSourceModeInfo = pNextVidPnSourceModeInfo;
823 else
824 {
825 AssertBreakpoint();
826 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
827 pNewVidPnSourceModeInfo = NULL;
828 break;
829 }
830 }
831 }
832 else
833 {
834 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
835 }
836
837 return Status;
838}
839
840NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
841 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
842 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext)
843{
844 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
845 NTSTATUS Status = pVidPnTargetModeSetInterface->pfnAcquireFirstModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
846 if (Status == STATUS_SUCCESS)
847 {
848 while (pNewVidPnTargetModeInfo)
849 {
850 const D3DKMDT_VIDPN_TARGET_MODE *pNextVidPnTargetModeInfo;
851 Status = pVidPnTargetModeSetInterface->pfnAcquireNextModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo, &pNextVidPnTargetModeInfo);
852 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface,
853 hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface,
854 pNewVidPnTargetModeInfo, pContext))
855 {
856 Assert(Status == STATUS_SUCCESS);
857 if (Status == STATUS_SUCCESS)
858 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNextVidPnTargetModeInfo);
859 else
860 {
861 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
862 Status = STATUS_SUCCESS;
863 }
864
865 break;
866 }
867 else if (Status == STATUS_SUCCESS)
868 pNewVidPnTargetModeInfo = pNextVidPnTargetModeInfo;
869 else
870 {
871 AssertBreakpoint();
872 drprintf((__FUNCTION__": pfnAcquireNextModeInfo Failed Status(0x%x)\n", Status));
873 pNewVidPnTargetModeInfo = NULL;
874 break;
875 }
876 }
877 }
878 else
879 {
880 drprintf((__FUNCTION__": pfnAcquireFirstModeInfo failed Status(0x%x)\n", Status));
881 }
882
883 return Status;
884}
885
886
887NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
888 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
889 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext)
890{
891 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo = NULL;
892 NTSTATUS Status = pVidPnTopologyInterface->pfnAcquireFirstPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
893 if (Status == STATUS_SUCCESS)
894 {
895 while (pNewVidPnPresentPathInfo)
896 {
897 const D3DKMDT_VIDPN_PRESENT_PATH *pNextVidPnPresentPathInfo;
898 Status = pVidPnTopologyInterface->pfnAcquireNextPathInfo(hVidPnTopology, pNewVidPnPresentPathInfo, &pNextVidPnPresentPathInfo);
899
900 if (!pfnCallback(pDevExt, hDesiredVidPn, pVidPnInterface, hVidPnTopology, pVidPnTopologyInterface, pNewVidPnPresentPathInfo, pContext))
901 {
902 Assert(Status == STATUS_SUCCESS);
903 if (Status == STATUS_SUCCESS)
904 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNextVidPnPresentPathInfo);
905 else
906 {
907 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x), ignored since callback returned false\n", Status));
908 Status = STATUS_SUCCESS;
909 }
910
911 break;
912 }
913 else if (Status == STATUS_SUCCESS)
914 pNewVidPnPresentPathInfo = pNextVidPnPresentPathInfo;
915 else
916 {
917 AssertBreakpoint();
918 drprintf((__FUNCTION__": pfnAcquireNextPathInfo Failed Status(0x%x)\n", Status));
919 pNewVidPnPresentPathInfo = NULL;
920 break;
921 }
922 }
923 }
924
925 return Status;
926}
927
928NTSTATUS vboxVidPnSetupSourceInfo(struct _DEVICE_EXTENSION* pDevExt, PVBOXWDDM_SOURCE pSource, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
929{
930 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, pVidPnSourceModeInfo->Id);
931 return STATUS_SUCCESS;
932}
933
934NTSTATUS vboxVidPnCommitSourceMode(struct _DEVICE_EXTENSION* pDevExt, CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, PVBOXWDDM_ALLOCATION pAllocation)
935{
936 Assert(pVidPnSourceModeInfo->Id < pDevExt->cSources);
937 if (pVidPnSourceModeInfo->Id < pDevExt->cSources)
938 {
939 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pVidPnSourceModeInfo->Id];
940 return vboxVidPnSetupSourceInfo(pDevExt, pSource, pVidPnSourceModeInfo, pAllocation);
941 }
942
943 drprintf((__FUNCTION__": invalid mode id (%d), cSources(%d)\n", pVidPnSourceModeInfo->Id, pDevExt->cSources));
944 return STATUS_INVALID_PARAMETER;
945}
946
947NTSTATUS vboxVidPnCommitSourceModeForSrcId(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, PVBOXWDDM_ALLOCATION pAllocation)
948{
949 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
950 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
951
952 NTSTATUS Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn,
953 srcId,
954 &hCurVidPnSourceModeSet,
955 &pCurVidPnSourceModeSetInterface);
956 Assert(Status == STATUS_SUCCESS);
957 if (Status == STATUS_SUCCESS)
958 {
959 CONST D3DKMDT_VIDPN_SOURCE_MODE* pPinnedVidPnSourceModeInfo;
960 Status = pCurVidPnSourceModeSetInterface->pfnAcquirePinnedModeInfo(hCurVidPnSourceModeSet, &pPinnedVidPnSourceModeInfo);
961 Assert(Status == STATUS_SUCCESS);
962 if (Status == STATUS_SUCCESS)
963 {
964 Assert(pPinnedVidPnSourceModeInfo);
965 if (pPinnedVidPnSourceModeInfo)
966 {
967 Status = vboxVidPnCommitSourceMode(pDevExt, pPinnedVidPnSourceModeInfo, pAllocation);
968 Assert(Status == STATUS_SUCCESS);
969 if (Status != STATUS_SUCCESS)
970 drprintf((__FUNCTION__": vboxVidPnCommitSourceMode failed Status(0x%x)\n", Status));
971 /* release */
972 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo);
973 }
974 else
975 drprintf((__FUNCTION__": no pPinnedVidPnSourceModeInfo available for source id (%d)\n", srcId));
976 }
977 else
978 drprintf((__FUNCTION__": pfnAcquirePinnedModeInfo failed Status(0x%x)\n", Status));
979
980 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet);
981 }
982 else
983 {
984 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status));
985 }
986
987 return Status;
988}
989
990DECLCALLBACK(BOOLEAN) vboxVidPnCommitPathEnum(struct _DEVICE_EXTENSION* pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
991 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
992 const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo, PVOID pContext)
993{
994 NTSTATUS Status = STATUS_SUCCESS;
995 PVBOXVIDPNCOMMIT pCommitInfo = (PVBOXVIDPNCOMMIT)pContext;
996
997 if (pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == D3DDDI_ID_ALL
998 || pCommitInfo->pCommitVidPnArg->AffectedVidPnSourceId == pVidPnPresentPathInfo->VidPnSourceId)
999 {
1000 Status = vboxVidPnCommitSourceModeForSrcId(pDevExt, hDesiredVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitInfo->pCommitVidPnArg->hPrimaryAllocation);
1001 Assert(Status == STATUS_SUCCESS);
1002 if (Status != STATUS_SUCCESS)
1003 drprintf((__FUNCTION__": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
1004 }
1005
1006 pCommitInfo->Status = Status;
1007 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pVidPnPresentPathInfo);
1008 return Status == STATUS_SUCCESS;
1009}
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