InitData.HwGetPowerState = VBEGetPowerState;
InitData.HwSetPowerState = VBESetPowerState;
InitData.HwDeviceExtensionSize = sizeof(VBE_DEVICE_EXTENSION);
-
+
return VideoPortInitialize(Context1, Context2, &InitData, NULL);
}
static int
VBESortModesCallback(PVBE_MODEINFO VbeModeInfoA, PVBE_MODEINFO VbeModeInfoB)
{
- DPRINT(("VBESortModesCallback: %dx%dx%d / %dx%dx%d\n",
+ VideoPortDebugPrint(Info, "VBESortModesCallback: %dx%dx%d / %dx%dx%d\n",
VbeModeInfoA->XResolution, VbeModeInfoA->YResolution,
VbeModeInfoA->BitsPerPixel,
VbeModeInfoB->XResolution, VbeModeInfoB->YResolution,
- VbeModeInfoB->BitsPerPixel));
-
+ VbeModeInfoB->BitsPerPixel);
+
/*
* FIXME: Until some reasonable method for changing video modes will
* be available we favor more bits per pixel. It should be changed
ULONG Pos;
int Result;
VBE_MODEINFO TempModeInfo;
- WORD TempModeNumber;
+ USHORT TempModeNumber;
while (!Finished)
{
{
INT10_BIOS_ARGUMENTS BiosRegisters;
VP_STATUS Status;
- PVBE_DEVICE_EXTENSION VBEDeviceExtension =
+ PVBE_DEVICE_EXTENSION VBEDeviceExtension =
(PVBE_DEVICE_EXTENSION)HwDeviceExtension;
ULONG Length;
ULONG ModeCount;
if (Status != NO_ERROR)
{
- DPRINT(("Failed to get Int 10 service functions (Status %x)\n", Status));
+ VideoPortDebugPrint(Error, "Failed to get Int 10 service functions (Status %x)\n", Status);
return FALSE;
}
-
+
/*
* Allocate a bit of memory that will be later used for VBE transport
* buffer. This memory must be accessible from V86 mode so it must fit
if (Status != NO_ERROR)
{
- DPRINT(("Failed to allocate virtual memory (Status %x)\n", Status));
+ VideoPortDebugPrint(Error, "Failed to allocate virtual memory (Status %x)\n", Status);
return FALSE;
}
/*
* Get the VBE general information.
*/
-
+
VBEDeviceExtension->Int10Interface.Int10WriteMemory(
VBEDeviceExtension->Int10Interface.Context,
VBEDeviceExtension->TrampolineMemorySegment,
VBEDeviceExtension->Int10Interface.Int10CallBios(
VBEDeviceExtension->Int10Interface.Context,
&BiosRegisters);
-
+
if (BiosRegisters.Eax == VBE_SUCCESS)
{
VBEDeviceExtension->Int10Interface.Int10ReadMemory(
&VBEDeviceExtension->VbeInfo,
sizeof(VBEDeviceExtension->VbeInfo));
- DPRINT(("VBE BIOS Present (%d.%d, %8ld Kb)\n",
+ /* Verify the VBE signature. */
+ if (VideoPortCompareMemory(VBEDeviceExtension->VbeInfo.Signature, "VESA", 4) != 4)
+ {
+ VideoPortDebugPrint(Warn, "No VBE BIOS present\n");
+ return FALSE;
+ }
+
+ VideoPortDebugPrint(Trace, "VBE BIOS Present (%d.%d, %8ld Kb)\n",
VBEDeviceExtension->VbeInfo.Version / 0x100,
VBEDeviceExtension->VbeInfo.Version & 0xFF,
- VBEDeviceExtension->VbeInfo.TotalMemory * 16));
+ VBEDeviceExtension->VbeInfo.TotalMemory * 64);
#ifdef VBE12_SUPPORT
if (VBEDeviceExtension->VbeInfo.Version < 0x102)
if (VBEDeviceExtension->VbeInfo.Version < 0x200)
#endif
{
- DPRINT(("VBE BIOS present, but incompatible version.\n"));
+ VideoPortDebugPrint(Warn, "VBE BIOS present, but incompatible version.\n");
return FALSE;
}
}
else
{
- DPRINT(("No VBE BIOS found.\n"));
+ VideoPortDebugPrint(Warn, "No VBE BIOS found.\n");
return FALSE;
}
*/
VBEDeviceExtension->ModeInfo =
- ExAllocatePool(PagedPool, ModeCount * sizeof(VBE_MODEINFO));
+ VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(VBE_MODEINFO), TAG_VBE);
VBEDeviceExtension->ModeNumbers =
- ExAllocatePool(PagedPool, ModeCount * sizeof(WORD));
+ VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(USHORT), TAG_VBE);
/*
* Get the actual mode infos.
*/
-
+
for (CurrentMode = 0, SuitableModeCount = 0;
CurrentMode < ModeCount;
CurrentMode++)
VbeModeInfo->XResolution >= 640 &&
VbeModeInfo->YResolution >= 480 &&
(VbeModeInfo->MemoryModel == VBE_MEMORYMODEL_PACKEDPIXEL ||
- VbeModeInfo->MemoryModel == VBE_MEMORYMODEL_DIRECTCOLOR))
+ VbeModeInfo->MemoryModel == VBE_MEMORYMODEL_DIRECTCOLOR) &&
+ VbeModeInfo->PhysBasePtr != 0)
{
if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_LINEAR)
{
if (SuitableModeCount == 0)
{
- DPRINT(("VBEMP: No video modes supported\n"));
+ VideoPortDebugPrint(Warn, "VBEMP: No video modes supported\n");
return FALSE;
}
-
+
VBEDeviceExtension->ModeCount = SuitableModeCount;
/*
VBESortModes(VBEDeviceExtension);
/*
- * Print the supported video modes when DBG is set.
+ * Print the supported video modes when NDEBUG is not set.
*/
-#ifdef DBG
for (CurrentMode = 0;
CurrentMode < SuitableModeCount;
CurrentMode++)
{
- DPRINT(("%dx%dx%d\n",
+ VideoPortDebugPrint(Trace, "%dx%dx%d\n",
VBEDeviceExtension->ModeInfo[CurrentMode].XResolution,
VBEDeviceExtension->ModeInfo[CurrentMode].YResolution,
- VBEDeviceExtension->ModeInfo[CurrentMode].BitsPerPixel));
+ VBEDeviceExtension->ModeInfo[CurrentMode].BitsPerPixel);
}
-#endif
return TRUE;
}
PVOID HwDeviceExtension,
PVIDEO_REQUEST_PACKET RequestPacket)
{
- BOOL Result;
+ BOOLEAN Result;
- RequestPacket->StatusBlock->Status = STATUS_UNSUCCESSFUL;
+ RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
switch (RequestPacket->IoControlCode)
{
case IOCTL_VIDEO_SET_CURRENT_MODE:
- if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
+ if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
case IOCTL_VIDEO_MAP_VIDEO_MEMORY:
if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION) ||
- RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
+ RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
break;
case IOCTL_VIDEO_UNMAP_VIDEO_MEMORY:
- if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
+ if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
break;
case IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES:
- if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
+ if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
case IOCTL_VIDEO_QUERY_AVAIL_MODES:
if (RequestPacket->OutputBufferLength <
- ((PVBE_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount * sizeof(VIDEO_MODE_INFORMATION))
+ ((PVBE_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount * sizeof(VIDEO_MODE_INFORMATION))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT) ||
RequestPacket->InputBufferLength <
(((PVIDEO_CLUT)RequestPacket->InputBuffer)->NumEntries * sizeof(ULONG)) +
- sizeof(VIDEO_CLUT))
+ FIELD_OFFSET(VIDEO_CLUT, LookupTable))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
break;
case IOCTL_VIDEO_QUERY_CURRENT_MODE:
- if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
+ if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
{
RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
return TRUE;
(PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
RequestPacket->StatusBlock);
break;
-
+
default:
- RequestPacket->StatusBlock->Status = STATUS_NOT_IMPLEMENTED;
+ RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
return FALSE;
}
-
+
if (Result)
- RequestPacket->StatusBlock->Status = STATUS_SUCCESS;
+ RequestPacket->StatusBlock->Status = NO_ERROR;
return TRUE;
}
ULONG Rows)
{
INT10_BIOS_ARGUMENTS BiosRegisters;
- PVBE_DEVICE_EXTENSION VBEDeviceExtension =
+ PVBE_DEVICE_EXTENSION VBEDeviceExtension =
(PVBE_DEVICE_EXTENSION)DeviceExtension;
-
+
if (!VBEResetDevice(DeviceExtension, NULL))
return FALSE;
-
+
/* Change number of columns/rows */
VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
-
+
if (Columns == 80 && Rows == 25)
{
/* Default text size, don't change anything. */
VBEDeviceExtension->Int10Interface.Int10CallBios(
VBEDeviceExtension->Int10Interface.Context,
&BiosRegisters);
-
+
BiosRegisters.Eax = 0x1112;
}
else if (Columns == 80 && Rows == 50)
}
else
return FALSE;
-
+
VBEDeviceExtension->Int10Interface.Int10CallBios(
VBEDeviceExtension->Int10Interface.Context,
&BiosRegisters);
-
+
return TRUE;
}
PVIDEO_POWER_MANAGEMENT VideoPowerControl)
{
INT10_BIOS_ARGUMENTS BiosRegisters;
- PVBE_DEVICE_EXTENSION VBEDeviceExtension =
+ PVBE_DEVICE_EXTENSION VBEDeviceExtension =
(PVBE_DEVICE_EXTENSION)HwDeviceExtension;
if (HwId != DISPLAY_ADAPTER_HW_ID ||
VideoPortZeroMemory(&BiosRegisters, sizeof(BiosRegisters));
BiosRegisters.Eax = VBE_POWER_MANAGEMENT_EXTENSIONS;
- BiosRegisters.Ebx = 0;
+ BiosRegisters.Ebx = 0;
BiosRegisters.Edi = 0;
BiosRegisters.SegEs = 0;
VBEDeviceExtension->Int10Interface.Int10CallBios(
&BiosRegisters);
if (BiosRegisters.Eax == VBE_NOT_SUPPORTED)
- return ERROR_NOT_SUPPORTED;
+ return ERROR_DEV_NOT_EXIST;
if (BiosRegisters.Eax != VBE_SUCCESS)
- return ERROR_INVALID_FUNCTION;
-
+ return ERROR_INVALID_FUNCTION;
+
/*
* Get current power state.
*/
return NO_ERROR;
}
- return ERROR_NOT_SUPPORTED;
+ return ERROR_DEV_NOT_EXIST;
}
/*
PVIDEO_POWER_MANAGEMENT VideoPowerControl)
{
INT10_BIOS_ARGUMENTS BiosRegisters;
- PVBE_DEVICE_EXTENSION VBEDeviceExtension =
+ PVBE_DEVICE_EXTENSION VBEDeviceExtension =
(PVBE_DEVICE_EXTENSION)HwDeviceExtension;
if (HwId != DISPLAY_ADAPTER_HW_ID ||
&BiosRegisters);
if (BiosRegisters.Eax == VBE_NOT_SUPPORTED)
- return ERROR_NOT_SUPPORTED;
+ return ERROR_DEV_NOT_EXIST;
if (BiosRegisters.Eax != VBE_SUCCESS)
- return ERROR_INVALID_FUNCTION;
+ return ERROR_INVALID_FUNCTION;
return VBE_SUCCESS;
}
* Sets the adapter to the specified operating mode.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBESetCurrentMode(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MODE RequestedMode,
}
else
{
- DPRINT(("VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax));
+ VideoPortDebugPrint(Error, "VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax);
DeviceExtension->CurrentMode = -1;
}
* VBEResetDevice
*
* Resets the video hardware to the default mode, to which it was initialized
- * at system boot.
+ * at system boot.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEResetDevice(
PVBE_DEVICE_EXTENSION DeviceExtension,
PSTATUS_BLOCK StatusBlock)
* VBEMapVideoMemory
*
* Maps the video hardware frame buffer and video RAM into the virtual address
- * space of the requestor.
+ * space of the requestor.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEMapVideoMemory(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MEMORY RequestedAddress,
if (DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].ModeAttributes &
VBE_MODEATTR_LINEAR)
- {
+ {
FrameBuffer.QuadPart =
DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].PhysBasePtr;
MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
if (DeviceExtension->VbeInfo.Version < 0x300)
{
- MapInformation->VideoRamLength =
+ MapInformation->VideoRamLength =
DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].BytesPerScanLine *
DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
}
else
{
- MapInformation->VideoRamLength =
+ MapInformation->VideoRamLength =
DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].LinBytesPerScanLine *
DeviceExtension->ModeInfo[DeviceExtension->CurrentMode].YResolution;
}
#ifdef VBE12_SUPPORT
else
{
- FrameBuffer.QuadPart = 0xA0000;
+ FrameBuffer.QuadPart = 0xA0000;
MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
MapInformation->VideoRamLength = 0x10000;
}
* frame buffer and video RAM.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEUnmapVideoMemory(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MEMORY VideoMemory,
VideoPortUnmapMemory(DeviceExtension, VideoMemory->RequestedVirtualAddress,
NULL);
return TRUE;
-}
+}
/*
* VBEQueryNumAvailModes
* buffer for an IOCTL_VIDEO_QUERY_AVAIL_MODES request.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEQueryNumAvailModes(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_NUM_MODES Modes,
* Returns information about one particular video mode.
*/
-VOID FASTCALL
+VOID FASTCALL
VBEQueryMode(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MODE_INFORMATION VideoMode,
VideoMode->YMillimeter = 0; /* FIXME */
if (VBEMode->BitsPerPixel > 8)
{
+ /*
+ * Always report 16bpp modes and not 15bpp mode...
+ */
+ if (VBEMode->BitsPerPixel == 15 && VBEMode->NumberOfPlanes == 1)
+ {
+ VideoMode->BitsPerPlane = 16;
+ }
+
if (DeviceExtension->VbeInfo.Version < 0x300)
{
VideoMode->NumberRedBits = VBEMode->RedMaskSize;
}
else
{
- VideoMode->NumberRedBits =
- VideoMode->NumberGreenBits =
+ VideoMode->NumberRedBits =
+ VideoMode->NumberGreenBits =
VideoMode->NumberBlueBits = 6;
- VideoMode->RedMask =
- VideoMode->GreenMask =
+ VideoMode->RedMask =
+ VideoMode->GreenMask =
VideoMode->BlueMask = 0;
}
VideoMode->VideoMemoryBitmapWidth = VBEMode->XResolution;
* Returns information about each video mode supported by the adapter.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEQueryAvailModes(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MODE_INFORMATION ReturnedModes,
* Returns information about current video mode.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBEQueryCurrentMode(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_MODE_INFORMATION VideoModeInfo,
* yet implemented.
*/
-BOOL FASTCALL
+BOOLEAN FASTCALL
VBESetColorRegisters(
PVBE_DEVICE_EXTENSION DeviceExtension,
PVIDEO_CLUT ColorLookUpTable,
else
{
/*
- * We can't just copy the values, because we need to swap the Red
+ * We can't just copy the values, because we need to swap the Red
* and Blue values.
*/