README revision 6df26cac
16df26cacSmrg 26df26cacSmrgCopyright (C) 1999-2002 VMware, Inc. 36df26cacSmrgAll Rights Reserved 46df26cacSmrg 56df26cacSmrgThe code here may be used/distributed under the terms of the standard 66df26cacSmrgXFree86 license. 76df26cacSmrg 86df26cacSmrg 96df26cacSmrg VMware SVGA Device Interface and Programming Model 106df26cacSmrg -------------------------------------------------- 116df26cacSmrg 126df26cacSmrg 136df26cacSmrgInclude Files 146df26cacSmrg------------- 156df26cacSmrg 166df26cacSmrgsvga_reg.h 176df26cacSmrg SVGA register definitions, SVGA capabilities, and FIFO command definitions. 186df26cacSmrg 196df26cacSmrgsvga_limits.h 206df26cacSmrg Included by svga_reg.h, defines maximum frame buffer and memory region 216df26cacSmrg sizes. 226df26cacSmrg 236df26cacSmrgsvga_modes.h 246df26cacSmrg A list of default display modes that are built into the driver. 256df26cacSmrg 266df26cacSmrgsvga_overlay.h 276df26cacSmrg A list of definitions required for Xv extension support. Included by vmwarevideo.c 286df26cacSmrg 296df26cacSmrgsvga_escape.h 306df26cacSmrg A list of definitions for the SVGA Escape commands. 316df26cacSmrg 326df26cacSmrgguest_os.h 336df26cacSmrg Values for the GUEST_ID register. 346df26cacSmrg 356df26cacSmrgvm_basic_types.h 366df26cacSmrg Common type definitions. 376df26cacSmrg 386df26cacSmrgvm_device_version.h 396df26cacSmrg PCI vendor ID's and related information. 406df26cacSmrg 416df26cacSmrgvmwarectrl.h 426df26cacSmrgvmwarectrlproto.h 436df26cacSmrg The definitions of the VMWARECTRL protocol extension. 446df26cacSmrg 456df26cacSmrgProgramming the VMware SVGA Device 466df26cacSmrg---------------------------------- 476df26cacSmrg 486df26cacSmrg1. Reading/writing a register: 496df26cacSmrg 506df26cacSmrg The SVGA registers are addressed by an index/value pair of 32 bit 516df26cacSmrg registers in the IO address space. 526df26cacSmrg 536df26cacSmrg The 0710 VMware SVGA chipset (PCI device ID PCI_DEVICE_ID_VMWARE_SVGA) has 546df26cacSmrg its index and value ports hardcoded at: 556df26cacSmrg 566df26cacSmrg index: SVGA_LEGACY_BASE_PORT + 4 * SVGA_INDEX_PORT 576df26cacSmrg value: SVGA_LEGACY_BASE_PORT + 4 * SVGA_VALUE_PORT 586df26cacSmrg 596df26cacSmrg The 0405 VMware SVGA chipset (PCI device ID PCI_DEVICE_ID_VMWARE_SVGA2) 606df26cacSmrg determines its index and value ports as a function of the first base 616df26cacSmrg address register in its PCI configuration space as: 626df26cacSmrg 636df26cacSmrg index: <Base Address Register 0> + SVGA_INDEX_PORT 646df26cacSmrg value: <Base Address Register 0> + SVGA_VALUE_PORT 656df26cacSmrg 666df26cacSmrg To read a register: 676df26cacSmrg Set the index port to the index of the register, using a dword OUT 686df26cacSmrg Do a dword IN from the value port 696df26cacSmrg 706df26cacSmrg To write a register: 716df26cacSmrg Set the index port to the index of the register, using a dword OUT 726df26cacSmrg Do a dword OUT to the value port 736df26cacSmrg 746df26cacSmrg Example, setting the width to 1024: 756df26cacSmrg 766df26cacSmrg mov eax, SVGA_REG_WIDTH 776df26cacSmrg mov edx, <SVGA Address Port> 786df26cacSmrg out dx, eax 796df26cacSmrg mov eax, 1024 806df26cacSmrg mov edx, <SVGA Value Port> 816df26cacSmrg out dx, eax 826df26cacSmrg 836df26cacSmrg2. Initialization 846df26cacSmrg Check the version number 856df26cacSmrg loop: 866df26cacSmrg Write into SVGA_REG_ID the maximum SVGA_ID_* the driver supports. 876df26cacSmrg Read from SVGA_REG_ID. 886df26cacSmrg Check if it is the value you wrote. 896df26cacSmrg If yes, VMware SVGA device supports it 906df26cacSmrg If no, decrement SVGA_ID_* and goto loop 916df26cacSmrg This algorithm converges. 926df26cacSmrg 936df26cacSmrg Map the frame buffer and the command FIFO 946df26cacSmrg Read SVGA_REG_FB_START, SVGA_REG_FB_SIZE, SVGA_REG_MEM_START, 956df26cacSmrg SVGA_REG_MEM_SIZE. 966df26cacSmrg Map the frame buffer (FB) and the FIFO memory (MEM) 976df26cacSmrg 986df26cacSmrg Get the device capabilities and frame buffer dimensions 996df26cacSmrg Read SVGA_REG_CAPABILITIES, SVGA_REG_MAX_WIDTH, SVGA_REG_MAX_HEIGHT, 1006df26cacSmrg and SVGA_REG_HOST_BITS_PER_PIXEL / SVGA_REG_BITS_PER_PIXEL. 1016df26cacSmrg 1026df26cacSmrg Note: The capabilities can and do change without the PCI device ID 1036df26cacSmrg changing or the SVGA_REG_ID changing. A driver should always check 1046df26cacSmrg the capabilities register when loading before expecting any 1056df26cacSmrg capabilities-determined feature to be available. See below for a list 1066df26cacSmrg of capabilities as of this writing. 1076df26cacSmrg 1086df26cacSmrg Note: If SVGA_CAP_8BIT_EMULATION is not set, then it is possible that 1096df26cacSmrg SVGA_REG_HOST_BITS_PER_PIXEL does not exist and 1106df26cacSmrg SVGA_REG_BITS_PER_PIXEL should be read instead. 1116df26cacSmrg 1126df26cacSmrg Report the Guest Operating System 1136df26cacSmrg Write SVGA_REG_GUEST_ID with the appropriate value from <guest_os.h>. 1146df26cacSmrg While not required in any way, this is useful information for the 1156df26cacSmrg virtual machine to have available for reporting and sanity checking 1166df26cacSmrg purposes. 1176df26cacSmrg 1186df26cacSmrg SetMode 1196df26cacSmrg Set SVGA_REG_WIDTH, SVGA_REG_HEIGHT, SVGA_REG_BITS_PER_PIXEL 1206df26cacSmrg Read SVGA_REG_FB_OFFSET 1216df26cacSmrg (SVGA_REG_FB_OFFSET is the offset from SVGA_REG_FB_START of the 1226df26cacSmrg visible portion of the frame buffer) 1236df26cacSmrg Read SVGA_REG_BYTES_PER_LINE, SVGA_REG_DEPTH, SVGA_REG_PSEUDOCOLOR, 1246df26cacSmrg SVGA_REG_RED_MASK, SVGA_REG_GREEN_MASK, SVGA_REG_BLUE_MASK 1256df26cacSmrg 1266df26cacSmrg Note: SVGA_REG_BITS_PER_PIXEL is readonly if 1276df26cacSmrg SVGA_CAP_8BIT_EMULATION is not set in the capabilities register. Even 1286df26cacSmrg if it is set, values other than 8 and SVGA_REG_HOST_BITS_PER_PIXEL 1296df26cacSmrg will be ignored. 1306df26cacSmrg 1316df26cacSmrg Enable SVGA 1326df26cacSmrg Set SVGA_REG_ENABLE to 1 1336df26cacSmrg (to disable SVGA, set SVGA_REG_ENABLE to 0. Setting SVGA_REG_ENABLE 1346df26cacSmrg to 0 also enables VGA.) 1356df26cacSmrg 1366df26cacSmrg Initialize the command FIFO 1376df26cacSmrg The FIFO is exclusively dword (32-bit) aligned. The first four 1386df26cacSmrg dwords define the portion of the MEM area that is used for the 1396df26cacSmrg command FIFO. These are values are all in byte offsets from the 1406df26cacSmrg start of the MEM area. 1416df26cacSmrg 1426df26cacSmrg A minimum sized FIFO would have these values: 1436df26cacSmrg mem[SVGA_FIFO_MIN] = 16; 1446df26cacSmrg mem[SVGA_FIFO_MAX] = 16 + (10 * 1024); 1456df26cacSmrg mem[SVGA_FIFO_NEXT_CMD] = 16; 1466df26cacSmrg mem[SVGA_FIFO_STOP] = 16; 1476df26cacSmrg 1486df26cacSmrg Set SVGA_REG_CONFIG_DONE to 1 after these values have been set. 1496df26cacSmrg 1506df26cacSmrg Note: Setting SVGA_REG_CONFIG_DONE to 0 will stop the device from 1516df26cacSmrg reading the FIFO until it is reinitialized and SVGA_REG_CONFIG_DONE is 1526df26cacSmrg set to 1 again. 1536df26cacSmrg 1546df26cacSmrg3. SVGA command FIFO protocol 1556df26cacSmrg The FIFO is empty when SVGA_FIFO_NEXT_CMD == SVGA_FIFO_STOP. The 1566df26cacSmrg driver writes commands to the FIFO starting at the offset specified 1576df26cacSmrg by SVGA_FIFO_NEXT_CMD, and then increments SVGA_FIFO_NEXT_CMD. 1586df26cacSmrg 1596df26cacSmrg The FIFO is full when SVGA_FIFO_NEXT_CMD is one word before SVGA_FIFO_STOP. 1606df26cacSmrg 1616df26cacSmrg When the FIFO becomes full, the FIFO should be sync'd 1626df26cacSmrg 1636df26cacSmrg To sync the FIFO 1646df26cacSmrg Write SVGA_REG_SYNC 1656df26cacSmrg Read SVGA_REG_BUSY 1666df26cacSmrg Wait for the value in SVGA_REG_BUSY to be 0 1676df26cacSmrg 1686df26cacSmrg The FIFO should be sync'd before the driver touches the frame buffer, to 1696df26cacSmrg guarantee that any outstanding BLT's are completed. 1706df26cacSmrg 1716df26cacSmrg4. Cursor 1726df26cacSmrg When SVGA_CAP_CURSOR is set, hardware cursor support is available. In 1736df26cacSmrg practice, SVGA_CAP_CURSOR will only be set when SVGA_CAP_CURSOR_BYPASS is 1746df26cacSmrg also set and drivers supporting a hardware cursor should only worry about 1756df26cacSmrg SVGA_CAP_CURSOR_BYPASS and only use the FIFO to define the cursor. See 1766df26cacSmrg below for more information. 1776df26cacSmrg 1786df26cacSmrg5. Pseudocolor 1796df26cacSmrg When the read-only register SVGA_REG_PSEUDOCOLOR is 1, the device is in a 1806df26cacSmrg colormapped mode whose index width and color width are both SVGA_REG_DEPTH. 1816df26cacSmrg Thus far, 8 is the only depth at which pseudocolor is ever used. 1826df26cacSmrg 1836df26cacSmrg In pseudocolor, the colormap is programmed by writing to the SVGA palette 1846df26cacSmrg registers. These start at SVGA_PALETTE_BASE and are interpreted as 1856df26cacSmrg follows: 1866df26cacSmrg 1876df26cacSmrg SVGA_PALETTE_BASE + 3*n - The nth red component 1886df26cacSmrg SVGA_PALETTE_BASE + 3*n + 1 - The nth green component 1896df26cacSmrg SVGA_PALETTE_BASE + 3*n + 2 - The nth blue component 1906df26cacSmrg 1916df26cacSmrg And n ranges from 0 to ((1<<SVGA_REG_DEPTH) - 1). 1926df26cacSmrg 1936df26cacSmrg 1946df26cacSmrgDrawing to the Screen 1956df26cacSmrg--------------------- 1966df26cacSmrg 1976df26cacSmrgAfter initialization, the driver can write directly to the frame buffer. The 1986df26cacSmrgupdated frame buffer is not displayed immediately, but only when an update 1996df26cacSmrgcommand is sent. The update command (SVGA_CMD_UPDATE) defines the rectangle 2006df26cacSmrgin the frame buffer that has been modified by the driver, and causes that 2016df26cacSmrgrectangle to be updated on the screen. 2026df26cacSmrg 2036df26cacSmrgA complete driver can be developed this way. For increased performance, 2046df26cacSmrgadditional commands are available to accelerate common operations. The two 2056df26cacSmrgmost useful are SVGA_CMD_RECT_FILL and SVGA_CMD_RECT_COPY. 2066df26cacSmrg 2076df26cacSmrgAfter issuing an accelerated command, the FIFO should be sync'd, as described 2086df26cacSmrgabove, before writing to the frame buffer. 2096df26cacSmrg 2106df26cacSmrgAddendum on 7/11/2000 2116df26cacSmrg--------------------- 2126df26cacSmrg 2136df26cacSmrgSVGA_REG_FB_OFFSET and SVGA_REG_BYTES_PER_LINE may change after SVGA_REG_WIDTH 2146df26cacSmrgor SVGA_REG_HEIGHT is set. Also the VGA registers must be written to after 2156df26cacSmrgsetting SVGA_REG_ENABLE to 0 to change the display to a VGA mode. 2166df26cacSmrg 2176df26cacSmrgAddendum on 11/29/2001 2186df26cacSmrg--------------------- 2196df26cacSmrg 2206df26cacSmrgActually, after changing any of SVGA_REG_WIDTH, SVGA_REG_HEIGHT, and 2216df26cacSmrgSVGA_REG_BITS_PER_PIXEL, all of the registers listed in the 'SetMode' 2226df26cacSmrginitialization section above should be reread. Additionally, when changing 2236df26cacSmrgmodes, it can be convenient to set SVGA_REG_ENABLE to 0, change 2246df26cacSmrgSVGA_REG_WIDTH, SVGA_REG_HEIGHT, and SVGA_REG_BITS_PER_PIXEL (if available), 2256df26cacSmrgand then set SVGA_REG_ENABLE to 1 again. 2266df26cacSmrg 2276df26cacSmrg 2286df26cacSmrgCapabilities 2296df26cacSmrg------------ 2306df26cacSmrg 2316df26cacSmrgThe capabilities register (SVGA_REG_CAPABILITIES) is an array of bits that 2326df26cacSmrgindicates the capabilities of the SVGA emulation. A driver should check 2336df26cacSmrgSVGA_REG_CAPABILITIES every time it loads before relying on any feature that 2346df26cacSmrgis only optionally available. 2356df26cacSmrg 2366df26cacSmrgSome of the capabilities determine which FIFO commands are available. This 2376df26cacSmrgtable shows which capability indicates support for which command. 2386df26cacSmrg 2396df26cacSmrg FIFO Command Capability 2406df26cacSmrg ------------ ---------- 2416df26cacSmrg 2426df26cacSmrg SVGA_CMD_RECT_FILL SVGA_CAP_RECT_FILL 2436df26cacSmrg SVGA_CMD_RECT_COPY SVGA_CAP_RECT_COPY 2446df26cacSmrg SVGA_CMD_DEFINE_BITMAP SVGA_CAP_OFFSCREEN 2456df26cacSmrg SVGA_CMD_DEFINE_BITMAP_SCANLINE SVGA_CAP_OFFSCREEN 2466df26cacSmrg SVGA_CMD_DEFINE_PIXMAP SVGA_CAP_OFFSCREEN 2476df26cacSmrg SVGA_CMD_DEFINE_PIXMAP_SCANLINE SVGA_CAP_OFFSCREEN 2486df26cacSmrg SVGA_CMD_RECT_BITMAP_FILL SVGA_CAP_RECT_PAT_FILL 2496df26cacSmrg SVGA_CMD_RECT_PIXMAP_FILL SVGA_CAP_RECT_PAT_FILL 2506df26cacSmrg SVGA_CMD_RECT_BITMAP_COPY SVGA_CAP_RECT_PAT_FILL 2516df26cacSmrg SVGA_CMD_RECT_PIXMAP_COPY SVGA_CAP_RECT_PAT_FILL 2526df26cacSmrg SVGA_CMD_FREE_OBJECT SVGA_CAP_OFFSCREEN 2536df26cacSmrg SVGA_CMD_RECT_ROP_FILL SVGA_CAP_RECT_FILL + 2546df26cacSmrg SVGA_CAP_RASTER_OP 2556df26cacSmrg SVGA_CMD_RECT_ROP_COPY SVGA_CAP_RECT_COPY + 2566df26cacSmrg SVGA_CAP_RASTER_OP 2576df26cacSmrg SVGA_CMD_RECT_ROP_BITMAP_FILL SVGA_CAP_RECT_PAT_FILL + 2586df26cacSmrg SVGA_CAP_RASTER_OP 2596df26cacSmrg SVGA_CMD_RECT_ROP_PIXMAP_FILL SVGA_CAP_RECT_PAT_FILL + 2606df26cacSmrg SVGA_CAP_RASTER_OP 2616df26cacSmrg SVGA_CMD_RECT_ROP_BITMAP_COPY SVGA_CAP_RECT_PAT_FILL + 2626df26cacSmrg SVGA_CAP_RASTER_OP 2636df26cacSmrg SVGA_CMD_RECT_ROP_PIXMAP_COPY SVGA_CAP_RECT_PAT_FILL + 2646df26cacSmrg SVGA_CAP_RASTER_OP 2656df26cacSmrg SVGA_CMD_DEFINE_CURSOR SVGA_CAP_CURSOR 2666df26cacSmrg SVGA_CMD_DISPLAY_CURSOR SVGA_CAP_CURSOR 2676df26cacSmrg SVGA_CMD_MOVE_CURSOR SVGA_CAP_CURSOR 2686df26cacSmrg SVGA_CMD_DEFINE_ALPHA_CURSOR SVGA_CAP_ALPHA_CURSOR 2696df26cacSmrg SVGA_CMD_DRAW_GLYPH SVGA_CAP_GLYPH 2706df26cacSmrg SVGA_CMD_DRAW_GLYPH_CLIPPED SVGA_CAP_GLYPH_CLIPPING 2716df26cacSmrg SVGA_CMD_ESCAPE SVGA_FIFO_CAP_ESCAPE 2726df26cacSmrg 2736df26cacSmrgNote: SVGA_CMD_DISPLAY_CURSOR and SVGA_CMD_MOVE_CURSOR should not be used. 2746df26cacSmrgDrivers wishing hardware cursor support should use cursor bypass (see below). 2756df26cacSmrg 2766df26cacSmrgOther capabilities indicate other functionality as described below: 2776df26cacSmrg 2786df26cacSmrg SVGA_CAP_CURSOR_BYPASS 2796df26cacSmrg The hardware cursor can be drawn via SVGA Registers (without requiring 2806df26cacSmrg the FIFO be synchronized and will be drawn potentially before any 2816df26cacSmrg outstanding unprocessed FIFO commands). 2826df26cacSmrg 2836df26cacSmrg Note: Without SVGA_CAP_CURSOR_BYPASS_2, cursors drawn this way still 2846df26cacSmrg appear in the guest's framebuffer and need to be turned off before any 2856df26cacSmrg save under / overlapping drawing and turned back on after. This can 2866df26cacSmrg cause very noticeable cursor flicker. 2876df26cacSmrg 2886df26cacSmrg SVGA_CAP_CURSOR_BYPASS_2 2896df26cacSmrg Instead of turning the cursor off and back on around any overlapping 2906df26cacSmrg drawing, the driver can write SVGA_CURSOR_ON_REMOVE_FROM_FB and 2916df26cacSmrg SVGA_CURSOR_ON_RESTORE_TO_FB to SVGA_REG_CURSOR_ON. In almost all 2926df26cacSmrg cases these are NOPs and the cursor will be remain visible without 2936df26cacSmrg appearing in the guest framebuffer. In 'direct graphics' modes like 2946df26cacSmrg Linux host fullscreen local displays, however, the cursor will still 2956df26cacSmrg be drawn in the framebuffer, still flicker, and be drawn incorrectly 2966df26cacSmrg if a driver does not use SVGA_CURSOR_ON_REMOVE_FROM_FB / RESTORE_TO_FB. 2976df26cacSmrg 2986df26cacSmrg SVGA_CAP_8BIT_EMULATION 2996df26cacSmrg SVGA_REG_BITS_PER_PIXEL is writable and can be set to either 8 or 3006df26cacSmrg SVGA_REG_HOST_BITS_PER_PIXEL. Otherwise the only SVGA modes available 3016df26cacSmrg inside a virtual machine must match the host's bits per pixel. 3026df26cacSmrg 3036df26cacSmrg Note: Some versions which lack SVGA_CAP_8BIT_EMULATION also lack the 3046df26cacSmrg SVGA_REG_HOST_BITS_PER_PIXEL and a driver should assume 3056df26cacSmrg SVGA_REG_BITS_PER_PIXEL is both read-only and initialized to the only 3066df26cacSmrg available value if SVGA_CAP_8BIT_EMULATION is not set. 3076df26cacSmrg 3086df26cacSmrg SVGA_CAP_OFFSCREEN_1 3096df26cacSmrg SVGA_CMD_RECT_FILL, SVGA_CMD_RECT_COPY, SVGA_CMD_RECT_ROP_FILL, 3106df26cacSmrg SVGA_CMD_RECT_ROP_COPY can operate with a source or destination (or 3116df26cacSmrg both) in offscreen memory. 3126df26cacSmrg 3136df26cacSmrg Usable offscreen memory is a rectangle located below the last scanline 3146df26cacSmrg of the visible memory: 3156df26cacSmrg x1 = 0 3166df26cacSmrg y1 = (SVGA_REG_FB_SIZE + SVGA_REG_BYTES_PER_LINE - 1) / 3176df26cacSmrg SVGA_REG_BYTES_PER_LINE 3186df26cacSmrg x2 = SVGA_REG_BYTES_PER_LINE / SVGA_REG_DEPTH 3196df26cacSmrg y2 = SVGA_REG_VRAM_SIZE / SVGA_REG_BYTES_PER_LINE 3206df26cacSmrg 3216df26cacSmrg 3226df26cacSmrgCursor Handling 3236df26cacSmrg--------------- 3246df26cacSmrg 3256df26cacSmrgStarting with GSX Server Beta 3 (after 11/15/2000), hardware cursor support 3266df26cacSmrgwas added. Actually, both a hardware cursor via the FIFO (SVGA_CAP_CURSOR) 3276df26cacSmrgand a hardware cursor via the SVGA registers (SVGA_CAP_CURSOR_BYPASS) were 3286df26cacSmrgadded. SVGA_CAP_CURSOR was never available without SVGA_CAP_CURSOR_BYPASS and 3296df26cacSmrgthe FIFO hardware cursor should never be used and may be removed without 3306df26cacSmrgwarning in the future. 3316df26cacSmrg 3326df26cacSmrgCursor bypass is programmed using the two FIFO commands SVGA_CMD_DEFINE_CURSOR 3336df26cacSmrgand SVGA_CMD_DEFINE_ALPHA_CURSOR in conjunction with the SVGA registers 3346df26cacSmrgSVGA_REG_CURSOR_ID, SVGA_REG_CURSOR_X, SVGA_REG_CURSOR_Y, and 3356df26cacSmrgSVGA_REG_CURSOR_ON. 3366df26cacSmrg 3376df26cacSmrgA driver defines an AND/XOR hardware cursor using SVGA_CMD_DEFINE_CURSOR to 3386df26cacSmrgassign an ID and establish the AND and XOR masks with the hardware. A driver 3396df26cacSmrguses SVGA_CMD_DEFINE_ALPHA_CURSOR to define a 32 bit mask whose top 8 bits are 3406df26cacSmrgused to blend the cursor image with the pixels it covers. Alpha cursor 3416df26cacSmrgsupport is only available when SVGA_CAP_ALPHA_CURSOR is set. 3426df26cacSmrg 3436df26cacSmrgOnce a cursor is defined, a driver can draw it to the screen at any time by 3446df26cacSmrgwriting the SVGA_REG_CURSOR_ID register with the ID used when the cursor was 3456df26cacSmrgdefined, writing SVGA_REG_CURSOR_X and SVGA_REG_CURSOR_Y with the location of 3466df26cacSmrgthe cursor, and SVGA_CURSOR_ON_SHOW to SVGA_REG_CURSOR_ON. The drawing occurs 3476df26cacSmrgwhen SVGA_REG_CURSOR_ON is written. 3486df26cacSmrg 3496df26cacSmrgWriting SVGA_CURSOR_ON_HIDE to SVGA_REG_CURSOR_ON will turn the cursor off and 3506df26cacSmrgmake it vanish from the display and, if present, from the framebuffer. 3516df26cacSmrgSVGA_CURSOR_ON_REMOVE_FROM_FB will ensure the cursor is not in the 3526df26cacSmrgframebuffer, but will only turn it off if there's no other way to remove it. 3536df26cacSmrgSVGA_CURSOR_ON_RESTORE_TO_FB is the complement to 3546df26cacSmrgSVGA_CURSOR_ON_REMOVE_FROM_FB. Whenever possible, the device will not put the 3556df26cacSmrgcursor in the framebuffer and Remove From / Restore To will be NOPs. 3566df26cacSmrg 3576df26cacSmrgNote: The cursor must be out of the frame buffer before the driver (or any 3586df26cacSmrgagent in the virtual machine) touches an overlapping portion of the frame 3596df26cacSmrgbuffer, because it is actually drawn into the frame buffer memory in the 3606df26cacSmrgcase of direct graphics mode (e.g. full screen mode on Linux). The cursor 3616df26cacSmrgdoes not have to be touched before issuing an accelerated command via the 3626df26cacSmrgcommand FIFO, this case is handled by the SVGA device. 3636df26cacSmrg 3646df26cacSmrgNote: If SVGA_CAP_CURSOR_BYPASS2 is not present, the driver must use 3656df26cacSmrgSVGA_CURSOR_ON_HIDE and SVGA_CURSOR_ON_HIDE to be certain the cursor is out of 3666df26cacSmrgthe framebuffer. 3676df26cacSmrg 3686df26cacSmrg 3696df26cacSmrgDriver Version Numbers 3706df26cacSmrg---------------------- 3716df26cacSmrg 3726df26cacSmrgThe SVGA drivers use the following convention for their version numbers: 3736df26cacSmrg 3746df26cacSmrgVersion 10.0 - The first version that uses the FIFO 3756df26cacSmrgVersion 10.1 - The version that uses the hardware cursor emulation via the FIFO 3766df26cacSmrgVersion 10.2 - The version that uses the cursor that bypasses the FIFO 3776df26cacSmrgVersion 10.3 - The version that can also support the 0405 chipset 3786df26cacSmrgVersion 10.4 - The version that knows about SVGA_CAP_CURSOR_BYPASS2 3796df26cacSmrgVersion 10.5 - [Never released or well defined] 3806df26cacSmrgVersion 10.6 - The version that knows about SVGA_CAP_8BIT_EMULATION 3816df26cacSmrgVersion 10.7 - The version that knows about SVGA_CAP_ALPHA_CURSOR 3826df26cacSmrgVersion 10.8 - The version that knows about SVGA_CAP_GLYPH 3836df26cacSmrgVersion 10.9 - The version that knows about SVGA_CAP_OFFSCREEN_1 3846df26cacSmrg 3856df26cacSmrgNote that this is merely the convention used by SVGA drivers written and 3866df26cacSmrgmaintained by VMware, Inc. and describes the capabilities of the driver, not 3876df26cacSmrgthe virtual hardware. An SVGA driver can only use the intersection of the 3886df26cacSmrgfunctionality it supports and the functionality available in the virtual SVGA 3896df26cacSmrghardware. 3906df26cacSmrg 3916df26cacSmrg 3926df26cacSmrgFrequently Asked Questions 3936df26cacSmrg-------------------------- 3946df26cacSmrg 3956df26cacSmrg1. My driver doesn't display anything, what's going on? 3966df26cacSmrg 3976df26cacSmrgFirst check if you are issuing an SVGA_CMD_UPDATE after drawing to 3986df26cacSmrgthe screen. Another check you can do is to run your driver in full 3996df26cacSmrgscreen mode on a Linux host. In this case you are drawing directly 4006df26cacSmrgon the frame buffer, so what you draw to the screen will be immediately 4016df26cacSmrgvisible. If nothing is visible in this case, then most likely your 4026df26cacSmrgdriver hasn't mapped the frame buffer correctly. 4036df26cacSmrg 4046df26cacSmrgA discrepancy between what you get in full screen mode and what you 4056df26cacSmrgget in window mode indicates that you have a missing or incorrect 4066df26cacSmrgupdate command. 4076df26cacSmrg 4086df26cacSmrg 4096df26cacSmrg2. What's the difference between bitmaps and pixmaps? 4106df26cacSmrg 4116df26cacSmrgPixmaps have the same depth as the screen, while bitmaps have depth one. 4126df26cacSmrgWhen a bitmap is drawn, the command also takes two colors, foreground and 4136df26cacSmrgbackground. The set bits in the bitmap are replaced with the foreground 4146df26cacSmrgcolor, and the unset bits are replaced with the background color. 4156df26cacSmrg 4166df26cacSmrgPixmaps, on the other hand, can be directly copied to the screen. 4176df26cacSmrg 4186df26cacSmrg 4196df26cacSmrg3. What's the significance of the ROP in the commands SVGA_CMD_RECT_ROP_FILL, 4206df26cacSmrgSVGA_CMD_RECT_ROP_BITMAP_COPY, etc. ? 4216df26cacSmrg 4226df26cacSmrgThe ROP in the ...ROP... commands is a raster operation. It has the same 4236df26cacSmrgsignificance (and encoding) as it does in X. The ROP value SVGA_ROP_COPY 4246df26cacSmrgmeans the source is copied to the destination, which makes these commands the 4256df26cacSmrgsame as their non-ROP counterparts. The most commonly used raster operation 4266df26cacSmrgother than copy is probably SVGA_ROP_XOR, which combines the source and 4276df26cacSmrgdestination using exclusive-or. 4286df26cacSmrg 4296df26cacSmrg 4306df26cacSmrg4. Tell me more about bitmaps and pixmaps. For example, the macro 4316df26cacSmrgSVGA_CMD_DEFINE_BITMAP has a field <scanlines>. What should this be 4326df26cacSmrgset to? Likewise with SVGA_CMD_DEFINE_PIXMAP. And when should the 4336df26cacSmrgSCANLINE macros be used? 4346df26cacSmrg 4356df26cacSmrgOK, I'll use pixmaps as an example. First you have to define the pixmap: 4366df26cacSmrg 4376df26cacSmrg#define SVGA_CMD_DEFINE_PIXMAP 6 4386df26cacSmrg /* FIFO layout: 4396df26cacSmrg Pixmap ID, Width, Height, Depth, <scanlines> */ 4406df26cacSmrg 4416df26cacSmrgThe ID is something you choose, which you subsequently use to refer to 4426df26cacSmrgthis pixmap. It must be an integer between 0 and SVGA_MAX_ID. 4436df26cacSmrg 4446df26cacSmrgThe width and height and depth are the dimensions of the pixmap. For now, 4456df26cacSmrgthe depth of the pixmap has to match the depth of the screen. 4466df26cacSmrg 4476df26cacSmrgThe scanlines are the pixels that make up the pixmap, arranged one row 4486df26cacSmrgat a time. Each row is required to be 32-bit aligned. The macros 4496df26cacSmrgSVGA_PIXMAP_SCANLINE_SIZE and SVGA_PIXMAP_SIZE give the size of a 4506df26cacSmrgsingle scanline, and the size of the entire pixmap, respectively, in 4516df26cacSmrg32-bit words. 4526df26cacSmrg 4536df26cacSmrgThe second step is to use it: 4546df26cacSmrg 4556df26cacSmrg#define SVGA_CMD_RECT_PIXMAP_FILL 9 4566df26cacSmrg /* FIFO layout: 4576df26cacSmrg Pixmap ID, X, Y, Width, Height */ 4586df26cacSmrg 4596df26cacSmrgThe ID here is the one you chose when defining the pixmap. X, Y, 4606df26cacSmrgWidth, and Height define a rectangle on the screen that is to be filled 4616df26cacSmrgwith the pixmap. The pixmap is screen aligned, which means that the 4626df26cacSmrgcoordinates in the pixmap are defined by the screen coordinates modulo 4636df26cacSmrgthe pixmap dimensions. 4646df26cacSmrg 4656df26cacSmrgIf you want a different alignment between the screen and the pixmap, 4666df26cacSmrgthen you can use this command, which allows the pixmap coordinates to 4676df26cacSmrgbe defined: 4686df26cacSmrg 4696df26cacSmrg#define SVGA_CMD_RECT_PIXMAP_COPY 11 4706df26cacSmrg /* FIFO layout: 4716df26cacSmrg Pixmap ID, Source X, Source Y, Dest X, Dest Y, Width, 4726df26cacSmrg Height */ 4736df26cacSmrg 4746df26cacSmrgThe Source X and Source Y are pixmap coordinates, and the Dest X and 4756df26cacSmrgDest Y are screen coordinates. 4766df26cacSmrg 4776df26cacSmrg 4786df26cacSmrg5. OK, now it works briefly, then stops displaying anything. Also, 4796df26cacSmrgmy log file is filled with lines like: 4806df26cacSmrg Unknown Command 0xff in SVGA command FIFO 4816df26cacSmrgWhat's happening? 4826df26cacSmrg 4836df26cacSmrgThe most common problem at this point is that the FIFO gets out 4846df26cacSmrgof sync. This can happen if the amount of data in the FIFO doesn't 4856df26cacSmrgmatch what the VMware SVGA device expects. To track this down, try 4866df26cacSmrgto isolate the particular command which causes the problem. 4876df26cacSmrg 4886df26cacSmrgAnother way this can happen is if the wraparound in the FIFO isn't 4896df26cacSmrgdone correctly. Here is some example code for writing to the FIFO 4906df26cacSmrg(mem is an array of 32-bit integers that points to the FIFO memory 4916df26cacSmrgregion): 4926df26cacSmrg 4936df26cacSmrgwhile (TRUE) { 4946df26cacSmrg fifo_min = mem[SVGA_FIFO_MIN] / 4; 4956df26cacSmrg fifo_max = mem[SVGA_FIFO_MAX] / 4; 4966df26cacSmrg fifo_next = mem[SVGA_FIFO_NEXT_CMD] / 4; 4976df26cacSmrg fifo_stop = mem[SVGA_FIFO_STOP] / 4; 4986df26cacSmrg 4996df26cacSmrg tmp_next = fifo_next+1; 5006df26cacSmrg if (tmp_next == fifo_max) 5016df26cacSmrg tmp_next = fifo_min; // Wraparound 5026df26cacSmrg 5036df26cacSmrg if (tmp_next == fifo_stop) { 5046df26cacSmrg sync_fifo(); // FIFO full 5056df26cacSmrg continue; // retry 5066df26cacSmrg } 5076df26cacSmrg 5086df26cacSmrg mem[fifo_next] = item; 5096df26cacSmrg mem[SVGA_FIFO_NEXT_CMD] = tmp_next * 4; 5106df26cacSmrg break; 5116df26cacSmrg} 5126df26cacSmrg 5136df26cacSmrgThis isn't the most efficient code, but it should work. It's important 5146df26cacSmrgto do the increment with wraparound before the FIFO full check, and to 5156df26cacSmrgcheck FIFO full before updating the next command pointer. 5166df26cacSmrg 5176df26cacSmrg 5186df26cacSmrg6. My driver tries to switch modes and either nothing happens or the 5196df26cacSmrgdisplay becomes completely garbled. What's going on? 5206df26cacSmrg 5216df26cacSmrgWhen you change modes, make very sure you reread all of the registers listed 5226df26cacSmrgabove under SetMode. Getting the pitch (SVGA_REG_BYTES_PER_LINE) incorrect 5236df26cacSmrgwill cause a heavily garbled display. Also, if you change 5246df26cacSmrgSVGA_REG_BITS_PER_PIXEL, make certain that SVGA_CAP_8BIT_EMULATION is present 5256df26cacSmrgin the SVGA_REG_CAPABILITIES register. Also, even with 8 bit emulation, the 5266df26cacSmrgdriver must still use either 8 bpp or SVGA_REG_HOST_BITS_PER_PIXEL bpp, 5276df26cacSmrgnothing else. 5286df26cacSmrg 5296df26cacSmrg 5306df26cacSmrg7. Why does my driver's hardware cursor work when my virtual machine is in 5316df26cacSmrgwindow mode, but draw/erase incorrectly or in garbled locations in fullscreen 5326df26cacSmrgmode? 5336df26cacSmrg 5346df26cacSmrgYou need to make sure you use SVGA_CURSOR_ON_REMOVE_FROM_FB and 5356df26cacSmrgSVGA_CURSOR_ON_RESTORE_TO_FB _every_ time your driver or the virtual machine 5366df26cacSmrgtouches a region of the framebuffer that overlaps the cursor. If you forget 5376df26cacSmrgto remove it then it can show up when doing save-under operations or get mixed 5386df26cacSmrgin with other drawing. If you forget to restore it then can disappear. You 5396df26cacSmrgalso need to make sure SVGA_CAP_CURSOR_BYPASS2 is available, or else you will 5406df26cacSmrghave to use SVGA_CURSOR_ON_SHOW and SVGA_CURSOR_ON_HIDE (which will flicker, 5416df26cacSmrgeven in window mode), or else a software cursor. Newer version of the virtual 5426df26cacSmrgSVGA hardware will never put the hardware cursor in the framebuffer while in 5436df26cacSmrgwindow mode, so everything will appear to work correctly there. 5446df26cacSmrg 5456df26cacSmrg 5466df26cacSmrg8. Why do my accelerated glyphs look funny? OR Why does the fifo complain 5476df26cacSmrgabout invalid commands when I draw accelerated glyphs? 5486df26cacSmrg 5496df26cacSmrgThe bitmap data passed to SVGA_CMD_DRAW_GLYPH_* must not have any per-scanline 5506df26cacSmrgalignment. If there are any remaining bits left in the last byte of a scanline, 5516df26cacSmrgthe first bits of the next scanline should use them. 5526df26cacSmrg 5536df26cacSmrgThe bitmap data as a whole must be 4 byte aligned. 5546df26cacSmrg 5556df26cacSmrg$XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/README,v 1.5 2002/10/16 22:12:53 alanh Exp $ 556