diff options
author | Dave Airlie <airlied@redhat.com> | 2012-06-06 12:00:14 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-06-06 12:00:14 +0100 |
commit | 1af03ed39b6692231544e5c7b8325fa8d70c728d (patch) | |
tree | 3abf9399a50a62fdc5f851bd50bde21712ce855d /src | |
parent | f981caeb7ebf53fea9d8f852edea6605d44d975e (diff) |
ast: port to new compat API.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/ast.h | 2 | ||||
-rw-r--r-- | src/ast_2dtool.c | 2 | ||||
-rw-r--r-- | src/ast_accel.c | 2 | ||||
-rw-r--r-- | src/ast_cursor.c | 4 | ||||
-rw-r--r-- | src/ast_driver.c | 68 | ||||
-rw-r--r-- | src/compat-api.h | 99 |
7 files changed, 141 insertions, 39 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4cd7075..dd6ca3d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,4 +42,5 @@ ast_drv_la_SOURCES = \ ast_pcirename.h \ ast_tool.c \ ast_vgatool.c \ - ast_vgatool.h + ast_vgatool.h \ + compat-api.h @@ -25,6 +25,8 @@ #include "ast_pcirename.h" +#include "compat-api.h" + /* Compiler Options */ #define Accel_2D /* #define MMIO_2D */ diff --git a/src/ast_2dtool.c b/src/ast_2dtool.c index 7e54370..ba58a08 100644 --- a/src/ast_2dtool.c +++ b/src/ast_2dtool.c @@ -82,7 +82,7 @@ bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST) if (!pAST->MMIO2D) { pAST->CMDQInfo.ulCMDQType = VM_CMD_QUEUE; - pScreen = screenInfo.screens[pScrn->scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); do { pAST->pCMDQPtr = xf86AllocateOffscreenLinear (pScreen, pAST->CMDQInfo.ulCMDQSize, 8, NULL, NULL, NULL); diff --git a/src/ast_accel.c b/src/ast_accel.c index 2d3dab3..f85692b 100644 --- a/src/ast_accel.c +++ b/src/ast_accel.c @@ -162,7 +162,7 @@ Bool ASTAccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ASTRecPtr pAST = ASTPTR(pScrn); pAST->AccelInfoPtr = infoPtr = XAACreateInfoRec(); diff --git a/src/ast_cursor.c b/src/ast_cursor.c index b3f2061..4fcbf95 100644 --- a/src/ast_cursor.c +++ b/src/ast_cursor.c @@ -76,7 +76,7 @@ static void ASTSetCursorPosition_AST1180(ScrnInfoPtr pScrn, int x, int y); Bool ASTCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ASTRecPtr pAST = ASTPTR(pScrn); xf86CursorInfoPtr infoPtr; @@ -126,7 +126,7 @@ Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST) /* allocate HWC cache */ if (!pAST->pHWCPtr) { - pScreen = screenInfo.screens[pScrn->scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); pAST->pHWCPtr = xf86AllocateOffscreenLinear (pScreen, (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM, HWC_ALIGN, NULL, NULL, NULL); if (!pAST->pHWCPtr) { diff --git a/src/ast_driver.c b/src/ast_driver.c index 7c0095f..7d7c035 100644 --- a/src/ast_driver.c +++ b/src/ast_driver.c @@ -98,19 +98,19 @@ static void ASTIdentify(int flags); const OptionInfoRec *ASTAvailableOptions(int chipid, int busid); static Bool ASTProbe(DriverPtr drv, int flags); static Bool ASTPreInit(ScrnInfoPtr pScrn, int flags); -static Bool ASTScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); -Bool ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -void ASTAdjustFrame(int scrnIndex, int x, int y, int flags); -static Bool ASTEnterVT(int scrnIndex, int flags); -static void ASTLeaveVT(int scrnIndex, int flags); -static void ASTFreeScreen(int scrnIndex, int flags); -static ModeStatus ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); +static Bool ASTScreenInit(SCREEN_INIT_ARGS_DECL); +Bool ASTSwitchMode(SWITCH_MODE_ARGS_DECL); +void ASTAdjustFrame(ADJUST_FRAME_ARGS_DECL); +static Bool ASTEnterVT(VT_FUNC_ARGS_DECL); +static void ASTLeaveVT(VT_FUNC_ARGS_DECL); +static void ASTFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus ASTValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); /* Internally used functions */ static Bool ASTGetRec(ScrnInfoPtr pScrn); static void ASTFreeRec(ScrnInfoPtr pScrn); static Bool ASTSaveScreen(ScreenPtr pScreen, Bool unblack); -static Bool ASTCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool ASTCloseScreen(CLOSE_SCREEN_ARGS_DECL); static void ASTSave(ScrnInfoPtr pScrn); static void ASTRestore(ScrnInfoPtr pScrn); static void ASTProbeDDC(ScrnInfoPtr pScrn, int index); @@ -775,7 +775,7 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags) static Bool -ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +ASTScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; ASTRecPtr pAST; @@ -784,7 +784,7 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) BoxRec FBMemBox; int AvailFBSize; - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); pAST = ASTPTR(pScrn); if (!ASTMapMem(pScrn)) { @@ -829,7 +829,7 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } ASTSaveScreen(pScreen, FALSE); - ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + ASTAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); miClearVisualTypes(); @@ -937,9 +937,9 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) Bool -ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +ASTSwitchMode(SWITCH_MODE_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ASTRecPtr pAST = ASTPTR(pScrn); /* VideoMode validate */ @@ -977,9 +977,9 @@ ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) } void -ASTAdjustFrame(int scrnIndex, int x, int y, int flags) +ASTAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ASTRecPtr pAST = ASTPTR(pScrn); ULONG base; @@ -992,9 +992,9 @@ ASTAdjustFrame(int scrnIndex, int x, int y, int flags) /* enter into X Server */ static Bool -ASTEnterVT(int scrnIndex, int flags) +ASTEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ASTRecPtr pAST = ASTPTR(pScrn); /* Fixed suspend can't resume issue */ @@ -1009,7 +1009,7 @@ ASTEnterVT(int scrnIndex, int flags) if (!ASTModeInit(pScrn, pScrn->currentMode)) return FALSE; - ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + ASTAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); return TRUE; @@ -1017,10 +1017,10 @@ ASTEnterVT(int scrnIndex, int flags) /* leave X server */ static void -ASTLeaveVT(int scrnIndex, int flags) +ASTLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ASTRecPtr pAST = ASTPTR(pScrn); #if !(defined(__sparc__)) && !(defined(__mips__)) vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -1054,20 +1054,20 @@ ASTLeaveVT(int scrnIndex, int flags) } static void -ASTFreeScreen(int scrnIndex, int flags) +ASTFreeScreen(FREE_SCREEN_ARGS_DECL) { - ASTFreeRec(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + ASTFreeRec(pScrn); #if !(defined(__sparc__)) && !(defined(__mips__)) if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); + vgaHWFreeHWRec(pScrn); #endif } static ModeStatus -ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +ASTValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { - - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ASTRecPtr pAST = ASTPTR(pScrn); ModeStatus Flags = MODE_NOMODE; UCHAR jReg; @@ -1075,7 +1075,7 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) if (mode->Flags & V_INTERLACE) { if (verbose) { - xf86DrvMsg(scrnIndex, X_PROBED, + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Removing interlaced mode \"%s\"\n", mode->name); } return MODE_NO_INTERLACE; @@ -1083,7 +1083,7 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) if ((mode->CrtcHDisplay > MAX_HResolution) || (mode->CrtcVDisplay > MAX_VResolution)) { if (verbose) { - xf86DrvMsg(scrnIndex, X_PROBED, + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Removing the mode \"%s\"\n", mode->name); } return Flags; @@ -1195,7 +1195,7 @@ ASTSaveScreen(ScreenPtr pScreen, Bool unblack) ScrnInfoPtr pScrn = NULL; if (pScreen != NULL) - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); if ((pScrn != NULL) && pScrn->vtSema) { ASTBlankScreen(pScrn, unblack); @@ -1205,9 +1205,9 @@ ASTSaveScreen(ScreenPtr pScreen, Bool unblack) } static Bool -ASTCloseScreen(int scrnIndex, ScreenPtr pScreen) +ASTCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ASTRecPtr pAST = ASTPTR(pScrn); #if !(defined(__sparc__)) && !(defined(__mips__)) vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -1258,7 +1258,7 @@ ASTCloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = pAST->CloseScreen; - return (*pScreen->CloseScreen) (scrnIndex, pScreen); + return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS); } static void @@ -2142,7 +2142,7 @@ static int ASTPutImage(ScrnInfoPtr pScrn, static XF86VideoAdaptorPtr ASTSetupImageVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ASTPtr pAST = ASTPTR(pScrn); XF86VideoAdaptorPtr adapt; ASTPortPrivPtr pPriv; @@ -2221,7 +2221,7 @@ static XF86VideoAdaptorPtr ASTSetupImageVideo(ScreenPtr pScreen) void ASTInitVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr ASTAdaptor = NULL; int num_adaptors; 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 |