1 | /* $Id: vboxvideo.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox X11 Additions graphics driver
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
8 | * This file is based on the X11 VESA driver:
|
---|
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,
|
---|
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.
|
---|
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 | *
|
---|
35 | * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
|
---|
36 | * Michael Thayer <michael.thayer@oracle.com>
|
---|
37 | */
|
---|
38 |
|
---|
39 | #ifndef GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h
|
---|
40 | #define GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h
|
---|
41 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
42 | # pragma once
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #include <VBoxVideoGuest.h>
|
---|
46 | #include <VBoxVideo.h>
|
---|
47 | #include "version-generated.h"
|
---|
48 |
|
---|
49 | #define VBOX_VENDORID 0x80EE
|
---|
50 | #define VBOX_DEVICEID 0xBEEF
|
---|
51 |
|
---|
52 | #ifndef VBVA_SCREEN_F_BLANK
|
---|
53 | # define VBVA_SCREEN_F_BLANK 0x0004
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | #include <VBoxVideoVBE.h>
|
---|
57 |
|
---|
58 | #include "xf86.h"
|
---|
59 | #include "xf86str.h"
|
---|
60 | #include "xf86Cursor.h"
|
---|
61 |
|
---|
62 | #ifdef DEBUG
|
---|
63 |
|
---|
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)
|
---|
68 | #define TRACE_LOG(...) \
|
---|
69 | do { \
|
---|
70 | xf86ErrorF("%s: ", __func__); \
|
---|
71 | xf86ErrorF(__VA_ARGS__); \
|
---|
72 | } while(0)
|
---|
73 |
|
---|
74 | #else /* !DEBUG */
|
---|
75 |
|
---|
76 | #define TRACE_ENTRY() do { } while (0)
|
---|
77 | #define TRACE_EXIT() do { } while (0)
|
---|
78 | #define TRACE_LOG(...) do { } while (0)
|
---|
79 |
|
---|
80 | #endif /* !DEBUG */
|
---|
81 |
|
---|
82 | #define VBOX_VERSION VBOX_VERSION_MAJOR * 10000 \
|
---|
83 | + VBOX_VERSION_MINOR * 100
|
---|
84 | #define VBOX_NAME "VBoxVideo"
|
---|
85 | #define VBOX_DRIVER_NAME "vboxvideo"
|
---|
86 |
|
---|
87 | #define VBOX_VIDEO_MAJOR VBOX_VERSION_MAJOR
|
---|
88 | #define VBOX_VIDEO_MINOR VBOX_VERSION_MINOR
|
---|
89 |
|
---|
90 | #define VBOX_VIDEO_MIN_SIZE 64
|
---|
91 | #define VBOX_VIDEO_MAX_VIRTUAL (INT16_MAX - 1)
|
---|
92 |
|
---|
93 | #define VBOXPTR(p) ((VBOXPtr)((p)->driverPrivate))
|
---|
94 |
|
---|
95 | /** Helper to work round different ways of getting the root window in different
|
---|
96 | * server versions. */
|
---|
97 | #if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 70000000 \
|
---|
98 | && XORG_VERSION_CURRENT >= 10900000
|
---|
99 | # define ROOT_WINDOW(pScrn) screenInfo.screens[(pScrn)->scrnIndex]->root
|
---|
100 | #else
|
---|
101 | # define ROOT_WINDOW(pScrn) WindowTable[(pScrn)->scrnIndex]
|
---|
102 | #endif
|
---|
103 |
|
---|
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 |
|
---|
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;
|
---|
119 | /** Is this CRTC enabled or in DPMS off state? */
|
---|
120 | Bool fPowerOn;
|
---|
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;
|
---|
133 | /** The current preferred location for the screen. */
|
---|
134 | RTPOINT aPreferredLocation;
|
---|
135 | /** Has this screen been enabled by the host? */
|
---|
136 | Bool afConnected;
|
---|
137 | /** Does this screen have a preferred location? */
|
---|
138 | Bool afHaveLocation;
|
---|
139 | };
|
---|
140 |
|
---|
141 | typedef struct VBOXRec
|
---|
142 | {
|
---|
143 | EntityInfoPtr pEnt;
|
---|
144 | #ifdef PCIACCESS
|
---|
145 | struct pci_device *pciInfo;
|
---|
146 | #else
|
---|
147 | pciVideoPtr pciInfo;
|
---|
148 | PCITAG pciTag;
|
---|
149 | #endif
|
---|
150 | void *base;
|
---|
151 | /** The amount of VRAM available for use as a framebuffer */
|
---|
152 | unsigned long cbFBMax;
|
---|
153 | /** The size of the framebuffer and the VBVA buffers at the end of it. */
|
---|
154 | unsigned long cbView;
|
---|
155 | /** Whether the pre-X-server mode was a VBE mode */
|
---|
156 | Bool fSavedVBEMode;
|
---|
157 | /** Paramters of the saved pre-X-server VBE mode, invalid if there is none
|
---|
158 | */
|
---|
159 | uint16_t cSavedWidth, cSavedHeight, cSavedPitch, cSavedBPP, fSavedFlags;
|
---|
160 | CloseScreenProcPtr CloseScreen;
|
---|
161 | /** Default X server procedure for enabling and disabling framebuffer access */
|
---|
162 | xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
|
---|
163 | OptionInfoPtr Options;
|
---|
164 | /** @todo we never actually free this */
|
---|
165 | xf86CursorInfoPtr pCurs;
|
---|
166 | /** Do we currently want to use the host cursor? */
|
---|
167 | Bool fUseHardwareCursor;
|
---|
168 | /** Number of screens attached */
|
---|
169 | uint32_t cScreens;
|
---|
170 | /** Information about each virtual screen. */
|
---|
171 | struct VBoxScreen *pScreens;
|
---|
172 | /** Can we get mode hint and cursor integration information from HGSMI? */
|
---|
173 | Bool fHaveHGSMIModeHints;
|
---|
174 | /** Does the host support the screen blanking flag? */
|
---|
175 | Bool fHostHasScreenBlankingFlag;
|
---|
176 | /** Array of structures for receiving mode hints. */
|
---|
177 | VBVAMODEHINT *paVBVAModeHints;
|
---|
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
|
---|
185 | #endif
|
---|
186 | /** HGSMI guest heap context */
|
---|
187 | HGSMIGUESTCOMMANDCONTEXT guestCtx;
|
---|
188 | /** Unrestricted horizontal resolution flag. */
|
---|
189 | Bool fAnyX;
|
---|
190 | } VBOXRec, *VBOXPtr;
|
---|
191 |
|
---|
192 | #define VBOXGetRec(pScrn) ((VBOXPtr)(pScrn)->driverPrivate)
|
---|
193 |
|
---|
194 | /* setmode.c */
|
---|
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 |
|
---|
211 | extern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
|
---|
212 | extern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, Bool fEnabled,
|
---|
213 | Bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
|
---|
214 | extern void vbvxSetSolarisMouseRange(int width, int height);
|
---|
215 |
|
---|
216 | /* pointer.h */
|
---|
217 | extern Bool vbvxCursorInit(ScreenPtr pScreen);
|
---|
218 | extern void vbvxCursorTerm(VBOXPtr pVBox);
|
---|
219 |
|
---|
220 | /* vbva.c */
|
---|
221 | extern void vbvxHandleDirtyRect(ScrnInfoPtr pScrn, int iRects, BoxPtr aRects);
|
---|
222 | extern void vbvxSetUpHGSMIHeapInGuest(VBOXPtr pVBox, uint32_t cbVRAM);
|
---|
223 | extern Bool vboxEnableVbva(ScrnInfoPtr pScrn);
|
---|
224 | extern void vboxDisableVbva(ScrnInfoPtr pScrn);
|
---|
225 |
|
---|
226 | /* getmode.c */
|
---|
227 | extern void vboxAddModes(ScrnInfoPtr pScrn);
|
---|
228 | extern void VBoxInitialiseSizeHints(ScrnInfoPtr pScrn);
|
---|
229 | extern void vbvxReadSizesAndCursorIntegrationFromProperties(ScrnInfoPtr pScrn, Bool *pfNeedUpdate);
|
---|
230 | extern void vbvxReadSizesAndCursorIntegrationFromHGSMI(ScrnInfoPtr pScrn, Bool *pfNeedUpdate);
|
---|
231 | extern void vbvxSetUpLinuxACPI(ScreenPtr pScreen);
|
---|
232 | extern void vbvxCleanUpLinuxACPI(ScreenPtr pScreen);
|
---|
233 |
|
---|
234 | /* EDID generation */
|
---|
235 | #ifdef VBOXVIDEO_13
|
---|
236 | extern Bool VBOXEDIDSet(struct _xf86Output *output, DisplayModePtr pmode);
|
---|
237 | #endif
|
---|
238 |
|
---|
239 | #endif /* !GA_INCLUDED_SRC_x11_vboxvideo_vboxvideo_h */
|
---|
240 |
|
---|