diff options
author | Dave Airlie <airlied@gmail.com> | 2012-07-13 14:56:12 +1000 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2012-07-13 15:09:01 +1000 |
commit | 01bdd7d3d18f5d5c94aa99ccd7677f5928b37392 (patch) | |
tree | a07600347008e0d4bb2dbd2db55352ae682e5c28 | |
parent | d63d7c600cb3927a5a2a5e223252cfd9a44112d4 (diff) |
apm: initial compat api
Port to new server compat API.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | src/apm.h | 6 | ||||
-rw-r--r-- | src/apm_dga.c | 8 | ||||
-rw-r--r-- | src/apm_driver.c | 59 | ||||
-rw-r--r-- | src/compat-api.h | 99 |
4 files changed, 136 insertions, 36 deletions
@@ -43,6 +43,7 @@ #include "xf86xv.h" #include <X11/extensions/Xv.h> +#include "compat-api.h" #ifdef TRUE #undef TRUE #endif @@ -218,9 +219,8 @@ extern void XFree86RushExtensionInit(ScreenPtr pScreen); extern void ApmInitVideo(ScreenPtr pScreen); extern void ApmInitVideo_IOP(ScreenPtr pScreen); extern void ApmSetupXAAInfo(ApmPtr pApm, XAAInfoRecPtr pXAAinfo); -extern Bool ApmSwitchMode(int scrnIndex, DisplayModePtr mode, - int flags); -extern void ApmAdjustFrame(int scrnIndex, int x, int y, int flags); +extern Bool ApmSwitchMode(SWITCH_MODE_ARGS_DECL); +extern void ApmAdjustFrame(ADJUST_FRAME_ARGS_DECL); extern void ApmHWCursorReserveSpace(ApmPtr pApm); extern void ApmAccelReserveSpace(ApmPtr pApm); diff --git a/src/apm_dga.c b/src/apm_dga.c index d250251..fa94006 100644 --- a/src/apm_dga.c +++ b/src/apm_dga.c @@ -243,8 +243,8 @@ ApmSetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) } pScrn->currentMode = pApm->CurrentLayout.pMode; - ApmSwitchMode(index, pScrn->currentMode, 0); - ApmAdjustFrame(index, pScrn->frameX0, pScrn->frameY0, 0); + ApmSwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode)); + ApmAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); #if 0 if (pApm->AccelInfoRec) XAAInit(pScrn->pScreen, pApm->AccelInfoRec); @@ -269,7 +269,7 @@ ApmSetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) else pApm->CurrentLayout.mask32 = 32 / pMode->bitsPerPixel - 1; - ApmSwitchMode(index, pMode->mode, 0); + ApmSwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode)); ApmSetupXAAInfo(pApm, NULL); #if 0 @@ -321,7 +321,7 @@ ApmSetViewport( ApmWriteSeq(0x1C, 0x2F); pApm->apmLock = FALSE; } - pScrn->AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y)); if (pApm->VGAMap) { /* Wait until vertical retrace is in progress. */ while (APMVGAB(0x3DA) & 0x08); diff --git a/src/apm_driver.c b/src/apm_driver.c index c35f489..0f20eb6 100644 --- a/src/apm_driver.c +++ b/src/apm_driver.c @@ -42,13 +42,12 @@ static const OptionInfoRec * ApmAvailableOptions(int chipid, int busid); static void ApmIdentify(int flags); static Bool ApmProbe(DriverPtr drv, int flags); static Bool ApmPreInit(ScrnInfoPtr pScrn, int flags); -static Bool ApmScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool ApmEnterVT(int scrnIndex, int flags); -static void ApmLeaveVT(int scrnIndex, int flags); -static Bool ApmCloseScreen(int scrnIndex, ScreenPtr pScreen); -static void ApmFreeScreen(int scrnIndex, int flags); -static ModeStatus ApmValidMode(int scrnIndex, DisplayModePtr mode, +static Bool ApmScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool ApmEnterVT(VT_FUNC_ARGS_DECL); +static void ApmLeaveVT(VT_FUNC_ARGS_DECL); +static Bool ApmCloseScreen(CLOSE_SCREEN_ARGS_DECL); +static void ApmFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus ApmValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); static Bool ApmSaveScreen(ScreenPtr pScreen, int mode); static void ApmUnlock(ApmPtr pApm); @@ -787,11 +786,11 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"I2C initialization failed\n"); } else { - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pApm->I2CPtr); + MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn),pApm->I2CPtr); } } if (0 && !MonInfo) - MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex,vgaHWddc1SetSpeed,ddc1Read); + MonInfo = xf86DoEDID_DDC1(XF86_SCRN_ARG(pScrn),vgaHWddc1SetSpeed,ddc1Read); if (MonInfo) { xf86PrintEDID(MonInfo); xf86SetDDCproperties(pScrn, MonInfo); @@ -1651,9 +1650,9 @@ ApmRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) /* This gets called at the start of each server generation */ static Bool -ApmScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +ApmScreenInit(SCREEN_INIT_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); APMDECL(pScrn); int ret; unsigned char *FbBase; @@ -1676,7 +1675,7 @@ ApmScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ ApmSaveScreen(pScreen, SCREEN_SAVER_ON); - ApmAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + ApmAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); /* * Reset fb's visual list. @@ -1733,7 +1732,7 @@ ApmScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->displayWidth, pScrn->bitsPerPixel); break; default: - xf86DrvMsg(scrnIndex, X_ERROR, + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) in ApmScrnInit\n", pScrn->bitsPerPixel); ret = FALSE; @@ -1876,9 +1875,10 @@ ApmLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, /* Usually mandatory */ Bool -ApmSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +ApmSwitchMode(SWITCH_MODE_ARGS_DECL) { - return ApmModeInit(xf86Screens[scrnIndex], mode); + SCRN_INFO_PTR(arg); + return ApmModeInit(pScrn, mode); } /* @@ -1887,9 +1887,9 @@ ApmSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) */ /* Usually mandatory */ void -ApmAdjustFrame(int scrnIndex, int x, int y, int flags) +ApmAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); APMDECL(pScrn); int Base; @@ -1930,9 +1930,9 @@ ApmAdjustFrame(int scrnIndex, int x, int y, int flags) /* Mandatory */ static Bool -ApmEnterVT(int scrnIndex, int flags) +ApmEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); APMDECL(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -1952,16 +1952,16 @@ ApmEnterVT(int scrnIndex, int flags) if (!ApmModeInit(pScrn, pScrn->currentMode)) return FALSE; - ApmAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + ApmAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); return TRUE; } /* Mandatory */ static void -ApmLeaveVT(int scrnIndex, int flags) +ApmLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); APMDECL(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -1991,9 +1991,9 @@ ApmLeaveVT(int scrnIndex, int flags) /* Mandatory */ static Bool -ApmCloseScreen(int scrnIndex, ScreenPtr pScreen) +ApmCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); vgaHWPtr hwp = VGAHWPTR(pScrn); APMDECL(pScrn); @@ -2021,24 +2021,25 @@ ApmCloseScreen(int scrnIndex, ScreenPtr pScreen) #endif pScreen->CloseScreen = pApm->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } /* Free up any per-generation data structures */ /* Optional */ static void -ApmFreeScreen(int scrnIndex, int flags) +ApmFreeScreen(FREE_SCREEN_ARGS_DECL) { - vgaHWFreeHWRec(xf86Screens[scrnIndex]); - ApmFreeRec(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + vgaHWFreeHWRec(pScrn); + ApmFreeRec(pScrn); } /* Checks if a mode is suitable for the selected chipset. */ /* Optional */ static ModeStatus -ApmValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +ApmValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { if (mode->Flags & V_INTERLACE) return(MODE_BAD); diff --git a/src/compat-api.h b/src/compat-api.h new file mode 100644 index 0000000..205ac59 --- /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 scrnIndex, 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 |