screen.c revision 3400a1195003605b6899c61cd77ea05053a0db48
/******************************Module*Header*******************************\
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*
* Based in part on Microsoft DDK sample code
*
* *******************
* * GDI SAMPLE CODE *
* *******************
*
* Module Name: screen.c
*
* Initializes the GDIINFO and DEVINFO structures for DrvEnablePDEV.
*
* Copyright (c) 1992-1998 Microsoft Corporation
\**************************************************************************/
#include "driver.h"
#ifdef VBOX_WITH_HGSMI
#endif
#define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"}
#define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"}
#define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"}
// This is the basic devinfo for a default driver. This is used as a base and customized based
// on information passed back from the miniport driver.
const DEVINFO gDevInfoFrameBuffer = {
#ifdef VBOX_WITH_DDRAW
#endif
), /* Graphics capabilities */
SYSTM_LOGFONT, /* Default font description */
HELVE_LOGFONT, /* ANSI variable font description */
COURI_LOGFONT, /* ANSI fixed font description */
0, /* Count of device fonts */
0, /* Preferred DIB format */
8, /* Width of color dither */
8, /* Height of color dither */
0 /* Default palette to use for this device */
};
{
ULONG cbAvailable = 0;
#ifndef VBOX_WITH_HGSMI
NULL,
0,
&DispInfo,
sizeof(DispInfo),
if (ppdev->bVBoxVideoSupported)
{
u32MinVBVABufferSize = 0; /* In old mode the buffer is not used at all. */
}
#else
NULL,
0,
&info,
sizeof(info),
if (ppdev->bHGSMISupported)
{
}
#endif /* VBOX_WITH_HGSMI */
#ifndef VBOX_WITH_HGSMI
if (ppdev->bVBoxVideoSupported)
{
#else
if (ppdev->bHGSMISupported)
{
#endif /* VBOX_WITH_HGSMI */
if (cbAvailable <= u32DisplayInfoSize)
{
#ifndef VBOX_WITH_HGSMI
#else
#endif /* VBOX_WITH_HGSMI */
}
else
{
/* Use minimum 64K and maximum the cbFrameBuffer for the VBVA buffer. */
#ifndef VBOX_WITH_HGSMI
#else
#endif /* VBOX_WITH_HGSMI */
{
{
break;
}
}
{
#ifndef VBOX_WITH_HGSMI
#else
#endif /* VBOX_WITH_HGSMI */
}
else
{
/* Now the offscreen heap followed by the VBVA buffer. */
}
}
}
#ifndef VBOX_WITH_HGSMI
if (!ppdev->bVBoxVideoSupported)
#else
if (!ppdev->bHGSMISupported)
#endif /* VBOX_WITH_HGSMI */
{
/* Setup a layout without both the VBVA buffer and the display information. */
}
#ifdef VBOX_WITH_HGSMI
else
{
/* Setup HGSMI heap in the display information area. The area has some space reserved for
* HGSMI event flags in the beginning.
*/
if (RT_FAILURE (rc))
{
DISPDBG((0, "VBoxDISP::vboxInitVBoxVideo: HGSMIHeapSetup failed rc = %d\n",
rc));
}
else
{
#if 0
/* Inform the host about the HGSMIHOSTEVENTS location. */
sizeof (HGSMI_BUFFER_LOCATION),
if (!p)
{
DISPDBG((0, "VBoxDISP::vboxInitVBoxVideo: HGSMIHeapAlloc failed\n"));
rc = VERR_NO_MEMORY;
}
else
{
p);
/* Submit the buffer to the host. */
}
#endif
}
}
#endif /* VBOX_WITH_HGSMI */
DISPDBG((0, "vboxInitVBoxVideo:\n"
" cbVRAM = 0x%X\n"
" offFrameBuffer = 0x%X\n"
" cbFrameBuffer = 0x%X\n"
" offDDRAWHeap = 0x%X\n"
" cbDDRAWHeap = 0x%X\n"
" offVBVABuffer = 0x%X\n"
" cbVBVABuffer = 0x%X\n"
" offDisplayInformation = 0x%X\n"
" cbDisplayInformation = 0x%X\n",
));
}
#ifndef VBOX_WITH_HGSMI
/* Setup display information after remapping. */
{
pu8 += sizeof (VBOXDISPLAYINFO);
}
{
{
}
}
#endif /* !VBOX_WITH_HGSMI */
/******************************Public*Routine******************************\
* bInitSURF
*
* Enables the surface. Maps the frame buffer into memory.
*
\**************************************************************************/
{
ULONG RemappingNeeded = 0;
//
// Set the current mode into the hardware.
//
sizeof(ULONG),
sizeof(ULONG),
{
return(FALSE);
}
//
// If this is the first time we enable the surface we need to map in the
// memory also.
//
if (bFirst || RemappingNeeded)
{
sizeof(VIDEO_MEMORY),
sizeof(VIDEO_MEMORY_INFORMATION),
{
return(FALSE);
}
{
DISPDBG((0, "VideoRamBase does not correspond to FrameBufferBase\n"));
}
//
// Make sure we can access this video memory
//
return(FALSE);
}
/* Clear VRAM to avoid distortions during the video mode change. */
//
// Initialize the head of the offscreen list to NULL.
//
// It's a hardware pointer; set up pointer attributes.
// device supports a color Pointer, we will allocate a larger bitmap.
// If this is a color bitmap we allocate for the largest possible
// bitmap because we have no idea of what the pixel depth might be.
// Width rounded up to nearest byte multiple
{
}
else
{
}
sizeof(VIDEO_POINTER_ATTRIBUTES) +
DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
return(FALSE);
}
#ifndef VBOX_WITH_HGSMI
if (ppdev->bVBoxVideoSupported)
{
/* Setup the display information. */
}
#endif /* !VBOX_WITH_HGSMI */
}
{
#ifndef VBOX_WITH_HGSMI
{
/* Enable VBVA for this video mode. */
}
#else
if (ppdev->bHGSMISupported)
{
/* Enable VBVA for this video mode. */
}
#endif /* VBOX_WITH_HGSMI */
}
#ifndef VBOX_WITH_HGSMI
/* Update the display information. */
#else
/* Inform the host about this screen layout. */
#endif /* VBOX_WITH_HGSMI */
return(TRUE);
}
/******************************Public*Routine******************************\
* vDisableSURF
*
* Disable the surface. Un-Maps the frame in memory.
*
\**************************************************************************/
{
sizeof(VIDEO_MEMORY),
NULL,
0,
{
DISPDBG((0, "DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n"));
}
}
/******************************Public*Routine******************************\
* bInitPDEV
*
* Determine the mode we should be in based on the DEVMODE passed in.
* Query mini-port to get information needed to fill in the DevInfo and the
* GdiInfo .
*
\**************************************************************************/
{
//
// calls the miniport to get mode information.
//
if (cModes == 0)
{
return(FALSE);
}
//
// Now see if the requested mode has a match in that table.
//
if ((pDevMode->dmPelsWidth == 0) &&
(pDevMode->dmPelsHeight == 0) &&
(pDevMode->dmBitsPerPel == 0) &&
(pDevMode->dmDisplayFrequency == 0))
{
}
else
{
}
while (cModes--)
{
if (pVideoTemp->Length != 0)
{
if (bSelectDefault ||
{
break;
}
}
}
//
// If no mode has been found, return an error
//
if (pVideoModeSelected == NULL)
{
DISPDBG((0,"DISP bInitPDEV failed - no valid modes\n"));
return(FALSE);
}
//
// Fill in the GDIINFO data structure with the information returned from
// the kernel driver.
//
if (g_bOnNT40)
{
}
else
{
}
/* bit block transfers are accelerated */
pGdiInfo->ulBltAlignment = 0;
#ifdef MIPS
else
#endif
pGdiInfo->ptlPhysOffset.x = 0;
pGdiInfo->ptlPhysOffset.y = 0;
// RGB and CMY color info.
//
// try to get it from the miniport.
// if the miniport doesn ot support this feature, use defaults.
//
NULL,
0,
sizeof(VIDEO_COLOR_CAPABILITIES),
&ulTemp))
{
}
else
{
// if we have a color device store the three color gamma values,
// otherwise store the unique gamma value in all three.
{
}
else
{
}
};
// No dye correction for raster displays.
// Note: this should be modified later to take into account the size
// of the display and the resolution.
// Fill in the basic devinfo structure
// Fill in the rest of the devinfo and GdiInfo structures.
{
// It is Palette Managed.
// Assuming palette is orthogonal - all colors are same size.
}
else
{
pGdiInfo->ulNumPalReg = 0;
{
}
{
}
else
{
}
}
return(TRUE);
}
/******************************Public*Routine******************************\
* getAvailableModes
*
* Calls the miniport to get the list of modes supported by the kernel driver,
* and returns the list of modes supported by the diplay driver among those
*
* returns the number of entries in the videomode buffer.
* 0 means no modes are supported by the miniport or that an error occured.
*
* NOTE: the buffer must be freed up by the caller.
*
\**************************************************************************/
{
//
// Get the number of modes supported by the mini-port
//
NULL,
0,
&modes,
sizeof(VIDEO_NUM_MODES),
&ulTemp))
{
DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n"));
return(0);
}
//
// Allocate the buffer for the mini-port to write the modes in.
//
{
DISPDBG((0, "getAvailableModes failed EngAllocMem\n"));
return 0;
}
//
// Ask the mini-port to fill in the available modes.
//
NULL,
0,
&ulTemp))
{
DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n"));
return(0);
}
//
// Now see which of these modes are supported by the display driver.
// As an internal mechanism, set the length to 0 for the modes we
// DO NOT support.
//
//
// Mode is rejected if it is not one plane, or not graphics, or is not
// one of 8, 16 or 32 bits per pel.
//
while (ulTemp--)
{
{
pVideoTemp->Length = 0;
}
}
}