- Fix a bug when iterating through the DEVMODE list
- Handle VgaCompatible flag differently, by reading this value from the registry for every installed driver.
- Priorize non-vga compatible devices over vga compatible, unless /BASEVIDEO is requested
- Fall back to vga compatible driver when no other is present

svn path=/trunk/; revision=54151
This commit is contained in:
Timo Kreuzer 2011-10-15 21:22:19 +00:00
parent 1d1913a81e
commit de06265192
3 changed files with 45 additions and 20 deletions

View file

@ -151,7 +151,7 @@ EngpRegisterGraphicsDevice(
/* Loop all DEVMODEs */
pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
for (pdm = pdminfo->adevmode;
pdm + 1 <= pdmEnd;
(pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
{
/* Count this DEVMODE */
@ -195,7 +195,7 @@ EngpRegisterGraphicsDevice(
/* Loop through the DEVMODEs */
for (pdm = pdminfo->adevmode;
pdm + 1 <= pdmEnd;
(pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
{
/* Compare with the default entry */

View file

@ -44,7 +44,7 @@ typedef struct _DEVMODEINFO
DEVMODEW adevmode[1];
} DEVMODEINFO, *PDEVMODEINFO;
typedef struct
typedef struct _DEVMODEENTRY
{
DWORD dwFlags;
PDEVMODEW pdm;

View file

@ -74,6 +74,7 @@ InitDisplayDriver(
ULONG cbSize;
HKEY hkey;
DEVMODEW dmDefault;
DWORD dwVga;
ERR("InitDisplayDriver(%S, %S);\n",
pwszDeviceName, pwszRegKey);
@ -128,6 +129,11 @@ InitDisplayDriver(
/* Query the default settings */
RegReadDisplaySettings(hkey, &dmDefault);
/* Query if this is a VGA compatible driver */
cbSize = sizeof(DWORD);
Status = RegQueryValue(hkey, L"VgaCompatible", REG_DWORD, &dwVga, &cbSize);
if (!NT_SUCCESS(Status)) dwVga = 0;
/* Close the registry key */
ZwClose(hkey);
@ -137,6 +143,10 @@ InitDisplayDriver(
&ustrDisplayDrivers,
&ustrDescription,
&dmDefault);
if (pGraphicsDevice && dwVga)
{
pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_VGA_COMPATIBLE;
}
return pGraphicsDevice;
}
@ -197,7 +207,7 @@ InitVideo()
ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
}
TRACE("Found %ld devices\n", ulMaxObjectNumber);
TRACE("Found %ld devices\n", ulMaxObjectNumber + 1);
/* Loop through all adapters */
for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
@ -218,31 +228,30 @@ InitVideo()
pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
if (!pGraphicsDevice) continue;
/* Check if this is the VGA adapter */
if (iDevNum == iVGACompatible)
/* Check if this is a VGA compatible adapter */
if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
{
/* Set the VGA device as primary */
gpVgaGraphicsDevice = pGraphicsDevice;
ERR("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
/* 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);
}
/* Set the first one as primary device */
if (!gpPrimaryGraphicsDevice)
gpPrimaryGraphicsDevice = pGraphicsDevice;
}
/* Close the device map registry key */
ZwClose(hkey);
/* Check if we had any success */
if (!gpPrimaryGraphicsDevice)
{
ERR("No usable display driver was found.\n");
return STATUS_UNSUCCESSFUL;
}
/* Was VGA mode requested? */
if (gbBaseVideo)
{
/* Check if we found a VGA compatible device */
if (gpVgaGraphicsDevice)
{
/* Set the VgaAdapter as primary */
@ -255,6 +264,22 @@ InitVideo()
}
}
/* Check if we had any success */
if (!gpPrimaryGraphicsDevice)
{
/* Check if there is a VGA device we skipped */
if (gpVgaGraphicsDevice)
{
/* There is, use the VGA device */
gpPrimaryGraphicsDevice = gpVgaGraphicsDevice;
}
else
{
ERR("No usable display driver was found.\n");
return STATUS_UNSUCCESSFUL;
}
}
InitSysParams();
return 1;