wip update. use unified fifo cmd reserve/bounce buffer between the 2d and 3d parts...
[AROS.git] / workbench / hidds / vmwaresvga / vmwaresvga_hardware.h
blobd0a5c174083f3a0cfd456f1e720e7448d27ffb34
1 #ifndef _VMWARESVGA_HARDWARE_H
2 #define _VMWARESVGA_HARDWARE_H
4 #include <exec/libraries.h>
5 #include <exec/tasks.h>
6 #include <hidd/pci.h>
7 #include <hidd/gfx.h>
8 #include <oop/oop.h>
10 #include "vmwaresvga_bitmap.h"
11 #include "vmwaresvga_mouse.h"
13 #include "svga_reg.h"
14 #define SVGA_LEGACY_BASE_PORT 0x4560
16 #define VENDOR_VMWARE 0x15ad
17 #define DEVICE_VMWARE0710 0x0710
18 #define DEVICE_VMWARE0405 0x0405
21 * Raster op codes (same encoding as X)
24 #define SVGA_ROP_CLEAR 0x00 /* 0 */
25 #define SVGA_ROP_AND 0x01 /* src AND dst */
26 #define SVGA_ROP_AND_REVERSE 0x02 /* src AND NOT dst */
27 #define SVGA_ROP_COPY 0x03 /* src */
28 #define SVGA_ROP_AND_INVERTED 0x04 /* NOT src AND dst */
29 #define SVGA_ROP_NOOP 0x05 /* dst */
30 #define SVGA_ROP_XOR 0x06 /* src XOR dst */
31 #define SVGA_ROP_OR 0x07 /* src OR dst */
32 #define SVGA_ROP_NOR 0x08 /* NOT src AND NOT dst */
33 #define SVGA_ROP_EQUIV 0x09 /* NOT src XOR dst */
34 #define SVGA_ROP_INVERT 0x0a /* NOT dst */
35 #define SVGA_ROP_OR_REVERSE 0x0b /* src OR NOT dst */
36 #define SVGA_ROP_COPY_INVERTED 0x0c /* NOT src */
37 #define SVGA_ROP_OR_INVERTED 0x0d /* NOT src OR dst */
38 #define SVGA_ROP_NAND 0x0e /* NOT src OR NOT dst */
39 #define SVGA_ROP_SET 0x0f /* 1 */
40 #define SVGA_ROP_UNSUPPORTED 0x10
42 #define SVGA_NUM_SUPPORTED_ROPS 16
45 * Commands in the command FIFO
48 #define SVGA_CMD_INVALID_CMD 0
49 /* FIFO layout:
50 <nothing> (well, undefined) */
52 #define SVGA_CMD_UPDATE 1
53 /* FIFO layout:
54 X, Y, Width, Height */
56 #define SVGA_CMD_RECT_FILL 2
57 /* FIFO layout:
58 Color, X, Y, Width, Height */
60 #define SVGA_CMD_RECT_COPY 3
61 /* FIFO layout:
62 Source X, Source Y, Dest X, Dest Y, Width, Height */
64 #define SVGA_CMD_DEFINE_BITMAP 4
65 /* FIFO layout:
66 Pixmap ID, Width, Height, <scanlines> */
68 #define SVGA_CMD_DEFINE_BITMAP_SCANLINE 5
69 /* FIFO layout:
70 Pixmap ID, Width, Height, Line #, scanline */
72 #define SVGA_CMD_DEFINE_PIXMAP 6
73 /* FIFO layout:
74 Pixmap ID, Width, Height, Depth, <scanlines> */
76 #define SVGA_CMD_DEFINE_PIXMAP_SCANLINE 7
77 /* FIFO layout:
78 Pixmap ID, Width, Height, Depth, Line #, scanline */
80 #define SVGA_CMD_RECT_BITMAP_FILL 8
81 /* FIFO layout:
82 Bitmap ID, X, Y, Width, Height, Foreground, Background */
84 #define SVGA_CMD_RECT_PIXMAP_FILL 9
85 /* FIFO layout:
86 Pixmap ID, X, Y, Width, Height */
88 #define SVGA_CMD_RECT_BITMAP_COPY 10
89 /* FIFO layout:
90 Bitmap ID, Source X, Source Y, Dest X, Dest Y,
91 Width, Height, Foreground, Background */
93 #define SVGA_CMD_RECT_PIXMAP_COPY 11
94 /* FIFO layout:
95 Pixmap ID, Source X, Source Y, Dest X, Dest Y, Width, Height */
97 #define SVGA_CMD_FREE_OBJECT 12
98 /* FIFO layout:
99 Object (pixmap, bitmap, ...) ID */
101 #define SVGA_CMD_RECT_ROP_FILL 13
102 /* FIFO layout:
103 Color, X, Y, Width, Height, ROP */
105 #define SVGA_CMD_RECT_ROP_COPY 14
106 /* FIFO layout:
107 Source X, Source Y, Dest X, Dest Y, Width, Height, ROP */
109 #define SVGA_CMD_RECT_ROP_BITMAP_FILL 15
110 /* FIFO layout:
111 ID, X, Y, Width, Height, Foreground, Background, ROP */
113 #define SVGA_CMD_RECT_ROP_PIXMAP_FILL 16
114 /* FIFO layout:
115 ID, X, Y, Width, Height, ROP */
117 #define SVGA_CMD_RECT_ROP_BITMAP_COPY 17
118 /* FIFO layout:
119 ID, Source X, Source Y,
120 Dest X, Dest Y, Width, Height, Foreground, Background, ROP */
122 #define SVGA_CMD_RECT_ROP_PIXMAP_COPY 18
123 /* FIFO layout:
124 ID, Source X, Source Y, Dest X, Dest Y, Width, Height, ROP */
126 #define SVGA_CMD_DEFINE_CURSOR 19
127 /* FIFO layout:
128 ID, Hotspot X, Hotspot Y, Width, Height,
129 Depth for AND mask, Depth for XOR mask,
130 <scanlines for AND mask>, <scanlines for XOR mask> */
132 #define SVGA_CMD_DISPLAY_CURSOR 20
133 /* FIFO layout:
134 ID, On/Off (1 or 0) */
136 #define SVGA_CMD_MOVE_CURSOR 21
137 /* FIFO layout:
138 X, Y */
140 #define SVGA_CMD_DEFINE_ALPHA_CURSOR 22
141 /* FIFO layout:
142 ID, Hotspot X, Hotspot Y, Width, Height,
143 <scanlines> */
145 #define SVGA_CMD_DRAW_GLYPH 23
146 /* FIFO layout:
147 X, Y, W, H, FGCOLOR, <stencil buffer> */
149 #define SVGA_CMD_DRAW_GLYPH_CLIPPED 24
150 /* FIFO layout:
151 X, Y, W, H, FGCOLOR, BGCOLOR, <cliprect>, <stencil buffer>
152 Transparent color expands are done by setting BGCOLOR to ~0 */
154 #define SVGA_CMD_UPDATE_VERBOSE 25
155 /* FIFO layout:
156 X, Y, Width, Height, Reason */
158 #define SVGA_CMD_SURFACE_FILL 26
159 /* FIFO layout:
160 color, dstSurfaceOffset, x, y, w, h, rop */
162 #define SVGA_CMD_SURFACE_COPY 27
163 /* FIFO layout:
164 srcSurfaceOffset, dstSurfaceOffset, srcX, srcY,
165 destX, destY, w, h, rop */
167 #define SVGA_CMD_SURFACE_ALPHA_BLEND 28
168 /* FIFO layout:
169 srcSurfaceOffset, dstSurfaceOffset, srcX, srcY,
170 destX, destY, w, h, op (SVGA_BLENDOP*), flags (SVGA_BLENDFLAGS*),
171 param1, param2 */
173 #define SVGA_CMD_FRONT_ROP_FILL 29
174 /* FIFO layout:
175 Color, X, Y, Width, Height, ROP */
177 #define SVGA_CMD_FENCE 30
178 /* FIFO layout:
179 Fence value */
182 * Capabilities
185 #define SVGA_CAP_RECT_FILL 0x00001
186 #define SVGA_CAP_RECT_PAT_FILL 0x00004
187 #define SVGA_CAP_LEGACY_OFFSCREEN 0x00008
188 #define SVGA_CAP_RASTER_OP 0x00010
189 #define SVGA_CAP_GLYPH 0x00400
190 #define SVGA_CAP_GLYPH_CLIPPING 0x00800
191 #define SVGA_CAP_OFFSCREEN_1 0x01000
192 #define SVGA_CAP_ALPHA_BLEND 0x02000
194 struct VMWareSVGAFIFO {
195 struct SignalSemaphore fifocmdsema;
196 UBYTE *buffer;
197 ULONG size;
198 ULONG used;
199 ULONG reserved;
202 struct HWData {
203 APTR iobase;
204 APTR vrambase;
205 APTR mmiobase;
206 ULONG vramsize;
207 ULONG mmiosize;
209 UWORD indexReg;
210 UWORD valueReg;
212 struct VMWareSVGAFIFO fifocmdbuf;
213 ULONG bbused;
215 ULONG capabilities;
216 ULONG fifocapabilities;
218 struct HIDD_ViewPortData *shown;
220 ULONG depth;
221 ULONG redmask;
222 ULONG greenmask;
223 ULONG bluemask;
224 ULONG redshift;
225 ULONG greenshift;
226 ULONG blueshift;
227 ULONG bytesperpixel;
228 ULONG bitsperpixel;
229 ULONG bytesperline;
231 ULONG maxwidth;
232 ULONG maxheight;
233 ULONG displaycount;
235 ULONG fboffset; /* last byte in framebuffer of current screen mode */
236 ULONG pseudocolor;
238 UWORD display_width;
239 UWORD display_height;
240 ULONG bytes_per_line;
242 ULONG txrmax; /* max texture size */
244 APTR maskPool;
245 APTR irq;
246 ULONG hwint;
247 ULONG fifomin;
248 ULONG fence;
250 struct Box delta_damage;
251 struct Task *render_task;
252 struct SignalSemaphore damage_control;
255 #define clearCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
256 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_CLEAR)
257 #define andCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
258 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_AND)
259 #define andReverseCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
260 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_AND_REVERSE)
261 #define copyCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
262 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_COPY)
263 #define andInvertedCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
264 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_AND_INVERTED)
265 #define noOpCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
266 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_NOOP)
267 #define xorCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
268 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_XOR)
269 #define orCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
270 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_OR)
271 #define norCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
272 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_NOR)
273 #define equivCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
274 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_EQUIV)
275 #define invertCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
276 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_INVERT)
277 #define orReverseCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
278 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_OR_REVERSE)
279 #define copyInvertedCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
280 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_COPY_INVERTED)
281 #define orInvertedCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
282 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_OR_INVERTED)
283 #define nandCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
284 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_NAND)
285 #define setCopyVMWareSVGA(d, sx, sy, dx, dy, w, h) \
286 ropCopyVMWareSVGA(d, sx, sy, dx, dy, w, h, SVGA_ROP_SET)
288 #define clearFillVMWareSVGA(d, c, x, y, w, h) \
289 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_CLEAR)
290 #define andFillVMWareSVGA(d, c, x, y, w, h) \
291 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_AND)
292 #define andReverseFillVMWareSVGA(d, c, x, y, w, h) \
293 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_AND_REVERSE)
294 #define copyFillVMWareSVGA(d, c, x, y, w, h) \
295 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_COPY)
296 #define andInvertedFillVMWareSVGA(d, c, x, y, w, h) \
297 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_AND_INVERTED)
298 #define noOpFillVMWareSVGA(d, c, x, y, w, h) \
299 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_NOOP)
300 #define xorFillVMWareSVGA(d, c, x, y, w, h) \
301 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_XOR)
302 #define orFillVMWareSVGA(d, c, x, y, w, h) \
303 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_OR)
304 #define norFillVMWareSVGA(d, c, x, y, w, h) \
305 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_NOR)
306 #define equivFillVMWareSVGA(d, c, x, y, w, h) \
307 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_EQUIV)
308 #define invertFillVMWareSVGA(d, c, x, y, w, h) \
309 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_INVERT)
310 #define orReverseFillVMWareSVGA(d, c, x, y, w, h) \
311 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_OR_REVERSE)
312 #define copyInvertedFillVMWareSVGA(d, c, x, y, w, h) \
313 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_COPY_INVERTED)
314 #define orInvertedFillVMWareSVGA(d, c, x, y, w, h) \
315 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_OR_INVERTED)
316 #define nandFillVMWareSVGA(d, c, x, y, w, h) \
317 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_NAND)
318 #define setFillVMWareSVGA(d, c, x, y, w, h) \
319 ropFillVMWareSVGA(d, c, x, y, w, h, SVGA_ROP_SET)
321 ULONG vmwareReadReg(struct HWData *, ULONG);
322 void vmwareWriteReg(struct HWData *, ULONG, ULONG);
324 VOID enableVMWareSVGA(struct HWData *);
325 VOID disableVMWareSVGA(struct HWData *);
327 BOOL initVMWareSVGAHW(struct HWData *, OOP_Object *);
328 VOID initDisplayVMWareSVGA(struct HWData *);
329 VOID getModeCfgVMWareSVGA(struct HWData *);
330 VOID setModeVMWareSVGA(struct HWData *, ULONG, ULONG);
331 VOID refreshAreaVMWareSVGA(struct HWData *, struct Box *);
333 APTR VMWareSVGA_MemAlloc(struct HWData *, ULONG);
334 VOID VMWareSVGA_MemFree(struct HWData *, APTR, ULONG);
336 VOID rectFillVMWareSVGA(struct HWData *, ULONG, LONG, LONG, LONG, LONG);
337 VOID ropFillVMWareSVGA(struct HWData *, ULONG, LONG, LONG, LONG, LONG, ULONG);
338 VOID ropCopyVMWareSVGA(struct HWData *, LONG, LONG, LONG, LONG, ULONG, ULONG, ULONG);
340 VOID defineCursorVMWareSVGA(struct HWData *, struct MouseData *);
341 VOID displayCursorVMWareSVGA(struct HWData *, LONG);
342 VOID moveCursorVMWareSVGA(struct HWData *, LONG, LONG);
344 void waitVMWareSVGAFIFO(struct HWData *);
345 APTR reserveVMWareSVGAFIFO(struct HWData *, ULONG);
346 VOID commitVMWareSVGAFIFO(struct HWData *, ULONG);
347 VOID flushVMWareSVGAFIFO(struct HWData *, ULONG *);
348 VOID writeVMWareSVGAFIFO(struct HWData *, ULONG);
349 VOID syncVMWareSVGAFIFO(struct HWData *);
351 ULONG fenceVMWareSVGAFIFO(struct HWData *);
352 VOID syncfenceVMWareSVGAFIFO(struct HWData *, ULONG);
354 VOID vmwareHandlerIRQ(struct HWData *, void *);
356 VOID VMWareSVGA_Damage_Reset(struct HWData *);
357 VOID VMWareSVGA_Damage_DeltaAdd(struct HWData *, struct Box *);
358 VOID VMWareSVGA_RestartRenderTask(struct HWData *);
360 #endif /* _VMWARESVGA_HARDWARE_H */