diff options
author | Dave Airlie <airlied@redhat.com> | 2012-06-06 11:22:29 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-06-06 11:22:29 +0100 |
commit | a2714fb09e1e0badbb3e98e24d4b1ed92003bdb9 (patch) | |
tree | 80a4688783ad46e33fc90e8c014f6a32f41e8c42 | |
parent | de22eab9a21df80fe965dc37d21ba3ac2b9f5fd0 (diff) |
savage: port to new compat API
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compat-api.h | 105 | ||||
-rw-r--r-- | src/savage_accel.c | 2 | ||||
-rw-r--r-- | src/savage_cursor.c | 4 | ||||
-rw-r--r-- | src/savage_dga.c | 8 | ||||
-rw-r--r-- | src/savage_dri.c | 48 | ||||
-rw-r--r-- | src/savage_driver.c | 91 | ||||
-rw-r--r-- | src/savage_driver.h | 10 | ||||
-rw-r--r-- | src/savage_exa.c | 14 | ||||
-rw-r--r-- | src/savage_hwmc.c | 2 | ||||
-rw-r--r-- | src/savage_shadow.c | 6 | ||||
-rw-r--r-- | src/savage_video.c | 10 | ||||
-rw-r--r-- | src/savage_xaa.c | 2 |
13 files changed, 201 insertions, 102 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e980c1a..52fdf9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,7 @@ savage_drv_la_LDFLAGS = -module -avoid-version savage_drv_ladir = @moduledir@/drivers savage_drv_la_SOURCES = \ + compat-api.h \ savage_accel.c \ savage_xaa.c \ savage_exa.c \ diff --git a/src/compat-api.h b/src/compat-api.h new file mode 100644 index 0000000..98ba435 --- /dev/null +++ b/src/compat-api.h @@ -0,0 +1,105 @@ +/* + * 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 WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask +#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask + +#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 WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask +#define WAKEUPHANDLER_ARGS arg, result, read_mask + +#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/savage_accel.c b/src/savage_accel.c index 0920e22..1bcb5fa 100644 --- a/src/savage_accel.c +++ b/src/savage_accel.c @@ -1274,7 +1274,7 @@ void SavageRestoreAccelState(ScrnInfoPtr pScrn) Bool SavageInitAccel(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); #ifdef SAVAGEDRI diff --git a/src/savage_cursor.c b/src/savage_cursor.c index 6364293..3506f3a 100644 --- a/src/savage_cursor.c +++ b/src/savage_cursor.c @@ -83,7 +83,7 @@ static void SavageSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); static Bool SavageUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) { - ScrnInfoPtr pScrn = xf86Screens[pScr->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScr); SavagePtr psav = SAVPTR(pScrn); if (psav->PanelX != pScrn->currentMode->HDisplay @@ -100,7 +100,7 @@ SavageUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) Bool SavageHWCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); xf86CursorInfoPtr infoPtr; diff --git a/src/savage_dga.c b/src/savage_dga.c index 1c4d884..cb541d3 100644 --- a/src/savage_dga.c +++ b/src/savage_dga.c @@ -202,7 +202,7 @@ SECOND_PASS: Bool SavageDGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); DGAModePtr modes = NULL; int num = 0; @@ -276,7 +276,7 @@ Savage_SetMode( pScrn->currentMode = OldMode[index]; psav->DGAactive = FALSE; - SavageSwitchMode(index, pScrn->currentMode, 0); + SavageSwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode)); if( psav->hwcursor && psav->hwc_on ) SavageShowCursor(pScrn); } else { @@ -312,7 +312,7 @@ Savage_SetMode( (pMode->bitsPerPixel >> 3); /* psav->UseBIOS = FALSE; */ - SavageSwitchMode(index, pMode->mode, 0); + SavageSwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode)); psav->UseBIOS = holdBIOS; } @@ -337,7 +337,7 @@ Savage_SetViewport( ){ SavagePtr psav = SAVPTR(pScrn); - SavageAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + SavageAdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y)); psav->DGAViewportStatus = 0; /* MGAAdjustFrame loops until finished */ } diff --git a/src/savage_dri.c b/src/savage_dri.c index 38d2a86..7b5d2b1 100644 --- a/src/savage_dri.c +++ b/src/savage_dri.c @@ -104,7 +104,7 @@ SAVAGEDRISubsequentScreenToScreenCopy( */ static Bool SAVAGEInitVisualConfigs( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); int numConfigs = 0; __GLXvisualConfig *pConfigs = 0; @@ -243,7 +243,7 @@ static Bool SAVAGECreateContext( ScreenPtr pScreen, VisualPtr visual, drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); if(psav->xvmcContext) @@ -259,21 +259,20 @@ static Bool SAVAGECreateContext( ScreenPtr pScreen, VisualPtr visual, static void SAVAGEDestroyContext( ScreenPtr pScreen, drm_context_t hwContext, DRIContextType contextStore ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); psav->DRIrunning--; } -static void SAVAGEWakeupHandler( int screenNum, pointer wakeupData, - unsigned long result, pointer pReadmask ) +static void SAVAGEWakeupHandler(WAKEUPHANDLER_ARGS_DECL) { - ScreenPtr pScreen = screenInfo.screens[screenNum]; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SCREEN_PTR(arg); + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); psav->pDRIInfo->wrap.WakeupHandler = psav->coreWakeupHandler; - (*psav->pDRIInfo->wrap.WakeupHandler) (screenNum, wakeupData, result, pReadmask); + (*psav->pDRIInfo->wrap.WakeupHandler) (WAKEUPHANDLER_ARGS); psav->pDRIInfo->wrap.WakeupHandler = SAVAGEWakeupHandler; psav->LockHeld = 1; if (psav->ShadowStatus) { @@ -293,11 +292,10 @@ static void SAVAGEWakeupHandler( int screenNum, pointer wakeupData, /* FK: this flag doesn't seem to be used. */ } -static void SAVAGEBlockHandler( int screenNum, pointer blockData, - pointer pTimeout, pointer pReadmask) +static void SAVAGEBlockHandler(BLOCKHANDLER_ARGS_DECL) { - ScreenPtr pScreen = screenInfo.screens[screenNum]; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SCREEN_PTR(arg); + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); if (psav->ShadowStatus) { @@ -316,7 +314,7 @@ static void SAVAGEBlockHandler( int screenNum, pointer blockData, } psav->LockHeld = 0; psav->pDRIInfo->wrap.BlockHandler = psav->coreBlockHandler; - (*psav->pDRIInfo->wrap.BlockHandler) (screenNum, blockData, pTimeout, pReadmask); + (*psav->pDRIInfo->wrap.BlockHandler) (BLOCKHANDLER_ARGS); psav->pDRIInfo->wrap.BlockHandler = SAVAGEBlockHandler; } @@ -395,7 +393,7 @@ static Bool SAVAGESetAgpMode(SavagePtr psav, ScreenPtr pScreen) static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; unsigned int offset; @@ -586,7 +584,7 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) static Bool SAVAGEDRIMapInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; @@ -688,7 +686,7 @@ static Bool SAVAGEDRIMapInit( ScreenPtr pScreen ) static Bool SAVAGEDRIBuffersInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; int count; @@ -736,7 +734,7 @@ static Bool SAVAGEDRIBuffersInit( ScreenPtr pScreen ) static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; drmSAVAGEInit init; @@ -791,7 +789,7 @@ static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen ) Bool SAVAGEDRIScreenInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); DRIInfoPtr pDRIInfo; SAVAGEDRIPtr pSAVAGEDRI; @@ -1069,7 +1067,7 @@ static void SAVAGEDRISetupTiledSurfaceRegs( SavagePtr psav ) Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate; @@ -1234,7 +1232,7 @@ Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen ) void SAVAGEDRIResume(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGESAREAPrivPtr pSAREAPriv = (SAVAGESAREAPrivPtr)DRIGetSAREAPrivate(pScreen); @@ -1250,7 +1248,7 @@ void SAVAGEDRIResume(ScreenPtr pScreen) void SAVAGEDRICloseScreen( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; @@ -1346,7 +1344,7 @@ void SAVAGEDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) { ScreenPtr pScreen = pWin->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); BoxPtr pbox = REGION_RECTS(prgn); int nbox = REGION_NUM_RECTS(prgn); @@ -1396,7 +1394,7 @@ SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index) { ScreenPtr pScreen = pParent->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); int nbox; BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; @@ -1613,7 +1611,7 @@ SAVAGEDRISubsequentScreenToScreenCopy( static Bool SAVAGEDRIOpenFullScreen(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); vgaHWPtr hwp = VGAHWPTR(pScrn); SavagePtr psav = SAVPTR(pScrn); unsigned int vgaCRIndex = hwp->IOBase + 4; @@ -1678,7 +1676,7 @@ SAVAGEDRIOpenFullScreen(ScreenPtr pScreen) static Bool SAVAGEDRICloseFullScreen(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); BCI_GET_PTR; diff --git a/src/savage_driver.c b/src/savage_driver.c index 5e4ca0e..1083d65 100644 --- a/src/savage_driver.c +++ b/src/savage_driver.c @@ -73,7 +73,6 @@ #include "savage_sarea.h" #endif - /* * prototypes */ @@ -91,25 +90,24 @@ static int LookupChipID(PciChipsets* pset, int ChipID); #endif static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags); -static Bool SavageEnterVT(int scrnIndex, int flags); -static void SavageLeaveVT(int scrnIndex, int flags); +static Bool SavageEnterVT(VT_FUNC_ARGS_DECL); +static void SavageLeaveVT(VT_FUNC_ARGS_DECL); static void SavageSave(ScrnInfoPtr pScrn); static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr, SavageRegPtr, Bool); static void SavageInitStatus(ScrnInfoPtr pScrn); static void SavageInitShadowStatus(ScrnInfoPtr pScrn); -static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, - char **argv); -static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen); -static ModeStatus SavageValidMode(int index, DisplayModePtr mode, +static Bool SavageScreenInit(SCREEN_INIT_ARGS_DECL); +static int SavageInternalScreenInit(ScreenPtr pScreen); +static ModeStatus SavageValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); void SavageDGAInit(ScreenPtr); static Bool SavageMapMem(ScrnInfoPtr pScrn); static void SavageUnmapMem(ScrnInfoPtr pScrn, int All); static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SavageCloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool SavageSaveScreen(ScreenPtr pScreen, int mode); static void SavageLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, @@ -125,7 +123,7 @@ static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1, void SavageGEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file); void SavagePrintRegs(ScrnInfoPtr pScrn); static void SavageDPMS(ScrnInfoPtr pScrn, int mode, int flags); -static Bool SavageDDC1(int scrnIndex); +static Bool SavageDDC1(ScrnInfoPtr pScrn); static unsigned int SavageDDC1Read(ScrnInfoPtr pScrn); static void SavageProbeDDC(ScrnInfoPtr pScrn, int index); static void SavageGetTvMaxSize(SavagePtr psav); @@ -899,7 +897,7 @@ static void SavageDoDDC(ScrnInfoPtr pScrn) break; } - if (!SavageDDC1(pScrn->scrnIndex)) { + if (!SavageDDC1(pScrn)) { /* DDC1 failed,switch to DDC2 */ if (xf86LoadSubModule(pScrn, "i2c")) { if (SavageI2CInit(pScrn)) { @@ -908,7 +906,7 @@ static void SavageDoDDC(ScrnInfoPtr pScrn) InI2CREG(tmp,psav->DDCPort); OutI2CREG(tmp | 0x13,psav->DDCPort); - pMon = xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex,psav->I2C)); + pMon = xf86PrintEDID(xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn),psav->I2C)); if (!psav->IgnoreEDID) xf86SetDDCproperties(pScrn, pMon); OutI2CREG(tmp,psav->DDCPort); } @@ -2198,22 +2196,20 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) } -static Bool SavageEnterVT(int scrnIndex, int flags) +static Bool SavageEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); #ifdef SAVAGEDRI SavagePtr psav = SAVPTR(pScrn); ScreenPtr pScreen; #endif - TRACE(("SavageEnterVT(%d)\n", flags)); - gpScrn = pScrn; SavageEnableMMIO(pScrn); #ifdef SAVAGEDRI if (psav->directRenderingEnabled) { - pScreen = screenInfo.screens[scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); SAVAGEDRIResume(pScreen); DRIUnlock(pScreen); psav->LockHeld = 0; @@ -2232,9 +2228,9 @@ static Bool SavageEnterVT(int scrnIndex, int flags) } -static void SavageLeaveVT(int scrnIndex, int flags) +static void SavageLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); vgaHWPtr hwp = VGAHWPTR(pScrn); SavagePtr psav = SAVPTR(pScrn); vgaRegPtr vgaSavePtr = &hwp->SavedReg; @@ -2248,7 +2244,7 @@ static void SavageLeaveVT(int scrnIndex, int flags) #ifdef SAVAGEDRI if (psav->directRenderingEnabled) { - pScreen = screenInfo.screens[scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); DRILock(pScreen, 0); psav->LockHeld = 1; } @@ -2461,7 +2457,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, #ifdef SAVAGEDRI if (psav->directRenderingEnabled) { - DRILock(screenInfo.screens[pScrn->scrnIndex], 0); + DRILock(xf86ScrnToScreen(pScrn), 0); psav->LockHeld = 1; } #endif @@ -2654,7 +2650,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, #ifdef SAVAGEDRI if (psav->directRenderingEnabled) - DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + DRIUnlock(xf86ScrnToScreen(pScrn)); psav->LockHeld = 0; #endif @@ -2910,7 +2906,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, #ifdef SAVAGEDRI if (psav->directRenderingEnabled) - DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + DRIUnlock(xf86ScrnToScreen(pScrn)); psav->LockHeld = 0; #endif @@ -3215,10 +3211,9 @@ static void SavageInitShadowStatus(ScrnInfoPtr pScrn) psav->dwBCIWait2DIdle = 0xc0020000; } -static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, - int argc, char **argv) +static Bool SavageScreenInit(SCREEN_INIT_ARGS_DECL) { - ScrnInfoPtr pScrn; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav; EntityInfoPtr pEnt; int ret; @@ -3226,7 +3221,6 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, TRACE(("SavageScreenInit()\n")); - pScrn = xf86Screens[pScreen->myNum]; psav = SAVPTR(pScrn); pEnt = xf86GetEntityInfo(pScrn->entityList[0]); @@ -3268,16 +3262,16 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, } else if (xf86IsEntityShared(psav->pEnt->index)) { /* Xinerama has sync problem with DRI, disable it for now */ psav->directRenderingEnabled = FALSE; - xf86DrvMsg(scrnIndex, X_WARNING, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Direct Rendering Disabled -- " "Dual-head configuration is not working with " "DRI at present.\n"); } else if (/*!psav->bTiled*/psav->bDisableTile) { - xf86DrvMsg(scrnIndex, X_WARNING, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Direct Rendering requires a tiled framebuffer -- " "Set Option \"DisableTile\" \"false\"\n"); } else if (psav->cobSize == 0) { - xf86DrvMsg(scrnIndex, X_WARNING, + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Direct Rendering requires the COB -- " "Set Option \"DisableCOB\" \"false\"\n"); } else if (((psav->Chipset == S3_TWISTER) @@ -3342,7 +3336,7 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, if (!miSetPixmapDepths ()) return FALSE; - ret = SavageInternalScreenInit(scrnIndex, pScreen); + ret = SavageInternalScreenInit(pScreen); if (!ret) return FALSE; @@ -3524,7 +3518,7 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, } -static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen) +static int SavageInternalScreenInit(ScreenPtr pScreen) { int ret = TRUE; ScrnInfoPtr pScrn; @@ -3534,7 +3528,7 @@ static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen) TRACE(("SavageInternalScreenInit()\n")); - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); psav = SAVPTR(pScrn); displayWidth = pScrn->displayWidth; @@ -3609,10 +3603,10 @@ static int SavageGetRefresh(DisplayModePtr mode) } -static ModeStatus SavageValidMode(int index, DisplayModePtr pMode, +static ModeStatus SavageValidMode(SCRN_ARG_TYPE arg, DisplayModePtr pMode, Bool verbose, int flags) { - ScrnInfoPtr pScrn = xf86Screens[index]; + SCRN_INFO_PTR(arg); SavagePtr psav = SAVPTR(pScrn); int refresh; @@ -3701,7 +3695,7 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) SavageInitSecondaryStream(pScrn); } - SavageAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + SavageAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); return TRUE; } @@ -3963,15 +3957,15 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) SavageInitSecondaryStream(pScrn); } - SavageAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + SavageAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); return TRUE; } -static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen) +static Bool SavageCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); vgaHWPtr hwp = VGAHWPTR(pScrn); SavagePtr psav = SAVPTR(pScrn); vgaRegPtr vgaSavePtr = &hwp->SavedReg; @@ -4020,13 +4014,13 @@ static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = psav->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } static Bool SavageSaveScreen(ScreenPtr pScreen, int mode) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); TRACE(("SavageSaveScreen(0x%x)\n", mode)); @@ -4042,9 +4036,9 @@ static Bool SavageSaveScreen(ScreenPtr pScreen, int mode) return vgaHWSaveScreen(pScreen, mode); } -void SavageAdjustFrame(int scrnIndex, int x, int y, int flags) +void SavageAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); SavagePtr psav = SAVPTR(pScrn); if (psav->IsSecondary) { @@ -4119,18 +4113,18 @@ SavageDoAdjustFrame(ScrnInfoPtr pScrn, int x, int y, int crtc2) return; } -Bool SavageSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +Bool SavageSwitchMode(SWITCH_MODE_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); SavagePtr psav = SAVPTR(pScrn); Bool success; TRACE(("SavageSwitchMode\n")); if (psav->FBStart2nd || (psav->videoFlags & VF_STREAMS_ON)) - SavageStreamsOff(xf86Screens[scrnIndex]); + SavageStreamsOff(pScrn); - success = SavageModeInit(xf86Screens[scrnIndex], mode); + success = SavageModeInit(pScrn, mode); /* switching mode on primary will reset secondary. it needs to be reset as well*/ if (psav->IsPrimary) { @@ -4578,9 +4572,8 @@ SavageDDC1Read(ScrnInfoPtr pScrn) } static Bool -SavageDDC1(int scrnIndex) +SavageDDC1(ScrnInfoPtr pScrn) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; SavagePtr psav = SAVPTR(pScrn); unsigned char byte; xf86MonPtr pMon; @@ -4591,7 +4584,7 @@ SavageDDC1(int scrnIndex) InI2CREG(byte,psav->I2CPort); OutI2CREG(byte | 0x12,psav->I2CPort); - pMon = xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeedWeak(),SavageDDC1Read); + pMon = xf86DoEDID_DDC1(XF86_SCRN_ARG(pScrn),vgaHWddc1SetSpeedWeak(),SavageDDC1Read); if (!pMon) return FALSE; diff --git a/src/savage_driver.h b/src/savage_driver.h index 338cfac..d51b2a1 100644 --- a/src/savage_driver.h +++ b/src/savage_driver.h @@ -82,6 +82,8 @@ #include "GL/glxint.h" #include "xf86drm.h" +#include "compat-api.h" + /* Totals 2 Mbytes which equals 2^16 32-byte vertices divided among up * to 32 clients. */ #define SAVAGE_NUM_BUFFERS 32 @@ -407,7 +409,7 @@ typedef struct _Savage { /* Support for shadowFB and rotation */ unsigned char * ShadowPtr; int ShadowPitch; - void (*PointerMoved)(int index, int x, int y); + void (*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y); /* support for EXA */ ExaDriverPtr EXADriverPtr; @@ -578,9 +580,9 @@ extern void SavageCommonCalcClock(long freq, int min_m, int min_n1, int max_n1, int min_n2, int max_n2, long freq_min, long freq_max, unsigned char *mdiv, unsigned char *ndiv); -void SavageAdjustFrame(int scrnIndex, int y, int x, int flags); +void SavageAdjustFrame(ADJUST_FRAME_ARGS_DECL); void SavageDoAdjustFrame(ScrnInfoPtr pScrn, int y, int x, int crtc2); -Bool SavageSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +Bool SavageSwitchMode(SWITCH_MODE_ARGS_DECL); /* In savage_cursor.c. */ @@ -606,7 +608,7 @@ Bool SavageI2CInit(ScrnInfoPtr pScrn); /* In savage_shadow.c */ -void SavagePointerMoved(int index, int x, int y); +void SavagePointerMoved(SCRN_ARG_TYPE arg, int x, int y); void SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void SavageRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void SavageRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); diff --git a/src/savage_exa.c b/src/savage_exa.c index 613100b..33c08c7 100644 --- a/src/savage_exa.c +++ b/src/savage_exa.c @@ -102,7 +102,7 @@ static int SavageGetSolidROP(int rop) { Bool SavageEXAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); if (!(psav->EXADriverPtr = exaDriverAlloc())) { @@ -196,7 +196,7 @@ SavageEXAInit(ScreenPtr pScreen) static void SavageEXASync(ScreenPtr pScreen, int marker) { - SavagePtr psav = SAVPTR(xf86Screens[pScreen->myNum]); + SavagePtr psav = SAVPTR(xf86ScreenToScrn(pScreen)); psav->WaitIdleEmpty(psav); } @@ -248,7 +248,7 @@ SavageSetBD(SavagePtr psav, PixmapPtr pPixmap) static Bool SavagePrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) { - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); SavagePtr psav = SAVPTR(pScrn); int cmd, rop; BCI_GET_PTR; @@ -322,7 +322,7 @@ SavagePrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) static void SavageSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) { - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); SavagePtr psav = SAVPTR(pScrn); int w = x2 - x1; int h = y2 - y1; @@ -352,7 +352,7 @@ static Bool SavagePrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, int alu, Pixel planemask) { - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); SavagePtr psav = SAVPTR(pScrn); int cmd; BCI_GET_PTR; @@ -400,7 +400,7 @@ SavagePrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir static void SavageCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height) { - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); SavagePtr psav = SAVPTR(pScrn); BCI_GET_PTR; @@ -435,7 +435,7 @@ SavageDoneCopy(PixmapPtr pDstPixmap) Bool SavageUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch) { - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen); SavagePtr psav = SAVPTR(pScrn); BCI_GET_PTR; int i, j, dwords, queue, Bpp; diff --git a/src/savage_hwmc.c b/src/savage_hwmc.c index ed881b4..2dea4df 100644 --- a/src/savage_hwmc.c +++ b/src/savage_hwmc.c @@ -181,7 +181,7 @@ static XF86MCAdaptorPtr ppAdapt[1] = **************************************************************************/ Bool SAVAGEInitMC(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr pSAVAGE = SAVPTR(pScrn); DRIInfoPtr pDRIInfo = pSAVAGE->pDRIInfo; SAVAGEDRIPtr pSAVAGEDriPriv = (SAVAGEDRIPtr)pDRIInfo->devPrivate; diff --git a/src/savage_shadow.c b/src/savage_shadow.c index 899da11..a430a69 100644 --- a/src/savage_shadow.c +++ b/src/savage_shadow.c @@ -42,9 +42,9 @@ SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void -SavagePointerMoved(int index, int x, int y) +SavagePointerMoved(SCRN_ARG_TYPE arg, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; + SCRN_INFO_PTR(arg); SavagePtr psav = SAVPTR(pScrn); int newX, newY; @@ -56,7 +56,7 @@ SavagePointerMoved(int index, int x, int y) newY = pScrn->pScreen->width - x - 1; } - (*psav->PointerMoved)(index, newX, newY); + (*psav->PointerMoved)(arg, newX, newY); } void diff --git a/src/savage_video.c b/src/savage_video.c index b5a6330..63958b7 100644 --- a/src/savage_video.c +++ b/src/savage_video.c @@ -338,7 +338,7 @@ SavageClipVWindow(ScrnInfoPtr pScrn) void SavageInitVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr newAdaptor = NULL; SavagePtr psav = SAVPTR(pScrn); @@ -877,7 +877,7 @@ void SavageResetVideo(ScrnInfoPtr pScrn) static XF86VideoAdaptorPtr SavageSetupImageVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); XF86VideoAdaptorPtr adapt; SavagePortPrivPtr pPriv; @@ -1324,7 +1324,7 @@ SavageCopyPlanarData( static void SavageVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); SavagePortPrivPtr pPriv = psav->adaptor->pPortPrivates[0].ptr; @@ -1340,7 +1340,7 @@ SavageAllocateMemory( void **mem_struct, int size ){ - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); SavagePtr psav = SAVPTR(pScrn); int offset = 0; @@ -2359,7 +2359,7 @@ static void SavageInitOffscreenImages(ScreenPtr pScreen) { XF86OffscreenImagePtr offscreenImages; - SavagePtr psav = SAVPTR(xf86Screens[pScreen->myNum]); + SavagePtr psav = SAVPTR(xf86ScreenToScrn(pScreen)); /* need to free this someplace */ if (!psav->offscreenImages) { diff --git a/src/savage_xaa.c b/src/savage_xaa.c index 4565ffd..e4d661b 100644 --- a/src/savage_xaa.c +++ b/src/savage_xaa.c @@ -151,7 +151,7 @@ void SavageRestoreAccelState(ScrnInfoPtr pScrn) Bool SavageXAAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SavagePtr psav = SAVPTR(pScrn); XAAInfoRecPtr xaaptr; BoxRec AvailFBArea; |