Skip to content

Commit a448f1a

Browse files
authored
Merge pull request #1 from intel/SudharsanRaman_Dev1
ZC v540 : Multi monitor support, logging and QEMU edid caching
2 parents 8856ca7 + f4243ef commit a448f1a

31 files changed

+1003
-540
lines changed

DVApp.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#===========================================================================
22
#DVApp.ps1
33
#----------------------------------------------------------------------------
4-
#* Copyright © 2021 Intel Corporation
4+
#Copyright (C) 2021 Intel Corporation
55
#SPDX-License-Identifier: MIT
66
#--------------------------------------------------------------------------*/
77

@@ -57,7 +57,12 @@ function create_node()
5757
Write-Host "Turning off MSFT Path"
5858

5959
& ".\DVEnabler.exe"
60-
return "SUCCESS"
60+
if ($LASTEXITCODE -eq 0) {
61+
return "SUCCESS"
62+
} else {
63+
Write-Host "DVEnabler failed. DVServerUMD has not taken over MSBDA!"
64+
return "FAIL"
65+
}
6166
}
6267

6368
#This API will execute the setup/run commands

DVInstaller.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#===========================================================================
22
#DVInstaller.ps1
33
#----------------------------------------------------------------------------
4-
#* Copyright © 2021 Intel Corporation
4+
#Copyright (C) 2021 Intel Corporation
55
#SPDX-License-Identifier: MIT
66
#--------------------------------------------------------------------------*/
77

DVServerKMD/DVServerKMD.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
9696
<WppKernelMode>true</WppKernelMode>
9797
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.19041.0\um;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.19041.0\km;..\VirtIO;..\EDIDParser;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
98+
<PreprocessorDefinitions>_WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);__DEBUG</PreprocessorDefinitions>
9899
</ClCompile>
99100
<Link>
100101
<AdditionalDependencies>virtiolib.lib;edidparser.lib;%(AdditionalDependencies)</AdditionalDependencies>

DVServerKMD/DVServerKMD_Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*===========================================================================
22
; DVServerKMD_Version.txt
33
;----------------------------------------------------------------------------
4-
; * Copyright 2021 Intel Corporation
4+
; Copyright (C) 2021 Intel Corporation
55
; SPDX-License-Identifier: BSD-3-Clause
66
;
77
; File Description:

DVServerKMD/Public.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ DEFINE_GUID (GUID_DEVINTERFACE_DVServerKMD,
2424
0x1c514918,0xa855,0x460a,0x97,0xda,0xed,0x69,0x1d,0xd5,0x63,0xcf);
2525
// {1c514918-a855-460a-97da-ed691dd563cf}
2626

27-
#define IOCTL_DVSERVER_FRAME_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
28-
#define IOCTL_DVSERVER_CURSOR_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
29-
#define IOCTL_DVSERVER_GET_EDID_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
30-
#define IOCTL_DVSERVER_SET_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
31-
#define IOCTL_DVSERVER_GENERAL CTL_CODE(FILE_DEVICE_UNKNOWN, 0x811, METHOD_BUFFERED, FILE_ANY_ACCESS)
32-
#define IOCTL_DVSERVER_TEST_IMAGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x812, METHOD_BUFFERED, FILE_ANY_ACCESS)
27+
#define MAX_SCAN_OUT 4
28+
#define IOCTL_DVSERVER_FRAME_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
29+
#define IOCTL_DVSERVER_CURSOR_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
30+
#define IOCTL_DVSERVER_GET_EDID_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
31+
#define IOCTL_DVSERVER_SET_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
32+
#define IOCTL_DVSERVER_GENERAL CTL_CODE(FILE_DEVICE_UNKNOWN, 0x811, METHOD_BUFFERED, FILE_ANY_ACCESS)
33+
#define IOCTL_DVSERVER_TEST_IMAGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x812, METHOD_BUFFERED, FILE_ANY_ACCESS)
34+
#define IOCTL_DVSERVER_GET_TOTAL_SCREENS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x813, METHOD_BUFFERED, FILE_ANY_ACCESS)
3335

3436
typedef struct FrameMetaData
3537
{
@@ -41,6 +43,7 @@ typedef struct FrameMetaData
4143
UINT16 bitrate;
4244
void* addr;
4345
unsigned short refresh_rate;
46+
unsigned int screen_num;
4447

4548
}FrameMetaData;
4649

@@ -68,9 +71,14 @@ struct edid_info
6871
{
6972
unsigned char edid_data[256];
7073
unsigned int mode_size;
74+
unsigned int screen_num;
7175
mode_info* mode_list;
7276
};
7377

78+
struct screen_info
79+
{
80+
unsigned int total_screens;
81+
};
7482

7583
struct KMDF_IOCTL_Response
7684
{

DVServerKMD/Queue.cpp

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*++
22
*
3-
* Copyright © 2021 Intel Corporation
3+
* Copyright (C) 2021 Intel Corporation
44
* SPDX-License-Identifier: MS-PL
55
66
Module Name:
@@ -32,9 +32,6 @@ extern "C" {
3232
#pragma alloc_text (PAGE, DVServerKMDQueueInitialize)
3333
#endif
3434

35-
extern GPU_DISP_MODE_EXT gpu_disp_mode_ext[MAX_MODELIST_SIZE];
36-
extern output_modelist mode_list;
37-
3835
NTSTATUS
3936
DVServerKMDQueueInitialize(
4037
_In_ WDFDEVICE Device
@@ -154,8 +151,10 @@ Return Value:
154151
// method retrieves an I/O request's input buffer.
155152
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfrequest/nf-wdfrequest-wdfrequestretrieveinputbuffer
156153
status = IoctlRequestPresentFb(pDeviceContext, InputBufferLength, OutputBufferLength, Request, &bytesReturned);
157-
if (status != STATUS_SUCCESS)
154+
if (status != STATUS_SUCCESS) {
155+
ERR("IoctlRequestPresentFb failed with status = %d\n", status);
158156
return;
157+
}
159158
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&resp, &bufSize);
160159
if (!NT_SUCCESS(status)) {
161160
ERR("Couldn't retrieve Output buffer\n");
@@ -232,6 +231,11 @@ Return Value:
232231
resp->retval = DVSERVERKMD_SUCCESS;
233232
WdfRequestSetInformation(Request, sizeof(struct KMDF_IOCTL_Response));
234233
break;
234+
case IOCTL_DVSERVER_GET_TOTAL_SCREENS:
235+
status = IoctlRequestTotalScreens(pDeviceContext, InputBufferLength, OutputBufferLength, Request, &bytesReturned);
236+
if (status != STATUS_SUCCESS)
237+
return;
238+
break;
235239
}
236240

237241
WdfRequestComplete(Request, STATUS_SUCCESS);
@@ -341,29 +345,40 @@ static NTSTATUS IoctlRequestSetMode(
341345
return STATUS_INVALID_USER_BUFFER;
342346
}
343347

348+
if (ptr->screen_num >= MAX_SCAN_OUT) {
349+
ERR("Screen number provided by UMD: %d is greater than or equal to the maximum supported: %d by the KMD\n",
350+
ptr->screen_num, MAX_SCAN_OUT);
351+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
352+
return status;
353+
}
354+
344355
CURRENT_MODE tempCurrentMode = { 0 };
345356
tempCurrentMode.DispInfo.Width = ptr->width;
346357
tempCurrentMode.DispInfo.Height = ptr->height;
347358
tempCurrentMode.DispInfo.Pitch = ptr->pitch;
359+
tempCurrentMode.DispInfo.TargetId = ptr->screen_num;
348360
tempCurrentMode.DispInfo.ColorFormat = (D3DDDIFORMAT) ptr->format;
349361
tempCurrentMode.FrameBuffer.Ptr = (BYTE*)ptr->addr;
350362

351363
status = pAdapter->SetCurrentModeExt(&tempCurrentMode);
352-
if (status != STATUS_SUCCESS)
364+
if (status != STATUS_SUCCESS) {
365+
ERR("SetCurrentModeExt failed with status = %d\n", status);
353366
return STATUS_UNSUCCESSFUL;
367+
}
354368

355369
// BlackOutScreen
356370
CURRENT_MODE CurrentMode = { 0 };
357371
CurrentMode.DispInfo.Width = ptr->width;
358372
CurrentMode.DispInfo.Height = ptr->height;
359373
CurrentMode.DispInfo.Pitch = ptr->pitch;
360-
CurrentMode.FrameBuffer.Ptr = pAdapter->m_FrameSegment.GetFbVAddr();
374+
CurrentMode.DispInfo.TargetId = ptr->screen_num;
375+
CurrentMode.FrameBuffer.Ptr = pAdapter->GetFbVAddr(ptr->screen_num);
361376
CurrentMode.Flags.FrameBufferIsActive = 1;
362377

363378
pAdapter->BlackOutScreen(&CurrentMode);
364379

365380
if (tempCurrentMode.FrameBuffer.Ptr) {
366-
pAdapter->m_FrameSegment.Close();
381+
pAdapter->Close(ptr->screen_num);
367382
}
368383

369384
return STATUS_SUCCESS;
@@ -387,7 +402,7 @@ static NTSTATUS IoctlRequestPresentFb(
387402
(VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : 0);
388403

389404
if (!pAdapter) {
390-
ERR("Coudlnt' find adapter\n");
405+
ERR("Couldnt' find adapter\n");
391406
return status;
392407
}
393408

@@ -398,15 +413,24 @@ static NTSTATUS IoctlRequestPresentFb(
398413
return STATUS_INVALID_USER_BUFFER;
399414
}
400415

416+
if (ptr->screen_num >= MAX_SCAN_OUT) {
417+
ERR("Screen number provided by UMD: %d is greater than or equal to the maximum supported: %d by the KMD\n",
418+
ptr->screen_num, MAX_SCAN_OUT);
419+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
420+
return status;
421+
}
401422
status = pAdapter->ExecutePresentDisplayZeroCopy(
402423
(BYTE*)ptr->addr,
403424
ptr->bitrate,
404425
ptr->pitch,
405426
ptr->width,
406-
ptr->height);
427+
ptr->height,
428+
ptr->screen_num);
407429

408-
if (status != STATUS_SUCCESS)
430+
if (status != STATUS_SUCCESS) {
431+
ERR("ExecutePresentDisplayZeroCopy failed with status = %d\n", status);
409432
return STATUS_UNSUCCESSFUL;
433+
}
410434

411435
return STATUS_SUCCESS;
412436
}
@@ -446,36 +470,78 @@ static NTSTATUS IoctlRequestEdid(
446470
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
447471
return status;
448472
}
473+
474+
if (edata->screen_num >= MAX_SCAN_OUT) {
475+
ERR("Screen number provided by UMD: %d is greater than or equal to the maximum supported: %d by the KMD\n",
476+
edata->screen_num, MAX_SCAN_OUT);
477+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
478+
return status;
479+
}
480+
449481
if (edata->mode_size == 0) {
450482
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&edata, &bufSize);
451483
if (!NT_SUCCESS(status)) {
452484
ERR("Couldn't retrieve Output buffer\n");
453485
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
454486
return status;
455487
}
488+
456489
//Return value from the KMDF DVServer
457-
if (mode_list.modelist_size != 0) {
458-
edata->mode_size = mode_list.modelist_size;
490+
if(pAdapter->GetModeListSize(edata->screen_num) != 0) {
491+
edata->mode_size = pAdapter->GetModeListSize(edata->screen_num);
459492
} else {
460493
edata->mode_size = QEMU_MODELIST_SIZE;
461494
}
462495
WdfRequestSetInformation(Request, sizeof(struct edid_info));
463-
} else if ((edata->mode_size == mode_list.modelist_size) || (edata->mode_size == QEMU_MODELIST_SIZE)) {
496+
} else if ((edata->mode_size == pAdapter->GetModeListSize(edata->screen_num)) || (edata->mode_size == QEMU_MODELIST_SIZE)) {
464497
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&edata, &bufSize);
465498
if (!NT_SUCCESS(status)) {
466499
ERR("Couldn't retrieve Output buffer\n");
467500
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
468501
return status;
469502
}
470503
//Return value from the KMDF DVServer
471-
RtlCopyMemory(edata->edid_data, pAdapter->GetEdidData(0), EDID_V1_BLOCK_SIZE);
504+
RtlCopyMemory(edata->edid_data, pAdapter->GetEdidData(edata->screen_num), EDID_V1_BLOCK_SIZE);
472505

473-
for (unsigned int i = 0; i < edata->mode_size; i++) {
474-
edata->mode_list[i].width = gpu_disp_mode_ext[i].XResolution;
475-
edata->mode_list[i].height = gpu_disp_mode_ext[i].YResolution;
476-
edata->mode_list[i].refreshrate = gpu_disp_mode_ext[i].refresh;
477-
}
506+
pAdapter->CopyResolution(edata->screen_num, edata);
478507
WdfRequestSetInformation(Request, sizeof(struct edid_info));
479508
}
480509
return STATUS_SUCCESS;
481510
}
511+
512+
static NTSTATUS IoctlRequestTotalScreens(
513+
const PDEVICE_CONTEXT DeviceContext,
514+
const size_t InputBufferLength,
515+
const size_t OutputBufferLength,
516+
const WDFREQUEST Request,
517+
size_t* BytesReturned)
518+
{
519+
UNREFERENCED_PARAMETER(DeviceContext);
520+
UNREFERENCED_PARAMETER(InputBufferLength);
521+
UNREFERENCED_PARAMETER(OutputBufferLength);
522+
UNREFERENCED_PARAMETER(BytesReturned);
523+
524+
NTSTATUS status = STATUS_UNSUCCESSFUL;
525+
struct screen_info* mdata = NULL;
526+
size_t bufSize;
527+
528+
VioGpuAdapterLite* pAdapter =
529+
(VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : 0);
530+
531+
if (!pAdapter) {
532+
ERR("Coudlnt' find adapter\n");
533+
return status;
534+
}
535+
536+
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&mdata, &bufSize);
537+
if (!NT_SUCCESS(status)) {
538+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
539+
return status;
540+
541+
}
542+
543+
mdata->total_screens = pAdapter->GetNumScreens();
544+
WdfRequestSetInformation(Request, sizeof(struct screen_info));
545+
546+
return STATUS_SUCCESS;
547+
}

DVServerKMD/Queue.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ static NTSTATUS IoctlRequestEdid(
5454
const WDFREQUEST Request,
5555
size_t* BytesReturned);
5656

57+
static NTSTATUS IoctlRequestTotalScreens(
58+
const PDEVICE_CONTEXT DeviceContext,
59+
const size_t InputBufferLength,
60+
const size_t OutputBufferLength,
61+
const WDFREQUEST Request,
62+
size_t * BytesReturned);
63+
5764
//
5865
// Events from the IoQueue object
5966
//

DVServerKMD/debug.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*===========================================================================
2+
; debug.h
3+
;----------------------------------------------------------------------------
4+
; Copyright (C) 2021 Intel Corporation
5+
; SPDX-License-Identifier: BSD-3-Clause
6+
;
7+
; File Description:
8+
; This file declares and defines the devserverkmd logging macros
9+
;--------------------------------------------------------------------------*/
10+
111
#ifndef _DEBUG_H
212
#define _DEBUG_H
313

DVServerKMD/edid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*===========================================================================
22
; edid.h
33
;----------------------------------------------------------------------------
4-
; * Copyright © 2021 Intel Corporation
4+
; Copyright (C) 2021 Intel Corporation
55
; SPDX-License-Identifier: BSD-3-Clause
66
;--------------------------------------------------------------------------*/
77

DVServerKMD/helper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ extern "C" {
8080
#include <evntrace.h>
8181
}
8282

83-
#define MAX_CHILDREN 4
8483
#define MAX_VIEWS 1
8584
#define BITS_PER_BYTE 8
8685

0 commit comments

Comments
 (0)