VirtualBox

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

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

wddm: make DispD3D inclusion customizable

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 113.7 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//VBOXVIDEOOFFSET vboxWddmVRAMAddressToOffset(PDEVICE_EXTENSION pDevExt, PHYSICAL_ADDRESS phAddress)
50//{
51// Assert(phAddress.QuadPart >= VBE_DISPI_LFB_PHYSICAL_ADDRESS);
52// if (phAddress.QuadPart < VBE_DISPI_LFB_PHYSICAL_ADDRESS)
53// return VBOXVIDEOOFFSET_VOID;
54//
55// VBOXVIDEOOFFSET off = phAddress.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS;
56// Assert(off < pDevExt->u.primary.cbVRAM);
57// if (off >= pDevExt->u.primary.cbVRAM)
58// return VBOXVIDEOOFFSET_VOID;
59//
60// return off;
61//}
62
63VBOXVIDEOOFFSET vboxWddmValidatePrimary(PVBOXWDDM_ALLOCATION pAllocation)
64{
65 Assert(pAllocation);
66 if (!pAllocation)
67 {
68 drprintf((__FUNCTION__": no allocation specified for Source\n"));
69 return VBOXVIDEOOFFSET_VOID;
70 }
71
72 Assert(pAllocation->SegmentId);
73 if (!pAllocation->SegmentId)
74 {
75 drprintf((__FUNCTION__": allocation is not paged in\n"));
76 return VBOXVIDEOOFFSET_VOID;
77 }
78
79 VBOXVIDEOOFFSET offVram = pAllocation->offVram;
80 Assert(offVram != VBOXVIDEOOFFSET_VOID);
81 if (offVram == VBOXVIDEOOFFSET_VOID)
82 drprintf((__FUNCTION__": VRAM pffset is not defined\n"));
83
84 return offVram;
85}
86
87NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
88{
89 VBOXVIDEOOFFSET offVram = pAllocation->offVram;
90 Assert(offVram != VBOXVIDEOOFFSET_VOID);
91 if (offVram == VBOXVIDEOOFFSET_VOID)
92 return STATUS_INVALID_PARAMETER;
93
94 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
95 /* Issue the screen info command. */
96 void *p = vboxHGSMIBufferAlloc (pDevExt,
97 sizeof (VBVAINFOSCREEN),
98 HGSMI_CH_VBVA,
99 VBVA_INFO_SCREEN);
100 Assert(p);
101 if (p)
102 {
103 VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
104
105 pScreen->u32ViewIndex = pPrimaryInfo->VidPnSourceId;
106 pScreen->i32OriginX = 0;
107 pScreen->i32OriginY = 0;
108 pScreen->u32StartOffset = offVram;
109 pScreen->u32LineSize = pAllocation->u.SurfInfo.pitch;
110 pScreen->u32Width = pAllocation->u.SurfInfo.width;
111 pScreen->u32Height = pAllocation->u.SurfInfo.height;
112 pScreen->u16BitsPerPixel = (uint16_t)pAllocation->u.SurfInfo.bpp;
113 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE;
114
115 vboxHGSMIBufferSubmit (pDevExt, p);
116
117 vboxHGSMIBufferFree (pDevExt, p);
118 }
119
120 return STATUS_SUCCESS;
121}
122
123NTSTATUS vboxWddmGhDisplayPostInfoView (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
124{
125 VBOXVIDEOOFFSET offVram = pAllocation->offVram;
126 Assert(offVram != VBOXVIDEOOFFSET_VOID);
127 if (offVram == VBOXVIDEOOFFSET_VOID)
128 return STATUS_INVALID_PARAMETER;
129
130 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
131 /* Issue the screen info command. */
132 void *p = vboxHGSMIBufferAlloc (pDevExt,
133 sizeof (VBVAINFOVIEW),
134 HGSMI_CH_VBVA,
135 VBVA_INFO_VIEW);
136 Assert(p);
137 if (p)
138 {
139 VBVAINFOVIEW *pView = (VBVAINFOVIEW *)p;
140
141 pView->u32ViewIndex = pPrimaryInfo->VidPnSourceId;
142 pView->u32ViewOffset = offVram;
143 pView->u32ViewSize = vboxWddmVramReportedSize(pDevExt)/pDevExt->cSources;
144
145 pView->u32MaxScreenSize = pView->u32ViewSize;
146
147 vboxHGSMIBufferSubmit (pDevExt, p);
148
149 vboxHGSMIBufferFree (pDevExt, p);
150 }
151
152 return STATUS_SUCCESS;
153}
154
155NTSTATUS vboxWddmGhDisplaySetMode (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
156{
157 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
158 if (pPrimaryInfo->VidPnSourceId)
159 return STATUS_SUCCESS;
160
161 if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->u.SurfInfo.width,
162 pAllocation->u.SurfInfo.height, pAllocation->u.SurfInfo.bpp))
163 return STATUS_SUCCESS;
164
165 AssertBreakpoint();
166 drprintf((__FUNCTION__": VBoxVideoSetCurrentModePerform failed\n"));
167 return STATUS_UNSUCCESSFUL;
168}
169
170
171NTSTATUS vboxWddmGhDisplaySetInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource)
172{
173 PVBOXWDDM_ALLOCATION pAllocation = pSource->pAllocation;
174 VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation);
175 Assert(offVram != VBOXVIDEOOFFSET_VOID);
176 if (offVram == VBOXVIDEOOFFSET_VOID)
177 return STATUS_INVALID_PARAMETER;
178
179 /*
180 * Set the current mode into the hardware.
181 */
182 NTSTATUS Status = vboxWddmGhDisplaySetMode (pDevExt, pAllocation);
183 Assert(Status == STATUS_SUCCESS);
184 if (Status == STATUS_SUCCESS)
185 {
186 Status = vboxWddmGhDisplayPostInfoView (pDevExt, pAllocation);
187 Assert(Status == STATUS_SUCCESS);
188 if (Status == STATUS_SUCCESS)
189 {
190 Status = vboxWddmGhDisplayPostInfoScreen (pDevExt, pAllocation);
191 Assert(Status == STATUS_SUCCESS);
192 if (Status != STATUS_SUCCESS)
193 drprintf((__FUNCTION__": vboxWddmGhDisplayPostInfoScreen failed\n"));
194 }
195 else
196 drprintf((__FUNCTION__": vboxWddmGhDisplayPostInfoView failed\n"));
197 }
198 else
199 drprintf((__FUNCTION__": vboxWddmGhDisplaySetMode failed\n"));
200
201 return Status;
202}
203
204HGSMIHEAP* vboxWddmHgsmiGetHeapFromCmdOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
205{
206 if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
207 return &pDevExt->u.primary.Vdma.CmdHeap;
208 if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
209 return &pDevExt->u.primary.hgsmiAdapterHeap;
210 return NULL;
211}
212
213typedef enum
214{
215 VBOXWDDM_HGSMICMD_TYPE_UNDEFINED = 0,
216 VBOXWDDM_HGSMICMD_TYPE_CTL = 1,
217 VBOXWDDM_HGSMICMD_TYPE_DMACMD = 2
218} VBOXWDDM_HGSMICMD_TYPE;
219
220VBOXWDDM_HGSMICMD_TYPE vboxWddmHgsmiGetCmdTypeFromOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
221{
222 if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
223 return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
224 if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
225 return VBOXWDDM_HGSMICMD_TYPE_CTL;
226 return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
227}
228
229
230#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
231
232NTSTATUS vboxWddmRegQueryDrvKeyName(PDEVICE_EXTENSION pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult)
233{
234 WCHAR fallBackBuf[2];
235 PWCHAR pSuffix;
236 bool bFallback = false;
237
238 if (cbBuf > sizeof(VBOXWDDM_REG_DRVKEY_PREFIX))
239 {
240 wcscpy(pBuf, VBOXWDDM_REG_DRVKEY_PREFIX);
241 pSuffix = pBuf + (sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2);
242 cbBuf -= sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2;
243 }
244 else
245 {
246 pSuffix = fallBackBuf;
247 cbBuf = sizeof (fallBackBuf);
248 bFallback = true;
249 }
250
251 NTSTATUS Status = IoGetDeviceProperty (pDevExt->pPDO,
252 DevicePropertyDriverKeyName,
253 cbBuf,
254 pSuffix,
255 &cbBuf);
256 if (Status == STATUS_SUCCESS && bFallback)
257 Status = STATUS_BUFFER_TOO_SMALL;
258 if (Status == STATUS_BUFFER_TOO_SMALL)
259 *pcbResult = cbBuf + sizeof (VBOXWDDM_REG_DRVKEY_PREFIX)-2;
260
261 return Status;
262}
263
264NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess)
265{
266 OBJECT_ATTRIBUTES ObjAttr;
267 UNICODE_STRING RtlStr;
268 RtlStr.Buffer = pName;
269 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
270 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
271
272 InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE, NULL, NULL);
273
274 return ZwOpenKey(phKey, fAccess, &ObjAttr);
275}
276
277NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword)
278{
279 UCHAR Buf[32]; /* should be enough */
280 ULONG cbBuf;
281 PKEY_VALUE_PARTIAL_INFORMATION pInfo = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
282 UNICODE_STRING RtlStr;
283 RtlStr.Buffer = pName;
284 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
285 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
286 NTSTATUS Status = ZwQueryValueKey(hKey,
287 &RtlStr,
288 KeyValuePartialInformation,
289 pInfo,
290 sizeof(Buf),
291 &cbBuf);
292 if (Status == STATUS_SUCCESS)
293 {
294 if (pInfo->Type == REG_DWORD)
295 {
296 Assert(pInfo->DataLength == 4);
297 *pDword = *((PULONG)pInfo->Data);
298 return STATUS_SUCCESS;
299 }
300 }
301
302 return STATUS_INVALID_PARAMETER;
303}
304
305NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT DWORD val)
306{
307 UCHAR Buf[32]; /* should be enough */
308 PKEY_VALUE_PARTIAL_INFORMATION pInfo = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
309 UNICODE_STRING RtlStr;
310 RtlStr.Buffer = pName;
311 RtlStr.Length = USHORT(wcslen(pName) * sizeof(WCHAR));
312 RtlStr.MaximumLength = RtlStr.Length + sizeof(WCHAR);
313 return ZwSetValueKey(hKey, &RtlStr,
314 NULL, /* IN ULONG TitleIndex OPTIONAL, reserved */
315 REG_DWORD,
316 &val,
317 sizeof(val));
318}
319
320VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)
321{
322 if(!Reg)
323 return ERROR_INVALID_PARAMETER;
324 NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);
325 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
326}
327
328VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)
329{
330 if(!Reg)
331 return ERROR_INVALID_PARAMETER;
332 NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);
333 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
334}
335
336VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
337{
338 WCHAR Buf[512];
339 ULONG cbBuf = sizeof(Buf);
340 NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf);
341 Assert(Status == STATUS_SUCCESS);
342 if (Status == STATUS_SUCCESS)
343 {
344 Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);
345 Assert(Status == STATUS_SUCCESS);
346 if(Status == STATUS_SUCCESS)
347 return NO_ERROR;
348 }
349
350 /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly
351 * basically needed to make as less modifications to the current XPDM code as possible */
352 *pReg = NULL;
353
354 return ERROR_INVALID_PARAMETER;
355}
356
357UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
358{
359 switch (format)
360 {
361 case D3DDDIFMT_R8G8B8:
362 return 24;
363 case D3DDDIFMT_A8R8G8B8:
364 case D3DDDIFMT_X8R8G8B8:
365 return 32;
366 case D3DDDIFMT_R5G6B5:
367 case D3DDDIFMT_X1R5G5B5:
368 case D3DDDIFMT_A1R5G5B5:
369 case D3DDDIFMT_A4R4G4B4:
370 return 16;
371 case D3DDDIFMT_R3G3B2:
372 case D3DDDIFMT_A8:
373 return 8;
374 case D3DDDIFMT_A8R3G3B2:
375 case D3DDDIFMT_X4R4G4B4:
376 return 16;
377 case D3DDDIFMT_A2B10G10R10:
378 case D3DDDIFMT_A8B8G8R8:
379 case D3DDDIFMT_X8B8G8R8:
380 case D3DDDIFMT_G16R16:
381 case D3DDDIFMT_A2R10G10B10:
382 return 32;
383 case D3DDDIFMT_A16B16G16R16:
384 return 64;
385 default:
386 AssertBreakpoint();
387 return 0;
388 }
389}
390
391D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo)
392{
393 switch (pInfo->BitsPerPlane)
394 {
395 case 32:
396 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
397 {
398 if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
399 return D3DDDIFMT_X8R8G8B8;
400 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
401 AssertBreakpoint();
402 }
403 else
404 {
405 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
406 AssertBreakpoint();
407 }
408 break;
409 case 24:
410 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
411 {
412 if (pInfo->RedMask == 0xFF0000 && pInfo->GreenMask == 0xFF00 && pInfo->BlueMask == 0xFF)
413 return D3DDDIFMT_R8G8B8;
414 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
415 AssertBreakpoint();
416 }
417 else
418 {
419 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
420 AssertBreakpoint();
421 }
422 break;
423 case 16:
424 if(!(pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && !(pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
425 {
426 if (pInfo->RedMask == 0xF800 && pInfo->GreenMask == 0x7E0 && pInfo->BlueMask == 0x1F)
427 return D3DDDIFMT_R5G6B5;
428 drprintf((__FUNCTION__": unsupported format: bpp(%d), rmask(%d), gmask(%d), bmask(%d)\n", pInfo->BitsPerPlane, pInfo->RedMask, pInfo->GreenMask, pInfo->BlueMask));
429 AssertBreakpoint();
430 }
431 else
432 {
433 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
434 AssertBreakpoint();
435 }
436 break;
437 case 8:
438 if((pInfo->AttributeFlags & VIDEO_MODE_PALETTE_DRIVEN) && (pInfo->AttributeFlags & VIDEO_MODE_MANAGED_PALETTE))
439 {
440 return D3DDDIFMT_P8;
441 }
442 else
443 {
444 drprintf((__FUNCTION__": unsupported AttributeFlags(0x%x)\n", pInfo->AttributeFlags));
445 AssertBreakpoint();
446 }
447 break;
448 default:
449 drprintf((__FUNCTION__": unsupported bpp(%d)\n", pInfo->BitsPerPlane));
450 AssertBreakpoint();
451 break;
452 }
453
454 return D3DDDIFMT_UNKNOWN;
455}
456
457UINT vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
458{
459 UINT Pitch = bitsPerPixel * w;
460 /* pitch is now in bits, translate in bytes */
461 if(Pitch & 7)
462 Pitch = (Pitch >> 3) + 1;
463 else
464 Pitch = (Pitch >> 3);
465
466 return Pitch;
467}
468
469NTSTATUS vboxWddmPickResources(PDEVICE_EXTENSION pContext, PDXGK_DEVICE_INFO pDeviceInfo, PULONG pAdapterMemorySize)
470{
471 NTSTATUS Status = STATUS_SUCCESS;
472 USHORT DispiId;
473 *pAdapterMemorySize = VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES;
474
475 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
476 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);
477 DispiId = VBoxVideoCmnPortReadUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
478 if (DispiId == VBE_DISPI_ID2)
479 {
480 dprintf(("VBoxVideoWddm: found the VBE card\n"));
481 /*
482 * Write some hardware information to registry, so that
483 * it's visible in Windows property dialog.
484 */
485
486 /*
487 * Query the adapter's memory size. It's a bit of a hack, we just read
488 * an ULONG from the data port without setting an index before.
489 */
490 *pAdapterMemorySize = VBoxVideoCmnPortReadUlong((PULONG)VBE_DISPI_IOPORT_DATA);
491 if (VBoxHGSMIIsSupported (pContext))
492 {
493 pContext->u.primary.IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
494 pContext->u.primary.IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
495
496 PCM_RESOURCE_LIST pRcList = pDeviceInfo->TranslatedResourceList;
497 /* @todo: verify resources */
498 for (ULONG i = 0; i < pRcList->Count; ++i)
499 {
500 PCM_FULL_RESOURCE_DESCRIPTOR pFRc = &pRcList->List[i];
501 for (ULONG j = 0; j < pFRc->PartialResourceList.Count; ++j)
502 {
503 PCM_PARTIAL_RESOURCE_DESCRIPTOR pPRc = &pFRc->PartialResourceList.PartialDescriptors[j];
504 switch (pPRc->Type)
505 {
506 case CmResourceTypePort:
507 break;
508 case CmResourceTypeInterrupt:
509 break;
510 case CmResourceTypeMemory:
511 break;
512 case CmResourceTypeDma:
513 break;
514 case CmResourceTypeDeviceSpecific:
515 break;
516 case CmResourceTypeBusNumber:
517 break;
518 default:
519 break;
520 }
521 }
522 }
523 }
524 else
525 {
526 drprintf(("VBoxVideoWddm: HGSMI unsupported, returning err\n"));
527 /* @todo: report a better status */
528 Status = STATUS_UNSUCCESSFUL;
529 }
530 }
531 else
532 {
533 drprintf(("VBoxVideoWddm:: VBE card not found, returning err\n"));
534 Status = STATUS_UNSUCCESSFUL;
535 }
536
537
538 return Status;
539}
540
541/* driver callbacks */
542
543NTSTATUS DxgkDdiAddDevice(
544 IN CONST PDEVICE_OBJECT PhysicalDeviceObject,
545 OUT PVOID *MiniportDeviceContext
546 )
547{
548 /* The DxgkDdiAddDevice function should be made pageable. */
549 PAGED_CODE();
550
551 dfprintf(("==> "__FUNCTION__ ", pdo(0x%x)\n", PhysicalDeviceObject));
552 NTSTATUS Status = STATUS_SUCCESS;
553
554 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)vboxWddmMemAllocZero(sizeof (DEVICE_EXTENSION));
555 if (pContext)
556 {
557 pContext->pPDO = PhysicalDeviceObject;
558 *MiniportDeviceContext = pContext;
559 }
560 else
561 {
562 Status = STATUS_INSUFFICIENT_RESOURCES;
563 drprintf(("VBoxVideoWddm: ERROR, failed to create context\n"));
564 }
565
566 dfprintf(("<== "__FUNCTION__ ", status(0x%x), pContext(0x%x)\n", Status, pContext));
567
568 return Status;
569}
570
571NTSTATUS DxgkDdiStartDevice(
572 IN CONST PVOID MiniportDeviceContext,
573 IN PDXGK_START_INFO DxgkStartInfo,
574 IN PDXGKRNL_INTERFACE DxgkInterface,
575 OUT PULONG NumberOfVideoPresentSources,
576 OUT PULONG NumberOfChildren
577 )
578{
579 /* The DxgkDdiStartDevice function should be made pageable. */
580 PAGED_CODE();
581
582 NTSTATUS Status;
583
584 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
585
586 if ( ARGUMENT_PRESENT(MiniportDeviceContext) &&
587 ARGUMENT_PRESENT(DxgkInterface) &&
588 ARGUMENT_PRESENT(DxgkStartInfo) &&
589 ARGUMENT_PRESENT(NumberOfVideoPresentSources),
590 ARGUMENT_PRESENT(NumberOfChildren)
591 )
592 {
593 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)MiniportDeviceContext;
594
595 /* Save DeviceHandle and function pointers supplied by the DXGKRNL_INTERFACE structure passed to DxgkInterface. */
596 memcpy(&pContext->u.primary.DxgkInterface, DxgkInterface, sizeof (DXGKRNL_INTERFACE));
597
598 /* 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)
599 * of the DXGK_DEVICE_INFO structure in the context block represented by MiniportDeviceContext. */
600 DXGK_DEVICE_INFO DeviceInfo;
601 Status = pContext->u.primary.DxgkInterface.DxgkCbGetDeviceInformation (pContext->u.primary.DxgkInterface.DeviceHandle, &DeviceInfo);
602 if (Status == STATUS_SUCCESS)
603 {
604 ULONG AdapterMemorySize;
605 Status = vboxWddmPickResources(pContext, &DeviceInfo, &AdapterMemorySize);
606 if (Status == STATUS_SUCCESS)
607 {
608 /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
609 VbglInit ();
610
611 /* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
612 * code will be ifdef'ed and later removed.
613 * The host will however support both old and new interface to keep compatibility
614 * with old guest additions.
615 */
616 VBoxSetupDisplaysHGSMI(pContext, AdapterMemorySize);
617 if ((pContext)->u.primary.bHGSMI)
618 {
619 drprintf(("VBoxVideoWddm: using HGSMI\n"));
620 *NumberOfVideoPresentSources = pContext->cSources;
621 *NumberOfChildren = pContext->cSources;
622 dprintf(("VBoxVideoWddm: sources(%d), children(%d)\n", *NumberOfVideoPresentSources, *NumberOfChildren));
623 }
624 else
625 {
626 drprintf(("VBoxVideoWddm: HGSMI failed to initialize, returning err\n"));
627 /* @todo: report a better status */
628 Status = STATUS_UNSUCCESSFUL;
629 }
630 }
631 else
632 {
633 drprintf(("VBoxVideoWddm:: vboxWddmPickResources failed Status(0x%x), returning err\n", Status));
634 Status = STATUS_UNSUCCESSFUL;
635 }
636 }
637 else
638 {
639 drprintf(("VBoxVideoWddm: DxgkCbGetDeviceInformation failed Status(0x%x), returning err\n", Status));
640 }
641 }
642 else
643 {
644 drprintf(("VBoxVideoWddm: invalid parameter, returning err\n"));
645 Status = STATUS_INVALID_PARAMETER;
646 }
647
648 dfprintf(("<== "__FUNCTION__ ", status(0x%x)\n", Status));
649
650 return Status;
651}
652
653NTSTATUS DxgkDdiStopDevice(
654 IN CONST PVOID MiniportDeviceContext
655 )
656{
657 /* The DxgkDdiStopDevice function should be made pageable. */
658 PAGED_CODE();
659
660 dfprintf(("==> "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
661
662 AssertBreakpoint();
663 /* @todo: fixme: implement */
664
665 dfprintf(("<== "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
666
667 return STATUS_SUCCESS;
668}
669
670NTSTATUS DxgkDdiRemoveDevice(
671 IN CONST PVOID MiniportDeviceContext
672 )
673{
674 /* DxgkDdiRemoveDevice should be made pageable. */
675 PAGED_CODE();
676
677 dfprintf(("==> "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
678
679 vboxWddmMemFree(MiniportDeviceContext);
680
681 dfprintf(("<== "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
682
683 return STATUS_SUCCESS;
684}
685
686NTSTATUS DxgkDdiDispatchIoRequest(
687 IN CONST PVOID MiniportDeviceContext,
688 IN ULONG VidPnSourceId,
689 IN PVIDEO_REQUEST_PACKET VideoRequestPacket
690 )
691{
692 dfprintf(("==> "__FUNCTION__ ", context(0x%p), ctl(0x%x)\n", MiniportDeviceContext, VideoRequestPacket->IoControlCode));
693
694 AssertBreakpoint();
695#if 0
696 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
697
698 switch (VideoRequestPacket->IoControlCode)
699 {
700 case IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES:
701 {
702 if (VideoRequestPacket->OutputBufferLength < sizeof(VIDEO_COLOR_CAPABILITIES))
703 {
704 AssertBreakpoint();
705 VideoRequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
706 return TRUE;
707 }
708 VIDEO_COLOR_CAPABILITIES *pCaps = (VIDEO_COLOR_CAPABILITIES*)VideoRequestPacket->OutputBuffer;
709
710 pCaps->Length = sizeof (VIDEO_COLOR_CAPABILITIES);
711 pCaps->AttributeFlags = VIDEO_DEVICE_COLOR;
712 pCaps->RedPhosphoreDecay = 0;
713 pCaps->GreenPhosphoreDecay = 0;
714 pCaps->BluePhosphoreDecay = 0;
715 pCaps->WhiteChromaticity_x = 3127;
716 pCaps->WhiteChromaticity_y = 3290;
717 pCaps->WhiteChromaticity_Y = 0;
718 pCaps->RedChromaticity_x = 6700;
719 pCaps->RedChromaticity_y = 3300;
720 pCaps->GreenChromaticity_x = 2100;
721 pCaps->GreenChromaticity_y = 7100;
722 pCaps->BlueChromaticity_x = 1400;
723 pCaps->BlueChromaticity_y = 800;
724 pCaps->WhiteGamma = 0;
725 pCaps->RedGamma = 20000;
726 pCaps->GreenGamma = 20000;
727 pCaps->BlueGamma = 20000;
728
729 VideoRequestPacket->StatusBlock->Status = NO_ERROR;
730 VideoRequestPacket->StatusBlock->Information = sizeof (VIDEO_COLOR_CAPABILITIES);
731 break;
732 }
733#if 0
734 case IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS:
735 {
736 if (VideoRequestPacket->OutputBufferLength < sizeof(VIDEOPARAMETERS)
737 || VideoRequestPacket->InputBufferLength < sizeof(VIDEOPARAMETERS))
738 {
739 AssertBreakpoint();
740 VideoRequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
741 return TRUE;
742 }
743
744 Result = VBoxVideoResetDevice((PDEVICE_EXTENSION)HwDeviceExtension,
745 RequestPacket->StatusBlock);
746 break;
747 }
748#endif
749 default:
750 AssertBreakpoint();
751 VideoRequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
752 VideoRequestPacket->StatusBlock->Information = 0;
753 }
754#endif
755 dfprintf(("<== "__FUNCTION__ ", context(0x%p), ctl(0x%x)\n", MiniportDeviceContext, VideoRequestPacket->IoControlCode));
756
757 return STATUS_SUCCESS;
758}
759
760BOOLEAN DxgkDdiInterruptRoutine(
761 IN CONST PVOID MiniportDeviceContext,
762 IN ULONG MessageNumber
763 )
764{
765 dfprintf(("==> "__FUNCTION__ ", context(0x%p), msg(0x%x)\n", MiniportDeviceContext, MessageNumber));
766
767 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
768 BOOLEAN bOur = FALSE;
769 if (pDevExt->u.primary.pHostFlags) /* If HGSMI is enabled at all. */
770 {
771 VBOXSHGSMILIST CtlList;
772 VBOXSHGSMILIST DmaCmdList;
773 vboxSHGSMIListInit(&CtlList);
774 vboxSHGSMIListInit(&DmaCmdList);
775 do
776 {
777 uint32_t flags = pDevExt->u.primary.pHostFlags->u32HostFlags;
778 if (flags & HGSMIHOSTFLAGS_GCOMMAND_COMPLETED)
779 {
780 bOur = TRUE;
781 /* read the command offset */
782 HGSMIOFFSET offCmd = VBoxHGSMIGuestRead(pDevExt);
783 Assert(offCmd != HGSMIOFFSET_VOID);
784 if (offCmd != HGSMIOFFSET_VOID)
785 {
786 VBOXWDDM_HGSMICMD_TYPE enmType = vboxWddmHgsmiGetCmdTypeFromOffset(pDevExt, offCmd);
787 PVBOXSHGSMILIST pList;
788 HGSMIHEAP * pHeap = NULL;
789 switch (enmType)
790 {
791 case VBOXWDDM_HGSMICMD_TYPE_DMACMD:
792 pList = &DmaCmdList;
793 pHeap = &pDevExt->u.primary.Vdma.CmdHeap;
794 break;
795 case VBOXWDDM_HGSMICMD_TYPE_CTL:
796 pList = &CtlList;
797 pHeap = &pDevExt->u.primary.hgsmiAdapterHeap;
798 break;
799 default:
800 AssertBreakpoint();
801 }
802
803 if (pHeap)
804 {
805 int rc = VBoxSHGSMICommandProcessCompletion (pHeap, offCmd, TRUE /*bool bIrq*/ , pList);
806 AssertRC(rc);
807 }
808 }
809 }
810 else if (flags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
811 {
812 bOur = TRUE;
813 AssertBreakpoint();
814 /* @todo: FIXME: implement !!! */
815 }
816 else if (flags & HGSMIHOSTFLAGS_IRQ)
817 {
818 bOur = TRUE;
819 AssertBreakpoint();
820 /* unknown command */
821 }
822 else
823 break;
824 } while (1);
825
826 if (!vboxSHGSMIListIsEmpty(&CtlList))
827 vboxSHGSMIListCat(&pDevExt->CtlList, &CtlList);
828
829 if (!vboxSHGSMIListIsEmpty(&DmaCmdList))
830 vboxSHGSMIListCat(&pDevExt->DmaCmdList, &DmaCmdList);
831
832 if (pDevExt->bSetNotifyDxDpc)
833 {
834 pDevExt->bNotifyDxDpc = TRUE;
835 pDevExt->bSetNotifyDxDpc = FALSE;
836 }
837
838 if (bOur)
839 HGSMIClearIrq (pDevExt);
840 }
841
842 dfprintf(("<== "__FUNCTION__ ", context(0x%p), bOur(0x%x)\n", MiniportDeviceContext, (ULONG)bOur));
843
844 return bOur;
845}
846
847
848typedef struct VBOXWDDM_DPCDATA
849{
850 VBOXSHGSMILIST CtlList;
851 VBOXSHGSMILIST DmaCmdList;
852 BOOL bNotifyDpc;
853} VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA;
854
855typedef struct VBOXWDDM_GETDPCDATA_CONTEXT
856{
857 PDEVICE_EXTENSION pDevExt;
858 VBOXWDDM_DPCDATA data;
859} VBOXWDDM_GETDPCDATA_CONTEXT, *PVBOXWDDM_GETDPCDATA_CONTEXT;
860
861BOOLEAN vboxWddmGetDPCDataCallback(PVOID Context)
862{
863 PVBOXWDDM_GETDPCDATA_CONTEXT pdc = (PVBOXWDDM_GETDPCDATA_CONTEXT)Context;
864
865 vboxSHGSMICmdListDetach2List(&pdc->pDevExt->CtlList, &pdc->data.CtlList);
866 vboxSHGSMICmdListDetach2List(&pdc->pDevExt->DmaCmdList, &pdc->data.DmaCmdList);
867 pdc->data.bNotifyDpc = pdc->pDevExt->bNotifyDxDpc;
868 pdc->pDevExt->bNotifyDxDpc = FALSE;
869 return TRUE;
870}
871
872VOID DxgkDdiDpcRoutine(
873 IN CONST PVOID MiniportDeviceContext
874 )
875{
876 dfprintf(("==> "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
877
878 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
879
880 VBOXWDDM_DPCDATA dpcData = {0};
881 BOOLEAN bRet;
882
883 /* get DPC data at IRQL */
884 NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
885 pDevExt->u.primary.DxgkInterface.DeviceHandle,
886 vboxWddmGetDPCDataCallback,
887 &dpcData,
888 0,
889 &bRet);
890 Assert(Status == STATUS_SUCCESS);
891
892 if (!vboxSHGSMIListIsEmpty(&dpcData.CtlList))
893 {
894 int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.hgsmiAdapterHeap, &dpcData.CtlList);
895 AssertRC(rc);
896 }
897
898 if (!vboxSHGSMIListIsEmpty(&dpcData.DmaCmdList))
899 {
900 int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.Vdma.CmdHeap, &dpcData.DmaCmdList);
901 AssertRC(rc);
902 }
903
904 if (dpcData.bNotifyDpc)
905 pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
906
907 dfprintf(("<== "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext));
908}
909
910NTSTATUS DxgkDdiQueryChildRelations(
911 IN CONST PVOID MiniportDeviceContext,
912 IN OUT PDXGK_CHILD_DESCRIPTOR ChildRelations,
913 IN ULONG ChildRelationsSize
914 )
915{
916 /* The DxgkDdiQueryChildRelations function should be made pageable. */
917 PAGED_CODE();
918
919 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
920
921 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
922 Assert(ChildRelationsSize == (pDevExt->cSources + 1)*sizeof(DXGK_CHILD_DESCRIPTOR));
923 for (UINT i = 0; i < pDevExt->cSources; ++i)
924 {
925 ChildRelations[i].ChildDeviceType = TypeVideoOutput;
926 ChildRelations[i].ChildCapabilities.Type.VideoOutput.InterfaceTechnology = D3DKMDT_VOT_HD15; /* VGA */
927 ChildRelations[i].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_INTERRUPTIBLE; /* ?? D3DKMDT_MOA_NONE*/
928 ChildRelations[i].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = FALSE;
929 ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible; /* ?? HpdAwarenessAlwaysConnected; */
930 ChildRelations[i].AcpiUid = i; /* */
931 ChildRelations[i].ChildUid = i; /* should be == target id */
932 }
933 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
934 return STATUS_SUCCESS;
935}
936
937NTSTATUS DxgkDdiQueryChildStatus(
938 IN CONST PVOID MiniportDeviceContext,
939 IN PDXGK_CHILD_STATUS ChildStatus,
940 IN BOOLEAN NonDestructiveOnly
941 )
942{
943 /* The DxgkDdiQueryChildStatus should be made pageable. */
944 PAGED_CODE();
945
946 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
947
948 NTSTATUS Status = STATUS_SUCCESS;
949 switch (ChildStatus->Type)
950 {
951 case StatusConnection:
952 ChildStatus->HotPlug.Connected = TRUE;
953 dfprintf(("VBoxVideoWddm: StatusConnection\n"));
954 break;
955 case StatusRotation:
956 ChildStatus->Rotation.Angle = 0;
957 dfprintf(("VBoxVideoWddm: StatusRotation\n"));
958 break;
959 default:
960 drprintf(("VBoxVideoWddm: ERROR: status type: %d\n", ChildStatus->Type));
961 Status = STATUS_INVALID_PARAMETER;
962 break;
963 }
964
965 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
966
967 return Status;
968}
969
970NTSTATUS DxgkDdiQueryDeviceDescriptor(
971 IN CONST PVOID MiniportDeviceContext,
972 IN ULONG ChildUid,
973 IN OUT PDXGK_DEVICE_DESCRIPTOR DeviceDescriptor
974 )
975{
976 /* The DxgkDdiQueryDeviceDescriptor should be made pageable. */
977 PAGED_CODE();
978
979 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
980
981 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
982
983 /* we do not support EDID */
984 return STATUS_MONITOR_NO_DESCRIPTOR;
985}
986
987NTSTATUS DxgkDdiSetPowerState(
988 IN CONST PVOID MiniportDeviceContext,
989 IN ULONG DeviceUid,
990 IN DEVICE_POWER_STATE DevicePowerState,
991 IN POWER_ACTION ActionType
992 )
993{
994 /* The DxgkDdiSetPowerState function should be made pageable. */
995 PAGED_CODE();
996
997 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
998
999 /* @todo: */
1000
1001 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
1002
1003 return STATUS_SUCCESS;
1004}
1005
1006NTSTATUS DxgkDdiNotifyAcpiEvent(
1007 IN CONST PVOID MiniportDeviceContext,
1008 IN DXGK_EVENT_TYPE EventType,
1009 IN ULONG Event,
1010 IN PVOID Argument,
1011 OUT PULONG AcpiFlags
1012 )
1013{
1014 dfprintf(("==> "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
1015
1016 AssertBreakpoint();
1017
1018 dfprintf(("<== "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
1019
1020 return STATUS_SUCCESS;
1021}
1022
1023VOID DxgkDdiResetDevice(
1024 IN CONST PVOID MiniportDeviceContext
1025 )
1026{
1027 /* DxgkDdiResetDevice can be called at any IRQL, so it must be in nonpageable memory. */
1028 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
1029 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));
1030}
1031
1032VOID DxgkDdiUnload(
1033 VOID
1034 )
1035{
1036 /* DxgkDdiUnload should be made pageable. */
1037 PAGED_CODE();
1038 dfprintf(("==> "__FUNCTION__ "\n"));
1039
1040 AssertBreakpoint();
1041
1042 dfprintf(("<== "__FUNCTION__ "\n"));
1043}
1044
1045NTSTATUS DxgkDdiQueryInterface(
1046 IN CONST PVOID MiniportDeviceContext,
1047 IN PQUERY_INTERFACE QueryInterface
1048 )
1049{
1050 dfprintf(("==> "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
1051
1052 AssertBreakpoint();
1053
1054 dfprintf(("<== "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
1055
1056 return STATUS_NOT_SUPPORTED;
1057}
1058
1059VOID DxgkDdiControlEtwLogging(
1060 IN BOOLEAN Enable,
1061 IN ULONG Flags,
1062 IN UCHAR Level
1063 )
1064{
1065 dfprintf(("==> "__FUNCTION__ "\n"));
1066
1067 AssertBreakpoint();
1068
1069 dfprintf(("<== "__FUNCTION__ "\n"));
1070}
1071
1072/**
1073 * DxgkDdiQueryAdapterInfo
1074 */
1075NTSTATUS APIENTRY DxgkDdiQueryAdapterInfo(
1076 CONST HANDLE hAdapter,
1077 CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
1078{
1079 /* The DxgkDdiQueryAdapterInfo should be made pageable. */
1080 PAGED_CODE();
1081
1082 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1083 NTSTATUS Status = STATUS_SUCCESS;
1084 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1085
1086 switch (pQueryAdapterInfo->Type)
1087 {
1088 case DXGKQAITYPE_DRIVERCAPS:
1089 {
1090 DXGK_DRIVERCAPS *pCaps = (DXGK_DRIVERCAPS*)pQueryAdapterInfo->pOutputData;
1091
1092 pCaps->HighestAcceptableAddress.HighPart = 0x0;
1093 pCaps->HighestAcceptableAddress.LowPart = 0xffffffffUL;
1094 pCaps->MaxAllocationListSlotId = 16;
1095 pCaps->ApertureSegmentCommitLimit = 0;
1096 pCaps->MaxPointerWidth = 64;
1097 pCaps->MaxPointerHeight = 64;
1098 pCaps->PointerCaps.Value = 3; /* Monochrome , Color*/ /* MaskedColor == Value | 4, dosable for now */
1099 pCaps->InterruptMessageNumber = 0;
1100 pCaps->NumberOfSwizzlingRanges = 0;
1101 /* @todo: need to adjust this for proper 2D Accel support */
1102 pCaps->MaxOverlays = 0; /* ?? how much should we support? 32 */
1103 pCaps->GammaRampCaps.Value = 0;
1104 pCaps->PresentationCaps.Value = 0;
1105 pCaps->PresentationCaps.NoScreenToScreenBlt = 1;
1106 pCaps->PresentationCaps.NoOverlapScreenBlt = 1;
1107 pCaps->MaxQueuedFlipOnVSync = 0; /* do we need it? */
1108 pCaps->FlipCaps.Value = 0;
1109 /* ? pCaps->FlipCaps.FlipOnVSyncWithNoWait = 1; */
1110 pCaps->SchedulingCaps.Value = 0;
1111 /* we might need it for Aero.
1112 * Setting this flag means we support DeviceContext, i.e.
1113 * DxgkDdiCreateContext and DxgkDdiDestroyContext
1114 */
1115 pCaps->SchedulingCaps.MultiEngineAware = 1;
1116 pCaps->MemoryManagementCaps.Value = 0;
1117 /* @todo: this corelates with pCaps->SchedulingCaps.MultiEngineAware */
1118 pCaps->MemoryManagementCaps.PagingNode = 0;
1119 /* @todo: this corelates with pCaps->SchedulingCaps.MultiEngineAware */
1120 pCaps->GpuEngineTopology.NbAsymetricProcessingNodes = 1;
1121
1122 break;
1123 }
1124 case DXGKQAITYPE_QUERYSEGMENT:
1125 {
1126 /* no need for DXGK_QUERYSEGMENTIN as it contains AGP aperture info, which (AGP aperture) we do not support
1127 * DXGK_QUERYSEGMENTIN *pQsIn = (DXGK_QUERYSEGMENTIN*)pQueryAdapterInfo->pInputData; */
1128 DXGK_QUERYSEGMENTOUT *pQsOut = (DXGK_QUERYSEGMENTOUT*)pQueryAdapterInfo->pOutputData;
1129 if (!pQsOut->pSegmentDescriptor)
1130 {
1131 /* we are requested to provide the number of segments we support */
1132 pQsOut->NbSegment = 1;
1133 }
1134 else if (pQsOut->NbSegment != 1)
1135 {
1136 AssertBreakpoint();
1137 drprintf((__FUNCTION__ " NbSegment (%d) != 1\n", pQsOut->NbSegment));
1138 Status = STATUS_INVALID_PARAMETER;
1139 }
1140 else
1141 {
1142 /* we are requested to provide segment information */
1143 pQsOut->pSegmentDescriptor->BaseAddress.QuadPart = 0; /* VBE_DISPI_LFB_PHYSICAL_ADDRESS; */
1144 pQsOut->pSegmentDescriptor->CpuTranslatedAddress.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
1145 /* make sure the size is page aligned */
1146 /* @todo: need to setup VBVA buffers and adjust the mem size here */
1147 pQsOut->pSegmentDescriptor->Size = vboxWddmVramReportedSize(pContext);
1148 pQsOut->pSegmentDescriptor->NbOfBanks = 0;
1149 pQsOut->pSegmentDescriptor->pBankRangeTable = 0;
1150 pQsOut->pSegmentDescriptor->CommitLimit = pQsOut->pSegmentDescriptor->Size;
1151 pQsOut->pSegmentDescriptor->Flags.Value = 0;
1152 pQsOut->pSegmentDescriptor->Flags.CpuVisible = 1;
1153 }
1154 pQsOut->PagingBufferSegmentId = 0;
1155 pQsOut->PagingBufferSize = 1024;
1156 pQsOut->PagingBufferPrivateDataSize = 0; /* @todo: do we need a private buffer ? */
1157 break;
1158 }
1159 case DXGKQAITYPE_UMDRIVERPRIVATE:
1160 drprintf((__FUNCTION__ ": we do not support DXGKQAITYPE_UMDRIVERPRIVATE\n"));
1161 AssertBreakpoint();
1162 Status = STATUS_NOT_SUPPORTED;
1163 break;
1164 default:
1165 drprintf((__FUNCTION__ ": unsupported Type (%d)\n", pQueryAdapterInfo->Type));
1166 AssertBreakpoint();
1167 Status = STATUS_NOT_SUPPORTED;
1168 break;
1169 }
1170 dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status));
1171 return Status;
1172}
1173
1174/**
1175 * DxgkDdiCreateDevice
1176 */
1177NTSTATUS APIENTRY DxgkDdiCreateDevice(
1178 CONST HANDLE hAdapter,
1179 DXGKARG_CREATEDEVICE* pCreateDevice)
1180{
1181 /* DxgkDdiCreateDevice should be made pageable. */
1182 PAGED_CODE();
1183
1184 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1185 NTSTATUS Status = STATUS_SUCCESS;
1186 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1187
1188 PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)vboxWddmMemAllocZero(sizeof (VBOXWDDM_DEVICE));
1189 pCreateDevice->hDevice = pDevice;
1190 if (pCreateDevice->Flags.SystemDevice)
1191 pDevice->enmType = VBOXWDDM_DEVICE_TYPE_SYSTEM;
1192 else
1193 {
1194 AssertBreakpoint(); /* we do not support custom contexts for now */
1195 drprintf((__FUNCTION__ ": we do not support custom devices for now, hAdapter (0x%x)\n", hAdapter));
1196 }
1197
1198 pDevice->pAdapter = pContext;
1199
1200 pCreateDevice->hDevice = pDevice;
1201 pCreateDevice->pInfo = NULL;
1202
1203 dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status));
1204
1205 return Status;
1206}
1207NTSTATUS vboxWddmDestroyAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
1208{
1209 PAGED_CODE();
1210
1211 vboxWddmMemFree(pAllocation);
1212 return STATUS_SUCCESS;
1213}
1214
1215NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONINFO* pAllocationInfo)
1216{
1217 PAGED_CODE();
1218
1219 NTSTATUS Status = STATUS_SUCCESS;
1220
1221 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
1222 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
1223 {
1224 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData;
1225 switch (pAllocInfo->enmType)
1226 {
1227 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE:
1228 {
1229 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE));
1230 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))
1231 {
1232 if (pAllocInfo->u.SurfInfo.bpp != 0)
1233 {
1234 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE));
1235 Assert(pAllocation);
1236 if (pAllocation)
1237 {
1238 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE;
1239 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
1240 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
1241 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1242 pAlloc->RefreshRate = pAllocI->RefreshRate;
1243 pAlloc->VidPnSourceId = pAllocI->VidPnSourceId;
1244// pAlloc->offAddress = VBOXVIDEOOFFSET_VOID;
1245 pAlloc->bVisible = FALSE;
1246
1247 pAllocationInfo->pPrivateDriverData = NULL;
1248 pAllocationInfo->PrivateDriverDataSize = 0;
1249 pAllocationInfo->Alignment = 0;
1250 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
1251 pAllocationInfo->PitchAlignedSize = 0;
1252 pAllocationInfo->HintedBank.Value = 0;
1253 pAllocationInfo->PreferredSegment.Value = 0;
1254 pAllocationInfo->SupportedReadSegmentSet = 1;
1255 pAllocationInfo->SupportedWriteSegmentSet = 1;
1256 pAllocationInfo->EvictionSegmentSet = 0;
1257 pAllocationInfo->MaximumRenamingListLength = 0;
1258 pAllocationInfo->hAllocation = pAllocation;
1259 pAllocationInfo->Flags.Value = 0;
1260 pAllocationInfo->Flags.CpuVisible = 1;
1261 pAllocationInfo->pAllocationUsageHint = NULL;
1262 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
1263 }
1264 else
1265 {
1266 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
1267 Status = STATUS_NO_MEMORY;
1268 }
1269 }
1270 else
1271 {
1272 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format));
1273 Status = STATUS_INVALID_PARAMETER;
1274 }
1275 }
1276 else
1277 {
1278 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)));
1279 Status = STATUS_INVALID_PARAMETER;
1280 }
1281 break;
1282 }
1283 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
1284 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE:
1285 {
1286 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
1287 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
1288 {
1289 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCINFO_HEADSIZE());
1290 Assert(pAllocation);
1291 if (pAllocation)
1292 {
1293 pAllocation->enmType = pAllocInfo->enmType;
1294 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
1295
1296 pAllocationInfo->pPrivateDriverData = NULL;
1297 pAllocationInfo->PrivateDriverDataSize = 0;
1298 pAllocationInfo->Alignment = 0;
1299 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
1300 pAllocationInfo->PitchAlignedSize = 0;
1301 pAllocationInfo->HintedBank.Value = 0;
1302 pAllocationInfo->PreferredSegment.Value = 0;
1303 pAllocationInfo->SupportedReadSegmentSet = 1;
1304 pAllocationInfo->SupportedWriteSegmentSet = 1;
1305 pAllocationInfo->EvictionSegmentSet = 0;
1306 pAllocationInfo->MaximumRenamingListLength = 0;
1307 pAllocationInfo->hAllocation = pAllocation;
1308 pAllocationInfo->Flags.Value = 0;
1309 pAllocationInfo->Flags.CpuVisible = 1;
1310 pAllocationInfo->pAllocationUsageHint = NULL;
1311 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
1312 }
1313 else
1314 {
1315 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
1316 Status = STATUS_NO_MEMORY;
1317 }
1318 }
1319 else
1320 {
1321 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
1322 Status = STATUS_INVALID_PARAMETER;
1323 }
1324 break;
1325 }
1326 default:
1327 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType));
1328 Status = STATUS_INVALID_PARAMETER;
1329 break;
1330 }
1331 }
1332 else
1333 {
1334 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
1335 Status = STATUS_INVALID_PARAMETER;
1336 }
1337
1338 return Status;
1339}
1340
1341NTSTATUS APIENTRY DxgkDdiCreateAllocation(
1342 CONST HANDLE hAdapter,
1343 DXGKARG_CREATEALLOCATION* pCreateAllocation)
1344{
1345 /* DxgkDdiCreateAllocation should be made pageable. */
1346 PAGED_CODE();
1347
1348 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1349
1350 NTSTATUS Status = STATUS_SUCCESS;
1351
1352 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
1353 {
1354 Status = vboxWddmCreateAllocation((PDEVICE_EXTENSION)hAdapter, &pCreateAllocation->pAllocationInfo[i]);
1355 Assert(Status == STATUS_SUCCESS);
1356 if (Status != STATUS_SUCCESS)
1357 {
1358 drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status));
1359 /* note: i-th allocation is expected to be cleared in a fail handling code above */
1360 for (UINT j = 0; j < i; ++j)
1361 {
1362 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
1363 }
1364 }
1365 }
1366
1367 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1368
1369 return Status;
1370}
1371
1372NTSTATUS
1373APIENTRY
1374DxgkDdiDestroyAllocation(
1375 CONST HANDLE hAdapter,
1376 CONST DXGKARG_DESTROYALLOCATION* pDestroyAllocation)
1377{
1378 /* DxgkDdiDestroyAllocation should be made pageable. */
1379 PAGED_CODE();
1380
1381 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1382 NTSTATUS Status = STATUS_SUCCESS;
1383
1384 for (UINT i = 0; i < pDestroyAllocation->NumAllocations; ++i)
1385 {
1386 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pDestroyAllocation->pAllocationList[i]);
1387 }
1388
1389 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1390
1391 return Status;
1392}
1393
1394
1395NTSTATUS
1396APIENTRY
1397DxgkDdiDescribeAllocation(
1398 CONST HANDLE hAdapter,
1399 DXGKARG_DESCRIBEALLOCATION* pDescribeAllocation)
1400{
1401 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1402
1403 AssertBreakpoint();
1404 /* @todo: fixme: implement */
1405
1406 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1407
1408 return STATUS_SUCCESS;
1409}
1410
1411/**
1412 * DxgkDdiGetStandardAllocationDriverData
1413 */
1414NTSTATUS
1415APIENTRY
1416DxgkDdiGetStandardAllocationDriverData(
1417 CONST HANDLE hAdapter,
1418 DXGKARG_GETSTANDARDALLOCATIONDRIVERDATA* pGetStandardAllocationDriverData)
1419{
1420 /* DxgkDdiGetStandardAllocationDriverData should be made pageable. */
1421 PAGED_CODE();
1422
1423 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1424
1425 NTSTATUS Status = STATUS_SUCCESS;
1426 PVBOXWDDM_ALLOCINFO pAllocInfo = NULL;
1427
1428 switch (pGetStandardAllocationDriverData->StandardAllocationType)
1429 {
1430 case D3DKMDT_STANDARDALLOCATION_SHAREDPRIMARYSURFACE:
1431 {
1432 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_SHAREDPRIMARYSURFACE\n"));
1433 if(pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1434 {
1435 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1436 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE;
1437 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width;
1438 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height;
1439 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format;
1440 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
1441 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
1442 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1443 pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate;
1444 pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId;
1445 }
1446 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
1447
1448 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1449 break;
1450 }
1451 case D3DKMDT_STANDARDALLOCATION_SHADOWSURFACE:
1452 {
1453 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_SHADOWSURFACE\n"));
1454 UINT bpp = vboxWddmCalcBitsPerPixel(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format);
1455 Assert(bpp);
1456 if (bpp != 0)
1457 {
1458 UINT Pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, bpp);
1459 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = Pitch;
1460
1461 /* @todo: need [d/q]word align?? */
1462
1463 if (pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1464 {
1465 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1466 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE;
1467 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width;
1468 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height;
1469 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format;
1470 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
1471 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
1472
1473 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
1474 }
1475 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
1476
1477 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1478 }
1479 else
1480 {
1481 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format));
1482 Status = STATUS_INVALID_PARAMETER;
1483 }
1484 break;
1485 }
1486 case D3DKMDT_STANDARDALLOCATION_STAGINGSURFACE:
1487 {
1488 dfprintf((__FUNCTION__ ": D3DKMDT_STANDARDALLOCATION_STAGINGSURFACE\n"));
1489 if(pGetStandardAllocationDriverData->pAllocationPrivateDriverData)
1490 {
1491 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
1492 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE;
1493 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width;
1494 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height;
1495 pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */
1496 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
1497 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
1498
1499 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
1500 }
1501 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
1502
1503 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
1504 break;
1505 }
1506//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
1507// case D3DKMDT_STANDARDALLOCATION_GDISURFACE:
1508//# error port to Win7 DDI
1509// break;
1510//#endif
1511 default:
1512 drprintf((__FUNCTION__ ": Invalid allocation type (%d)\n", pGetStandardAllocationDriverData->StandardAllocationType));
1513 Status = STATUS_INVALID_PARAMETER;
1514 break;
1515 }
1516
1517 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1518
1519 return Status;
1520}
1521
1522NTSTATUS
1523APIENTRY
1524DxgkDdiAcquireSwizzlingRange(
1525 CONST HANDLE hAdapter,
1526 DXGKARG_ACQUIRESWIZZLINGRANGE* pAcquireSwizzlingRange)
1527{
1528 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1529
1530 AssertBreakpoint();
1531
1532 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1533
1534 return STATUS_SUCCESS;
1535}
1536
1537NTSTATUS
1538APIENTRY
1539DxgkDdiReleaseSwizzlingRange(
1540 CONST HANDLE hAdapter,
1541 CONST DXGKARG_RELEASESWIZZLINGRANGE* pReleaseSwizzlingRange)
1542{
1543 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1544
1545 AssertBreakpoint();
1546
1547 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1548
1549 return STATUS_SUCCESS;
1550}
1551
1552NTSTATUS
1553APIENTRY
1554DxgkDdiPatch(
1555 CONST HANDLE hAdapter,
1556 CONST DXGKARG_PATCH* pPatch)
1557{
1558 /* DxgkDdiPatch should be made pageable. */
1559 PAGED_CODE();
1560
1561 NTSTATUS Status = STATUS_SUCCESS;
1562
1563 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1564
1565 /* Value == 2 is Present
1566 * Value == 4 is RedirectedPresent
1567 * we do not expect any other flags to be set here */
1568 Assert(pPatch->Flags.Value == 2 || pPatch->Flags.Value == 4);
1569
1570 uint8_t *pBuf = ((uint8_t *)pPatch->pDmaBuffer) + pPatch->DmaBufferPrivateDataSubmissionStartOffset;
1571 for (UINT i = pPatch->PatchLocationListSubmissionStart; i < pPatch->PatchLocationListSubmissionLength; ++i)
1572 {
1573 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[i];
1574 Assert(pPatchList->AllocationIndex < pPatch->AllocationListSize);
1575 const DXGK_ALLOCATIONLIST *pAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
1576 if (pAllocationList->SegmentId)
1577 {
1578 Assert(pPatchList->PatchOffset < (pPatch->DmaBufferPrivateDataSubmissionEndOffset - pPatch->DmaBufferPrivateDataSubmissionStartOffset));
1579 *((VBOXVIDEOOFFSET*)(pBuf+pPatchList->PatchOffset)) = (VBOXVIDEOOFFSET)pAllocationList->PhysicalAddress.QuadPart;
1580 }
1581 else
1582 {
1583 /* sanity */
1584 if (pPatch->Flags.Value == 2 || pPatch->Flags.Value == 4)
1585 Assert(i == 0);
1586 }
1587 }
1588
1589 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1590
1591 return Status;
1592}
1593
1594NTSTATUS
1595APIENTRY
1596DxgkDdiSubmitCommand(
1597 CONST HANDLE hAdapter,
1598 CONST DXGKARG_SUBMITCOMMAND* pSubmitCommand)
1599{
1600 /* DxgkDdiSubmitCommand runs at dispatch, should not be pageable. */
1601 NTSTATUS Status = STATUS_SUCCESS;
1602
1603 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1604
1605 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
1606 VBOXVDMACMDBUF_INFO BufInfo = {0};
1607
1608 Assert(pSubmitCommand->DmaBufferSegmentId);
1609
1610 /* the DMA command buffer is located in system RAM, the host will need to pick it from there */
1611 //BufInfo.fFlags = 0; /* see VBOXVDMACBUF_FLAG_xx */
1612 BufInfo.cbBuf = pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset - pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset;
1613 BufInfo.Location.phBuf = pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset;
1614 BufInfo.u32FenceId = pSubmitCommand->SubmissionFenceId;
1615
1616 int rc = vboxVdmaCBufSubmit (pDevExt, &pDevExt->u.primary.Vdma, &BufInfo);
1617 AssertRC(rc);
1618 if (!RT_SUCCESS(rc))
1619 {
1620 switch (rc)
1621 {
1622 case VERR_OUT_OF_RESOURCES:
1623 /* @todo: try flushing.. */
1624 Status = STATUS_INSUFFICIENT_RESOURCES;
1625 break;
1626 default:
1627 Status = STATUS_UNSUCCESSFUL;
1628 break;
1629 }
1630 }
1631
1632 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1633
1634 return Status;
1635}
1636
1637NTSTATUS
1638APIENTRY
1639DxgkDdiPreemptCommand(
1640 CONST HANDLE hAdapter,
1641 CONST DXGKARG_PREEMPTCOMMAND* pPreemptCommand)
1642{
1643 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1644
1645 AssertBreakpoint();
1646 /* @todo: fixme: implement */
1647
1648 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1649
1650 return STATUS_SUCCESS;
1651}
1652
1653NTSTATUS
1654APIENTRY
1655DxgkDdiBuildPagingBuffer(
1656 CONST HANDLE hAdapter,
1657 DXGKARG_BUILDPAGINGBUFFER* pBuildPagingBuffer)
1658{
1659 /* DxgkDdiBuildPagingBuffer should be made pageable. */
1660 PAGED_CODE();
1661
1662 NTSTATUS Status = STATUS_SUCCESS;
1663
1664 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1665
1666 /* @todo: */
1667 switch (pBuildPagingBuffer->Operation)
1668 {
1669 case DXGK_OPERATION_TRANSFER:
1670 {
1671 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->Transfer.hAllocation;
1672 break;
1673 }
1674 case DXGK_OPERATION_FILL:
1675 break;
1676 case DXGK_OPERATION_DISCARD_CONTENT:
1677 break;
1678 default:
1679 drprintf((__FUNCTION__": unsupported op (%d)\n", pBuildPagingBuffer->Operation));
1680 AssertBreakpoint();
1681 break;
1682 }
1683
1684 dfprintf(("<== "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1685
1686 return Status;
1687
1688}
1689
1690NTSTATUS
1691APIENTRY
1692DxgkDdiSetPalette(
1693 CONST HANDLE hAdapter,
1694 CONST DXGKARG_SETPALETTE* pSetPalette
1695 )
1696{
1697 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1698
1699 AssertBreakpoint();
1700 /* @todo: fixme: implement */
1701
1702 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1703
1704 return STATUS_SUCCESS;
1705}
1706
1707NTSTATUS
1708APIENTRY
1709DxgkDdiSetPointerPosition(
1710 CONST HANDLE hAdapter,
1711 CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
1712{
1713 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1714
1715 AssertBreakpoint();
1716 /* @todo: fixme: implement */
1717
1718 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1719
1720 return STATUS_SUCCESS;
1721}
1722
1723NTSTATUS
1724APIENTRY
1725DxgkDdiSetPointerShape(
1726 CONST HANDLE hAdapter,
1727 CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
1728{
1729 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1730
1731 AssertBreakpoint();
1732 /* @todo: fixme: implement */
1733
1734 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1735
1736 return STATUS_SUCCESS;
1737}
1738
1739NTSTATUS
1740APIENTRY CALLBACK
1741DxgkDdiResetFromTimeout(
1742 CONST HANDLE hAdapter)
1743{
1744 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1745
1746 AssertBreakpoint();
1747 /* @todo: fixme: implement */
1748
1749 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1750
1751 return STATUS_SUCCESS;
1752}
1753
1754NTSTATUS
1755APIENTRY
1756DxgkDdiEscape(
1757 CONST HANDLE hAdapter,
1758 CONST DXGKARG_ESCAPE* pEscape)
1759{
1760 PAGED_CODE();
1761
1762 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1763
1764 AssertBreakpoint();
1765
1766 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1767
1768 return STATUS_INVALID_PARAMETER;
1769}
1770
1771NTSTATUS
1772APIENTRY
1773DxgkDdiCollectDbgInfo(
1774 CONST HANDLE hAdapter,
1775 CONST DXGKARG_COLLECTDBGINFO* pCollectDbgInfo
1776 )
1777{
1778 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1779
1780 AssertBreakpoint();
1781
1782 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1783
1784 return STATUS_SUCCESS;
1785}
1786
1787NTSTATUS
1788APIENTRY
1789DxgkDdiQueryCurrentFence(
1790 CONST HANDLE hAdapter,
1791 DXGKARG_QUERYCURRENTFENCE* pCurrentFence)
1792{
1793 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1794
1795 AssertBreakpoint();
1796 /* @todo: fixme: implement */
1797
1798 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
1799
1800 return STATUS_SUCCESS;
1801}
1802
1803NTSTATUS
1804APIENTRY
1805DxgkDdiIsSupportedVidPn(
1806 CONST HANDLE hAdapter,
1807 OUT DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPnArg
1808 )
1809{
1810 /* The DxgkDdiIsSupportedVidPn should be made pageable. */
1811 PAGED_CODE();
1812
1813 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1814
1815 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1816 BOOLEAN bSupported = TRUE;
1817 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
1818 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pIsSupportedVidPnArg->hDesiredVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
1819 if (Status == STATUS_SUCCESS)
1820 {
1821 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1822 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1823 Status = pVidPnInterface->pfnGetTopology(pIsSupportedVidPnArg->hDesiredVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1824 if (Status == STATUS_SUCCESS)
1825 {
1826 Status = vboxVidPnCheckTopology(pIsSupportedVidPnArg->hDesiredVidPn, hVidPnTopology, pVidPnTopologyInterface, &bSupported);
1827 if (Status == STATUS_SUCCESS && bSupported)
1828 {
1829 for (UINT id = 0; id < pContext->cSources; ++id)
1830 {
1831 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
1832 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface;
1833 Status = pVidPnInterface->pfnAcquireSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn,
1834 id,
1835 &hNewVidPnSourceModeSet,
1836 &pVidPnSourceModeSetInterface);
1837 if (Status == STATUS_SUCCESS)
1838 {
1839 Status = vboxVidPnCheckSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface, &bSupported);
1840
1841 pVidPnInterface->pfnReleaseSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet);
1842
1843 if (Status != STATUS_SUCCESS || !bSupported)
1844 break;
1845 }
1846 else if (Status == STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE)
1847 {
1848 drprintf(("VBoxVideoWddm: Warning: pfnAcquireSourceModeSet returned STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE, continuing\n"));
1849 Status = STATUS_SUCCESS;
1850 }
1851 else
1852 {
1853 drprintf(("VBoxVideoWddm: pfnAcquireSourceModeSet failed Status(0x%x)\n"));
1854 break;
1855 }
1856 }
1857
1858 if (Status == STATUS_SUCCESS && bSupported)
1859 {
1860 for (UINT id = 0; id < pContext->cSources; ++id)
1861 {
1862 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
1863 CONST DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface;
1864 Status = pVidPnInterface->pfnAcquireTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn,
1865 id, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
1866 &hNewVidPnTargetModeSet,
1867 &pVidPnTargetModeSetInterface);
1868 if (Status == STATUS_SUCCESS)
1869 {
1870 Status = vboxVidPnCheckTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface, &bSupported);
1871
1872 pVidPnInterface->pfnReleaseTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet);
1873
1874 if (Status != STATUS_SUCCESS || !bSupported)
1875 break;
1876 }
1877 else if (Status == STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE)
1878 {
1879 drprintf(("VBoxVideoWddm: Warning: pfnAcquireSourceModeSet returned STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE, continuing\n"));
1880 Status = STATUS_SUCCESS;
1881 }
1882 else
1883 {
1884 drprintf(("VBoxVideoWddm: pfnAcquireSourceModeSet failed Status(0x%x)\n"));
1885 break;
1886 }
1887 }
1888 }
1889 }
1890 }
1891 else
1892 {
1893 drprintf(("VBoxVideoWddm: pfnGetTopology failed Status(0x%x)\n"));
1894 }
1895 }
1896 else
1897 {
1898 drprintf(("VBoxVideoWddm: DxgkCbQueryVidPnInterface failed Status(0x%x)\n"));
1899 }
1900 pIsSupportedVidPnArg->IsVidPnSupported = bSupported;
1901
1902 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
1903
1904 return Status;
1905}
1906
1907NTSTATUS
1908APIENTRY
1909DxgkDdiRecommendFunctionalVidPn(
1910 CONST HANDLE hAdapter,
1911 CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPnArg
1912 )
1913{
1914 /* The DxgkDdiRecommendFunctionalVidPn should be made pageable. */
1915 PAGED_CODE();
1916
1917 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
1918
1919 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
1920 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
1921 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
1922 if (Status == STATUS_SUCCESS)
1923 {
1924 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
1925 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
1926 Status = pVidPnInterface->pfnGetTopology(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
1927 if (Status == STATUS_SUCCESS)
1928 {
1929 D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo;
1930 Status = pVidPnTopologyInterface->pfnCreateNewPathInfo(hVidPnTopology, &pNewVidPnPresentPathInfo);
1931 if (Status == STATUS_SUCCESS)
1932 {
1933 pNewVidPnPresentPathInfo->VidPnSourceId = 0;
1934 pNewVidPnPresentPathInfo->VidPnTargetId = 0;
1935 pNewVidPnPresentPathInfo->ImportanceOrdinal = D3DKMDT_VPPI_PRIMARY;
1936 pNewVidPnPresentPathInfo->ContentTransformation.Scaling = D3DKMDT_VPPS_IDENTITY;
1937 memset(&pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport,
1938 0, sizeof (pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport));
1939 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Identity = 1;
1940 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Centered = 1;
1941 pNewVidPnPresentPathInfo->ContentTransformation.ScalingSupport.Stretched = 0;
1942 pNewVidPnPresentPathInfo->ContentTransformation.Rotation = D3DKMDT_VPPR_IDENTITY;
1943 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Identity = 1;
1944 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate180 = 0;
1945 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate270 = 0;
1946 pNewVidPnPresentPathInfo->ContentTransformation.RotationSupport.Rotate90 = 0;
1947 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cx = 0;
1948 pNewVidPnPresentPathInfo->VisibleFromActiveTLOffset.cy = 0;
1949 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cx = 0;
1950 pNewVidPnPresentPathInfo->VisibleFromActiveBROffset.cy = 0;
1951 pNewVidPnPresentPathInfo->VidPnTargetColorBasis = D3DKMDT_CB_SRGB; /* @todo: how does it matters? */
1952 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FirstChannel = 8;
1953 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.SecondChannel = 8;
1954 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.ThirdChannel = 8;
1955 pNewVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges.FourthChannel = 0;
1956 pNewVidPnPresentPathInfo->Content = D3DKMDT_VPPC_GRAPHICS;
1957 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionType = D3DKMDT_VPPMT_NOPROTECTION;
1958 pNewVidPnPresentPathInfo->CopyProtection.APSTriggerBits = 0;
1959 memset(&pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport, 0, sizeof (pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport));
1960 pNewVidPnPresentPathInfo->CopyProtection.CopyProtectionSupport.NoProtection = 1;
1961 pNewVidPnPresentPathInfo->GammaRamp.Type = D3DDDI_GAMMARAMP_DEFAULT;
1962 pNewVidPnPresentPathInfo->GammaRamp.DataSize = 0;
1963 Status = pVidPnTopologyInterface->pfnAddPath(hVidPnTopology, pNewVidPnPresentPathInfo);
1964 if (Status == STATUS_SUCCESS)
1965 {
1966 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
1967 const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface;
1968 Status = pVidPnInterface->pfnCreateNewSourceModeSet(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn,
1969 0, /*__in CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId */
1970 &hNewVidPnSourceModeSet,
1971 &pVidPnSourceModeSetInterface);
1972 if (Status == STATUS_SUCCESS)
1973 {
1974 D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo;
1975 Status = pVidPnSourceModeSetInterface->pfnCreateNewModeInfo(hNewVidPnSourceModeSet, &pNewVidPnSourceModeInfo);
1976 if (Status == STATUS_SUCCESS)
1977 {
1978 D3DKMDT_VIDEO_PRESENT_SOURCE_MODE_ID modeId = pNewVidPnSourceModeInfo->Id;
1979 pNewVidPnSourceModeInfo->Type = D3DKMDT_RMT_GRAPHICS;
1980 /* @todo: should we obtain the default mode from the host? */
1981 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx = 1024;
1982 pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy = 768;
1983 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize;
1984 pNewVidPnSourceModeInfo->Format.Graphics.Stride = pNewVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx * 4;
1985 pNewVidPnSourceModeInfo->Format.Graphics.PixelFormat = D3DDDIFMT_X8R8G8B8;
1986 pNewVidPnSourceModeInfo->Format.Graphics.ColorBasis = D3DKMDT_CB_SRGB;
1987 pNewVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode = D3DKMDT_PVAM_DIRECT;
1988 Status = pVidPnSourceModeSetInterface->pfnAddMode(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
1989 if (Status == STATUS_SUCCESS)
1990 {
1991 Status = pVidPnSourceModeSetInterface->pfnPinMode(hNewVidPnSourceModeSet, modeId);
1992 if (Status == STATUS_SUCCESS)
1993 {
1994 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet;
1995 CONST DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface;
1996 Status = pVidPnInterface->pfnCreateNewTargetModeSet(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn,
1997 0, /* __in CONST D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId */
1998 &hNewVidPnTargetModeSet,
1999 &pVidPnTargetModeSetInterface);
2000 if (Status == STATUS_SUCCESS)
2001 {
2002 D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo;
2003 Status = pVidPnTargetModeSetInterface->pfnCreateNewModeInfo(hNewVidPnTargetModeSet, &pNewVidPnTargetModeInfo);
2004 if (Status == STATUS_SUCCESS)
2005 {
2006 D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID targetId = pNewVidPnTargetModeInfo->Id;
2007 pNewVidPnTargetModeInfo->VideoSignalInfo.VideoStandard = D3DKMDT_VSS_OTHER;
2008 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cx = 1024;
2009 pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize.cy = 768;
2010 pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize = pNewVidPnTargetModeInfo->VideoSignalInfo.TotalSize;
2011 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60;
2012 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1;
2013 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = 63 * 768; /* @todo: do we need that? */
2014 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
2015 pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* ?? */
2016 pNewVidPnTargetModeInfo->VideoSignalInfo.ScanLineOrdering = D3DDDI_VSSLO_PROGRESSIVE;
2017 pNewVidPnTargetModeInfo->Preference = D3DKMDT_MP_PREFERRED;
2018 Status = pVidPnTargetModeSetInterface->pfnAddMode(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
2019 if (Status == STATUS_SUCCESS)
2020 {
2021 Status = pVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, targetId);
2022 if (Status == STATUS_SUCCESS)
2023 {
2024
2025 }
2026 else
2027 {
2028 drprintf(("VBoxVideoWddm: pfnPinMode (target) failed Status(0x%x)\n"));
2029 }
2030 }
2031 else
2032 {
2033 drprintf(("VBoxVideoWddm: pfnAddMode (target) failed Status(0x%x)\n"));
2034 pVidPnTargetModeSetInterface->pfnReleaseModeInfo(hNewVidPnTargetModeSet, pNewVidPnTargetModeInfo);
2035 pNewVidPnTargetModeInfo = NULL;
2036 }
2037 }
2038 else
2039 {
2040 drprintf(("VBoxVideoWddm: pfnCreateNewModeInfo (target) failed Status(0x%x)\n"));
2041 }
2042 }
2043 else
2044 {
2045 drprintf(("VBoxVideoWddm: pfnCreateNewTargetModeSet failed Status(0x%x)\n"));
2046 }
2047 }
2048 else
2049 {
2050 drprintf(("VBoxVideoWddm: pfnPinMode failed Status(0x%x)\n"));
2051 }
2052 }
2053 else
2054 {
2055 drprintf(("VBoxVideoWddm: pfnAddMode failed Status(0x%x)\n"));
2056 pVidPnSourceModeSetInterface->pfnReleaseModeInfo(hNewVidPnSourceModeSet, pNewVidPnSourceModeInfo);
2057 pNewVidPnSourceModeInfo = NULL;
2058 }
2059 }
2060 else
2061 {
2062 drprintf(("VBoxVideoWddm: pfnCreateNewModeInfo failed Status(0x%x)\n"));
2063 }
2064 }
2065 else
2066 {
2067 drprintf(("VBoxVideoWddm: pfnCreateNewSourceModeSet failed Status(0x%x)\n"));
2068 }
2069 }
2070 else
2071 {
2072 drprintf(("VBoxVideoWddm: pfnAddPath failed Status(0x%x)\n"));
2073 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo);
2074 pNewVidPnPresentPathInfo = NULL;
2075 }
2076 }
2077 else
2078 {
2079 drprintf(("VBoxVideoWddm: pfnCreateNewPathInfo failed Status(0x%x)\n"));
2080 }
2081 }
2082 else
2083 {
2084 drprintf(("VBoxVideoWddm: pfnGetTopology failed Status(0x%x)\n"));
2085 }
2086 }
2087 else
2088 {
2089 drprintf(("VBoxVideoWddm: DxgkCbQueryVidPnInterface failed Status(0x%x)\n"));
2090 }
2091
2092 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
2093
2094 return Status;
2095}
2096
2097NTSTATUS
2098APIENTRY
2099DxgkDdiEnumVidPnCofuncModality(
2100 CONST HANDLE hAdapter,
2101 CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModalityArg
2102 )
2103{
2104 /* The DxgkDdiEnumVidPnCofuncModality function should be made pageable. */
2105 PAGED_CODE();
2106
2107 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
2108
2109 PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)hAdapter;
2110
2111 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
2112 NTSTATUS Status = pContext->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pEnumCofuncModalityArg->hConstrainingVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
2113 if (Status == STATUS_SUCCESS)
2114 {
2115 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
2116 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
2117 NTSTATUS Status = pVidPnInterface->pfnGetTopology(pEnumCofuncModalityArg->hConstrainingVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
2118 Assert(Status == STATUS_SUCCESS);
2119 if (Status == STATUS_SUCCESS)
2120 {
2121 VBOXVIDPNCOFUNCMODALITY CbContext = {0};
2122 CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg;
2123 VBoxWddmGetModesTable(pContext, /* PDEVICE_EXTENSION DeviceExtension */
2124 true, /* bool bRebuildTable*/
2125 &CbContext.pModes, /* VIDEO_MODE_INFORMATION ** ppModes*/
2126 &CbContext.cModes, /* uint32_t * pcModes */
2127 &CbContext.iPreferredMode, /* uint32_t * pPreferrableMode*/
2128 &CbContext.pResolutions, /* D3DKMDT_2DREGION **ppResolutions */
2129 &CbContext.cResolutions /* uint32_t * pcResolutions */);
2130 Assert(CbContext.cModes);
2131 Assert(CbContext.cModes > CbContext.iPreferredMode);
2132 Status = vboxVidPnEnumPaths(pContext, pEnumCofuncModalityArg->hConstrainingVidPn, pVidPnInterface,
2133 hVidPnTopology, pVidPnTopologyInterface,
2134 vboxVidPnCofuncModalityPathEnum, &CbContext);
2135 Assert(Status == STATUS_SUCCESS);
2136 if (Status == STATUS_SUCCESS)
2137 {
2138 Status = CbContext.Status;
2139 Assert(Status == STATUS_SUCCESS);
2140 if (Status != STATUS_SUCCESS)
2141 drprintf((__FUNCTION__ ": vboxVidPnAdjustSourcesTargetsCallback failed Status(0x%x)\n", Status));
2142 }
2143 else
2144 drprintf((__FUNCTION__ ": vboxVidPnEnumPaths failed Status(0x%x)\n", Status));
2145 }
2146 else
2147 drprintf((__FUNCTION__ ": pfnGetTopology failed Status(0x%x)\n", Status));
2148 }
2149 else
2150 drprintf((__FUNCTION__ ": DxgkCbQueryVidPnInterface failed Status(0x%x)\n", Status));
2151
2152 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
2153
2154 return Status;
2155}
2156
2157NTSTATUS
2158APIENTRY
2159DxgkDdiSetVidPnSourceAddress(
2160 CONST HANDLE hAdapter,
2161 CONST DXGKARG_SETVIDPNSOURCEADDRESS* pSetVidPnSourceAddress
2162 )
2163{
2164 /* The DxgkDdiSetVidPnSourceAddress function should be made pageable. */
2165 PAGED_CODE();
2166
2167 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
2168
2169 NTSTATUS Status = STATUS_SUCCESS;
2170 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
2171 Assert(pDevExt->cSources > pSetVidPnSourceAddress->VidPnSourceId);
2172 if (pDevExt->cSources > pSetVidPnSourceAddress->VidPnSourceId)
2173 {
2174 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceAddress->VidPnSourceId];
2175 PVBOXWDDM_ALLOCATION pAllocation;
2176 Assert(pSetVidPnSourceAddress->hAllocation);
2177 Assert(pSetVidPnSourceAddress->hAllocation || pSource->pAllocation);
2178 Assert (pSetVidPnSourceAddress->Flags.Value < 2); /* i.e. 0 or 1 (ModeChange) */
2179 if (pSetVidPnSourceAddress->hAllocation)
2180 {
2181 pAllocation = (PVBOXWDDM_ALLOCATION)pSetVidPnSourceAddress->hAllocation;
2182 vboxWddmAssignPrimary(pDevExt, pSource, pAllocation, pSetVidPnSourceAddress->VidPnSourceId);
2183 }
2184 else
2185 pAllocation = pSource->pAllocation;
2186
2187 Assert(pAllocation);
2188 if (pAllocation)
2189 {
2190 Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE);
2191 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
2192 pAllocation->offVram = (VBOXVIDEOOFFSET)pSetVidPnSourceAddress->PrimaryAddress.QuadPart;
2193 pAllocation->SegmentId = pSetVidPnSourceAddress->PrimarySegment;
2194 Assert (pAllocation->SegmentId);
2195 Assert (!pPrimary->bVisible);
2196 if (pPrimary->bVisible)
2197 {
2198 /* should not generally happen, but still inform host*/
2199 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource);
2200 Assert(Status == STATUS_SUCCESS);
2201 if (Status != STATUS_SUCCESS)
2202 drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
2203 }
2204 }
2205 else
2206 {
2207 drprintf((__FUNCTION__": no allocation data available!!\n"));
2208 Status = STATUS_INVALID_PARAMETER;
2209 }
2210 }
2211 else
2212 {
2213 drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceAddress->VidPnSourceId, pDevExt->cSources));
2214 Status = STATUS_INVALID_PARAMETER;
2215 }
2216
2217 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
2218
2219 return Status;
2220}
2221
2222NTSTATUS
2223APIENTRY
2224DxgkDdiSetVidPnSourceVisibility(
2225 CONST HANDLE hAdapter,
2226 CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility
2227 )
2228{
2229 /* DxgkDdiSetVidPnSourceVisibility should be made pageable. */
2230 PAGED_CODE();
2231
2232 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
2233
2234 NTSTATUS Status = STATUS_SUCCESS;
2235 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
2236 Assert(pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId);
2237 if (pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId)
2238 {
2239 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
2240 PVBOXWDDM_ALLOCATION pAllocation = pSource->pAllocation;
2241 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
2242
2243 Assert(pPrimary->bVisible != pSetVidPnSourceVisibility->Visible);
2244 if (pPrimary->bVisible != pSetVidPnSourceVisibility->Visible)
2245 {
2246 pPrimary->bVisible = pSetVidPnSourceVisibility->Visible;
2247 if (pPrimary->bVisible)
2248 {
2249 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource);
2250 Assert(Status == STATUS_SUCCESS);
2251 if (Status != STATUS_SUCCESS)
2252 drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
2253 }
2254 else
2255 {
2256 vboxVdmaFlush (pDevExt, &pDevExt->u.primary.Vdma);
2257 }
2258 }
2259 }
2260 else
2261 {
2262 drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceVisibility->VidPnSourceId, pDevExt->cSources));
2263 Status = STATUS_INVALID_PARAMETER;
2264 }
2265
2266 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
2267
2268 return Status;
2269}
2270
2271NTSTATUS
2272APIENTRY
2273DxgkDdiCommitVidPn(
2274 CONST HANDLE hAdapter,
2275 CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPnArg
2276 )
2277{
2278 dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
2279
2280 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
2281
2282 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
2283 NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pCommitVidPnArg->hFunctionalVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
2284 if (Status == STATUS_SUCCESS)
2285 {
2286 if (pCommitVidPnArg->AffectedVidPnSourceId != D3DDDI_ID_ALL)
2287 {
2288 Status = vboxVidPnCommitSourceModeForSrcId(
2289 pDevExt,
2290 pCommitVidPnArg->hFunctionalVidPn, pVidPnInterface,
2291 pCommitVidPnArg->AffectedVidPnSourceId, (PVBOXWDDM_ALLOCATION)pCommitVidPnArg->hPrimaryAllocation);
2292 Assert(Status == STATUS_SUCCESS);
2293 if (Status != STATUS_SUCCESS)
2294 drprintf((__FUNCTION__ ": vboxVidPnCommitSourceModeForSrcId failed Status(0x%x)\n", Status));
2295 }
2296 else
2297 {
2298 /* clear all current primaries */
2299 for (UINT i = 0; i < pDevExt->cSources; ++i)
2300 {
2301 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[i], NULL, i);
2302 }
2303
2304 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology;
2305 const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface;
2306 NTSTATUS Status = pVidPnInterface->pfnGetTopology(pCommitVidPnArg->hFunctionalVidPn, &hVidPnTopology, &pVidPnTopologyInterface);
2307 Assert(Status == STATUS_SUCCESS);
2308 if (Status == STATUS_SUCCESS)
2309 {
2310 VBOXVIDPNCOMMIT CbContext = {0};
2311 CbContext.pCommitVidPnArg = pCommitVidPnArg;
2312 Status = vboxVidPnEnumPaths(pDevExt, pCommitVidPnArg->hFunctionalVidPn, pVidPnInterface,
2313 hVidPnTopology, pVidPnTopologyInterface,
2314 vboxVidPnCommitPathEnum, &CbContext);
2315 Assert(Status == STATUS_SUCCESS);
2316 if (Status == STATUS_SUCCESS)
2317 {
2318 Status = CbContext.Status;
2319 Assert(Status == STATUS_SUCCESS);
2320 if (Status != STATUS_SUCCESS)
2321 drprintf((__FUNCTION__ ": vboxVidPnCommitPathEnum failed Status(0x%x)\n", Status));
2322 }
2323 else
2324 drprintf((__FUNCTION__ ": vboxVidPnEnumPaths failed Status(0x%x)\n", Status));
2325 }
2326 else
2327 drprintf((__FUNCTION__ ": pfnGetTopology failed Status(0x%x)\n", Status));
2328 }
2329 }
2330 else
2331 drprintf((__FUNCTION__ ": DxgkCbQueryVidPnInterface failed Status(0x%x)\n", Status));
2332
2333 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
2334
2335 return Status;
2336}
2337
2338NTSTATUS
2339APIENTRY
2340DxgkDdiUpdateActiveVidPnPresentPath(
2341 CONST HANDLE hAdapter,
2342 CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPathArg
2343 )
2344{
2345 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2346
2347 AssertBreakpoint();
2348
2349 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2350
2351 return STATUS_SUCCESS;
2352}
2353
2354NTSTATUS
2355APIENTRY
2356DxgkDdiRecommendMonitorModes(
2357 CONST HANDLE hAdapter,
2358 CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModesArg
2359 )
2360{
2361 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2362
2363 AssertBreakpoint();
2364
2365 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2366
2367 return STATUS_SUCCESS;
2368}
2369
2370NTSTATUS
2371APIENTRY
2372DxgkDdiRecommendVidPnTopology(
2373 CONST HANDLE hAdapter,
2374 CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopologyArg
2375 )
2376{
2377 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2378
2379 AssertBreakpoint();
2380
2381 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2382
2383 return STATUS_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY;
2384}
2385
2386NTSTATUS
2387APIENTRY
2388DxgkDdiGetScanLine(
2389 CONST HANDLE hAdapter,
2390 DXGKARG_GETSCANLINE* pGetScanLine)
2391{
2392 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2393
2394 AssertBreakpoint();
2395
2396 pGetScanLine->InVerticalBlank = FALSE;
2397 pGetScanLine->ScanLine = 0;
2398
2399 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2400
2401 return STATUS_SUCCESS;
2402}
2403
2404NTSTATUS
2405APIENTRY
2406DxgkDdiStopCapture(
2407 CONST HANDLE hAdapter,
2408 CONST DXGKARG_STOPCAPTURE* pStopCapture)
2409{
2410 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2411
2412 AssertBreakpoint();
2413
2414 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2415
2416 return STATUS_SUCCESS;
2417}
2418
2419NTSTATUS
2420APIENTRY
2421DxgkDdiControlInterrupt(
2422 CONST HANDLE hAdapter,
2423 CONST DXGK_INTERRUPT_TYPE InterruptType,
2424 BOOLEAN Enable
2425 )
2426{
2427 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2428
2429 AssertBreakpoint();
2430
2431 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2432
2433 /* @todo: STATUS_NOT_IMPLEMENTED ?? */
2434 return STATUS_SUCCESS;
2435}
2436
2437NTSTATUS
2438APIENTRY
2439DxgkDdiCreateOverlay(
2440 CONST HANDLE hAdapter,
2441 DXGKARG_CREATEOVERLAY *pCreateOverlay)
2442{
2443 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2444
2445 AssertBreakpoint();
2446
2447 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2448
2449 return STATUS_NOT_IMPLEMENTED;
2450}
2451
2452NTSTATUS
2453APIENTRY
2454DxgkDdiDestroyDevice(
2455 CONST HANDLE hDevice)
2456{
2457 /* DxgkDdiDestroyDevice should be made pageable. */
2458 PAGED_CODE();
2459
2460 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2461
2462 vboxWddmMemFree(hDevice);
2463
2464 dfprintf(("<== "__FUNCTION__ ", \n"));
2465
2466 return STATUS_SUCCESS;
2467}
2468
2469NTSTATUS
2470APIENTRY
2471DxgkDdiOpenAllocation(
2472 CONST HANDLE hDevice,
2473 CONST DXGKARG_OPENALLOCATION *pOpenAllocation)
2474{
2475 /* DxgkDdiOpenAllocation should be made pageable. */
2476 PAGED_CODE();
2477
2478 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2479
2480 NTSTATUS Status = STATUS_SUCCESS;
2481
2482 for (UINT i = 0; i < pOpenAllocation->NumAllocations; ++i)
2483 {
2484 DXGK_OPENALLOCATIONINFO* pInfo = &pOpenAllocation->pOpenAllocation[i];
2485 PVBOXWDDM_OPENALLOCATION pOa = (PVBOXWDDM_OPENALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_OPENALLOCATION));
2486 pOa->hAllocation = pInfo->hAllocation;
2487 pInfo->hDeviceSpecificAllocation = pOa;
2488 }
2489
2490 dfprintf(("<== "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2491
2492 return Status;
2493}
2494
2495NTSTATUS
2496APIENTRY
2497DxgkDdiCloseAllocation(
2498 CONST HANDLE hDevice,
2499 CONST DXGKARG_CLOSEALLOCATION* pCloseAllocation)
2500{
2501 /* DxgkDdiCloseAllocation should be made pageable. */
2502 PAGED_CODE();
2503
2504 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2505
2506 for (UINT i = 0; i < pCloseAllocation->NumAllocations; ++i)
2507 {
2508 vboxWddmMemFree(pCloseAllocation->pOpenHandleList[i]);
2509 }
2510
2511 dfprintf(("<== "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2512
2513 return STATUS_SUCCESS;
2514}
2515
2516NTSTATUS
2517APIENTRY
2518DxgkDdiRender(
2519 CONST HANDLE hContext,
2520 DXGKARG_RENDER *pRender)
2521{
2522 drprintf(("==> "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext));
2523
2524 AssertBreakpoint();
2525
2526 drprintf(("<== "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext));
2527
2528 return STATUS_NOT_IMPLEMENTED;
2529}
2530
2531#define VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE() (VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_PRESENT_BLT))
2532#define VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(_c) (VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[_c]))
2533
2534DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromOpenData(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OPENALLOCATION pOa)
2535{
2536 DXGKARGCB_GETHANDLEDATA GhData;
2537 GhData.hObject = pOa->hAllocation;
2538 GhData.Type = DXGK_HANDLE_ALLOCATION;
2539 GhData.Flags.Value = 0;
2540 return (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData);
2541}
2542
2543DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromAllocList(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONLIST *pAllocList)
2544{
2545 return vboxWddmGetAllocationFromOpenData(pDevExt, (PVBOXWDDM_OPENALLOCATION)pAllocList->hDeviceSpecificAllocation);
2546}
2547
2548DECLINLINE(VBOXVIDEOOFFSET) vboxWddmOffsetFromPhAddress(PHYSICAL_ADDRESS phAddr)
2549{
2550 return (VBOXVIDEOOFFSET)(phAddr.QuadPart ? phAddr.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS : VBOXVIDEOOFFSET_VOID);
2551}
2552
2553DECLINLINE(VOID) vboxWddmRectlFromRect(const RECT *pRect, PVBOXVDMA_RECTL pRectl)
2554{
2555 pRectl->left = (int16_t)pRect->left;
2556 pRectl->width = (uint16_t)(pRect->right - pRect->left);
2557 pRectl->top = (int16_t)pRect->top;
2558 pRectl->height = (uint16_t)(pRect->bottom - pRect->top);
2559}
2560
2561DECLINLINE(VBOXVDMA_PIXEL_FORMAT) vboxWddmFromPixFormat(D3DDDIFORMAT format)
2562{
2563 return (VBOXVDMA_PIXEL_FORMAT)format;
2564}
2565
2566DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc)
2567{
2568 pDesc->width = pAllocation->u.SurfInfo.width;
2569 pDesc->height = pAllocation->u.SurfInfo.height;
2570 pDesc->format = vboxWddmFromPixFormat(pAllocation->u.SurfInfo.format);
2571 pDesc->bpp = pAllocation->u.SurfInfo.bpp;
2572 pDesc->pitch = pAllocation->u.SurfInfo.pitch;
2573 pDesc->fFlags = 0;
2574}
2575
2576DECLINLINE(BOOLEAN) vboxWddmPixFormatConversionSupported(D3DDDIFORMAT From, D3DDDIFORMAT To)
2577{
2578 Assert(From != D3DDDIFMT_UNKNOWN);
2579 Assert(To != D3DDDIFMT_UNKNOWN);
2580 Assert(From == To);
2581 return From == To;
2582}
2583
2584DECLINLINE(PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
2585{
2586 if (pAllocation->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
2587 return NULL;
2588
2589 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
2590 if (!pPrimary->bVisible)
2591 return NULL;
2592
2593 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId;
2594 if (id >= pDevExt->cSources)
2595 return NULL;
2596
2597 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id];
2598 if (pSource->pAllocation != pAllocation)
2599 return NULL;
2600
2601 return pPrimary;
2602}
2603
2604/**
2605 * DxgkDdiPresent
2606 */
2607NTSTATUS
2608APIENTRY
2609DxgkDdiPresent(
2610 CONST HANDLE hContext,
2611 DXGKARG_PRESENT *pPresent)
2612{
2613 PAGED_CODE();
2614
2615 dfprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext));
2616
2617 NTSTATUS Status = STATUS_SUCCESS;
2618 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
2619 PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
2620 PDEVICE_EXTENSION pDevExt = pDevice->pAdapter;
2621
2622 if (pPresent->Flags.Blt)
2623 {
2624 Assert(pPresent->Flags.Value == 1); /* only Blt is set, we do not support anything else for now */
2625 UINT cbCmd = pPresent->DmaSize;
2626
2627 UINT cmdSize = VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(pPresent->SubRectCnt - pPresent->MultipassOffset);
2628 PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pPresent->pDmaBuffer;
2629 pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cmdSize;
2630 Assert(cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE());
2631 if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE())
2632 {
2633 DXGK_ALLOCATIONLIST *pSrc = &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
2634 DXGK_ALLOCATIONLIST *pDst = &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
2635 PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc);
2636 Assert(pSrcAlloc);
2637 if (pSrcAlloc)
2638 {
2639 PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
2640 Assert(pDstAlloc);
2641 if (pDstAlloc)
2642 {
2643 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))
2644 {
2645 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
2646// pPresent->pPatchLocationListOut->PatchOffset = 0;
2647// ++pPresent->pPatchLocationListOut;
2648 pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc);
2649 pPresent->pPatchLocationListOut->AllocationIndex = 0;
2650 ++pPresent->pPatchLocationListOut;
2651 pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst);
2652 pPresent->pPatchLocationListOut->AllocationIndex = 1;
2653 ++pPresent->pPatchLocationListOut;
2654
2655 pCmd->enmType = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
2656 pCmd->u32CmdSpecific = 0;
2657 PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT);
2658 pTransfer->offSrc = (VBOXVIDEOOFFSET)pSrc->PhysicalAddress.QuadPart;
2659 pTransfer->offDst = (VBOXVIDEOOFFSET)pDst->PhysicalAddress.QuadPart;
2660 vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc);
2661 vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc);
2662 vboxWddmRectlFromRect(&pPresent->SrcRect, &pTransfer->srcRectl);
2663 vboxWddmRectlFromRect(&pPresent->DstRect, &pTransfer->dstRectl);
2664 UINT i = 0;
2665 cbCmd -= VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects);
2666 Assert(cbCmd >= sizeof (VBOXVDMA_RECTL));
2667 Assert(cbCmd < pPresent->DmaSize);
2668 for (; i < pPresent->SubRectCnt; ++i)
2669 {
2670 if (cbCmd < sizeof (VBOXVDMA_RECTL))
2671 {
2672 Assert(i);
2673 pPresent->MultipassOffset += i;
2674 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
2675 break;
2676 }
2677 vboxWddmRectlFromRect(&pPresent->pDstSubRects[i + pPresent->MultipassOffset], &pTransfer->aDstSubRects[i]);
2678 cbCmd -= sizeof (VBOXVDMA_RECTL);
2679 }
2680 Assert(i);
2681 pTransfer->cDstSubRects = i;
2682 }
2683 else
2684 {
2685 AssertBreakpoint();
2686 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));
2687 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
2688 }
2689 }
2690 else
2691 {
2692 /* this should not happen actually */
2693 drprintf((__FUNCTION__": failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)\n",pDst->hDeviceSpecificAllocation));
2694 Status = STATUS_INVALID_HANDLE;
2695 }
2696 }
2697 else
2698 {
2699 /* this should not happen actually */
2700 drprintf((__FUNCTION__": failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)\n",pSrc->hDeviceSpecificAllocation));
2701 Status = STATUS_INVALID_HANDLE;
2702 }
2703 }
2704 else
2705 {
2706 /* this should not happen actually */
2707 drprintf((__FUNCTION__": cbCmd too small!! (%d)\n", cbCmd));
2708 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
2709 }
2710
2711 }
2712 else
2713 {
2714 drprintf((__FUNCTION__": cmd NOT IMPLEMENTED!! Flags(0x%x)\n", pPresent->Flags.Value));
2715 AssertBreakpoint();
2716 }
2717
2718 dfprintf(("<== "__FUNCTION__ ", hContext(0x%x), Status(0x%x)\n", hContext, Status));
2719
2720 return Status;
2721}
2722
2723NTSTATUS
2724APIENTRY
2725DxgkDdiUpdateOverlay(
2726 CONST HANDLE hOverlay,
2727 CONST DXGKARG_UPDATEOVERLAY *pUpdateOverlay)
2728{
2729 dfprintf(("==> "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2730 AssertBreakpoint();
2731 dfprintf(("<== "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2732 return STATUS_NOT_IMPLEMENTED;
2733}
2734
2735NTSTATUS
2736APIENTRY
2737DxgkDdiFlipOverlay(
2738 CONST HANDLE hOverlay,
2739 CONST DXGKARG_FLIPOVERLAY *pFlipOverlay)
2740{
2741 dfprintf(("==> "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2742 AssertBreakpoint();
2743 dfprintf(("<== "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2744 return STATUS_NOT_IMPLEMENTED;
2745}
2746
2747NTSTATUS
2748APIENTRY
2749DxgkDdiDestroyOverlay(
2750 CONST HANDLE hOverlay)
2751{
2752 dfprintf(("==> "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2753 AssertBreakpoint();
2754 dfprintf(("<== "__FUNCTION__ ", hOverlay(0x%x)\n", hOverlay));
2755 return STATUS_NOT_IMPLEMENTED;
2756}
2757
2758/**
2759 * DxgkDdiCreateContext
2760 */
2761NTSTATUS
2762APIENTRY
2763DxgkDdiCreateContext(
2764 CONST HANDLE hDevice,
2765 DXGKARG_CREATECONTEXT *pCreateContext)
2766{
2767 /* DxgkDdiCreateContext should be made pageable */
2768 PAGED_CODE();
2769
2770 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2771
2772 NTSTATUS Status = STATUS_SUCCESS;
2773 PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)hDevice;
2774 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)vboxWddmMemAllocZero(sizeof (VBOXWDDM_CONTEXT));
2775
2776 pContext->pDevice = pDevice;
2777 pContext->EngineAffinity = pCreateContext->EngineAffinity;
2778 pContext->NodeOrdinal = pCreateContext->NodeOrdinal;
2779 if (pCreateContext->Flags.SystemContext)
2780 pContext->enmType = VBOXWDDM_CONTEXT_TYPE_SYSTEM;
2781 else
2782 {
2783 AssertBreakpoint(); /* we do not support custom contexts for now */
2784 drprintf((__FUNCTION__ ", we do not support custom contexts for now, hDevice (0x%x)\n", hDevice));
2785 }
2786
2787 pCreateContext->hContext = pContext;
2788 pCreateContext->ContextInfo.DmaBufferSize = VBOXWDDM_C_DMA_BUFFER_SIZE;
2789 pCreateContext->ContextInfo.DmaBufferSegmentSet = 0;
2790 pCreateContext->ContextInfo.DmaBufferPrivateDataSize = sizeof (VBOXWDDM_DMA_PRIVATE_DATA);
2791 pCreateContext->ContextInfo.AllocationListSize = VBOXWDDM_C_ALLOC_LIST_SIZE;
2792 pCreateContext->ContextInfo.PatchLocationListSize = VBOXWDDM_C_PATH_LOCATION_LIST_SIZE;
2793//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
2794//# error port to Win7 DDI
2795// //pCreateContext->ContextInfo.DmaBufferAllocationGroup = ???;
2796//#endif // DXGKDDI_INTERFACE_VERSION
2797
2798 dfprintf(("<== "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
2799
2800 return Status;
2801}
2802
2803NTSTATUS
2804APIENTRY
2805DxgkDdiDestroyContext(
2806 CONST HANDLE hContext)
2807{
2808 dfprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext));
2809 vboxWddmMemFree(hContext);
2810 dfprintf(("<== "__FUNCTION__ ", hContext(0x%x)\n", hContext));
2811 return STATUS_SUCCESS;
2812}
2813
2814NTSTATUS
2815APIENTRY
2816DxgkDdiLinkDevice(
2817 __in CONST PDEVICE_OBJECT PhysicalDeviceObject,
2818 __in CONST PVOID MiniportDeviceContext,
2819 __inout PLINKED_DEVICE LinkedDevice
2820 )
2821{
2822 drprintf(("==> "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
2823 AssertBreakpoint();
2824 drprintf(("<== "__FUNCTION__ ", MiniportDeviceContext(0x%x)\n", MiniportDeviceContext));
2825 return STATUS_NOT_IMPLEMENTED;
2826}
2827
2828NTSTATUS
2829APIENTRY
2830DxgkDdiSetDisplayPrivateDriverFormat(
2831 CONST HANDLE hAdapter,
2832 /*CONST*/ DXGKARG_SETDISPLAYPRIVATEDRIVERFORMAT* pSetDisplayPrivateDriverFormat
2833 )
2834{
2835 dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2836 AssertBreakpoint();
2837 dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
2838 return STATUS_SUCCESS;
2839}
2840
2841NTSTATUS
2842DriverEntry(
2843 IN PDRIVER_OBJECT DriverObject,
2844 IN PUNICODE_STRING RegistryPath
2845 )
2846{
2847 PAGED_CODE();
2848
2849 AssertBreakpoint();
2850
2851 drprintf(("VBoxVideoWddm::DriverEntry. Built %s %s\n", __DATE__, __TIME__));
2852
2853 DRIVER_INITIALIZATION_DATA DriverInitializationData = {'\0'};
2854
2855 if (! ARGUMENT_PRESENT(DriverObject) ||
2856 ! ARGUMENT_PRESENT(RegistryPath))
2857 {
2858 return STATUS_INVALID_PARAMETER;
2859 }
2860
2861 // Fill in the DriverInitializationData structure and call DxgkInitialize()
2862 DriverInitializationData.Version = DXGKDDI_INTERFACE_VERSION;
2863
2864 DriverInitializationData.DxgkDdiAddDevice = DxgkDdiAddDevice;
2865 DriverInitializationData.DxgkDdiStartDevice = DxgkDdiStartDevice;
2866 DriverInitializationData.DxgkDdiStopDevice = DxgkDdiStopDevice;
2867 DriverInitializationData.DxgkDdiRemoveDevice = DxgkDdiRemoveDevice;
2868 DriverInitializationData.DxgkDdiDispatchIoRequest = DxgkDdiDispatchIoRequest;
2869 DriverInitializationData.DxgkDdiInterruptRoutine = DxgkDdiInterruptRoutine;
2870 DriverInitializationData.DxgkDdiDpcRoutine = DxgkDdiDpcRoutine;
2871 DriverInitializationData.DxgkDdiQueryChildRelations = DxgkDdiQueryChildRelations;
2872 DriverInitializationData.DxgkDdiQueryChildStatus = DxgkDdiQueryChildStatus;
2873 DriverInitializationData.DxgkDdiQueryDeviceDescriptor = DxgkDdiQueryDeviceDescriptor;
2874 DriverInitializationData.DxgkDdiSetPowerState = DxgkDdiSetPowerState;
2875 DriverInitializationData.DxgkDdiNotifyAcpiEvent = DxgkDdiNotifyAcpiEvent;
2876 DriverInitializationData.DxgkDdiResetDevice = DxgkDdiResetDevice;
2877 DriverInitializationData.DxgkDdiUnload = DxgkDdiUnload;
2878 DriverInitializationData.DxgkDdiQueryInterface = DxgkDdiQueryInterface;
2879 DriverInitializationData.DxgkDdiControlEtwLogging = DxgkDdiControlEtwLogging;
2880
2881 DriverInitializationData.DxgkDdiQueryAdapterInfo = DxgkDdiQueryAdapterInfo;
2882 DriverInitializationData.DxgkDdiCreateDevice = DxgkDdiCreateDevice;
2883 DriverInitializationData.DxgkDdiCreateAllocation = DxgkDdiCreateAllocation;
2884 DriverInitializationData.DxgkDdiDestroyAllocation = DxgkDdiDestroyAllocation ;
2885
2886 DriverInitializationData.DxgkDdiDescribeAllocation = DxgkDdiDescribeAllocation;
2887 DriverInitializationData.DxgkDdiGetStandardAllocationDriverData = DxgkDdiGetStandardAllocationDriverData;
2888
2889 DriverInitializationData.DxgkDdiAcquireSwizzlingRange = DxgkDdiAcquireSwizzlingRange;
2890 DriverInitializationData.DxgkDdiReleaseSwizzlingRange = DxgkDdiReleaseSwizzlingRange;
2891
2892 DriverInitializationData.DxgkDdiPatch = DxgkDdiPatch;
2893
2894 DriverInitializationData.DxgkDdiSubmitCommand = DxgkDdiSubmitCommand;
2895 DriverInitializationData.DxgkDdiPreemptCommand = DxgkDdiPreemptCommand;
2896 DriverInitializationData.DxgkDdiBuildPagingBuffer = DxgkDdiBuildPagingBuffer;
2897
2898 DriverInitializationData.DxgkDdiSetPalette = DxgkDdiSetPalette;
2899 DriverInitializationData.DxgkDdiSetPointerPosition = DxgkDdiSetPointerPosition;
2900 DriverInitializationData.DxgkDdiSetPointerShape = DxgkDdiSetPointerShape;
2901
2902 DriverInitializationData.DxgkDdiResetFromTimeout = DxgkDdiResetFromTimeout;
2903
2904 DriverInitializationData.DxgkDdiEscape = DxgkDdiEscape;
2905
2906 DriverInitializationData.DxgkDdiCollectDbgInfo = DxgkDdiCollectDbgInfo;
2907
2908 DriverInitializationData.DxgkDdiQueryCurrentFence = DxgkDdiQueryCurrentFence;
2909
2910 DriverInitializationData.DxgkDdiIsSupportedVidPn = DxgkDdiIsSupportedVidPn;
2911 DriverInitializationData.DxgkDdiRecommendFunctionalVidPn = DxgkDdiRecommendFunctionalVidPn;
2912 DriverInitializationData.DxgkDdiEnumVidPnCofuncModality = DxgkDdiEnumVidPnCofuncModality;
2913 DriverInitializationData.DxgkDdiSetVidPnSourceAddress = DxgkDdiSetVidPnSourceAddress;
2914 DriverInitializationData.DxgkDdiSetVidPnSourceVisibility = DxgkDdiSetVidPnSourceVisibility;
2915 DriverInitializationData.DxgkDdiCommitVidPn = DxgkDdiCommitVidPn;
2916 DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = DxgkDdiUpdateActiveVidPnPresentPath;
2917
2918 DriverInitializationData.DxgkDdiRecommendMonitorModes = DxgkDdiRecommendMonitorModes;
2919 DriverInitializationData.DxgkDdiRecommendVidPnTopology = DxgkDdiRecommendVidPnTopology;
2920
2921 DriverInitializationData.DxgkDdiGetScanLine = DxgkDdiGetScanLine;
2922
2923 DriverInitializationData.DxgkDdiStopCapture = DxgkDdiStopCapture;
2924
2925 DriverInitializationData.DxgkDdiControlInterrupt = DxgkDdiControlInterrupt;
2926
2927 DriverInitializationData.DxgkDdiCreateOverlay = DxgkDdiCreateOverlay;
2928
2929 DriverInitializationData.DxgkDdiDestroyDevice = DxgkDdiDestroyDevice;
2930
2931 DriverInitializationData.DxgkDdiOpenAllocation = DxgkDdiOpenAllocation;
2932 DriverInitializationData.DxgkDdiCloseAllocation = DxgkDdiCloseAllocation;
2933
2934 DriverInitializationData.DxgkDdiRender = DxgkDdiRender;
2935 DriverInitializationData.DxgkDdiPresent = DxgkDdiPresent;
2936
2937 DriverInitializationData.DxgkDdiUpdateOverlay = DxgkDdiUpdateOverlay;
2938 DriverInitializationData.DxgkDdiFlipOverlay = DxgkDdiFlipOverlay;
2939 DriverInitializationData.DxgkDdiDestroyOverlay = DxgkDdiDestroyOverlay;
2940
2941 DriverInitializationData.DxgkDdiCreateContext = DxgkDdiCreateContext;
2942 DriverInitializationData.DxgkDdiDestroyContext = DxgkDdiDestroyContext;
2943
2944// DriverInitializationData.DxgkDdiLinkDevice = DxgkDdiLinkDevice;
2945 DriverInitializationData.DxgkDdiLinkDevice = NULL; /* not needed */
2946 DriverInitializationData.DxgkDdiSetDisplayPrivateDriverFormat = DxgkDdiSetDisplayPrivateDriverFormat;
2947
2948//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
2949//# error port to Win7 DDI
2950// DriverInitializationData.DxgkDdiRenderKm = DxgkDdiRenderKm;
2951// DriverInitializationData.DxgkDdiRestartFromTimeout = DxgkDdiRestartFromTimeout;
2952// DriverInitializationData.DxgkDdiSetVidPnSourceVisibility = DxgkDdiSetVidPnSourceVisibility;
2953// DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = DxgkDdiUpdateActiveVidPnPresentPath;
2954// DriverInitializationData.DxgkDdiQueryVidPnHWCapability = DxgkDdiQueryVidPnHWCapability;
2955//#endif
2956
2957 return DxgkInitialize(DriverObject,
2958 RegistryPath,
2959 &DriverInitializationData);
2960}
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