Send cursor hotspot through the FIFO. This fixes host cursor. Allow any bpp XORG-6_7_99_1 XORG-6_7_99_2
authornolan <nolan>
Tue, 29 Jun 2004 02:20:25 +0000 (02:20 +0000)
committernolan <nolan>
Tue, 29 Jun 2004 02:20:25 +0000 (02:20 +0000)
    when 8BIT_EMULATION is set. Save/restore the ID register.

src/vmware.c
src/vmware.h
src/vmwarecurs.c

index d21ebb7..baa302d 100644 (file)
@@ -6,7 +6,7 @@
 char rcsId_vmware[] =
     "Id: vmware.c,v 1.11 2001/02/23 02:10:39 yoel Exp $";
 #endif
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmware.c,v 1.17 2003/02/18 19:10:36 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmware.c,v 1.18 2003/09/24 02:43:31 dawes Exp $ */
 
 /*
  * TODO: support the vmware linux kernel fb driver (Option "UseFBDev").
@@ -130,7 +130,7 @@ static XF86ModuleVersionInfo vmwareVersRec = {
     MODULEVENDORSTRING,
     MODINFOSTRING1,
     MODINFOSTRING2,
-    XF86_VERSION_CURRENT,
+    XORG_VERSION_CURRENT,
     VMWARE_MAJOR_VERSION, VMWARE_MINOR_VERSION, VMWARE_PATCHLEVEL,
     ABI_CLASS_VIDEODRV,
     ABI_VIDEODRV_VERSION,
@@ -432,7 +432,7 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
            pVMWARE->PciInfo->ioBase[0] + SVGA_VALUE_PORT;
     }
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-               "VMware SVGA regs at (0x%04x, 0x%04x)\n",
+               "VMware SVGA regs at (0x%04lx, 0x%04lx)\n",
                pVMWARE->indexReg, pVMWARE->valueReg);
 
     id = VMXGetVMwareSvgaId(pVMWARE);
@@ -464,15 +464,12 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
     pVMWARE->vmwareCapability = 0;
 #endif
 
+    pVMWARE->bitsPerPixel = vmwareReadReg(pVMWARE,
+                                          SVGA_REG_HOST_BITS_PER_PIXEL);
     if (pVMWARE->vmwareCapability & SVGA_CAP_8BIT_EMULATION) {
-        pVMWARE->bitsPerPixel =
-           vmwareReadReg(pVMWARE, SVGA_REG_HOST_BITS_PER_PIXEL);
-        vmwareWriteReg(pVMWARE,
-                       SVGA_REG_BITS_PER_PIXEL, pVMWARE->bitsPerPixel);
-    } else {
-        pVMWARE->bitsPerPixel =
-           vmwareReadReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL);
+       vmwareWriteReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL, pVMWARE->bitsPerPixel);
     }
+
     pVMWARE->depth = vmwareReadReg(pVMWARE, SVGA_REG_DEPTH);
     pVMWARE->videoRam = vmwareReadReg(pVMWARE, SVGA_REG_VRAM_SIZE);
     pVMWARE->memPhysBase = vmwareReadReg(pVMWARE, SVGA_REG_FB_START);
@@ -494,55 +491,75 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "bpp:   %d\n", pVMWARE->bitsPerPixel);
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "vram:  %d\n", pVMWARE->videoRam);
-    xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "pbase: %p\n", pVMWARE->memPhysBase);
+    xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "pbase: 0x%08lx\n", pVMWARE->memPhysBase);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "mwidt: %d\n", pVMWARE->maxWidth);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 2, "mheig: %d\n", pVMWARE->maxHeight);
 
-    switch (pVMWARE->depth) {
-    case 16:
-        /*
-         * In certain cases, the Windows host appears to
-         * report 16 bpp and 16 depth but 555 weight.  Just
-         * silently convert it to depth of 15.
-         */
-        if (pVMWARE->bitsPerPixel == 16 &&
-            pVMWARE->weight.green == 5)
-            pVMWARE->depth = 15;
+    if (pVMWARE->vmwareCapability & SVGA_CAP_8BIT_EMULATION) {
+        bpp24flags = Support24bppFb | Support32bppFb;
+    } else {
+        switch (pVMWARE->depth) {
+        case 16:
+            /*
+             * In certain cases, the Windows host appears to
+             * report 16 bpp and 16 depth but 555 weight.  Just
+             * silently convert it to depth of 15.
+             */
+            if (pVMWARE->bitsPerPixel == 16 &&
+                pVMWARE->weight.green == 5)
+                pVMWARE->depth = 15;
+        case 8:
+        case 15:
+            bpp24flags = NoDepth24Support;
+         break;
+        case 32:
+            /*
+             * There is no 32 bit depth, apparently it can get
+             * reported this way sometimes on the Windows host.
+             */
+            if (pVMWARE->bitsPerPixel == 32)
+                pVMWARE->depth = 24;
+        case 24:
+            if (pVMWARE->bitsPerPixel == 24)
+                bpp24flags = Support24bppFb;
+            else
+                bpp24flags = Support32bppFb;
+            break;
+       default:
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Adapter is using an unsupported depth (%d).\n",
+                       pVMWARE->depth);
+            return FALSE;
+       }
+    }
+
+    if (!xf86SetDepthBpp(pScrn, pVMWARE->depth, pVMWARE->bitsPerPixel,
+                         pVMWARE->bitsPerPixel, bpp24flags)) {
+        return FALSE;
+    }
+
+    /* Check that the returned depth is one we support */
+    switch (pScrn->depth) {
     case 8:
     case 15:
-        bpp24flags = NoDepth24Support;
-        break;
-
-    case 32:
-        /*
-         * There is no 32 bit depth, apparently it can get
-         * reported this way sometimes on the Windows host.
-         */
-        if (pVMWARE->bitsPerPixel == 32)
-            pVMWARE->depth = 24;
+    case 16:
     case 24:
-        if (pVMWARE->bitsPerPixel == 24)
-            bpp24flags = Support24bppFb;
-        else
-            bpp24flags = Support32bppFb;
+        /* OK */
         break;
     default:
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                   "Adapter is using an unsupported depth (%d).\n",
-                   pVMWARE->depth);
-        return FALSE;
-    }
-
-    if (!xf86SetDepthBpp(pScrn, pVMWARE->depth, pVMWARE->bitsPerPixel, pVMWARE->bitsPerPixel, bpp24flags)) {
+                   "Given depth (%d) is not supported by this driver\n",
+                   pScrn->depth);
         return FALSE;
     }
 
     if (pScrn->bitsPerPixel != pVMWARE->bitsPerPixel) {
-        if (pScrn->bitsPerPixel == 8 &&
-            pVMWARE->vmwareCapability & SVGA_CAP_8BIT_EMULATION) {
-            vmwareWriteReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL, 8);
+        if (pVMWARE->vmwareCapability & SVGA_CAP_8BIT_EMULATION) {
+            vmwareWriteReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL,
+                           pScrn->bitsPerPixel);
             pVMWARE->bitsPerPixel =
                vmwareReadReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL);
+            pVMWARE->depth = vmwareReadReg(pVMWARE, SVGA_REG_DEPTH);
         } else {
             xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "Currently unavailable depth/bpp of %d/%d requested.\n"
@@ -556,11 +573,10 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
     }
 
     /*
-     * Reread depth and defer reading the colour registers until here
-     * in case we changed bpp above.
+     * Defer reading the colour registers until here in case we changed
+     * bpp above.
      */
 
-    pVMWARE->depth = vmwareReadReg(pVMWARE, SVGA_REG_DEPTH);
     pVMWARE->weight.red =
        vmwareCalculateWeight(vmwareReadReg(pVMWARE, SVGA_REG_RED_MASK));
     pVMWARE->weight.green =
@@ -578,22 +594,32 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED,
                    2, "bpp:   %d\n", pVMWARE->bitsPerPixel);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED,
-                   2, "w.red: %d\n", pVMWARE->weight.red);
+                   2, "w.red: %d\n", (int)pVMWARE->weight.red);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED,
-                   2, "w.grn: %d\n", pVMWARE->weight.green);
+                   2, "w.grn: %d\n", (int)pVMWARE->weight.green);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED,
-                   2, "w.blu: %d\n", pVMWARE->weight.blue);
+                   2, "w.blu: %d\n", (int)pVMWARE->weight.blue);
     xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED,
                    2, "vis:   %d\n", pVMWARE->defaultVisual);
 
     if (pScrn->depth != pVMWARE->depth) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                   "Currently unavailable depth of %d requested.\n"
-                   "\tThe guest X server must run at the same depth as the host (which\n"
-                   "\tis currently %d).  This is automatically detected.  Please do not\n"
-                   "\tspecify a depth on the command line or via the config file.\n",
-                   pScrn->depth, pVMWARE->depth);
-        return FALSE;
+        if (pVMWARE->vmwareCapability & SVGA_CAP_8BIT_EMULATION) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Currently unavailable depth of %d requested.\n"
+                       "\tIf the guest X server's BPP matches the host's "
+                       "BPP, then\n\tthe guest X server's depth must also "
+                       "match the\n\thost's depth (currently %d).\n",
+                       pScrn->depth, pVMWARE->depth);
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Currently unavailable depth of %d requested.\n"
+                       "\tThe guest X server must run at the same depth as "
+                       "the host (which\n\tis currently %d).  This is "
+                       "automatically detected.  Please do not\n\tspecify "
+                       "a depth on the command line or via the config file.\n",
+                       pScrn->depth, pVMWARE->depth);
+        }
+           return FALSE;
     }
     xf86PrintDepthBpp(pScrn);
 
@@ -646,7 +672,7 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
     pScrn->chipset = (char*)xf86TokenToString(VMWAREChipsets, pVMWARE->PciInfo->chipType);
 
     if (!pScrn->chipset) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ChipID 0x%04 is not recognised\n", pVMWARE->PciInfo->chipType);
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ChipID 0x%04x is not recognised\n", pVMWARE->PciInfo->chipType);
         return FALSE;
     }
 
@@ -794,6 +820,7 @@ VMWARESave(ScrnInfoPtr pScrn)
     vmwareReg->svga_reg_height = vmwareReadReg(pVMWARE, SVGA_REG_HEIGHT);
     vmwareReg->svga_reg_bits_per_pixel =
        vmwareReadReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL);
+    vmwareReg->svga_reg_id = vmwareReadReg(pVMWARE, SVGA_REG_ID);
 
     /* XXX this should be based on the cap bit, not hwCursor... */
     if (pVMWARE->hwCursor) {
@@ -818,6 +845,7 @@ VMWARERestoreRegs(ScrnInfoPtr pScrn, VMWARERegPtr vmwareReg)
               vmwareReg->svga_reg_width, vmwareReg->svga_reg_height,
               vmwareReg->svga_reg_bits_per_pixel, vmwareReg->svga_reg_enable));
     if (vmwareReg->svga_reg_enable) {
+        vmwareWriteReg(pVMWARE, SVGA_REG_ID, vmwareReg->svga_reg_id);
         vmwareWriteReg(pVMWARE, SVGA_REG_WIDTH, vmwareReg->svga_reg_width);
         vmwareWriteReg(pVMWARE, SVGA_REG_HEIGHT, vmwareReg->svga_reg_height);
         vmwareWriteReg(pVMWARE, SVGA_REG_BITS_PER_PIXEL,
@@ -1303,7 +1331,7 @@ VMWAREFreeScreen(int scrnIndex, int flags)
    VMWAREFreeRec(xf86Screens[scrnIndex]);
 }
 
-static Bool
+static ModeStatus
 VMWAREValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
 {
     return MODE_OK;
index c12fc29..83edb74 100644 (file)
@@ -18,6 +18,7 @@
 #include "xf86PciInfo.h"       /* pci vendor id */
 #include "xf86Pci.h"           /* pci */
 #include "xf86Cursor.h"                /* hw cursor */
+#include "cursorstr.h"          /* xhot/yhot */
 
 #include "vgaHW.h"             /* VGA hardware */
 #include "fb.h"
@@ -46,6 +47,8 @@ typedef struct {
     CARD32 svga_reg_cursor_id;
 
     Bool svga_fifo_enabled;
+
+    CARD32 svga_reg_id;
 } VMWARERegRec, *VMWARERegPtr;
 
 typedef struct {
@@ -99,6 +102,7 @@ typedef struct {
     xf86CursorInfoPtr CursorInfoRec;
     struct {
         int bg, fg, x, y;
+        int hotX, hotY;
         BoxRec box;
 
         uint32 mask[SVGA_BITMAP_SIZE(MAX_CURS, MAX_CURS)];
@@ -180,87 +184,61 @@ extern const char *vmwareXaaSymbols[];
 #define ACCELERATE_OPS
 
 void vmwareWriteReg(
-#if NeedFunctionPrototypes
    VMWAREPtr pVMWARE, int index, CARD32 value
-#endif
    );
 
 CARD32 vmwareReadReg(
-#if NeedFunctionPrototypes
     VMWAREPtr pVMWARE, int index
-#endif
     );
 
 void vmwareWriteWordToFIFO(
-#if NeedFunctionPrototypes
    VMWAREPtr pVMWARE, CARD32 value
-#endif
    );
 
 void vmwareWaitForFB(
-#ifdef NeedFunctionPrototypes
    VMWAREPtr pVMWARE
-#endif
    );
 
 void vmwareSendSVGACmdUpdate(
-#if NeedFunctionPrototypes
    VMWAREPtr pVMWARE, BoxPtr pBB
-#endif
    );
 
 /* vmwarecurs.c */
 Bool vmwareCursorInit(
-#if NeedFunctionPrototypes
    ScreenPtr pScr
-#endif
    );
 
 void vmwareCursorModeInit(
-#if NeedFunctionPrototypes
     ScrnInfoPtr pScrn,
     DisplayModePtr mode
-#endif
    );
 
 void vmwareCursorCloseScreen(
-#if NeedFunctionPrototypes
     ScreenPtr pScr
-#endif
     );
 
 void vmwareWriteCursorRegs(
-#if NeedFunctionPrototypes
    VMWAREPtr pVMWARE,
    Bool visible,
    Bool force
-#endif
    );
 
 void vmwareCursorHookWrappers(
-#if NeedFunctionPrototypes
    ScreenPtr pScreen
-#endif
    );
 
 
 /* vmwarexaa.c */
 Bool vmwareXAAScreenInit(
-#if NeedFunctionPrototypes
    ScreenPtr pScreen
-#endif
    );
 
 Bool vmwareXAAModeInit(
-#if NeedFunctionPrototypes
     ScrnInfoPtr pScrn, DisplayModePtr mode
-#endif
     );
 
 void vmwareXAACloseScreen(
-#if NeedFunctionPrototypes
    ScreenPtr pScreen
-#endif
    );
 
 #endif
index 1a7c6eb..8a647a2 100644 (file)
@@ -6,7 +6,7 @@
 char rcsId_vmwarecurs[] =
     "Id: vmwarecurs.c,v 1.5 2001/01/30 23:33:02 bennett Exp $";
 #endif
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c,v 1.11 2003/02/05 12:47:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarecurs.c,v 1.10 2003/02/04 01:39:53 dawes Exp $ */
 
 #include "vmware.h"
 #include "bits2pixels.h"
@@ -36,8 +36,8 @@ RedefineCursor(VMWAREPtr pVMWARE)
     /* Define cursor */
     vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_DEFINE_CURSOR);
     vmwareWriteWordToFIFO(pVMWARE, MOUSE_ID);
-    vmwareWriteWordToFIFO(pVMWARE, 0);          /* HotX/HotY seem to be zero? */
-    vmwareWriteWordToFIFO(pVMWARE, 0);          /* HotX/HotY seem to be zero? */
+    vmwareWriteWordToFIFO(pVMWARE, pVMWARE->hwcur.hotX);
+    vmwareWriteWordToFIFO(pVMWARE, pVMWARE->hwcur.hotY);
     vmwareWriteWordToFIFO(pVMWARE, pVMWARE->CursorInfoRec->MaxWidth);
     vmwareWriteWordToFIFO(pVMWARE, pVMWARE->CursorInfoRec->MaxHeight);
     vmwareWriteWordToFIFO(pVMWARE, 1);
@@ -104,6 +104,18 @@ vmwareSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
     }
 }
 
+static Bool
+vmwareUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
+{
+    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
+
+    pVMWARE->hwcur.hotX = pCurs->bits->xhot;
+    pVMWARE->hwcur.hotY = pCurs->bits->yhot;
+
+    return pScrn->bitsPerPixel > 8;
+}
+
 static void
 vmwareLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src )
 {
@@ -125,6 +137,7 @@ static Bool
 vmwareUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
 {
     ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+
     return pCurs->bits->height <= MAX_CURS &&
            pCurs->bits->width <= MAX_CURS &&
            pScrn->bitsPerPixel > 8;
@@ -141,10 +154,13 @@ vmwareLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs)
 
     pVMWARE->cursorDefined = FALSE;
 
+    pVMWARE->hwcur.hotX = pCurs->bits->xhot;
+    pVMWARE->hwcur.hotY = pCurs->bits->yhot;
+
     vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_DEFINE_ALPHA_CURSOR);
     vmwareWriteWordToFIFO(pVMWARE, MOUSE_ID);
-    vmwareWriteWordToFIFO(pVMWARE, 0);
-    vmwareWriteWordToFIFO(pVMWARE, 0);
+    vmwareWriteWordToFIFO(pVMWARE, pCurs->bits->xhot);
+    vmwareWriteWordToFIFO(pVMWARE, pCurs->bits->yhot);
     vmwareWriteWordToFIFO(pVMWARE, width);
     vmwareWriteWordToFIFO(pVMWARE, height);
 
@@ -153,7 +169,6 @@ vmwareLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs)
     }
 
     vmwareWaitForFB(pVMWARE);
-
     pVMWARE->cursorDefined = TRUE;
 }
 #endif
@@ -165,10 +180,12 @@ vmwareWriteCursorRegs(VMWAREPtr pVMWARE, Bool visible, Bool force)
 
     vmwareWriteReg(pVMWARE, SVGA_REG_CURSOR_ID, MOUSE_ID);
     if (visible) {
-        vmwareWriteReg(pVMWARE, SVGA_REG_CURSOR_X, pVMWARE->hwcur.x);
-        vmwareWriteReg(pVMWARE, SVGA_REG_CURSOR_Y, pVMWARE->hwcur.y);
+        vmwareWriteReg(pVMWARE, SVGA_REG_CURSOR_X,
+                       pVMWARE->hwcur.x + pVMWARE->hwcur.hotX);
+        vmwareWriteReg(pVMWARE, SVGA_REG_CURSOR_Y,
+                       pVMWARE->hwcur.y + pVMWARE->hwcur.hotY);
     }
-    
+
     if (force) {
         enableVal = visible ? SVGA_CURSOR_ON_SHOW : SVGA_CURSOR_ON_HIDE;
     } else {
@@ -275,6 +292,7 @@ vmwareCursorInit(ScreenPtr pScreen)
     infoPtr->LoadCursorImage = vmwareLoadCursorImage;
     infoPtr->HideCursor = vmwareHideCursor;
     infoPtr->ShowCursor = vmwareShowCursor;
+    infoPtr->UseHWCursor = vmwareUseHWCursor;
 
 #ifdef ARGB_CURSOR
     if (pVMWARE->vmwareCapability & SVGA_CAP_ALPHA_CURSOR) {