summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:06 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:06 +0000
commit14194e3c743fb99c1d483dcfd19a077f7df8855b (patch)
tree328f4ff2503c24c37f83e04eef93bcff858164b2 /src
parent6094aa7bedee4b7602c70b80af56b51ca995fb57 (diff)
Diffstat (limited to 'src')
-rw-r--r--src/vmware.c154
-rw-r--r--src/vmware.h4
-rw-r--r--src/vmwarecurs.c34
3 files changed, 123 insertions, 69 deletions
diff --git a/src/vmware.c b/src/vmware.c
index 76d4bc3..15363e4 100644
--- a/src/vmware.c
+++ b/src/vmware.c
@@ -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,
@@ -151,6 +151,7 @@ static const OptionInfoRec VMWAREOptions[] = {
};
static void VMWAREStopFIFO(ScrnInfoPtr pScrn);
+static void VMWARESave(ScrnInfoPtr pScrn);
static Bool
VMWAREGetRec(ScrnInfoPtr pScrn)
@@ -435,13 +436,6 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
"VMware SVGA regs at (0x%04lx, 0x%04lx)\n",
pVMWARE->indexReg, pVMWARE->valueReg);
- id = VMXGetVMwareSvgaId(pVMWARE);
- if (id == SVGA_ID_0 || id == SVGA_ID_INVALID) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "No supported VMware SVGA found (read ID 0x%08x).\n", id);
- return FALSE;
- }
-
if (!xf86LoadSubModule(pScrn, "vgahw")) {
return FALSE;
}
@@ -452,6 +446,19 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
+ /*
+ * Save the current video state. Do it here before VMXGetVMwareSvgaId
+ * writes to any registers.
+ */
+ VMWARESave(pScrn);
+
+ id = VMXGetVMwareSvgaId(pVMWARE);
+ if (id == SVGA_ID_0 || id == SVGA_ID_INVALID) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "No supported VMware SVGA found (read ID 0x%08x).\n", id);
+ return FALSE;
+ }
+
pVMWARE->PciTag = pciTag(pVMWARE->PciInfo->bus, pVMWARE->PciInfo->device,
pVMWARE->PciInfo->func);
pVMWARE->Primary = xf86IsPrimaryPci(pVMWARE->PciInfo);
@@ -464,15 +471,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);
@@ -498,51 +502,71 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
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 +580,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 =
@@ -587,13 +610,23 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
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);
@@ -794,6 +827,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 +852,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,
@@ -1096,9 +1131,6 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
hwp = VGAHWPTR(pScrn);
vgaHWGetIOBase(hwp);
- /* Save the current video state */
- VMWARESave(pScrn);
-
VMWAREInitFIFO(pScrn);
/* Initialise the first mode */
diff --git a/src/vmware.h b/src/vmware.h
index 7be49d5..83edb74 100644
--- a/src/vmware.h
+++ b/src/vmware.h
@@ -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)];
diff --git a/src/vmwarecurs.c b/src/vmwarecurs.c
index 23ddc59..8a647a2 100644
--- a/src/vmwarecurs.c
+++ b/src/vmwarecurs.c
@@ -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) {