summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-06-06 14:13:48 +0100
committerDave Airlie <airlied@redhat.com>2012-06-06 14:13:48 +0100
commiteffa2938ee2b576b8eb6cd7f774d8b1656c50e82 (patch)
tree21cc37366ca361313b0a33b1fcea65b9b6bcbf31
parent7b26793ba2572c412f03e9a4acf83237fbec71bd (diff)
rendition: port to new compat API.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/Makefile.am1
-rw-r--r--src/accelX.c2
-rw-r--r--src/compat-api.h99
-rw-r--r--src/hwcursor.c4
-rw-r--r--src/hwcursor.h2
-rw-r--r--src/rendition.c63
-rw-r--r--src/rendition.h1
-rw-r--r--src/rendition_shadow.c6
-rw-r--r--src/rendition_shadow.h2
-rw-r--r--src/vmodes.c4
-rw-r--r--src/vtypes.h2
11 files changed, 145 insertions, 41 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6770629..0666377 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ rendition_drv_ladir = @moduledir@/drivers
rendition_drv_la_SOURCES = \
cmd2d.h \
commonregs.h \
+ compat-api.h \
cscode.h \
hwcursor.c \
hwcursor.h \
diff --git a/src/accelX.c b/src/accelX.c
index ed4964e..bd237b3 100644
--- a/src/accelX.c
+++ b/src/accelX.c
@@ -133,7 +133,7 @@ RENDITIONAccelPreInit(ScrnInfoPtr pScreenInfo)
void
RENDITIONAccelXAAInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen);
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
XAAInfoRecPtr pXAAinfo;
diff --git a/src/compat-api.h b/src/compat-api.h
new file mode 100644
index 0000000..e4f03d2
--- /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 pScreenInfo = 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 pScreenInfo->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScreenInfo = (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 pScreenInfo
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
diff --git a/src/hwcursor.c b/src/hwcursor.c
index c3b5ee8..609417a 100644
--- a/src/hwcursor.c
+++ b/src/hwcursor.c
@@ -75,9 +75,9 @@ RenditionHWCursorRelease (ScrnInfoPtr pScreenInfo)
Bool
-RenditionHWCursorInit(int scrnIndex, ScreenPtr pScreen)
+RenditionHWCursorInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen);
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
xf86CursorInfoPtr infoPtr;
diff --git a/src/hwcursor.h b/src/hwcursor.h
index e0d742b..cfe24d3 100644
--- a/src/hwcursor.h
+++ b/src/hwcursor.h
@@ -10,7 +10,7 @@
*/
void RenditionHWCursorPreInit(ScrnInfoPtr pScreenInfo);
-Bool RenditionHWCursorInit(int scrnIndex, ScreenPtr pScreen);
+Bool RenditionHWCursorInit(ScreenPtr pScreen);
void RenditionHWCursorRelease (ScrnInfoPtr pScreenInfo);
#define HC_SIZE (64*64*2)/8 /* 1024 */
diff --git a/src/rendition.c b/src/rendition.c
index 8da5e13..5fa5eca 100644
--- a/src/rendition.c
+++ b/src/rendition.c
@@ -106,14 +106,14 @@ static Bool renditionPciProbe(DriverPtr drv, int entity_num,
static Bool renditionProbe(DriverPtr, int);
#endif
static Bool renditionPreInit(ScrnInfoPtr, int);
-static Bool renditionScreenInit(int, ScreenPtr, int, char **);
-static Bool renditionSwitchMode(int, DisplayModePtr, int);
-static void renditionAdjustFrame(int, int, int, int);
-static Bool renditionEnterVT(int, int);
-static void renditionLeaveVT(int, int);
-static void renditionFreeScreen(int, int);
-
-static ModeStatus renditionValidMode(int, DisplayModePtr, Bool, int);
+static Bool renditionScreenInit(SCREEN_INIT_ARGS_DECL);
+static Bool renditionSwitchMode(SWITCH_MODE_ARGS_DECL);
+static void renditionAdjustFrame(ADJUST_FRAME_ARGS_DECL);
+static Bool renditionEnterVT(VT_FUNC_ARGS_DECL);
+static void renditionLeaveVT(VT_FUNC_ARGS_DECL);
+static void renditionFreeScreen(FREE_SCREEN_ARGS_DECL);
+
+static ModeStatus renditionValidMode(SCRN_ARG_TYPE, DisplayModePtr, Bool, int);
static Bool renditionMapMem(ScrnInfoPtr pScreenInfo);
static Bool renditionUnmapMem(ScrnInfoPtr pScreenInfo);
#if 0
@@ -1022,9 +1022,9 @@ renditionLeaveGraphics(ScrnInfoPtr pScreenInfo)
/* Unravel the screen */
static Bool
-renditionCloseScreen(int scrnIndex, ScreenPtr pScreen)
+renditionCloseScreen(CLOSE_SCREEN_ARGS_DECL)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen);
renditionPtr prenditionPriv=renditionGetRec(pScreenInfo);
Bool Closed = TRUE;
@@ -1044,7 +1044,7 @@ renditionCloseScreen(int scrnIndex, ScreenPtr pScreen)
if (prenditionPriv
&& (pScreen->CloseScreen = prenditionPriv->CloseScreen)) {
prenditionPriv->CloseScreen = NULL;
- Closed = (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ Closed = (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
}
#ifdef DEBUG
@@ -1066,9 +1066,9 @@ renditionDPMSSet(ScrnInfoPtr pScreen, int mode, int flags)
}
static Bool
-renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+renditionScreenInit(SCREEN_INIT_ARGS_DECL)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen);
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
Bool Inited = FALSE;
unsigned char *FBBase;
@@ -1109,8 +1109,8 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* blank the screen */
renditionSaveScreen(pScreen, SCREEN_SAVER_ON);
- (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
- pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
+ (*pScreenInfo->AdjustFrame)(ADJUST_FRAME_ARGS(pScreenInfo,
+ pScreenInfo->frameX0, pScreenInfo->frameY0));
miClearVisualTypes();
@@ -1186,7 +1186,7 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if(!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0)&&
!pRendition->board.rotate){
/* Initialise HW cursor */
- if(!RenditionHWCursorInit(scrnIndex, pScreen)){
+ if(!RenditionHWCursorInit(pScreen)){
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Hardware Cursor initalization failed!!\n");
}
@@ -1238,7 +1238,7 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScreen->SaveScreen = renditionSaveScreen;
if (!Inited)
- renditionCloseScreen(scrnIndex, pScreen);
+ renditionCloseScreen(CLOSE_SCREEN_ARGS);
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options);
@@ -1251,19 +1251,20 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
static Bool
-renditionSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags)
+renditionSwitchMode(SWITCH_MODE_ARGS_DECL)
{
+ SCRN_INFO_PTR(arg);
#ifdef DEBUG
ErrorF("RENDITION: renditionSwitchMode() called\n");
#endif
- return renditionSetMode(xf86Screens[scrnIndex], pMode);
+ return renditionSetMode(pScreenInfo, mode);
}
static void
-renditionAdjustFrame(int scrnIndex, int x, int y, int flags)
+renditionAdjustFrame(ADJUST_FRAME_ARGS_DECL)
{
- ScrnInfoPtr pScreenInfo=xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
int offset, virtualwidth, bitsPerPixel;
@@ -1285,9 +1286,9 @@ renditionAdjustFrame(int scrnIndex, int x, int y, int flags)
static Bool
-renditionEnterVT(int scrnIndex, int flags)
+renditionEnterVT(VT_FUNC_ARGS_DECL)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo);
#ifdef DEBUG
@@ -1304,32 +1305,34 @@ renditionEnterVT(int scrnIndex, int flags)
if (!renditionSetMode(pScreenInfo, pScreenInfo->currentMode))
return FALSE;
- (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
- pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
+ (*pScreenInfo->AdjustFrame)(ADJUST_FRAME_ARGS(pScreenInfo,
+ pScreenInfo->frameX0, pScreenInfo->frameY0));
return TRUE;
}
static void
-renditionLeaveVT(int scrnIndex, int flags)
+renditionLeaveVT(VT_FUNC_ARGS_DECL)
{
+ SCRN_INFO_PTR(arg);
#ifdef DEBUG
ErrorF("RENDITION: renditionLeaveVT() called\n");
#endif
- renditionLeaveGraphics(xf86Screens[scrnIndex]);
+ renditionLeaveGraphics(pScreenInfo);
}
static void
-renditionFreeScreen(int scrnIndex, int flags)
+renditionFreeScreen(FREE_SCREEN_ARGS_DECL)
{
- renditionFreeRec(xf86Screens[scrnIndex]);
+ SCRN_INFO_PTR(arg);
+ renditionFreeRec(pScreenInfo);
}
static ModeStatus
-renditionValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose,
+renditionValidMode(SCRN_ARG_TYPE arg, DisplayModePtr pMode, Bool Verbose,
int flags)
{
if (pMode->Flags & V_INTERLACE)
diff --git a/src/rendition.h b/src/rendition.h
index 0ea5cca..7d104a8 100644
--- a/src/rendition.h
+++ b/src/rendition.h
@@ -65,5 +65,6 @@
#include "commonregs.h"
+#include "compat-api.h"
/* end of __RENDITION_H__ */
#endif
diff --git a/src/rendition_shadow.c b/src/rendition_shadow.c
index 5f7a5f5..b5e4ef6 100644
--- a/src/rendition_shadow.c
+++ b/src/rendition_shadow.c
@@ -48,9 +48,9 @@ renditionRefreshArea(ScrnInfoPtr pScreenInfo, int num, BoxPtr pbox)
}
void
-renditionPointerMoved(int index, int x, int y)
+renditionPointerMoved(SCRN_ARG_TYPE arg, int x, int y)
{
- ScrnInfoPtr pScreenInfo = xf86Screens[index];
+ SCRN_INFO_PTR(arg);
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
int newX, newY;
@@ -62,7 +62,7 @@ renditionPointerMoved(int index, int x, int y)
newY = pScreenInfo->pScreen->width - x - 1;
}
- (*pRendition->board.PointerMoved)(index, newX, newY);
+ (*pRendition->board.PointerMoved)(arg, newX, newY);
}
void
diff --git a/src/rendition_shadow.h b/src/rendition_shadow.h
index 5d9634f..d4527a8 100644
--- a/src/rendition_shadow.h
+++ b/src/rendition_shadow.h
@@ -12,7 +12,7 @@ void renditionRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void renditionRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void renditionRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void renditionRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
-void renditionPointerMoved(int index, int x, int y);
+void renditionPointerMoved(SCRN_ARG_TYPE arg, int x, int y);
#endif
diff --git a/src/vmodes.c b/src/vmodes.c
index f2dae0b..ba91d1a 100644
--- a/src/vmodes.c
+++ b/src/vmodes.c
@@ -301,8 +301,8 @@ verite_setmode(ScrnInfoPtr pScreenInfo, struct verite_modeinfo_t *mode)
pRendition->board.mode.virtualwidth=pRendition->board.mode.screenwidth;
pRendition->board.init=1;
- (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
- pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
+ (*pScreenInfo->AdjustFrame)(ADJUST_FRAME_ARGS(pScreenInfo,
+ pScreenInfo->frameX0, pScreenInfo->frameY0));
/* Need to fix up syncs */
diff --git a/src/vtypes.h b/src/vtypes.h
index 3a701f4..5e0abf1 100644
--- a/src/vtypes.h
+++ b/src/vtypes.h
@@ -161,7 +161,7 @@ struct verite_board_t {
Bool shadowfb; /* Use ShadowFB ? */
vu8 *shadowPtr;
vu32 shadowPitch;
- void (*PointerMoved)(int index, int x, int y);
+ void (*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y);
int rotate; /* Rotate clockwise or counterclockwise */