VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp@ 26556

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

wddm: more impl

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 85.2 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
17#include "../VBoxVideo.h"
18#include "../Helper.h"
19
20#include <VBox/VBoxGuestLib.h>
21#include <VBox/VBoxVideo.h>
22
23#define VBOXWDDM_MEMTAG 'MDBV'
24PVOID vboxWddmMemAlloc(IN SIZE_T cbSize)
25{
26 return ExAllocatePoolWithTag(NonPagedPool, cbSize, VBOXWDDM_MEMTAG);
27}
28
29PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize)
30{
31 PVOID pvMem = vboxWddmMemAlloc(cbSize);
32 memset(pvMem, 0, cbSize);
33 return pvMem;
34}
35
36
37VOID vboxWddmMemFree(PVOID pvMem)
38{
39 ExFreePool(pvMem);
40}
41
42void vboxSHGSMICbCommandWrite(struct _HGSMIHEAP * pHeap, HGSMIOFFSET data)
43{
44 /* @todo: this should be taken from PDEVICE_EXTENSION */
45 //VBoxHGSMIGuestWrite(pDevExt, data);
46 VBoxVideoCmnPortWriteUlong((PULONG)VGA_PORT_HGSMI_GUEST, data);
47}
48
49#if 0
50void vboxWddmProcessDisplayInfo (PPDEV ppdev)
51{
52 if (ppdev->bHGSMISupported)
53 {
54 /* Issue the screen info command. */
55 void *p = HGSMIHeapAlloc (&ppdev->hgsmiDisplayHeap,
56 sizeof (VBVAINFOSCREEN),
57 HGSMI_CH_VBVA,
58 VBVA_INFO_SCREEN);
59 if (!p)
60 {
61 DISPDBG((0, "VBoxDISP::VBoxProcessDisplayInfo: HGSMIHeapAlloc failed\n"));
62 }
63 else
64 {
65 VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
66
67 pScreen->u32ViewIndex = ppdev->iDevice;
68 pScreen->i32OriginX = ppdev->ptlDevOrg.x;
69 pScreen->i32OriginY = ppdev->ptlDevOrg.y;
70 pScreen->u32StartOffset = 0;
71 pScreen->u32LineSize = ppdev->lDeltaScreen > 0?ppdev->lDeltaScreen: -ppdev->lDeltaScreen;
72 pScreen->u32Width = ppdev->cxScreen;
73 pScreen->u32Height = ppdev->cyScreen;
74 pScreen->u16BitsPerPixel = (uint16_t)ppdev->ulBitCount;
75 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE;
76
77 vboxHGSMIBufferSubmit (ppdev, p);
78
79 HGSMIHeapFree (&ppdev->hgsmiDisplayHeap, p);
80 }
81 }
82
83 return;
84}
85
86NTSTATUS vboxWddmGhInitPrimary(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, D3DKMDT_VIDPN_SOURCE_MODE *pVidPnSourceModeInfo)
87{
88 NTSTATUS Status;
89 PVBOXWDDM_SOURCE pSourceInfo = &pDevExt->aSources[srcId];
90 memset(pSourceInfo, 0, sizeof (VBOXWDDM_SOURCE));
91 pSourceInfo->VisScreenWidth = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx;
92 pSourceInfo->VisScreenHeight = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy;
93 pSourceInfo->BitsPerPlane = vboxWddmCalcBitsPerPixel(pVidPnSourceModeInfo->Format.Graphics.PixelFormat);
94 Assert(pSourceInfo->BitsPerPlane);
95 if (pSourceInfo->BitsPerPlane)
96 {
97 /*
98 * Set the current mode into the hardware.
99 */
100 if (VBoxVideoSetCurrentMode(pDevExt, srcId, pSourceInfo))
101 {
102
103
104 }
105 else
106 {
107 AssertBreakpoint();
108
109 }
110 }
111 else
112 {
113 drprintf((__FUNCTION__":ERROR: failed to caltulate bpp from pixel format (%d)\n",
114 pVidPnSourceModeInfo->Format.Graphics.PixelFormat));
115 return STATUS_INVALID_PARAMETER;
116 }
117
118 return Status;
119
120
121
122// DWORD returnedDataLength;
123// DWORD MaxWidth, MaxHeight;
124// VIDEO_MEMORY videoMemory;
125// VIDEO_MEMORY_INFORMATION videoMemoryInformation;
126// ULONG RemappingNeeded = 0;
127
128
129 /*
130 * don't need to map anything here, we use one common HGSMI heap for all sources
131 */
132
133 // If this is the first time we enable the surface we need to map in the
134 // memory also.
135 //
136
137 if (bFirst || RemappingNeeded)
138 {
139// videoMemory.RequestedVirtualAddress = NULL;
140//
141// if (EngDeviceIoControl(ppdev->hDriver,
142// IOCTL_VIDEO_MAP_VIDEO_MEMORY,
143// &videoMemory,
144// sizeof(VIDEO_MEMORY),
145// &videoMemoryInformation,
146// sizeof(VIDEO_MEMORY_INFORMATION),
147// &returnedDataLength))
148// {
149// DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_MAP\n"));
150// return(FALSE);
151// }
152//
153// ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
154//
155// if (videoMemoryInformation.FrameBufferBase !=
156// videoMemoryInformation.VideoRamBase)
157// {
158// DISPDBG((0, "VideoRamBase does not correspond to FrameBufferBase\n"));
159// }
160//
161// //
162// // Make sure we can access this video memory
163// //
164//
165// *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
166//
167// if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
168//
169// DISPDBG((1, "Frame buffer memory is not accessible.\n"));
170// return(FALSE);
171// }
172//
173// /* Clear VRAM to avoid distortions during the video mode change. */
174// RtlZeroMemory(ppdev->pjScreen,
175// ppdev->cyScreen * (ppdev->lDeltaScreen > 0? ppdev->lDeltaScreen: -ppdev->lDeltaScreen));
176//
177// //
178// // Initialize the head of the offscreen list to NULL.
179// //
180//
181// ppdev->pOffscreenList = NULL;
182//
183// // It's a hardware pointer; set up pointer attributes.
184//
185// MaxHeight = ppdev->PointerCapabilities.MaxHeight;
186//
187// // Allocate space for two DIBs (data/mask) for the pointer. If this
188// // device supports a color Pointer, we will allocate a larger bitmap.
189// // If this is a color bitmap we allocate for the largest possible
190// // bitmap because we have no idea of what the pixel depth might be.
191//
192// // Width rounded up to nearest byte multiple
193//
194// if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))
195// {
196// MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
197// }
198// else
199// {
200// MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
201// }
202//
203// ppdev->cjPointerAttributes =
204// sizeof(VIDEO_POINTER_ATTRIBUTES) +
205// ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
206//
207// ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
208// EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG);
209//
210// if (ppdev->pPointerAttributes == NULL) {
211//
212// DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
213// return(FALSE);
214// }
215//
216// ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
217// ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
218// ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
219// ppdev->pPointerAttributes->Height = MaxHeight;
220// ppdev->pPointerAttributes->Column = 0;
221// ppdev->pPointerAttributes->Row = 0;
222// ppdev->pPointerAttributes->Enable = 0;
223
224 vboxInitVBoxVideo (ppdev, &videoMemoryInformation);
225
226#ifndef VBOX_WITH_HGSMI
227 if (ppdev->bVBoxVideoSupported)
228 {
229 /* Setup the display information. */
230 vboxSetupDisplayInfo (ppdev, &videoMemoryInformation);
231 }
232#endif /* !VBOX_WITH_HGSMI */
233 }
234
235
236 DISPDBG((1, "DISP bInitSURF: ppdev->ulBitCount %d\n", ppdev->ulBitCount));
237
238 if ( ppdev->ulBitCount == 16
239 || ppdev->ulBitCount == 24
240 || ppdev->ulBitCount == 32)
241 {
242#ifndef VBOX_WITH_HGSMI
243 if (ppdev->pInfo) /* Do not use VBVA on old hosts. */
244 {
245 /* Enable VBVA for this video mode. */
246 vboxVbvaEnable (ppdev);
247 }
248#else
249 if (ppdev->bHGSMISupported)
250 {
251 /* Enable VBVA for this video mode. */
252 ppdev->bHGSMISupported = vboxVbvaEnable (ppdev);
253 LogRel(("VBoxDisp[%d]: VBVA %senabled\n", ppdev->iDevice, ppdev->bHGSMISupported? "": "not "));
254 }
255#endif /* VBOX_WITH_HGSMI */
256 }
257
258 DISPDBG((1, "DISP bInitSURF success\n"));
259
260#ifndef VBOX_WITH_HGSMI
261 /* Update the display information. */
262 vboxUpdateDisplayInfo (ppdev);
263#else
264 /* Inform the host about this screen layout. */
265 DISPDBG((1, "bInitSURF: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y));
266 VBoxProcessDisplayInfo (ppdev);
267#endif /* VBOX_WITH_HGSMI */
268
269#ifdef VBOX_WITH_VIDEOHWACCEL
270 /* tells we can process host commands */
271 vboxVHWAEnable(ppdev);
272#endif
273
274 return(TRUE);
275}
276#endif
277
278HGSMIHEAP* vboxWddmHgsmiGetHeapFromCmdOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
279{
280 if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
281 return &pDevExt->u.primary.Vdma.CmdHeap;
282 if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
283 return &pDevExt->u.primary.hgsmiAdapterHeap;
284 return NULL;
285}
286
287typedef enum
288{
289 VBOXWDDM_HGSMICMD_TYPE_UNDEFINED = 0,
290 VBOXWDDM_HGSMICMD_TYPE_CTL = 1,
291 VBOXWDDM_HGSMICMD_TYPE_DMACMD = 2
292} VBOXWDDM_HGSMICMD_TYPE;
293
294VBOXWDDM_HGSMICMD_TYPE vboxWddmHgsmiGetCmdTypeFromOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
295{
296 if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
297 return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
298 if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
299 return VBOXWDDM_HGSMICMD_TYPE_CTL;
300 return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
301}
302
303
304#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
305
306NTSTATUS vboxWddmRegQueryDrvKeyName(PDEVICE_EXTENSION pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult)
307{
308 WCHAR fallBackBuf[2];
309 PWCHAR pSuffix;
310 bool bFallback = false;
311
312 if (cbBuf > sizeof(VBOXWDDM_REG_DRVKEY_PREFIX))
313 {
314 wcscpy(pBuf, VBOXWDDM_REG_DRVKEY_PREFIX);
315 pSuffix = pBuf + (sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2);
316 cbBuf -= sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2;
317 }
318 else
319 {
320 pSuffix = fallBackBuf;
321 cbBuf = sizeof (fallBackBuf);
322 bFallback = true;
323 }
324
325 NTSTATUS Status = IoGetDeviceProperty (pDevExt->pPDO,
326 DevicePropertyDriverKeyName,
327 cbBuf,
328 pSuffix,
329 &cbBuf);
330 if (Status == STATUS_SUCCESS && bFallback)
331 Status = STATUS_BUFFER_TOO_SMALL;
332 if (Status == STATUS_BUFFER_TOO_SMALL)
333 *pcbResult = cbBuf + sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2;
334
335 return Status;
336}
337
338NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess)
339{
340 OBJECT_ATTRIBUTES ObjAttr;
341 UNICODE_STRING RtlStr;
342 RtlStr.Buffer = pName;
343 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
344 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
345
346 InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE, NULL, NULL);
347
348 return ZwOpenKey(phKey, fAccess, &ObjAttr);
349}
350
351NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword)
352{
353 UCHAR Buf[32]; /* should be enough */
354 ULONG cbBuf;
355 PKEY_VALUE_PARTIAL_INFORMATION pInfo = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
356 UNICODE_STRING RtlStr;
357 RtlStr.Buffer = pName;
358 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
359 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
360 NTSTATUS Status = ZwQueryValueKey(hKey,
361 &RtlStr,
362 KeyValuePartialInformation,
363 pInfo,
364 sizeof(Buf),
365 &cbBuf);
366 if (Status == STATUS_SUCCESS)
367 {
368 if (pInfo->Type == REG_DWORD)
369 {
370 Assert(pInfo->DataLength == 4);
371 *pDword = *((PULONG)pInfo->Data);
372 return STATUS_SUCCESS;
373 }
374 }
375
376 return STATUS_INVALID_PARAMETER;
377}
378
379NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT DWORD val)
380{
381 UCHAR Buf[32]; /* should be enough */
382 PKEY_VALUE_PARTIAL_INFORMATION pInfo = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
383 UNICODE_STRING RtlStr;
384 RtlStr.Buffer = pName;
385 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
386 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
387 return ZwSetValueKey(hKey, &RtlStr,
388 NULL, /* IN ULONG TitleIndex OPTIONAL, reserved */
389 REG_DWORD,
390 &val,
391 sizeof(val));
392}
393
394VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)
395{
396 if(!Reg)
397 return ERROR_INVALID_PARAMETER;
398 NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);
399 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
400}
401
402VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)
403{
404 if(!Reg)
405 return ERROR_INVALID_PARAMETER;
406 NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);
407 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
408}
409
410VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
411{
412 WCHAR Buf[512];
413 ULONG cbBuf = sizeof(Buf);
414 NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf);
415 Assert(Status == STATUS_SUCCESS);
416 if (Status == STATUS_SUCCESS)
417 {
418 Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);
419 Assert(Status == STATUS_SUCCESS);
420 if(Status == STATUS_SUCCESS)
421 return NO_ERROR;
422 }
423
424 /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly
425 * basically needed to make as less modifications to the current XPDM code as possible */
426 *pReg = NULL;
427
428 return ERROR_INVALID_PARAMETER;
429}
430
431UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
432{
433 switch (format)
434 {
435 case D3DDDIFMT_R8G8B8:
436 return 24;
437 case D3DDDIFMT_A8R8G8B8:
438 case D3DDDIFMT_X8R8G8B8:
439 return 32;
440 case D3DDDIFMT_R5G6B5:
441 case D3DDDIFMT_X1R5G5B5:
442 case D3DDDIFMT_A1R5G5B5:
443 case D3DDDIFMT_A4R4G4B4:
444 return 16;
445 case D3DDDIFMT_R3G3B2:
446 case D3DDDIFMT_A8:
447 return 8;
448 case D3DDDIFMT_A8R3G3B2:
449 case D3DDDIFMT_X4R4G4B4:
450 return 16;
451 case D3DDDIFMT_A2B10G10R10:
452 case D3DDDIFMT_A8B8G8R8:
453 case D3DDDIFMT_X8B8G8R8:
454 case D3DDDIFMT_G16R16:
455 case D3DDDIFMT_A2R10G10B10:
456 return 32;
457 case D3DDDIFMT_A16B16G16R16:
458 return 64;
459 default:
460 AssertBreakpoint();
461 return 0;
462 }
463}
464
465D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo)
466{
467 switch (pInfo->BitsPerPlane)
468 {
469 case 32:
470 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
471 {
472 if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
473 return D3DDDIFMT_X8R8G8B8;
474 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
475 AssertBreakpoint();
476 }
477 else
478 {
479 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
480 AssertBreakpoint();
481 }
482 break;
483 case 24:
484 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
485 {
486 if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
487 return D3DDDIFMT_R8G8B8;
488 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
489 AssertBreakpoint();
490 }
491 else
492 {
493 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
494 AssertBreakpoint();
495 }
496 break;
497 case 16:
498 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
499 {
500 if (pInfo->RedMask == 0xF800 && pInfo->GreenMask == 0x7E0 && pInfo->BlueMask == 0x1F)
501 return D3DDDIFMT_R5G6B5;
502 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
503 AssertBreakpoint();
504 }
505 else
506 {
507 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
508 AssertBreakpoint();
509 }
510 break;
511 case 8:
512 if((pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && (pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
513 {
514 return D3DDDIFMT_P8;
515 }
516 else
517 {
518 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
519 AssertBreakpoint();
520 }
521 break;
522 default:
523 drprintf((__FUNCTION__": unsupported bpp(%d)\n", pInfo->BitsPerPlane));
524 AssertBreakpoint();
525 break;
526 }
527
528 return D3DDDIFMT_UNKNOWN;
529}
530
531UINT vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
532{
533 UINT Pitch = bitsPerPixel * w;
534 /* pitch is now in bits, translate in bytes */
535 if(Pitch & 7)
536 Pitch = (Pitch >> 3) + 1;
537 else
538 Pitch = (Pitch >> 3);
539
540 return Pitch;
541}
542
543NTSTATUS vboxWddmPickResources(PDEVICE_EXTENSION pContext, PDXGK_DEVICE_INFO pDeviceInfo, PULONG pAdapterMemorySize)
544{
545 NTSTATUS Status = STATUS_SUCCESS;
546 USHORT DispiId;
547 *pAdapterMemorySize = VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES;
548
549 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
550 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);
551 DispiId = VBoxVideoCmnPortReadUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
552 if (DispiId == VBE_DISPI_ID2)
553 {
554 dprintf(("VBoxVideoWddm: found the VBE card\n"));
555 /*
556 * Write some hardware information to registry, so that
557 * it's visible in Windows property dialog.
558 */
559
560 /*
561 * Query the adapter's memory size. It's a bit of a hack, we just read
562 * an ULONG from the data port without setting an index before.
563 */
564 *pAdapterMemorySize = VBoxVideoCmnPortReadUlong((PULONG)VBE_DISPI_IOPORT_DATA);
565 if (VBoxHGSMIIsSupported (pContext))
566 {
567 pContext->u.primary.IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
568 pContext->u.primary.IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
569
570 PCM_RESOURCE_LIST pRcList = pDeviceInfo->TranslatedResourceList;
571 /* @todo: verify resources */
572 for (ULONG i = 0; i < pRcList->Count; ++i)
573 {
574 PCM_FULL_RESOURCE_DESCRIPTOR pFRc = &pRcList->List[i];
575 for (ULONG j = 0; j < pFRc->PartialResourceList.Count; ++j)
576 {
577 PCM_PARTIAL_RESOURCE_DESCRIPTOR pPRc = &pFRc->PartialResourceList.PartialDescriptors[j];
578 switch (pPRc->Type)
579 {
580 case CmResourceTypePort:
581 break;
582 case CmResourceTypeInterrupt:
583 break;
584 case CmResourceTypeMemory:
585 break;
586 case CmResourceTypeDma:
587 break;
588 case CmResourceTypeDeviceSpecific:
589 break;
590 case CmResourceTypeBusNumber:
591 break;
592 default:
593 break;
594 }
595 }
596 }
597 }
598 else
599 {
600 drprintf(("VBoxVideoWddm: HGSMI unsupported, returning err\n"));
601 /* @todo: report a better status */
602 Status = STATUS_UNSUCCESSFUL;
603 }
604 }
605 else
606 {
607 drprintf(("VBoxVideoWddm:: VBE card not found, returning err\n"));
608 Status = STATUS_UNSUCCESSFUL;
609 }
610
611
612 return Status;
613}
614
615/* driver callbacks */
616
617NTSTATUS DxgkDdiAddDevice(
618 IN CONST PDEVICE_OBJECT PhysicalDeviceObject,
619 OUT PVOID *MiniportDeviceContext
620 )
621{
622 /* The DxgkDdiAddDevice function should be made pageable. */
623 PAGED_CODE();
624
625 dfprintf(("==> "__FUNCTION__ ", pdo(0x%x)\n", PhysicalDeviceObject));
626 NTSTATUS Status = STATUS_UNSUCCESSFUL;
627
628 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)vboxWddmMemAllocZero(sizeof (DEVICE_EXTENSION));
629 if (pContext)
630 {
631 pContext->pPDO = PhysicalDeviceObject;
632 *MiniportDeviceContext = pContext;
633 }
634 else
635 {
636 Status = STATUS_INSUFFICIENT_RESOURCES;
637 drprintf(("VBoxVideoWddm: ERROR, failed to create context\n"));
638 }
639
640 dfprintf(("<== "__FUNCTION__ ", status(0x%x), pContext(0x%x)\n", Status, pContext));
641
642 return Status;
643}
644
645NTSTATUS DxgkDdiStartDevice(
646 IN CONST PVOID MiniportDeviceContext,
647 IN PDXGK_START_INFO DxgkStartInfo,
648 IN PDXGKRNL_INTERFACE DxgkInterface,
649 OUT PULONG NumberOfVideoPresentSources,
650 OUT PULONG NumberOfChildren
651 )
652{
653 /* The DxgkDdiStartDevice function should be made pageable. */
654 PAGED_CODE();
655
656 NTSTATUS Status;
657
658 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
659
660 if ( ARGUMENT_PRESENT(MiniportDeviceContext) &&
661 ARGUMENT_PRESENT(DxgkInterface) &&
662 ARGUMENT_PRESENT(DxgkStartInfo) &&
663 ARGUMENT_PRESENT(NumberOfVideoPresentSources),
664 ARGUMENT_PRESENT(NumberOfChildren)
665 )
666 {
667 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)MiniportDeviceContext;
668
669 /* Save DeviceHandle and function pointers supplied by the DXGKRNL_INTERFACE structure passed to DxgkInterface. */
670 memcpy(&pContext->u.primary.DxgkInterface, DxgkInterface, sizeof (DXGKRNL_INTERFACE));
671
672 /* Allocate a DXGK_DEVICE_INFO structure, and call DxgkCbGetDeviceInformation to fill in the members of that structure, which include the registry path, the PDO, and a list of translated resources for the display adapter represented by MiniportDeviceContext. Save selected members (ones that the display miniport driver will need later)
673 * of the DXGK_DEVICE_INFO structure in the context block represented by MiniportDeviceContext. */
674 DXGK_DEVICE_INFO DeviceInfo;
675 Status = pContext->u.primary.DxgkInterface.DxgkCbGetDeviceInformation (pContext->u.primary.DxgkInterface.DeviceHandle, &DeviceInfo);
676 if (Status == STATUS_SUCCESS)
677 {
678 ULONG AdapterMemorySize;
679 Status = vboxWddmPickResources(pContext, &DeviceInfo, &AdapterMemorySize);
680 if (Status == STATUS_SUCCESS)
681 {
682 /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
683 VbglInit ();
684
685 /* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
686 * code will be ifdef'ed and later removed.
687 * The host will however support both old and new interface to keep compatibility
688 * with old guest additions.
689 */
690 VBoxSetupDisplaysHGSMI(pContext, AdapterMemorySize);
691 if ((pContext)->u.primary.bHGSMI)
692 {
693 drprintf(("VBoxVideoWddm: using HGSMI\n"));
694 *NumberOfVideoPresentSources = pContext->u.primary.cDisplays;
695 *NumberOfChildren = pContext->u.primary.cDisplays;
696 dprintf(("VBoxVideoWddm: sources(%d), children(%d)\n", *NumberOfVideoPresentSources, *NumberOfChildren));
697 }
698 else
699 {
700 drprintf(("VBoxVideoWddm: HGSMI failed to initialize, returning err\n"));
701 /* @todo: report a better status */
702 Status = STATUS_UNSUCCESSFUL;
703 }
704 }
705 else
706 {
707 drprintf(("VBoxVideoWddm:: vboxWddmPickResources failed Status(0x%x), returning err\n", Status));
708 Status = STATUS_UNSUCCESSFUL;
709 }
710 }
711 else
712 {
713 drprintf(("VBoxVideoWddm: DxgkCbGetDeviceInformation failed Status(0x%x), returning err\n", Status));
714 }
715 }
716 else
717 {
718 drprintf(("VBoxVideoWddm: invalid parameter, returning err\n"));
719 Status = STATUS_INVALID_PARAMETER;
720 }
721
722 dfprintf(("<== "__FUNCTION__ ", status(0x%x)\n", Status));
723
724 return Status;
725}
726
727NTSTATUS DxgkDdiStopDevice(
728 IN CONST PVOID MiniportDeviceContext
729 )
730{
731 return STATUS_NOT_IMPLEMENTED;
732}
733
734NTSTATUS DxgkDdiRemoveDevice(
735 IN CONST PVOID MiniportDeviceContext
736 )
737{
738 return STATUS_NOT_IMPLEMENTED;
739}
740
741NTSTATUS DxgkDdiDispatchIoRequest(
742 IN CONST PVOID MiniportDeviceContext,
743 IN ULONG VidPnSourceId,
744 IN PVIDEO_REQUEST_PACKET VideoRequestPacket
745 )
746{
747 return STATUS_NOT_IMPLEMENTED;
748}
749
750BOOLEAN DxgkDdiInterruptRoutine(
751 IN CONST PVOID MiniportDeviceContext,
752 IN ULONG MessageNumber
753 )
754{
755 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
756 BOOLEAN bOur = FALSE;
757 if (pDevExt->u.primary.pHostFlags) /* If HGSMI is enabled at all. */
758 {
759 VBOXSHGSMILIST CtlList;
760 VBOXSHGSMILIST DmaCmdList;
761 vboxSHGSMIListInit(&CtlList);
762 vboxSHGSMIListInit(&DmaCmdList);
763 do
764 {
765 uint32_t flags = pDevExt->u.primary.pHostFlags->u32HostFlags;
766 if (flags & HGSMIHOSTFLAGS_GCOMMAND_COMPLETED)
767 {
768 bOur = TRUE;
769 /* read the command offset */
770 HGSMIOFFSET offCmd = VBoxHGSMIGuestRead(pDevExt);
771 Assert(offCmd != HGSMIOFFSET_VOID);
772 if (offCmd != HGSMIOFFSET_VOID)
773 {
774 VBOXWDDM_HGSMICMD_TYPE enmType = vboxWddmHgsmiGetCmdTypeFromOffset(pDevExt, offCmd);
775 PVBOXSHGSMILIST pList;
776 HGSMIHEAP * pHeap = NULL;
777 switch (enmType)
778 {
779 case VBOXWDDM_HGSMICMD_TYPE_DMACMD:
780 pList = &DmaCmdList;
781 pHeap = &pDevExt->u.primary.Vdma.CmdHeap;
782 break;
783 case VBOXWDDM_HGSMICMD_TYPE_CTL:
784 pList = &CtlList;
785 pHeap = &pDevExt->u.primary.hgsmiAdapterHeap;
786 break;
787 default:
788 AssertBreakpoint();
789 }
790
791 if (pHeap)
792 {
793 int rc = VBoxSHGSMICommandProcessCompletion (pHeap, offCmd, TRUE /*bool bIrq*/ , pList);
794 AssertRC(rc);
795 }
796 }
797 }
798 else if (flags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
799 {
800 bOur = TRUE;
801 AssertBreakpoint();
802 /* @todo: FIXME: implement !!! */
803 }
804 else if (flags & HGSMIHOSTFLAGS_IRQ)
805 {
806 bOur = TRUE;
807 AssertBreakpoint();
808 /* unknown command */
809 }
810 else
811 break;
812 } while (1);
813
814 if (!vboxSHGSMIListIsEmpty(&CtlList))
815 vboxSHGSMIListCat(&pDevExt->CtlList, &CtlList);
816
817 if (!vboxSHGSMIListIsEmpty(&DmaCmdList))
818 vboxSHGSMIListCat(&pDevExt->DmaCmdList, &DmaCmdList);
819
820 if (pDevExt->bSetNotifyDxDpc)
821 {
822 pDevExt->bNotifyDxDpc = TRUE;
823 pDevExt->bSetNotifyDxDpc = FALSE;
824 }
825
826 if (bOur)
827 HGSMIClearIrq (pDevExt);
828 }
829
830 return bOur;
831}
832
833
834typedef struct VBOXWDDM_DPCDATA
835{
836 VBOXSHGSMILIST CtlList;
837 VBOXSHGSMILIST DmaCmdList;
838 BOOL bNotifyDpc;
839} VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA;
840
841typedef struct VBOXWDDM_GETDPCDATA_CONTEXT
842{
843 PDEVICE_EXTENSION pDevExt;
844 VBOXWDDM_DPCDATA data;
845} VBOXWDDM_GETDPCDATA_CONTEXT, *PVBOXWDDM_GETDPCDATA_CONTEXT;
846
847BOOLEAN vboxWddmGetDPCDataCallback(PVOID Context)
848{
849 PVBOXWDDM_GETDPCDATA_CONTEXT pdc = (PVBOXWDDM_GETDPCDATA_CONTEXT)Context;
850
851 vboxSHGSMICmdListDetach2List(&pdc->pDevExt->CtlList, &pdc->data.CtlList);
852 vboxSHGSMICmdListDetach2List(&pdc->pDevExt->DmaCmdList, &pdc->data.DmaCmdList);
853 pdc->data.bNotifyDpc = pdc->pDevExt->bNotifyDxDpc;
854 pdc->pDevExt->bNotifyDxDpc = FALSE;
855 return TRUE;
856}
857
858VOID DxgkDdiDpcRoutine(
859 IN CONST PVOID MiniportDeviceContext
860 )
861{
862 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
863
864 VBOXWDDM_DPCDATA dpcData = {0};
865 BOOLEAN bRet;
866
867 /* get DPC data at IRQL */
868 NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
869 pDevExt->u.primary.DxgkInterface.DeviceHandle,
870 vboxWddmGetDPCDataCallback,
871 &dpcData,
872 0,
873 &bRet);
874 Assert(Status == STATUS_SUCCESS);
875
876 if (!vboxSHGSMIListIsEmpty(&dpcData.CtlList))
877 {
878 int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.hgsmiAdapterHeap, &dpcData.CtlList);
879 AssertRC(rc);
880 }
881
882 if (!vboxSHGSMIListIsEmpty(&dpcData.DmaCmdList))
883 {
884 int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.Vdma.CmdHeap, &dpcData.DmaCmdList);
885 AssertRC(rc);
886 }
887
888 if (dpcData.bNotifyDpc)
889 pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
890}
891
892NTSTATUS DxgkDdiQueryChildRelations(
893 IN CONST PVOID MiniportDeviceContext,
894 IN OUT PDXGK_CHILD_DESCRIPTOR ChildRelations,
895 IN ULONG ChildRelationsSize
896 )
897{
898 /* The DxgkDdiQueryChildRelations function should be made pageable. */
899 PAGED_CODE();
900
901 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
902
903 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
904 for (int i = 0; i < pDevExt->u.primary.cDisplays; ++i)
905 {
906 ChildRelations[i].ChildDeviceType = TypeVideoOutput;
907 ChildRelations[i].ChildCapabilities.Type.VideoOutput.InterfaceTechnology = D3DKMDT_VOT_HD15; /* VGA */
908 ChildRelations[i].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_INTERRUPTIBLE; /* ?? D3DKMDT_MOA_NONE*/
909 ChildRelations[i].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = FALSE;
910 ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible; /* ?? HpdAwarenessAlwaysConnected; */
911 ChildRelations[i].AcpiUid = i; /* */
912 ChildRelations[i].ChildUid = i; /* should be == target id */
913 }
914 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
915 return STATUS_SUCCESS;
916}
917
918NTSTATUS DxgkDdiQueryChildStatus(
919 IN CONST PVOID MiniportDeviceContext,
920 IN PDXGK_CHILD_STATUS ChildStatus,
921 IN BOOLEAN NonDestructiveOnly
922 )
923{
924 /* The DxgkDdiQueryChildStatus should be made pageable. */
925 PAGED_CODE();
926
927 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
928
929 NTSTATUS Status = STATUS_SUCCESS;
930 switch (ChildStatus->Type)
931 {
932 case StatusConnection:
933 ChildStatus->HotPlug.Connected = TRUE;
934 dfprintf(("VBoxVideoWddm: StatusConnection\n"));
935 break;
936 case StatusRotation:
937 ChildStatus->Rotation.Angle = 0;
938 dfprintf(("VBoxVideoWddm: StatusRotation\n"));
939 break;
940 default:
941 drprintf(("VBoxVideoWddm: ERROR: status type: %d\n", ChildStatus->Type));
942 Status = STATUS_INVALID_PARAMETER;
943 break;
944 }
945
946 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
947
948 return Status;
949}
950
951NTSTATUS DxgkDdiQueryDeviceDescriptor(
952 IN CONST PVOID MiniportDeviceContext,
953 IN ULONG ChildUid,
954 IN OUT PDXGK_DEVICE_DESCRIPTOR DeviceDescriptor
955 )
956{
957 /* The DxgkDdiQueryDeviceDescriptor should be made pageable. */
958 PAGED_CODE();
959
960 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
961
962 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
963
964 /* we do not support EDID */
965 return STATUS_MONITOR_NO_DESCRIPTOR;
966}
967
968NTSTATUS DxgkDdiSetPowerState(
969 IN CONST PVOID MiniportDeviceContext,
970 IN ULONG DeviceUid,
971 IN DEVICE_POWER_STATE DevicePowerState,
972 IN POWER_ACTION ActionType
973 )
974{
975 /* The DxgkDdiSetPowerState function should be made pageable. */
976 PAGED_CODE();
977
978 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
979
980 /* @todo: */
981
982 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
983
984 return STATUS_SUCCESS;
985}
986
987NTSTATUS DxgkDdiNotifyAcpiEvent(
988 IN CONST PVOID MiniportDeviceContext,
989 IN DXGK_EVENT_TYPE EventType,
990 IN ULONG Event,
991 IN PVOID Argument,
992 OUT PULONG AcpiFlags
993 )
994{
995 return STATUS_NOT_IMPLEMENTED;
996}
997
998VOID DxgkDdiResetDevice(
999 IN CONST PVOID MiniportDeviceContext
1000 )
1001{
1002 /* DxgkDdiResetDevice can be called at any IRQL, so it must be in nonpageable memory. */
1003 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
1004 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
1005}
1006
1007VOID DxgkDdiUnload(
1008 VOID
1009 )
1010{
1011 /* DxgkDdiUnload should be made pageable. */
1012 PAGED_CODE();
1013 dfprintf(("==> "__FUNCTION__ "\n"));
1014 dfprintf(("<== "__FUNCTION__ "\n"));
1015}
1016
1017NTSTATUS DxgkDdiQueryInterface(
1018 IN CONST PVOID MiniportDeviceContext,
1019 IN PQUERY_INTERFACE QueryInterface
1020 )
1021{
1022 return STATUS_NOT_IMPLEMENTED;
1023}
1024
1025VOID DxgkDdiControlEtwLogging(
1026 IN BOOLEAN Enable,
1027 IN ULONG Flags,
1028 IN UCHAR Level
1029 )
1030{
1031
1032}
1033
1034NTSTATUS APIENTRY DxgkDdiQueryAdapterInfo(
1035 CONST HANDLE hAdapter,
1036 CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
1037{
1038 /* The DxgkDdiQueryAdapterInfo should be made pageable. */
1039 PAGED_CODE();
1040
1041 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1042 NTSTATUS Status = STATUS_SUCCESS;
1043 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1044
1045 switch (pQueryAdapterInfo->Type)
1046 {
1047 case DXGKQAITYPE_DRIVERCAPS:
1048 {
1049 DXGK_DRIVERCAPS *pCaps = (DXGK_DRIVERCAPS*)pQueryAdapterInfo->pOutputData;
1050
1051 pCaps->HighestAcceptableAddress.HighPart = 0x0;
1052 pCaps->HighestAcceptableAddress.LowPart = 0xffffffffUL;
1053 pCaps->MaxAllocationListSlotId = 16;
1054 pCaps->ApertureSegmentCommitLimit = 0;
1055 pCaps->MaxPointerWidth = 64;
1056 pCaps->MaxPointerHeight = 64;
1057 pCaps->PointerCaps.Value = 3; /* Monochrome , Color*/ /* MaskedColor == Value | 4, dosable for now */
1058 pCaps->InterruptMessageNumber = 0;
1059 pCaps->NumberOfSwizzlingRanges = 0;
1060 /* @todo: need to adjust this for proper 2D Accel support */
1061 pCaps->MaxOverlays = 0; /* ?? how much should we support? 32 */
1062 pCaps->GammaRampCaps.Value = 0;
1063 pCaps->PresentationCaps.Value = 0;
1064 pCaps->PresentationCaps.NoScreenToScreenBlt = 1;
1065 pCaps->PresentationCaps.NoOverlapScreenBlt = 1;
1066 pCaps->MaxQueuedFlipOnVSync = 0; /* do we need it? */
1067 pCaps->FlipCaps.Value = 0;
1068 /* ? pCaps->FlipCaps.FlipOnVSyncWithNoWait = 1; */
1069 pCaps->SchedulingCaps.Value = 0;
1070 /* we might need it for Aero.
1071 * Setting this glag means we support DeviceContext, i.e.
1072 * DxgkDdiCreateContext and DxgkDdiDestroyContext
1073 */
1074 pCaps->SchedulingCaps.MultiEngineAware = 1;
1075 pCaps->MemoryManagementCaps.Value = 0;
1076 /* @todo: this corelates with pCaps->SchedulingCaps.MultiEngineAware */
1077 pCaps->MemoryManagementCaps.PagingNode = 0;
1078 /* @todo: this corelates with pCaps->SchedulingCaps.MultiEngineAware */
1079 pCaps->GpuEngineTopology.NbAsymetricProcessingNodes = 1;
1080
1081 break;
1082 }
1083 case DXGKQAITYPE_QUERYSEGMENT:
1084 {
1085 /* no need for DXGK_QUERYSEGMENTIN as it contains AGP aperture info, which (AGP aperture) we do not support
1086 * DXGK_QUERYSEGMENTIN *pQsIn = (DXGK_QUERYSEGMENTIN*)pQueryAdapterInfo->pInputData; */
1087 DXGK_QUERYSEGMENTOUT *pQsOut = (DXGK_QUERYSEGMENTOUT*)pQueryAdapterInfo->pOutputData;
1088 if (!pQsOut->pSegmentDescriptor)
1089 {
1090 /* we are requested to provide the number of segments we support */
1091 pQsOut->NbSegment = 1;
1092 }
1093 else if (pQsOut->NbSegment != 1)
1094 {
1095 AssertBreakpoint();
1096 drprintf((__FUNCTION__ " NbSegment (%d) != 1\n", pQsOut->NbSegment));
1097 Status = STATUS_INVALID_PARAMETER;
1098 }
1099 else
1100 {
1101 /* we are requested to provide segment information */
1102 pQsOut->pSegmentDescriptor->BaseAddress.QuadPart = 0; /* VBE_DISPI_LFB_PHYSICAL_ADDRESS; */
1103 pQsOut->pSegmentDescriptor->CpuTranslatedAddress.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
1104 /* make sure the size is page aligned */
1105 /* @todo: need to setup VBVA buffers and adjust the mem size here */
1106 pQsOut->pSegmentDescriptor->Size = (pContext->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE - pContext->u.primary.cbMiniportHeap) & (~0xfffUL);
1107 pQsOut->pSegmentDescriptor->NbOfBanks = 0;
1108 pQsOut->pSegmentDescriptor->pBankRangeTable = 0;
1109 pQsOut->pSegmentDescriptor->CommitLimit = pQsOut->pSegmentDescriptor->Size;
1110 pQsOut->pSegmentDescriptor->Flags.Value = 0;
1111 pQsOut->pSegmentDescriptor->Flags.CpuVisible = 1;
1112 }
1113 pQsOut->PagingBufferSegmentId = 0;
1114 pQsOut->PagingBufferSize = 1024;
1115 pQsOut->PagingBufferPrivateDataSize = 0; /* @todo: do we need a private buffer ? */
1116 break;
1117 }
1118 case DXGKQAITYPE_UMDRIVERPRIVATE:
1119 drprintf((__FUNCTION__ ": we do not support DXGKQAITYPE_UMDRIVERPRIVATE\n"));
1120 AssertBreakpoint();
1121 Status = STATUS_NOT_SUPPORTED;
1122 break;
1123 default:
1124 drprintf((__FUNCTION__ ": unsupported Type (%d)\n", pQueryAdapterInfo->Type));
1125 AssertBreakpoint();
1126 Status = STATUS_NOT_SUPPORTED;
1127 break;
1128 }
1129 dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status));
1130 return Status;
1131}
1132
1133NTSTATUS APIENTRY DxgkDdiCreateDevice(
1134 CONST HANDLE hAdapter,
1135 DXGKARG_CREATEDEVICE* pCreateDevice)
1136{
1137 /* DxgkDdiCreateDevice should be made pageable. */
1138 PAGED_CODE();
1139
1140 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1141 NTSTATUS Status = STATUS_SUCCESS;
1142 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1143
1144 PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)vboxWddmMemAllocZero(sizeof (VBOXWDDM_DEVICE));
1145 pDevice->hDevice = pCreateDevice->hDevice;
1146 pDevice->pAdapter = pContext;
1147 pDevice->fCreationFlags = pCreateDevice->Flags;
1148
1149 pDevice->DeviceInfo.AllocationListSize = 1024;
1150 pDevice->DeviceInfo.DmaBufferSegmentSet = 0;
1151 pDevice->DeviceInfo.DmaBufferPrivateDataSize = 0;
1152 pDevice->DeviceInfo.AllocationListSize = 4;
1153 pDevice->DeviceInfo.PatchLocationListSize = 4;
1154 pDevice->DeviceInfo.Flags.Value = 0;
1155 pDevice->DeviceInfo.Flags.GuaranteedDmaBufferContract = 1;
1156
1157 pCreateDevice->pInfo = &pDevice->DeviceInfo;
1158 pCreateDevice->hDevice = pDevice;
1159
1160 dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status));
1161
1162 return Status;
1163}
1164NTSTATUS vboxWddmDestroyAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
1165{
1166 PAGED_CODE();
1167
1168 vboxWddmMemFree(pAllocation);
1169 return STATUS_SUCCESS;
1170}
1171
1172NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONINFO* pAllocationInfo)
1173{
1174 PAGED_CODE();
1175
1176 NTSTATUS Status = STATUS_SUCCESS;
1177
1178 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
1179 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
1180 {
1181 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData;
1182 switch (pAllocInfo->enmType)
1183 {
1184 case VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE:
1185 {
1186 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE));
1187 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))
1188 {
1189 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1190 UINT bpp = vboxWddmCalcBitsPerPixel(pInfo->SurfData.Format);
1191 Assert(bpp);
1192 if (bpp != 0)
1193 {
1194 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE));
1195 Assert(pAllocation);
1196 if (pAllocation)
1197 {
1198 UINT Pitch = vboxWddmCalcPitch(pInfo->SurfData.Width, bpp);
1199 pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE;
1200 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
1201 memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo));
1202
1203 pAllocationInfo->pPrivateDriverData = NULL;
1204 pAllocationInfo->PrivateDriverDataSize = 0;
1205 pAllocationInfo->Alignment = 0;
1206 pAllocationInfo->Size = Pitch * pInfo->SurfData.Height;
1207 pAllocationInfo->PitchAlignedSize = 0;
1208 pAllocationInfo->HintedBank.Value = 0;
1209 pAllocationInfo->PreferredSegment.Value = 0;
1210 pAllocationInfo->SupportedReadSegmentSet = 1;
1211 pAllocationInfo->SupportedWriteSegmentSet = 1;
1212 pAllocationInfo->EvictionSegmentSet = 0;
1213 pAllocationInfo->MaximumRenamingListLength = 0;
1214 pAllocationInfo->hAllocation = pAlloc;
1215 pAllocationInfo->Flags.Value = 0;
1216 pAllocationInfo->Flags.CpuVisible = 1;
1217 pAllocationInfo->pAllocationUsageHint = NULL;
1218 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
1219 }
1220 else
1221 {
1222 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
1223 Status = STATUS_NO_MEMORY;
1224 }
1225 }
1226 else
1227 {
1228 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pInfo->SurfData.Format));
1229 Status = STATUS_INVALID_PARAMETER;
1230 }
1231 }
1232 else
1233 {
1234 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)));
1235 Status = STATUS_INVALID_PARAMETER;
1236 }
1237 break;
1238 }
1239 case VBOXWDDM_ALLOC_STD_SHADOWSURFACE:
1240 {
1241 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE));
1242 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE))
1243 {
1244 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE));
1245 Assert(pAllocation);
1246 if (pAllocation)
1247 {
1248 pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE;
1249 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHADOWSURFACE);
1250 PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
1251 memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo));
1252
1253 pAllocationInfo->pPrivateDriverData = NULL;
1254 pAllocationInfo->PrivateDriverDataSize = 0;
1255 pAllocationInfo->Alignment = 0;
1256 pAllocationInfo->Size = pInfo->SurfData.Pitch * pInfo->SurfData.Height;
1257 pAllocationInfo->PitchAlignedSize = 0;
1258 pAllocationInfo->HintedBank.Value = 0;
1259 pAllocationInfo->PreferredSegment.Value = 0;
1260 pAllocationInfo->SupportedReadSegmentSet = 1;
1261 pAllocationInfo->SupportedWriteSegmentSet = 1;
1262 pAllocationInfo->EvictionSegmentSet = 0;
1263 pAllocationInfo->MaximumRenamingListLength = 0;
1264 pAllocationInfo->hAllocation = pAlloc;
1265 pAllocationInfo->Flags.Value = 0;
1266 pAllocationInfo->Flags.CpuVisible = 1;
1267 pAllocationInfo->pAllocationUsageHint = NULL;
1268 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
1269 }
1270 else
1271 {
1272 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
1273 Status = STATUS_NO_MEMORY;
1274 }
1275 }
1276 else
1277 {
1278 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHADOWSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)));
1279 Status = STATUS_INVALID_PARAMETER;
1280 }
1281 break;
1282 }
1283 case VBOXWDDM_ALLOC_STD_STAGINGSURFACE:
1284 {
1285 /* @todo: impl */
1286 AssertBreakpoint();
1287 break;
1288 }
1289 default:
1290 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType));
1291 Status = STATUS_INVALID_PARAMETER;
1292 break;
1293 }
1294 }
1295 else
1296 {
1297 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
1298 Status = STATUS_INVALID_PARAMETER;
1299 }
1300
1301 return Status;
1302}
1303
1304NTSTATUS APIENTRY DxgkDdiCreateAllocation(
1305 CONST HANDLE hAdapter,
1306 DXGKARG_CREATEALLOCATION* pCreateAllocation)
1307{
1308 /* DxgkDdiCreateAllocation should be made pageable. */
1309 PAGED_CODE();
1310
1311 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1312
1313 NTSTATUS Status = STATUS_SUCCESS;
1314
1315 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
1316 {
1317 Status = vboxWddmCreateAllocation((PDEVICE_EXTENSION)hAdapter, &pCreateAllocation->pAllocationInfo[i]);
1318 Assert(Status == STATUS_SUCCESS);
1319 if (Status != STATUS_SUCCESS)
1320 {
1321 drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status));
1322 /* note: i-th allocation is expected to be cleared in a fail handling code above */
1323 for (UINT j = 0; j < i; ++j)
1324 {
1325 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
1326 }
1327 }
1328 }
1329
1330 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1331
1332 return Status;
1333}
1334
1335NTSTATUS
1336APIENTRY
1337DxgkDdiDestroyAllocation(
1338 CONST HANDLE hAdapter,
1339 CONST DXGKARG_DESTROYALLOCATION* pDestroyAllocation)
1340{
1341 /* DxgkDdiDestroyAllocation should be made pageable. */
1342 PAGED_CODE();
1343
1344 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1345 NTSTATUS Status = STATUS_SUCCESS;
1346
1347 for (UINT i = 0; i < pDestroyAllocation->NumAllocations; ++i)
1348 {
1349 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pDestroyAllocation->pAllocationList[i]);
1350 }
1351
1352 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1353
1354 return Status;
1355}
1356
1357
1358NTSTATUS
1359APIENTRY
1360DxgkDdiDescribeAllocation(
1361 CONST HANDLE hAdapter,
1362 DXGKARG_DESCRIBEALLOCATION* pDescribeAllocation)
1363{
1364 return STATUS_NOT_IMPLEMENTED;
1365}
1366
1367/**
1368 *
1369 */
1370NTSTATUS
1371APIENTRY
1372DxgkDdiGetStandardAllocationDriverData(
1373 CONST HANDLE hAdapter,
1374 DXGKARG_GETSTANDARDALLOCATIONDRIVERDATA* pGetStandardAllocationDriverData)
1375{
1376 /* DxgkDdiGetStandardAllocationDriverData should be made pageable. */
1377 PAGED_CODE();
1378
1379 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1380
1381 NTSTATUS Status = STATUS_SUCCESS;
1382 PVBOXWDDM_ALLOCINFO pAllocInfo = NULL;
1383
1384 switch (pGetStandardAllocationDriverData->StandardAllocationType)
1385 {
1386 case D3DKMDT_STANDARDALLOCATION_SHAREDPRIMARYSURFACE:
1387 {
1388 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_SHAREDPRIMARYSURFACE\n"));
1389 if(pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1390 {
1391 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1392 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE;
1393 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1394 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData, sizeof (pInfo->SurfData));
1395 }
1396 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1397
1398 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1399 break;
1400 }
1401 case D3DKMDT_STANDARDALLOCATION_SHADOWSURFACE:
1402 {
1403 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_SHADOWSURFACE\n"));
1404 UINT bpp = vboxWddmCalcBitsPerPixel(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format);
1405 Assert(bpp);
1406 if (bpp != 0)
1407 {
1408 UINT Pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, bpp);
1409 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = Pitch;
1410
1411 /* @todo: need [d/q]word align?? */
1412
1413 if (pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1414 {
1415 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1416 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE;
1417 PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
1418 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateShadowSurfaceData, sizeof (pInfo->SurfData));
1419 }
1420 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
1421
1422 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1423 }
1424 else
1425 {
1426 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format));
1427 Status = STATUS_INVALID_PARAMETER;
1428 }
1429 break;
1430 }
1431 case D3DKMDT_STANDARDALLOCATION_STAGINGSURFACE:
1432 {
1433 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_STAGINGSURFACE\n"));
1434 if(pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1435 {
1436 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1437 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_STAGINGSURFACE;
1438 PVBOXWDDM_ALLOCINFO_STAGINGSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_STAGINGSURFACE);
1439 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateStagingSurfaceData, sizeof (pInfo->SurfData));
1440 }
1441 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_STAGINGSURFACE);
1442
1443 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1444 break;
1445 }
1446//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
1447// case D3DKMDT_STANDARDALLOCATION_GDISURFACE:
1448// break;
1449//#endif
1450 default:
1451 drprintf((__FUNCTION__ ": Invalid allocation type (%d)\n", pGetStandardAllocationDriverData->StandardAllocationType));
1452 Status = STATUS_INVALID_PARAMETER;
1453 break;
1454 }
1455
1456 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1457
1458 return Status;
1459}
1460
1461NTSTATUS
1462APIENTRY
1463DxgkDdiAcquireSwizzlingRange(
1464 CONST HANDLE hAdapter,
1465 DXGKARG_ACQUIRESWIZZLINGRANGE* pAcquireSwizzlingRange)
1466{
1467 return STATUS_NOT_IMPLEMENTED;
1468}
1469
1470NTSTATUS
1471APIENTRY
1472DxgkDdiReleaseSwizzlingRange(
1473 CONST HANDLE hAdapter,
1474 CONST DXGKARG_RELEASESWIZZLINGRANGE* pReleaseSwizzlingRange)
1475{
1476 return STATUS_NOT_IMPLEMENTED;
1477}
1478
1479NTSTATUS
1480APIENTRY
1481DxgkDdiPatch(
1482 CONST HANDLE hAdapter,
1483 CONST DXGKARG_PATCH* pPatch)
1484{
1485 return STATUS_NOT_IMPLEMENTED;
1486}
1487
1488NTSTATUS
1489APIENTRY
1490DxgkDdiSubmitCommand(
1491 CONST HANDLE hAdapter,
1492 CONST DXGKARG_SUBMITCOMMAND* pSubmitCommand)
1493{
1494 return STATUS_NOT_IMPLEMENTED;
1495}
1496
1497NTSTATUS
1498APIENTRY
1499DxgkDdiPreemptCommand(
1500 CONST HANDLE hAdapter,
1501 CONST DXGKARG_PREEMPTCOMMAND* pPreemptCommand)
1502{
1503 return STATUS_NOT_IMPLEMENTED;
1504}
1505
1506NTSTATUS
1507APIENTRY
1508DxgkDdiBuildPagingBuffer(
1509 CONST HANDLE hAdapter,
1510 DXGKARG_BUILDPAGINGBUFFER* pBuildPagingBuffer)
1511{
1512 return STATUS_NOT_IMPLEMENTED;
1513}
1514
1515NTSTATUS
1516APIENTRY
1517DxgkDdiSetPalette(
1518 CONST HANDLE hAdapter,
1519 CONST DXGKARG_SETPALETTE* pSetPalette
1520 )
1521{
1522 return STATUS_NOT_IMPLEMENTED;
1523}
1524
1525NTSTATUS
1526APIENTRY
1527DxgkDdiSetPointerPosition(
1528 CONST HANDLE hAdapter,
1529 CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
1530{
1531 return STATUS_NOT_IMPLEMENTED;
1532}
1533
1534NTSTATUS
1535APIENTRY
1536DxgkDdiSetPointerShape(
1537 CONST HANDLE hAdapter,
1538 CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
1539{
1540 return STATUS_NOT_IMPLEMENTED;
1541}
1542
1543NTSTATUS
1544APIENTRY CALLBACK
1545DxgkDdiResetFromTimeout(
1546 CONST HANDLE hAdapter)
1547{
1548 return STATUS_NOT_IMPLEMENTED;
1549}
1550
1551NTSTATUS
1552APIENTRY
1553DxgkDdiEscape(
1554 CONST HANDLE hAdapter,
1555 CONST DXGKARG_ESCAPE* pEscape)
1556{
1557 PAGED_CODE();
1558
1559 return STATUS_INVALID_PARAMETER;
1560}
1561
1562NTSTATUS
1563APIENTRY
1564DxgkDdiCollectDbgInfo(
1565 CONST HANDLE hAdapter,
1566 CONST DXGKARG_COLLECTDBGINFO* pCollectDbgInfo
1567 )
1568{
1569 return STATUS_NOT_IMPLEMENTED;
1570}
1571
1572NTSTATUS
1573APIENTRY
1574DxgkDdiQueryCurrentFence(
1575 CONST HANDLE hAdapter,
1576 DXGKARG_QUERYCURRENTFENCE* pCurrentFence)
1577{
1578 return STATUS_NOT_IMPLEMENTED;
1579}
1580
1581NTSTATUS
1582APIENTRY
1583DxgkDdiIsSupportedVidPn(
1584 CONST HANDLE hAdapter,
1585 OUT DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPnArg
1586 )
1587{
1588 /* The DxgkDdiIsSupportedVidPn should be made pageable. */
1589 PAGED_CODE();
1590
1591 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1592
1593 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1594 BOOLEAN bSupported = TRUE;
1595 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
1596 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pIsSupportedVidPnArg->hDesiredVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
1597 if (Status == STATUS_SUCCESS)
1598 {
1599 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1600 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1601 Status = pVidPnInterface->pfnGetTopology(pIsSupportedVidPnArg->hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1602 if (Status == STATUS_SUCCESS)
1603 {
1604 Status = vboxVidPnCheckTopology(pIsSupportedVidPnArg->hDesiredVidPn, hVidPnTopology, pVidPnTopologyInterface, &bSupported);
1605 if (Status == STATUS_SUCCESS && bSupported)
1606 {
1607 for (int id = 0; id < pContext->u.primary.cDisplays; id++)
1608 {
1609 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
1610 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface;
1611 Status = pVidPnInterface->pfnAcquireSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn,
1612 id,
1613 &hNewVidPnSourceModeSet,
1614 &pVidPnSourceModeSetInterface);
1615 if (Status == STATUS_SUCCESS)
1616 {
1617 Status = vboxVidPnCheckSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface, &bSupported);
1618
1619 pVidPnInterface->pfnReleaseSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet);
1620
1621 if (Status != STATUS_SUCCESS || !bSupported)
1622 break;
1623 }
1624 else if (Status == STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE)
1625 {
1626 drprintf(("VBoxVideoWddm: Warning: pfnAcquireSourceModeSet returned STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE, continuing\n"));
1627 Status = STATUS_SUCCESS;
1628 }
1629 else
1630 {
1631 drprintf(("VBoxVideoWddm: pfnAcquireSourceModeSet failed Status(0x%x)\n"));
1632 break;
1633 }
1634 }
1635
1636 if (Status == STATUS_SUCCESS && bSupported)
1637 {
1638 for (int id = 0; id < pContext->u.primary.cDisplays; id++)
1639 {
1640 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
1641 CONST DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface;
1642 Status = pVidPnInterface->pfnAcquireTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn,
1643 id, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
1644 &hNewVidPnTargetModeSet,
1645 &pVidPnTargetModeSetInterface);
1646 if (Status == STATUS_SUCCESS)
1647 {
1648 Status = vboxVidPnCheckTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface, &bSupported);
1649
1650 pVidPnInterface->pfnReleaseTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet);
1651
1652 if (Status != STATUS_SUCCESS || !bSupported)
1653 break;
1654 }
1655 else if (Status == STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE)
1656 {
1657 drprintf(("VBoxVideoWddm: Warning: pfnAcquireSourceModeSet returned STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE, continuing\n"));
1658 Status = STATUS_SUCCESS;
1659 }
1660 else
1661 {
1662 drprintf(("VBoxVideoWddm: pfnAcquireSourceModeSet failed Status(0x%x)\n"));
1663 break;
1664 }
1665 }
1666 }
1667 }
1668 }
1669 else
1670 {
1671 drprintf(("VBoxVideoWddm: pfnGetTopology failed Status(0x%x)\n"));
1672 }
1673 }
1674 else
1675 {
1676 drprintf(("VBoxVideoWddm: DxgkCbQueryVidPnInterface failed Status(0x%x)\n"));
1677 }
1678 pIsSupportedVidPnArg->IsVidPnSupported = bSupported;
1679
1680 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1681
1682 return STATUS_SUCCESS;
1683}
1684
1685NTSTATUS
1686APIENTRY
1687DxgkDdiRecommendFunctionalVidPn(
1688 CONST HANDLE hAdapter,
1689 CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPnArg
1690 )
1691{
1692 /* The DxgkDdiRecommendFunctionalVidPn should be made pageable. */
1693 PAGED_CODE();
1694
1695 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1696
1697 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1698 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
1699 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
1700 if (Status == STATUS_SUCCESS)
1701 {
1702 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1703 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1704 Status = pVidPnInterface->pfnGetTopology(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1705 if (Status == STATUS_SUCCESS)
1706 {
1707 D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo;
1708 Status = pVidPnTopologyInterface->pfnCreateNewPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1709 if (Status == STATUS_SUCCESS)
1710 {
1711 pNewVidPnPresentPathInfo->VidPnSourceId = 0;
1712 pNewVidPnPresentPathInfo->VidPnTargetId = 0;
1713 pNewVidPnPresentPathInfo->ImportanceOrdinal = D3DKMDT_VPPI_PRIMARY;
1714 pNewVidPnPresentPathInfo->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
1715 memset(&pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport,
1716 0, sizeof (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport));
1717 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity = 1;
1718 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered = 1;
1719 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched = 0;
1720 pNewVidPnPresentPathInfo->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
1721 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity = 1;
1722 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180 = 0;
1723 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270 = 0;
1724 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90 = 0;
1725 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx = 0;
1726 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy = 0;
1727 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx = 0;
1728 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy = 0;
1729 pNewVidPnPresentPathInfo->VidPnTargetColorBasis = D3DKMDT_CB_SRGB; /* @todo: how does it matters? */
1730 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel = 8;
1731 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel = 8;
1732 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel = 8;
1733 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel = 0;
1734 pNewVidPnPresentPathInfo->Content = D3DKMDT_VPPC_GRAPHICS;
1735 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_NOPROTECTION;
1736 pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits = 0;
1737 memset(&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, 0, sizeof (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport));
1738 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport.NoProtection = 1;
1739 pNewVidPnPresentPathInfo->GammaRamp.Type = D3DDDI_GAMMARAMP_DEFAULT;
1740 pNewVidPnPresentPathInfo->GammaRamp.DataSize = 0;
1741 Status = pVidPnTopologyInterface->pfnAddPath(hVidPnTopology, pNewVidPnPresentPathInfo);
1742 if (Status == STATUS_SUCCESS)
1743 {
1744 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
1745 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface;
1746 Status = pVidPnInterface->pfnCreateNewSourceModeSet(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn,
1747 0, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
1748 &hNewVidPnSourceModeSet,
1749 &pVidPnSourceModeSetInterface);
1750 if (Status == STATUS_SUCCESS)
1751 {
1752 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1753 Status = pVidPnSourceModeSetInterface->pfnCreateNewModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1754 if (Status == STATUS_SUCCESS)
1755 {
1756 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnSourceModeInfo->Id;
1757 pNewVidPnSourceModeInfo->Type = D3DKMDT_RMT_GRAPHICS;
1758 /* @todo: should we obtain the default mode from the host? */
1759 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx = 1024;
1760 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy = 768;
1761 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
1762 pNewVidPnSourceModeInfo->Format.Graphics.Stride = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx * 4;
1763 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat = D3DDDIFMT_X8R8G8B8;
1764 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis = D3DKMDT_CB_SRGB;
1765 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_DIRECT;
1766 Status = pVidPnSourceModeSetInterface->pfnAddMode(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
1767 if (Status == STATUS_SUCCESS)
1768 {
1769 Status = pVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, modeId);
1770 if (Status == STATUS_SUCCESS)
1771 {
1772 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
1773 CONST DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface;
1774 Status = pVidPnInterface->pfnCreateNewTargetModeSet(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn,
1775 0, /* __in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
1776 &hNewVidPnTargetModeSet,
1777 &pVidPnTargetModeSetInterface);
1778 if (Status == STATUS_SUCCESS)
1779 {
1780 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
1781 Status = pVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
1782 if (Status == STATUS_SUCCESS)
1783 {
1784 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID targetId = pNewVidPnTargetModeInfo->Id;
1785 pNewVidPnTargetModeInfo->VideoSignalInfo.VideoStandard = D3DKMDT_VSS_OTHER;
1786 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cx = 1024;
1787 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy = 768;
1788 pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize = pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize;
1789 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60;
1790 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1;
1791 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = 63 * 768; /* @todo: do we need that? */
1792 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
1793 pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* ?? */
1794 pNewVidPnTargetModeInfo->VideoSignalInfo.ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
1795 pNewVidPnTargetModeInfo->Preference = D3DKMDT_MP_PREFERRED;
1796 Status = pVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
1797 if (Status == STATUS_SUCCESS)
1798 {
1799 Status = pVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, targetId);
1800 if (Status == STATUS_SUCCESS)
1801 {
1802
1803 }
1804 else
1805 {
1806 drprintf(("VBoxVideoWddm: pfnPinMode (target) failed Status(0x%x)\n"));
1807 }
1808 }
1809 else
1810 {
1811 drprintf(("VBoxVideoWddm: pfnAddMode (target) failed Status(0x%x)\n"));
1812 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
1813 pNewVidPnTargetModeInfo = NULL;
1814 }
1815 }
1816 else
1817 {
1818 drprintf(("VBoxVideoWddm: pfnCreateNewModeInfo (target) failed Status(0x%x)\n"));
1819 }
1820 }
1821 else
1822 {
1823 drprintf(("VBoxVideoWddm: pfnCreateNewTargetModeSet failed Status(0x%x)\n"));
1824 }
1825 }
1826 else
1827 {
1828 drprintf(("VBoxVideoWddm: pfnPinMode failed Status(0x%x)\n"));
1829 }
1830 }
1831 else
1832 {
1833 drprintf(("VBoxVideoWddm: pfnAddMode failed Status(0x%x)\n"));
1834 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
1835 pNewVidPnSourceModeInfo = NULL;
1836 }
1837 }
1838 else
1839 {
1840 drprintf(("VBoxVideoWddm: pfnCreateNewModeInfo failed Status(0x%x)\n"));
1841 }
1842 }
1843 else
1844 {
1845 drprintf(("VBoxVideoWddm: pfnCreateNewSourceModeSet failed Status(0x%x)\n"));
1846 }
1847 }
1848 else
1849 {
1850 drprintf(("VBoxVideoWddm: pfnAddPath failed Status(0x%x)\n"));
1851 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
1852 pNewVidPnPresentPathInfo = NULL;
1853 }
1854 }
1855 else
1856 {
1857 drprintf(("VBoxVideoWddm: pfnCreateNewPathInfo failed Status(0x%x)\n"));
1858 }
1859 }
1860 else
1861 {
1862 drprintf(("VBoxVideoWddm: pfnGetTopology failed Status(0x%x)\n"));
1863 }
1864 }
1865 else
1866 {
1867 drprintf(("VBoxVideoWddm: DxgkCbQueryVidPnInterface failed Status(0x%x)\n"));
1868 }
1869
1870 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1871
1872 return Status;
1873}
1874
1875NTSTATUS
1876APIENTRY
1877DxgkDdiEnumVidPnCofuncModality(
1878 CONST HANDLE hAdapter,
1879 CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModalityArg
1880 )
1881{
1882 /* The DxgkDdiEnumVidPnCofuncModality function should be made pageable. */
1883 PAGED_CODE();
1884
1885 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1886
1887 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1888
1889 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
1890 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pEnumCofuncModalityArg->hConstrainingVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
1891 if (Status == STATUS_SUCCESS)
1892 {
1893 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1894 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1895 NTSTATUS Status = pVidPnInterface->pfnGetTopology(pEnumCofuncModalityArg->hConstrainingVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1896 Assert(Status == STATUS_SUCCESS);
1897 if (Status == STATUS_SUCCESS)
1898 {
1899 VBOXVIDPNCOFUNCMODALITY CbContext = {0};
1900 CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg;
1901 VBoxWddmGetModesTable(pContext, /* PDEVICE_EXTENSION DeviceExtension */
1902 true, /* bool bRebuildTable*/
1903 &CbContext.pModes, /* VIDEO_MODE_INFORMATION ** ppModes*/
1904 &CbContext.cModes, /* uint32_t * pcModes */
1905 &CbContext.iPreferredMode, /* uint32_t * pPreferrableMode*/
1906 &CbContext.pResolutions, /* D3DKMDT_2DREGION **ppResolutions */
1907 &CbContext.cResolutions /* uint32_t * pcResolutions */);
1908 Assert(CbContext.cModes);
1909 Assert(CbContext.cModes > CbContext.iPreferredMode);
1910 Status = vboxVidPnEnumPaths(pContext, pEnumCofuncModalityArg->hConstrainingVidPn, pVidPnInterface,
1911 hVidPnTopology, pVidPnTopologyInterface,
1912 vboxVidPnCofuncModalityPathEnum, &CbContext);
1913 Assert(Status == STATUS_SUCCESS);
1914 if (Status == STATUS_SUCCESS)
1915 {
1916 Status = CbContext.Status;
1917 Assert(Status == STATUS_SUCCESS);
1918 if (Status != STATUS_SUCCESS)
1919 drprintf((__FUNCTION__ ": vboxVidPnAdjustSourcesTargetsCallback failed Status(0x%x)\n", Status));
1920 }
1921 else
1922 drprintf((__FUNCTION__ ": vboxVidPnEnumPaths failed Status(0x%x)\n", Status));
1923 }
1924 else
1925 drprintf((__FUNCTION__ ": pfnGetTopology failed Status(0x%x)\n", Status));
1926 }
1927 else
1928 drprintf((__FUNCTION__ ": DxgkCbQueryVidPnInterface failed Status(0x%x)\n", Status));
1929
1930 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1931
1932 return STATUS_NOT_IMPLEMENTED;
1933}
1934
1935NTSTATUS
1936APIENTRY
1937DxgkDdiSetVidPnSourceAddress(
1938 CONST HANDLE hAdapter,
1939 CONST DXGKARG_SETVIDPNSOURCEADDRESS* pSetVidPnSourceAddress
1940 )
1941{
1942 return STATUS_NOT_IMPLEMENTED;
1943}
1944
1945NTSTATUS
1946APIENTRY
1947DxgkDdiSetVidPnSourceVisibility(
1948 CONST HANDLE hAdapter,
1949 CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility
1950 )
1951{
1952 return STATUS_NOT_IMPLEMENTED;
1953}
1954
1955NTSTATUS
1956APIENTRY
1957DxgkDdiCommitVidPn(
1958 CONST HANDLE hAdapter,
1959 CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPnArg
1960 )
1961{
1962 return STATUS_NOT_IMPLEMENTED;
1963}
1964
1965NTSTATUS
1966APIENTRY
1967DxgkDdiUpdateActiveVidPnPresentPath(
1968 CONST HANDLE hAdapter,
1969 CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPathArg
1970 )
1971{
1972 return STATUS_NOT_IMPLEMENTED;
1973}
1974
1975NTSTATUS
1976APIENTRY
1977DxgkDdiRecommendMonitorModes(
1978 CONST HANDLE hAdapter,
1979 CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModesArg
1980 )
1981{
1982 return STATUS_NOT_IMPLEMENTED;
1983}
1984
1985NTSTATUS
1986APIENTRY
1987DxgkDdiRecommendVidPnTopology(
1988 CONST HANDLE hAdapter,
1989 CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopologyArg
1990 )
1991{
1992 return STATUS_NOT_IMPLEMENTED;
1993}
1994
1995NTSTATUS
1996APIENTRY
1997DxgkDdiGetScanLine(
1998 CONST HANDLE hAdapter,
1999 DXGKARG_GETSCANLINE* pGetScanLine)
2000{
2001 return STATUS_NOT_IMPLEMENTED;
2002}
2003
2004NTSTATUS
2005APIENTRY
2006DxgkDdiStopCapture(
2007 CONST HANDLE hAdapter,
2008 CONST DXGKARG_STOPCAPTURE* pStopCapture)
2009{
2010 return STATUS_NOT_IMPLEMENTED;
2011}
2012
2013NTSTATUS
2014APIENTRY
2015DxgkDdiControlInterrupt(
2016 CONST HANDLE hAdapter,
2017 CONST DXGK_INTERRUPT_TYPE InterruptType,
2018 BOOLEAN Enable
2019 )
2020{
2021 return STATUS_NOT_IMPLEMENTED;
2022}
2023
2024NTSTATUS
2025APIENTRY
2026DxgkDdiCreateOverlay(
2027 CONST HANDLE hAdapter,
2028 DXGKARG_CREATEOVERLAY *pCreateOverlay)
2029{
2030 return STATUS_NOT_IMPLEMENTED;
2031}
2032
2033NTSTATUS
2034APIENTRY
2035DxgkDdiDestroyDevice(
2036 CONST HANDLE hDevice)
2037{
2038 /* DxgkDdiDestroyDevice should be made pageable. */
2039 PAGED_CODE();
2040
2041 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2042
2043 vboxWddmMemFree(hDevice);
2044
2045 dfprintf(("<== "__FUNCTION__ ", \n"));
2046
2047 return STATUS_UNSUCCESSFUL;
2048}
2049
2050NTSTATUS
2051APIENTRY
2052DxgkDdiOpenAllocation(
2053 CONST HANDLE hDevice,
2054 CONST DXGKARG_OPENALLOCATION *pOpenAllocation)
2055{
2056 return STATUS_NOT_IMPLEMENTED;
2057}
2058
2059NTSTATUS
2060APIENTRY
2061DxgkDdiCloseAllocation(
2062 CONST HANDLE hDevice,
2063 CONST DXGKARG_CLOSEALLOCATION* pCloseAllocation)
2064{
2065 return STATUS_NOT_IMPLEMENTED;
2066}
2067
2068NTSTATUS
2069APIENTRY
2070DxgkDdiRender(
2071 CONST HANDLE hContext,
2072 DXGKARG_RENDER *pRender)
2073{
2074 return STATUS_NOT_IMPLEMENTED;
2075}
2076
2077NTSTATUS
2078APIENTRY
2079DxgkDdiPresent(
2080 CONST HANDLE hContext,
2081 DXGKARG_PRESENT *pPresent)
2082{
2083 return STATUS_NOT_IMPLEMENTED;
2084}
2085
2086NTSTATUS
2087APIENTRY
2088DxgkDdiUpdateOverlay(
2089 CONST HANDLE hOverlay,
2090 CONST DXGKARG_UPDATEOVERLAY *pUpdateOverlay)
2091{
2092 return STATUS_NOT_IMPLEMENTED;
2093}
2094
2095NTSTATUS
2096APIENTRY
2097DxgkDdiFlipOverlay(
2098 CONST HANDLE hOverlay,
2099 CONST DXGKARG_FLIPOVERLAY *pFlipOverlay)
2100{
2101 return STATUS_NOT_IMPLEMENTED;
2102}
2103
2104NTSTATUS
2105APIENTRY
2106DxgkDdiDestroyOverlay(
2107 CONST HANDLE hOverlay)
2108{
2109 return STATUS_NOT_IMPLEMENTED;
2110}
2111
2112NTSTATUS
2113APIENTRY
2114DxgkDdiCreateContext(
2115 CONST HANDLE hDevice,
2116 DXGKARG_CREATECONTEXT *pCreateContext)
2117{
2118 return STATUS_NOT_IMPLEMENTED;
2119}
2120
2121NTSTATUS
2122APIENTRY
2123DxgkDdiDestroyContext(
2124 CONST HANDLE hContext)
2125{
2126 return STATUS_NOT_IMPLEMENTED;
2127}
2128
2129NTSTATUS
2130APIENTRY
2131DxgkDdiLinkDevice(
2132 __in CONST PDEVICE_OBJECT PhysicalDeviceObject,
2133 __in CONST PVOID MiniportDeviceContext,
2134 __inout PLINKED_DEVICE LinkedDevice
2135 )
2136{
2137 return STATUS_NOT_IMPLEMENTED;
2138}
2139
2140NTSTATUS
2141APIENTRY
2142DxgkDdiSetDisplayPrivateDriverFormat(
2143 CONST HANDLE hAdapter,
2144 /*CONST*/ DXGKARG_SETDISPLAYPRIVATEDRIVERFORMAT* pSetDisplayPrivateDriverFormat
2145 )
2146{
2147 return STATUS_NOT_IMPLEMENTED;
2148}
2149
2150NTSTATUS
2151DriverEntry(
2152 IN PDRIVER_OBJECT DriverObject,
2153 IN PUNICODE_STRING RegistryPath
2154 )
2155{
2156 dprintf(("VBoxVideoWddm::DriverEntry. Built %s %s\n", __DATE__, __TIME__));
2157
2158 DRIVER_INITIALIZATION_DATA DriverInitializationData = {'\0'};
2159
2160 PAGED_CODE();
2161
2162 if (! ARGUMENT_PRESENT(DriverObject) ||
2163 ! ARGUMENT_PRESENT(RegistryPath))
2164 {
2165 return STATUS_INVALID_PARAMETER;
2166 }
2167
2168 // Fill in the DriverInitializationData structure and call DxgkInitialize()
2169 DriverInitializationData.Version = DXGKDDI_INTERFACE_VERSION;
2170
2171 DriverInitializationData.DxgkDdiAddDevice = DxgkDdiAddDevice;
2172 DriverInitializationData.DxgkDdiStartDevice = DxgkDdiStartDevice;
2173 DriverInitializationData.DxgkDdiStopDevice = DxgkDdiStopDevice;
2174 DriverInitializationData.DxgkDdiRemoveDevice = DxgkDdiRemoveDevice;
2175 DriverInitializationData.DxgkDdiDispatchIoRequest = DxgkDdiDispatchIoRequest;
2176 DriverInitializationData.DxgkDdiInterruptRoutine = DxgkDdiInterruptRoutine;
2177 DriverInitializationData.DxgkDdiDpcRoutine = DxgkDdiDpcRoutine;
2178 DriverInitializationData.DxgkDdiQueryChildRelations = DxgkDdiQueryChildRelations;
2179 DriverInitializationData.DxgkDdiQueryChildStatus = DxgkDdiQueryChildStatus;
2180 DriverInitializationData.DxgkDdiQueryDeviceDescriptor = DxgkDdiQueryDeviceDescriptor;
2181 DriverInitializationData.DxgkDdiSetPowerState = DxgkDdiSetPowerState;
2182 DriverInitializationData.DxgkDdiNotifyAcpiEvent = DxgkDdiNotifyAcpiEvent;
2183 DriverInitializationData.DxgkDdiResetDevice = DxgkDdiResetDevice;
2184 DriverInitializationData.DxgkDdiUnload = DxgkDdiUnload;
2185 DriverInitializationData.DxgkDdiQueryInterface = DxgkDdiQueryInterface;
2186 DriverInitializationData.DxgkDdiControlEtwLogging = DxgkDdiControlEtwLogging;
2187
2188 DriverInitializationData.DxgkDdiQueryAdapterInfo = DxgkDdiQueryAdapterInfo;
2189 DriverInitializationData.DxgkDdiCreateDevice = DxgkDdiCreateDevice;
2190 DriverInitializationData.DxgkDdiCreateAllocation = DxgkDdiCreateAllocation;
2191 DriverInitializationData.DxgkDdiDestroyAllocation = DxgkDdiDestroyAllocation ;
2192
2193 DriverInitializationData.DxgkDdiDescribeAllocation = DxgkDdiDescribeAllocation;
2194 DriverInitializationData.DxgkDdiGetStandardAllocationDriverData = DxgkDdiGetStandardAllocationDriverData;
2195
2196 DriverInitializationData.DxgkDdiAcquireSwizzlingRange = DxgkDdiAcquireSwizzlingRange;
2197 DriverInitializationData.DxgkDdiReleaseSwizzlingRange = DxgkDdiReleaseSwizzlingRange;
2198
2199 DriverInitializationData.DxgkDdiPatch = DxgkDdiPatch;
2200
2201 DriverInitializationData.DxgkDdiSubmitCommand = DxgkDdiSubmitCommand;
2202 DriverInitializationData.DxgkDdiPreemptCommand = DxgkDdiPreemptCommand;
2203 DriverInitializationData.DxgkDdiBuildPagingBuffer = DxgkDdiBuildPagingBuffer;
2204
2205 DriverInitializationData.DxgkDdiSetPalette = DxgkDdiSetPalette;
2206 DriverInitializationData.DxgkDdiSetPointerPosition = DxgkDdiSetPointerPosition;
2207 DriverInitializationData.DxgkDdiSetPointerShape = DxgkDdiSetPointerShape;
2208
2209 DriverInitializationData.DxgkDdiResetFromTimeout = DxgkDdiResetFromTimeout;
2210
2211 DriverInitializationData.DxgkDdiEscape = DxgkDdiEscape;
2212
2213 DriverInitializationData.DxgkDdiCollectDbgInfo = DxgkDdiCollectDbgInfo;
2214
2215 DriverInitializationData.DxgkDdiQueryCurrentFence = DxgkDdiQueryCurrentFence;
2216
2217 DriverInitializationData.DxgkDdiIsSupportedVidPn = DxgkDdiIsSupportedVidPn;
2218 DriverInitializationData.DxgkDdiRecommendFunctionalVidPn = DxgkDdiRecommendFunctionalVidPn;
2219 DriverInitializationData.DxgkDdiEnumVidPnCofuncModality = DxgkDdiEnumVidPnCofuncModality;
2220 DriverInitializationData.DxgkDdiSetVidPnSourceAddress = DxgkDdiSetVidPnSourceAddress;
2221 DriverInitializationData.DxgkDdiSetVidPnSourceVisibility = DxgkDdiSetVidPnSourceVisibility;
2222 DriverInitializationData.DxgkDdiCommitVidPn = DxgkDdiCommitVidPn;
2223 DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = DxgkDdiUpdateActiveVidPnPresentPath;
2224
2225 DriverInitializationData.DxgkDdiRecommendMonitorModes = DxgkDdiRecommendMonitorModes;
2226 DriverInitializationData.DxgkDdiRecommendVidPnTopology = DxgkDdiRecommendVidPnTopology;
2227
2228 DriverInitializationData.DxgkDdiGetScanLine = DxgkDdiGetScanLine;
2229
2230 DriverInitializationData.DxgkDdiStopCapture = DxgkDdiStopCapture;
2231
2232 DriverInitializationData.DxgkDdiControlInterrupt = DxgkDdiControlInterrupt;
2233
2234 DriverInitializationData.DxgkDdiCreateOverlay = DxgkDdiCreateOverlay;
2235
2236 DriverInitializationData.DxgkDdiDestroyDevice = DxgkDdiDestroyDevice;
2237
2238 DriverInitializationData.DxgkDdiOpenAllocation = DxgkDdiOpenAllocation;
2239 DriverInitializationData.DxgkDdiCloseAllocation = DxgkDdiCloseAllocation;
2240
2241 DriverInitializationData.DxgkDdiRender = DxgkDdiRender;
2242 DriverInitializationData.DxgkDdiPresent = DxgkDdiPresent;
2243
2244 DriverInitializationData.DxgkDdiUpdateOverlay = DxgkDdiUpdateOverlay;
2245 DriverInitializationData.DxgkDdiFlipOverlay = DxgkDdiFlipOverlay;
2246 DriverInitializationData.DxgkDdiDestroyOverlay = DxgkDdiDestroyOverlay;
2247
2248 DriverInitializationData.DxgkDdiCreateContext = DxgkDdiCreateContext;
2249 DriverInitializationData.DxgkDdiDestroyContext = DxgkDdiDestroyContext;
2250
2251 DriverInitializationData.DxgkDdiLinkDevice = DxgkDdiLinkDevice;
2252 DriverInitializationData.DxgkDdiSetDisplayPrivateDriverFormat = DxgkDdiSetDisplayPrivateDriverFormat;
2253
2254//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
2255// DriverInitializationData.DxgkDdiRenderKm = D3DDDIRenderKm;
2256// DriverInitializationData.DxgkDdiRestartFromTimeout = D3DDDIRestartFromTimeout;
2257// DriverInitializationData.DxgkDdiSetVidPnSourceVisibility = DxgkDdiSetVidPnSourceVisibility;
2258// DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = D3DDDIUpdateActiveVidPnPresentPath;
2259// DriverInitializationData.DxgkDdiQueryVidPnHWCapability = D3DDDI DxgkDdiQueryVidPnHWCapability;
2260//#endif
2261
2262 return DxgkInitialize(DriverObject,
2263 RegistryPath,
2264 &DriverInitializationData);
2265}
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