VirtualBox

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

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