1 /* ********************************************************** 2 * Copyright (C) 1998-2001 VMware, Inc. 3 * All Rights Reserved 4 * **********************************************************/ 5 6 #ifndef VMWARE_H 7 #define VMWARE_H 8 9 10 #ifdef HAVE_CONFIG_H 11 #include "config.h" 12 #endif 13 14 #ifdef HAVE_XORG_SERVER_1_1_0 15 #include <string.h> 16 #endif 17 18 #include "xf86.h" 19 #include "xf86_OSproc.h" 20 21 #include <X11/extensions/panoramiXproto.h> 22 23 #ifdef XSERVER_LIBPCIACCESS 24 #include <pciaccess.h> 25 #else 26 #include "xf86Resources.h" 27 #endif 28 29 #include "compiler.h" /* inb/outb */ 30 31 #include "xf86Pci.h" /* pci */ 32 #include "xf86Cursor.h" /* hw cursor */ 33 #include "cursorstr.h" /* xhot/yhot */ 34 35 #include "vgaHW.h" /* VGA hardware */ 36 #include "fb.h" 37 38 #include "xf86cmap.h" /* xf86HandleColormaps */ 39 40 #include "vm_basic_types.h" 41 #include "svga_reg.h" 42 #include "svga_struct.h" 43 #include "vmware_bootstrap.h" 44 #include <xf86Module.h> 45 46 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12 47 #define _swapl(x, n) swapl(x,n) 48 #define _swaps(x, n) swaps(x,n) 49 #else 50 #define _swapl(x, n) (void) n; swapl(x) 51 #define _swaps(x, n) (void) n; swaps(x) 52 #endif 53 54 /* 55 * The virtual hardware's cursor limits are pretty big. Some VMware 56 * product versions limit to 1024x1024 pixels, others limit to 128 57 * kilobytes of cursor data. We just choose an arbitrary maximum 58 * cursor size. 64x64 is a common value for real hardware, so we'll go 59 * with that. 60 */ 61 #define MAX_CURS 64 62 63 #define NUM_DYN_MODES 2 64 65 66 typedef struct { 67 CARD32 svga_reg_enable; 68 CARD32 svga_reg_width; 69 CARD32 svga_reg_height; 70 CARD32 svga_reg_bits_per_pixel; 71 72 CARD32 svga_reg_cursor_on; 73 CARD32 svga_reg_cursor_x; 74 CARD32 svga_reg_cursor_y; 75 CARD32 svga_reg_cursor_id; 76 77 Bool svga_fifo_enabled; 78 79 CARD32 svga_reg_id; 80 } VMWARERegRec, *VMWARERegPtr; 81 82 typedef xXineramaScreenInfo VMWAREXineramaRec, *VMWAREXineramaPtr; 83 84 typedef struct { 85 EntityInfoPtr pEnt; 86 #if XSERVER_LIBPCIACCESS 87 struct pci_device *PciInfo; 88 #else 89 pciVideoPtr PciInfo; 90 PCITAG PciTag; 91 #endif 92 Bool Primary; 93 int depth; 94 int bitsPerPixel; 95 rgb weight; 96 rgb offset; 97 int defaultVisual; 98 int videoRam; 99 unsigned long memPhysBase; 100 unsigned long fbOffset; 101 unsigned long fbPitch; 102 unsigned long ioBase; 103 unsigned long portIOBase; 104 int maxWidth; 105 int maxHeight; 106 unsigned int vmwareCapability; 107 108 unsigned char* FbBase; 109 unsigned long FbSize; 110 111 VMWARERegRec SavedReg; 112 VMWARERegRec ModeReg; 113 CARD32 suspensionSavedRegId; 114 115 DisplayModePtr dynModes[NUM_DYN_MODES]; 116 117 Bool* pvtSema; 118 119 Bool noAccel; 120 Bool hwCursor; 121 Bool cursorDefined; 122 int cursorSema; 123 Bool cursorExcludedForUpdate; 124 Bool cursorShouldBeHidden; 125 126 unsigned int cursorRemoveFromFB; 127 unsigned int cursorRestoreToFB; 128 129 #ifdef RENDER 130 CompositeProcPtr Composite; 131 void (*EnableDisableFBAccess)(int, Bool); 132 #endif /* RENDER */ 133 134 unsigned long mmioPhysBase; 135 unsigned long mmioSize; 136 137 unsigned char* mmioVirtBase; 138 CARD32* vmwareFIFO; 139 140 xf86CursorInfoPtr CursorInfoRec; 141 CursorPtr oldCurs; 142 struct { 143 int bg, fg, x, y; 144 int hotX, hotY; 145 BoxRec box; 146 147 uint32 mask[SVGA_BITMAP_SIZE(MAX_CURS, MAX_CURS)]; 148 uint32 maskPixmap[SVGA_PIXMAP_SIZE(MAX_CURS, MAX_CURS, 32)]; 149 uint32 source[SVGA_BITMAP_SIZE(MAX_CURS, MAX_CURS)]; 150 uint32 sourcePixmap[SVGA_PIXMAP_SIZE(MAX_CURS, MAX_CURS, 32)]; 151 } hwcur; 152 153 unsigned long indexReg, valueReg; 154 155 ScreenRec ScrnFuncs; 156 157 /* 158 * Xinerama state 159 */ 160 Bool xinerama; 161 Bool xineramaStatic; 162 163 VMWAREXineramaPtr xineramaState; 164 unsigned int xineramaNumOutputs; 165 166 VMWAREXineramaPtr xineramaNextState; 167 unsigned int xineramaNextNumOutputs; 168 169 /* 170 * Xv 171 */ 172 DevUnion *videoStreams; 173 174 } VMWARERec, *VMWAREPtr; 175 176 #define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate)) 177 178 #define MIN(a,b) ((a)<(b)?(a):(b)) 179 #define MAX(a,b) ((a)>(b)?(a):(b)) 180 #define ABS(x) (((x) >= 0) ? (x) : -(x)) 181 182 #define BOX_INTERSECT(a, b) \ 183 (ABS(((a).x1 + (a).x2) - ((b).x1 + (b).x2)) <= \ 184 ((a).x2 - (a).x1) + ((b).x2 - (b).x1) && \ 185 ABS(((a).y1 + (a).y2) - ((b).y1 + (b).y2)) <= \ 186 ((a).y2 - (a).y1) + ((b).y2 - (b).y1)) 187 188 #define SVGA_GLYPH_SCANLINE_SIZE_DWORDS(w) (((w) + 31) >> 5) 189 190 #define PRE_OP_HIDE_CURSOR() \ 191 if (pVMWARE->cursorDefined && *pVMWARE->pvtSema) { \ 192 pVMWARE->cursorSema++; \ 193 if (pVMWARE->cursorSema == 1) { \ 194 vmwareWriteCursorRegs(pVMWARE, FALSE, FALSE); \ 195 } \ 196 } 197 #define POST_OP_SHOW_CURSOR() \ 198 if (pVMWARE->cursorDefined && *pVMWARE->pvtSema) { \ 199 pVMWARE->cursorSema--; \ 200 if (!pVMWARE->cursorSema && !pVMWARE->cursorShouldBeHidden) { \ 201 vmwareWriteCursorRegs(pVMWARE, TRUE, FALSE); \ 202 } \ 203 } 204 205 #define MOUSE_ID 1 206 207 /* Undefine this to kill all acceleration */ 208 #define ACCELERATE_OPS 209 210 #if XSERVER_LIBPCIACCESS 211 #define VENDOR_ID(p) (p)->vendor_id 212 #define DEVICE_ID(p) (p)->device_id 213 #define SUBVENDOR_ID(p) (p)->subvendor_id 214 #define SUBSYS_ID(p) (p)->subdevice_id 215 #define CHIP_REVISION(p) (p)->revision 216 #else 217 #define VENDOR_ID(p) (p)->vendor 218 #define DEVICE_ID(p) (p)->chipType 219 #define SUBVENDOR_ID(p) (p)->subsysVendor 220 #define SUBSYS_ID(p) (p)->subsysCard 221 #define CHIP_REVISION(p) (p)->chipRev 222 #endif 223 224 void vmwareWriteReg( 225 VMWAREPtr pVMWARE, int index, CARD32 value 226 ); 227 228 CARD32 vmwareReadReg( 229 VMWAREPtr pVMWARE, int index 230 ); 231 232 void vmwareWriteWordToFIFO( 233 VMWAREPtr pVMWARE, CARD32 value 234 ); 235 236 void vmwareWaitForFB( 237 VMWAREPtr pVMWARE 238 ); 239 240 void vmwareSendSVGACmdUpdate( 241 VMWAREPtr pVMWARE, BoxPtr pBB 242 ); 243 244 void vmwareSendSVGACmdUpdateFullScreen( 245 VMWAREPtr pVMWARE 246 ); 247 248 DisplayModeRec *VMWAREAddDisplayMode( 249 ScrnInfoPtr pScrn, 250 const char *name, 251 int width, 252 int height 253 ); 254 255 Bool vmwareIsRegionEqual( 256 const RegionPtr reg1, 257 const RegionPtr reg2 258 ); 259 260 void vmwareNextXineramaState( 261 VMWAREPtr pVMWARE 262 ); 263 264 /* vmwarecurs.c */ 265 Bool vmwareCursorInit( 266 ScreenPtr pScr 267 ); 268 269 void vmwareCursorModeInit( 270 ScrnInfoPtr pScrn, 271 DisplayModePtr mode 272 ); 273 274 void vmwareCursorCloseScreen( 275 ScreenPtr pScr 276 ); 277 278 void vmwareWriteCursorRegs( 279 VMWAREPtr pVMWARE, 280 Bool visible, 281 Bool force 282 ); 283 284 void vmwareCursorHookWrappers( 285 ScreenPtr pScreen 286 ); 287 288 289 /* vmwarectrl.c */ 290 void VMwareCtrl_ExtInit(ScrnInfoPtr pScrn); 291 292 /* vmwarexinerama.c */ 293 void VMwareXinerama_ExtInit(ScrnInfoPtr pScrn); 294 295 /* vmwarevideo.c */ 296 Bool vmwareVideoInit( 297 ScreenPtr pScreen 298 ); 299 void vmwareVideoEnd( 300 ScreenPtr pScreen 301 ); 302 Bool vmwareVideoEnabled( 303 VMWAREPtr pVMWARE 304 ); 305 306 void vmwareCheckVideoSanity( 307 ScrnInfoPtr pScrn 308 ); 309 310 /* vmwaremode.c */ 311 void vmwareAddDefaultMode( 312 ScrnInfoPtr pScrn, 313 uint32 dwidth, 314 uint32 dheight 315 ); 316 #endif 317