vboxvideo.c revision 78df65edff21c11c537f38e736707ea434ab5623
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* $Id$ */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/** @file
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Linux Additions X11 graphics driver
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Copyright (C) 2006-2010 Oracle Corporation
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * available from http://www.virtualbox.org. This file is free software;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * you can redistribute it and/or modify it under the terms of the GNU
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * General Public License (GPL) as published by the Free Software
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * --------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This code is based on:
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * X11 VESA driver
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Permission is hereby granted, free of charge, to any person obtaining a
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * copy of this software and associated documentation files (the "Software"),
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * to deal in the Software without restriction, including without limitation
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * and/or sell copies of the Software, and to permit persons to whom the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Software is furnished to do so, subject to the following conditions:
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The above copyright notice and this permission notice shall be included in
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * all copies or substantial portions of the Software.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * SOFTWARE.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Except as contained in this notice, the name of Conectiva Linux shall
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * not be used in advertising or otherwise to promote the sale, use or other
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * dealings in this Software without prior written authorization from
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Conectiva Linux.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync# include "xorg-server.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync# include <string.h>
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "vboxvideo.h"
dbec828311ed2a5cf6fbc68fe4391d516ba4f92fvboxsync#include <iprt/asm-math.h>
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "version-generated.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "product-generated.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include <xf86.h>
5eb36887f6970e0033f63fa135f3bb8fbfd6059bvboxsync#include <misc.h>
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* All drivers initialising the SW cursor need this */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "mipointer.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* All drivers implementing backing store need this */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "mibstore.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* Colormap handling */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "micmap.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "xf86cmap.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* DPMS */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* #define DPMS_SERVER
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "extensions/dpms.h" */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* VGA hardware functions for setting and restoring text mode */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#include "vgaHW.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* X.org 1.3+ mode setting */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync# define _HAVE_STRING_ARCH_strsep /* bits/string2.h, __strsep_1c. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync# include "xf86Crtc.h"
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync# include "xf86Modes.h"
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync# include <X11/Xatom.h>
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* Mandatory functions */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const OptionInfoRec * VBOXAvailableOptions(int chipid, int busid);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXIdentify(int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifndef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXProbe(DriverPtr drv, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXPciProbe(DriverPtr drv, int entity_num,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync struct pci_device *dev, intptr_t match_data);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXPreInit(ScrnInfoPtr pScrn, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXScreenInit(int Index, ScreenPtr pScreen, int argc,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync char **argv);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXEnterVT(int scrnIndex, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXLeaveVT(int scrnIndex, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXCloseScreen(int scrnIndex, ScreenPtr pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXSaveScreen(ScreenPtr pScreen, int mode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync unsigned cHeight, int x, int y);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXAdjustFrame(int scrnIndex, int x, int y, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXFreeScreen(int scrnIndex, int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXFreeRec(ScrnInfoPtr pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int flags);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* locally used functions */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXMapVidMem(ScrnInfoPtr pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void VBOXUnmapVidMem(ScrnInfoPtr pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXSaveRestore(ScrnInfoPtr pScrn,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbeSaveRestoreFunction function);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncenum GenericTypes
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync CHIP_VBOX_GENERIC
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const struct pci_id_match vbox_device_match[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_VENDORID, VBOX_DEVICEID, PCI_MATCH_ANY, PCI_MATCH_ANY,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync 0, 0, 0
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync },
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync { 0, 0, 0 },
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* Supported chipsets */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic SymTabRec VBOXChipsets[] =
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {VBOX_DEVICEID, "vbox"},
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {-1, NULL}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic PciChipsets VBOXPCIchipsets[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync { VBOX_DEVICEID, VBOX_DEVICEID, RES_SHARED_VGA },
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync { -1, -1, RES_UNDEFINED },
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This contains the functions needed by the server after loading the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * driver module. It must be supplied, and gets added the driver list by
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * the Module Setup function in the dynamic case. In the static case a
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * reference to this is compiled in, and this requires that the name of
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * this DriverRec be an upper-case version of the driver name.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync_X_EXPORT
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncDriverRec VBOXVIDEO = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_VERSION,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_DRIVER_NAME,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXIdentify,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXProbe,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXAvailableOptions,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync 0,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbox_device_match,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPciProbe
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* No options for now */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const OptionInfoRec VBOXOptions[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync { -1, NULL, OPTV_NONE, {0}, FALSE }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifndef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * List of symbols from other modules that this module references. This
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * list is used to tell the loader that it is OK for symbols here to be
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * unresolved providing that it hasn't been told that they haven't been
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * told that they are essential via a call to xf86LoaderReqSymbols() or
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * unresolved symbols that are not required.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const char *fbSymbols[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "fbPictureInit",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "fbScreenInit",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const char *shadowfbSymbols[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "ShadowFBInit2",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const char *vbeSymbols[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEExtendedInit",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEFindSupportedDepths",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEGetModeInfo",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEGetVBEInfo",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEGetVBEMode",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEPrintModes",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESaveRestore",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetDisplayStart",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetGetDACPaletteFormat",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetGetLogicalScanlineLength",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetGetPaletteData",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetModeNames",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetModeParameters",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBESetVBEMode",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VBEValidateModes",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vbeDoEDID",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vbeFree",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const char *ramdacSymbols[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "xf86InitCursor",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "xf86CreateCursorInfoRec",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const char *vgahwSymbols[] = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWGetHWRec",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWHandleColormaps",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWFreeHWRec",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWMapMem",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWUnmapMem",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWSaveFonts",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWRestoreFonts",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWGetIndex",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWSaveScreen",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "vgaHWDPMSSet",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif /* !XORG_7X */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic VBOXPtr
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXGetRec(ScrnInfoPtr pScrn)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!pScrn->driverPrivate)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverPrivate = calloc(sizeof(VBOXRec), 1);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return ((VBOXPtr)pScrn->driverPrivate);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXFreeRec(ScrnInfoPtr pScrn)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync free(pVBox->savedPal);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync free(pVBox->fonts);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync free(pScrn->driverPrivate);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverPrivate = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* X.org 1.3+ mode-setting support ******************************************/
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* For descriptions of these functions and structures, see
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync hw/xfree86/modes/xf86Crtc.h and hw/xfree86/modes/xf86Modes.h in the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync X.Org source tree. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXAdjustScreenPixmap
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_dpms(xf86CrtcPtr crtc, int mode)
78df65edff21c11c537f38e736707ea434ab5623vboxsync{
78df65edff21c11c537f38e736707ea434ab5623vboxsync VBOXPtr pVBox = VBOXGetRec(crtc->scrn);
78df65edff21c11c537f38e736707ea434ab5623vboxsync unsigned cDisplay = (uintptr_t)crtc->driver_private;
78df65edff21c11c537f38e736707ea434ab5623vboxsync TRACE_LOG("cDisplay=%u, mode=%i\n", cDisplay, mode);
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->afDisabled[cDisplay] = (mode != DPMSModeOn);
78df65edff21c11c537f38e736707ea434ab5623vboxsync if ( pVBox->aScreenLocation[cDisplay].cx
78df65edff21c11c537f38e736707ea434ab5623vboxsync && pVBox->aScreenLocation[cDisplay].cy)
78df65edff21c11c537f38e736707ea434ab5623vboxsync VBOXSetMode(crtc->scrn, cDisplay,
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->aScreenLocation[cDisplay].cx,
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->aScreenLocation[cDisplay].cy,
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->aScreenLocation[cDisplay].x,
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->aScreenLocation[cDisplay].y);
78df65edff21c11c537f38e736707ea434ab5623vboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_lock (xf86CrtcPtr crtc)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) crtc; return FALSE; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr adjusted_mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) crtc; (void) mode; (void) adjusted_mode; return TRUE; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_stub (xf86CrtcPtr crtc)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) crtc; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr adjusted_mode, int x, int y)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void) mode;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(crtc->scrn);
78df65edff21c11c537f38e736707ea434ab5623vboxsync unsigned cDisplay = (uintptr_t)crtc->driver_private;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("name=%s, HDisplay=%d, VDisplay=%d, x=%d, y=%d\n", adjusted_mode->name,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync adjusted_mode->HDisplay, adjusted_mode->VDisplay, x, y);
78df65edff21c11c537f38e736707ea434ab5623vboxsync pVBox->afDisabled[cDisplay] = false;
78df65edff21c11c537f38e736707ea434ab5623vboxsync VBOXSetMode(crtc->scrn, cDisplay, adjusted_mode->HDisplay,
78df65edff21c11c537f38e736707ea434ab5623vboxsync adjusted_mode->VDisplay, x, y);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Don't remember any modes set while we are seamless, as they are
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * just temporary. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!vboxGuestIsSeamless(crtc->scrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxSaveVideoMode(crtc->scrn, adjusted_mode->HDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync adjusted_mode->VDisplay, crtc->scrn->bitsPerPixel);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync CARD16 *green, CARD16 *blue, int size)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) crtc; (void) red; (void) green; (void) blue; (void) size; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) crtc; (void) width; (void) height; return NULL; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const xf86CrtcFuncsRec VBOXCrtcFuncs = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .dpms = vbox_crtc_dpms,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .save = NULL, /* These two are never called by the server. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .restore = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .lock = vbox_crtc_lock,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .unlock = NULL, /* This will not be invoked if lock returns FALSE. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .mode_fixup = vbox_crtc_mode_fixup,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .prepare = vbox_crtc_stub,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .mode_set = vbox_crtc_mode_set,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .commit = vbox_crtc_stub,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .gamma_set = vbox_crtc_gamma_set,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .shadow_allocate = vbox_crtc_shadow_allocate,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .shadow_create = NULL, /* These two should not be invoked if allocate
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync returns NULL. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .shadow_destroy = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .set_cursor_colors = NULL, /* We are still using the old cursor API. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .set_cursor_position = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .show_cursor = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .hide_cursor = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .load_cursor_argb = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .destroy = vbox_crtc_stub
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_stub (xf86OutputPtr output)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) output; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_dpms (xf86OutputPtr output, int mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) output; (void) mode; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic int
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = output->scrn;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int rc = MODE_OK;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("HDisplay=%d, VDisplay=%d\n", mode->HDisplay, mode->VDisplay);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We always like modes specified by the user in the configuration
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * file and modes requested by the host, as doing otherwise is likely to
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * annoy people. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ( !(mode->type & M_T_USERDEF)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync && !(mode->type & M_T_PREFERRED)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync && vbox_device_available(VBOXGetRec(pScrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync && !vboxHostLikesVideoMode(pScrn, mode->HDisplay, mode->VDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->bitsPerPixel)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync )
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = MODE_BAD;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", MODE_OK == rc ? "MODE_OK" : "MODE_BAD");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr adjusted_mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) output; (void) mode; (void) adjusted_mode; return TRUE; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_mode_set (xf86OutputPtr output, DisplayModePtr mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr adjusted_mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{ (void) output; (void) mode; (void) adjusted_mode; }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* A virtual monitor is always connected. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic xf86OutputStatus
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_detect (xf86OutputPtr output)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void) output;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return XF86OutputStatusConnected;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_add_mode (VBOXPtr pVBox, DisplayModePtr *pModes,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync const char *pszName, int x, int y,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Bool isPreferred, Bool isUserDef)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("pszName=%s, x=%d, y=%d\n", pszName, x, y);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr pMode = xnfcalloc(1, sizeof(DisplayModeRec));
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->status = MODE_OK;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We don't ask the host whether it likes user defined modes,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * as we assume that the user really wanted that mode. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->type = isUserDef ? M_T_USERDEF : M_T_BUILTIN;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (isPreferred)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->type |= M_T_PREFERRED;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Older versions of VBox only support screen widths which are a multiple
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * of 8 */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->fAnyX)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->HDisplay = x;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->HDisplay = x & ~7;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->HSyncStart = pMode->HDisplay + 2;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->HSyncEnd = pMode->HDisplay + 4;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->HTotal = pMode->HDisplay + 6;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->VDisplay = y;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->VSyncStart = pMode->VDisplay + 2;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->VSyncEnd = pMode->VDisplay + 4;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->VTotal = pMode->VDisplay + 6;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->Clock = pMode->HTotal * pMode->VTotal * 60 / 1000; /* kHz */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (NULL == pszName) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86SetModeDefaultName(pMode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync } else {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pMode->name = xnfstrdup(pszName);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *pModes = xf86ModesAdd(*pModes, pMode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic DisplayModePtr
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_get_modes (xf86OutputPtr output)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync unsigned i;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DisplayModePtr pModes = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = output->scrn;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync uint32_t x, y, bpp, iScreen;
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync iScreen = (uintptr_t)output->driver_private;
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync vboxGetPreferredMode(pScrn, iScreen, &x, &y, &bpp);
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync vbox_output_add_mode(pVBox, &pModes, NULL, x, y, TRUE, FALSE);
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Also report any modes the user may have requested in the xorg.conf
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * configuration file. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync for (i = 0; pScrn->display->modes[i] != NULL; i++)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync if (2 == sscanf(pScrn->display->modes[i], "%ux%u", &x, &y))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbox_output_add_mode(pVBox, &pModes, pScrn->display->modes[i], x, y,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync FALSE, TRUE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return pModes;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef RANDR_12_INTERFACE
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsyncstatic Atom
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsyncvboxAtomVBoxMode(void)
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync{
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync static Atom rc = 0;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync if (!rc)
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync rc = MakeAtom("VBOX_MODE", sizeof("VBOX_MODE") - 1, TRUE);
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync return rc;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync}
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync/** We use this for receiving information from clients for the purpose of
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * dynamic resizing, and later possibly other things too.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvbox_output_set_property(xf86OutputPtr output, Atom property,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync RRPropertyValuePtr value)
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync{
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync ScrnInfoPtr pScrn = output->scrn;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync TRACE_LOG("property=%d, value->type=%d, value->format=%d, value->size=%ld\n",
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync (int)property, (int)value->type, value->format, value->size);
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync if (property == vboxAtomVBoxMode())
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync {
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync uint32_t cDisplay = (uintptr_t)output->driver_private;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync char sz[256] = { 0 };
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync int w, h;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync if ( value->type != XA_STRING
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync || (unsigned) value->size > (sizeof(sz) - 1))
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync return FALSE;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync strncpy(sz, value->data, value->size);
a86135e41c89c7b599607649347a4240809c784bvboxsync TRACE_LOG("screen=%u, property value=%s\n", cDisplay, sz);
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync if (sscanf(sz, "%dx%d", &w, &h) != 2)
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync return FALSE;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync pVBox->aPreferredSize[cDisplay].cx = w;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync pVBox->aPreferredSize[cDisplay].cy = h;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync return TRUE;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync }
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync return FALSE;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const xf86OutputFuncsRec VBOXOutputFuncs = {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .create_resources = vbox_output_stub,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .dpms = vbox_output_dpms,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .save = NULL, /* These two are never called by the server. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .restore = NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .mode_valid = vbox_output_mode_valid,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .mode_fixup = vbox_output_mode_fixup,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .prepare = vbox_output_stub,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .commit = vbox_output_stub,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .mode_set = vbox_output_mode_set,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .detect = vbox_output_detect,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .get_modes = vbox_output_get_modes,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef RANDR_12_INTERFACE
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .set_property = vbox_output_set_property,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync .destroy = vbox_output_stub
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif /* VBOXVIDEO_13 */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XFree86LOADER
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/* Module loader interface */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic MODULESETUPPROTO(vboxSetup);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic XF86ModuleVersionInfo vboxVersionRec =
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_DRIVER_NAME,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_VENDOR,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync MODINFOSTRING1,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync MODINFOSTRING2,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync XORG_VERSION_CURRENT,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync XF86_VERSION_CURRENT,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync 1, /* Module major version. Xorg-specific */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync 0, /* Module minor version. Xorg-specific */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync 1, /* Module patchlevel. Xorg-specific */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ABI_CLASS_VIDEODRV, /* This is a video driver */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ABI_VIDEODRV_VERSION,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync MOD_CLASS_VIDEODRV,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {0, 0, 0, 0}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This data is accessed by the loader. The name must be the module name
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * followed by "ModuleData".
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync_X_EXPORT
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncXF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic pointer
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvboxSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync static Bool Initialised = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!Initialised)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Initialised = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86AddDriver(&VBOXVIDEO, Module, HaveDriverFuncs);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86AddDriver(&VBOXVIDEO, Module, 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifndef XORG_7X
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync LoaderRefSymLists(fbSymbols,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync shadowfbSymbols,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbeSymbols,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ramdacSymbols,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vgahwSymbols,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86Msg(X_CONFIG, "Load address of symbol \"VBOXVIDEO\" is %p\n",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void *)&VBOXVIDEO);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (pointer)TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (ErrorMajor)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *ErrorMajor = LDR_ONCEONLY;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (NULL);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif /* XFree86Loader defined */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic const OptionInfoRec *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXAvailableOptions(int chipid, int busid)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (VBOXOptions);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXIdentify(int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86PrintChipsets(VBOX_NAME, "guest driver for VirtualBox", VBOXChipsets);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This function is called once, at the start of the first server generation to
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * do a minimal probe for supported hardware.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync intptr_t match_data)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, VBOXPCIchipsets,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL, NULL, NULL, NULL, NULL);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pScrn != NULL) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverVersion = VBOX_VERSION;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverName = VBOX_DRIVER_NAME;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->name = VBOX_NAME;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->Probe = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->PreInit = VBOXPreInit;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->ScreenInit = VBOXScreenInit;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->SwitchMode = VBOXSwitchMode;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->AdjustFrame = VBOXAdjustFrame;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->EnterVT = VBOXEnterVT;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->LeaveVT = VBOXLeaveVT;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->FreeScreen = VBOXFreeScreen;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciInfo = dev;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", BOOL_STR(pScrn != NULL));
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (pScrn != NULL);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifndef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXProbe(DriverPtr drv, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Bool foundScreen = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int numDevSections;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync GDevPtr *devSections;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Find the config file Device sections that match this
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * driver, and return if there are none.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ((numDevSections = xf86MatchDevice(VBOX_NAME,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync &devSections)) <= 0)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* PCI BUS */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (xf86GetPciVideoInfo()) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int numUsed;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int *usedChips;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int i;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync numUsed = xf86MatchPciInstances(VBOX_NAME, VBOX_VENDORID,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXChipsets, VBOXPCIchipsets,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync devSections, numDevSections,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync drv, &usedChips);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (numUsed > 0) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (flags & PROBE_DETECT)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync foundScreen = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync else {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync for (i = 0; i < numUsed; i++) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Allocate a ScrnInfoRec */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPCIchipsets,NULL,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync NULL,NULL,NULL,NULL))) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverVersion = VBOX_VERSION;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->driverName = VBOX_DRIVER_NAME;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->name = VBOX_NAME;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->Probe = VBOXProbe;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->PreInit = VBOXPreInit;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->ScreenInit = VBOXScreenInit;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->SwitchMode = VBOXSwitchMode;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->AdjustFrame = VBOXAdjustFrame;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->EnterVT = VBOXEnterVT;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->LeaveVT = VBOXLeaveVT;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->FreeScreen = VBOXFreeScreen;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync foundScreen = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync free(usedChips);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync free(devSections);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (foundScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/**
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This function hooks into the chain that is called when framebuffer access
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * is allowed or disallowed by a call to EnableDisableFBAccess in the server.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * In other words, it observes when the server wishes access to the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * framebuffer to be enabled and when it should be disabled. We need to know
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * this because we disable access ourselves during mode switches (presumably
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * the server should do this but it doesn't) and want to know whether to
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * restore it or not afterwards.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvboxEnableDisableFBAccess(int scrnIndex, Bool enable)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("enable=%s\n", enable ? "TRUE" : "FALSE");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->accessEnabled = enable;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->EnableDisableFBAccess(scrnIndex, enable);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync/** Calculate the BPP from the screen depth */
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncstatic uint16_t
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncvboxBPP(ScrnInfoPtr pScrn)
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync{
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync return pScrn->depth == 24 ? 32 : 16;
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync}
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync/** Calculate the scan line length for a display width */
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncstatic int32_t
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncvboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync{
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync uint64_t cbLine = ((uint64_t)cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync return cbLine < INT32_MAX ? cbLine : INT32_MAX;
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync}
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync/** Calculate the display pitch from the scan line length */
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncstatic int32_t
af0a09edb4c1431b606fe207d4138da008f67f13vboxsyncvboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync{
dbec828311ed2a5cf6fbc68fe4391d516ba4f92fvboxsync return ASMDivU64ByU32RetU32((uint64_t)cbLine * 8, vboxBPP(pScrn));
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync}
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * QUOTE from the XFree86 DESIGN document:
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The purpose of this function is to find out all the information
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * required to determine if the configuration is usable, and to initialise
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * those parts of the ScrnInfoRec that can be set once at the beginning of
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * the first server generation.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * (...)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This includes probing for video memory, clocks, ramdac, and all other
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * HW info that is needed. It includes determining the depth/bpp/visual
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * and related info. It includes validating and determining the set of
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * video modes that will be used (and anything that is required to
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * determine that).
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This information should be determined in the least intrusive way
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * possible. The state of the HW must remain unchanged by this function.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Although video memory (including MMIO) may be mapped within this
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * function, it must be unmapped before returning.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * END QUOTE
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXPreInit(ScrnInfoPtr pScrn, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Gamma gzeros = {0.0, 0.0, 0.0};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rgb rzeros = {0, 0, 0};
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync unsigned DispiId;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Are we really starting the server, or is this just a dummy run? */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (flags & PROBE_DETECT)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DrvMsg(pScrn->scrnIndex, X_INFO,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "VirtualBox guest additions video driver version "
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOX_VERSION_STRING "\n");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Get our private data from the ScrnInfoRec structure. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Initialise the guest library */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbox_init(pScrn->scrnIndex, pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Entity information seems to mean bus information. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* The ramdac module is needed for the hardware cursor. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86LoadSubModule(pScrn, "ramdac"))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We need the vbe module because we use VBE code to save and restore
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync text mode, in order to keep our code simple. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86LoadSubModule(pScrn, "vbe"))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* The framebuffer module. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (xf86LoadSubModule(pScrn, "fb") == NULL)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86LoadSubModule(pScrn, "shadowfb"))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86LoadSubModule(pScrn, "vgahw"))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Load the dri module. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86LoadSubModule(pScrn, "dri"))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifndef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->pEnt->location.type != BUS_PCI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciInfo = xf86GetPciInfoForEntity(pVBox->pEnt->index);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciTag = pciTag(pVBox->pciInfo->bus,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciInfo->device,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciInfo->func);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Set up our ScrnInfoRec structure to describe our virtual
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync capabilities to X. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->chipset = "vbox";
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->rgbBits = 8;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Let's create a nice, capable virtual monitor.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This *is* still needed, at least for server version 1.3 */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor = pScrn->confScreen->monitor;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->DDC = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->nHsync = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->hsync[0].lo = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->hsync[0].hi = 10000;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->nVrefresh = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->vrefresh[0].lo = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->monitor->vrefresh[0].hi = 100;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->progClock = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Using the PCI information caused problems with non-powers-of-two
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync sized video RAM configurations */
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync pVBox->cbFBMax = inl(VBE_DISPI_IOPORT_DATA);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync pScrn->videoRam = pVBox->cbFBMax / 1024;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Check if the chip restricts horizontal resolution or not. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync outw(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_ANYX);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DispiId = inw(VBE_DISPI_IOPORT_DATA);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (DispiId == VBE_DISPI_ID_ANYX)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->fAnyX = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->fAnyX = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Set up clock information that will support all modes we need. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges = xnfcalloc(sizeof(ClockRange), 1);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges->minClock = 1000;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges->maxClock = 1000000000;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges->clockIndex = -1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges->ClockMulFactor = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->clockRanges->ClockDivFactor = 1;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Query the host for the preferred colour depth */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync uint32_t cx = 0, cy = 0, cBits = 0;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync vboxGetPreferredMode(pScrn, 0, &cx, &cy, &cBits);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (cBits != 16)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync cBits = 24;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetDepthBpp(pScrn, cBits, 0, 0, Support32bppFb))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxAddModes(pScrn, cx, cy);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "The VBox additions only support 16 and 32bpp graphics modes\n");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86PrintDepthBpp(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Work around a bug in the original X server modesetting code, which
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * took the first valid values set to these two as maxima over the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * server lifetime. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualX = 32000;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualY = 32000;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We don't validate with xf86ValidateModes and xf86PruneModes as we
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * already know what we like and what we don't. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->currentMode = pScrn->modes;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Set the right virtual resolution. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualX = pScrn->currentMode->HDisplay;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualY = pScrn->currentMode->VDisplay;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync#endif /* !VBOXVIDEO_13 */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Needed before we initialise DRI. */
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync pVBox->cbLine = vboxLineLength(pScrn, pScrn->virtualX);
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync pScrn->displayWidth = vboxDisplayPitch(pScrn, pVBox->cbLine);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86PrintModes(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Colour weight - we always call this, since we are always in
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync truecolour. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetWeight(pScrn, rzeros, rzeros))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* visual init */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetDefaultVisual(pScrn, -1))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86SetGamma(pScrn, gzeros);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Set the DPI. Perhaps we should read this from the host? */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86SetDpi(pScrn, 96, 96);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Framebuffer-related setup */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->bitmapBitOrder = BITMAP_BIT_ORDER;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* VGA hardware initialisation */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!vgaHWGetHWRec(pScrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (TRUE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/**
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Dummy function for setting the colour palette, which we actually never
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * touch. However, the server still requires us to provide this.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncvboxLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync LOCO *colors, VisualPtr pVisual)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void)pScrn; (void) numColors; (void) indices; (void) colors;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void)pVisual;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync/*
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * QUOTE from the XFree86 DESIGN document:
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * This is called at the start of each server generation.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * (...)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Decide which operations need to be placed under resource access
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * control. (...) Map any video memory or other memory regions. (...)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Save the video card state. (...) Initialise the initial video
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * mode.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync *
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * End QUOTE.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VisualPtr visual;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync unsigned flags;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We make use of the X11 VBE code to save and restore text mode, in
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync order to keep our code simple. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ((pVBox->pVbe = VBEExtendedInit(NULL, pVBox->pEnt->index,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync SET_BIOS_SCRATCH
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync | RESTORE_BIOS_SCRATCH)) == NULL)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pScrn->memPhysBase == 0) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->memPhysBase = pVBox->pciInfo->regions[0].base_addr;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->memPhysBase = pVBox->pciInfo->memBase[0];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->fbOffset = 0;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!VBOXMapVidMem(pScrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* save current video state */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXSaveRestore(pScrn, MODE_SAVE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* mi layer - reset the visual list (?)*/
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync miClearVisualTypes();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetDefaultVisual(pScrn, -1))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->rgbBits, TrueColor))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!miSetPixmapDepths())
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->useDRI = VBOXDRIScreenInit(scrnIndex, pScreen, pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* I checked in the sources, and XFree86 4.2 does seem to support
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this function for 32bpp. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!fbScreenInit(pScreen, pVBox->base,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualX, pScrn->virtualY,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->xDpi, pScrn->yDpi,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->displayWidth, pScrn->bitsPerPixel))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Fixup RGB ordering */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual = pScreen->visuals + pScreen->numVisuals;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync while (--visual >= pScreen->visuals) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ((visual->class | DynamicClass) == DirectColor) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->offsetRed = pScrn->offset.red;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->offsetGreen = pScrn->offset.green;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->offsetBlue = pScrn->offset.blue;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->redMask = pScrn->mask.red;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->greenMask = pScrn->mask.green;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync visual->blueMask = pScrn->mask.blue;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* must be after RGB ordering fixed */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync fbPictureInit(pScreen, 0, 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86SetBlackWhitePixels(pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync miInitializeBackingStore(pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86SetBackingStore(pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We need to keep track of whether we are currently switched to a virtual
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * terminal to know whether a mode set operation is currently safe to do.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->vtSwitch = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync if (vbox_open (pScrn, pScreen, pVBox)) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxEnableVbva(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxEnableGraphicsCap(pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Initialise CRTC and output configuration for use with randr1.2. */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync xf86CrtcConfigInit(pScrn, &VBOXCrtcConfigFuncs);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync {
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync uint32_t i;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync for (i = 0; i < pVBox->cScreens; ++i)
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync {
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync char szOutput[256];
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Setup our virtual CRTCs. */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync pVBox->paCrtcs[i] = xf86CrtcCreate(pScrn, &VBOXCrtcFuncs);
11c2b573e2625474a51ae55ee1f3f82936f125davboxsync pVBox->paCrtcs[i]->driver_private = (void *)(uintptr_t)i;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Set up our virtual outputs. */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync snprintf(szOutput, sizeof(szOutput), "VBOX%u", i);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync pVBox->paOutputs[i] = xf86OutputCreate(pScrn, &VBOXOutputFuncs,
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync szOutput);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* We are not interested in the monitor section in the
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * configuration file. */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync xf86OutputUseScreenMonitor(pVBox->paOutputs[i], FALSE);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync pVBox->paOutputs[i]->possible_crtcs = 1 << i;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync pVBox->paOutputs[i]->possible_clones = 0;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync pVBox->paOutputs[i]->driver_private = (void *)(uintptr_t)i;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync TRACE_LOG("Created crtc (%p) and output %s (%p)\n",
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync (void *)pVBox->paCrtcs[i], szOutput,
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync (void *)pVBox->paOutputs[i]);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync }
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync }
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Set a sane minimum and maximum mode size */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync xf86CrtcSetSizeRange(pScrn, 64, 64, 32000, 32000);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync /* Now create our initial CRTC/output configuration. */
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync if (!xf86InitialConfiguration(pScrn, TRUE)) {
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n");
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync return (FALSE);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync }
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Initialise randr 1.2 mode-setting functions and set first mode.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Note that the mode won't be usable until the server has resized the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * framebuffer to something reasonable. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86CrtcScreenInit(pScreen)) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync /* Create our VBOX_MODE display properties. */
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync {
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync uint32_t i;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync for (i = 0; i < pVBox->cScreens; ++i)
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync {
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync char csz[] = "0x0";
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync RRChangeOutputProperty(pVBox->paOutputs[i]->randr_output,
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync vboxAtomVBoxMode(), XA_STRING, 8,
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync PropModeReplace, sizeof(csz), csz, TRUE,
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync FALSE);
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync }
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync }
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetDesiredModes(pScrn)) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else /* !VBOXVIDEO_13 */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* set first video mode */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!VBOXSetMode(pScrn, 0, pScrn->currentMode->HDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->currentMode->VDisplay, pScrn->frameX0,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->frameY0))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* And make sure that a non-current dynamic mode is at the front of the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * list */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxWriteHostModes(pScrn, pScrn->currentMode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif /* !VBOXVIDEO_13 */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* software cursor */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* colourmap code */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!miCreateDefColormap(pScreen))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if(!xf86HandleColormaps(pScreen, 256, 8, vboxLoadPalette, NULL, 0))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Hook our observer function ito the chain which is called when
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * framebuffer access is enabled or disabled in the server, and
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * assume an initial state of enabled. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->accessEnabled = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->EnableDisableFBAccess = vboxEnableDisableFBAccess;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->CloseScreen = pScreen->CloseScreen;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScreen->CloseScreen = VBOXCloseScreen;
78df65edff21c11c537f38e736707ea434ab5623vboxsync#ifdef VBOXVIDEO_13
78df65edff21c11c537f38e736707ea434ab5623vboxsync pScreen->SaveScreen = xf86SaveScreen;
78df65edff21c11c537f38e736707ea434ab5623vboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScreen->SaveScreen = VBOXSaveScreen;
78df65edff21c11c537f38e736707ea434ab5623vboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
78df65edff21c11c537f38e736707ea434ab5623vboxsync#ifdef VBOXVIDEO_13
78df65edff21c11c537f38e736707ea434ab5623vboxsync xf86DPMSInit(pScreen, xf86DPMSSet, 0);
78df65edff21c11c537f38e736707ea434ab5623vboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We probably do want to support power management - even if we just use
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync a dummy function. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DPMSInit(pScreen, VBOXDisplayPowerManagementSet, 0);
78df65edff21c11c537f38e736707ea434ab5623vboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Report any unused options (only for the first generation) */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (serverGeneration == 1)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (vbox_cursor_init(pScreen) != TRUE)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DrvMsg(scrnIndex, X_ERROR,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync "Unable to start the VirtualBox mouse pointer integration with the host system.\n");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->useDRI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->useDRI = VBOXDRIFinishScreenInit(pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return (TRUE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync/** Clear the virtual framebuffer in VRAM. Optionally also clear up to the
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync * size of a new framebuffer. Framebuffer sizes larger than available VRAM
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync * be treated as zero and passed over. */
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsyncstatic void
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsyncvboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY)
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync{
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
0fc8a97f9a19a44f1ad4670454edf26d80c42281vboxsync uint64_t cbOldFB, cbNewFB;
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync cbOldFB = pVBox->cbLine * pScrn->virtualX;
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync cbNewFB = vboxLineLength(pScrn, cNewX) * cNewY;
78df65edff21c11c537f38e736707ea434ab5623vboxsync if (cbOldFB > (uint64_t)pVBox->cbFBMax)
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync cbOldFB = 0;
78df65edff21c11c537f38e736707ea434ab5623vboxsync if (cbNewFB > (uint64_t)pVBox->cbFBMax)
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync cbNewFB = 0;
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync memset(pVBox->base, 0, max(cbOldFB, cbNewFB));
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync}
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXEnterVT(int scrnIndex, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxClearVRAM(pScrn, 0, 0);
2506c2bcd77fcc75b5640fa0f6a55fb5ab48ff80vboxsync if (pVBox->fHaveHGSMI)
2506c2bcd77fcc75b5640fa0f6a55fb5ab48ff80vboxsync vboxEnableVbva(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->vtSwitch = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->useDRI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DRIUnlock(screenInfo.screens[scrnIndex]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!xf86SetDesiredModes(pScrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!VBOXSetMode(pScrn, 0, pScrn->currentMode->HDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->currentMode->VDisplay, pScrn->frameX0,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->frameY0))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXLeaveVT(int scrnIndex, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->vtSwitch = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->fHaveHGSMI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxDisableVbva(pScrn);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxClearVRAM(pScrn, 0, 0);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync VBOXSaveRestore(pScrn, MODE_RESTORE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxDisableGraphicsCap(pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->useDRI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync DRILock(screenInfo.screens[scrnIndex], 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXCloseScreen(int scrnIndex, ScreenPtr pScreen)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync if (pVBox->fHaveHGSMI)
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxDisableVbva(pScrn);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxDisableGraphicsCap(pVBox);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxClearVRAM(pScrn, 0, 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->useDRI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXDRICloseScreen(pScreen, pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->useDRI = false;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pScrn->vtSema) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXSaveRestore(xf86Screens[scrnIndex], MODE_RESTORE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXUnmapVidMem(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->vtSema = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Destroy the VGA hardware record */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vgaHWFreeHWRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* And do additional bits which are separate for historical reasons */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vbox_close(pScrn, pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Remove our observer functions from the X server call chains. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->EnableDisableFBAccess = pVBox->EnableDisableFBAccess;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScreen->CloseScreen = pVBox->CloseScreen;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return pScreen->CloseScreen(scrnIndex, pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Bool rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn = xf86Screens[scrnIndex]; /* Why does X have three ways of referring to the screen? */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We want to disable access to the framebuffer before switching mode.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * After doing the switch, we allow access if it was allowed before. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->accessEnabled)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->EnableDisableFBAccess(scrnIndex, FALSE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = xf86SetSingleMode(pScrn, pMode, 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync VBOXAdjustScreenPixmap(pScrn, pMode->HDisplay, pMode->VDisplay);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = VBOXSetMode(pScrn, 0, pMode->HDisplay, pMode->VDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->frameX0, pScrn->frameY0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (rc)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxWriteHostModes(pScrn, pMode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86PrintModes(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (rc && !vboxGuestIsSeamless(pScrn))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxSaveVideoMode(pScrn, pMode->HDisplay, pMode->VDisplay,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->bitsPerPixel);
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->accessEnabled)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->EnableDisableFBAccess(scrnIndex, TRUE);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync/** Set a graphics mode. Poke any required values into registers, do an HGSMI
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * mode set and tell the host we support advanced graphics functions. This
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * procedure is complicated by the fact that X.Org can implicitly disable a
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * screen by resizing the virtual framebuffer so that the screen is no longer
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * inside it. We have to spot and handle this.
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync unsigned cHeight, int x, int y)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
78df65edff21c11c537f38e736707ea434ab5623vboxsync Bool rc = TRUE, fActive = !pVBox->afDisabled[cDisplay];
02e851310fa6b70ff20500172a9758a50731a451vboxsync uint32_t offStart, cwReal = cWidth;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, displayWidth=%d\n",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync cDisplay, cWidth, cHeight, x, y, pScrn->displayWidth);
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[cDisplay].cx = cWidth;
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[cDisplay].cy = cHeight;
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[cDisplay].x = x;
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[cDisplay].y = y;
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync offStart = y * pVBox->cbLine + x * vboxBPP(pScrn) / 8;
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync /* Deactivate the screen if the mode - specifically the virtual width - is
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * too large for VRAM as we sometimes have to do this - see comments in
a144bb4a097a1818739e00ba31bea88ce63f5345vboxsync * VBOXPreInit. */
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync if ( offStart + pVBox->cbLine * cHeight > pVBox->cbFBMax
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync || pVBox->cbLine * pScrn->virtualY > pVBox->cbFBMax)
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync fActive = FALSE;
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync /* Deactivate the screen if it is outside of the virtual framebuffer and
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * clamp it to lie inside if it is partly outside. */
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync if (x >= pScrn->displayWidth || x + (int) cWidth <= 0)
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync fActive = FALSE;
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync else
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync cwReal = RT_MIN((int) cWidth, pScrn->displayWidth - x);
78df65edff21c11c537f38e736707ea434ab5623vboxsync TRACE_LOG("pVBox->afDisabled[cDisplay]=%d, fActive=%d\n",
78df65edff21c11c537f38e736707ea434ab5623vboxsync (int)pVBox->afDisabled[cDisplay], (int)fActive);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Don't fiddle with the hardware if we are switched
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * to a virtual terminal. */
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync if (!pVBox->vtSwitch && fActive)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (cDisplay == 0)
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync VBoxVideoSetModeRegisters(cwReal, cHeight, pScrn->displayWidth,
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync vboxBPP(pScrn), x, y);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Tell the host we support graphics */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (vbox_device_available(pVBox))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vboxEnableGraphicsCap(pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync if ( (pVBox->fHaveHGSMI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync && !pVBox->vtSwitch)
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync VBoxHGSMIProcessDisplayInfo(&pVBox->guestCtx, cDisplay, x, y,
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync offStart, pVBox->cbLine, cwReal, cHeight,
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync vboxBPP(pScrn),
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync VBVA_SCREEN_F_ACTIVE
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync | (fActive ? 0: VBVA_SCREEN_F_DISABLED));
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync/** Resize the virtual framebuffer. After resizing we reset all modes
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * (X.Org 1.3+) to adjust them to the new framebuffer.
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScreenPtr pScreen = pScrn->pScreen;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync uint64_t cbLine = vboxLineLength(pScrn, width);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("width=%d, height=%d\n", width, height);
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync if (!pPixmap) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync "Failed to get the screen pixmap.\n");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync if (cbLine > UINT32_MAX || cbLine * height >= pVBox->cbFBMax)
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync "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",
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync width, height, pVBox->cbFBMax / 1024, pScrn->videoRam);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScreen->ModifyPixmapHeader(pPixmap, width, height,
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync pScrn->depth, vboxBPP(pScrn), cbLine,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->base);
37a7e3e6f9ce5f6cabeb3f734044e9e8ca9cb1bfvboxsync vboxClearVRAM(pScrn, width, height);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualX = width;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->virtualY = height;
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync pScrn->displayWidth = vboxDisplayPitch(pScrn, cbLine);
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync pVBox->cbLine = cbLine;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOX_DRI
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->useDRI)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXDRIUpdateStride(pScrn, pVBox);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef VBOXVIDEO_13
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Write the new values to the hardware */
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync {
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync unsigned i;
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync for (i = 0; i < pVBox->cScreens; ++i)
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync VBOXSetMode(pScrn, i, pVBox->aScreenLocation[i].cx,
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[i].cy,
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[i].x,
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync pVBox->aScreenLocation[i].y);
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXAdjustFrame(int scrnIndex, int x, int y, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(xf86Screens[scrnIndex]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Don't fiddle with the hardware if we are switched
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * to a virtual terminal. */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXSetMode(pScrn, 0, pVBox->aScreenLocation[0].cx,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->aScreenLocation[0].cy, x, y);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXFreeScreen(int scrnIndex, int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXFreeRec(xf86Screens[scrnIndex]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXMapVidMem(ScrnInfoPtr pScrn)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Bool rc = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!pVBox->base)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void) pci_device_map_range(pVBox->pciInfo,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->memPhysBase,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->videoRam * 1024,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync PCI_DEV_MAP_FLAG_WRITABLE,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync & pVBox->base);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->base = xf86MapPciMem(pScrn->scrnIndex,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VIDMEM_FRAMEBUFFER,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pciTag, pScrn->memPhysBase,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (unsigned) pScrn->videoRam * 1024);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->base)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* We need this for saving/restoring textmode */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VGAHWPTR(pScrn)->IOBase = pScrn->domainIOBase;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = vgaHWMapMem(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXUnmapVidMem(ScrnInfoPtr pScrn)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->base == NULL)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#ifdef PCIACCESS
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void) pci_device_unmap_range(pVBox->pciInfo,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->base,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pScrn->videoRam * 1024);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#else
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync xf86UnMapVidMem(pScrn->scrnIndex, pVBox->base,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (unsigned) pScrn->videoRam * 1024);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync#endif
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vgaHWUnmapMem(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->base = NULL;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_EXIT();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic Bool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXSaveScreen(ScreenPtr pScreen, int mode)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void)pScreen; (void)mode;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncBool
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXSaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBOXPtr pVBox;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Bool rc = TRUE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_ENTRY();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (MODE_QUERY < 0 || function > MODE_RESTORE)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (rc)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox = VBOXGetRec(pScrn);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Query amount of memory to save state */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (function == MODE_QUERY ||
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (function == MODE_SAVE && pVBox->state == NULL))
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Make sure we save at least this information in case of failure */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void)VBEGetVBEMode(pVBox->pVbe, &pVBox->stateMode);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vgaHWSaveFonts(pScrn, &pVBox->vgaRegs);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!VBESaveRestore(pVBox->pVbe,function,(pointer)&pVBox->state,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync &pVBox->stateSize,&pVBox->statePage)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync )
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync rc = FALSE;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (rc)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* Save/Restore Super VGA state */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (function != MODE_QUERY) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (function == MODE_RESTORE)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync memcpy(pVBox->state, pVBox->pstate,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (unsigned) pVBox->stateSize);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if ( (rc = VBESaveRestore(pVBox->pVbe,function,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (pointer)&pVBox->state,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync &pVBox->stateSize,&pVBox->statePage)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync )
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync && (function == MODE_SAVE)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync )
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync /* don't rely on the memory not being touched */
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (pVBox->pstate == NULL)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync pVBox->pstate = malloc(pVBox->stateSize);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync memcpy(pVBox->pstate, pVBox->state,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (unsigned) pVBox->stateSize);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (function == MODE_RESTORE)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync VBESetVBEMode(pVBox->pVbe, pVBox->stateMode, NULL);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync vgaHWRestoreFonts(pScrn, &pVBox->vgaRegs);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync }
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return rc;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncstatic void
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsyncVBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync int flags)
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync (void)pScrn; (void)mode; (void) flags;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync}