setmode.c revision b27ea9ec24c539f55433c8c33d0219f14fb354d5
/* $Id$ */
/** @file
*
* Linux Additions X11 graphics driver, mode setting
*/
/*
* Copyright (C) 2006-2013 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.
* --------------------------------------------------------------------
*
* This code is based on:
*
* X11 VESA driver
*
* Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of Conectiva Linux shall
* not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization from
* Conectiva Linux.
*
* Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
*/
#ifdef XORG_7X
/* We include <unistd.h> for Solaris below, and the ANSI C emulation layer
* interferes with that. */
# define _XF86_ANSIC_H
# define XF86_LIBC_H
# include <string.h>
#endif
#include "vboxvideo.h"
#include "version-generated.h"
#include "product-generated.h"
#include "xf86.h"
/* VGA hardware functions for setting and restoring text mode */
#include "vgaHW.h"
#ifdef RT_OS_SOLARIS
# include <sys/vuid_event.h>
# include <errno.h>
# include <fcntl.h>
# include <unistd.h>
#endif
/** Clear the virtual framebuffer in VRAM. Optionally also clear up to the
* size of a new framebuffer. Framebuffer sizes larger than available VRAM
* be treated as zero and passed over. */
{
/* Assume 32BPP - this is just a sanity test. */
("cbOldSize=%llu cbNewSize=%llu, max=%u.\n", (unsigned long long)cbOldSize, (unsigned long long)cbNewSize,
}
/** Clear the virtual framebuffer in VRAM. Optionally also clear up to the
* size of a new framebuffer. Framebuffer sizes larger than available VRAM
* be treated as zero and passed over. */
{
cbOldFB = 0;
cbNewFB = 0;
}
/** Set a graphics mode. Poke any required values into registers, do an HGSMI
* mode set and tell the host we support advanced graphics functions. This
* procedure is complicated by the fact that X.Org can implicitly disable a
* screen by resizing the virtual framebuffer so that the screen is no longer
* inside it. We have to spot and handle this.
*/
unsigned cHeight, int x, int y)
{
bool fEnabled;
int rc;
TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, displayWidth=%d\n",
/* Deactivate the screen if the mode - specifically the virtual width - is
* too large for VRAM as we sometimes have to do this - see comments in
* VBOXPreInit. */
return FALSE;
/* Deactivate the screen if it is outside of the virtual framebuffer and
* clamp it to lie inside if it is partly outside. */
return FALSE;
else
TRACE_LOG("pVBox->pScreens[%u].fCrtcEnabled=%d, fOutputEnabled=%d\n",
if (cDisplay == 0)
if (cDisplay == 0)
{
if (RT_FAILURE(rc))
FatalError("Failed to update the input mapping.\n");
}
return TRUE;
}
/** Resize the virtual framebuffer. After resizing we reset all modes
* (X.Org 1.3+) to adjust them to the new framebuffer.
*/
{
int rc;
return TRUE;
if (!pPixmap) {
"Failed to get the screen pixmap.\n");
return FALSE;
}
{
"Unable to set up a virtual screen size of %dx%d with %lu of %d Kb of video memory available. Please increase the video memory size.\n",
return FALSE;
}
#ifdef VBOX_DRI_OLD
#endif
#ifdef VBOXVIDEO_13
/* Write the new values to the hardware */
/** @todo why is this only for VBOXVIDEO_13? */
{
unsigned i;
}
#else
if (RT_FAILURE(rc))
FatalError("Failed to update the input mapping.\n");
#endif
return TRUE;
}
/** Tell the virtual mouse device about the new virtual desktop size. */
{
#ifdef RT_OS_SOLARIS
int rc;
if (hMouse >= 0)
{
do {
}
#else
#endif
}