2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
5 Desc: Class for VMWare.
13 #include <aros/debug.h>
15 #define __OOP_NOATTRBASES__
17 #include <proto/exec.h>
18 #include <proto/kernel.h>
19 #include <proto/oop.h>
20 #include <proto/utility.h>
22 #include <aros/symbolsets.h>
23 #include <devices/inputevent.h>
24 #include <exec/alerts.h>
25 #include <exec/memory.h>
26 #include <hardware/custom.h>
27 #include <hidd/hidd.h>
30 #include <clib/alib_protos.h>
37 #include "vmwaresvga_intern.h"
39 #include LC_LIBDEFS_FILE
47 static OOP_AttrBase HiddAttrBase
;
48 static OOP_AttrBase HiddBitMapAttrBase
;
49 static OOP_AttrBase HiddPixFmtAttrBase
;
50 static OOP_AttrBase HiddGfxAttrBase
;
51 static OOP_AttrBase HiddSyncAttrBase
;
52 static OOP_AttrBase HiddVMWareSVGAAttrBase
;
53 static OOP_AttrBase HiddVMWareSVGABitMapAttrBase
;
55 static struct OOP_ABDescr attrbases
[] =
57 {IID_Hidd
, &HiddAttrBase
},
58 {IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
59 {IID_Hidd_VMWareSVGABitMap
, &HiddVMWareSVGABitMapAttrBase
},
60 {IID_Hidd_VMWareSVGA
, &HiddVMWareSVGAAttrBase
},
61 {IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
62 {IID_Hidd_Sync
, &HiddSyncAttrBase
},
63 {IID_Hidd_Gfx
, &HiddGfxAttrBase
},
67 static ULONG
mask_to_shift(ULONG mask
)
71 for (i
= 32; mask
; i
--) {
82 static ULONG
VMWareSVGA__GetDefSyncSizes(ULONG syncno
, ULONG
*syncwid
, ULONG
*synchi
)
84 #define VMWARESVGA_DEFSYNCMAX 12
85 switch (syncno
% VMWARESVGA_DEFSYNCMAX
)
136 return (syncno
% VMWARESVGA_DEFSYNCMAX
);
139 OOP_Object
*VMWareSVGA__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
141 struct TagItem pftags
[] =
143 {aHidd_PixFmt_RedShift
, 0 }, /* 0 */
144 {aHidd_PixFmt_GreenShift
, 0 }, /* 1 */
145 {aHidd_PixFmt_BlueShift
, 0 }, /* 2 */
146 {aHidd_PixFmt_AlphaShift
, 0 }, /* 3 */
147 {aHidd_PixFmt_RedMask
, 0 }, /* 4 */
148 {aHidd_PixFmt_GreenMask
, 0 }, /* 5 */
149 {aHidd_PixFmt_BlueMask
, 0 }, /* 6 */
150 {aHidd_PixFmt_AlphaMask
, 0 }, /* 7 */
151 {aHidd_PixFmt_ColorModel
, 0 }, /* 8 */
152 {aHidd_PixFmt_Depth
, 0 }, /* 9 */
153 {aHidd_PixFmt_BytesPerPixel
, 0 }, /* 10 */
154 {aHidd_PixFmt_BitsPerPixel
, 0 }, /* 11 */
155 {aHidd_PixFmt_StdPixFmt
, 0 }, /* 12 */
156 {aHidd_PixFmt_CLUTShift
, 0 }, /* 13 */
157 {aHidd_PixFmt_CLUTMask
, 0x0f }, /* 14 */
158 {aHidd_PixFmt_BitMapType
, 0 }, /* 15 */
161 struct TagItem
*modetags
;
162 ULONG max_width
, max_height
;
163 ULONG sync_Width
, sync_Height
;
164 ULONG sync_count
, sync_modes
, sync_curr
, sync_actual
, sync_displayid
, sync_modeid
;
166 XSD(cl
)->prefWidth
= vmwareReadReg(&XSD(cl
)->data
, SVGA_REG_WIDTH
);
167 XSD(cl
)->prefHeight
= vmwareReadReg(&XSD(cl
)->data
, SVGA_REG_HEIGHT
);
168 DINFO(bug("[VMWareSVGA] %s: Default %dx%d\n", __func__
, XSD(cl
)->prefWidth
, XSD(cl
)->prefHeight
));
170 max_width
= vmwareReadReg(&XSD(cl
)->data
, SVGA_REG_MAX_WIDTH
);
171 max_height
= vmwareReadReg(&XSD(cl
)->data
, SVGA_REG_MAX_HEIGHT
);
172 DINFO(bug("[VMWareSVGA] %s: Max %dx%d\n", __func__
, max_width
, max_height
));
174 DINFO(bug("[VMWareSVGA] %s: counting usable modes ...\n", __func__
);)
175 /* Determine the number of sync modes we will expose (per display if applicable) */
176 sync_count
= VMWARESVGA_DEFSYNCMAX
;
178 while (sync_count
> 0)
180 sync_count
= VMWareSVGA__GetDefSyncSizes(sync_count
- 1, &sync_Width
, &sync_Height
) + 1;
181 DINFO(bug("[VMWareSVGA] %s: #%d ... %dx%d ", __func__
, (VMWARESVGA_DEFSYNCMAX
- sync_count
) + 1, sync_Width
, sync_Height
);)
182 if ((sync_Width
<= max_width
) && (sync_Height
<= max_height
))
184 DINFO(bug("is suitable");)
190 DINFO(bug("[VMWareSVGA] %s: %d usable modes found\n", __func__
, sync_modes
);)
191 sync_count
= sync_modes
;
192 #if defined(VMWARESVGA_USEMULTIMON)
193 sync_count
*= XSD(cl
)->data
.displaycount
;
196 #if defined(VMWARESVGA_USE8BIT)
197 if ((data
->capabilities
& SVGA_CAP_8BIT_EMULATION
) && (XSD(cl
)->data
.depth
> 8))
200 modetags
= AllocVec((sync_count
+ sync_curr
+ 1) * sizeof(struct TagItem
), MEMF_CLEAR
);
201 modetags
[0].ti_Tag
= aHidd_Gfx_PixFmtTags
;
202 modetags
[0].ti_Data
= (IPTR
)pftags
;
203 #if defined(VMWARESVGA_USE8BIT)
204 if ((data
->capabilities
& SVGA_CAP_8BIT_EMULATION
) && (XSD(cl
)->data
.depth
> 8))
210 while (sync_curr
< sync_count
)
212 char *sync_Description
= AllocVec(SYNC_DESCNAME_LEN
, MEMF_CLEAR
);
213 struct TagItem
*sync_mode
= AllocVec(11 * sizeof(struct TagItem
), MEMF_CLEAR
);
215 sync_modeid
= VMWareSVGA__GetDefSyncSizes(sync_curr
, &sync_Width
, &sync_Height
);
216 sync_displayid
= sync_curr
/sync_modes
;
218 DINFO(bug("[VMWareSVGA] %s: Setting Sync Mode %d for Display %d\n", __func__
, sync_modeid
, sync_displayid
));
220 if (sync_displayid
== 0)
222 sprintf(sync_Description
, "VMWareSVGA:%dx%d", sync_Width
, sync_Height
);
226 sprintf(sync_Description
, "VMWareSVGA.%d:%dx%d", sync_displayid
, sync_Width
, sync_Height
);
228 DINFO(bug("[VMWareSVGA] %s: Description '%s'\n", __func__
, sync_Description
));
230 sync_mode
[0].ti_Tag
= aHidd_Sync_Description
;
231 sync_mode
[0].ti_Data
= (IPTR
)sync_Description
;
233 sync_mode
[1].ti_Tag
= aHidd_Sync_PixelClock
;
235 sync_mode
[2].ti_Tag
= aHidd_Sync_HDisp
;
236 sync_mode
[2].ti_Data
= sync_Width
;
238 sync_mode
[3].ti_Tag
= aHidd_Sync_VDisp
;
239 sync_mode
[3].ti_Data
= sync_Height
;
241 sync_mode
[4].ti_Tag
= aHidd_Sync_HSyncStart
;
243 sync_mode
[5].ti_Tag
= aHidd_Sync_HSyncEnd
;
245 sync_mode
[6].ti_Tag
= aHidd_Sync_HTotal
;
247 sync_mode
[7].ti_Tag
= aHidd_Sync_VSyncStart
;
249 sync_mode
[8].ti_Tag
= aHidd_Sync_VSyncEnd
;
251 sync_mode
[9].ti_Tag
= aHidd_Sync_VTotal
;
253 sync_mode
[10].ti_Tag
= TAG_DONE
;
255 modetags
[1 + sync_curr
].ti_Tag
= aHidd_Gfx_SyncTags
;
256 modetags
[1 + sync_curr
].ti_Data
= (IPTR
)sync_mode
;
259 modetags
[1 + sync_curr
].ti_Tag
= TAG_DONE
;
261 struct TagItem svganewtags
[] =
263 {aHidd_Gfx_ModeTags
, (IPTR
)modetags
},
264 { aHidd_Name
, (IPTR
)"VMWareSVGA" },
265 { aHidd_HardwareName
, (IPTR
)"VMWare SVGA Gfx Adaptor" },
266 { aHidd_ProducerName
, (IPTR
)"VMWare Inc" },
267 {TAG_MORE
, (IPTR
)msg
->attrList
}
269 struct pRoot_New svganewmsg
;
272 if (!XSD(cl
)->data
.pseudocolor
)
274 pftags
[0].ti_Data
= mask_to_shift(XSD(cl
)->data
.redmask
);
275 pftags
[1].ti_Data
= mask_to_shift(XSD(cl
)->data
.greenmask
);
276 pftags
[2].ti_Data
= mask_to_shift(XSD(cl
)->data
.bluemask
);
280 pftags
[0].ti_Data
= 0;
281 pftags
[1].ti_Data
= 0;
282 pftags
[2].ti_Data
= 0;
284 pftags
[3].ti_Data
= 0;
285 pftags
[4].ti_Data
= XSD(cl
)->data
.redmask
;
286 pftags
[5].ti_Data
= XSD(cl
)->data
.greenmask
;
287 pftags
[6].ti_Data
= XSD(cl
)->data
.bluemask
;
288 pftags
[7].ti_Data
= 0;
289 DINFO(bug("[VMWareSVGA] New: Masks red=%08x<<%d,green=%08x<<%d,blue%08x<<%d\n",
290 pftags
[4].ti_Data
, pftags
[0].ti_Data
,
291 pftags
[5].ti_Data
, pftags
[1].ti_Data
,
292 pftags
[6].ti_Data
, pftags
[2].ti_Data
));
294 if (XSD(cl
)->data
.pseudocolor
)
295 pftags
[8].ti_Data
= vHidd_ColorModel_Palette
;
297 pftags
[8].ti_Data
= vHidd_ColorModel_TrueColor
;
299 pftags
[9].ti_Data
= XSD(cl
)->data
.depth
;
300 pftags
[10].ti_Data
= XSD(cl
)->data
.bytesperpixel
;
301 pftags
[11].ti_Data
= XSD(cl
)->data
.bitsperpixel
;
302 pftags
[12].ti_Data
= vHidd_StdPixFmt_Native
;
303 pftags
[15].ti_Data
= vHidd_BitMapType_Chunky
;
304 #if defined(VMWARESVGA_USE8BIT)
305 if ((data
->capabilities
& SVGA_CAP_8BIT_EMULATION
) && (XSD(cl
)->data
.depth
> 8))
310 svganewmsg
.mID
= msg
->mID
;
311 svganewmsg
.attrList
= svganewtags
;
313 EnterFunc(bug("[VMWareSVGA] New()\n"));
314 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
317 DINFO(bug("[VMWareSVGA] %s: object @ 0x%p\n", __func__
, o
);)
319 XSD(cl
)->vmwaresvgahidd
= o
;
320 XSD(cl
)->mouse
.shape
= NULL
;
322 bug("[VMWareSVGA] %s: Device capabilities: %08x\n", __func__
, XSD(cl
)->data
.capabilities
);
324 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_IRQMASK
)
326 UWORD port
= (UWORD
)((IPTR
)XSD(cl
)->data
.iobase
+ SVGA_IRQSTATUS_PORT
);
327 DINFO(bug("[VMWareSVGA] %s: IRQ Mask\n", __func__
);)
328 vmwareWriteReg(&XSD(cl
)->data
, SVGA_REG_IRQMASK
, 0);
331 DINFO(bug("[VMWareSVGA] %s: - Registering handler for IRQ #%d\n", __func__
, XSD(cl
)->data
.hwint
);)
332 XSD(cl
)->data
.irq
= KrnAddIRQHandler(XSD(cl
)->data
.hwint
, vmwareHandlerIRQ
, &XSD(cl
)->data
, NULL
);
333 vmwareWriteReg(&XSD(cl
)->data
, SVGA_REG_IRQMASK
, SVGA_IRQFLAG_ERROR
);
336 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_EXTENDED_FIFO
)
337 bug("[VMWareSVGA] %s: Extended FIFO\n", __func__
);
338 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_ALPHA_CURSOR
)
339 bug("[VMWareSVGA] %s: Alpha Cursor\n", __func__
);
340 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_CURSOR_BYPASS
)
341 bug("[VMWareSVGA] %s: Cursor-Bypass\n", __func__
);
342 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_CURSOR_BYPASS_2
)
343 bug("[VMWareSVGA] %s: Cursor-Bypass2\n", __func__
);
344 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_8BIT_EMULATION
)
345 bug("[VMWareSVGA] %s: 8bit-emu\n", __func__
);
346 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_3D
)
347 bug("[VMWareSVGA] %s: 3D.\n", __func__
);
348 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_MULTIMON
)
349 bug("[VMWareSVGA] %s: Multimon\n", __func__
);
351 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_DISPLAY_TOPOLOGY
)
353 DINFO(bug("[VMWareSVGA] %s: Display Topology\n", __func__
);)
354 vmwareWriteReg(&XSD(cl
)->data
, SVGA_REG_NUM_GUEST_DISPLAYS
, 1);
357 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_PITCHLOCK
)
358 bug("[VMWareSVGA] %s: Pitchlock\n", __func__
);
359 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_GMR
)
360 bug("[VMWareSVGA] %s: GMR\n", __func__
);
361 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_GMR2
)
362 bug("[VMWareSVGA] %s: GMR2\n", __func__
);
363 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_TRACES
)
364 bug("[VMWareSVGA] %s: Traces\n", __func__
);
365 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_SCREEN_OBJECT_2
)
366 bug("[VMWareSVGA] %s: Screen-Object2\n", __func__
);
369 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_RECT_COPY
)
370 bug("[VMWareSVGA] %s: Copy Rect\n", __func__
);
371 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_RECT_FILL
)
372 bug("[VMWareSVGA] %s: Fill Rect\n", __func__
);
373 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_OFFSCREEN_1
)
374 bug("[VMWareSVGA] %s: BitMap/Pixmap\n", __func__
);
375 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_RECT_PAT_FILL
)
376 bug("[VMWareSVGA] %s: Pattern Fill\n", __func__
);
377 if ((XSD(cl
)->data
.capabilities
& (SVGA_CAP_RECT_FILL
|SVGA_CAP_RASTER_OP
)) == (SVGA_CAP_RECT_FILL
|SVGA_CAP_RASTER_OP
))
378 bug("[VMWareSVGA] %s: ROp Fill\n", __func__
);
379 if ((XSD(cl
)->data
.capabilities
& (SVGA_CAP_RECT_COPY
|SVGA_CAP_RASTER_OP
)) == (SVGA_CAP_RECT_COPY
|SVGA_CAP_RASTER_OP
))
380 bug("[VMWareSVGA] %s: ROp Copy\n", __func__
);
381 if ((XSD(cl
)->data
.capabilities
& (SVGA_CAP_RECT_PAT_FILL
|SVGA_CAP_RASTER_OP
)) == (SVGA_CAP_RECT_PAT_FILL
|SVGA_CAP_RASTER_OP
))
382 bug("[VMWareSVGA] %s: ROp Pattern Fill\n", __func__
);
383 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_GLYPH
)
384 bug("[VMWareSVGA] %s: Glyph\n", __func__
);
385 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_GLYPH_CLIPPING
)
386 bug("[VMWareSVGA] %s: Glyph Clipping\n", __func__
);
389 /* Set the ID so vmware knows we are here */
390 vmwareWriteReg(&XSD(cl
)->data
, SVGA_REG_GUEST_ID
, 0x09);
394 D(bug("[VMWareSVGA] %s: returning 0x%p\n", __func__
, o
);)
399 VOID
VMWareSVGA__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
401 FreeVec(XSD(cl
)->mouse
.shape
);
402 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
405 VOID
VMWareSVGA__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
410 if (IS_GFX_ATTR(msg
->attrID
, idx
))
414 case aoHidd_Gfx_SupportsHWCursor
:
417 if (XSD(cl
)->data
.capabilities
& SVGA_CAP_CURSOR
)
419 DINFO(bug("[VMWareSVGA] %s: HW Cursor\n", __func__
);)
420 *msg
->storage
= (IPTR
)TRUE
;
423 *msg
->storage
= (IPTR
)FALSE
;
427 case aoHidd_Gfx_SupportsGamma
:
428 *msg
->storage
= (IPTR
)TRUE
;
432 case aoHidd_Gfx_MemoryAttribs
:
434 struct TagItem
*matstate
= (struct TagItem
*)msg
->storage
;
438 struct TagItem
*matag
;
439 while ((matag
= NextTagItem(&matstate
)))
441 switch(matag
->ti_Tag
)
443 case tHidd_Gfx_MemTotal
:
444 case tHidd_Gfx_MemAddressableTotal
:
445 matag
->ti_Data
= (IPTR
)vmwareReadReg(&XSD(cl
)->data
, SVGA_REG_VRAM_SIZE
);
446 DINFO(bug("[VMWareSVGA] %s: Mem Size = %ld\n", __func__
, matag
->ti_Data
);)
448 case tHidd_Gfx_MemFree
:
449 case tHidd_Gfx_MemAddressableFree
:
460 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
463 OOP_Object
*VMWareSVGA__Hidd_Gfx__CreateObject(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CreateObject
*msg
)
465 OOP_Object
*object
= NULL
;
467 D(bug("[VMWareSVGA] %s()\n", __func__
);)
469 if (msg
->cl
== XSD(cl
)->basebm
)
473 OOP_Class
*classptr
= NULL
;
474 struct TagItem tags
[] =
476 { TAG_IGNORE
, TAG_IGNORE
}, /* Placeholder for aHidd_BitMap_ClassPtr */
477 { TAG_MORE
, (IPTR
)msg
->attrList
}
480 struct pHidd_Gfx_CreateObject comsg
;
482 displayable
= GetTagData(aHidd_BitMap_Displayable
, FALSE
, msg
->attrList
);
483 framebuffer
= GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
485 classptr
= XSD(cl
)->vmwaresvgaonbmclass
;
486 else if (displayable
)
487 classptr
= XSD(cl
)->vmwaresvgaoffbmclass
;
491 modeid
= (HIDDT_ModeID
)GetTagData(aHidd_BitMap_ModeID
, vHidd_ModeID_Invalid
, msg
->attrList
);
492 if (modeid
!= vHidd_ModeID_Invalid
)
493 classptr
= XSD(cl
)->vmwaresvgaoffbmclass
;
496 HIDDT_StdPixFmt stdpf
;
497 stdpf
= (HIDDT_StdPixFmt
)GetTagData(aHidd_BitMap_StdPixFmt
, vHidd_StdPixFmt_Unknown
, msg
->attrList
);
498 if (stdpf
== vHidd_StdPixFmt_Unknown
)
501 friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, (IPTR
)NULL
, msg
->attrList
);
504 OOP_Class
*friend_class
= NULL
;
505 OOP_GetAttr(friend, aHidd_BitMap_ClassPtr
, (IPTR
*)&friend_class
);
506 if (friend_class
== XSD(cl
)->vmwaresvgaonbmclass
)
508 classptr
= XSD(cl
)->vmwaresvgaoffbmclass
;
514 if (classptr
!= NULL
)
516 tags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
517 tags
[0].ti_Data
= (IPTR
)classptr
;
519 comsg
.mID
= msg
->mID
;
521 comsg
.attrList
= tags
;
523 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)&comsg
);
525 else if ((XSD(cl
)->basegallium
&& (msg
->cl
== XSD(cl
)->basegallium
)) &&
526 (XSD(cl
)->data
.capabilities
& SVGA_CAP_3D
))
528 /* Create the gallium 3d driver object .. */
529 object
= OOP_NewObject(NULL
, CLID_Hidd_Gallium_VMWareSVGA
, msg
->attrList
);
532 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
534 D(bug("[VMWareSVGA] %s: returning 0x%p\n", __func__
, object
);)
538 ULONG
VMWareSVGA__Hidd_Gfx__ShowViewPorts(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_ShowViewPorts
*msg
)
540 IPTR width
= 0, bm_width
, height
= 0, bm_height
;
541 struct HIDD_ViewPortData
*currVPD
;
543 D(bug("[VMWareSVGA] %s()\n", __func__
);)
545 #if defined(VMWAREGFX_UPDATEFBONSHOWVP)
546 if ((currVPD
= msg
->Data
) != 0)
548 if ((XSD(cl
)->data
.shown
) && (XSD(cl
)->mouse
.visible
))
550 D(bug("[VMWareSVGA] %s: removing cursor...\n", __func__
);)
551 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_HIDE
);
554 XSD(cl
)->data
.shown
= currVPD
;
555 D(bug("[VMWareSVGA] %s: shown = 0x%p\n", __func__
, XSD(cl
)->data
.shown
));
557 while ((currVPD
) && (currVPD
->Bitmap
))
559 OOP_GetAttr(currVPD
->Bitmap
, aHidd_BitMap_Width
, (IPTR
*)&bm_width
);
560 if (bm_width
> width
)
562 OOP_GetAttr(currVPD
->Bitmap
, aHidd_BitMap_Height
, (IPTR
*)&bm_height
);
563 if (bm_height
> height
)
565 currVPD
= currVPD
->Next
;
567 D(bug("[VMWareSVGA] %s: %dx%d\n", __func__
, width
, height
));
570 width
= XSD(cl
)->prefWidth
;
572 height
= XSD(cl
)->prefHeight
;
574 setModeVMWareSVGA(&XSD(cl
)->data
, width
, height
);
575 syncfenceVMWareSVGAFIFO(&XSD(cl
)->data
, fenceVMWareSVGAFIFO(&XSD(cl
)->data
));
576 if (XSD(cl
)->mouse
.visible
)
578 D(bug("[VMWareSVGA] %s: displaying cursor...\n", __func__
);)
579 defineCursorVMWareSVGA(&XSD(cl
)->data
, &XSD(cl
)->mouse
);
580 moveCursorVMWareSVGA(&XSD(cl
)->data
, XSD(cl
)->mouse
.x
, XSD(cl
)->mouse
.y
);
581 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_SHOW
);
586 D(bug("[VMWareSVGA] %s: nothing to show ...\n", __func__
);)
589 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
592 BOOL
VMWareSVGA__Hidd_Gfx__SetGamma(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_Gamma
*msg
)
594 D(bug("[VMWareSVGA] %s()\n", __func__
);)
597 for (i
= 0; i
< 256; i
++) {
598 D(bug("[VMWareSVGA] %s: #%d 0x%04x:0x%04x:0x%04x\n", __func__
, i
, msg
->Red
[i
], msg
->Green
[i
], msg
->Blue
[i
]);)
599 vmwareWriteReg(&XSD(cl
)->data
, SVGA_PALETTE_BASE
+ i
* 3 + 0, msg
->Red
[i
] >> 8);
600 vmwareWriteReg(&XSD(cl
)->data
, SVGA_PALETTE_BASE
+ i
* 3 + 1, msg
->Green
[i
] >> 8);
601 vmwareWriteReg(&XSD(cl
)->data
, SVGA_PALETTE_BASE
+ i
* 3 + 2, msg
->Blue
[i
] >> 8);
607 VOID
VMWareSVGA__Hidd_Gfx__CopyBox(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CopyBox
*msg
)
612 struct HWData
*hwdata
= &XSD(cl
)->data
;
613 struct Box box
= { msg
->srcX
, msg
->srcY
, msg
->srcX
+ msg
->width
+ 1, msg
->srcY
+ msg
->height
+ 1};
615 D(bug("[VMWareSVGA] %s()\n", __func__
);)
617 ObtainSemaphore(&hwdata
->damage_control
);
619 mode
= GC_DRMD(msg
->gc
);
620 OOP_GetAttr(msg
->src
, aHidd_VMWareSVGABitMap_Drawable
, (IPTR
*)&src
);
621 OOP_GetAttr(msg
->dest
, aHidd_VMWareSVGABitMap_Drawable
, (IPTR
*)&dst
);
622 if (((dst
== NULL
) || (src
== NULL
))) /* no vmwaregfx bitmap */
624 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
627 // TODO: This is nice and fast. but unfortunately has to go. We'll soon switch to a more refined accelerated blitting
628 else if ((VPVISFLAG
) && (dst
== src
) && (OOP_OCLASS(msg
->dest
) == XSD(cl
)->vmwaresvgaonbmclass
))
630 D(bug("[VMWareSVGA] %s: suitable bitmaps used ...\n", __func__
);)
632 struct BitmapData
*data
;
633 data
= OOP_INST_DATA(OOP_OCLASS(msg
->src
), msg
->src
);
636 case vHidd_GC_DrawMode_Clear
:
637 clearCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
639 case vHidd_GC_DrawMode_And
:
640 andCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
642 case vHidd_GC_DrawMode_AndReverse
:
643 andReverseCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
645 case vHidd_GC_DrawMode_Copy
:
646 copyCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
648 case vHidd_GC_DrawMode_AndInverted
:
649 andInvertedCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
651 case vHidd_GC_DrawMode_NoOp
:
652 noOpCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
654 case vHidd_GC_DrawMode_Xor
:
655 xorCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
657 case vHidd_GC_DrawMode_Or
:
658 orCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
660 case vHidd_GC_DrawMode_Nor
:
661 norCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
663 case vHidd_GC_DrawMode_Equiv
:
664 equivCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
666 case vHidd_GC_DrawMode_Invert
:
667 invertCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
669 case vHidd_GC_DrawMode_OrReverse
:
670 orReverseCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
672 case vHidd_GC_DrawMode_CopyInverted
:
673 copyInvertedCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
675 case vHidd_GC_DrawMode_OrInverted
:
676 orInvertedCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
678 case vHidd_GC_DrawMode_Nand
:
679 nandCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
681 case vHidd_GC_DrawMode_Set
:
682 setCopyVMWareSVGA(data
->data
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
);
686 D(bug("[VMWareSVGA] %s: mode %d is not handled\n", __func__
, mode
);)
687 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
693 struct BitmapData
*srcbd
= OOP_INST_DATA(OOP_OCLASS(msg
->src
), msg
->src
);
694 struct BitmapData
*dstbd
= OOP_INST_DATA(OOP_OCLASS(msg
->dest
), msg
->dest
);
699 ULONG ycnt
= msg
->height
;
703 /* get src/dest video data start addresses and skip sizes */
704 if (srcbd
->VideoData
== srcbd
->data
->vrambase
)
706 offset
= (msg
->srcX
*srcbd
->bytesperpix
)+(msg
->srcY
*srcbd
->data
->bytesperline
);
707 srestadd
= (srcbd
->data
->bytesperline
- (msg
->width
*srcbd
->bytesperpix
));
708 if ((VPVISFLAG
) && (XSD(cl
)->mouse
.visible
))
710 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_REMOVE_FROM_FB
);
715 offset
= (msg
->srcX
+(msg
->srcY
*srcbd
->width
))*srcbd
->bytesperpix
;
716 srestadd
= (srcbd
->width
- msg
->width
)*srcbd
->bytesperpix
;
718 sbuffer
= srcbd
->VideoData
+offset
;
719 if (dstbd
->VideoData
== dstbd
->data
->vrambase
)
721 offset
= (msg
->destX
*dstbd
->bytesperpix
)+(msg
->destY
*dstbd
->data
->bytesperline
);
722 drestadd
= (dstbd
->data
->bytesperline
- (msg
->width
*dstbd
->bytesperpix
));
723 if ((VPVISFLAG
) && (XSD(cl
)->mouse
.visible
))
725 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_REMOVE_FROM_FB
);
730 offset
= (msg
->destX
+(msg
->destY
*dstbd
->width
))*dstbd
->bytesperpix
;
731 drestadd
= (dstbd
->width
- msg
->width
)*dstbd
->bytesperpix
;
733 dbuffer
= dstbd
->VideoData
+offset
;
737 case vHidd_GC_DrawMode_Copy
:
739 D(bug("[VMWareSVGA] %s: using CopyMem\n", __func__
);)
744 // NOTE: this is only valid if the two bitmaps share the same bytes per pixel.
745 // we may want to pre-process it (see below in the mouse definition code)
746 CopyMem(sbuffer
, dbuffer
, xcnt
* dstbd
->bytesperpix
);
748 sbuffer
+= xcnt
* dstbd
->bytesperpix
;
750 dbuffer
+= xcnt
* dstbd
->bytesperpix
;
756 D(bug("[VMWareSVGA] mode = %ld, src @ 0x%p dst @ 0x%p\n", mode
, src
, dst
);)
757 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
760 if ((VPVISFLAG
) && (XSD(cl
)->mouse
.visible
))
762 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_RESTORE_TO_FB
);
768 box
.x2
= box
.x1
+msg
->width
+1;
769 box
.y2
= box
.y1
+msg
->height
+1;
771 VMWareSVGA_Damage_DeltaAdd(hwdata
, &box
);
772 ReleaseSemaphore(&hwdata
->damage_control
);
774 D(bug("[VMWareSVGA] %s: done\n", __func__
);)
777 BOOL
VMWareSVGA__Hidd_Gfx__SetCursorShape(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_SetCursorShape
*msg
)
779 struct VMWareSVGA_staticdata
*data
= XSD(cl
);
781 D(bug("[VMWareSVGA] %s()\n", __func__
);)
783 if (msg
->shape
== NULL
)
785 D(bug("[VMWareSVGA] %s: blanking cursor\n", __func__
);)
786 if ((VPVISFLAG
) && (XSD(cl
)->visible
))
787 displayCursorVMWareSVGA(&XSD(cl
)->data
, SVGA_CURSOR_ON_HIDE
);
788 data
->mouse
.oopshape
= NULL
;
789 FreeVec(data
->mouse
.shape
);
790 data
->mouse
.shape
= NULL
;
799 HIDDT_StdPixFmt pixfmt
;
803 OOP_GetAttr(msg
->shape
, aHidd_BitMap_Width
, &tmp
);
804 data
->mouse
.width
= tmp
;
805 OOP_GetAttr(msg
->shape
, aHidd_BitMap_Height
, &tmp
);
806 data
->mouse
.height
= tmp
;
808 OOP_GetAttr(msg
->shape
, aHidd_BitMap_PixFmt
, (IPTR
*)&pfmt
);
809 OOP_GetAttr(pfmt
, aHidd_PixFmt_StdPixFmt
, (IPTR
*)&pixfmt
);
810 OOP_GetAttr(msg
->shape
, aHidd_BitMap_ColorMap
, (IPTR
*)&colmap
);
813 /* convert shape to vmware needs */
814 FreeVec(data
->mouse
.shape
);
815 tmp
= data
->mouse
.width
* data
->mouse
.height
;
816 data
->mouse
.shape
= AllocVec(tmp
<< 2, MEMF_CLEAR
|MEMF_PUBLIC
);
817 if (data
->mouse
.shape
!= NULL
)
820 shape
= data
->mouse
.shape
;
822 data
->mouse
.oopshape
= msg
->shape
;
823 // Get data from the bitmap. Using the ALPHA CURSOR we can now directly pre-process the bitmap to a suitable format
824 HIDD_BM_GetImage(msg
->shape
, (UBYTE
*)shape
, data
->mouse
.width
* 4, 0, 0, data
->mouse
.width
, data
->mouse
.height
, vHidd_StdPixFmt_BGRA32
);
825 if (XSD(cl
)->visible
)
827 struct BitmapData
*bmdata
= OOP_INST_DATA(XSD(cl
)->vmwaresvgaonbmclass
, XSD(cl
)->visible
);
829 syncfenceVMWareSVGAFIFO(bmdata
->data
, (bmdata
->data
->fence
- 1));
830 defineCursorVMWareSVGA(bmdata
->data
, &data
->mouse
);
831 syncfenceVMWareSVGAFIFO(bmdata
->data
, fenceVMWareSVGAFIFO(bmdata
->data
));
840 BOOL
VMWareSVGA__Hidd_Gfx__SetCursorPos(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_SetCursorPos
*msg
)
842 D(bug("[VMWareSVGA] %s()\n", __func__
);)
844 XSD(cl
)->mouse
.x
= msg
->x
;
845 XSD(cl
)->mouse
.y
= msg
->y
;
847 if ((VPVISFLAG
) && (XSD(cl
)->visible
))
849 struct BitmapData
*bmdata
= OOP_INST_DATA(XSD(cl
)->vmwaresvgaonbmclass
, XSD(cl
)->visible
);
851 syncfenceVMWareSVGAFIFO(bmdata
->data
, (bmdata
->data
->fence
- 1));
852 moveCursorVMWareSVGA(bmdata
->data
, XSD(cl
)->mouse
.x
, XSD(cl
)->mouse
.y
);
853 syncfenceVMWareSVGAFIFO(bmdata
->data
, fenceVMWareSVGAFIFO(bmdata
->data
));
859 VOID
VMWareSVGA__Hidd_Gfx__SetCursorVisible(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_SetCursorVisible
*msg
)
861 D(bug("[VMWareSVGA] %s()\n", __func__
);)
863 XSD(cl
)->mouse
.visible
= msg
->visible
;
864 if ((VPVISFLAG
) && (XSD(cl
)->visible
))
866 struct BitmapData
*bmdata
= OOP_INST_DATA(XSD(cl
)->vmwaresvgaonbmclass
, XSD(cl
)->visible
);
868 syncfenceVMWareSVGAFIFO(bmdata
->data
, (bmdata
->data
->fence
- 1));
869 displayCursorVMWareSVGA(bmdata
->data
, msg
->visible
? SVGA_CURSOR_ON_SHOW
: SVGA_CURSOR_ON_HIDE
);
870 syncfenceVMWareSVGAFIFO(bmdata
->data
, fenceVMWareSVGAFIFO(bmdata
->data
));
874 static int VMWareSVGA_InitStatic(LIBBASETYPEPTR LIBBASE
)
876 D(bug("[VMWareSVGA] %s()\n", __func__
);)
878 LIBBASE
->vsd
.mouse
.x
=0;
879 LIBBASE
->vsd
.mouse
.y
=0;
880 LIBBASE
->vsd
.mouse
.shape
= NULL
;
882 if (!OOP_ObtainAttrBases(attrbases
))
884 D(bug("[VMWareSVGA] %s: attrbases init failed\n", __func__
);)
888 D(bug("[VMWareSVGA] %s: initialised\n", __func__
);)
893 static int VMWareSVGA_ExpungeStatic(LIBBASETYPEPTR LIBBASE
)
895 D(bug("[VMWareSVGA] %s()\n", __func__
);)
897 OOP_ReleaseAttrBases(attrbases
);
899 D(bug("[VMWareSVGA] %s: done\n", __func__
);)
904 ADD2INITLIB(VMWareSVGA_InitStatic
, 0)
905 ADD2EXPUNGELIB(VMWareSVGA_ExpungeStatic
, 0)