Skip to content

Commit dab92a9

Browse files
sraman4malayaku
authored andcommitted
ZC v912 : HPD feature enablement and DTD EDID support
1 parent 6f90297 commit dab92a9

26 files changed

+799
-212
lines changed

DVInstaller.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function check_executables()
2121
(is_present("DVServer\dvserverkmd.cat") -eq $true) -and
2222
(is_present("DVServer\DVServerKMD.inf") -eq $true) -and
2323
(is_present("DVServer\DVServerKMD.sys") -eq $true) -and
24-
(is_present("DVEnabler.exe") -eq $true) -and
24+
(is_present("DVEnabler.dll") -eq $true) -and
2525
(is_present("GraphicsDriver\Graphics\iigd_dch.inf") -eq $true)){
2626
Write-Host "Setup files present"
2727
return "SUCCESS"
@@ -53,8 +53,29 @@ else {
5353
}
5454
}
5555

56-
Write-Host "Running DVEnabler..."
57-
& ".\DVEnabler.exe"
56+
Write-Host "creating DVEnabler Task and running it as service ..."
57+
58+
Remove-Item -path C:\Windows\System32\DVEnabler.dll
59+
60+
rundll32.exe DVEnabler.dll,dvenabler_init
61+
while($true){
62+
$DVE = tasklist /m | findstr "DVEnabler.dll"
63+
if ($DVE) {
64+
Write-Host "DvEnabler started as service ."
65+
break
66+
}
67+
else{
68+
Write-Host " Dvenabler not yet started. Please wait..."
69+
continue
70+
}
71+
}
72+
73+
cp DVEnabler.dll C:\Windows\System32
74+
unregister-scheduledtask -TaskName "DVEnabler" -confirm:$false -ErrorAction SilentlyContinue
75+
$ac = New-ScheduledTaskAction -Execute "rundll32.exe" -Argument "C:\Windows\System32\DVEnabler.dll,dvenabler_init"
76+
$tr = New-ScheduledTaskTrigger -AtLogOn
77+
$pr = New-ScheduledTaskPrincipal -Groupid "INTERACTIVE"
78+
Register-ScheduledTask -TaskName "DVEnabler" -Trigger $tr -TaskPath "\Microsoft\Windows\DVEnabler" -Action $ac -Principal $pr
5879
if ($LASTEXITCODE -eq 0) {
5980
Write-Host "DVEnabler Success. DVServerUMD has taken over MSBDA!"
6081
} else {

DVServerKMD/DVServerKMD_Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
; This file will have the DVServerKMD version
99
;--------------------------------------------------------------------------*/
1010

11-
DVServerKMD_Version = 3.4.0
11+
DVServerKMD_Version = 4.0.0

DVServerKMD/Public.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ DEFINE_GUID (GUID_DEVINTERFACE_DVServerKMD,
2929
#define IOCTL_DVSERVER_CURSOR_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
3030
#define IOCTL_DVSERVER_GET_EDID_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
3131
#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)
3332
#define IOCTL_DVSERVER_TEST_IMAGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x812, METHOD_BUFFERED, FILE_ANY_ACCESS)
3433
#define IOCTL_DVSERVER_GET_TOTAL_SCREENS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x813, METHOD_BUFFERED, FILE_ANY_ACCESS)
34+
#define IOCTL_DVSERVER_HP_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x814, METHOD_BUFFERED, FILE_ANY_ACCESS)
3535

3636
typedef struct FrameMetaData
3737
{
@@ -80,6 +80,12 @@ struct screen_info
8080
unsigned int total_screens;
8181
};
8282

83+
struct hp_info
84+
{
85+
HANDLE event;
86+
bool screen_present[MAX_SCAN_OUT];
87+
};
88+
8389
struct KMDF_IOCTL_Response
8490
{
8591
UINT16 retval;

DVServerKMD/Queue.cpp

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ Return Value:
212212
WdfRequestSetInformation(Request, sizeof(struct KMDF_IOCTL_Response));
213213
break;
214214

215-
case IOCTL_DVSERVER_GENERAL:
216-
// << TODO>>
217-
break;
218-
219215
case IOCTL_DVSERVER_TEST_IMAGE:
220216
status = IoctlRequestPresentFb(pDeviceContext, InputBufferLength, OutputBufferLength, Request, &bytesReturned);
221217
if (status != STATUS_SUCCESS)
@@ -236,6 +232,11 @@ Return Value:
236232
if (status != STATUS_SUCCESS)
237233
return;
238234
break;
235+
case IOCTL_DVSERVER_HP_EVENT:
236+
status = IoctlRequestHPEventInfo(pDeviceContext, InputBufferLength, OutputBufferLength, Request, &bytesReturned);
237+
if (status != STATUS_SUCCESS)
238+
return;
239+
break;
239240
}
240241

241242
WdfRequestComplete(Request, STATUS_SUCCESS);
@@ -516,7 +517,6 @@ static NTSTATUS IoctlRequestTotalScreens(
516517
const WDFREQUEST Request,
517518
size_t* BytesReturned)
518519
{
519-
UNREFERENCED_PARAMETER(DeviceContext);
520520
UNREFERENCED_PARAMETER(InputBufferLength);
521521
UNREFERENCED_PARAMETER(OutputBufferLength);
522522
UNREFERENCED_PARAMETER(BytesReturned);
@@ -529,19 +529,61 @@ static NTSTATUS IoctlRequestTotalScreens(
529529
(VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : 0);
530530

531531
if (!pAdapter) {
532-
ERR("Coudlnt' find adapter\n");
532+
ERR("Couldn't find adapter\n");
533533
return status;
534534
}
535535

536536
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&mdata, &bufSize);
537537
if (!NT_SUCCESS(status)) {
538538
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
539539
return status;
540-
541540
}
542541

543542
mdata->total_screens = pAdapter->GetNumScreens();
544543
WdfRequestSetInformation(Request, sizeof(struct screen_info));
545544

545+
return STATUS_SUCCESS;
546+
}
547+
548+
static NTSTATUS IoctlRequestHPEventInfo(
549+
const PDEVICE_CONTEXT DeviceContext,
550+
const size_t InputBufferLength,
551+
const size_t OutputBufferLength,
552+
const WDFREQUEST Request,
553+
size_t* BytesReturned)
554+
{
555+
UNREFERENCED_PARAMETER(DeviceContext);
556+
UNREFERENCED_PARAMETER(InputBufferLength);
557+
UNREFERENCED_PARAMETER(OutputBufferLength);
558+
UNREFERENCED_PARAMETER(Request);
559+
UNREFERENCED_PARAMETER(BytesReturned);
560+
561+
NTSTATUS status = STATUS_UNSUCCESSFUL;
562+
struct hp_info* info = NULL;
563+
size_t bufSize;
564+
565+
status = WdfRequestRetrieveInputBuffer(Request, 0, (PVOID*)&info, &bufSize);
566+
if (!NT_SUCCESS(status)) {
567+
ERR("Couldn't retrieve Input buffer\n");
568+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
569+
return status;
570+
}
571+
572+
VioGpuAdapterLite* pAdapter =
573+
(VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : 0);
574+
575+
if (!pAdapter) {
576+
ERR("Couldn't find adapter\n");
577+
return status;
578+
}
579+
status = WdfRequestRetrieveOutputBuffer(Request, 0, (PVOID*)&info, &bufSize);
580+
if (!NT_SUCCESS(status)) {
581+
WdfRequestComplete(Request, STATUS_INSUFFICIENT_RESOURCES);
582+
return status;
583+
}
584+
pAdapter->SetEvent(info->event);
585+
pAdapter->FillPresentStatus(info);
586+
WdfRequestSetInformation(Request, sizeof(struct hp_info));
587+
546588
return STATUS_SUCCESS;
547589
}

DVServerKMD/Queue.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ static NTSTATUS IoctlRequestTotalScreens(
6161
const WDFREQUEST Request,
6262
size_t * BytesReturned);
6363

64+
static NTSTATUS IoctlRequestHPEventInfo(
65+
const PDEVICE_CONTEXT DeviceContext,
66+
const size_t InputBufferLength,
67+
const size_t OutputBufferLength,
68+
const WDFREQUEST Request,
69+
size_t* BytesReturned);
70+
6471
//
6572
// Events from the IoQueue object
6673
//

DVServerKMD/viogpulite.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ScreenInfo::ScreenInfo()
6969
mode_list.modelist_size = 0;
7070
m_pFrameBuf = NULL;
7171
m_FlushCount = 0;
72+
enabled = FALSE;
7273
}
7374

7475
ScreenInfo::~ScreenInfo()
@@ -109,12 +110,16 @@ VioGpuAdapterLite::VioGpuAdapterLite(_In_ PVOID pvDeviceContext) : IVioGpuAdapte
109110
m_bStopWorkThread = FALSE;
110111
m_pWorkThread = NULL;
111112
m_bBlobSupported = FALSE;
113+
hpd_event = NULL;
112114
}
113115

114116
VioGpuAdapterLite::~VioGpuAdapterLite(void)
115117
{
116118
PAGED_CODE();
117119
TRACING();
120+
if (hpd_event) {
121+
ObDereferenceObject(hpd_event);
122+
}
118123
VioGpuAdapterLiteClose();
119124
HWClose();
120125
m_Id = 0;
@@ -750,7 +755,8 @@ BOOLEAN VioGpuAdapterLite::GetDisplayInfo(UINT32 screen_num)
750755
ULONG yres = 0;
751756

752757
if (m_CtrlQueue.AskDisplayInfo(&vbuf, &m_screen[screen_num].m_DisplayInfoEvent)) {
753-
m_CtrlQueue.GetDisplayInfo(vbuf, screen_num, &xres, &yres);
758+
m_screen[screen_num].enabled = m_CtrlQueue.GetDisplayInfo(vbuf, screen_num, &xres, &yres);
759+
DBGPRINT("Screen %d status = %s\n", screen_num, (m_screen[screen_num].enabled) ? "Enabled" : "Disabled");
754760
m_CtrlQueue.ReleaseBuffer(vbuf);
755761
if (xres && yres) {
756762
DBGPRINT("(%dx%d)\n", xres, yres);
@@ -824,7 +830,7 @@ void VioGpuAdapterLite::AddEdidModes(UINT32 screen_num)
824830
}
825831
}
826832
else {
827-
for (unsigned int i = 0; i < QEMU_MODELIST_SIZE; i++) {
833+
for (unsigned int i = 0; i < m_screen[screen_num].mode_list.modelist_size; i++) {
828834
m_screen[screen_num].gpu_disp_mode_ext[i].XResolution = (USHORT)m_screen[screen_num].mode_list.modelist[i].width;
829835
m_screen[screen_num].gpu_disp_mode_ext[i].YResolution = (USHORT)m_screen[screen_num].mode_list.modelist[i].height;
830836
m_screen[screen_num].gpu_disp_mode_ext[i].refresh = m_screen[screen_num].mode_list.modelist[i].refresh_rate;
@@ -1055,6 +1061,10 @@ void VioGpuAdapterLite::ConfigChanged(void)
10551061
for (UINT32 i = 0; i < m_u32NumScanouts; i++) {
10561062
GetDisplayInfo(i);
10571063
}
1064+
if (hpd_event) {
1065+
DBGPRINT("Sending Hot Plug event to UMD\n");
1066+
KeSetEvent(hpd_event, IO_NO_INCREMENT, FALSE);
1067+
}
10581068
events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
10591069
virtio_set_config(&m_VioDev, FIELD_OFFSET(GPU_CONFIG, events_clear),
10601070
&events_clear, sizeof(m_u32NumScanouts));
@@ -1362,4 +1372,24 @@ BOOLEAN VioGpuAdapterLite::GpuObjectAttach(UINT res_id, VioGpuObj* obj, ULONGLON
13621372
return TRUE;
13631373
}
13641374

1375+
VOID VioGpuAdapterLite::SetEvent(HANDLE event)
1376+
{
1377+
NTSTATUS status;
1378+
/* If the UMD has provided us with an event and we don't have it initialized already */
1379+
if (event && !hpd_event) {
1380+
status = ObReferenceObjectByHandle(event, SYNCHRONIZE | EVENT_MODIFY_STATE,
1381+
*ExEventObjectType, UserMode, (PVOID * ) &hpd_event, NULL);
1382+
if (status != STATUS_SUCCESS) {
1383+
ERR("Couldn't retrieve event from handle. Error is %d\n", status);
1384+
}
1385+
}
1386+
}
1387+
1388+
VOID VioGpuAdapterLite::FillPresentStatus(struct hp_info* info)
1389+
{
1390+
for (UINT32 i = 0; i < m_u32NumScanouts; i++) {
1391+
info->screen_present[i] = m_screen[i].enabled;
1392+
}
1393+
}
1394+
13651395
PAGED_CODE_SEG_END

DVServerKMD/viogpulite.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ScreenInfo {
9494
VioGpuMemSegment m_FrameSegment;
9595
VioGpuObj* m_pFrameBuf;
9696
BOOL m_FlushCount;
97+
BOOL enabled;
9798

9899
public:
99100
ScreenInfo();
@@ -166,19 +167,20 @@ class VioGpuAdapterLite :
166167
return m_Flags.HardwareInit;
167168
}
168169
UINT32 GetNumScreens() { return m_u32NumScanouts; }
169-
UINT32 GetModeListSize(UINT32 screen_num) { return m_screen[screen_num].mode_list.modelist_size; }
170+
UINT32 GetModeListSize(UINT32 screen_num) { return m_screen[screen_num].mode_list.modelist_size; }
170171
VOID CopyResolution(UINT32 screen_num, struct edid_info* edata);
171172
PVOID GetFbVAddr(UINT32 screen_num) { return m_screen[screen_num].m_FrameSegment.GetFbVAddr(); }
172173
VOID Close(UINT32 screen_num) { m_screen[screen_num].m_FrameSegment.Close(); }
174+
PBYTE GetEdidData(UINT Idx);
175+
VOID FillPresentStatus(struct hp_info* info);
176+
VOID SetEvent(HANDLE event);
177+
173178
private:
174179

175180
void SetHardwareInit(BOOLEAN init)
176181
{
177182
m_Flags.HardwareInit = init;
178183
}
179-
180-
protected:
181-
private:
182184
NTSTATUS VioGpuAdapterLiteInit();
183185
void VioGpuAdapterLiteClose(void);
184186
NTSTATUS GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo);
@@ -199,8 +201,6 @@ class VioGpuAdapterLite :
199201
void ConfigChanged(void);
200202
NTSTATUS VirtIoDeviceInit(void);
201203
DEVICE_STATUS_FLAG m_Flags;
202-
203-
private:
204204
VirtIODevice m_VioDev;
205205
CPciResources m_PciResources;
206206
UINT64 m_u64HostFeatures;
@@ -215,12 +215,10 @@ class VioGpuAdapterLite :
215215
VioGpuMemSegment m_CursorSegment;
216216
volatile ULONG m_PendingWorks;
217217
KEVENT m_ConfigUpdateEvent;
218-
219218
PETHREAD m_pWorkThread;
220219
BOOLEAN m_bStopWorkThread;
221220
CURRENT_MODE m_CurrentModeInfo;
222221
BOOLEAN m_bBlobSupported;
223-
public:
224-
PBYTE GetEdidData(UINT Idx);
222+
PKEVENT hpd_event;
225223
};
226224

0 commit comments

Comments
 (0)