diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/compat-api.h | 99 | ||||
-rw-r--r-- | src/mga.h | 12 | ||||
-rw-r--r-- | src/mga_dacG.c | 2 | ||||
-rw-r--r-- | src/mga_dga.c | 10 | ||||
-rw-r--r-- | src/mga_dri.c | 24 | ||||
-rw-r--r-- | src/mga_driver.c | 111 | ||||
-rw-r--r-- | src/mga_exa.c | 10 | ||||
-rw-r--r-- | src/mga_hwcurs.c | 2 | ||||
-rw-r--r-- | src/mga_merge.c | 61 | ||||
-rw-r--r-- | src/mga_merge.h | 6 | ||||
-rw-r--r-- | src/mga_shadow.c | 6 | ||||
-rw-r--r-- | src/mga_storm.c | 6 | ||||
-rw-r--r-- | src/mga_video.c | 14 |
14 files changed, 228 insertions, 138 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 44417de..46f0265 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,7 +55,8 @@ mga_drv_la_SOURCES = \ mga_shadow.c \ mga_ucode.h \ mga_vga.c \ - mga_video.c + mga_video.c \ + compat-api.h if DRI mga_drv_la_SOURCES += \ 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 @@ -46,6 +46,8 @@ #include "mga_dri.h" #endif +#include "compat-api.h" + typedef enum { OPTION_SW_CURSOR, OPTION_HW_CURSOR, @@ -564,7 +566,7 @@ typedef struct { void (*Save)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); void (*Restore)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); Bool (*ModeInit)(ScrnInfoPtr, DisplayModePtr); - void (*PointerMoved)(int index, int x, int y); + void (*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y); CloseScreenProcPtr CloseScreen; ScreenBlockHandlerProcPtr BlockHandler; unsigned int (*ddc1Read)(ScrnInfoPtr); @@ -693,8 +695,8 @@ extern CARD32 MGAAtypeNoBLK[16]; /* Prototypes */ -void MGAAdjustFrame(int scrnIndex, int x, int y, int flags); -Bool MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +void MGAAdjustFrame(ADJUST_FRAME_ARGS_DECL); +Bool MGASwitchMode(SWITCH_MODE_ARGS_DECL); void MGAFillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode); Bool MGAGetRec(ScrnInfoPtr pScrn); void MGAProbeDDC(ScrnInfoPtr pScrn, int index); @@ -703,7 +705,7 @@ void MGAFreeRec(ScrnInfoPtr pScrn); Bool mga_read_and_process_bios(ScrnInfoPtr pScrn); void MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); -void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags); +void MGAAdjustFrameCrtc2(ADJUST_FRAME_ARGS_DECL); void MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); @@ -743,7 +745,7 @@ void mgaDoSetupForScreenToScreenCopy( ScrnInfoPtr pScrn, int xdir, void mgaDoSetupForSolidFill( ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask, unsigned int bpp ); -void MGAPointerMoved(int index, int x, int y); +void MGAPointerMoved(SCRN_ARG_TYPE arg, int x, int y); void MGAInitVideo(ScreenPtr pScreen); void MGAResetVideo(ScrnInfoPtr pScrn); diff --git a/src/mga_dacG.c b/src/mga_dacG.c index ea598be..9a80193 100644 --- a/src/mga_dacG.c +++ b/src/mga_dacG.c @@ -1794,7 +1794,7 @@ MGAGSetCursorColorsG100(ScrnInfoPtr pScrn, int bg, int fg) static Bool MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) { - MGAPtr pMga = MGAPTR(xf86Screens[pScrn->myNum]); + MGAPtr pMga = MGAPTR(xf86ScreenToScrn(pScrn)); /* This needs to detect if its on the second dac */ if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN ) return FALSE; diff --git a/src/mga_dga.c b/src/mga_dga.c index 6c26e44..a806eb2 100644 --- a/src/mga_dga.c +++ b/src/mga_dga.c @@ -197,7 +197,7 @@ SECOND_PASS: Bool MGADGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); DGAModePtr modes = NULL; int num = 0; @@ -310,8 +310,8 @@ MGA_SetMode( memcpy(&pMga->CurrentLayout, &SavedLayouts[index], sizeof(MGAFBLayout)); pScrn->currentMode = pMga->CurrentLayout.mode; - pScrn->SwitchMode(index, pScrn->currentMode, 0); - MGAAdjustFrame(index, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->SwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode)); + MGAAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); pMga->DGAactive = FALSE; } else { if(!pMga->DGAactive) { /* save the old parameters */ @@ -328,7 +328,7 @@ MGA_SetMode( pMga->CurrentLayout.weight.blue = BitsSet(pMode->blue_mask); /* MGAModeInit() will set the mode field */ - pScrn->SwitchMode(index, pMode->mode, 0); + pScrn->SwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode)); /* not strictly required but nice */ mgaDGASetPalette(pScrn); } @@ -355,7 +355,7 @@ MGA_SetViewport( ){ MGAPtr pMga = MGAPTR(pScrn); - MGAAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + MGAAdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y)); pMga->DGAViewportStatus = 0; /* MGAAdjustFrame loops until finished */ } diff --git a/src/mga_dri.c b/src/mga_dri.c index 4156bb5..c517322 100644 --- a/src/mga_dri.c +++ b/src/mga_dri.c @@ -74,7 +74,7 @@ static char MGAClientDriverName[] = "mga"; */ static Bool MGAInitVisualConfigs( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); int numConfigs = 0; __GLXvisualConfig *pConfigs = 0; @@ -407,7 +407,7 @@ void MGAGetQuiescenceShared( ScrnInfoPtr pScrn ) static void MGASwapContext( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); /* Arrange for dma_quiescence and xaa sync to be called as @@ -420,7 +420,7 @@ static void MGASwapContext( ScreenPtr pScreen ) static void MGASwapContextShared( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGAEntPtr pMGAEnt = pMga->entityPrivate; MGAPtr pMGA2 = MGAPTR(pMGAEnt->pScrn_2); @@ -522,7 +522,7 @@ static unsigned int mylog2( unsigned int n ) */ static Bool MGADRIBootstrapDMA(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; int ret; @@ -778,7 +778,7 @@ static Bool MGADRIBootstrapDMA(ScreenPtr pScreen) static Bool MGADRIKernelInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; drm_mga_init_t init; @@ -838,7 +838,7 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen ) */ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); if (!pMga->irq) { pMga->irq = drmGetInterruptFromBusID(pMga->drmFD, @@ -873,7 +873,7 @@ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen) static Bool MGADRIBuffersInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; @@ -896,7 +896,7 @@ static void MGADRIInitBuffersXAA(WindowPtr pWin, RegionPtr prgn, CARD32 index) { ScreenPtr pScreen = pWin->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); BoxPtr pbox = REGION_RECTS(prgn); int nbox = REGION_NUM_RECTS(prgn); @@ -941,7 +941,7 @@ static void MGADRIMoveBuffersXAA(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index) { ScreenPtr pScreen = pParent->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); int nbox; BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; @@ -1088,7 +1088,7 @@ static void MGADRIMoveBuffersEXA(WindowPtr pParent, DDXPointRec ptOldOrg, Bool MGADRIScreenInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); DRIInfoPtr pDRIInfo; MGADRIPtr pMGADRI; @@ -1367,7 +1367,7 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; MGADRIPtr pMGADRI; @@ -1462,7 +1462,7 @@ Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) void MGADRICloseScreen( ScreenPtr pScreen ) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; drm_mga_init_t init; diff --git a/src/mga_driver.c b/src/mga_driver.c index 0c04d74..e50d77b 100644 --- a/src/mga_driver.c +++ b/src/mga_driver.c @@ -118,12 +118,11 @@ static Bool MGAPciProbe(DriverPtr drv, int entity_num, static Bool MGAProbe(DriverPtr drv, int flags); #endif static Bool MGAPreInit(ScrnInfoPtr pScrn, int flags); -static Bool MGAScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool MGAEnterVT(int scrnIndex, int flags); -static Bool MGAEnterVTFBDev(int scrnIndex, int flags); -static void MGALeaveVT(int scrnIndex, int flags); -static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool MGAScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool MGAEnterVT(VT_FUNC_ARGS_DECL); +static Bool MGAEnterVTFBDev(VT_FUNC_ARGS_DECL); +static void MGALeaveVT(VT_FUNC_ARGS_DECL); +static Bool MGACloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool MGASaveScreen(ScreenPtr pScreen, int mode); static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode); @@ -134,8 +133,8 @@ static void VgaIORestore(int i, void *arg); #endif /* Optional functions */ -static void MGAFreeScreen(int scrnIndex, int flags); -static ModeStatus MGAValidMode(int scrnIndex, DisplayModePtr mode, +static void MGAFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus MGAValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); #if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ >= 4) @@ -150,7 +149,7 @@ static Bool MGAUnmapMem(ScrnInfoPtr pScrn); static void MGASave(ScrnInfoPtr pScrn); static void MGARestore(ScrnInfoPtr pScrn); static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -static void MGABlockHandler(int, pointer, pointer, pointer); +static void MGABlockHandler(BLOCKHANDLER_ARGS_DECL); static void MGAG100BlackMagic(ScrnInfoPtr pScrn); static int MGAEntityIndex = -1; @@ -1331,18 +1330,18 @@ MGAdoDDC(ScrnInfoPtr pScrn) /* DDC for second head... */ if (pMga->SecondCrtc && pMga->DDC_Bus2) { - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pMga->DDC_Bus2); + MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), pMga->DDC_Bus2); from = "I2C"; } else { /* Its the first head... */ if (pMga->DDC_Bus1) { - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pMga->DDC_Bus1); + MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), pMga->DDC_Bus1); from = "I2C"; } if (!MonInfo) /* Read and output monitor info using DDC1 */ if (pMga->ddc1Read && pMga->DDC1SetSpeed) { - MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, + MonInfo = xf86DoEDID_DDC1(XF86_SCRN_ARG(pScrn), pMga->DDC1SetSpeed, pMga->ddc1Read ) ; from = "DDC1"; @@ -2886,7 +2885,7 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #ifdef MGADRI if (pMga->directRenderingEnabled) { - DRILock(screenInfo.screens[pScrn->scrnIndex], 0); + DRILock(xf86ScrnToScreen(pScrn), 0); } #endif @@ -2997,7 +2996,7 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #ifdef MGADRI if (pMga->directRenderingEnabled) - DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + DRIUnlock(xf86ScrnToScreen(pScrn)); #endif #ifdef DEBUG MGAG450PrintPLL(pScrn); @@ -3131,9 +3130,9 @@ MGACrtc2FillStrip(ScrnInfoPtr pScrn) /* This gets called at the start of each server generation */ static Bool -MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +MGAScreenInit(SCREEN_INIT_ARGS_DECL) { - ScrnInfoPtr pScrn; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); vgaHWPtr hwp; MGAPtr pMga; MGARamdacPtr MGAdac; @@ -3149,11 +3148,6 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #endif DPMSSetProcPtr mga_dpms_set_proc = NULL; - /* - * First get the ScrnInfoRec - */ - pScrn = xf86Screens[pScreen->myNum]; - hwp = VGAHWPTR(pScrn); pMga = MGAPTR(pScrn); MGAdac = &pMga->Dac; @@ -3256,7 +3250,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ (*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_ON); - pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); /* @@ -3517,13 +3511,13 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Usually mandatory */ Bool -MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +MGASwitchMode(SWITCH_MODE_ARGS_DECL) { - + SCRN_INFO_PTR(arg); if (mode->Flags & 0x80000000) { return FALSE; } else - return MGAModeInit(xf86Screens[scrnIndex], mode); + return MGAModeInit(pScrn, mode); } /* Adjusts coordinates to match Panning granularity. @@ -3541,16 +3535,14 @@ MGAAdjustGranularity(ScrnInfoPtr pScrn, int* x, int* y) */ /* Usually mandatory */ void -MGAAdjustFrame(int scrnIndex, int x, int y, int flags) +MGAAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn; + SCRN_INFO_PTR(arg); int Base, tmp, count; MGAFBLayout *pLayout; MGAPtr pMga; - - pScrn = xf86Screens[scrnIndex]; pMga = MGAPTR(pScrn); pLayout = &pMga->CurrentLayout; @@ -3589,14 +3581,13 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags) } void -MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags) +MGAAdjustFrameCrtc2(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn; + SCRN_INFO_PTR(arg); int Base; MGAFBLayout *pLayout; MGAPtr pMga; - pScrn = xf86Screens[scrnIndex]; pMga = MGAPTR(pScrn); pLayout = &pMga->CurrentLayout; MGA_NOT_HAL( @@ -3624,9 +3615,9 @@ MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags) /* Mandatory */ static Bool -MGAEnterVT(int scrnIndex, int flags) +MGAEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); MGAPtr pMga; pMga = MGAPTR(pScrn); @@ -3637,13 +3628,13 @@ MGAEnterVT(int scrnIndex, int flags) /* Need to make sure interrupts are enabled */ OUTREG(MGAREG_IEN, pMga->reg_ien); } - DRIUnlock(screenInfo.screens[scrnIndex]); + DRIUnlock(xf86ScrnToScreen(pScrn)); } #endif if (!MGAModeInit(pScrn, pScrn->currentMode)) return FALSE; - pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); /* For the second head, work around display problem. */ if (pMga->SecondCrtc) { @@ -3654,21 +3645,21 @@ MGAEnterVT(int scrnIndex, int flags) } static Bool -MGAEnterVTFBDev(int scrnIndex, int flags) +MGAEnterVTFBDev(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); #ifdef MGADRI ScreenPtr pScreen; MGAPtr pMga; pMga = MGAPTR(pScrn); if (pMga->directRenderingEnabled) { - pScreen = screenInfo.screens[scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); DRIUnlock(pScreen); } #endif - fbdevHWEnterVT(scrnIndex,flags); + fbdevHWEnterVT(VT_FUNC_ARGS); MGAStormEngineInit(pScrn); return TRUE; } @@ -3692,9 +3683,9 @@ MGAEnterVTFBDev(int scrnIndex, int flags) /* Mandatory */ static void -MGALeaveVT(int scrnIndex, int flags) +MGALeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); vgaHWPtr hwp = VGAHWPTR(pScrn); #ifdef MGADRI MGAPtr pMga = MGAPTR(pScrn); @@ -3706,7 +3697,7 @@ MGALeaveVT(int scrnIndex, int flags) #ifdef MGADRI if (pMga->directRenderingEnabled) { - pScreen = screenInfo.screens[scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); DRILock(pScreen, 0); } #endif @@ -3722,16 +3713,16 @@ MGALeaveVT(int scrnIndex, int flags) /* Mandatory */ static Bool -MGACloseScreen(int scrnIndex, ScreenPtr pScreen) +MGACloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); vgaHWPtr hwp = VGAHWPTR(pScrn); MGAPtr pMga = MGAPTR(pScrn); MGAEntPtr pMgaEnt = NULL; CARD32 VRTemp, FBTemp; if (pMga->MergedFB) - MGACloseScreenMerged(scrnIndex, pScreen); + MGACloseScreenMerged(pScreen); if (pMga->is_G200SE) { @@ -3807,7 +3798,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) pScreen->CloseScreen = pMga->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } @@ -3815,16 +3806,16 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) /* Optional */ static void -MGAFreeScreen(int scrnIndex, int flags) +MGAFreeScreen(FREE_SCREEN_ARGS_DECL) { - + SCRN_INFO_PTR(arg); /* * This only gets called when a screen is being deleted. It does not * get called routinely at the end of a server generation. */ if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); - MGAFreeRec(xf86Screens[scrnIndex]); + vgaHWFreeHWRec(pScrn); + MGAFreeRec(pScrn); } @@ -3855,10 +3846,10 @@ xf86ModeBandwidth(DisplayModePtr mode, int depth) /* Optional */ static ModeStatus -MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +MGAValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { + SCRN_INFO_PTR(arg); int lace; - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; MGAPtr pMga = MGAPTR(pScrn); if (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) { @@ -4056,21 +4047,17 @@ MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode, static void -MGABlockHandler ( - int i, - pointer blockData, - pointer pTimeout, - pointer pReadmask -){ - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; +MGABlockHandler (BLOCKHANDLER_ARGS_DECL) +{ + SCREEN_PTR(arg); + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); if(pMga->PaletteLoadCallback) (*pMga->PaletteLoadCallback)(pScrn); pScreen->BlockHandler = pMga->BlockHandler; - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS); pScreen->BlockHandler = MGABlockHandler; if(pMga->VideoTimerCallback) { diff --git a/src/mga_exa.c b/src/mga_exa.c index 6cb4ae6..f4a6eb2 100644 --- a/src/mga_exa.c +++ b/src/mga_exa.c @@ -53,10 +53,10 @@ #endif #define PMGA(x) \ - MGAPtr pMga = xf86Screens[x->drawable.pScreen->myNum]->driverPrivate; + MGAPtr pMga = xf86ScreenToScrn(x->drawable.pScreen)->driverPrivate; #define QUIESCE_DMA(x) \ - CHECK_DMA_QUIESCENT(pMga, xf86Screens[x->drawable.pScreen->myNum]); + CHECK_DMA_QUIESCENT(pMga, xf86ScreenToScrn(x->drawable.pScreen)); /* stuff stolen from mga_storm.c */ #define BLIT_LEFT 1 @@ -354,7 +354,7 @@ static Bool mgaCheckComposite(int op, PicturePtr pSrcPict, PicturePtr pMaskPict, PicturePtr pDstPict) { - MGAPtr pMga = xf86Screens[pSrcPict->pDrawable->pScreen->myNum]->driverPrivate; + MGAPtr pMga = xf86ScreenToScrn(pSrcPict->pDrawable->pScreen)->driverPrivate; if (op >= sizeof(mgaBlendOp) / sizeof(mgaBlendOp[0])) { DEBUG_MSG(("unsupported op %x\n", op)); @@ -751,7 +751,7 @@ mgaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, static void mgaWaitMarker(ScreenPtr pScreen, int marker) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = pScrn->driverPrivate; WAITFIFO(1); @@ -842,7 +842,7 @@ Bool mgaExaInit(ScreenPtr pScreen) { ExaDriverPtr pExa; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = pScrn->driverPrivate; pExa = exaDriverAlloc(); diff --git a/src/mga_hwcurs.c b/src/mga_hwcurs.c index 937f979..5e43f21 100644 --- a/src/mga_hwcurs.c +++ b/src/mga_hwcurs.c @@ -13,7 +13,7 @@ Bool MGAHWCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGARamdacPtr MGAdac = &pMga->Dac; xf86CursorInfoPtr infoPtr; diff --git a/src/mga_merge.c b/src/mga_merge.c index 9045b63..6d7b71e 100644 --- a/src/mga_merge.c +++ b/src/mga_merge.c @@ -671,10 +671,10 @@ InRegion(int x, int y, region r) { low += test-hi; \ hi = test; } } void -MGAMergePointerMoved(int scrnIndex, int x, int y) +MGAMergePointerMoved(SCRN_ARG_TYPE arg, int x, int y) { - ScrnInfoPtr pScr = xf86Screens[scrnIndex]; - MGAPtr pMga = MGAPTR(pScr); + SCRN_INFO_PTR(arg); + MGAPtr pMga = MGAPTR(pScrn); ScrnInfoPtr pScr2 = pMga->pScrn2; region out,in1,in2,f2,f1; @@ -693,10 +693,10 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) /*specify outer clipping region. crossing this causes all frames to move*/ - out.x0 = pScr->frameX0; - out.x1 = pScr->frameX1+1; - out.y0 = pScr->frameY0; - out.y1 = pScr->frameY1+1; + out.x0 = pScrn->frameX0; + out.x1 = pScrn->frameX1+1; + out.y0 = pScrn->frameY0; + out.y1 = pScrn->frameY1+1; /* * specify inner sliding window. beeing outsize both frames, and inside @@ -704,7 +704,7 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) */ in1 = out; in2 = out; - switch(((MergedDisplayModePtr)pScr->currentMode->Private)->Monitor2Pos) { + switch(((MergedDisplayModePtr)pScrn->currentMode->Private)->Monitor2Pos) { case mgaLeftOf : in1.x0 = f1.x0; in2.x1 = f2.x1; @@ -752,8 +752,8 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) f1.x1 += deltax; f2.x0 += deltax; f2.x1 += deltax; - pScr->frameX0 += deltax; - pScr->frameX1 += deltax; + pScrn->frameX0 += deltax; + pScrn->frameX1 += deltax; if ( out.y0 > y) { @@ -766,8 +766,8 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) f1.y1 += deltay; f2.y0 += deltay; f2.y1 += deltay; - pScr->frameY0 += deltay; - pScr->frameY1 += deltay; + pScrn->frameY0 += deltay; + pScrn->frameY1 += deltay; } @@ -779,19 +779,19 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) pScr2->frameY0 = f2.y0; /*Adjust Granularity */ - MGAAdjustGranularity(pScr,&pMga->M1frameX0,&pMga->M1frameY0); - MGAAdjustGranularity(pScr,&pScr2->frameX0,&pScr2->frameY0); - MGAAdjustGranularity(pScr,&pScr->frameX0,&pScr->frameY0); + MGAAdjustGranularity(pScrn,&pMga->M1frameX0,&pMga->M1frameY0); + MGAAdjustGranularity(pScrn,&pScr2->frameX0,&pScr2->frameY0); + MGAAdjustGranularity(pScrn,&pScrn->frameX0,&pScrn->frameY0); - pMga->M1frameX1 = pMga->M1frameX0 + MDMPTR(pScr)->Monitor1->HDisplay -1; - pMga->M1frameY1 = pMga->M1frameY0 + MDMPTR(pScr)->Monitor1->VDisplay -1; - pScr2->frameX1 = pScr2->frameX0 + MDMPTR(pScr)->Monitor2->HDisplay -1; - pScr2->frameY1 = pScr2->frameY0 + MDMPTR(pScr)->Monitor2->VDisplay -1; - pScr->frameX1 = pScr->frameX0 + pScr->currentMode->HDisplay -1; - pScr->frameY1 = pScr->frameY0 + pScr->currentMode->VDisplay -1; + pMga->M1frameX1 = pMga->M1frameX0 + MDMPTR(pScrn)->Monitor1->HDisplay -1; + pMga->M1frameY1 = pMga->M1frameY0 + MDMPTR(pScrn)->Monitor1->VDisplay -1; + pScr2->frameX1 = pScr2->frameX0 + MDMPTR(pScrn)->Monitor2->HDisplay -1; + pScr2->frameY1 = pScr2->frameY0 + MDMPTR(pScrn)->Monitor2->VDisplay -1; + pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay -1; + pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay -1; - MGAAdjustFrame(pScr->scrnIndex, pMga->M1frameX0, pMga->M1frameY0, 0); - MGAAdjustFrameCrtc2(pScr->scrnIndex, pScr2->frameX0, pScr2->frameY0, 0); + MGAAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pMga->M1frameX0, pMga->M1frameY0)); + MGAAdjustFrameCrtc2(ADJUST_FRAME_ARGS(pScrn, pScr2->frameX0, pScr2->frameY0)); } /* if(pMga->PointerMoved) @@ -801,8 +801,9 @@ MGAMergePointerMoved(int scrnIndex, int x, int y) void -MGAAdjustMergeFrames(int scrnIndex, int x, int y, int flags) { - ScrnInfoPtr pScrn1 = xf86Screens[scrnIndex]; +MGAAdjustMergeFrames(ADJUST_FRAME_ARGS_DECL) { + SCRN_INFO_PTR(arg); + ScrnInfoPtr pScrn1 = pScrn; MGAPtr pMga = MGAPTR(pScrn1); ScrnInfoPtr pScrn2 = pMga->pScrn2; int VTotal = pScrn1->currentMode->VDisplay; @@ -866,14 +867,14 @@ MGAAdjustMergeFrames(int scrnIndex, int x, int y, int flags) { pScrn1->frameX1 = pScrn1->frameX0 + pScrn1->currentMode->HDisplay -1; pScrn1->frameY1 = pScrn1->frameY0 + pScrn1->currentMode->VDisplay -1; - MGAAdjustFrame(scrnIndex, pMga->M1frameX0, pMga->M1frameY0, flags); - MGAAdjustFrameCrtc2(scrnIndex, pScrn2->frameX0, pScrn2->frameY0, flags); + MGAAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pMga->M1frameX0, pMga->M1frameY0)); + MGAAdjustFrameCrtc2(ADJUST_FRAME_ARGS(pScrn, pScrn2->frameX0, pScrn2->frameY0)); return; } Bool -MGACloseScreenMerged(int scrnIndex, ScreenPtr pScreen) { - ScrnInfoPtr pScrn1 = xf86Screens[scrnIndex]; +MGACloseScreenMerged(ScreenPtr pScreen) { + ScrnInfoPtr pScrn1 = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn1); ScrnInfoPtr pScrn2 = pMga->pScrn2; @@ -904,7 +905,7 @@ MGACloseScreenMerged(int scrnIndex, ScreenPtr pScreen) { Bool MGASaveScreenMerged(ScreenPtr pScreen, int mode) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); BOOL on = xf86IsUnblank(mode); CARD8 reg; diff --git a/src/mga_merge.h b/src/mga_merge.h index f823b23..ecbb4b6 100644 --- a/src/mga_merge.h +++ b/src/mga_merge.h @@ -4,10 +4,10 @@ void MGADisplayPowerManagementSetMerged(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); -void MGAMergePointerMoved(int scrnIndex, int x, int y); -void MGAAdjustMergeFrames(int scrnIndex, int x, int y, int flags); +void MGAMergePointerMoved(SCRN_ARG_TYPE arg, int x, int y); +void MGAAdjustMergeFrames(ADJUST_FRAME_ARGS_DECL); Bool MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags); -Bool MGACloseScreenMerged(int scrnIndex, ScreenPtr pScreen); +Bool MGACloseScreenMerged(ScreenPtr pScreen); Bool MGASaveScreenMerged(ScreenPtr pScreen, int mode); typedef struct _MergedDisplayModeRec { diff --git a/src/mga_shadow.c b/src/mga_shadow.c index 4842e3a..a8d5cfb 100644 --- a/src/mga_shadow.c +++ b/src/mga_shadow.c @@ -45,9 +45,9 @@ MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } void -MGAPointerMoved(int index, int x, int y) +MGAPointerMoved(SCRN_ARG_TYPE arg, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; + SCRN_INFO_PTR(arg); MGAPtr pMga = MGAPTR(pScrn); int newX, newY; @@ -59,7 +59,7 @@ MGAPointerMoved(int index, int x, int y) newY = pScrn->pScreen->width - x - 1; } - (*pMga->PointerMoved)(index, newX, newY); + (*pMga->PointerMoved)(arg, newX, newY); } void diff --git a/src/mga_storm.c b/src/mga_storm.c index a0189a6..c32caf4 100644 --- a/src/mga_storm.c +++ b/src/mga_storm.c @@ -573,7 +573,7 @@ MGASubsequentCPUToScreenTexture ( Bool mgaAccelInit( ScreenPtr pScreen ) { XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); int maxFastBlitMem, maxlines; Bool doRender = FALSE; @@ -2337,7 +2337,7 @@ MGAValidatePolyArc( unsigned long changes, DrawablePtr pDraw ){ - ScrnInfoPtr pScrn = xf86Screens[pGC->pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pGC->pScreen); MGAPtr pMga = MGAPTR(pScrn); Bool fullPlanemask = TRUE; @@ -2424,7 +2424,7 @@ MGAValidatePolyPoint( unsigned long changes, DrawablePtr pDraw ){ - ScrnInfoPtr pScrn = xf86Screens[pGC->pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pGC->pScreen); MGAPtr pMga = MGAPTR(pScrn); Bool fullPlanemask = TRUE; diff --git a/src/mga_video.c b/src/mga_video.c index 2b755d7..00e026d 100644 --- a/src/mga_video.c +++ b/src/mga_video.c @@ -72,7 +72,7 @@ static Atom xvBrightness, xvContrast, xvColorKey, xvDoubleBuffer; static void MGAVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; @@ -83,7 +83,7 @@ MGAVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area) void MGAInitVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr newAdaptor = NULL; MGAPtr pMga = MGAPTR(pScrn); @@ -263,7 +263,7 @@ MGAAllocAdaptor(ScrnInfoPtr pScrn, Bool doublebuffer) static XF86VideoAdaptorPtr MGASetupImageVideoOverlay(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); XF86VideoAdaptorPtr adapt; @@ -312,7 +312,7 @@ MGASetupImageVideoOverlay(ScreenPtr pScreen) static XF86VideoAdaptorPtr MGASetupImageVideoTexture(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr adapt; MGAPtr pMga = MGAPTR(pScrn); @@ -567,7 +567,7 @@ MGAAllocateMemory( int size ){ MGAPtr pMga = MGAPTR(pScrn); - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); int offset = 0; #ifdef USE_EXA @@ -1227,7 +1227,7 @@ MGADisplaySurface( static void MGAInitOffscreenImages(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); int num = (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550) ? 2 : 1; XF86OffscreenImagePtr offscreenImages; @@ -1296,7 +1296,7 @@ MGAInitOffscreenImages(ScreenPtr pScreen) static XF86VideoAdaptorPtr MGASetupImageVideoILOAD(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr adapt; MGAPtr pMga = MGAPTR(pScrn); |