mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 10:46:58 +00:00
[WIN32K] Move detection of available display devices a new fonction EngpUpdateGraphicsDeviceList
- rewrite InitVideo() to call this new function - also call it at the start of UserEnumDisplayDevices, to detect new potential devices
This commit is contained in:
parent
b5966977ac
commit
6739fb1bc3
4 changed files with 95 additions and 82 deletions
|
@ -32,6 +32,84 @@ InitDeviceImpl(VOID)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
EngpUpdateGraphicsDeviceList(VOID)
|
||||||
|
{
|
||||||
|
ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
|
||||||
|
WCHAR awcDeviceName[20];
|
||||||
|
WCHAR awcBuffer[256];
|
||||||
|
NTSTATUS Status;
|
||||||
|
PGRAPHICS_DEVICE pGraphicsDevice;
|
||||||
|
ULONG cbValue;
|
||||||
|
HKEY hkey;
|
||||||
|
|
||||||
|
/* Open the key for the adapters */
|
||||||
|
Status = RegOpenKey(L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO", &hkey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key:0x%lx\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the name of the VGA adapter */
|
||||||
|
cbValue = sizeof(awcDeviceName);
|
||||||
|
Status = RegQueryValue(hkey, L"VgaCompatible", REG_SZ, awcDeviceName, &cbValue);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
iVGACompatible = _wtoi(&awcDeviceName[sizeof("\\Device\\Video")-1]);
|
||||||
|
ERR("VGA adapter = %lu\n", iVGACompatible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the maximum mumber of adapters */
|
||||||
|
if (!RegReadDWORD(hkey, L"MaxObjectNumber", &ulMaxObjectNumber))
|
||||||
|
{
|
||||||
|
ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Found %lu devices\n", ulMaxObjectNumber + 1);
|
||||||
|
|
||||||
|
/* Loop through all adapters */
|
||||||
|
for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
|
||||||
|
{
|
||||||
|
/* Create the adapter's key name */
|
||||||
|
swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum);
|
||||||
|
|
||||||
|
/* Read the reg key name */
|
||||||
|
cbValue = sizeof(awcBuffer);
|
||||||
|
Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("failed to query the registry path:0x%lx\n", Status);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the driver for this device */
|
||||||
|
pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
|
||||||
|
if (!pGraphicsDevice) continue;
|
||||||
|
|
||||||
|
/* Check if this is a VGA compatible adapter */
|
||||||
|
if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
|
||||||
|
{
|
||||||
|
/* Save this as the VGA adapter */
|
||||||
|
if (!gpVgaGraphicsDevice)
|
||||||
|
gpVgaGraphicsDevice = pGraphicsDevice;
|
||||||
|
TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set the first one as primary device */
|
||||||
|
if (!gpPrimaryGraphicsDevice)
|
||||||
|
gpPrimaryGraphicsDevice = pGraphicsDevice;
|
||||||
|
TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the device map registry key */
|
||||||
|
ZwClose(hkey);
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EngpPopulateDeviceModeList(
|
EngpPopulateDeviceModeList(
|
||||||
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
||||||
|
|
|
@ -39,6 +39,9 @@ EngpPopulateDeviceModeList(
|
||||||
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
||||||
_In_ PDEVMODEW pdmDefault);
|
_In_ PDEVMODEW pdmDefault);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
EngpUpdateGraphicsDeviceList(VOID);
|
||||||
|
|
||||||
CODE_SEG("INIT")
|
CODE_SEG("INIT")
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
|
|
@ -155,12 +155,7 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
InitVideo(VOID)
|
InitVideo(VOID)
|
||||||
{
|
{
|
||||||
ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
|
|
||||||
WCHAR awcDeviceName[20];
|
|
||||||
WCHAR awcBuffer[256];
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PGRAPHICS_DEVICE pGraphicsDevice;
|
|
||||||
ULONG cbValue;
|
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
|
||||||
TRACE("----------------------------- InitVideo() -------------------------------\n");
|
TRACE("----------------------------- InitVideo() -------------------------------\n");
|
||||||
|
@ -173,85 +168,10 @@ InitVideo(VOID)
|
||||||
if (gbBaseVideo)
|
if (gbBaseVideo)
|
||||||
ERR("VGA mode requested.\n");
|
ERR("VGA mode requested.\n");
|
||||||
|
|
||||||
/* Open the key for the adapters */
|
/* Initialize all display devices */
|
||||||
Status = RegOpenKey(KEY_VIDEO, &hkey);
|
Status = EngpUpdateGraphicsDeviceList();
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
|
||||||
ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key:0x%lx\n", Status);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the name of the VGA adapter */
|
|
||||||
cbValue = sizeof(awcDeviceName);
|
|
||||||
Status = RegQueryValue(hkey, L"VgaCompatible", REG_SZ, awcDeviceName, &cbValue);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
iVGACompatible = _wtoi(&awcDeviceName[sizeof("\\Device\\Video")-1]);
|
|
||||||
ERR("VGA adapter = %lu\n", iVGACompatible);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the maximum mumber of adapters */
|
|
||||||
if (!RegReadDWORD(hkey, L"MaxObjectNumber", &ulMaxObjectNumber))
|
|
||||||
{
|
|
||||||
ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("Found %lu devices\n", ulMaxObjectNumber + 1);
|
|
||||||
|
|
||||||
/* Loop through all adapters */
|
|
||||||
for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
|
|
||||||
{
|
|
||||||
/* Create the adapter's key name */
|
|
||||||
swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum);
|
|
||||||
|
|
||||||
/* Read the reg key name */
|
|
||||||
cbValue = sizeof(awcBuffer);
|
|
||||||
Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
ERR("failed to query the registry path:0x%lx\n", Status);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the driver for this device */
|
|
||||||
pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
|
|
||||||
if (!pGraphicsDevice) continue;
|
|
||||||
|
|
||||||
/* Check if this is a VGA compatible adapter */
|
|
||||||
if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
|
|
||||||
{
|
|
||||||
/* Save this as the VGA adapter */
|
|
||||||
if (!gpVgaGraphicsDevice)
|
|
||||||
gpVgaGraphicsDevice = pGraphicsDevice;
|
|
||||||
TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Set the first one as primary device */
|
|
||||||
if (!gpPrimaryGraphicsDevice)
|
|
||||||
gpPrimaryGraphicsDevice = pGraphicsDevice;
|
|
||||||
TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close the device map registry key */
|
|
||||||
ZwClose(hkey);
|
|
||||||
|
|
||||||
/* Was VGA mode requested? */
|
|
||||||
if (gbBaseVideo)
|
|
||||||
{
|
|
||||||
/* Check if we found a VGA compatible device */
|
|
||||||
if (gpVgaGraphicsDevice)
|
|
||||||
{
|
|
||||||
/* Set the VgaAdapter as primary */
|
|
||||||
gpPrimaryGraphicsDevice = gpVgaGraphicsDevice;
|
|
||||||
// FIXME: DEVMODE
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("Could not find VGA compatible driver. Trying normal.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we had any success */
|
/* Check if we had any success */
|
||||||
if (!gpPrimaryGraphicsDevice)
|
if (!gpPrimaryGraphicsDevice)
|
||||||
|
@ -326,6 +246,12 @@ UserEnumDisplayDevices(
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (!pustrDevice)
|
||||||
|
{
|
||||||
|
/* Check if some devices have been added since last time */
|
||||||
|
EngpUpdateGraphicsDeviceList();
|
||||||
|
}
|
||||||
|
|
||||||
/* Ask gdi for the GRAPHICS_DEVICE */
|
/* Ask gdi for the GRAPHICS_DEVICE */
|
||||||
pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, iDevNum, 0);
|
pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, iDevNum, 0);
|
||||||
if (!pGraphicsDevice)
|
if (!pGraphicsDevice)
|
||||||
|
|
|
@ -48,4 +48,10 @@ RegWriteUserSetting(
|
||||||
_In_reads_bytes_(cjDataSize) const VOID *pvData,
|
_In_reads_bytes_(cjDataSize) const VOID *pvData,
|
||||||
_In_ ULONG cjDataSize);
|
_In_ ULONG cjDataSize);
|
||||||
|
|
||||||
|
PGRAPHICS_DEVICE
|
||||||
|
NTAPI
|
||||||
|
InitDisplayDriver(
|
||||||
|
IN PWSTR pwszDeviceName,
|
||||||
|
IN PWSTR pwszRegKey);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue