summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-06-06 09:58:01 +0100
committerJakob Bornecrantz <jakob@vmware.com>2012-06-09 05:54:30 +0200
commit61df95a86f4997e342d50d7779b00aba2e8849a6 (patch)
tree117cbcc8d4c27b926bd2951db9994329e02dc109 /src
parent46cdf0ed0ad9df66f36f95e27b209d454f67d526 (diff)
vmware: port vmware driver to new compat API
This is a port of the vmware driver to the new compat API. Tested-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/compat-api.h99
-rw-r--r--src/vmware.c40
-rw-r--r--src/vmware.h2
-rw-r--r--src/vmware_common.h2
5 files changed, 122 insertions, 22 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 04c9e0d..b0dd147 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,6 +37,7 @@ endif
vmware_drv_la_SOURCES = \
bits2pixels.c \
bits2pixels.h \
+ compat-api.h \
guest_os.h \
includeCheck.h \
svga_escape.h \
diff --git a/src/compat-api.h b/src/compat-api.h
new file mode 100644
index 0000000..6bc946f
--- /dev/null
+++ b/src/compat-api.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Dave Airlie <airlied@redhat.com>
+ */
+
+/* this file provides API compat between server post 1.13 and pre it,
+ it should be reused inside as many drivers as possible */
+#ifndef COMPAT_API_H
+#define COMPAT_API_H
+
+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
+#endif
+
+#ifndef XF86_HAS_SCRN_CONV
+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS pScreen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS pScrn
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
diff --git a/src/vmware.c b/src/vmware.c
index e3892f1..41201f1 100644
--- a/src/vmware.c
+++ b/src/vmware.c
@@ -901,8 +901,8 @@ VMWAREModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool rebuildPixmap)
pScrn->pScreen->rootDepth),
(pointer)(pVMWARE->FbBase + pScrn->fbOffset));
- (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, FALSE);
- (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, TRUE);
+ (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), FALSE);
+ (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), TRUE);
}
vgaHWProtect(pScrn, FALSE);
@@ -1018,7 +1018,7 @@ vmwareNextXineramaState(VMWAREPtr pVMWARE)
}
static void
-VMWAREAdjustFrame(int scrnIndex, int x, int y, int flags)
+VMWAREAdjustFrame(ADJUST_FRAME_ARGS_DECL)
{
/* FIXME */
}
@@ -1089,9 +1089,9 @@ VMWAREStopFIFO(ScrnInfoPtr pScrn)
}
static Bool
-VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
+VMWARECloseScreen(CLOSE_SCREEN_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
ScreenPtr save = &pVMWARE->ScrnFuncs;
@@ -1119,7 +1119,7 @@ VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
pScrn->DriverFunc = NULL;
#endif
- return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
}
static Bool
@@ -1296,16 +1296,14 @@ vmwareIsRegionEqual(const RegionPtr reg1,
}
static Bool
-VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+VMWAREScreenInit(SCREEN_INIT_ARGS_DECL)
{
- ScrnInfoPtr pScrn;
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
vgaHWPtr hwp;
VMWAREPtr pVMWARE;
OptionInfoPtr options;
Bool useXinerama = TRUE;
- /* Get the ScrnInfoRec */
- pScrn = xf86Screens[pScreen->myNum];
pVMWARE = VMWAREPTR(pScrn);
@@ -1381,7 +1379,7 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
VMWAREModeInit(pScrn, pScrn->currentMode, FALSE);
/* Set the viewport if supported */
- VMWAREAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ VMWAREAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
/*
* Setup the screen's visuals, and initialise the framebuffer
@@ -1582,10 +1580,9 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
static Bool
-VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
-
+VMWARESwitchMode(SWITCH_MODE_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
ScreenPtr pScreen = pScrn->pScreen;
pScreen->mmWidth = (pScreen->width * VMWARE_INCHTOMM +
@@ -1597,9 +1594,9 @@ VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
}
static Bool
-VMWAREEnterVT(int scrnIndex, int flags)
+VMWAREEnterVT(VT_FUNC_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
/*
@@ -1616,9 +1613,9 @@ VMWAREEnterVT(int scrnIndex, int flags)
}
static void
-VMWARELeaveVT(int scrnIndex, int flags)
+VMWARELeaveVT(VT_FUNC_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
/*
@@ -1631,17 +1628,18 @@ VMWARELeaveVT(int scrnIndex, int flags)
}
static void
-VMWAREFreeScreen(int scrnIndex, int flags)
+VMWAREFreeScreen(FREE_SCREEN_ARGS_DECL)
{
+ SCRN_INFO_PTR(arg);
/*
* If the vgahw module is used vgaHWFreeHWRec() would be called
* here.
*/
- VMWAREFreeRec(xf86Screens[scrnIndex]);
+ VMWAREFreeRec(pScrn);
}
static ModeStatus
-VMWAREValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+VMWAREValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
{
return MODE_OK;
}
diff --git a/src/vmware.h b/src/vmware.h
index 458390a..4818e16 100644
--- a/src/vmware.h
+++ b/src/vmware.h
@@ -177,7 +177,7 @@ typedef struct {
#define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate))
static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) {
- return xf86Screens[s->myNum];
+ return xf86ScreenToScrn(s);
}
#define MIN(a,b) ((a)<(b)?(a):(b))
diff --git a/src/vmware_common.h b/src/vmware_common.h
index 9cd7194..5629c10 100644
--- a/src/vmware_common.h
+++ b/src/vmware_common.h
@@ -32,6 +32,8 @@
#include <X11/extensions/panoramiXproto.h>
#include <xf86.h>
+#include "compat-api.h"
+
xXineramaScreenInfo *
VMWAREParseTopologyString(ScrnInfoPtr pScrn,
const char *topology,