return pGraphicsDevice;
}
-BOOL
-InitVideo(
- PUNICODE_STRING pustrRegPath,
- FLONG flags)
+NTSTATUS
+NTAPI
+InitVideo()
{
ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
WCHAR awcDeviceName[20];
ULONG cbValue;
HKEY hkey;
- DPRINT1("----------------------------- InitVideo() -------------------------------\n");
+ DPRINT("----------------------------- InitVideo() -------------------------------\n");
+ /* Open the key for the boot command line */
Status = RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control", &hkey);
if (NT_SUCCESS(Status))
{
if (!NT_SUCCESS(Status))
{
DPRINT1("Could not open device registry key!\n");
- ASSERT(FALSE);
+ return Status;
}
/* Read the name of the VGA adapter */
DPRINT("Found %ld devices\n", ulMaxObjectNumber);
/* Loop through all adapters */
- cbValue = 256;
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))
+ {
+ DPRINT1("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 the VGA adapter */
if (iDevNum == iVGACompatible)
gpPrimaryGraphicsDevice = pGraphicsDevice;
}
+ /* Close the device map registry key */
ZwClose(hkey);
+ /* Check if we had any success */
+ if (!gpPrimaryGraphicsDevice)
+ {
+ DPRINT1("No usable display driver was found.\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
if (gbBaseVideo)
{
if (gpVgaGraphicsDevice)
DISPLAY_DEVICEW dispdev;
NTSTATUS Status;
- DPRINT1("Enter NtUserEnumDisplayDevices(%p, %ls, %ld)\n",
- pustrDevice, pustrDevice ? pustrDevice->Buffer : 0, iDevNum);
+ DPRINT("Enter NtUserEnumDisplayDevices(%wZ, %ld)\n",
+ pustrDevice, iDevNum);
// FIXME: HACK, desk.cpl passes broken crap
if (pustrDevice && iDevNum != 0)
PDEVMODEENTRY pdmentry;
ULONG i, iFoundMode;
- DPRINT1("Enter UserEnumDisplaySettings('%ls', %ld)\n",
+ DPRINT("Enter UserEnumDisplaySettings('%ls', %ld)\n",
pustrDevice ? pustrDevice->Buffer : NULL, iModeNum);
/* Ask gdi for the GRAPHICS_DEVICE */
pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, 0, 0);
+
if (!pGraphicsDevice)
{
/* No device found */
return STATUS_UNSUCCESSFUL;
}
- if (iModeNum == 0)
- {
- DPRINT1("Should initialize modes somehow\n");
- // Update DISPLAY_DEVICEs?
- }
+ if (iModeNum >= pGraphicsDevice->cDevModes)
+ return STATUS_NO_MORE_ENTRIES;
iFoundMode = 0;
for (i = 0; i < pGraphicsDevice->cDevModes; i++)
{
pdmentry = &pGraphicsDevice->pDevModeList[i];
-// if ((!(dwFlags & EDS_RAWMODE) && (pdmentry->dwFlags & 1)) || // FIXME!
-// (dwFlags & EDS_RAWMODE))
+ /* FIXME: consider EDS_RAWMODE */
+#if 0
+ if ((!(dwFlags & EDS_RAWMODE) && (pdmentry->dwFlags & 1)) ||!
+ (dwFlags & EDS_RAWMODE))
+#endif
{
/* Is this the one we want? */
if (iFoundMode == iModeNum)
DEVMODEW dmReg, *pdm;
DPRINT1("Enter NtUserEnumDisplaySettings(%ls, %ld)\n",
- pustrDevice ? pustrDevice->Buffer:0, iModeNum);
+ pustrDevice ? pustrDevice->Buffer : 0, iModeNum);
if (pustrDevice)
{
}
/* Fixup values */
- if((dm.dmFields & DM_BITSPERPEL) && (dm.dmBitsPerPel == 0))
+ if(dm.dmBitsPerPel == 0 || !(dm.dmFields & DM_BITSPERPEL))
+ {
dm.dmBitsPerPel = ppdev->pdmwDev->dmBitsPerPel;
+ dm.dmFields |= DM_BITSPERPEL;
+ }
+
if((dm.dmFields & DM_DISPLAYFREQUENCY) && (dm.dmDisplayFrequency == 0))
dm.dmDisplayFrequency = ppdev->pdmwDev->dmDisplayFrequency;