summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/compat-api.h99
-rw-r--r--src/leo.h1
-rw-r--r--src/leo_accel.c2
-rw-r--r--src/leo_cursor.c2
-rw-r--r--src/leo_driver.c46
6 files changed, 126 insertions, 25 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c5c8b92..b25302f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ sunleo_drv_la_LDFLAGS = -module -avoid-version
sunleo_drv_ladir = @moduledir@/drivers
sunleo_drv_la_SOURCES = \
+ compat-api.h \
leo_accel.c \
leo_cursor.c \
leo_driver.c \
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/leo.h b/src/leo.h
index 10f53f7..a5bf41d 100644
--- a/src/leo.h
+++ b/src/leo.h
@@ -32,6 +32,7 @@
#include "leo_regs.h"
#include "xf86sbusBus.h"
+#include "compat-api.h"
/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
#define LEO_FB0_VOFF 0x00000000
#define LEO_LC0_VOFF 0x00800000
diff --git a/src/leo_accel.c b/src/leo_accel.c
index 209cbeb..f276652 100644
--- a/src/leo_accel.c
+++ b/src/leo_accel.c
@@ -68,7 +68,7 @@ int leoRopTable[16] = {
void LeoVtChange (ScreenPtr pScreen, int enter)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
LeoPtr pLeo = GET_LEO_FROM_SCRN (pScrn);
LeoCommand0 *lc0 = pLeo->lc0;
LeoDraw *ld0 = pLeo->ld0;
diff --git a/src/leo_cursor.c b/src/leo_cursor.c
index 0ebbae7..cd926dc 100644
--- a/src/leo_cursor.c
+++ b/src/leo_cursor.c
@@ -125,7 +125,7 @@ LeoSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
Bool
LeoHWCursorInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
LeoPtr pLeo;
xf86CursorInfoPtr infoPtr;
diff --git a/src/leo_driver.c b/src/leo_driver.c
index d509f44..4b7ffb3 100644
--- a/src/leo_driver.c
+++ b/src/leo_driver.c
@@ -42,21 +42,20 @@ static const OptionInfoRec * LeoAvailableOptions(int chipid, int busid);
static void LeoIdentify(int flags);
static Bool LeoProbe(DriverPtr drv, int flags);
static Bool LeoPreInit(ScrnInfoPtr pScrn, int flags);
-static Bool LeoScreenInit(int Index, ScreenPtr pScreen, int argc,
- char **argv);
-static Bool LeoEnterVT(int scrnIndex, int flags);
-static void LeoLeaveVT(int scrnIndex, int flags);
-static Bool LeoCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool LeoScreenInit(SCREEN_INIT_ARGS_DECL);
+static Bool LeoEnterVT(VT_FUNC_ARGS_DECL);
+static void LeoLeaveVT(VT_FUNC_ARGS_DECL);
+static Bool LeoCloseScreen(CLOSE_SCREEN_ARGS_DECL);
static Bool LeoSaveScreen(ScreenPtr pScreen, int mode);
/* Required if the driver supports mode switching */
-static Bool LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+static Bool LeoSwitchMode(SWITCH_MODE_ARGS_DECL);
/* Required if the driver supports moving the viewport */
-static void LeoAdjustFrame(int scrnIndex, int x, int y, int flags);
+static void LeoAdjustFrame(ADJUST_FRAME_ARGS_DECL);
/* Optional functions */
-static void LeoFreeScreen(int scrnIndex, int flags);
-static ModeStatus LeoValidMode(int scrnIndex, DisplayModePtr mode,
+static void LeoFreeScreen(FREE_SCREEN_ARGS_DECL);
+static ModeStatus LeoValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode,
Bool verbose, int flags);
void LeoSync(ScrnInfoPtr pScrn);
@@ -453,7 +452,7 @@ LeoPreInit(ScrnInfoPtr pScrn, int flags)
/* This gets called at the start of each server generation */
static Bool
-LeoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+LeoScreenInit(SCREEN_INIT_ARGS_DECL)
{
ScrnInfoPtr pScrn;
LeoPtr pLeo;
@@ -464,7 +463,7 @@ LeoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/*
* First get the ScrnInfoRec
*/
- pScrn = xf86Screens[pScreen->myNum];
+ pScrn = xf86ScreenToScrn(pScreen);
pLeo = GET_LEO_FROM_SCRN(pScrn);
@@ -575,7 +574,7 @@ LeoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Usually mandatory */
static Bool
-LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+LeoSwitchMode(SWITCH_MODE_ARGS_DECL)
{
return TRUE;
}
@@ -587,7 +586,7 @@ LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
*/
/* Usually mandatory */
static void
-LeoAdjustFrame(int scrnIndex, int x, int y, int flags)
+LeoAdjustFrame(ADJUST_FRAME_ARGS_DECL)
{
/* we don't support virtual desktops */
return;
@@ -602,9 +601,9 @@ extern void LeoVtChange (ScreenPtr pScreen, int enter);
/* Mandatory */
static Bool
-LeoEnterVT(int scrnIndex, int flags)
+LeoEnterVT(VT_FUNC_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
pLeo->vtSema = FALSE;
@@ -621,9 +620,9 @@ LeoEnterVT(int scrnIndex, int flags)
/* Mandatory */
static void
-LeoLeaveVT(int scrnIndex, int flags)
+LeoLeaveVT(VT_FUNC_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ SCRN_INFO_PTR(arg);
LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
LeoVtChange (pScrn->pScreen, FALSE);
@@ -638,9 +637,9 @@ LeoLeaveVT(int scrnIndex, int flags)
/* Mandatory */
static Bool
-LeoCloseScreen(int scrnIndex, ScreenPtr pScreen)
+LeoCloseScreen(CLOSE_SCREEN_ARGS_DECL)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
pScrn->vtSema = FALSE;
@@ -650,7 +649,7 @@ LeoCloseScreen(int scrnIndex, ScreenPtr pScreen)
xf86SbusHideOsHwCursor (pLeo->psdp);
pScreen->CloseScreen = pLeo->CloseScreen;
- return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
return FALSE;
}
@@ -659,9 +658,10 @@ LeoCloseScreen(int scrnIndex, ScreenPtr pScreen)
/* Optional */
static void
-LeoFreeScreen(int scrnIndex, int flags)
+LeoFreeScreen(FREE_SCREEN_ARGS_DECL)
{
- LeoFreeRec(xf86Screens[scrnIndex]);
+ SCRN_INFO_PTR(pScrn);
+ LeoFreeRec(pScrn);
}
@@ -669,7 +669,7 @@ LeoFreeScreen(int scrnIndex, int flags)
/* Optional */
static ModeStatus
-LeoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+LeoValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
{
if (mode->Flags & V_INTERLACE)
return(MODE_BAD);