vboxvideo.h revision 10028648143893a0291db53b6a5f7d061f8b0fa8
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * VirtualBox X11 Additions graphics driver
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2013 Oracle Corporation
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * available from http://www.virtualbox.org. This file is free software;
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * you can redistribute it and/or modify it under the terms of the GNU
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * General Public License (GPL) as published by the Free Software
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * --------------------------------------------------------------------
0d12c7f9423f2745f8e282523d0930f91bff03b3vboxsync * This code is based on:
0d12c7f9423f2745f8e282523d0930f91bff03b3vboxsync * X11 VESA driver
0d12c7f9423f2745f8e282523d0930f91bff03b3vboxsync * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
0d12c7f9423f2745f8e282523d0930f91bff03b3vboxsync * Permission is hereby granted, free of charge, to any person obtaining a
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * copy of this software and associated documentation files (the "Software"),
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * to deal in the Software without restriction, including without limitation
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * and/or sell copies of the Software, and to permit persons to whom the
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * Software is furnished to do so, subject to the following conditions:
032a52c5b2984e26e84c2961f8f7f98a3954c8f2vboxsync * The above copyright notice and this permission notice shall be included in
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * all copies or substantial portions of the Software.
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45c3e41d012100c5f4a3f77e391e4c6da8f5b97avboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45c3e41d012100c5f4a3f77e391e4c6da8f5b97avboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * SOFTWARE.
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * Except as contained in this notice, the name of Conectiva Linux shall
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * not be used in advertising or otherwise to promote the sale, use or other
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * dealings in this Software without prior written authorization from
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * Conectiva Linux.
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h,v 1.9 2001/05/04 19:05:49 dawes Exp $
2d8870843ff566fee9bd3a6a5942414254106479vboxsync#define TRACE_LOG(...) \
2d8870843ff566fee9bd3a6a5942414254106479vboxsync# define TRACE_LINE() do \
044af0d1e6474076366759db86f101778c5f20ccvboxsync vbvxMsg("%s: line %d\n", __FUNCTION__, __LINE__); \
044af0d1e6474076366759db86f101778c5f20ccvboxsync#else /* !DEBUG */
044af0d1e6474076366759db86f101778c5f20ccvboxsync#define TRACE_ENTRY() do { } while (0)
044af0d1e6474076366759db86f101778c5f20ccvboxsync#define TRACE_EXIT() do { } while (0)
044af0d1e6474076366759db86f101778c5f20ccvboxsync#define TRACE_LOG(...) do { } while (0)
044af0d1e6474076366759db86f101778c5f20ccvboxsync#endif /* !DEBUG */
044af0d1e6474076366759db86f101778c5f20ccvboxsync/* Not just for debug builds. If something is wrong we want to know at once. */
044af0d1e6474076366759db86f101778c5f20ccvboxsync vbvxMsg("at %s (%s:%d)\n", RT_GCC_EXTENSION __PRETTY_FUNCTION__, __FILE__, __LINE__); \
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync/* DRI support */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync/* Hack to work around a libdrm header which is broken on Solaris */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync/* Get rid of a warning due to a broken header file */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync/* For some reason this is not in the header files. */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsyncextern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
044af0d1e6474076366759db86f101778c5f20ccvboxsync#define VBOX_DRM_DRIVER_NAME "vboxvideo" /* For now, as this driver is basically a stub. */
044af0d1e6474076366759db86f101778c5f20ccvboxsync#define VBOX_DRI_DRIVER_NAME "vboxvideo" /* For starters. */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync/** Helper to work round different ways of getting the root window in different
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * server versions. */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync# define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync# define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync/** Structure containing all virtual monitor-specific information. */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /** Position information for each virtual screen for the purposes of
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * sending dirty rectangle information to the right one. */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /** Is this CRTC enabled or in DPMS off state? */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /** Is this output enabled or in DPMS low power state? */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /** The virtual crtcs. */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /** The virtual outputs, logically not distinct from crtcs. */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /** Offsets of VBVA buffers in video RAM */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** Context information about the VBVA buffers for each screen */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** The current preferred resolution for the screen */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** The current preferred location for the screen. */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** Has this screen been enabled by the host? */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /** The last mode hint data read from the X11 property. */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** Does this screen have a preferred location? */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsynctypedef struct VBOXRec
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** The amount of VRAM available for use as a framebuffer */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync unsigned long cbFBMax;
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** The size of the framebuffer and the VBVA buffers at the end of it. */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync unsigned long cbView;
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** The current line size in bytes */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Whether the pre-X-server mode was a VBE mode */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Default X server procedure for enabling and disabling framebuffer access */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** @todo we never actually free this */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Do we currently want to use the host cursor? */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** The last cursor capabilities data read from the X11 property. */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Number of screens attached */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** Information about each virtual screen. */
7d80dfbe5d66fc4c6de6fe109ce96a081496dcd4vboxsync /** The last requested framebuffer size. */
3a4a6501d0ccd629d9951b644d380c7bb2d46086vboxsync /** Can we get mode hint and cursor integration information from HGSMI? */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Does the host support the screen blanking flag? */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Array of structures for receiving mode hints. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Input device file descriptor for getting ACPI hot-plug events. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Input handler handle for ACPI hot-plug listener. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Have we read all available HGSMI mode hint data? */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** The original CreateScreenResources procedure which we wrap with our own.
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync CreateScreenResourcesProcPtr pfnCreateScreenResources;
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** HGSMI guest heap context */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Unrestricted horizontal resolution flag. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxMsgV(const char *pszFormat, va_list args);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxAbortServer(void);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern int vbvxGetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t *pcData, int32_t **ppaData);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxSetIntegerPropery(ScrnInfoPtr pScrn, char *pszName, size_t cData, int32_t *paData, Bool fSendEvent);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/** Structure describing the virtual frame buffer. It starts at the beginning
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync * of the video RAM. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** X offset of first screen in frame buffer. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Y offset of first screen in frame buffer. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Frame buffer virtual width. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Frame buffer virtual height. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync /** Bits per pixel. */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, bool fEnabled,
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbvxSetSolarisMouseRange(int width, int height);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/* DRI stuff */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen,
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern Bool VBOXDRIFinishScreenInit(ScreenPtr pScreen);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void VBOXDRIUpdateStride(ScrnInfoPtr pScrn, VBOXPtr pVBox);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void VBOXDRICloseScreen(ScreenPtr pScreen, VBOXPtr pVBox);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/* Utilities */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/** Calculate the BPP from the screen depth */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/** Calculate the scan line length for a display width */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncstatic inline int32_t vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth)
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync uint32_t cbLine = (cDisplayWidth * vboxBPP(pScrn) / 8 + 3) & ~3;
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync/** Calculate the display pitch from the scan line length */
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncstatic inline int32_t vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine)
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern void vboxClearVRAM(ScrnInfoPtr pScrn, int32_t cNewX, int32_t cNewY);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern Bool VBOXSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth,
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync unsigned cHeight, int x, int y);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncextern Bool VBOXAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync#endif /* _VBOXVIDEO_H_ */