/* $Id$ */
/** @file
* VirtualBox Video driver, common code - HGSMI initialisation and helper
* functions.
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* 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.
*/
#include <VBox/VBoxVideoGuest.h>
#include <VBox/VBoxVideo.h>
#include <VBox/VBoxGuest.h>
#ifndef VBOX_GUESTR3XF86MOD
# include <string.h>
#endif
/**
* Gets the count of virtual monitors attached to the guest via an HGSMI
* command
*
* @returns the right count on success or 1 on failure.
* @param pCtx the context containing the heap to use
*/
{
/* Query the configured number of displays. */
/* Host reported some bad value. Continue in the 1 screen mode. */
cDisplays = 1;
return cDisplays;
}
/**
* Returns the size of the video RAM in bytes.
*
* @returns the size
*/
{
/** @note A 32bit read on this port returns the VRAM size. */
}
/**
* Check whether this hardware allows the display width to have non-multiple-
* of-eight values.
*
* @returns true if any width is allowed, false otherwise.
*/
{
unsigned DispiId;
return (DispiId == VBE_DISPI_ID_ANYX);
}
/**
* Tell the host about how VRAM is divided up between each screen via an HGSMI
* command. It is acceptable to specifiy identical data for each screen if
* they share a single framebuffer.
*
* @returns iprt status code, either VERR_NO_MEMORY or the status returned by
* @a pfnFill
* @todo What was I thinking of with that callback function? It
* would be much simpler to just pass in a structure in normal
* memory and copy it.
* @param pCtx the context containing the heap to use
* @param u32Count the number of screens we are activating
* @param pfnFill a callback which initialises the VBVAINFOVIEW structures
* for all screens
* @param pvData context data for @a pfnFill
*/
void *pvData)
{
int rc;
/* Issue the screen info command. */
if (p)
{
if (RT_SUCCESS(rc))
VBoxHGSMIBufferSubmit (pCtx, p);
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Set a video mode using port registers. This must be done for the first
* screen before every HGSMI modeset and also works when HGSM is not enabled.
* @param cWidth the mode width
* @param cHeight the mode height
* @param cVirtWidth the mode pitch
* @param cBPP the colour depth of the mode
* @param fFlags flags for the mode. These will be or-ed with the
* default _ENABLED flag, so unless you are restoring
* a saved mode or have special requirements you can pass
* zero here.
* @param cx the horizontal panning offset
* @param cy the vertical panning offset
*/
{
/* set the mode characteristics */
/* enable the mode */
/* Panning registers */
/** @todo read from the port to see if the mode switch was successful */
}
/**
* Get the video mode for the first screen using the port registers. All
* parameters are optional
* @returns true if the VBE mode returned is active, false if we are in VGA
* mode
* @note If anyone else needs additional register values just extend the
* function with additional parameters and fix any existing callers.
* @param pcWidth where to store the mode width
* @param pcHeight where to store the mode height
* @param pcVirtWidth where to store the mode pitch
* @param pcBPP where to store the colour depth of the mode
* @param pfFlags where to store the flags for the mode
*/
{
if (pcWidth)
{
}
if (pcHeight)
{
}
if (pcVirtWidth)
{
}
if (pcBPP)
{
}
if (pfFlags)
}
/**
* Disable our extended graphics mode and go back to VGA mode.
*/
{
}
/**
* Set a video mode via an HGSMI request. The views must have been
* initialised first using @a VBoxHGSMISendViewInfo and if the mode is being
* set on the first display then it must be set first using registers.
* @param cDisplay the screen number
* @param cOriginX the horizontal displacement relative to the first screen
* @param cOriginY the vertical displacement relative to the first screen
* @param offStart the offset of the visible area of the framebuffer
* relative to the framebuffer start
* @param cbPitch the offset in bytes between the starts of two adjecent
* scan lines in video RAM
* @param cWidth the mode width
* @param cHeight the mode height
* @param cBPP the colour depth of the mode
*/
{
/* Issue the screen info command. */
void *p = VBoxHGSMIBufferAlloc(pCtx,
sizeof (VBVAINFOSCREEN),
if (!p)
{
LogFunc(("HGSMIHeapAlloc failed\n"));
}
else
{
VBoxHGSMIBufferFree(pCtx, p);
}
}
/** Report the rectangle relative to which absolute pointer events should be
* expressed. This information remains valid until the next VBVA resize event
* for any screen, at which time it is reset to the bounding rectangle of all
* virtual screens.
* @param pCtx The context containing the heap to use.
* @param cOriginX Upper left X co-ordinate relative to the first screen.
* @param cOriginY Upper left Y co-ordinate relative to the first screen.
* @param cWidth Rectangle width.
* @param cHeight Rectangle height.
* @returns iprt status code.
* @returns VERR_NO_MEMORY HGSMI heap allocation failed.
*/
RTDECL(int) VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t cOriginX, int32_t cOriginY,
{
Log(("%s: cOriginX=%u, cOriginY=%u, cWidth=%u, cHeight=%u\n", __PRETTY_FUNCTION__, (unsigned)cOriginX, (unsigned)cOriginX,
/* Allocate the IO buffer. */
p = (VBVAREPORTINPUTMAPPING *)VBoxHGSMIBufferAlloc(pCtx, sizeof(VBVAREPORTINPUTMAPPING), HGSMI_CH_VBVA,
if (p)
{
/* Prepare data to be sent to the host. */
p->x = cOriginX;
p->y = cOriginY;
/* Free the IO buffer. */
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Get most recent video mode hints.
* @param pCtx the context containing the heap to use
* @param cScreens the number of screens to query hints for, starting at 0.
* @param pHints array of VBVAMODEHINT structures for receiving the hints.
* @returns iprt status code
* @returns VERR_NO_MEMORY HGSMI heap allocation failed.
* @returns VERR_NOT_SUPPORTED Host does not support this command.
*/
{
int rc;
+ cScreens * sizeof(VBVAMODEHINT),
if (!p)
{
LogFunc(("HGSMIHeapAlloc failed\n"));
return VERR_NO_MEMORY;
}
else
{
if (RT_SUCCESS(rc))
cScreens * sizeof(VBVAMODEHINT));
VBoxHGSMIBufferFree(pCtx, p);
}
return rc;
}
/**
* Query the supported flags in VBVAINFOSCREEN::u16Flags.
*
* @returns The mask of VBVA_SCREEN_F_* flags or 0 if host does not support the request.
* @param pCtx the context containing the heap to use
*/
{
if (RT_FAILURE(rc))
u32Flags = 0;
}