vbva.c revision b1ad3f99d0b864a8d2787ff732dd2c01f626f2d6
/** @file
* VirtualBox X11 Additions graphics driver 2D acceleration functions
*/
/*
* Copyright (C) 2006-2007 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/VBoxGuestLib.h>
#ifndef PCIACCESS
# include <xf86Pci.h>
# include <Pci.h>
#endif
#include "xf86.h"
#define NEED_XF86_TYPES
#include "compiler.h"
#include "vboxvideo.h"
/**************************************************************************
* Main functions *
**************************************************************************/
/**
* Callback function called by the X server to tell us about dirty
* rectangles in the video buffer.
*
* @param pScreen pointer to the information structure for the current
* screen
* @param iRects Number of dirty rectangles to update
* @param aRects Array of structures containing the coordinates of the
* rectangles
*/
static void
{
int i;
unsigned j;
return;
for (i = 0; i < iRects; ++i)
{
/* Just continue quietly if VBVA is not currently active. */
if ( !pVBVA
continue;
continue;
#if 0
TRACE_LOG("display=%u, x=%d, y=%d, w=%d, h=%d\n",
#endif
{
sizeof(cmdHdr));
}
}
}
/** Callback to fill in the view structures */
static int
{
unsigned i;
for (i = 0; i < cViews; ++i)
{
pViews[i].u32ViewIndex = i;
pViews[i].u32ViewOffset = 0;
}
return VINF_SUCCESS;
}
/**
* Initialise VirtualBox's accelerated video extensions.
*
* @returns TRUE on success, FALSE on failure
*/
static Bool
{
int rc = VINF_SUCCESS;
if (!VBoxHGSMIIsSupported())
{
xf86DrvMsg(scrnIndex, X_ERROR, "The graphics device does not seem to support HGSMI. Disableing video acceleration.\n");
return FALSE;
}
/* Set up the dirty rectangle handler. It will be added into a function
* chain and gets removed when the screen is cleaned up. */
{
"Unable to install dirty rectangle handler for VirtualBox graphics acceleration.\n");
return FALSE;
}
return TRUE;
}
/**
* Initialise VirtualBox's accelerated video extensions.
*
* @returns TRUE on success, FALSE on failure
*/
static Bool
{
int rc = VINF_SUCCESS;
unsigned i;
void *pvGuestHeapMemory;
if (!pVBox->fHaveHGSMI)
return FALSE;
NULL);
TRACE_LOG("video RAM: %u KB, guest heap offset: 0x%x, cbGuestHeapMemory: %u\n",
if (RT_FAILURE(rc))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to set up the guest-to-host communication context, rc=%d\n", rc);
return FALSE;
}
{
TRACE_LOG("VBVA buffer offset for screen %u: 0x%lx\n", i,
pVBox->aoffVBVABuffer[i],
}
TRACE_LOG("Maximum framebuffer size: %lu (0x%lx)\n",
vboxFillViewInfo, (void *)pVBox);
if (RT_FAILURE(rc))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to send the view information to the host, rc=%d\n", rc);
return FALSE;
}
return TRUE;
}
{
TRACE_ENTRY();
return pVBox->fHaveHGSMI;
}
{
}
/**
* Inform VBox that we will supply it with dirty rectangle information
* and install the dirty rectangle handler.
*
* @returns TRUE for success, FALSE for failure
* @param pScrn Pointer to a structure describing the X screen in use
*/
{
unsigned i;
TRACE_ENTRY();
return FALSE;
{
struct VBVABUFFER *pVBVA;
+ pVBox->aoffVBVABuffer[i]);
}
if (!rc)
{
/* Request not accepted - disable for old hosts. */
"Failed to enable screen update reporting for at least one virtual monitor.\n");
}
return rc;
}
/**
* Inform VBox that we will stop supplying it with dirty rectangle
* information. This function is intended to be called when an X
* virtual terminal is disabled, or the X server is terminated.
*
* @returns TRUE for success, FALSE for failure
* @param pScrn Pointer to a structure describing the X screen in use
*/
void
{
int rc;
unsigned i;
TRACE_ENTRY();
return;
}