fix resolution mismatch when switching between VGA and QXL modes

(cherry picked from commit b2a0aef4a5)
This commit is contained in:
Vadim Rozenfeld 2015-02-19 21:07:24 +11:00
parent fa8291cf37
commit f059ee240e
3 changed files with 41 additions and 25 deletions

View File

@ -2404,7 +2404,9 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
VBE_INFO VbeInfo = {0}; VBE_INFO VbeInfo = {0};
ULONG Length; ULONG Length;
VBE_MODEINFO tmpModeInfo; VBE_MODEINFO tmpModeInfo;
UINT Height = pDispInfo->Height;
UINT Width = pDispInfo->Width;
UINT BitsPerPixel = BPPFromPixelFormat(pDispInfo->ColorFormat);
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
//Get VBE Mode List //Get VBE Mode List
@ -2451,6 +2453,7 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
DbgPrint(TRACE_LEVEL_INFORMATION, ("VBE BIOS Present (%d.%d, %8ld Kb)\n", VbeInfo.Version / 0x100, VbeInfo.Version & 0xFF, VbeInfo.TotalMemory * 64)); DbgPrint(TRACE_LEVEL_INFORMATION, ("VBE BIOS Present (%d.%d, %8ld Kb)\n", VbeInfo.Version / 0x100, VbeInfo.Version & 0xFF, VbeInfo.TotalMemory * 64));
DbgPrint(TRACE_LEVEL_INFORMATION, ("Capabilities = 0x%x\n", VbeInfo.Capabilities)); DbgPrint(TRACE_LEVEL_INFORMATION, ("Capabilities = 0x%x\n", VbeInfo.Capabilities));
DbgPrint(TRACE_LEVEL_INFORMATION, ("VideoModePtr = 0x%x (0x%x.0x%x)\n", VbeInfo.VideoModePtr, HIWORD( VbeInfo.VideoModePtr), LOWORD( VbeInfo.VideoModePtr))); DbgPrint(TRACE_LEVEL_INFORMATION, ("VideoModePtr = 0x%x (0x%x.0x%x)\n", VbeInfo.VideoModePtr, HIWORD( VbeInfo.VideoModePtr), LOWORD( VbeInfo.VideoModePtr)));
DbgPrint(TRACE_LEVEL_INFORMATION, ("pDispInfo = %p %dx%d@%d\n", pDispInfo, Width, Height, BitsPerPixel));
for (ModeCount = 0; ; ModeCount++) for (ModeCount = 0; ; ModeCount++)
{ {
@ -2479,6 +2482,12 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
m_ModeNumbers = reinterpret_cast<PUSHORT> (new (PagedPool) BYTE [sizeof (USHORT) * ModeCount]); m_ModeNumbers = reinterpret_cast<PUSHORT> (new (PagedPool) BYTE [sizeof (USHORT) * ModeCount]);
m_CurrentMode = 0; m_CurrentMode = 0;
DbgPrint(TRACE_LEVEL_INFORMATION, ("m_ModeInfo = 0x%p, m_ModeNumbers = 0x%p\n", m_ModeInfo, m_ModeNumbers)); DbgPrint(TRACE_LEVEL_INFORMATION, ("m_ModeInfo = 0x%p, m_ModeNumbers = 0x%p\n", m_ModeInfo, m_ModeNumbers));
if (Width == 0 || Height == 0 || BitsPerPixel != VGA_BPP)
{
Width = MIN_WIDTH_SIZE;
Height = MIN_HEIGHT_SIZE;
BitsPerPixel = VGA_BPP;
}
for (CurrentMode = 0, SuitableModeCount = 0; for (CurrentMode = 0, SuitableModeCount = 0;
CurrentMode < ModeCount; CurrentMode < ModeCount;
CurrentMode++) CurrentMode++)
@ -2495,7 +2504,6 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
break; break;
} }
DbgPrint(TRACE_LEVEL_INFORMATION, ("ModeTemp = 0x%X\n", ModeTemp));
RtlZeroMemory(&regs, sizeof(regs)); RtlZeroMemory(&regs, sizeof(regs));
regs.Eax = 0x4F01; regs.Eax = 0x4F01;
regs.Ecx = ModeTemp; regs.Ecx = ModeTemp;
@ -2512,9 +2520,7 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
&tmpModeInfo, &tmpModeInfo,
sizeof(VBE_MODEINFO)); sizeof(VBE_MODEINFO));
UINT Height = pDispInfo->Height; DbgPrint(TRACE_LEVEL_INFORMATION, ("ModeTemp = 0x%X %dx%d@%d\n", ModeTemp, tmpModeInfo.XResolution, tmpModeInfo.YResolution, tmpModeInfo.BitsPerPixel));
UINT Width = pDispInfo->Width;
UINT BitsPerPixel = BPPFromPixelFormat(pDispInfo->ColorFormat);
if (tmpModeInfo.XResolution >= Width && if (tmpModeInfo.XResolution >= Width &&
tmpModeInfo.YResolution >= Height && tmpModeInfo.YResolution >= Height &&
@ -3045,6 +3051,13 @@ NTSTATUS QxlDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
UINT Height = pDispInfo->Height; UINT Height = pDispInfo->Height;
UINT Width = pDispInfo->Width; UINT Width = pDispInfo->Width;
UINT BitsPerPixel = BPPFromPixelFormat(pDispInfo->ColorFormat); UINT BitsPerPixel = BPPFromPixelFormat(pDispInfo->ColorFormat);
if (Width == 0 || Height == 0 || BitsPerPixel != QXL_BPP)
{
Width = MIN_WIDTH_SIZE;
Height = MIN_HEIGHT_SIZE;
BitsPerPixel = QXL_BPP;
}
for (CurrentMode = 0, SuitableModeCount = 0; for (CurrentMode = 0, SuitableModeCount = 0;
CurrentMode < modes->n_modes; CurrentMode < modes->n_modes;
CurrentMode++) CurrentMode++)
@ -3075,7 +3088,6 @@ NTSTATUS QxlDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;
} }
// m_CurrentMode = m_ModeNumbers[0];
m_CustomMode = SuitableModeCount; m_CustomMode = SuitableModeCount;
for (CurrentMode = SuitableModeCount; for (CurrentMode = SuitableModeCount;
CurrentMode < SuitableModeCount + 2; CurrentMode < SuitableModeCount + 2;
@ -4307,25 +4319,28 @@ VOID QxlDevice::BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod)
QXLDrawable *drawable; QXLDrawable *drawable;
RECT Rect; RECT Rect;
PAGED_CODE(); PAGED_CODE();
return;
DbgPrint(TRACE_LEVEL_FATAL, ("---> %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_FATAL, ("---> %s\n", __FUNCTION__));
Rect.bottom = pCurrentBddMod->SrcModeHeight; if (pCurrentBddMod->Flags.FrameBufferIsActive)
Rect.top = 0; {
Rect.left = 0; Rect.bottom = pCurrentBddMod->SrcModeHeight;
Rect.right = pCurrentBddMod->SrcModeWidth; Rect.top = 0;
if (!(drawable = Drawable(QXL_DRAW_FILL, &Rect, NULL, 0))) { Rect.left = 0;
DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n")); Rect.right = pCurrentBddMod->SrcModeWidth;
if (!(drawable = Drawable(QXL_DRAW_FILL, &Rect, NULL, 0)))
{
DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));
return;
}
drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
drawable->u.fill.brush.u.color = 0;
drawable->u.fill.rop_descriptor = SPICE_ROPD_OP_PUT;
drawable->u.fill.mask.flags = 0;
drawable->u.fill.mask.pos.x = 0;
drawable->u.fill.mask.pos.y = 0;
drawable->u.fill.mask.bitmap = 0;
PushDrawable(drawable);
} }
drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
drawable->u.fill.brush.u.color = 0;
drawable->u.fill.rop_descriptor = SPICE_ROPD_OP_PUT;
drawable->u.fill.mask.flags = 0;
drawable->u.fill.mask.pos.x = 0;
drawable->u.fill.mask.pos.y = 0;
drawable->u.fill.mask.bitmap = 0;
PushDrawable(drawable);
DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s\n", __FUNCTION__));
} }

View File

@ -11,6 +11,7 @@
#define MIN_WIDTH_SIZE 1024 #define MIN_WIDTH_SIZE 1024
#define MIN_HEIGHT_SIZE 768 #define MIN_HEIGHT_SIZE 768
#define QXL_BPP 32 #define QXL_BPP 32
#define VGA_BPP 24
typedef struct _QXL_FLAGS typedef struct _QXL_FLAGS
{ {

View File

@ -9,7 +9,7 @@
// Driver Entry point // Driver Entry point
// //
int nDebugLevel = TRACE_LEVEL_ERROR; int nDebugLevel = TRACE_LEVEL_INFORMATION;
extern "C" extern "C"