DisplayImpl.cpp revision 9f52ff8b6b89d6ac4215d122a95b685170a5a382
/* $Id$ */
/** @file
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2010 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.
*/
#include "DisplayImpl.h"
#include "ConsoleImpl.h"
#include "ConsoleVRDPServer.h"
#include "VMMDev.h"
#include "AutoCaller.h"
#include "Logging.h"
#include <iprt/semaphore.h>
#ifdef DEBUG /* for VM_ASSERT_EMT(). */
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
# include <VBox/VBoxVideo.h>
#endif
#ifdef VBOX_WITH_CROGL
#endif
#include <png.h>
/**
* Display driver instance data.
*
* @implements PDMIDISPLAYCONNECTOR
*/
typedef struct DRVMAINDISPLAY
{
/** Pointer to the display object. */
/** Pointer to the driver instance structure. */
/** Our display connector interface. */
#if defined(VBOX_WITH_VIDEOHWACCEL)
/** VBVA callbacks */
#endif
/** Converts PDMIDISPLAYCONNECTOR pointer to a DRVMAINDISPLAY pointer. */
#define PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface) RT_FROM_MEMBER(pInterface, DRVMAINDISPLAY, IConnector)
#ifdef DEBUG_sunlover
static STAMPROFILE StatDisplayRefresh;
static int stam = 0;
#endif /* DEBUG_sunlover */
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
}
{
}
{
mpVbvaMemory = NULL;
mfVideoAccelEnabled = false;
mfVideoAccelVRDP = false;
mfu32SupportedOrders = 0;
mcVideoAccelVRDPRefs = 0;
mfPendingVideoAccelEnable = false;
mfMachineRunning = false;
mcbVbvaPartial = 0;
mfVMMDevInited = false;
mLastAddress = NULL;
mLastBytesPerLine = 0;
mLastBitsPerPixel = 0,
mLastWidth = 0;
mLastHeight = 0;
#ifdef VBOX_WITH_OLD_VBVA_LOCK
mfu32PendingVideoAccelDisable = false;
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef VBOX_WITH_HGSMI
mu32UpdateVBVAFlags = 0;
#endif
return S_OK;
}
void Display::FinalRelease()
{
uninit();
#ifdef VBOX_WITH_OLD_VBVA_LOCK
if (RTCritSectIsInitialized (&mVBVALock))
{
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
#define sSSMDisplayScreenshotVer 0x00010001
#define sSSMDisplayVer 0x00010001
#define kMaxSizePNG 1024
#define kMaxSizeThumbnail 64
/**
* Save thumbnail and screenshot of the guest screen.
*/
{
int rc = VINF_SUCCESS;
uint32_t cbThumbnail = 0;
uint32_t cxThumbnail = 0;
uint32_t cyThumbnail = 0;
{
}
else
{
}
if (pu8Thumbnail)
{
int dstX = 0;
int dstY = 0;
int srcX = 0;
int srcY = 0;
int dstW = cxThumbnail;
int dstH = cyThumbnail;
src,
}
else
{
rc = VERR_NO_MEMORY;
}
return rc;
}
typedef struct PNGWriteCtx
{
int rc;
} PNGWriteCtx;
{
{
{
if (!pNew)
{
return;
}
}
}
}
{
/* Do nothing. */
}
{
int rc = VINF_SUCCESS;
{
/* Save unscaled screenshot. */
}
else
{
/* Large screenshot, scale. */
{
}
else
{
}
if (pu8Bitmap)
{
int dstX = 0;
int dstY = 0;
int srcX = 0;
int srcY = 0;
src,
}
else
{
rc = VERR_NO_MEMORY;
}
}
if (RT_SUCCESS(rc))
{
if (row_pointers)
{
if (png_ptr)
{
if (info_ptr)
{
{
ctx.cbAllocated = 0;
unsigned i = 0;
{
row_pointers[i] = row_pointer;
}
if (RT_SUCCESS(rc))
{
}
}
else
{
}
}
else
{
rc = VERR_NO_MEMORY;
}
: (png_infopp)NULL);
}
else
{
rc = VERR_NO_MEMORY;
}
}
else
{
rc = VERR_NO_MEMORY;
}
}
{
}
return rc;
}
DECLCALLBACK(void)
{
/* 32bpp small RGB image. */
uint32_t cbThumbnail = 0;
uint32_t cxThumbnail = 0;
uint32_t cyThumbnail = 0;
/* PNG screenshot. */
{
/* Query RGB bitmap. */
/* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
int rc = that->mpDrv->pUpPort->pfnTakeScreenshot (that->mpDrv->pUpPort, &pu8Data, &cbData, &cx, &cy);
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
/*
* It is possible that success is returned but everything is 0 or NULL.
* (no display attached if a VM is running with VBoxHeadless on OSE for example)
*/
{
/* Prepare a small thumbnail and a PNG screenshot. */
/* This can be called from any thread. */
}
}
else
{
}
/* Regardless of rc, save what is available:
* Data format:
* uint32_t cBlocks;
* [blocks]
*
* Each block is:
* uint32_t cbBlock; if 0 - no 'block data'.
* uint32_t typeOfBlock; 0 - 32bpp RGB bitmap, 1 - PNG, ignored if 'cbBlock' is 0.
* [block data]
*
* Block data for bitmap and PNG:
* uint32_t cx;
* uint32_t cy;
* [image data]
*/
/* First block. */
if (cbThumbnail)
{
}
/* Second block. */
if (cbPNG)
{
}
}
DECLCALLBACK(int)
{
if (uVersion != sSSMDisplayScreenshotVer)
/* Skip data. */
{
/* Note: displaySSMSaveScreenshot writes size of a block = 8 and
* do not write any data if the image size was 0.
* @todo Fix and increase saved state version.
*/
{
}
}
return rc;
}
/**
*/
DECLCALLBACK(void)
{
for (unsigned i = 0; i < that->mcMonitors; i++)
{
}
}
DECLCALLBACK(int)
{
if (uVersion != sSSMDisplayVer)
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Number of monitors changed (%d->%d)!"), cMonitors, that->mcMonitors);
{
}
return VINF_SUCCESS;
}
/**
* Initializes the display object.
*
* @returns COM result indicator
* @param parent handle of our parent object
* @param qemuConsoleData address of common console data structure
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
// by default, we have an internal framebuffer which is
// NULL, i.e. a black hole for no display output
mFramebufferOpened = false;
mcMonitors = ul;
{
maFramebuffers[ul].w = 0;
maFramebuffers[ul].h = 0;
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
}
mParent->RegisterCallback (this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
if (mParent)
mParent->UnregisterCallback (this);
if (mpDrv)
mfVMMDevInited = true;
}
/**
* Register the SSM methods. Called by the power up thread to be able to
* pass pVM
*/
{
/*
* Register loaders for old saved states where iInstance was 3 * sizeof(uint32_t *).
*/
/* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
rc = SSMR3RegisterExternal(pVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
return VINF_SUCCESS;
}
// IConsoleCallback method
{
if ( machineState == MachineState_Running
)
{
LogFlowFunc(("Machine is running.\n"));
mfMachineRunning = true;
}
else
mfMachineRunning = false;
return S_OK;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
/**
* @thread EMT
*/
int w, int h)
{
/* Call the framebuffer to try and set required pixelFormat. */
if (!finished)
{
LogFlowFunc (("External framebuffer wants us to wait!\n"));
return VINF_VGA_RESIZE_IN_PROGRESS;
}
return VINF_SUCCESS;
}
/**
* Handles display resize event.
* Disables access to VGA device;
* calls the framebuffer RequestResize method;
* if framebuffer resizes synchronously,
* updates the display connector data and enables access to the VGA device.
*
* @param w New display width
* @param h New display height
*
* @thread EMT
*/
{
LogRel (("Display::handleDisplayResize(): uScreenId = %d, pvVRAM=%p "
"w=%d h=%d bpp=%d cbLine=0x%X\n",
/* If there is no framebuffer, this call is not interesting. */
if ( uScreenId >= mcMonitors
{
return VINF_SUCCESS;
}
mLastWidth = w;
mLastHeight = h;
switch (bpp)
{
case 32:
case 24:
case 16:
break;
default:
break;
}
/* Atomically set the resize status before calling the framebuffer. The new InProgress status will
* disable access to the VGA device by the EMT thread.
*/
if (!f)
{
/* This could be a result of the screenshot taking call Display::TakeScreenShot:
* if the framebuffer is processing the resize request and GUI calls the TakeScreenShot
* and the guest has reprogrammed the virtual VGA devices again so a new resize is required.
*
* Save the resize information and return the pending status code.
*
* Note: the resize information is only accessed on EMT so no serialization is required.
*/
LogRel (("Display::handleDisplayResize(): Warning: resize postponed.\n"));
return VINF_VGA_RESIZE_IN_PROGRESS;
}
if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
{
/* Immediately return to the caller. ResizeCompleted will be called back by the
* GUI thread. The ResizeCompleted callback will change the resize status from
* InProgress to UpdateDisplayData. The latter status will be checked by the
* display timer callback on EMT and all required adjustments will be done there.
*/
return rc;
}
/* Set the status so the 'handleResizeCompleted' would work. */
AssertRelease(f);NOREF(f);
/* The method also unlocks the framebuffer. */
return VINF_SUCCESS;
}
/**
* Framebuffer has been resized.
* Read the new display data and unlock the framebuffer.
*
* @thread EMT
*/
void Display::handleResizeCompletedEMT (void)
{
LogFlowFunc(("\n"));
unsigned uScreenId;
{
/* Try to into non resizing state. */
bool f = ASMAtomicCmpXchgU32 (&pFBInfo->u32ResizeStatus, ResizeStatus_Void, ResizeStatus_UpdateDisplayData);
if (f == false)
{
/* This is not the display that has completed resizing. */
continue;
}
/* Check whether a resize is pending for this framebuffer. */
{
/* Reset the condition, call the display resize with saved data and continue.
*
* Note: handleDisplayResize can call handleResizeCompletedEMT back,
* but infinite recursion is not possible, because when the handleResizeCompletedEMT
* is called, the pFBInfo->pendingResize.fPending is equal to false.
*/
continue;
}
{
/* Primary framebuffer has completed the resize. Update the connector data for VGA device. */
/* Check the framebuffer pixel format to setup the rendering in VGA device. */
}
#ifdef DEBUG_sunlover
if (!stam)
{
/* protect mpVM */
STAM_REG(pVM, &StatDisplayRefresh, STAMTYPE_PROFILE, "/PROF/Display/Refresh", STAMUNIT_TICKS_PER_CALL, "Time spent in EMT for display updates.");
stam = 1;
}
#endif /* DEBUG_sunlover */
/* Inform VRDP server about the change of display parameters. */
LogFlowFunc (("Calling VRDP\n"));
}
}
{
/* Correct negative x and y coordinates. */
if (*px < 0)
{
*px = 0;
}
if (*py < 0)
{
*py = 0;
}
/* Also check if coords are greater than the display resolution. */
{
}
{
}
}
unsigned mapCoordsToScreen(DISPLAYFBINFO *pInfos, unsigned cInfos, int *px, int *py, int *pw, int *ph)
{
unsigned uScreenId;
{
LogSunlover ((" [%d] %d,%d %dx%d\n", uScreenId, pInfo->xOrigin, pInfo->yOrigin, pInfo->w, pInfo->h));
{
/* The rectangle belongs to the screen. Correct coordinates. */
break;
}
}
{
/* Map to primary screen. */
uScreenId = 0;
}
return uScreenId;
}
/**
* Handles display update event.
*
* @param x Update area x coordinate
* @param y Update area y coordinate
* @param w Update area width
* @param h Update area height
*
* @thread EMT
*/
void Display::handleDisplayUpdate (int x, int y, int w, int h)
{
#ifdef VBOX_WITH_OLD_VBVA_LOCK
/*
* Always runs under either VBVA lock or, for HGSMI, DevVGA lock.
* Safe to use VBVA vars and take the framebuffer lock.
*/
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef DEBUG_sunlover
LogFlowFunc (("%d,%d %dx%d (%d,%d)\n",
#endif /* DEBUG_sunlover */
#ifdef DEBUG_sunlover
LogFlowFunc (("%d,%d %dx%d (checked)\n", x, y, w, h));
#endif /* DEBUG_sunlover */
// if there is no framebuffer, this call is not interesting
if (pFramebuffer == NULL)
return;
pFramebuffer->Lock();
if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
else
maFramebuffers[uScreenId].h);
if (w != 0 && h != 0)
pFramebuffer->NotifyUpdate(x, y, w, h);
pFramebuffer->Unlock();
#ifndef VBOX_WITH_HGSMI
if (!mfVideoAccelEnabled)
{
#else
{
#endif /* VBOX_WITH_HGSMI */
/* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush.
* Inform the server here only if VBVA is disabled.
*/
}
}
typedef struct _VBVADIRTYREGION
{
/* Copies of object's pointers used by vbvaRgn functions. */
unsigned cMonitors;
static void vbvaRgnInit (VBVADIRTYREGION *prgn, DISPLAYFBINFO *paFramebuffers, unsigned cMonitors, Display *pd, PPDMIDISPLAYPORT pp)
{
unsigned uScreenId;
{
}
}
{
LogSunlover (("x = %d, y = %d, w = %d, h = %d\n",
/*
* Here update rectangles are accumulated to form an update area.
* @todo
* Now the simpliest method is used which builds one rectangle that
* includes all update areas. A bit more advanced method can be
* employed here. The method should be fast however.
*/
{
/* Empty rectangle. */
return;
}
{
/* This is the first rectangle to be added. */
}
else
{
/* Adjust region coordinates. */
{
}
{
}
{
}
{
}
}
if (pFBInfo->fDefaultFormat)
{
//@todo pfnUpdateDisplayRect must take the vram offset parameter for the framebuffer
}
return;
}
{
{
//@todo pfnUpdateDisplayRect must take the vram offset parameter for the framebuffer
prgn->pPort->pfnUpdateDisplayRect (prgn->pPort, pFBInfo->dirtyRect.xLeft, pFBInfo->dirtyRect.yTop, w, h);
}
}
bool fVideoAccelEnabled,
bool fVideoAccelVRDP,
unsigned cFBInfos)
{
if (pVbvaMemory)
{
/* This called only on changes in mode. So reset VRDP always. */
if (fVideoAccelEnabled)
{
if (fVideoAccelVRDP)
{
}
}
}
unsigned uScreenId;
{
{
}
}
}
#ifdef VBOX_WITH_HGSMI
static void vbvaSetMemoryFlagsHGSMI (unsigned uScreenId,
bool fVideoAccelVRDP,
{
if (pFBInfo->pVBVAHostFlags)
{
if (pFBInfo->fVBVAEnabled)
{
if (fVideoAccelVRDP)
{
}
}
LogFlowFunc((" fu32HostEvents = 0x%08X, fu32SupportedOrders = 0x%08X\n", fu32HostEvents, fu32SupportedOrders));
}
}
bool fVideoAccelVRDP,
unsigned cFBInfos)
{
unsigned uScreenId;
{
}
}
#endif /* VBOX_WITH_HGSMI */
bool Display::VideoAccelAllowed (void)
{
return true;
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
{
return RTCritSectEnter(&mVBVALock);
}
void Display::vbvaUnlock(void)
{
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
/**
* @thread EMT
*/
#ifdef VBOX_WITH_OLD_VBVA_LOCK
{
int rc;
vbvaLock();
vbvaUnlock();
return rc;
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
{
int rc = VINF_SUCCESS;
/* Called each time the guest wants to use acceleration,
* or when the VGA device disables acceleration,
* or when restoring the saved state with accel enabled.
*
* VGA device disables acceleration on each video mode change
* and on reset.
*
* Guest enabled acceleration at will. And it has to enable
* acceleration after a mode change.
*/
LogFlowFunc (("mfVideoAccelEnabled = %d, fEnable = %d, pVbvaMemory = %p\n",
/* Strictly check parameters. Callers must not pass anything in the case. */
if (!VideoAccelAllowed ())
{
return VERR_NOT_SUPPORTED;
}
/*
* Verify that the VM is in running state. If it is not,
* then this must be postponed until it goes to running.
*/
if (!mfMachineRunning)
{
LogFlowFunc (("Machine is not yet running.\n"));
if (fEnable)
{
}
return rc;
}
/* Check that current status is not being changed */
if (mfVideoAccelEnabled == fEnable)
{
return rc;
}
if (mfVideoAccelEnabled)
{
/* Process any pending orders and empty the VBVA ring buffer. */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
videoAccelFlush ();
#else
VideoAccelFlush ();
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
}
if (!fEnable && mpVbvaMemory)
{
}
/* Safety precaution. There is no more VBVA until everything is setup! */
mpVbvaMemory = NULL;
mfVideoAccelEnabled = false;
/* Update entire display. */
{
}
/* Everything OK. VBVA status can be changed. */
/* Notify the VMMDev, which saves VBVA status in the saved state,
* and needs to know current status.
*/
if (pVMMDevPort)
{
}
if (fEnable)
{
mfVideoAccelEnabled = true;
/* Initialize the hardware memory. */
vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
mpVbvaMemory->off32Data = 0;
mpVbvaMemory->off32Free = 0;
mpVbvaMemory->indexRecordFirst = 0;
mpVbvaMemory->indexRecordFree = 0;
#ifdef VBOX_WITH_OLD_VBVA_LOCK
mfu32PendingVideoAccelDisable = false;
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
LogRel(("VBVA: Enabled.\n"));
}
else
{
LogRel(("VBVA: Disabled.\n"));
}
return rc;
}
#ifdef VBOX_WITH_VRDP
/* Called always by one VRDP server thread. Can be thread-unsafe.
*/
{
#ifdef VBOX_WITH_OLD_VBVA_LOCK
vbvaLock();
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
int c = fEnable?
Assert (c >= 0);
if (c == 0)
{
/* The last client has disconnected, and the accel can be
* disabled.
*/
mfVideoAccelVRDP = false;
mfu32SupportedOrders = 0;
vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
#ifdef VBOX_WITH_HGSMI
/* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
#endif /* VBOX_WITH_HGSMI */
LogRel(("VBVA: VRDP acceleration has been disabled.\n"));
}
else if ( c == 1
&& !mfVideoAccelVRDP)
{
/* The first client has connected. Enable the accel.
*/
mfVideoAccelVRDP = true;
/* Supporting all orders. */
mfu32SupportedOrders = ~0;
vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
#ifdef VBOX_WITH_HGSMI
/* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
#endif /* VBOX_WITH_HGSMI */
LogRel(("VBVA: VRDP acceleration has been requested.\n"));
}
else
{
/* A client is connected or disconnected but there is no change in the
* accel state. It remains enabled.
*/
Assert (mfVideoAccelVRDP == true);
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
vbvaUnlock();
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
}
#endif /* VBOX_WITH_VRDP */
{
return true;
}
{
if (cbDst >= VBVA_RING_BUFFER_SIZE)
{
return;
}
if (i32Diff <= 0)
{
/* Chunk will not cross buffer boundary. */
}
else
{
/* Chunk crosses buffer boundary. */
}
/* Advance data offset. */
return;
}
static bool vbvaPartialRead (uint8_t **ppu8, uint32_t *pcb, uint32_t cbRecord, VBVAMEMORY *pVbvaMemory)
{
LogFlow(("MAIN::DisplayImpl::vbvaPartialRead: p = %p, cb = %d, cbRecord 0x%08X\n",
if (*ppu8)
{
}
else
{
}
if (!pu8New)
{
/* Memory allocation failed, fail the function. */
Log(("MAIN::vbvaPartialRead: failed to (re)alocate memory for partial record!!! cbRecord 0x%08X\n",
cbRecord));
if (*ppu8)
{
}
*pcb = 0;
return false;
}
/* Fetch data from the ring buffer. */
return true;
}
/* For contiguous chunks just return the address in the buffer.
* For crossing boundary - allocate a buffer from heap.
*/
{
#ifdef DEBUG_sunlover
LogFlowFunc (("first = %d, free = %d\n",
#endif /* DEBUG_sunlover */
if (!vbvaVerifyRingBuffer (mpVbvaMemory))
{
return false;
}
if (indexRecordFirst == indexRecordFree)
{
/* No records to process. Return without assigning output variables. */
return true;
}
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
if (mcbVbvaPartial)
{
/* There is a partial read in process. Continue with it. */
LogFlowFunc (("continue partial record mcbVbvaPartial = %d cbRecord 0x%08X, first = %d, free = %d\n",
if (cbRecord > mcbVbvaPartial)
{
/* New data has been added to the record. */
{
return false;
}
}
{
/* The record is completed by guest. Return it to the caller. */
*pcbCmd = mcbVbvaPartial;
mcbVbvaPartial = 0;
/* Advance the record index. */
#ifdef DEBUG_sunlover
LogFlowFunc (("partial done ok, data = %d, free = %d\n",
#endif /* DEBUG_sunlover */
}
return true;
}
/* A new record need to be processed. */
{
/* Current record is being written by guest. '=' is important here. */
{
/* Partial read must be started. */
{
return false;
}
LogFlowFunc (("started partial record mcbVbvaPartial = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
}
return true;
}
/* Current record is complete. If it is not empty, process it. */
if (cbRecord)
{
/* The size of largest contiguos chunk in the ring biffer. */
/* The ring buffer pointer. */
/* The pointer to data in the ring buffer. */
/* Fetch or point the data. */
if (u32BytesTillBoundary >= cbRecord)
{
/* The command does not cross buffer boundary. Return address in the buffer. */
/* Advance data offset. */
}
else
{
/* The command crosses buffer boundary. Rare case, so not optimized. */
if (!dst)
{
return false;
}
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
}
}
/* Advance the record index. */
#ifdef DEBUG_sunlover
LogFlowFunc (("done ok, data = %d, free = %d\n",
#endif /* DEBUG_sunlover */
return true;
}
{
{
/* The pointer is inside ring buffer. Must be continuous chunk. */
/* Do nothing. */
}
else
{
/* The pointer is outside. It is then an allocated copy. */
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
{
mcbVbvaPartial = 0;
}
else
{
}
}
return;
}
/**
* Called regularly on the DisplayRefresh timer.
* Also on behalf of guest, when the ring buffer is full.
*
* @thread EMT
*/
#ifdef VBOX_WITH_OLD_VBVA_LOCK
void Display::VideoAccelFlush (void)
{
vbvaLock();
vbvaUnlock();
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
/* Under VBVA lock. DevVGA is not taken. */
void Display::videoAccelFlush (void)
#else
void Display::VideoAccelFlush (void)
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
{
#ifdef DEBUG_sunlover_2
#endif /* DEBUG_sunlover_2 */
if (!mfVideoAccelEnabled)
{
Log(("Display::VideoAccelFlush: called with disabled VBVA!!! Ignoring.\n"));
return;
}
/* Here VBVA is enabled and we have the accelerator memory pointer. */
#ifdef DEBUG_sunlover_2
LogFlowFunc (("indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
mpVbvaMemory->indexRecordFirst, mpVbvaMemory->indexRecordFree, mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
#endif /* DEBUG_sunlover_2 */
/* Quick check for "nothing to update" case. */
{
return;
}
/* Process the ring buffer */
unsigned uScreenId;
#ifndef VBOX_WITH_OLD_VBVA_LOCK
{
{
}
}
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
/* Initialize dirty rectangles accumulator. */
for (;;)
{
/* Fetch the command data. */
{
Log(("Display::VideoAccelFlush: unable to fetch command. off32Data = %d, off32Free = %d. Disabling VBVA!!!\n",
/* Disable VBVA on those processing errors. */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
videoAccelEnable (false, NULL);
#else
VideoAccelEnable (false, NULL);
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
break;
}
{
/* No more commands yet in the queue. */
break;
}
if (cbCmd != 0)
{
#ifdef DEBUG_sunlover
LogFlowFunc (("hdr: cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
#endif /* DEBUG_sunlover */
int x = phdr->x;
int y = phdr->y;
int w = phdr->w;
int h = phdr->h;
{
/* Handle the command.
*
* Guest is responsible for updating the guest video memory.
* The Windows guest does all drawing using Eng*.
*
* For local output, only dirty rectangle information is used
* to update changed areas.
*
* Dirty rectangles are accumulated to exclude overlapping updates and
* group small updates to a larger one.
*/
/* Accumulate the update. */
/* Forward the command to VRDP server. */
}
}
}
{
#ifndef VBOX_WITH_OLD_VBVA_LOCK
{
}
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
{
/* Draw the framebuffer. */
}
}
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
int Display::videoAccelRefreshProcess(void)
{
vbvaLock();
if (ASMAtomicCmpXchgU32(&mfu32PendingVideoAccelDisable, false, true))
{
videoAccelEnable (false, NULL);
}
else if (mfPendingVideoAccelEnable)
{
/* Acceleration was enabled while machine was not yet running
* due to restoring from saved state. Update entire display and
* actually enable acceleration.
*/
/* Acceleration can not be yet enabled.*/
if (mfMachineRunning)
{
/* Reset the pending state. */
mfPendingVideoAccelEnable = false;
}
rc = VINF_TRY_AGAIN;
}
else
{
if (mfVideoAccelEnabled)
{
videoAccelFlush ();
}
}
vbvaUnlock();
return rc;
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
// IDisplay properties
/////////////////////////////////////////////////////////////////////////////
/**
* Returns the current display width in pixel
*
* @returns COM status code
* @param width Address of result variable.
*/
{
AutoCaller autoCaller(this);
return S_OK;
}
/**
* Returns the current display height in pixel
*
* @returns COM status code
* @param height Address of result variable.
*/
{
AutoCaller autoCaller(this);
return S_OK;
}
/**
* Returns the current display color depth in bits
*
* @returns COM status code
* @param bitsPerPixel Address of result variable.
*/
{
if (!bitsPerPixel)
return E_INVALIDARG;
AutoCaller autoCaller(this);
*bitsPerPixel = cBits;
return S_OK;
}
// IDisplay methods
/////////////////////////////////////////////////////////////////////////////
{
LogFlowFunc (("\n"));
if (aFramebuffer != NULL)
AutoCaller autoCaller(this);
{
/* Must leave the lock here because the changeFramebuffer will
* also obtain it. */
/* send request to the EMT thread */
#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
{
if (is3denabled)
{
/*ComAssertRCRet (vrc, E_FAIL);*/
}
}
#endif /* VBOX_WITH_CROGL */
}
else
{
/* No VM is created (VM is powered off), do a direct call */
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* @todo this should be actually done on EMT. */
if (*aFramebuffer)
(*aFramebuffer)->AddRef ();
if (aXOrigin)
if (aYOrigin)
return S_OK;
}
{
AutoCaller autoCaller(this);
/*
* Do some rough checks for valid input
*/
if (!width)
if (!height)
if (!bpp)
{
}
return E_INVALIDARG;
return E_INVALIDARG;
// sunlover 20070614: It is up to the guest to decide whether the hint is valid.
// ULONG vramSize;
// mParent->machine()->COMGETTER(VRAMSize)(&vramSize);
// /* enough VRAM? */
// if ((width * height * (bpp / 8)) > (vramSize * 1024 * 1024))
// return setError(E_FAIL, tr("Not enough VRAM for the selected video mode"));
/* Have to leave the lock because the pfnRequestDisplayChange
* will call EMT. */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* Have to leave the lock because the pfnRequestSeamlessChange will call EMT. */
!!enabled);
return S_OK;
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
int Display::displayTakeScreenshotEMT(Display *pDisplay, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height)
{
int rc;
rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height);
pDisplay->vbvaUnlock();
return rc;
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
static int displayTakeScreenshot(PVM pVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
#else
static int displayTakeScreenshot(PVM pVM, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
{
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
/* @todo pfnTakeScreenshot is probably callable from any thread, because it uses the VGA device lock. */
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
if (RT_SUCCESS(vrc))
{
{
/* No scaling required. */
}
else
{
/* Scale. */
int dstX = 0;
int dstY = 0;
int srcX = 0;
int srcY = 0;
src,
}
/* This can be called from any thread. */
}
return vrc;
}
{
/// @todo (r=dmik) this function may take too long to complete if the VM
// is doing something like saving state right now. Which, in case if it
// is called on the GUI thread, will make it unresponsive. We should
// check the machine state here (by enclosing the check and VMRequCall
// within the Console lock to make it atomic).
LogFlowFunc (("address=%p, width=%d, height=%d\n",
AutoCaller autoCaller(this);
LogFlowFunc (("Sending SCREENSHOT request\n"));
/* Leave lock because other thread (EMT) is called and it may initiate a resize
* which also needs lock.
*
* This method does not need the lock anymore.
*/
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
if (vrc == VERR_NOT_IMPLEMENTED)
tr("This feature is not implemented"));
else if (RT_FAILURE(vrc))
return rc;
}
{
LogFlowFunc (("width=%d, height=%d\n",
AutoCaller autoCaller(this);
LogFlowFunc (("Sending SCREENSHOT request\n"));
/* Leave lock because other thread (EMT) is called and it may initiate a resize
* which also needs lock.
*
* This method does not need the lock anymore.
*/
if (!pu8Data)
return E_OUTOFMEMORY;
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
if (RT_SUCCESS(vrc))
{
/* Convert pixels to format expected by the API caller: [0] R, [1] G, [2] B, [3] A. */
while (cPixels)
{
cPixels--;
pu8 += 4;
}
for (unsigned i = 0; i < cbData; i++)
screenData[i] = pu8Data[i];
}
else if (vrc == VERR_NOT_IMPLEMENTED)
tr("This feature is not implemented"));
else
return rc;
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
int Display::DrawToScreenEMT(Display *pDisplay, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height)
{
int rc;
rc = pDisplay->mpDrv->pUpPort->pfnDisplayBlt(pDisplay->mpDrv->pUpPort, address, x, y, width, height);
pDisplay->vbvaUnlock();
return rc;
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
{
/// @todo (r=dmik) this function may take too long to complete if the VM
// is doing something like saving state right now. Which, in case if it
// is called on the GUI thread, will make it unresponsive. We should
// check the machine state here (by enclosing the check and VMRequCall
// within the Console lock to make it atomic).
LogFlowFunc (("address=%p, x=%d, y=%d, width=%d, height=%d\n",
AutoCaller autoCaller(this);
/*
* Again we're lazy and make the graphics device do all the
* dirty conversion work.
*/
#ifdef VBOX_WITH_OLD_VBVA_LOCK
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
/*
* If the function returns not supported, we'll have to do all the
* work ourselves using the framebuffer.
*/
{
/** @todo implement generic fallback for screen blitting. */
}
else if (RT_FAILURE(rcVBox))
//@todo
// else
// {
// /* All ok. Redraw the screen. */
// handleDisplayUpdate (x, y, width, height);
// }
return rc;
}
#ifdef VBOX_WITH_OLD_VBVA_LOCK
{
pDisplay->vbvaUnlock();
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
/**
* Does a full invalidation of the VM display and instructs the VM
* to update it immediately.
*
* @returns COM status code
*/
{
AutoCaller autoCaller(this);
LogFlowFunc (("Sending DPYUPDATE request\n"));
/* Have to leave the lock when calling EMT. */
/* pdm.h says that this has to be called from the EMT thread */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
1, this);
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
if (RT_FAILURE(rcVBox))
return rc;
}
/**
* Notification that the framebuffer has completed the
* asynchronous resize processing
*
* @returns COM status code
*/
{
LogFlowFunc (("\n"));
/// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
// do it when we switch this class to VirtualBoxBase_NEXT.
// This will require general code review and may add some details.
// In particular, we may want to check whether EMT is really waiting for
// this notification, etc. It might be also good to obey the caller to make
// sure this method is not called from more than one thread at a time
// (and therefore don't use Display lock at all here to save some
// milliseconds).
AutoCaller autoCaller(this);
/* this is only valid for external framebuffers */
return setError(VBOX_E_NOT_SUPPORTED,
tr("Resize completed notification is valid only for external framebuffers"));
/* Set the flag indicating that the resize has completed and display
* data need to be updated. */
AssertRelease(f);NOREF(f);
return S_OK;
}
/**
* Notification that the framebuffer has completed the
* asynchronous update processing
*
* @returns COM status code
*/
{
LogFlowFunc (("\n"));
/// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
// do it when we switch this class to VirtualBoxBase_NEXT.
// Tthis will require general code review and may add some details.
// In particular, we may want to check whether EMT is really waiting for
// this notification, etc. It might be also good to obey the caller to make
// sure this method is not called from more than one thread at a time
// (and therefore don't use Display lock at all here to save some
// milliseconds).
AutoCaller autoCaller(this);
/* this is only valid for external framebuffers */
return setError(VBOX_E_NOT_SUPPORTED,
tr("Resize completed notification is valid only for external framebuffers"));
return S_OK;
}
{
#ifdef VBOX_WITH_VIDEOHWACCEL
return S_OK;
#else
return E_NOTIMPL;
#endif
}
// private methods
/////////////////////////////////////////////////////////////////////////////
/**
* Helper to update the display information from the framebuffer.
*
* @param aCheckParams true to compare the parameters of the current framebuffer
* and the new one and issue handleDisplayResize()
* if they differ.
* @thread EMT
*/
{
/* the driver might not have been constructed yet */
if (!mpDrv)
return;
#if DEBUG
/*
* Sanity check. Note that this method may be called on EMT after Console
* has started the power down procedure (but before our #drvDestruct() is
* called, in which case pVM will aleady be NULL but mpDrv will not). Since
* we don't really need pVM to proceed, we avoid this check in the release
* build to save some ms (necessary to construct SafeVMPtrQuiet) in this
* time-critical method.
*/
#endif
/* The method is only relevant to the primary framebuffer. */
if (pFramebuffer)
{
AssertComRC (rc);
ULONG bytesPerLine = 0;
AssertComRC (rc);
ULONG bitsPerPixel = 0;
AssertComRC (rc);
AssertComRC (rc);
AssertComRC (rc);
/*
* Check current parameters with new ones and issue handleDisplayResize()
* to let the new frame buffer adjust itself properly. Note that it will
* result into a recursive updateDisplayData() call but with
* aCheckOld = false.
*/
if (aCheckParams &&
(mLastAddress != address ||
mLastWidth != (int) width ||
mLastHeight != (int) height))
{
return;
}
}
else
{
/* black hole */
}
}
/**
* Changes the current frame buffer. Called on EMT to avoid both
* race conditions and excessive locking.
*
* @note locks this object for writing
* @thread EMT
*/
/* static */
unsigned uScreenId)
{
return VINF_SUCCESS;
}
/**
* Handle display resize event issued by the VGA device for the primary screen.
*
* @see PDMIDISPLAYCONNECTOR::pfnResize
*/
{
LogFlowFunc (("bpp %d, pvVRAM %p, cbLine %d, cx %d, cy %d\n",
}
/**
* Handle display update.
*
* @see PDMIDISPLAYCONNECTOR::pfnUpdateRect
*/
{
#ifdef DEBUG_sunlover
LogFlowFunc (("mfVideoAccelEnabled = %d, %d,%d %dx%d\n",
#endif /* DEBUG_sunlover */
/* This call does update regardless of VBVA status.
* But in VBVA mode this is called only as result of
* pfnUpdateDisplayAll in the VGA device.
*/
}
/**
* Periodic display refresh callback.
*
* @see PDMIDISPLAYCONNECTOR::pfnRefresh
*/
{
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
#ifdef DEBUG_sunlover_2
LogFlowFunc (("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
#endif /* DEBUG_sunlover_2 */
bool fNoUpdate = false; /* Do not update the display if any of the framebuffers is being resized. */
unsigned uScreenId;
{
/* Check the resize status. The status can be checked normally because
* the status affects only the EMT.
*/
{
fNoUpdate = true; /* Always set it here, because pfnUpdateDisplayAll can cause a new resize. */
/* The framebuffer was resized and display data need to be updated. */
{
/* The resize status could be not Void here because a pending resize is issued. */
continue;
}
/* Continue with normal processing because the status here is ResizeStatus_Void. */
if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
{
/* Repaint the display because VM continued to run during the framebuffer resize. */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
{
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
pDisplay->vbvaUnlock();
}
#endif /* VBOX_WITH_OLD_VBVA_LOCK */
}
}
else if (u32ResizeStatus == ResizeStatus_InProgress)
{
/* The framebuffer is being resized. Do not call the VGA device back. Immediately return. */
LogFlowFunc (("ResizeStatus_InProcess\n"));
fNoUpdate = true;
continue;
}
}
if (!fNoUpdate)
{
#ifdef VBOX_WITH_OLD_VBVA_LOCK
{
if (rc == VWRN_INVALID_STATE)
{
/* No VBVA do a display update. */
{
pDisplay->vbvaUnlock();
}
}
/* Inform the VRDP server that the current display update sequence is
* completed. At this moment the framebuffer memory contains a definite
* image, that is synchronized with the orders already sent to VRDP client.
* The server can now process redraw requests from clients or initial
* fullscreen updates for new clients.
*/
{
{
}
}
}
#else
{
/* Acceleration was enabled while machine was not yet running
* due to restoring from saved state. Update entire display and
* actually enable acceleration.
*/
/* Acceleration can not be yet enabled.*/
if (pDisplay->mfMachineRunning)
{
/* Reset the pending state. */
pDisplay->mfPendingVideoAccelEnable = false;
}
}
else
{
if (pDisplay->mfVideoAccelEnabled)
{
pDisplay->VideoAccelFlush ();
}
else
{
{
}
}
/* Inform the VRDP server that the current display update sequence is
* completed. At this moment the framebuffer memory contains a definite
* image, that is synchronized with the orders already sent to VRDP client.
* The server can now process redraw requests from clients or initial
* fullscreen updates for new clients.
*/
{
{
}
}
}
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
}
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
#ifdef DEBUG_sunlover_2
LogFlowFunc (("leave\n"));
#endif /* DEBUG_sunlover_2 */
}
/**
* Reset notification
*
* @see PDMIDISPLAYCONNECTOR::pfnReset
*/
{
LogFlowFunc (("\n"));
/* Disable VBVA mode. */
}
/**
* LFBModeChange notification
*
* @see PDMIDISPLAYCONNECTOR::pfnLFBModeChange
*/
DECLCALLBACK(void) Display::displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled)
{
/* Disable VBVA mode in any case. The guest driver reenables VBVA mode if necessary. */
#ifdef VBOX_WITH_OLD_VBVA_LOCK
/* This is called under DevVGA lock. Postpone disabling VBVA, do it in the refresh timer. */
#else
#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
}
/**
* Adapter information change notification.
*
* @see PDMIDISPLAYCONNECTOR::pfnProcessAdapterData
*/
DECLCALLBACK(void) Display::displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize)
{
{
unsigned i;
{
pFBInfo->u32MaxFramebufferSize = 0;
pFBInfo->u32InformationSize = 0;
}
}
#ifndef VBOX_WITH_HGSMI
else
{
// @todo
for (;;)
{
pu8 += sizeof (VBOXVIDEOINFOHDR);
{
LogRel(("VBoxVideo: Guest adapter information overflow!!!\n"));
break;
}
{
{
LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "DISPLAY", pHdr->u16Length));
break;
}
{
break;
}
LogFlow(("VBOX_VIDEO_INFO_TYPE_DISPLAY: %d: at 0x%08X, size 0x%08X, info 0x%08X\n", pDisplay->u32Index, pDisplay->u32Offset, pDisplay->u32FramebufferSize, pDisplay->u32InformationSize));
}
{
{
LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "CONF32", pHdr->u16Length));
break;
}
{
{
} break;
{
/* @todo make configurable. */
} break;
default:
}
}
{
{
break;
}
break;
}
else if (pHdr->u8Type != VBOX_VIDEO_INFO_TYPE_NV_HEAP) /** @todo why is Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp pushing this to us? */
{
LogRel(("Guest adapter information contains unsupported type %d. The block has been skipped.\n", pHdr->u8Type));
}
}
}
#endif /* !VBOX_WITH_HGSMI */
}
/**
* Display information change notification.
*
* @see PDMIDISPLAYCONNECTOR::pfnProcessDisplayData
*/
DECLCALLBACK(void) Display::displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId)
{
{
return;
}
/* Get the display information structure. */
// @todo
for (;;)
{
pu8 += sizeof (VBOXVIDEOINFOHDR);
{
LogRel(("VBoxVideo: Guest display information overflow!!!\n"));
break;
}
{
{
LogRel(("VBoxVideo: Guest display information %s invalid length %d!!!\n", "SCREEN", pHdr->u16Length));
break;
}
LogFlow(("VBOX_VIDEO_INFO_TYPE_SCREEN: (%p) %d: at %d,%d, linesize 0x%X, size %dx%d, bpp %d, flags 0x%02X\n",
pHdr, uScreenId, pScreen->xOrigin, pScreen->yOrigin, pScreen->u32LineSize, pScreen->u16Width, pScreen->u16Height, pScreen->bitsPerPixel, pScreen->u8Flags));
if (uScreenId != VBOX_VIDEO_PRIMARY_SCREEN)
{
/* Primary screen resize is initiated by the VGA device. */
pDrv->pDisplay->handleDisplayResize(uScreenId, pScreen->bitsPerPixel, (uint8_t *)pvVRAM + pFBInfo->u32Offset, pScreen->u32LineSize, pScreen->u16Width, pScreen->u16Height);
}
}
{
{
break;
}
break;
}
{
{
LogRel(("VBoxVideo: Guest display information %s invalid length %d!!!\n", "HOST_EVENTS", pHdr->u16Length));
break;
}
LogFlow(("VBOX_VIDEO_INFO_TYPE_HOSTEVENTS: (%p)\n",
pHostEvents));
}
{
{
LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "LINK", pHdr->u16Length));
break;
}
}
else
{
}
}
}
#ifdef VBOX_WITH_VIDEOHWACCEL
{
int rc = VINF_SUCCESS;
if(id < mcMonitors)
{
if (pFramebuffer != NULL)
{
pFramebuffer->Lock();
{
}
pFramebuffer->Unlock();
}
else
{
}
}
else
{
}
if(RT_FAILURE(rc))
{
/* tell the guest the command is complete */
}
}
DECLCALLBACK(void) Display::displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand)
{
}
#endif
#ifdef VBOX_WITH_HGSMI
DECLCALLBACK(int) Display::displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags)
{
vbvaSetMemoryFlagsHGSMI(uScreenId, pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, &pThis->maFramebuffers[uScreenId]);
return VINF_SUCCESS;
}
DECLCALLBACK(void) Display::displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
{
}
DECLCALLBACK(void) Display::displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
{
{
vbvaSetMemoryFlagsAllHGSMI(pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, pThis->maFramebuffers, pThis->mcMonitors);
}
{
{
/* Some updates were skipped. Note: displayVBVAUpdate* callbacks are called
* under display device lock, so thread safe.
*/
pFBInfo->cVBVASkipUpdate = 0;
}
}
else
{
/* The framebuffer is being resized. */
}
}
DECLCALLBACK(void) Display::displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd)
{
{
if (pFBInfo->fDefaultFormat)
{
}
}
}
DECLCALLBACK(void) Display::displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y, uint32_t cx, uint32_t cy)
{
/* @todo handleFramebufferUpdate (uScreenId,
* x - pThis->maFramebuffers[uScreenId].xOrigin,
* y - pThis->maFramebuffers[uScreenId].yOrigin,
* cx, cy);
*/
{
}
else
{
/* Save the updated rectangle. */
{
}
else
{
{
}
{
}
{
}
{
}
}
}
}
DECLCALLBACK(int) Display::displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, const PVBVAINFOVIEW pView, const PVBVAINFOSCREEN pScreen, void *pvVRAM)
{
}
DECLCALLBACK(int) Display::displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
const void *pvShape)
{
LogFlowFunc(("\n"));
/* Tell the console about it */
return VINF_SUCCESS;
}
#endif /* VBOX_WITH_HGSMI */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/**
* Destruct a display driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
*/
{
{
}
}
/**
* Construct a display driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Validate configuration.
*/
("Configuration error: Not possible to attach anything to this driver!\n"),
/*
* Init Interfaces.
*/
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
#ifdef VBOX_WITH_HGSMI
#endif
/*
*/
{
AssertMsgFailed(("Configuration error: No display port interface above!\n"));
return VERR_PDM_MISSING_INTERFACE_ABOVE;
}
#if defined(VBOX_WITH_VIDEOHWACCEL)
if (!pData->pVBVACallbacks)
{
AssertMsgFailed(("Configuration error: No VBVA callback interface above!\n"));
return VERR_PDM_MISSING_INTERFACE_ABOVE;
}
#endif
/*
* Get the Display object pointer and update the mpDrv member.
*/
void *pv;
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Update our display information according to the framebuffer
*/
/*
* Start periodic screen refreshes
*/
return VINF_SUCCESS;
}
/**
* Display driver registration record.
*/
{
/* u32Version */
/* szName */
"MainDisplay",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Main display driver (Main as in the API).",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVMAINDISPLAY),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};
/* vi: set tabstop=4 shiftwidth=4 expandtab: */