vboxvideo.c revision 23ff0a80f28ba27da3cb458face82665fe65e96c
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* $Id$ */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/** @file
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Linux Additions X11 graphics driver
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright (C) 2006-2013 Oracle Corporation
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * available from http://www.virtualbox.org. This file is free software;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * General Public License (GPL) as published by the Free Software
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * --------------------------------------------------------------------
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This code is based on the X.Org VESA driver with the following copyrights:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright 2008 Red Hat, Inc.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright 2012 Red Hat, Inc.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * and the following permission notice (not all original sourse files include
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * the last paragraph):
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Permission is hereby granted, free of charge, to any person obtaining a
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * copy of this software and associated documentation files (the "Software"),
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * to deal in the Software without restriction, including without limitation
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * and/or sell copies of the Software, and to permit persons to whom the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Software is furnished to do so, subject to the following conditions:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * The above copyright notice and this permission notice shall be included in
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * all copies or substantial portions of the Software.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * SOFTWARE.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync *
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * Except as contained in this notice, the name of Conectiva Linux shall
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * not be used in advertising or otherwise to promote the sale, use or other
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * dealings in this Software without prior written authorization from
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * Conectiva Linux.
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * David Dawes <dawes@xfree86.org>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Adam Jackson <ajax@redhat.com>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Dave Airlie <airlied@redhat.com>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef XORG_7X
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync# include <stdlib.h>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync# include <string.h>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "xf86.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "xf86_OSproc.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include "xf86Resources.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* This was accepted upstream in X.Org Server 1.16 which bumped the video
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * driver ABI to 17. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 17
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define SET_HAVE_VT_PROPERTY
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Drivers for PCI hardware need this */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync# include "xf86PciInfo.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/* Drivers that need to access the PCI config space directly need this */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync# include "xf86Pci.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "fb.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "vboxvideo.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <VBox/VBoxGuest.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "version-generated.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "product-generated.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <xf86.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <misc.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/* All drivers initialising the SW cursor need this */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "mipointer.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync/* Colormap handling */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "micmap.h"
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include "xf86cmap.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* DPMS */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* #define DPMS_SERVER
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "extensions/dpms.h" */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* VGA hardware functions for setting and restoring text mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "vgaHW.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXVIDEO_13
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* X.org 1.3+ mode setting */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define _HAVE_STRING_ARCH_strsep /* bits/string2.h, __strsep_1c. */
ffb50166c9adb4ae583b914d405197035cf890advboxsync# include "xf86Crtc.h"
ffb50166c9adb4ae583b914d405197035cf890advboxsync# include "xf86Modes.h"
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync/* For setting the root window property. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <X11/Xatom.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "property.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_DRI
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include "xf86drm.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include "xf86drmMode.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Mandatory functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const OptionInfoRec * VBOXAvailableOptions(int chipid, int busid);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXIdentify(int flags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXProbe(DriverPtr drv, int flags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXPciProbe(DriverPtr drv, int entity_num,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync struct pci_device *dev, intptr_t match_data);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXPreInit(ScrnInfoPtr pScrn, int flags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXScreenInit(ScreenPtr pScreen, int argc, char **argv);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXEnterVT(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXLeaveVT(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXCloseScreen(ScreenPtr pScreen);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXSaveScreen(ScreenPtr pScreen, int mode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr pMode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXAdjustFrame(ScrnInfoPtr pScrn, int x, int y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXFreeScreen(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int flags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* locally used functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXMapVidMem(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXUnmapVidMem(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXSaveMode(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXRestoreMode(ScrnInfoPtr pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic inline void VBOXSetRec(ScrnInfoPtr pScrn)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pScrn->driverPrivate)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync VBOXPtr pVBox = (VBOXPtr)xnfcalloc(sizeof(VBOXRec), 1);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pScrn->driverPrivate = pVBox;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->fdACPIDevices = -1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncenum GenericTypes
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync CHIP_VBOX_GENERIC
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync};
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const struct pci_id_match vbox_device_match[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync VBOX_VENDORID, VBOX_DEVICEID, PCI_MATCH_ANY, PCI_MATCH_ANY,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 0, 0, 0
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { 0, 0, 0 },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Supported chipsets */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic SymTabRec VBOXChipsets[] =
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {VBOX_DEVICEID, "vbox"},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {-1, NULL}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic PciChipsets VBOXPCIchipsets[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { VBOX_DEVICEID, VBOX_DEVICEID, RES_SHARED_VGA },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { -1, -1, RES_UNDEFINED },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This contains the functions needed by the server after loading the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * driver module. It must be supplied, and gets added the driver list by
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * the Module Setup function in the dynamic case. In the static case a
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * reference to this is compiled in, and this requires that the name of
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * this DriverRec be an upper-case version of the driver name.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync_X_EXPORT
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncDriverRec VBOXVIDEO = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_VERSION,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_DRIVER_NAME,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXIdentify,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXProbe,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXAvailableOptions,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 0,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vbox_device_match,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPciProbe
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* No options for now */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const OptionInfoRec VBOXOptions[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { -1, NULL, OPTV_NONE, {0}, FALSE }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * List of symbols from other modules that this module references. This
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * list is used to tell the loader that it is OK for symbols here to be
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * unresolved providing that it hasn't been told that they haven't been
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * told that they are essential via a call to xf86LoaderReqSymbols() or
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * unresolved symbols that are not required.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const char *fbSymbols[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "fbPictureInit",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "fbScreenInit",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const char *shadowfbSymbols[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "ShadowFBInit2",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const char *ramdacSymbols[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "xf86DestroyCursorInfoRec",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "xf86InitCursor",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "xf86CreateCursorInfoRec",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const char *vgahwSymbols[] = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWFreeHWRec",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWGetHWRec",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWGetIOBase",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWGetIndex",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWRestore",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWSave",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "vgaHWSetStdFuncs",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif /* !XORG_7X */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXVIDEO_13
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* X.org 1.3+ mode-setting support ******************************************/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* For descriptions of these functions and structures, see
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync hw/xfree86/modes/xf86Crtc.h and hw/xfree86/modes/xf86Modes.h in the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync X.Org source tree. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool vbox_config_resize(ScrnInfoPtr pScrn, int cw, int ch)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("width=%d, height=%d\n", cw, ch);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Save the size in case we need to re-set it later. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->FBSize.cx = cw;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->FBSize.cy = ch;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Don't fiddle with the hardware if we are switched
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * to a virtual terminal. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pScrn->vtSema) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "We do not own the active VT, exiting.\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VBOXAdjustScreenPixmap(pScrn, cw, ch);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vbox_config_resize
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_dpms(xf86CrtcPtr crtc, int mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(crtc->scrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned cDisplay = (uintptr_t)crtc->driver_private;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bool fEnabled = (mode != DPMSModeOff);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("cDisplay=%u, mode=%i\n", cDisplay, mode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].fCrtcEnabled = fEnabled;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Don't fiddle with the hardware if we are switched
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * to a virtual terminal. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!crtc->scrn->vtSema) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "We do not own the active VT, exiting.\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( pVBox->pScreens[cDisplay].aScreenLocation.cx
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && pVBox->pScreens[cDisplay].aScreenLocation.cy)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetMode(crtc->scrn, cDisplay,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cx,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cy,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.x,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_lock (xf86CrtcPtr crtc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) crtc; return FALSE; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* We use this function to check whether the X server owns the active virtual
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * terminal before attempting a mode switch, since the RandR extension isn't
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * very dilligent here, which can mean crashes if we are unlucky. This is
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * not the way it the function is intended - it is meant for reporting modes
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * which the hardware can't handle. I hope that this won't confuse any clients
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * connecting to us. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr adjusted_mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) crtc; (void) mode; (void) adjusted_mode; return TRUE; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_stub (xf86CrtcPtr crtc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) crtc; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr adjusted_mode, int x, int y)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (void) mode;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(crtc->scrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned cDisplay = (uintptr_t)crtc->driver_private;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("name=%s, HDisplay=%d, VDisplay=%d, x=%d, y=%d\n", adjusted_mode->name,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync adjusted_mode->HDisplay, adjusted_mode->VDisplay, x, y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].fCrtcEnabled = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].fOutputEnabled = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cx = adjusted_mode->HDisplay;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cy = adjusted_mode->VDisplay;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.x = x;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.y = y;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Don't fiddle with the hardware if we are switched
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * to a virtual terminal. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!crtc->scrn->vtSema)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "We do not own the active VT, exiting.\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetMode(crtc->scrn, cDisplay, adjusted_mode->HDisplay,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync adjusted_mode->VDisplay, x, y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync CARD16 *green, CARD16 *blue, int size)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) crtc; (void) red; (void) green; (void) blue; (void) size; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) crtc; (void) width; (void) height; return NULL; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const xf86CrtcFuncsRec VBOXCrtcFuncs = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .dpms = vbox_crtc_dpms,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .save = NULL, /* These two are never called by the server. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .restore = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .lock = vbox_crtc_lock,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .unlock = NULL, /* This will not be invoked if lock returns FALSE. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .mode_fixup = vbox_crtc_mode_fixup,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .prepare = vbox_crtc_stub,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .mode_set = vbox_crtc_mode_set,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .commit = vbox_crtc_stub,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .gamma_set = vbox_crtc_gamma_set,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .shadow_allocate = vbox_crtc_shadow_allocate,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .shadow_create = NULL, /* These two should not be invoked if allocate
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync returns NULL. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .shadow_destroy = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .set_cursor_colors = NULL, /* We are still using the old cursor API. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .set_cursor_position = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .show_cursor = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .hide_cursor = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .load_cursor_argb = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .destroy = vbox_crtc_stub
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_stub (xf86OutputPtr output)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) output; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_dpms (xf86OutputPtr output, int mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(output->scrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned cDisplay = (uintptr_t)output->driver_private;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bool fEnabled = (mode == DPMSModeOn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("cDisplay=%u, mode=%i\n", cDisplay, mode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].fOutputEnabled = fEnabled;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Don't fiddle with the hardware if we are switched
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * to a virtual terminal. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!output->scrn->vtSema) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "We do not own the active VT, exiting.\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ( pVBox->pScreens[cDisplay].aScreenLocation.cx
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && pVBox->pScreens[cDisplay].aScreenLocation.cy)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetMode(output->scrn, cDisplay,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cx,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.cy,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.x,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[cDisplay].aScreenLocation.y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic int
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return MODE_OK;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr adjusted_mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) output; (void) mode; (void) adjusted_mode; return TRUE; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_mode_set (xf86OutputPtr output, DisplayModePtr mode,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr adjusted_mode)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) output; (void) mode; (void) adjusted_mode; }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* A virtual monitor is always connected. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic xf86OutputStatus
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncvbox_output_detect (xf86OutputPtr output)
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ScrnInfoPtr pScrn = output->scrn;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync uint32_t iScreen = (uintptr_t)output->driver_private;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pVBox->pScreens[iScreen].afConnected
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ? XF86OutputStatusConnected : XF86OutputStatusDisconnected;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DisplayModePtr vbox_output_add_mode(VBOXPtr pVBox, DisplayModePtr *pModes, const char *pszName, int x, int y,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Bool isPreferred, Bool isUserDef)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("pszName=%s, x=%d, y=%d\n", pszName ? pszName : "(null)", x, y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr pMode = xnfcalloc(1, sizeof(DisplayModeRec));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int cRefresh = 60;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->status = MODE_OK;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* We don't ask the host whether it likes user defined modes,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * as we assume that the user really wanted that mode. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->type = isUserDef ? M_T_USERDEF : M_T_BUILTIN;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (isPreferred)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->type |= M_T_PREFERRED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Older versions of VBox only support screen widths which are a multiple
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * of 8 */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pVBox->fAnyX)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->HDisplay = x;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->HDisplay = x & ~7;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->HSyncStart = pMode->HDisplay + 2;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->HSyncEnd = pMode->HDisplay + 4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->HTotal = pMode->HDisplay + 6;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->VDisplay = y;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->VSyncStart = pMode->VDisplay + 2;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->VSyncEnd = pMode->VDisplay + 4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->VTotal = pMode->VDisplay + 6;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->Clock = pMode->HTotal * pMode->VTotal * cRefresh / 1000; /* kHz */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (NULL == pszName) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86SetModeDefaultName(pMode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync } else {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode->name = xnfstrdup(pszName);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pModes = xf86ModesAdd(*pModes, pMode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pMode;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DisplayModePtr
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvbox_output_get_modes (xf86OutputPtr output)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned i, cIndex = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DisplayModePtr pModes = NULL, pMode;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ScrnInfoPtr pScrn = output->scrn;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_ENTRY();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync uint32_t x, y, iScreen;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync iScreen = (uintptr_t)output->driver_private;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxUpdateSizeHints(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pMode = vbox_output_add_mode(pVBox, &pModes, NULL, pVBox->pScreens[iScreen].aPreferredSize.cx,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[iScreen].aPreferredSize.cy, TRUE, FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_EXIT();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pModes;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const xf86OutputFuncsRec VBOXOutputFuncs = {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .create_resources = vbox_output_stub,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .dpms = vbox_output_dpms,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .save = NULL, /* These two are never called by the server. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .restore = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .mode_valid = vbox_output_mode_valid,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .mode_fixup = vbox_output_mode_fixup,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .prepare = vbox_output_stub,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .commit = vbox_output_stub,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .mode_set = vbox_output_mode_set,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .detect = vbox_output_detect,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .get_modes = vbox_output_get_modes,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef RANDR_12_INTERFACE
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .set_property = NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync .destroy = vbox_output_stub
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif /* VBOXVIDEO_13 */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Module loader interface */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic MODULESETUPPROTO(vboxSetup);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic XF86ModuleVersionInfo vboxVersionRec =
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_DRIVER_NAME,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_VENDOR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync MODINFOSTRING1,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync MODINFOSTRING2,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync XORG_VERSION_CURRENT,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync XF86_VERSION_CURRENT,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 1, /* Module major version. Xorg-specific */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 0, /* Module minor version. Xorg-specific */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 1, /* Module patchlevel. Xorg-specific */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ABI_CLASS_VIDEODRV, /* This is a video driver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ABI_VIDEODRV_VERSION,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync MOD_CLASS_VIDEODRV,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {0, 0, 0, 0}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This data is accessed by the loader. The name must be the module name
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * followed by "ModuleData".
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync_X_EXPORT
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncXF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic pointer
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncvboxSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync static Bool Initialised = FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!Initialised)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Initialised = TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86AddDriver(&VBOXVIDEO, Module, HaveDriverFuncs);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86AddDriver(&VBOXVIDEO, Module, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef XORG_7X
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LoaderRefSymLists(fbSymbols,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync shadowfbSymbols,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ramdacSymbols,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vgahwSymbols,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86Msg(X_CONFIG, "Load address of symbol \"VBOXVIDEO\" is %p\n",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (void *)&VBOXVIDEO);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (pointer)TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (ErrorMajor)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *ErrorMajor = LDR_ONCEONLY;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic const OptionInfoRec *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBOXAvailableOptions(int chipid, int busid)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (VBOXOptions);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBOXIdentify(int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86PrintChipsets(VBOX_NAME, "guest driver for VirtualBox", VBOXChipsets);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef XF86_SCRN_INTERFACE
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define xf86ScreenToScrn(pScreen) xf86Screens[(pScreen)->myNum]
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define xf86ScrnToScreen(pScrn) screenInfo.screens[(pScrn)->scrnIndex]
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define SCRNINDEXAPI(pfn) pfn ## Index
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXScreenInitIndex(int scrnIndex, ScreenPtr pScreen, int argc,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync char **argv)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ return VBOXScreenInit(pScreen, argc, argv); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXEnterVTIndex(int scrnIndex, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) flags; return VBOXEnterVT(xf86Screens[scrnIndex]); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXLeaveVTIndex(int scrnIndex, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) flags; VBOXLeaveVT(xf86Screens[scrnIndex]); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXCloseScreenIndex(int scrnIndex, ScreenPtr pScreen)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) scrnIndex; return VBOXCloseScreen(pScreen); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool VBOXSwitchModeIndex(int scrnIndex, DisplayModePtr pMode, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) flags; return VBOXSwitchMode(xf86Screens[scrnIndex], pMode); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXAdjustFrameIndex(int scrnIndex, int x, int y, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) flags; VBOXAdjustFrame(xf86Screens[scrnIndex], x, y); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXFreeScreenIndex(int scrnIndex, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{ (void) flags; VBOXFreeScreen(xf86Screens[scrnIndex]); }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# define SCRNINDEXAPI(pfn) pfn
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif /* XF86_SCRN_INTERFACE */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void setScreenFunctions(ScrnInfoPtr pScrn, xf86ProbeProc pfnProbe)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->driverVersion = VBOX_VERSION;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->driverName = VBOX_DRIVER_NAME;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->name = VBOX_NAME;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->Probe = pfnProbe;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->PreInit = VBOXPreInit;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->ScreenInit = SCRNINDEXAPI(VBOXScreenInit);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->SwitchMode = SCRNINDEXAPI(VBOXSwitchMode);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->AdjustFrame = SCRNINDEXAPI(VBOXAdjustFrame);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->EnterVT = SCRNINDEXAPI(VBOXEnterVT);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->LeaveVT = SCRNINDEXAPI(VBOXLeaveVT);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->FreeScreen = SCRNINDEXAPI(VBOXFreeScreen);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * One of these functions is called once, at the start of the first server
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * generation to do a minimal probe for supported hardware.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBOXPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync intptr_t match_data)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ScrnInfoPtr pScrn;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_ENTRY();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, VBOXPCIchipsets,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL, NULL, NULL, NULL, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pScrn != NULL) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pVBox)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync setScreenFunctions(pScrn, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pciInfo = dev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("returning %s\n", BOOL_STR(pScrn != NULL));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (pScrn != NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef PCIACCESS
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncstatic Bool
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncVBOXProbe(DriverPtr drv, int flags)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Bool foundScreen = FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int numDevSections;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync GDevPtr *devSections;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Find the config file Device sections that match this
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * driver, and return if there are none.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ((numDevSections = xf86MatchDevice(VBOX_NAME,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync &devSections)) <= 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* PCI BUS */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (xf86GetPciVideoInfo())
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int numUsed;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int *usedChips;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int i;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync numUsed = xf86MatchPciInstances(VBOX_NAME, VBOX_VENDORID,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXChipsets, VBOXPCIchipsets,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync devSections, numDevSections,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync drv, &usedChips);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (numUsed > 0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (flags & PROBE_DETECT)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync foundScreen = TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (i = 0; i < numUsed; i++)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ScrnInfoPtr pScrn = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Allocate a ScrnInfoRec */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPCIchipsets,NULL,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NULL,NULL,NULL,NULL)))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync setScreenFunctions(pScrn, VBOXProbe);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync foundScreen = TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync free(usedChips);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync free(devSections);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (foundScreen);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * QUOTE from the XFree86 DESIGN document:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * The purpose of this function is to find out all the information
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * required to determine if the configuration is usable, and to initialise
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * those parts of the ScrnInfoRec that can be set once at the beginning of
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * the first server generation.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * (...)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This includes probing for video memory, clocks, ramdac, and all other
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * HW info that is needed. It includes determining the depth/bpp/visual
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * and related info. It includes validating and determining the set of
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * video modes that will be used (and anything that is required to
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * determine that).
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This information should be determined in the least intrusive way
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * possible. The state of the HW must remain unchanged by this function.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Although video memory (including MMIO) may be mapped within this
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * function, it must be unmapped before returning.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * END QUOTE
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic Bool
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBOXPreInit(ScrnInfoPtr pScrn, int flags)
ffb50166c9adb4ae583b914d405197035cf890advboxsync{
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXPtr pVBox;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Gamma gzeros = {0.0, 0.0, 0.0};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rgb rzeros = {0, 0, 0};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned DispiId;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_ENTRY();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Are we really starting the server, or is this just a dummy run? */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (flags & PROBE_DETECT)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(pScrn->scrnIndex, X_INFO,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "VirtualBox guest additions video driver version "
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBOX_VERSION_STRING "\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Get our private data from the ScrnInfoRec structure. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pVBox)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Entity information seems to mean bus information. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* The ramdac module is needed for the hardware cursor. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "ramdac"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* The framebuffer module. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "fb"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "shadowfb"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "vgahw"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOX_DRI_OLD
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* Load the dri module. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "dri"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# ifdef VBOX_DRI
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Load the dri module. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86LoadSubModule(pScrn, "dri2"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync# endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifndef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pVBox->pEnt->location.type != BUS_PCI)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync pVBox->pciInfo = xf86GetPciInfoForEntity(pVBox->pEnt->index);
ffb50166c9adb4ae583b914d405197035cf890advboxsync pVBox->pciTag = pciTag(pVBox->pciInfo->bus,
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pVBox->pciInfo->device,
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pVBox->pciInfo->func);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* Set up our ScrnInfoRec structure to describe our virtual
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync capabilities to X. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->chipset = "vbox";
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /** @note needed during colourmap initialisation */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->rgbBits = 8;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Let's create a nice, capable virtual monitor. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor = pScrn->confScreen->monitor;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->DDC = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->nHsync = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->hsync[0].lo = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->hsync[0].hi = 10000;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->monitor->nVrefresh = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->vrefresh[0].lo = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->monitor->vrefresh[0].hi = 100;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->progClock = TRUE;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Using the PCI information caused problems with non-powers-of-two
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync sized video RAM configurations */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->cbFBMax = VBoxVideoGetVRAMSize();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->videoRam = pVBox->cbFBMax / 1024;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Check if the chip restricts horizontal resolution or not. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->fAnyX = VBoxVideoAnyWidthAllowed();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set up clock information that will support all modes we need. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->clockRanges = xnfcalloc(sizeof(ClockRange), 1);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pScrn->clockRanges->minClock = 1000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->clockRanges->maxClock = 1000000000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->clockRanges->clockIndex = -1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->clockRanges->ClockMulFactor = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->clockRanges->ClockDivFactor = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86SetDepthBpp(pScrn, 24, 0, 0, Support32bppFb))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "The VBox additions only support 16 and 32bpp graphics modes\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86PrintDepthBpp(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vboxAddModes(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOXVIDEO_13
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Work around a bug in the original X server modesetting code, which
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * took the first valid values set to these two as maxima over the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * server lifetime. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->virtualX = VBOX_VIDEO_MAX_VIRTUAL;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pScrn->virtualY = VBOX_VIDEO_MAX_VIRTUAL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync /* We don't validate with xf86ValidateModes and xf86PruneModes as we
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * already know what we like and what we don't. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->currentMode = pScrn->modes;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set the right virtual resolution. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->virtualX = pScrn->currentMode->HDisplay;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pScrn->virtualY = pScrn->currentMode->VDisplay;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync#endif /* !VBOXVIDEO_13 */
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync /* Needed before we initialise DRI. */
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pVBox->cbLine = vboxLineLength(pScrn, pScrn->virtualX);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync pScrn->displayWidth = vboxDisplayPitch(pScrn, pVBox->cbLine);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86PrintModes(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* VGA hardware initialisation */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!vgaHWGetHWRec(pScrn))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Must be called before any VGA registers are saved or restored */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync vgaHWSetStdFuncs(VGAHWPTR(pScrn));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vgaHWGetIOBase(VGAHWPTR(pScrn));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Colour weight - we always call this, since we are always in
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync truecolour. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86SetWeight(pScrn, rzeros, rzeros))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* visual init */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86SetDefaultVisual(pScrn, -1))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86SetGamma(pScrn, gzeros);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set the DPI. Perhaps we should read this from the host? */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86SetDpi(pScrn, 96, 96);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pScrn->memPhysBase == 0) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef PCIACCESS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->memPhysBase = pVBox->pciInfo->regions[0].base_addr;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->memPhysBase = pVBox->pciInfo->memBase[0];
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->fbOffset = 0;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync TRACE_EXIT();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (TRUE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync/**
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Dummy function for setting the colour palette, which we actually never
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * touch. However, the server still requires us to provide this.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncstatic void
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncvboxLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOCO *colors, VisualPtr pVisual)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync{
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync (void)pScrn; (void) numColors; (void) indices; (void) colors;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync (void)pVisual;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#define HAS_VT_ATOM_NAME "XFree86_has_VT"
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#define VBOXVIDEO_DRIVER_ATOM_NAME "VBOXVIDEO_DRIVER_IN_USE"
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync/* The memory storing the initial value of the XFree86_has_VT root window
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * property. This has to remain available until server start-up, so we just
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * use a global. */
0dd3967035b8a02985920baa57f948dc542b9388vboxsyncstatic CARD32 InitialPropertyValue = 1;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
0dd3967035b8a02985920baa57f948dc542b9388vboxsync/** Initialise a flag property on the root window to say whether the server VT
0dd3967035b8a02985920baa57f948dc542b9388vboxsync * is currently the active one as some clients need to know this. */
0dd3967035b8a02985920baa57f948dc542b9388vboxsyncstatic void initialiseProperties(ScrnInfoPtr pScrn)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync{
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync Atom atom = -1;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync CARD32 *PropertyValue = &InitialPropertyValue;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync#ifdef SET_HAVE_VT_PROPERTY
0dd3967035b8a02985920baa57f948dc542b9388vboxsync atom = MakeAtom(HAS_VT_ATOM_NAME, sizeof(HAS_VT_ATOM_NAME) - 1, TRUE);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync if (xf86RegisterRootWindowProperty(pScrn->scrnIndex, atom, XA_INTEGER,
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync 32, 1, PropertyValue) != Success)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync FatalError("vboxvideo: failed to register VT property\n");
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#endif /* SET_HAVE_VT_PROPERTY */
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync atom = MakeAtom(VBOXVIDEO_DRIVER_ATOM_NAME,
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync sizeof(VBOXVIDEO_DRIVER_ATOM_NAME) - 1, TRUE);
0dd3967035b8a02985920baa57f948dc542b9388vboxsync if (xf86RegisterRootWindowProperty(pScrn->scrnIndex, atom, XA_INTEGER,
0dd3967035b8a02985920baa57f948dc542b9388vboxsync 32, 1, PropertyValue) != Success)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync FatalError("vboxvideo: failed to register driver in use property\n");
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef SET_HAVE_VT_PROPERTY
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync/** Update a flag property on the root window to say whether the server VT
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * is currently the active one as some clients need to know this. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncstatic void updateHasVTProperty(ScrnInfoPtr pScrn, Bool hasVT)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync{
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync Atom property_name;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync int32_t value = hasVT ? 1 : 0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync int i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync property_name = MakeAtom(HAS_VT_ATOM_NAME, sizeof(HAS_VT_ATOM_NAME) - 1,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync FALSE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (property_name == BAD_RESOURCE)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync FatalError("Failed to retrieve \"HAS_VT\" atom\n");
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (ROOT_WINDOW(pScrn) == NULL)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync ChangeWindowProperty(ROOT_WINDOW(pScrn), property_name, XA_INTEGER, 32,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync PropModeReplace, 1, &value, TRUE);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync}
0dd3967035b8a02985920baa57f948dc542b9388vboxsync#endif /* SET_HAVE_VT_PROPERTY */
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
0dd3967035b8a02985920baa57f948dc542b9388vboxsync/*
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * QUOTE from the XFree86 DESIGN document:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync *
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * This is called at the start of each server generation.
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync *
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * (...)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync *
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Decide which operations need to be placed under resource access
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * control. (...) Map any video memory or other memory regions. (...)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * Save the video card state. (...) Initialise the initial video
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * mode.
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync *
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync * End QUOTE.
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync */
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsyncstatic Bool VBOXScreenInit(ScreenPtr pScreen, int argc, char **argv)
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync{
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync VisualPtr visual;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync unsigned flags;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync TRACE_ENTRY();
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (!VBOXMapVidMem(pScrn))
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return (FALSE);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync /* save current video state */
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync VBOXSaveMode(pScrn);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync /* mi layer - reset the visual list (?)*/
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync miClearVisualTypes();
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pScrn->rgbBits, TrueColor))
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return (FALSE);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (!miSetPixmapDepths())
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return (FALSE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOX_DRI
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync pVBox->useDRI = VBOXDRIScreenInit(pScrn, pScreen, pVBox);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync# ifndef VBOX_DRI_OLD /* DRI2 */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pVBox->drmFD >= 0)
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync /* Tell the kernel driver, if present, that we are taking over. */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync drmIoctl(pVBox->drmFD, VBOXVIDEO_IOCTL_DISABLE_HGSMI, NULL);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync# endif
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (!fbScreenInit(pScreen, pVBox->base,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->virtualX, pScrn->virtualY,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->xDpi, pScrn->yDpi,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->displayWidth, pScrn->bitsPerPixel))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return (FALSE);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Fixup RGB ordering */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /** @note the X server uses this even in true colour. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual = pScreen->visuals + pScreen->numVisuals;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync while (--visual >= pScreen->visuals) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ((visual->class | DynamicClass) == DirectColor) {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual->offsetRed = pScrn->offset.red;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual->offsetGreen = pScrn->offset.green;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync visual->offsetBlue = pScrn->offset.blue;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual->redMask = pScrn->mask.red;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual->greenMask = pScrn->mask.green;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync visual->blueMask = pScrn->mask.blue;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* must be after RGB ordering fixed */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync fbPictureInit(pScreen, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86SetBlackWhitePixels(pScreen);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pScrn->vtSema = TRUE;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync VBoxSetUpLinuxACPI(pScreen);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vbox_open (pScrn, pScreen, pVBox);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync vboxEnableVbva(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxInitialiseSizeHints(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOXVIDEO_13
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Initialise CRTC and output configuration for use with randr1.2. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86CrtcConfigInit(pScrn, &VBOXCrtcConfigFuncs);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync uint32_t i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync for (i = 0; i < pVBox->cScreens; ++i)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync char szOutput[256];
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Setup our virtual CRTCs. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[i].paCrtcs = xf86CrtcCreate(pScrn, &VBOXCrtcFuncs);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[i].paCrtcs->driver_private = (void *)(uintptr_t)i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Set up our virtual outputs. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync snprintf(szOutput, sizeof(szOutput), "VGA-%u", i);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[i].paOutputs
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync = xf86OutputCreate(pScrn, &VBOXOutputFuncs, szOutput);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* We are not interested in the monitor section in the
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * configuration file. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86OutputUseScreenMonitor(pVBox->pScreens[i].paOutputs, FALSE);
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync pVBox->pScreens[i].paOutputs->possible_crtcs = 1 << i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[i].paOutputs->possible_clones = 0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[i].paOutputs->driver_private = (void *)(uintptr_t)i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync TRACE_LOG("Created crtc (%p) and output %s (%p)\n",
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync (void *)pVBox->pScreens[i].paCrtcs, szOutput,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync (void *)pVBox->pScreens[i].paOutputs);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set a sane minimum and maximum mode size to match what the hardware
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * supports. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86CrtcSetSizeRange(pScrn, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL, VBOX_VIDEO_MAX_VIRTUAL);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Now create our initial CRTC/output configuration. */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if (!xf86InitialConfiguration(pScrn, TRUE)) {
ffb50166c9adb4ae583b914d405197035cf890advboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n");
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return (FALSE);
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* Initialise randr 1.2 mode-setting functions and set first mode.
ffb50166c9adb4ae583b914d405197035cf890advboxsync * Note that the mode won't be usable until the server has resized the
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync * framebuffer to something reasonable. */
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (!xf86CrtcScreenInit(pScreen)) {
ffb50166c9adb4ae583b914d405197035cf890advboxsync return FALSE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!xf86SetDesiredModes(pScrn)) {
ffb50166c9adb4ae583b914d405197035cf890advboxsync return FALSE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync#else /* !VBOXVIDEO_13 */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBoxSetUpRandR11(pScreen);
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* set first video mode */
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (!VBOXSetMode(pScrn, 0, pScrn->currentMode->HDisplay,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->currentMode->VDisplay, pScrn->frameX0,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScrn->frameY0))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return FALSE;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync /* Save the size in case we need to re-set it later. */
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pVBox->FBSize.cx = pScrn->currentMode->HDisplay;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->FBSize.cy = pScrn->currentMode->VDisplay;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[0].aScreenLocation.cx = pScrn->currentMode->HDisplay;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[0].aScreenLocation.cy = pScrn->currentMode->VDisplay;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[0].aScreenLocation.x = pScrn->frameX0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->pScreens[0].aScreenLocation.y = pScrn->frameY0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif /* !VBOXVIDEO_13 */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* software cursor */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* colourmap code */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (!miCreateDefColormap(pScreen))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return (FALSE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if(!xf86HandleColormaps(pScreen, 256, 8, vboxLoadPalette, NULL, 0))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return (FALSE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
0dd3967035b8a02985920baa57f948dc542b9388vboxsync pVBox->CloseScreen = pScreen->CloseScreen;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScreen->CloseScreen = SCRNINDEXAPI(VBOXCloseScreen);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOXVIDEO_13
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScreen->SaveScreen = xf86SaveScreen;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#else
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pScreen->SaveScreen = VBOXSaveScreen;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOXVIDEO_13
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86DPMSInit(pScreen, xf86DPMSSet, 0);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#else
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* We probably do want to support power management - even if we just use
0dd3967035b8a02985920baa57f948dc542b9388vboxsync a dummy function. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86DPMSInit(pScreen, VBOXDisplayPowerManagementSet, 0);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Report any unused options (only for the first generation) */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (serverGeneration == 1)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (vbox_cursor_init(pScreen) != TRUE)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync "Unable to start the VirtualBox mouse pointer integration with the host system.\n");
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOX_DRI_OLD
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pVBox->useDRI)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pVBox->useDRI = VBOXDRIFinishScreenInit(pScreen);
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync initialiseProperties(pScrn);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync return (TRUE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync}
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsyncstatic Bool VBOXEnterVT(ScrnInfoPtr pScrn)
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync{
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync TRACE_ENTRY();
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOX_DRI_OLD
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (pVBox->useDRI)
ffb50166c9adb4ae583b914d405197035cf890advboxsync DRIUnlock(xf86ScrnToScreen(pScrn));
ffb50166c9adb4ae583b914d405197035cf890advboxsync#elif defined(VBOX_DRI) /* DRI2 */
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (pVBox->drmFD >= 0)
ffb50166c9adb4ae583b914d405197035cf890advboxsync {
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* Tell the kernel driver, if present, that we are taking over. */
ffb50166c9adb4ae583b914d405197035cf890advboxsync drmSetMaster(pVBox->drmFD);
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync vboxEnableVbva(pScrn);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Re-assert this in case we had a change request while switched out. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pVBox->FBSize.cx && pVBox->FBSize.cy)
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXAdjustScreenPixmap(pScrn, pVBox->FBSize.cx, pVBox->FBSize.cy);
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOXVIDEO_13
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (!xf86SetDesiredModes(pScrn))
ffb50166c9adb4ae583b914d405197035cf890advboxsync return FALSE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync#else
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (!VBOXSetMode(pScrn, 0, pScrn->currentMode->HDisplay,
ffb50166c9adb4ae583b914d405197035cf890advboxsync pScrn->currentMode->VDisplay, pScrn->frameX0,
ffb50166c9adb4ae583b914d405197035cf890advboxsync pScrn->frameY0))
ffb50166c9adb4ae583b914d405197035cf890advboxsync return FALSE;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef SET_HAVE_VT_PROPERTY
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync updateHasVTProperty(pScrn, TRUE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsyncstatic void VBOXLeaveVT(ScrnInfoPtr pScrn)
ffb50166c9adb4ae583b914d405197035cf890advboxsync{
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOXVIDEO_13
ffb50166c9adb4ae583b914d405197035cf890advboxsync unsigned i;
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync TRACE_ENTRY();
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef VBOXVIDEO_13
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync for (i = 0; i < pVBox->cScreens; ++i)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync vbox_output_dpms(pVBox->pScreens[i].paOutputs, DPMSModeOff);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync vboxDisableVbva(pScrn);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync vboxClearVRAM(pScrn, 0, 0);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOX_DRI_OLD
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pVBox->useDRI)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync DRILock(xf86ScrnToScreen(pScrn), 0);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#elif defined(VBOX_DRI) /* DRI2 */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pVBox->drmFD >= 0)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync drmDropMaster(pVBox->drmFD);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync#endif
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync VBOXRestoreMode(pScrn);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef SET_HAVE_VT_PROPERTY
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync updateHasVTProperty(pScrn, FALSE);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync TRACE_EXIT();
ffb50166c9adb4ae583b914d405197035cf890advboxsync}
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsyncstatic Bool VBOXCloseScreen(ScreenPtr pScreen)
ffb50166c9adb4ae583b914d405197035cf890advboxsync{
ffb50166c9adb4ae583b914d405197035cf890advboxsync ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#if defined(VBOX_DRI) && !defined(VBOX_DRI_OLD) /* DRI2 */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync BOOL fRestore = TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pScrn->vtSema)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOXVIDEO_13
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync unsigned i;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync for (i = 0; i < pVBox->cScreens; ++i)
ffb50166c9adb4ae583b914d405197035cf890advboxsync vbox_output_dpms(pVBox->pScreens[i].paOutputs, DPMSModeOff);
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync vboxDisableVbva(pScrn);
ffb50166c9adb4ae583b914d405197035cf890advboxsync vboxClearVRAM(pScrn, 0, 0);
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOX_DRI
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync# ifndef VBOX_DRI_OLD /* DRI2 */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if ( pVBox->drmFD >= 0
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Tell the kernel driver, if present, that we are going away. */
ffb50166c9adb4ae583b914d405197035cf890advboxsync && drmIoctl(pVBox->drmFD, VBOXVIDEO_IOCTL_ENABLE_HGSMI, NULL) >= 0)
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync fRestore = false;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync# endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (pVBox->useDRI)
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXDRICloseScreen(pScreen, pVBox);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync pVBox->useDRI = false;
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync#if defined(VBOX_DRI) && !defined(VBOX_DRI_OLD) /* DRI2 */
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (fRestore)
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync if (pScrn->vtSema)
ffb50166c9adb4ae583b914d405197035cf890advboxsync VBOXRestoreMode(pScrn);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if (pScrn->vtSema)
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBOXUnmapVidMem(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->vtSema = FALSE;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Do additional bits which are separate for historical reasons */
ffb50166c9adb4ae583b914d405197035cf890advboxsync vbox_close(pScrn, pVBox);
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync pScreen->CloseScreen = pVBox->CloseScreen;
ffb50166c9adb4ae583b914d405197035cf890advboxsync#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync VBoxCleanUpLinuxACPI(pScreen);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#endif
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#ifndef XF86_SCRN_INTERFACE
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync return pScreen->CloseScreen(pScreen->myNum, pScreen);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#else
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync return pScreen->CloseScreen(pScreen);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#endif
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync}
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync
6475559a7e0e52892efbab4fbdedc879f6866109vboxsyncstatic Bool VBOXSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync{
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync VBOXPtr pVBox;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync Bool rc;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync TRACE_LOG("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#ifndef VBOXVIDEO_13
ffb50166c9adb4ae583b914d405197035cf890advboxsync pVBox = VBOXGetRec(pScrn);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync /* Save the size in case we need to re-set it later. */
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync pVBox->FBSize.cx = pMode->HDisplay;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync pVBox->FBSize.cy = pMode->VDisplay;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync pVBox->pScreens[0].aScreenLocation.cx = pMode->HDisplay;
ffb50166c9adb4ae583b914d405197035cf890advboxsync pVBox->pScreens[0].aScreenLocation.cy = pMode->VDisplay;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync pVBox->pScreens[0].aScreenLocation.x = pScrn->frameX0;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync pVBox->pScreens[0].aScreenLocation.y = pScrn->frameY0;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#endif
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync if (!pScrn->vtSema)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync {
ffb50166c9adb4ae583b914d405197035cf890advboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
ffb50166c9adb4ae583b914d405197035cf890advboxsync "We do not own the active VT, exiting.\n");
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync return TRUE;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXVIDEO_13
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync rc = xf86SetSingleMode(pScrn, pMode, RR_Rotate_0);
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync#else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXAdjustScreenPixmap(pScrn, pMode->HDisplay, pMode->VDisplay);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBOXSetMode(pScrn, 0, pMode->HDisplay, pMode->VDisplay,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pScrn->frameX0, pScrn->frameY0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXPtr pVBox = VBOXGetRec(pScrn);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_ENTRY();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[0].aScreenLocation.x = x;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[0].aScreenLocation.y = y;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Don't fiddle with the hardware if we are switched
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * to a virtual terminal. */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pScrn->vtSema)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "We do not own the active VT, exiting.\n");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXSetMode(pScrn, 0, pVBox->pScreens[0].aScreenLocation.cx,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pVBox->pScreens[0].aScreenLocation.cy, x, y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync TRACE_EXIT();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic void VBOXFreeScreen(ScrnInfoPtr pScrn)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Destroy the VGA hardware record */
vgaHWFreeHWRec(pScrn);
/* And our private record */
free(pScrn->driverPrivate);
pScrn->driverPrivate = NULL;
}
static Bool
VBOXMapVidMem(ScrnInfoPtr pScrn)
{
VBOXPtr pVBox = VBOXGetRec(pScrn);
Bool rc = TRUE;
TRACE_ENTRY();
if (!pVBox->base)
{
#ifdef PCIACCESS
(void) pci_device_map_range(pVBox->pciInfo,
pScrn->memPhysBase,
pScrn->videoRam * 1024,
PCI_DEV_MAP_FLAG_WRITABLE,
& pVBox->base);
#else
pVBox->base = xf86MapPciMem(pScrn->scrnIndex,
VIDMEM_FRAMEBUFFER,
pVBox->pciTag, pScrn->memPhysBase,
(unsigned) pScrn->videoRam * 1024);
#endif
if (!pVBox->base)
rc = FALSE;
}
TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
return rc;
}
static void
VBOXUnmapVidMem(ScrnInfoPtr pScrn)
{
VBOXPtr pVBox = VBOXGetRec(pScrn);
TRACE_ENTRY();
if (pVBox->base == NULL)
return;
#ifdef PCIACCESS
(void) pci_device_unmap_range(pVBox->pciInfo,
pVBox->base,
pScrn->videoRam * 1024);
#else
xf86UnMapVidMem(pScrn->scrnIndex, pVBox->base,
(unsigned) pScrn->videoRam * 1024);
#endif
pVBox->base = NULL;
TRACE_EXIT();
}
static Bool
VBOXSaveScreen(ScreenPtr pScreen, int mode)
{
(void)pScreen; (void)mode;
return TRUE;
}
void
VBOXSaveMode(ScrnInfoPtr pScrn)
{
VBOXPtr pVBox = VBOXGetRec(pScrn);
vgaRegPtr vgaReg;
TRACE_ENTRY();
vgaReg = &VGAHWPTR(pScrn)->SavedReg;
vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
pVBox->fSavedVBEMode = VBoxVideoGetModeRegisters(&pVBox->cSavedWidth,
&pVBox->cSavedHeight,
&pVBox->cSavedPitch,
&pVBox->cSavedBPP,
&pVBox->fSavedFlags);
}
void
VBOXRestoreMode(ScrnInfoPtr pScrn)
{
VBOXPtr pVBox = VBOXGetRec(pScrn);
vgaRegPtr vgaReg;
#ifdef VBOX_DRI
drmModeResPtr pRes;
#endif
TRACE_ENTRY();
#ifdef VBOX_DRI
/* Do not try to re-set the VGA state if a mode-setting driver is loaded. */
if ( pVBox->drmFD >= 0
&& LoaderSymbol("drmModeGetResources") != NULL
&& (pRes = drmModeGetResources(pVBox->drmFD)) != NULL)
{
drmModeFreeResources(pRes);
return;
}
#endif
vgaReg = &VGAHWPTR(pScrn)->SavedReg;
vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);
if (pVBox->fSavedVBEMode)
VBoxVideoSetModeRegisters(pVBox->cSavedWidth, pVBox->cSavedHeight,
pVBox->cSavedPitch, pVBox->cSavedBPP,
pVBox->fSavedFlags, 0, 0);
else
VBoxVideoDisableVBE();
}
static void
VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
int flags)
{
(void)pScrn; (void)mode; (void) flags;
}