[55401] | 1 | /* $Id: vboxvideo.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
[6202] | 2 | /** @file
|
---|
[6497] | 3 | * VirtualBox X11 Additions graphics driver
|
---|
[6202] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[69346] | 8 | * This file is based on the X11 VESA driver:
|
---|
[6202] | 9 | *
|
---|
| 10 | * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
---|
| 11 | *
|
---|
| 12 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
| 13 | * copy of this software and associated documentation files (the "Software"),
|
---|
| 14 | * to deal in the Software without restriction, including without limitation
|
---|
| 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
| 16 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
| 17 | * Software is furnished to do so, subject to the following conditions:
|
---|
| 18 | *
|
---|
| 19 | * The above copyright notice and this permission notice shall be included in
|
---|
| 20 | * all copies or substantial portions of the Software.
|
---|
| 21 | *
|
---|
| 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
| 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
[69058] | 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
---|
| 25 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
---|
| 26 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
---|
| 27 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
---|
| 28 | * USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
[6202] | 29 | *
|
---|
| 30 | * Except as contained in this notice, the name of Conectiva Linux shall
|
---|
| 31 | * not be used in advertising or otherwise to promote the sale, use or other
|
---|
| 32 | * dealings in this Software without prior written authorization from
|
---|
| 33 | * Conectiva Linux.
|
---|
| 34 | *
|
---|
[22149] | 35 | * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
|
---|
[69058] | 36 | * Michael Thayer <michael.thayer@oracle.com>
|
---|
[6202] | 37 | */
|
---|
| 38 |
|
---|
[76563] | 39 | #ifndef GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h
|
---|
| 40 | #define GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h
|
---|
[76535] | 41 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 42 | # pragma once
|
---|
| 43 | #endif
|
---|
[6202] | 44 |
|
---|
[65381] | 45 | #include <VBoxVideoGuest.h>
|
---|
| 46 | #include <VBoxVideo.h>
|
---|
[55519] | 47 | #include "version-generated.h"
|
---|
[34715] | 48 |
|
---|
[69065] | 49 | #define VBOX_VENDORID 0x80EE
|
---|
| 50 | #define VBOX_DEVICEID 0xBEEF
|
---|
| 51 |
|
---|
[55374] | 52 | #ifndef VBVA_SCREEN_F_BLANK
|
---|
| 53 | # define VBVA_SCREEN_F_BLANK 0x0004
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
[69078] | 56 | #include <VBoxVideoVBE.h>
|
---|
| 57 |
|
---|
| 58 | #include "xf86.h"
|
---|
| 59 | #include "xf86str.h"
|
---|
| 60 | #include "xf86Cursor.h"
|
---|
| 61 |
|
---|
[27529] | 62 | #ifdef DEBUG
|
---|
[17318] | 63 |
|
---|
[69078] | 64 | #define TRACE_ENTRY() do { xf86ErrorF("%s: entering\n", __func__); } while(0)
|
---|
| 65 | #define TRACE_EXIT() do { xf86ErrorF("%s: leaving\n", __func__); } while(0)
|
---|
| 66 | #define TRACE_LINE() \
|
---|
| 67 | do { xf86ErrorF("%s: line\n", __func__, __LINE__); } while(0)
|
---|
[17318] | 68 | #define TRACE_LOG(...) \
|
---|
| 69 | do { \
|
---|
[69078] | 70 | xf86ErrorF("%s: ", __func__); \
|
---|
| 71 | xf86ErrorF(__VA_ARGS__); \
|
---|
[17318] | 72 | } while(0)
|
---|
[69078] | 73 |
|
---|
[27529] | 74 | #else /* !DEBUG */
|
---|
[17318] | 75 |
|
---|
[27530] | 76 | #define TRACE_ENTRY() do { } while (0)
|
---|
| 77 | #define TRACE_EXIT() do { } while (0)
|
---|
| 78 | #define TRACE_LOG(...) do { } while (0)
|
---|
[17318] | 79 |
|
---|
[27529] | 80 | #endif /* !DEBUG */
|
---|
[17318] | 81 |
|
---|
[69065] | 82 | #define VBOX_VERSION VBOX_VERSION_MAJOR * 10000 \
|
---|
| 83 | + VBOX_VERSION_MINOR * 100
|
---|
[45356] | 84 | #define VBOX_NAME "VBoxVideo"
|
---|
| 85 | #define VBOX_DRIVER_NAME "vboxvideo"
|
---|
[6202] | 86 |
|
---|
[55519] | 87 | #define VBOX_VIDEO_MAJOR VBOX_VERSION_MAJOR
|
---|
| 88 | #define VBOX_VIDEO_MINOR VBOX_VERSION_MINOR
|
---|
[17243] | 89 |
|
---|
[55236] | 90 | #define VBOX_VIDEO_MIN_SIZE 64
|
---|
| 91 | #define VBOX_VIDEO_MAX_VIRTUAL (INT16_MAX - 1)
|
---|
| 92 |
|
---|
[17085] | 93 | #define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
|
---|
| 94 |
|
---|
[51242] | 95 | /** Helper to work round different ways of getting the root window in different
|
---|
| 96 | * server versions. */
|
---|
[54324] | 97 | #if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
|
---|
| 98 | && XORG_VERSION_CURRENT >= 10900000
|
---|
[51242] | 99 | # define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
|
---|
| 100 | #else
|
---|
| 101 | # define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
[69082] | 104 | /** ChangeWindowProperty for X.Org Server 1.19 and later */
|
---|
| 105 | #if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
|
---|
| 106 | && XORG_VERSION_CURRENT >= 11900000
|
---|
| 107 | # define ChangeWindowProperty(pWin, property, type, format, mode, \
|
---|
| 108 | len, value, sendevent) \
|
---|
| 109 | dixChangeWindowProperty(serverClient, pWin, property, type, format, \
|
---|
| 110 | mode, len, value, sendevent)
|
---|
| 111 | #endif
|
---|
| 112 |
|
---|
[52199] | 113 | /** Structure containing all virtual monitor-specific information. */
|
---|
| 114 | struct VBoxScreen
|
---|
| 115 | {
|
---|
| 116 | /** Position information for each virtual screen for the purposes of
|
---|
| 117 | * sending dirty rectangle information to the right one. */
|
---|
| 118 | RTRECT2 aScreenLocation;
|
---|
[53544] | 119 | /** Is this CRTC enabled or in DPMS off state? */
|
---|
[55332] | 120 | Bool fPowerOn;
|
---|
[52199] | 121 | #ifdef VBOXVIDEO_13
|
---|
| 122 | /** The virtual crtcs. */
|
---|
| 123 | struct _xf86Crtc *paCrtcs;
|
---|
| 124 | /** The virtual outputs, logically not distinct from crtcs. */
|
---|
| 125 | struct _xf86Output *paOutputs;
|
---|
| 126 | #endif
|
---|
| 127 | /** Offsets of VBVA buffers in video RAM */
|
---|
| 128 | uint32_t aoffVBVABuffer;
|
---|
| 129 | /** Context information about the VBVA buffers for each screen */
|
---|
| 130 | struct VBVABUFFERCONTEXT aVbvaCtx;
|
---|
| 131 | /** The current preferred resolution for the screen */
|
---|
| 132 | RTRECTSIZE aPreferredSize;
|
---|
[55225] | 133 | /** The current preferred location for the screen. */
|
---|
| 134 | RTPOINT aPreferredLocation;
|
---|
[53527] | 135 | /** Has this screen been enabled by the host? */
|
---|
| 136 | Bool afConnected;
|
---|
[55225] | 137 | /** Does this screen have a preferred location? */
|
---|
| 138 | Bool afHaveLocation;
|
---|
[52199] | 139 | };
|
---|
[6202] | 140 |
|
---|
[34715] | 141 | typedef struct VBOXRec
|
---|
[6202] | 142 | {
|
---|
| 143 | EntityInfoPtr pEnt;
|
---|
[9252] | 144 | #ifdef PCIACCESS
|
---|
| 145 | struct pci_device *pciInfo;
|
---|
| 146 | #else
|
---|
[6202] | 147 | pciVideoPtr pciInfo;
|
---|
| 148 | PCITAG pciTag;
|
---|
[9252] | 149 | #endif
|
---|
[32495] | 150 | void *base;
|
---|
[34715] | 151 | /** The amount of VRAM available for use as a framebuffer */
|
---|
[35268] | 152 | unsigned long cbFBMax;
|
---|
[35102] | 153 | /** The size of the framebuffer and the VBVA buffers at the end of it. */
|
---|
| 154 | unsigned long cbView;
|
---|
[35949] | 155 | /** Whether the pre-X-server mode was a VBE mode */
|
---|
[69064] | 156 | Bool fSavedVBEMode;
|
---|
[35949] | 157 | /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
|
---|
| 158 | */
|
---|
| 159 | uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
|
---|
[6202] | 160 | CloseScreenProcPtr CloseScreen;
|
---|
[8531] | 161 | /** Default X server procedure for enabling and disabling framebuffer access */
|
---|
| 162 | xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
|
---|
[6202] | 163 | OptionInfoPtr Options;
|
---|
[32692] | 164 | /** @todo we never actually free this */
|
---|
[32495] | 165 | xf86CursorInfoPtr pCurs;
|
---|
[53966] | 166 | /** Do we currently want to use the host cursor? */
|
---|
| 167 | Bool fUseHardwareCursor;
|
---|
[34715] | 168 | /** Number of screens attached */
|
---|
| 169 | uint32_t cScreens;
|
---|
[52199] | 170 | /** Information about each virtual screen. */
|
---|
| 171 | struct VBoxScreen *pScreens;
|
---|
[55225] | 172 | /** Can we get mode hint and cursor integration information from HGSMI? */
|
---|
[69064] | 173 | Bool fHaveHGSMIModeHints;
|
---|
[55241] | 174 | /** Does the host support the screen blanking flag? */
|
---|
[69064] | 175 | Bool fHostHasScreenBlankingFlag;
|
---|
[53530] | 176 | /** Array of structures for receiving mode hints. */
|
---|
| 177 | VBVAMODEHINT *paVBVAModeHints;
|
---|
[60190] | 178 | #ifdef VBOXVIDEO_13
|
---|
| 179 | # ifdef RT_OS_LINUX
|
---|
| 180 | /** Input device file descriptor for getting ACPI hot-plug events. */
|
---|
| 181 | int fdACPIDevices;
|
---|
| 182 | /** Input handler handle for ACPI hot-plug listener. */
|
---|
| 183 | void *hACPIEventHandler;
|
---|
| 184 | # endif
|
---|
[54531] | 185 | #endif
|
---|
[34715] | 186 | /** HGSMI guest heap context */
|
---|
| 187 | HGSMIGUESTCOMMANDCONTEXT guestCtx;
|
---|
[34911] | 188 | /** Unrestricted horizontal resolution flag. */
|
---|
| 189 | Bool fAnyX;
|
---|
[6202] | 190 | } VBOXRec, *VBOXPtr;
|
---|
| 191 |
|
---|
[69078] | 192 | #define VBOXGetRec(pScrn) ((VBOXPtr)(pScrn)->driverPrivate)
|
---|
[53770] | 193 |
|
---|
| 194 | /* setmode.c */
|
---|
[55241] | 195 |
|
---|
| 196 | /** Structure describing the virtual frame buffer. It starts at the beginning
|
---|
| 197 | * of the video RAM. */
|
---|
| 198 | struct vbvxFrameBuffer {
|
---|
| 199 | /** X offset of first screen in frame buffer. */
|
---|
| 200 | int x0;
|
---|
| 201 | /** Y offset of first screen in frame buffer. */
|
---|
| 202 | int y0;
|
---|
| 203 | /** Frame buffer virtual width. */
|
---|
| 204 | unsigned cWidth;
|
---|
| 205 | /** Frame buffer virtual height. */
|
---|
| 206 | unsigned cHeight;
|
---|
| 207 | /** Bits per pixel. */
|
---|
| 208 | unsigned cBPP;
|
---|
| 209 | };
|
---|
| 210 |
|
---|
[55375] | 211 | extern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
|
---|
[69064] | 212 | extern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, Bool fEnabled,
|
---|
| 213 | Bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
|
---|
[55204] | 214 | extern void vbvxSetSolarisMouseRange(int width, int height);
|
---|
| 215 |
|
---|
[55391] | 216 | /* pointer.h */
|
---|
| 217 | extern Bool vbvxCursorInit(ScreenPtr pScreen);
|
---|
| 218 | extern void vbvxCursorTerm(VBOXPtr pVBox);
|
---|
[6202] | 219 |
|
---|
[55358] | 220 | /* vbva.c */
|
---|
| 221 | extern void vbvxHandleDirtyRect(ScrnInfoPtr pScrn, int iRects, BoxPtr aRects);
|
---|
[55367] | 222 | extern void vbvxSetUpHGSMIHeapInGuest(VBOXPtr pVBox, uint32_t cbVRAM);
|
---|
[6518] | 223 | extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
|
---|
[34715] | 224 | extern void vboxDisableVbva(ScrnInfoPtr pScrn);
|
---|
[6202] | 225 |
|
---|
[53530] | 226 | /* getmode.c */
|
---|
[51242] | 227 | extern void vboxAddModes(ScrnInfoPtr pScrn);
|
---|
| 228 | extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
|
---|
[69064] | 229 | extern void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, Bool *pfNeedUpdate);
|
---|
| 230 | extern void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, Bool *pfNeedUpdate);
|
---|
[60190] | 231 | extern void vbvxSetUpLinuxACPI(ScreenPtr pScreen);
|
---|
| 232 | extern void vbvxCleanUpLinuxACPI(ScreenPtr pScreen);
|
---|
[7464] | 233 |
|
---|
[60180] | 234 | /* EDID generation */
|
---|
| 235 | #ifdef VBOXVIDEO_13
|
---|
| 236 | extern Bool VBOXEDIDSet(struct _xf86Output *output, DisplayModePtr pmode);
|
---|
| 237 | #endif
|
---|
| 238 |
|
---|
[76563] | 239 | #endif /* !GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h */
|
---|
[17451] | 240 |
|
---|