Add compat-api.h for compatibility with xserver 1.13

This commit is contained in:
matthieu 2012-09-09 11:42:57 +00:00
parent bbe9035b7f
commit 786d76b97a
3 changed files with 125 additions and 23 deletions

View File

@ -29,4 +29,5 @@ wsudl_drv_la_LDFLAGS = -module -avoid-version
wsudl_drv_ladir = @moduledir@/drivers
wsudl_drv_la_SOURCES = \
wsudl_driver.c
wsudl_driver.c \
compat_api.h

View File

@ -0,0 +1,98 @@
/*
* 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 SCRN_OR_INDEX_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 SCRN_OR_INDEX_ARG(x) (x)
#endif
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wsudl_driver.c,v 1.8 2011/11/05 14:55:09 matthieu Exp $ */
/* $OpenBSD: wsudl_driver.c,v 1.9 2012/09/09 11:42:57 matthieu Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@ -84,6 +84,8 @@
#include "damage.h"
#include "compat-api.h"
/*
* Debugging.
*/
@ -107,12 +109,13 @@ static Bool WsudlGetRec(ScrnInfoPtr);
static void WsudlFreeRec(ScrnInfoPtr);
static const OptionInfoRec * WsudlAvailableOptions(int, int);
static Bool WsudlCreateScreenResources(ScreenPtr);
static Bool WsudlScreenInit(int, ScreenPtr, int, char **);
static Bool WsudlCloseScreen(int, ScreenPtr);
static Bool WsudlSwitchMode(int, DisplayModePtr, int);
static Bool WsudlEnterVT(int, int);
static void WsudlLeaveVT(int, int);
static int WsudlValidMode(int, DisplayModePtr, Bool, int);
static Bool WsudlScreenInit(SCREEN_INIT_ARGS_DECL);
static Bool WsudlCloseScreen(CLOSE_SCREEN_ARGS_DECL);
static Bool WsudlSwitchMode(SWITCH_MODE_ARGS_DECL);
static Bool WsudlEnterVT(VT_FUNC_ARGS_DECL);
static void WsudlLeaveVT(VT_FUNC_ARGS_DECL);
static int WsudlValidMode(SCRN_ARG_TYPE, DisplayModePtr,
Bool, int);
static void WsudlLoadPalette(ScrnInfoPtr, int, int *,
LOCO *, VisualPtr);
static Bool WsudlSaveScreen(ScreenPtr, int);
@ -122,7 +125,7 @@ static void WsudlBlockHandler(pointer, struct timeval **,
pointer);
static void WsudlWakeupHandler(pointer, int, pointer);
/* helper functions */
static int wsudl_open(char *);
static int wsudl_open(const char *);
/*
* Respect privilege seperation when opening device nodes.
@ -287,7 +290,7 @@ WsudlProbe(DriverPtr drv, int flags)
int numDevSections;
Bool foundScreen = FALSE;
GDevPtr *devSections;
char *dev;
const char *dev;
DEBUGP("WsudlProbe");
@ -337,7 +340,7 @@ static Bool
WsudlPreInit(ScrnInfoPtr pScrn, int flags)
{
WsudlPtr fPtr;
char *dev;
const char *dev;
int r, wstype, defaultDepth, flags24;
Gamma zeros = { 0.0, 0.0, 0.0 };
DisplayModePtr mode;
@ -522,7 +525,7 @@ WsudlAvailableOptions(int chipid, int busid)
static Bool
WsudlCreateScreenResources(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
WsudlPtr fPtr = WSUDLPTR(pScrn);
PixmapPtr pPixmap;
Bool r;
@ -553,10 +556,10 @@ WsudlCreateScreenResources(ScreenPtr pScreen)
}
static Bool
WsudlScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
WsudlScreenInit(SCREEN_INIT_ARGS_DECL)
{
int r, wsmode, flags, ncolors;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
WsudlPtr fPtr = WSUDLPTR(pScrn);
VisualPtr visual;
@ -636,7 +639,7 @@ WsudlScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* do damage initialization */
if (!WsudlDamageInit(pScreen)) {
xf86DrvMsg(scrnIndex, X_ERROR,
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"damage initialization failed\n");
return (FALSE);
}
@ -672,9 +675,9 @@ WsudlScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
static Bool
WsudlCloseScreen(int scrnIndex, ScreenPtr pScreen)
WsudlCloseScreen(CLOSE_SCREEN_ARGS_DECL)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
WsudlPtr fPtr = WSUDLPTR(pScrn);
DEBUGP("WsudlCloseScreen");
@ -694,11 +697,11 @@ WsudlCloseScreen(int scrnIndex, ScreenPtr pScreen)
/* unwrap CloseScreen */
pScreen->CloseScreen = fPtr->CloseScreen;
return ((*pScreen->CloseScreen)(scrnIndex, pScreen));
return ((*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS));
}
static Bool
WsudlSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
WsudlSwitchMode(SWITCH_MODE_ARGS_DECL)
{
DEBUGP("WsudlSwitchMode");
@ -706,7 +709,7 @@ WsudlSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
}
static Bool
WsudlEnterVT(int scrnIndex, int flags)
WsudlEnterVT(VT_FUNC_ARGS_DECL)
{
DEBUGP("WsudlEnterVT (TODO)");
@ -716,7 +719,7 @@ WsudlEnterVT(int scrnIndex, int flags)
}
static void
WsudlLeaveVT(int scrnIndex, int flags)
WsudlLeaveVT(VT_FUNC_ARGS_DECL)
{
DEBUGP("WsudlLeaveVT (TODO)");
@ -724,7 +727,7 @@ WsudlLeaveVT(int scrnIndex, int flags)
}
static int
WsudlValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
WsudlValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
{
DEBUGP("WsudlValidMode");
@ -855,7 +858,7 @@ WsudlWakeupHandler(pointer data, int i, pointer LastSelectMask)
}
static int
wsudl_open(char *dev)
wsudl_open(const char *dev)
{
int fd = -1;