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