README revision 1.1 1 1.1 mrg
2 1.1 mrg Copyright (C) 1999-2002 VMware, Inc.
3 1.1 mrg All Rights Reserved
4 1.1 mrg
5 1.1 mrg The code here may be used/distributed under the terms of the standard
6 1.1 mrg XFree86 license.
7 1.1 mrg
8 1.1 mrg
9 1.1 mrg VMware SVGA Device Interface and Programming Model
10 1.1 mrg --------------------------------------------------
11 1.1 mrg
12 1.1 mrg
13 1.1 mrg Include Files
14 1.1 mrg -------------
15 1.1 mrg
16 1.1 mrg svga_reg.h
17 1.1 mrg SVGA register definitions, SVGA capabilities, and FIFO command definitions.
18 1.1 mrg
19 1.1 mrg svga_limits.h
20 1.1 mrg Included by svga_reg.h, defines maximum frame buffer and memory region
21 1.1 mrg sizes.
22 1.1 mrg
23 1.1 mrg svga_modes.h
24 1.1 mrg A list of default display modes that are built into the driver.
25 1.1 mrg
26 1.1 mrg svga_overlay.h
27 1.1 mrg A list of definitions required for Xv extension support. Included by vmwarevideo.c
28 1.1 mrg
29 1.1 mrg svga_escape.h
30 1.1 mrg A list of definitions for the SVGA Escape commands.
31 1.1 mrg
32 1.1 mrg guest_os.h
33 1.1 mrg Values for the GUEST_ID register.
34 1.1 mrg
35 1.1 mrg vm_basic_types.h
36 1.1 mrg Common type definitions.
37 1.1 mrg
38 1.1 mrg vm_device_version.h
39 1.1 mrg PCI vendor ID's and related information.
40 1.1 mrg
41 1.1 mrg vmwarectrl.h
42 1.1 mrg vmwarectrlproto.h
43 1.1 mrg The definitions of the VMWARECTRL protocol extension.
44 1.1 mrg
45 1.1 mrg Programming the VMware SVGA Device
46 1.1 mrg ----------------------------------
47 1.1 mrg
48 1.1 mrg 1. Reading/writing a register:
49 1.1 mrg
50 1.1 mrg The SVGA registers are addressed by an index/value pair of 32 bit
51 1.1 mrg registers in the IO address space.
52 1.1 mrg
53 1.1 mrg The 0710 VMware SVGA chipset (PCI device ID PCI_DEVICE_ID_VMWARE_SVGA) has
54 1.1 mrg its index and value ports hardcoded at:
55 1.1 mrg
56 1.1 mrg index: SVGA_LEGACY_BASE_PORT + 4 * SVGA_INDEX_PORT
57 1.1 mrg value: SVGA_LEGACY_BASE_PORT + 4 * SVGA_VALUE_PORT
58 1.1 mrg
59 1.1 mrg The 0405 VMware SVGA chipset (PCI device ID PCI_DEVICE_ID_VMWARE_SVGA2)
60 1.1 mrg determines its index and value ports as a function of the first base
61 1.1 mrg address register in its PCI configuration space as:
62 1.1 mrg
63 1.1 mrg index: <Base Address Register 0> + SVGA_INDEX_PORT
64 1.1 mrg value: <Base Address Register 0> + SVGA_VALUE_PORT
65 1.1 mrg
66 1.1 mrg To read a register:
67 1.1 mrg Set the index port to the index of the register, using a dword OUT
68 1.1 mrg Do a dword IN from the value port
69 1.1 mrg
70 1.1 mrg To write a register:
71 1.1 mrg Set the index port to the index of the register, using a dword OUT
72 1.1 mrg Do a dword OUT to the value port
73 1.1 mrg
74 1.1 mrg Example, setting the width to 1024:
75 1.1 mrg
76 1.1 mrg mov eax, SVGA_REG_WIDTH
77 1.1 mrg mov edx, <SVGA Address Port>
78 1.1 mrg out dx, eax
79 1.1 mrg mov eax, 1024
80 1.1 mrg mov edx, <SVGA Value Port>
81 1.1 mrg out dx, eax
82 1.1 mrg
83 1.1 mrg 2. Initialization
84 1.1 mrg Check the version number
85 1.1 mrg loop:
86 1.1 mrg Write into SVGA_REG_ID the maximum SVGA_ID_* the driver supports.
87 1.1 mrg Read from SVGA_REG_ID.
88 1.1 mrg Check if it is the value you wrote.
89 1.1 mrg If yes, VMware SVGA device supports it
90 1.1 mrg If no, decrement SVGA_ID_* and goto loop
91 1.1 mrg This algorithm converges.
92 1.1 mrg
93 1.1 mrg Map the frame buffer and the command FIFO
94 1.1 mrg Read SVGA_REG_FB_START, SVGA_REG_FB_SIZE, SVGA_REG_MEM_START,
95 1.1 mrg SVGA_REG_MEM_SIZE.
96 1.1 mrg Map the frame buffer (FB) and the FIFO memory (MEM)
97 1.1 mrg
98 1.1 mrg Get the device capabilities and frame buffer dimensions
99 1.1 mrg Read SVGA_REG_CAPABILITIES, SVGA_REG_MAX_WIDTH, SVGA_REG_MAX_HEIGHT,
100 1.1 mrg and SVGA_REG_HOST_BITS_PER_PIXEL / SVGA_REG_BITS_PER_PIXEL.
101 1.1 mrg
102 1.1 mrg Note: The capabilities can and do change without the PCI device ID
103 1.1 mrg changing or the SVGA_REG_ID changing. A driver should always check
104 1.1 mrg the capabilities register when loading before expecting any
105 1.1 mrg capabilities-determined feature to be available. See below for a list
106 1.1 mrg of capabilities as of this writing.
107 1.1 mrg
108 1.1 mrg Note: If SVGA_CAP_8BIT_EMULATION is not set, then it is possible that
109 1.1 mrg SVGA_REG_HOST_BITS_PER_PIXEL does not exist and
110 1.1 mrg SVGA_REG_BITS_PER_PIXEL should be read instead.
111 1.1 mrg
112 1.1 mrg Report the Guest Operating System
113 1.1 mrg Write SVGA_REG_GUEST_ID with the appropriate value from <guest_os.h>.
114 1.1 mrg While not required in any way, this is useful information for the
115 1.1 mrg virtual machine to have available for reporting and sanity checking
116 1.1 mrg purposes.
117 1.1 mrg
118 1.1 mrg SetMode
119 1.1 mrg Set SVGA_REG_WIDTH, SVGA_REG_HEIGHT, SVGA_REG_BITS_PER_PIXEL
120 1.1 mrg Read SVGA_REG_FB_OFFSET
121 1.1 mrg (SVGA_REG_FB_OFFSET is the offset from SVGA_REG_FB_START of the
122 1.1 mrg visible portion of the frame buffer)
123 1.1 mrg Read SVGA_REG_BYTES_PER_LINE, SVGA_REG_DEPTH, SVGA_REG_PSEUDOCOLOR,
124 1.1 mrg SVGA_REG_RED_MASK, SVGA_REG_GREEN_MASK, SVGA_REG_BLUE_MASK
125 1.1 mrg
126 1.1 mrg Note: SVGA_REG_BITS_PER_PIXEL is readonly if
127 1.1 mrg SVGA_CAP_8BIT_EMULATION is not set in the capabilities register. Even
128 1.1 mrg if it is set, values other than 8 and SVGA_REG_HOST_BITS_PER_PIXEL
129 1.1 mrg will be ignored.
130 1.1 mrg
131 1.1 mrg Enable SVGA
132 1.1 mrg Set SVGA_REG_ENABLE to 1
133 1.1 mrg (to disable SVGA, set SVGA_REG_ENABLE to 0. Setting SVGA_REG_ENABLE
134 1.1 mrg to 0 also enables VGA.)
135 1.1 mrg
136 1.1 mrg Initialize the command FIFO
137 1.1 mrg The FIFO is exclusively dword (32-bit) aligned. The first four
138 1.1 mrg dwords define the portion of the MEM area that is used for the
139 1.1 mrg command FIFO. These are values are all in byte offsets from the
140 1.1 mrg start of the MEM area.
141 1.1 mrg
142 1.1 mrg A minimum sized FIFO would have these values:
143 1.1 mrg mem[SVGA_FIFO_MIN] = 16;
144 1.1 mrg mem[SVGA_FIFO_MAX] = 16 + (10 * 1024);
145 1.1 mrg mem[SVGA_FIFO_NEXT_CMD] = 16;
146 1.1 mrg mem[SVGA_FIFO_STOP] = 16;
147 1.1 mrg
148 1.1 mrg Set SVGA_REG_CONFIG_DONE to 1 after these values have been set.
149 1.1 mrg
150 1.1 mrg Note: Setting SVGA_REG_CONFIG_DONE to 0 will stop the device from
151 1.1 mrg reading the FIFO until it is reinitialized and SVGA_REG_CONFIG_DONE is
152 1.1 mrg set to 1 again.
153 1.1 mrg
154 1.1 mrg 3. SVGA command FIFO protocol
155 1.1 mrg The FIFO is empty when SVGA_FIFO_NEXT_CMD == SVGA_FIFO_STOP. The
156 1.1 mrg driver writes commands to the FIFO starting at the offset specified
157 1.1 mrg by SVGA_FIFO_NEXT_CMD, and then increments SVGA_FIFO_NEXT_CMD.
158 1.1 mrg
159 1.1 mrg The FIFO is full when SVGA_FIFO_NEXT_CMD is one word before SVGA_FIFO_STOP.
160 1.1 mrg
161 1.1 mrg When the FIFO becomes full, the FIFO should be sync'd
162 1.1 mrg
163 1.1 mrg To sync the FIFO
164 1.1 mrg Write SVGA_REG_SYNC
165 1.1 mrg Read SVGA_REG_BUSY
166 1.1 mrg Wait for the value in SVGA_REG_BUSY to be 0
167 1.1 mrg
168 1.1 mrg The FIFO should be sync'd before the driver touches the frame buffer, to
169 1.1 mrg guarantee that any outstanding BLT's are completed.
170 1.1 mrg
171 1.1 mrg 4. Cursor
172 1.1 mrg When SVGA_CAP_CURSOR is set, hardware cursor support is available. In
173 1.1 mrg practice, SVGA_CAP_CURSOR will only be set when SVGA_CAP_CURSOR_BYPASS is
174 1.1 mrg also set and drivers supporting a hardware cursor should only worry about
175 1.1 mrg SVGA_CAP_CURSOR_BYPASS and only use the FIFO to define the cursor. See
176 1.1 mrg below for more information.
177 1.1 mrg
178 1.1 mrg 5. Pseudocolor
179 1.1 mrg When the read-only register SVGA_REG_PSEUDOCOLOR is 1, the device is in a
180 1.1 mrg colormapped mode whose index width and color width are both SVGA_REG_DEPTH.
181 1.1 mrg Thus far, 8 is the only depth at which pseudocolor is ever used.
182 1.1 mrg
183 1.1 mrg In pseudocolor, the colormap is programmed by writing to the SVGA palette
184 1.1 mrg registers. These start at SVGA_PALETTE_BASE and are interpreted as
185 1.1 mrg follows:
186 1.1 mrg
187 1.1 mrg SVGA_PALETTE_BASE + 3*n - The nth red component
188 1.1 mrg SVGA_PALETTE_BASE + 3*n + 1 - The nth green component
189 1.1 mrg SVGA_PALETTE_BASE + 3*n + 2 - The nth blue component
190 1.1 mrg
191 1.1 mrg And n ranges from 0 to ((1<<SVGA_REG_DEPTH) - 1).
192 1.1 mrg
193 1.1 mrg
194 1.1 mrg Drawing to the Screen
195 1.1 mrg ---------------------
196 1.1 mrg
197 1.1 mrg After initialization, the driver can write directly to the frame buffer. The
198 1.1 mrg updated frame buffer is not displayed immediately, but only when an update
199 1.1 mrg command is sent. The update command (SVGA_CMD_UPDATE) defines the rectangle
200 1.1 mrg in the frame buffer that has been modified by the driver, and causes that
201 1.1 mrg rectangle to be updated on the screen.
202 1.1 mrg
203 1.1 mrg A complete driver can be developed this way. For increased performance,
204 1.1 mrg additional commands are available to accelerate common operations. The two
205 1.1 mrg most useful are SVGA_CMD_RECT_FILL and SVGA_CMD_RECT_COPY.
206 1.1 mrg
207 1.1 mrg After issuing an accelerated command, the FIFO should be sync'd, as described
208 1.1 mrg above, before writing to the frame buffer.
209 1.1 mrg
210 1.1 mrg Addendum on 7/11/2000
211 1.1 mrg ---------------------
212 1.1 mrg
213 1.1 mrg SVGA_REG_FB_OFFSET and SVGA_REG_BYTES_PER_LINE may change after SVGA_REG_WIDTH
214 1.1 mrg or SVGA_REG_HEIGHT is set. Also the VGA registers must be written to after
215 1.1 mrg setting SVGA_REG_ENABLE to 0 to change the display to a VGA mode.
216 1.1 mrg
217 1.1 mrg Addendum on 11/29/2001
218 1.1 mrg ---------------------
219 1.1 mrg
220 1.1 mrg Actually, after changing any of SVGA_REG_WIDTH, SVGA_REG_HEIGHT, and
221 1.1 mrg SVGA_REG_BITS_PER_PIXEL, all of the registers listed in the 'SetMode'
222 1.1 mrg initialization section above should be reread. Additionally, when changing
223 1.1 mrg modes, it can be convenient to set SVGA_REG_ENABLE to 0, change
224 1.1 mrg SVGA_REG_WIDTH, SVGA_REG_HEIGHT, and SVGA_REG_BITS_PER_PIXEL (if available),
225 1.1 mrg and then set SVGA_REG_ENABLE to 1 again.
226 1.1 mrg
227 1.1 mrg
228 1.1 mrg Capabilities
229 1.1 mrg ------------
230 1.1 mrg
231 1.1 mrg The capabilities register (SVGA_REG_CAPABILITIES) is an array of bits that
232 1.1 mrg indicates the capabilities of the SVGA emulation. A driver should check
233 1.1 mrg SVGA_REG_CAPABILITIES every time it loads before relying on any feature that
234 1.1 mrg is only optionally available.
235 1.1 mrg
236 1.1 mrg Some of the capabilities determine which FIFO commands are available. This
237 1.1 mrg table shows which capability indicates support for which command.
238 1.1 mrg
239 1.1 mrg FIFO Command Capability
240 1.1 mrg ------------ ----------
241 1.1 mrg
242 1.1 mrg SVGA_CMD_RECT_FILL SVGA_CAP_RECT_FILL
243 1.1 mrg SVGA_CMD_RECT_COPY SVGA_CAP_RECT_COPY
244 1.1 mrg SVGA_CMD_DEFINE_BITMAP SVGA_CAP_OFFSCREEN
245 1.1 mrg SVGA_CMD_DEFINE_BITMAP_SCANLINE SVGA_CAP_OFFSCREEN
246 1.1 mrg SVGA_CMD_DEFINE_PIXMAP SVGA_CAP_OFFSCREEN
247 1.1 mrg SVGA_CMD_DEFINE_PIXMAP_SCANLINE SVGA_CAP_OFFSCREEN
248 1.1 mrg SVGA_CMD_RECT_BITMAP_FILL SVGA_CAP_RECT_PAT_FILL
249 1.1 mrg SVGA_CMD_RECT_PIXMAP_FILL SVGA_CAP_RECT_PAT_FILL
250 1.1 mrg SVGA_CMD_RECT_BITMAP_COPY SVGA_CAP_RECT_PAT_FILL
251 1.1 mrg SVGA_CMD_RECT_PIXMAP_COPY SVGA_CAP_RECT_PAT_FILL
252 1.1 mrg SVGA_CMD_FREE_OBJECT SVGA_CAP_OFFSCREEN
253 1.1 mrg SVGA_CMD_RECT_ROP_FILL SVGA_CAP_RECT_FILL +
254 1.1 mrg SVGA_CAP_RASTER_OP
255 1.1 mrg SVGA_CMD_RECT_ROP_COPY SVGA_CAP_RECT_COPY +
256 1.1 mrg SVGA_CAP_RASTER_OP
257 1.1 mrg SVGA_CMD_RECT_ROP_BITMAP_FILL SVGA_CAP_RECT_PAT_FILL +
258 1.1 mrg SVGA_CAP_RASTER_OP
259 1.1 mrg SVGA_CMD_RECT_ROP_PIXMAP_FILL SVGA_CAP_RECT_PAT_FILL +
260 1.1 mrg SVGA_CAP_RASTER_OP
261 1.1 mrg SVGA_CMD_RECT_ROP_BITMAP_COPY SVGA_CAP_RECT_PAT_FILL +
262 1.1 mrg SVGA_CAP_RASTER_OP
263 1.1 mrg SVGA_CMD_RECT_ROP_PIXMAP_COPY SVGA_CAP_RECT_PAT_FILL +
264 1.1 mrg SVGA_CAP_RASTER_OP
265 1.1 mrg SVGA_CMD_DEFINE_CURSOR SVGA_CAP_CURSOR
266 1.1 mrg SVGA_CMD_DISPLAY_CURSOR SVGA_CAP_CURSOR
267 1.1 mrg SVGA_CMD_MOVE_CURSOR SVGA_CAP_CURSOR
268 1.1 mrg SVGA_CMD_DEFINE_ALPHA_CURSOR SVGA_CAP_ALPHA_CURSOR
269 1.1 mrg SVGA_CMD_DRAW_GLYPH SVGA_CAP_GLYPH
270 1.1 mrg SVGA_CMD_DRAW_GLYPH_CLIPPED SVGA_CAP_GLYPH_CLIPPING
271 1.1 mrg SVGA_CMD_ESCAPE SVGA_FIFO_CAP_ESCAPE
272 1.1 mrg
273 1.1 mrg Note: SVGA_CMD_DISPLAY_CURSOR and SVGA_CMD_MOVE_CURSOR should not be used.
274 1.1 mrg Drivers wishing hardware cursor support should use cursor bypass (see below).
275 1.1 mrg
276 1.1 mrg Other capabilities indicate other functionality as described below:
277 1.1 mrg
278 1.1 mrg SVGA_CAP_CURSOR_BYPASS
279 1.1 mrg The hardware cursor can be drawn via SVGA Registers (without requiring
280 1.1 mrg the FIFO be synchronized and will be drawn potentially before any
281 1.1 mrg outstanding unprocessed FIFO commands).
282 1.1 mrg
283 1.1 mrg Note: Without SVGA_CAP_CURSOR_BYPASS_2, cursors drawn this way still
284 1.1 mrg appear in the guest's framebuffer and need to be turned off before any
285 1.1 mrg save under / overlapping drawing and turned back on after. This can
286 1.1 mrg cause very noticeable cursor flicker.
287 1.1 mrg
288 1.1 mrg SVGA_CAP_CURSOR_BYPASS_2
289 1.1 mrg Instead of turning the cursor off and back on around any overlapping
290 1.1 mrg drawing, the driver can write SVGA_CURSOR_ON_REMOVE_FROM_FB and
291 1.1 mrg SVGA_CURSOR_ON_RESTORE_TO_FB to SVGA_REG_CURSOR_ON. In almost all
292 1.1 mrg cases these are NOPs and the cursor will be remain visible without
293 1.1 mrg appearing in the guest framebuffer. In 'direct graphics' modes like
294 1.1 mrg Linux host fullscreen local displays, however, the cursor will still
295 1.1 mrg be drawn in the framebuffer, still flicker, and be drawn incorrectly
296 1.1 mrg if a driver does not use SVGA_CURSOR_ON_REMOVE_FROM_FB / RESTORE_TO_FB.
297 1.1 mrg
298 1.1 mrg SVGA_CAP_8BIT_EMULATION
299 1.1 mrg SVGA_REG_BITS_PER_PIXEL is writable and can be set to either 8 or
300 1.1 mrg SVGA_REG_HOST_BITS_PER_PIXEL. Otherwise the only SVGA modes available
301 1.1 mrg inside a virtual machine must match the host's bits per pixel.
302 1.1 mrg
303 1.1 mrg Note: Some versions which lack SVGA_CAP_8BIT_EMULATION also lack the
304 1.1 mrg SVGA_REG_HOST_BITS_PER_PIXEL and a driver should assume
305 1.1 mrg SVGA_REG_BITS_PER_PIXEL is both read-only and initialized to the only
306 1.1 mrg available value if SVGA_CAP_8BIT_EMULATION is not set.
307 1.1 mrg
308 1.1 mrg SVGA_CAP_OFFSCREEN_1
309 1.1 mrg SVGA_CMD_RECT_FILL, SVGA_CMD_RECT_COPY, SVGA_CMD_RECT_ROP_FILL,
310 1.1 mrg SVGA_CMD_RECT_ROP_COPY can operate with a source or destination (or
311 1.1 mrg both) in offscreen memory.
312 1.1 mrg
313 1.1 mrg Usable offscreen memory is a rectangle located below the last scanline
314 1.1 mrg of the visible memory:
315 1.1 mrg x1 = 0
316 1.1 mrg y1 = (SVGA_REG_FB_SIZE + SVGA_REG_BYTES_PER_LINE - 1) /
317 1.1 mrg SVGA_REG_BYTES_PER_LINE
318 1.1 mrg x2 = SVGA_REG_BYTES_PER_LINE / SVGA_REG_DEPTH
319 1.1 mrg y2 = SVGA_REG_VRAM_SIZE / SVGA_REG_BYTES_PER_LINE
320 1.1 mrg
321 1.1 mrg
322 1.1 mrg Cursor Handling
323 1.1 mrg ---------------
324 1.1 mrg
325 1.1 mrg Starting with GSX Server Beta 3 (after 11/15/2000), hardware cursor support
326 1.1 mrg was added. Actually, both a hardware cursor via the FIFO (SVGA_CAP_CURSOR)
327 1.1 mrg and a hardware cursor via the SVGA registers (SVGA_CAP_CURSOR_BYPASS) were
328 1.1 mrg added. SVGA_CAP_CURSOR was never available without SVGA_CAP_CURSOR_BYPASS and
329 1.1 mrg the FIFO hardware cursor should never be used and may be removed without
330 1.1 mrg warning in the future.
331 1.1 mrg
332 1.1 mrg Cursor bypass is programmed using the two FIFO commands SVGA_CMD_DEFINE_CURSOR
333 1.1 mrg and SVGA_CMD_DEFINE_ALPHA_CURSOR in conjunction with the SVGA registers
334 1.1 mrg SVGA_REG_CURSOR_ID, SVGA_REG_CURSOR_X, SVGA_REG_CURSOR_Y, and
335 1.1 mrg SVGA_REG_CURSOR_ON.
336 1.1 mrg
337 1.1 mrg A driver defines an AND/XOR hardware cursor using SVGA_CMD_DEFINE_CURSOR to
338 1.1 mrg assign an ID and establish the AND and XOR masks with the hardware. A driver
339 1.1 mrg uses SVGA_CMD_DEFINE_ALPHA_CURSOR to define a 32 bit mask whose top 8 bits are
340 1.1 mrg used to blend the cursor image with the pixels it covers. Alpha cursor
341 1.1 mrg support is only available when SVGA_CAP_ALPHA_CURSOR is set.
342 1.1 mrg
343 1.1 mrg Once a cursor is defined, a driver can draw it to the screen at any time by
344 1.1 mrg writing the SVGA_REG_CURSOR_ID register with the ID used when the cursor was
345 1.1 mrg defined, writing SVGA_REG_CURSOR_X and SVGA_REG_CURSOR_Y with the location of
346 1.1 mrg the cursor, and SVGA_CURSOR_ON_SHOW to SVGA_REG_CURSOR_ON. The drawing occurs
347 1.1 mrg when SVGA_REG_CURSOR_ON is written.
348 1.1 mrg
349 1.1 mrg Writing SVGA_CURSOR_ON_HIDE to SVGA_REG_CURSOR_ON will turn the cursor off and
350 1.1 mrg make it vanish from the display and, if present, from the framebuffer.
351 1.1 mrg SVGA_CURSOR_ON_REMOVE_FROM_FB will ensure the cursor is not in the
352 1.1 mrg framebuffer, but will only turn it off if there's no other way to remove it.
353 1.1 mrg SVGA_CURSOR_ON_RESTORE_TO_FB is the complement to
354 1.1 mrg SVGA_CURSOR_ON_REMOVE_FROM_FB. Whenever possible, the device will not put the
355 1.1 mrg cursor in the framebuffer and Remove From / Restore To will be NOPs.
356 1.1 mrg
357 1.1 mrg Note: The cursor must be out of the frame buffer before the driver (or any
358 1.1 mrg agent in the virtual machine) touches an overlapping portion of the frame
359 1.1 mrg buffer, because it is actually drawn into the frame buffer memory in the
360 1.1 mrg case of direct graphics mode (e.g. full screen mode on Linux). The cursor
361 1.1 mrg does not have to be touched before issuing an accelerated command via the
362 1.1 mrg command FIFO, this case is handled by the SVGA device.
363 1.1 mrg
364 1.1 mrg Note: If SVGA_CAP_CURSOR_BYPASS2 is not present, the driver must use
365 1.1 mrg SVGA_CURSOR_ON_HIDE and SVGA_CURSOR_ON_HIDE to be certain the cursor is out of
366 1.1 mrg the framebuffer.
367 1.1 mrg
368 1.1 mrg
369 1.1 mrg Driver Version Numbers
370 1.1 mrg ----------------------
371 1.1 mrg
372 1.1 mrg The SVGA drivers use the following convention for their version numbers:
373 1.1 mrg
374 1.1 mrg Version 10.0 - The first version that uses the FIFO
375 1.1 mrg Version 10.1 - The version that uses the hardware cursor emulation via the FIFO
376 1.1 mrg Version 10.2 - The version that uses the cursor that bypasses the FIFO
377 1.1 mrg Version 10.3 - The version that can also support the 0405 chipset
378 1.1 mrg Version 10.4 - The version that knows about SVGA_CAP_CURSOR_BYPASS2
379 1.1 mrg Version 10.5 - [Never released or well defined]
380 1.1 mrg Version 10.6 - The version that knows about SVGA_CAP_8BIT_EMULATION
381 1.1 mrg Version 10.7 - The version that knows about SVGA_CAP_ALPHA_CURSOR
382 1.1 mrg Version 10.8 - The version that knows about SVGA_CAP_GLYPH
383 1.1 mrg Version 10.9 - The version that knows about SVGA_CAP_OFFSCREEN_1
384 1.1 mrg
385 1.1 mrg Note that this is merely the convention used by SVGA drivers written and
386 1.1 mrg maintained by VMware, Inc. and describes the capabilities of the driver, not
387 1.1 mrg the virtual hardware. An SVGA driver can only use the intersection of the
388 1.1 mrg functionality it supports and the functionality available in the virtual SVGA
389 1.1 mrg hardware.
390 1.1 mrg
391 1.1 mrg
392 1.1 mrg Frequently Asked Questions
393 1.1 mrg --------------------------
394 1.1 mrg
395 1.1 mrg 1. My driver doesn't display anything, what's going on?
396 1.1 mrg
397 1.1 mrg First check if you are issuing an SVGA_CMD_UPDATE after drawing to
398 1.1 mrg the screen. Another check you can do is to run your driver in full
399 1.1 mrg screen mode on a Linux host. In this case you are drawing directly
400 1.1 mrg on the frame buffer, so what you draw to the screen will be immediately
401 1.1 mrg visible. If nothing is visible in this case, then most likely your
402 1.1 mrg driver hasn't mapped the frame buffer correctly.
403 1.1 mrg
404 1.1 mrg A discrepancy between what you get in full screen mode and what you
405 1.1 mrg get in window mode indicates that you have a missing or incorrect
406 1.1 mrg update command.
407 1.1 mrg
408 1.1 mrg
409 1.1 mrg 2. What's the difference between bitmaps and pixmaps?
410 1.1 mrg
411 1.1 mrg Pixmaps have the same depth as the screen, while bitmaps have depth one.
412 1.1 mrg When a bitmap is drawn, the command also takes two colors, foreground and
413 1.1 mrg background. The set bits in the bitmap are replaced with the foreground
414 1.1 mrg color, and the unset bits are replaced with the background color.
415 1.1 mrg
416 1.1 mrg Pixmaps, on the other hand, can be directly copied to the screen.
417 1.1 mrg
418 1.1 mrg
419 1.1 mrg 3. What's the significance of the ROP in the commands SVGA_CMD_RECT_ROP_FILL,
420 1.1 mrg SVGA_CMD_RECT_ROP_BITMAP_COPY, etc. ?
421 1.1 mrg
422 1.1 mrg The ROP in the ...ROP... commands is a raster operation. It has the same
423 1.1 mrg significance (and encoding) as it does in X. The ROP value SVGA_ROP_COPY
424 1.1 mrg means the source is copied to the destination, which makes these commands the
425 1.1 mrg same as their non-ROP counterparts. The most commonly used raster operation
426 1.1 mrg other than copy is probably SVGA_ROP_XOR, which combines the source and
427 1.1 mrg destination using exclusive-or.
428 1.1 mrg
429 1.1 mrg
430 1.1 mrg 4. Tell me more about bitmaps and pixmaps. For example, the macro
431 1.1 mrg SVGA_CMD_DEFINE_BITMAP has a field <scanlines>. What should this be
432 1.1 mrg set to? Likewise with SVGA_CMD_DEFINE_PIXMAP. And when should the
433 1.1 mrg SCANLINE macros be used?
434 1.1 mrg
435 1.1 mrg OK, I'll use pixmaps as an example. First you have to define the pixmap:
436 1.1 mrg
437 1.1 mrg #define SVGA_CMD_DEFINE_PIXMAP 6
438 1.1 mrg /* FIFO layout:
439 1.1 mrg Pixmap ID, Width, Height, Depth, <scanlines> */
440 1.1 mrg
441 1.1 mrg The ID is something you choose, which you subsequently use to refer to
442 1.1 mrg this pixmap. It must be an integer between 0 and SVGA_MAX_ID.
443 1.1 mrg
444 1.1 mrg The width and height and depth are the dimensions of the pixmap. For now,
445 1.1 mrg the depth of the pixmap has to match the depth of the screen.
446 1.1 mrg
447 1.1 mrg The scanlines are the pixels that make up the pixmap, arranged one row
448 1.1 mrg at a time. Each row is required to be 32-bit aligned. The macros
449 1.1 mrg SVGA_PIXMAP_SCANLINE_SIZE and SVGA_PIXMAP_SIZE give the size of a
450 1.1 mrg single scanline, and the size of the entire pixmap, respectively, in
451 1.1 mrg 32-bit words.
452 1.1 mrg
453 1.1 mrg The second step is to use it:
454 1.1 mrg
455 1.1 mrg #define SVGA_CMD_RECT_PIXMAP_FILL 9
456 1.1 mrg /* FIFO layout:
457 1.1 mrg Pixmap ID, X, Y, Width, Height */
458 1.1 mrg
459 1.1 mrg The ID here is the one you chose when defining the pixmap. X, Y,
460 1.1 mrg Width, and Height define a rectangle on the screen that is to be filled
461 1.1 mrg with the pixmap. The pixmap is screen aligned, which means that the
462 1.1 mrg coordinates in the pixmap are defined by the screen coordinates modulo
463 1.1 mrg the pixmap dimensions.
464 1.1 mrg
465 1.1 mrg If you want a different alignment between the screen and the pixmap,
466 1.1 mrg then you can use this command, which allows the pixmap coordinates to
467 1.1 mrg be defined:
468 1.1 mrg
469 1.1 mrg #define SVGA_CMD_RECT_PIXMAP_COPY 11
470 1.1 mrg /* FIFO layout:
471 1.1 mrg Pixmap ID, Source X, Source Y, Dest X, Dest Y, Width,
472 1.1 mrg Height */
473 1.1 mrg
474 1.1 mrg The Source X and Source Y are pixmap coordinates, and the Dest X and
475 1.1 mrg Dest Y are screen coordinates.
476 1.1 mrg
477 1.1 mrg
478 1.1 mrg 5. OK, now it works briefly, then stops displaying anything. Also,
479 1.1 mrg my log file is filled with lines like:
480 1.1 mrg Unknown Command 0xff in SVGA command FIFO
481 1.1 mrg What's happening?
482 1.1 mrg
483 1.1 mrg The most common problem at this point is that the FIFO gets out
484 1.1 mrg of sync. This can happen if the amount of data in the FIFO doesn't
485 1.1 mrg match what the VMware SVGA device expects. To track this down, try
486 1.1 mrg to isolate the particular command which causes the problem.
487 1.1 mrg
488 1.1 mrg Another way this can happen is if the wraparound in the FIFO isn't
489 1.1 mrg done correctly. Here is some example code for writing to the FIFO
490 1.1 mrg (mem is an array of 32-bit integers that points to the FIFO memory
491 1.1 mrg region):
492 1.1 mrg
493 1.1 mrg while (TRUE) {
494 1.1 mrg fifo_min = mem[SVGA_FIFO_MIN] / 4;
495 1.1 mrg fifo_max = mem[SVGA_FIFO_MAX] / 4;
496 1.1 mrg fifo_next = mem[SVGA_FIFO_NEXT_CMD] / 4;
497 1.1 mrg fifo_stop = mem[SVGA_FIFO_STOP] / 4;
498 1.1 mrg
499 1.1 mrg tmp_next = fifo_next+1;
500 1.1 mrg if (tmp_next == fifo_max)
501 1.1 mrg tmp_next = fifo_min; // Wraparound
502 1.1 mrg
503 1.1 mrg if (tmp_next == fifo_stop) {
504 1.1 mrg sync_fifo(); // FIFO full
505 1.1 mrg continue; // retry
506 1.1 mrg }
507 1.1 mrg
508 1.1 mrg mem[fifo_next] = item;
509 1.1 mrg mem[SVGA_FIFO_NEXT_CMD] = tmp_next * 4;
510 1.1 mrg break;
511 1.1 mrg }
512 1.1 mrg
513 1.1 mrg This isn't the most efficient code, but it should work. It's important
514 1.1 mrg to do the increment with wraparound before the FIFO full check, and to
515 1.1 mrg check FIFO full before updating the next command pointer.
516 1.1 mrg
517 1.1 mrg
518 1.1 mrg 6. My driver tries to switch modes and either nothing happens or the
519 1.1 mrg display becomes completely garbled. What's going on?
520 1.1 mrg
521 1.1 mrg When you change modes, make very sure you reread all of the registers listed
522 1.1 mrg above under SetMode. Getting the pitch (SVGA_REG_BYTES_PER_LINE) incorrect
523 1.1 mrg will cause a heavily garbled display. Also, if you change
524 1.1 mrg SVGA_REG_BITS_PER_PIXEL, make certain that SVGA_CAP_8BIT_EMULATION is present
525 1.1 mrg in the SVGA_REG_CAPABILITIES register. Also, even with 8 bit emulation, the
526 1.1 mrg driver must still use either 8 bpp or SVGA_REG_HOST_BITS_PER_PIXEL bpp,
527 1.1 mrg nothing else.
528 1.1 mrg
529 1.1 mrg
530 1.1 mrg 7. Why does my driver's hardware cursor work when my virtual machine is in
531 1.1 mrg window mode, but draw/erase incorrectly or in garbled locations in fullscreen
532 1.1 mrg mode?
533 1.1 mrg
534 1.1 mrg You need to make sure you use SVGA_CURSOR_ON_REMOVE_FROM_FB and
535 1.1 mrg SVGA_CURSOR_ON_RESTORE_TO_FB _every_ time your driver or the virtual machine
536 1.1 mrg touches a region of the framebuffer that overlaps the cursor. If you forget
537 1.1 mrg to remove it then it can show up when doing save-under operations or get mixed
538 1.1 mrg in with other drawing. If you forget to restore it then can disappear. You
539 1.1 mrg also need to make sure SVGA_CAP_CURSOR_BYPASS2 is available, or else you will
540 1.1 mrg have to use SVGA_CURSOR_ON_SHOW and SVGA_CURSOR_ON_HIDE (which will flicker,
541 1.1 mrg even in window mode), or else a software cursor. Newer version of the virtual
542 1.1 mrg SVGA hardware will never put the hardware cursor in the framebuffer while in
543 1.1 mrg window mode, so everything will appear to work correctly there.
544 1.1 mrg
545 1.1 mrg
546 1.1 mrg 8. Why do my accelerated glyphs look funny? OR Why does the fifo complain
547 1.1 mrg about invalid commands when I draw accelerated glyphs?
548 1.1 mrg
549 1.1 mrg The bitmap data passed to SVGA_CMD_DRAW_GLYPH_* must not have any per-scanline
550 1.1 mrg alignment. If there are any remaining bits left in the last byte of a scanline,
551 1.1 mrg the first bits of the next scanline should use them.
552 1.1 mrg
553 1.1 mrg The bitmap data as a whole must be 4 byte aligned.
554 1.1 mrg
555 1.1 mrg $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/README,v 1.5 2002/10/16 22:12:53 alanh Exp $
556