diff options
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compat-api.h | 105 | ||||
-rw-r--r-- | src/g80_driver.c | 37 | ||||
-rw-r--r-- | src/g80_exa.c | 12 | ||||
-rw-r--r-- | src/g80_output.c | 15 | ||||
-rw-r--r-- | src/g80_type.h | 1 | ||||
-rw-r--r-- | src/g80_xaa.c | 2 | ||||
-rw-r--r-- | src/nv_cursor.c | 2 | ||||
-rw-r--r-- | src/nv_dac.c | 11 | ||||
-rw-r--r-- | src/nv_dga.c | 10 | ||||
-rw-r--r-- | src/nv_driver.c | 104 | ||||
-rw-r--r-- | src/nv_include.h | 1 | ||||
-rw-r--r-- | src/nv_proto.h | 6 | ||||
-rw-r--r-- | src/nv_setup.c | 4 | ||||
-rw-r--r-- | src/nv_shadow.c | 6 | ||||
-rw-r--r-- | src/nv_type.h | 2 | ||||
-rw-r--r-- | src/nv_video.c | 8 | ||||
-rw-r--r-- | src/nv_xaa.c | 2 | ||||
-rw-r--r-- | src/riva_cursor.c | 2 | ||||
-rw-r--r-- | src/riva_dac.c | 11 | ||||
-rw-r--r-- | src/riva_dga.c | 10 | ||||
-rw-r--r-- | src/riva_driver.c | 62 | ||||
-rw-r--r-- | src/riva_include.h | 1 | ||||
-rw-r--r-- | src/riva_proto.h | 4 | ||||
-rw-r--r-- | src/riva_setup.c | 4 | ||||
-rw-r--r-- | src/riva_shadow.c | 6 | ||||
-rw-r--r-- | src/riva_type.h | 4 | ||||
-rw-r--r-- | src/riva_xaa.c | 2 |
28 files changed, 289 insertions, 146 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 70e127c..0143af7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,7 @@ nv_drv_ladir = @moduledir@/drivers nv_drv_la_SOURCES = $(nv_sources) $(riva_sources) $(g80_sources) nv_sources = \ + compat-api.h \ nv_const.h \ nv_cursor.c \ nv_dac.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/g80_driver.c b/src/g80_driver.c index 35e5d7e..c666977 100644 --- a/src/g80_driver.c +++ b/src/g80_driver.c @@ -495,9 +495,9 @@ ReleaseDisplay(ScrnInfoPtr pScrn) } static Bool -G80CloseScreen(int scrnIndex, ScreenPtr pScreen) +G80CloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); G80Ptr pNv = G80PTR(pScrn); if(pScrn->vtSema) @@ -530,14 +530,14 @@ G80CloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = pNv->CloseScreen; pScreen->BlockHandler = pNv->BlockHandler; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } static void -G80BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) +G80BlockHandler(BLOCKHANDLER_ARGS_DECL) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrnInfo = xf86Screens[i]; + SCREEN_PTR(arg); + ScrnInfoPtr pScrnInfo = xf86ScreenToScrn(pScreen); G80Ptr pNv = G80PTR(pScrnInfo); if(pNv->DMAKickoffCallback) @@ -546,7 +546,7 @@ G80BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) G80OutputResetCachedStatus(pScrnInfo); pScreen->BlockHandler = pNv->BlockHandler; - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS); pScreen->BlockHandler = G80BlockHandler; } @@ -738,7 +738,7 @@ G80InitHW(ScrnInfoPtr pScrn) } static Bool -G80ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +G80ScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; G80Ptr pNv; @@ -747,7 +747,7 @@ G80ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) BoxRec AvailFBArea; /* First get the ScrnInfoRec */ - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); pNv = G80PTR(pScrn); pScrn->vtSema = TRUE; @@ -885,27 +885,28 @@ G80ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } static void -G80FreeScreen(int scrnIndex, int flags) +G80FreeScreen(FREE_SCREEN_ARGS_DECL) { - G80FreeRec(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + G80FreeRec(pScrn); } static Bool -G80SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +G80SwitchMode(SWITCH_MODE_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); } static void -G80AdjustFrame(int scrnIndex, int x, int y, int flags) +G80AdjustFrame(ADJUST_FRAME_ARGS_DECL) { } static Bool -G80EnterVT(int scrnIndex, int flags) +G80EnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); G80Ptr pNv = G80PTR(pScrn); /* Reinit the hardware */ @@ -919,9 +920,9 @@ G80EnterVT(int scrnIndex, int flags) } static void -G80LeaveVT(int scrnIndex, int flags) +G80LeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); ReleaseDisplay(pScrn); } diff --git a/src/g80_exa.c b/src/g80_exa.c index a327c51..0555cc6 100644 --- a/src/g80_exa.c +++ b/src/g80_exa.c @@ -33,7 +33,7 @@ static void waitMarker(ScreenPtr pScreen, int marker) { - G80Sync(xf86Screens[pScreen->myNum]); + G80Sync(xf86ScreenToScrn(pScreen)); } static Bool @@ -103,7 +103,7 @@ prepareSolid(PixmapPtr pPixmap, Pixel planemask, Pixel fg) { - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); G80Ptr pNv = G80PTR(pScrn); if(pPixmap->drawable.depth > 24) return FALSE; @@ -123,7 +123,7 @@ prepareSolid(PixmapPtr pPixmap, static void solid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) { - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); G80Ptr pNv = G80PTR(pScrn); G80DmaStart(pNv, 0x600, 4); @@ -151,7 +151,7 @@ prepareCopy(PixmapPtr pSrcPixmap, int alu, Pixel planemask) { - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); G80Ptr pNv = G80PTR(pScrn); if(!setSrc(pNv, pSrcPixmap)) return FALSE; @@ -176,7 +176,7 @@ copy(PixmapPtr pDstPixmap, int width, int height) { - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); G80Ptr pNv = G80PTR(pScrn); G80DmaStart(pNv, 0x110, 1); @@ -226,7 +226,7 @@ upload(PixmapPtr pDst, char *src, int src_pitch) { - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen); G80Ptr pNv = G80PTR(pScrn); const int Bpp = pDst->drawable.bitsPerPixel >> 3; int line_dwords = (w * Bpp + 3) / 4; diff --git a/src/g80_output.c b/src/g80_output.c index 2da99cb..13f9b1b 100644 --- a/src/g80_output.c +++ b/src/g80_output.c @@ -254,13 +254,21 @@ static CARD32 i2cAddr(const int port) static void G80_I2CPutBits(I2CBusPtr b, int clock, int data) { +#ifdef XF86_SCRN_INTERFACE + G80Ptr pNv = G80PTR(b->pScrn); +#else G80Ptr pNv = G80PTR(xf86Screens[b->scrnIndex]); +#endif pNv->reg[i2cAddr(b->DriverPrivate.val)/4] = 4 | clock | data << 1; } static void G80_I2CGetBits(I2CBusPtr b, int *clock, int *data) { +#ifdef XF86_SCRN_INTERFACE + G80Ptr pNv = G80PTR(b->pScrn); +#else G80Ptr pNv = G80PTR(xf86Screens[b->scrnIndex]); +#endif unsigned char val; val = pNv->reg[i2cAddr(b->DriverPrivate.val)/4]; @@ -279,6 +287,9 @@ G80I2CInit(ScrnInfoPtr pScrn, const char *name, const int port) i2c->BusName = strdup(name); i2c->scrnIndex = pScrn->scrnIndex; +#ifdef XF86_SCRN_INTERFACE + i2c->pScrn = pScrn; +#endif i2c->I2CPutBits = G80_I2CPutBits; i2c->I2CGetBits = G80_I2CGetBits; i2c->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ @@ -339,9 +350,9 @@ ProbeDDC(I2CBusPtr i2c) pNv->reg[addr/4] = 7; /* Should probably use xf86OutputGetEDID here */ #ifdef EDID_COMPLETE_RAWDATA - monInfo = xf86DoEEDID(pScrn->scrnIndex, i2c, TRUE); + monInfo = xf86DoEEDID(XF86_SCRN_ARG(pScrn), i2c, TRUE); #else - monInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, i2c); + monInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), i2c); #endif pNv->reg[addr/4] = 3; diff --git a/src/g80_type.h b/src/g80_type.h index 270e383..e313b45 100644 --- a/src/g80_type.h +++ b/src/g80_type.h @@ -6,6 +6,7 @@ #include <xf86DDC.h> #include <xf86Crtc.h> +#include "compat-api.h" #define G80_NUM_I2C_PORTS 10 typedef enum Head { diff --git a/src/g80_xaa.c b/src/g80_xaa.c index ce21899..a8ae4ae 100644 --- a/src/g80_xaa.c +++ b/src/g80_xaa.c @@ -486,7 +486,7 @@ G80DisableClipping(ScrnInfoPtr pScrn) Bool G80XAAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); G80Ptr pNv = G80PTR(pScrn); XAAInfoRecPtr xaa; diff --git a/src/nv_cursor.c b/src/nv_cursor.c index 823bb43..d15f754 100644 --- a/src/nv_cursor.c +++ b/src/nv_cursor.c @@ -270,7 +270,7 @@ NVLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) Bool NVCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrn); xf86CursorInfoPtr infoPtr; diff --git a/src/nv_dac.c b/src/nv_dac.c index b6df107..2269ae3 100644 --- a/src/nv_dac.c +++ b/src/nv_dac.c @@ -373,7 +373,11 @@ NVDACLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, static void NV_I2CGetBits(I2CBusPtr b, int *clock, int *data) { +#ifdef XF86_SCRN_INTERFACE + NVPtr pNv = NVPTR(b->pScrn); +#else NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]); +#endif unsigned char val; /* Get the result. */ @@ -387,7 +391,11 @@ NV_I2CGetBits(I2CBusPtr b, int *clock, int *data) static void NV_I2CPutBits(I2CBusPtr b, int clock, int data) { +#ifdef XF86_SCRN_INTERFACE + NVPtr pNv = NVPTR(b->pScrn); +#else NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]); +#endif unsigned char val; VGA_WR08(pNv->PCIO, 0x3d4, pNv->DDCBase + 1); @@ -419,6 +427,9 @@ NVDACi2cInit(ScrnInfoPtr pScrn) I2CPtr->BusName = "DDC"; I2CPtr->scrnIndex = pScrn->scrnIndex; +#ifdef XF86_SCRN_INTERFACE + I2CPtr->pScrn = pScrn; +#endif I2CPtr->I2CPutBits = NV_I2CPutBits; I2CPtr->I2CGetBits = NV_I2CGetBits; I2CPtr->AcknTimeout = 5; diff --git a/src/nv_dga.c b/src/nv_dga.c index 7f8561b..76e5e28 100644 --- a/src/nv_dga.c +++ b/src/nv_dga.c @@ -128,7 +128,7 @@ SECOND_PASS: Bool NVDGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrn); DGAModePtr modes = NULL; int num = 0; @@ -191,8 +191,8 @@ NV_SetMode( memcpy(&pNv->CurrentLayout, &SavedLayouts[index], sizeof(NVFBLayout)); pScrn->currentMode = pNv->CurrentLayout.mode; - NVSwitchMode(index, pScrn->currentMode, 0); - NVAdjustFrame(index, pScrn->frameX0, pScrn->frameY0, 0); + NVSwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode)); + NVAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); pNv->DGAactive = FALSE; } else { if(!pNv->DGAactive) { /* save the old parameters */ @@ -209,7 +209,7 @@ NV_SetMode( pNv->CurrentLayout.weight.green = BitsSet(pMode->green_mask); pNv->CurrentLayout.weight.blue = BitsSet(pMode->blue_mask); /* NVModeInit() will set the mode field */ - NVSwitchMode(index, pMode->mode, 0); + NVSwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode)); } return TRUE; @@ -234,7 +234,7 @@ NV_SetViewport( ){ NVPtr pNv = NVPTR(pScrn); - NVAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + NVAdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y)); while(VGA_RD08(pNv->PCIO, 0x3da) & 0x08); while(!(VGA_RD08(pNv->PCIO, 0x3da) & 0x08)); diff --git a/src/nv_driver.c b/src/nv_driver.c index 527ae5f..5e5c1d6 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -49,17 +49,16 @@ static Bool NVPciProbe(DriverPtr, int entity, struct pci_device*, intptr_t da static Bool NVProbe(DriverPtr drv, int flags); #endif static Bool NVPreInit(ScrnInfoPtr pScrn, int flags); -static Bool NVScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool NVEnterVT(int scrnIndex, int flags); -static Bool NVEnterVTFBDev(int scrnIndex, int flags); -static void NVLeaveVT(int scrnIndex, int flags); -static Bool NVCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool NVScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool NVEnterVT(VT_FUNC_ARGS_DECL); +static Bool NVEnterVTFBDev(VT_FUNC_ARGS_DECL); +static void NVLeaveVT(VT_FUNC_ARGS_DECL); +static Bool NVCloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool NVSaveScreen(ScreenPtr pScreen, int mode); /* Optional functions */ -static void NVFreeScreen(int scrnIndex, int flags); -static ModeStatus NVValidMode(int scrnIndex, DisplayModePtr mode, +static void NVFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus NVValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); #ifdef RANDR static Bool NVDriverFunc(ScrnInfoPtr pScrnInfo, xorgDriverFuncOp op, @@ -1051,31 +1050,31 @@ NVProbe(DriverPtr drv, int flags) /* Usually mandatory */ Bool -NVSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +NVSwitchMode(SWITCH_MODE_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); NVSync(pScrn); return NVModeInit(pScrn, mode); } static Bool -NVSwitchModeVBE(int scrnIndex, DisplayModePtr mode, int flags) +NVSwitchModeVBE(SWITCH_MODE_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); NVPtr pNv = NVPTR(pScrn); const Bool disableAccess = pNv->accessEnabled; if(disableAccess) - pScrn->EnableDisableFBAccess(scrnIndex, FALSE); + pScrn->EnableDisableFBAccess(XF86_SCRN_ARG(pScrn), FALSE); NVSync(pScrn); if (!NVSetModeVBE(pScrn, mode)) return FALSE; - NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + NVAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); if(disableAccess) - pScrn->EnableDisableFBAccess(scrnIndex, TRUE); + pScrn->EnableDisableFBAccess(XF86_SCRN_ARG(pScrn), TRUE); return TRUE; } @@ -1086,9 +1085,9 @@ NVSwitchModeVBE(int scrnIndex, DisplayModePtr mode, int flags) */ /* Usually mandatory */ void -NVAdjustFrame(int scrnIndex, int x, int y, int flags) +NVAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); int startAddr; NVPtr pNv = NVPTR(pScrn); NVFBLayout *pLayout = &pNv->CurrentLayout; @@ -1107,14 +1106,14 @@ NVAdjustFrame(int scrnIndex, int x, int y, int flags) /* Mandatory */ static Bool -NVEnterVT(int scrnIndex, int flags) +NVEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); NVPtr pNv = NVPTR(pScrn); if (!NVModeInit(pScrn, pScrn->currentMode)) return FALSE; - NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + NVAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); if(pNv->overlayAdaptor) NVResetVideo(pScrn); @@ -1122,20 +1121,21 @@ NVEnterVT(int scrnIndex, int flags) } static Bool -NVEnterVTFBDev(int scrnIndex, int flags) +NVEnterVTFBDev(VT_FUNC_ARGS_DECL) { - fbdevHWEnterVT(scrnIndex,flags); + SCRN_INFO_PTR(arg); + fbdevHWEnterVT(VT_FUNC_ARGS); return TRUE; } static Bool -NVEnterVTVBE(int scrnIndex, int flags) +NVEnterVTVBE(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); if (!NVSetModeVBE(pScrn, pScrn->currentMode)) return FALSE; - NVAdjustFrame(scrnIndex, 0, 0, 0); + NVAdjustFrame(ADJUST_FRAME_ARGS(pScrn, 0, 0)); return TRUE; } @@ -1148,9 +1148,9 @@ NVEnterVTVBE(int scrnIndex, int flags) /* Mandatory */ static void -NVLeaveVT(int scrnIndex, int flags) +NVLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); NVPtr pNv = NVPTR(pScrn); NVSync(pScrn); @@ -1159,31 +1159,26 @@ NVLeaveVT(int scrnIndex, int flags) } static void -NVLeaveVTVBE(int scrnIndex, int flags) +NVLeaveVTVBE(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); NVSync(pScrn); NVSaveRestoreVBE(pScrn, MODE_RESTORE); } static void -NVBlockHandler ( - int i, - pointer blockData, - pointer pTimeout, - pointer pReadmask -) +NVBlockHandler (BLOCKHANDLER_ARGS_DECL) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrnInfo = xf86Screens[i]; + SCREEN_PTR(arg); + ScrnInfoPtr pScrnInfo = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrnInfo); if (pNv->DMAKickoffCallback) (*pNv->DMAKickoffCallback)(pScrnInfo); pScreen->BlockHandler = pNv->BlockHandler; - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS); pScreen->BlockHandler = NVBlockHandler; if (pNv->VideoTimerCallback) @@ -1201,9 +1196,9 @@ NVBlockHandler ( /* Mandatory */ static Bool -NVCloseScreen(int scrnIndex, ScreenPtr pScreen) +NVCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrn); if (pScrn->vtSema) { @@ -1236,16 +1231,17 @@ NVCloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = pNv->CloseScreen; pScreen->BlockHandler = pNv->BlockHandler; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } static void -NVEnableDisableFBAccess(int scrnIndex, Bool enable) +NVEnableDisableFBAccess(SCRN_ARG_TYPE arg, Bool enable) { - NVPtr pNv = NVPTR(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + NVPtr pNv = NVPTR(pScrn); pNv->accessEnabled = enable; - pNv->EnableDisableFBAccess(scrnIndex, enable); + pNv->EnableDisableFBAccess(arg, enable); } @@ -1253,15 +1249,16 @@ NVEnableDisableFBAccess(int scrnIndex, Bool enable) /* Optional */ static void -NVFreeScreen(int scrnIndex, int flags) +NVFreeScreen(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]); - NVFreeRec(xf86Screens[scrnIndex]); + vgaHWFreeHWRec(pScrn); + NVFreeRec(pScrn); } @@ -1269,9 +1266,10 @@ NVFreeScreen(int scrnIndex, int flags) /* Optional */ static ModeStatus -NVValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +NVValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { - NVPtr pNv = NVPTR(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + NVPtr pNv = NVPTR(pScrn); if(pNv->fpWidth && pNv->fpHeight) if((pNv->fpWidth < mode->HDisplay) || (pNv->fpHeight < mode->VDisplay)) @@ -2380,7 +2378,7 @@ NVDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) /* This gets called at the start of each server generation */ static Bool -NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +NVScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; vgaHWPtr hwp; @@ -2394,7 +2392,7 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* * First get the ScrnInfoRec */ - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); hwp = VGAHWPTR(pScrn); pNv = NVPTR(pScrn); @@ -2435,7 +2433,7 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ NVSaveScreen(pScreen, SCREEN_SAVER_ON); - pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); /* * The next step is to setup the screen's visuals, and initialise the @@ -2505,7 +2503,7 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) displayWidth, pScrn->bitsPerPixel); break; default: - xf86DrvMsg(scrnIndex, X_ERROR, + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) in NVScreenInit\n", pScrn->bitsPerPixel); ret = FALSE; diff --git a/src/nv_include.h b/src/nv_include.h index a0d5ad1..a40bc7b 100644 --- a/src/nv_include.h +++ b/src/nv_include.h @@ -58,6 +58,7 @@ #include <X11/extensions/randr.h> #endif +#include "compat-api.h" #include "nv_local.h" #include "nv_type.h" #include "nv_proto.h" diff --git a/src/nv_proto.h b/src/nv_proto.h index 142cd4c..0e9fdcc 100644 --- a/src/nv_proto.h +++ b/src/nv_proto.h @@ -2,8 +2,8 @@ #define __NV_PROTO_H__ /* in nv_driver.c */ -Bool NVSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -void NVAdjustFrame(int scrnIndex, int x, int y, int flags); +Bool NVSwitchMode(SWITCH_MODE_ARGS_DECL); +void NVAdjustFrame(ADJUST_FRAME_ARGS_DECL); Bool NVI2CInit(ScrnInfoPtr pScrn); @@ -53,6 +53,6 @@ void NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void NVRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); -void NVPointerMoved(int index, int x, int y); +void NVPointerMoved(SCRN_ARG_TYPE arg, int x, int y); #endif /* __NV_PROTO_H__ */ diff --git a/src/nv_setup.c b/src/nv_setup.c index c11427f..203e7b2 100644 --- a/src/nv_setup.c +++ b/src/nv_setup.c @@ -230,9 +230,9 @@ NVProbeDDC (ScrnInfoPtr pScrn, int bus) "Probing for EDID on I2C bus %s...\n", bus ? "B" : "A"); #ifdef EDID_COMPLETE_RAWDATA - MonInfo = xf86DoEEDID(pScrn->scrnIndex, pNv->I2C, TRUE); + MonInfo = xf86DoEEDID(XF86_SCRN_ARG(pScrn), pNv->I2C, TRUE); #else - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pNv->I2C); + MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), pNv->I2C); #endif if (MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, diff --git a/src/nv_shadow.c b/src/nv_shadow.c index 7f835a1..3946448 100644 --- a/src/nv_shadow.c +++ b/src/nv_shadow.c @@ -42,9 +42,9 @@ NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } void -NVPointerMoved(int index, int x, int y) +NVPointerMoved(SCRN_ARG_TYPE arg, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; + SCRN_INFO_PTR(arg); NVPtr pNv = NVPTR(pScrn); int newX, newY; @@ -56,7 +56,7 @@ NVPointerMoved(int index, int x, int y) newY = pScrn->pScreen->width - x - 1; } - (*pNv->PointerMoved)(index, newX, newY); + (*pNv->PointerMoved)(arg, newX, newY); } void diff --git a/src/nv_type.h b/src/nv_type.h index 8ebb9a8..f7a32a0 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -133,7 +133,7 @@ typedef struct { int numDGAModes; Bool DGAactive; int DGAViewportStatus; - void (*PointerMoved)(int index, int x, int y); + void (*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y); ScreenBlockHandlerProcPtr BlockHandler; CloseScreenProcPtr CloseScreen; xf86EnableDisableFBAccessProc *EnableDisableFBAccess; diff --git a/src/nv_video.c b/src/nv_video.c index ad267bf..52d651b 100644 --- a/src/nv_video.c +++ b/src/nv_video.c @@ -239,7 +239,7 @@ NVAllocateOverlayMemory( xf86FreeOffscreenLinear(linear); } - pScreen = screenInfo.screens[pScrn->scrnIndex]; + pScreen = xf86ScrnToScreen(pScrn); new_linear = xf86AllocateOffscreenLinear(pScreen, size, 32, NULL, NULL, NULL); @@ -287,7 +287,7 @@ static void NVFreeBlitMemory(ScrnInfoPtr pScrnInfo) void NVInitVideo (ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr overlayAdaptor = NULL; XF86VideoAdaptorPtr blitAdaptor = NULL; @@ -343,7 +343,7 @@ void NVInitVideo (ScreenPtr pScreen) static XF86VideoAdaptorPtr NVSetupBlitVideo (ScreenPtr pScreen) { - ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrnInfo = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrnInfo); XF86VideoAdaptorPtr adapt; NVPortPrivPtr pPriv; @@ -406,7 +406,7 @@ NVSetupBlitVideo (ScreenPtr pScreen) static XF86VideoAdaptorPtr NVSetupOverlayVideo (ScreenPtr pScreen) { - ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrnInfo = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrnInfo); XF86VideoAdaptorPtr adapt; NVPortPrivPtr pPriv; diff --git a/src/nv_xaa.c b/src/nv_xaa.c index b29bf38..c179f1f 100644 --- a/src/nv_xaa.c +++ b/src/nv_xaa.c @@ -651,7 +651,7 @@ NVDisableClipping(ScrnInfoPtr pScrn) Bool NVAccelInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); NVPtr pNv = NVPTR(pScrn); XAAInfoRecPtr accel; diff --git a/src/riva_cursor.c b/src/riva_cursor.c index a9c614e..f8dcae1 100644 --- a/src/riva_cursor.c +++ b/src/riva_cursor.c @@ -144,7 +144,7 @@ RivaUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) Bool RivaCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RivaPtr pRiva = RivaPTR(pScrn); xf86CursorInfoPtr infoPtr; diff --git a/src/riva_dac.c b/src/riva_dac.c index 9b7b518..440aa42 100644 --- a/src/riva_dac.c +++ b/src/riva_dac.c @@ -224,7 +224,11 @@ RivaDACLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, static void Riva_I2CGetBits(I2CBusPtr b, int *clock, int *data) { +#ifdef XF86_SCRN_INTERFACE + RivaPtr pRiva = RivaPTR(b->pScrn); +#else RivaPtr pRiva = RivaPTR(xf86Screens[b->scrnIndex]); +#endif unsigned char val; /* Get the result. */ @@ -238,7 +242,11 @@ Riva_I2CGetBits(I2CBusPtr b, int *clock, int *data) static void Riva_I2CPutBits(I2CBusPtr b, int clock, int data) { +#ifdef XF86_SCRN_INTERFACE + RivaPtr pRiva = RivaPTR(b->pScrn); +#else RivaPtr pRiva = RivaPTR(xf86Screens[b->scrnIndex]); +#endif unsigned char val; VGA_WR08(pRiva->riva.PCIO, 0x3d4, pRiva->DDCBase + 1); @@ -270,6 +278,9 @@ RivaDACi2cInit(ScrnInfoPtr pScrn) I2CPtr->BusName = "DDC"; I2CPtr->scrnIndex = pScrn->scrnIndex; +#ifdef XF86_SCRN_INTERFACE + I2CPtr->pScrn = pScrn; +#endif I2CPtr->I2CPutBits = Riva_I2CPutBits; I2CPtr->I2CGetBits = Riva_I2CGetBits; I2CPtr->AcknTimeout = 5; diff --git a/src/riva_dga.c b/src/riva_dga.c index 7a984f1..8dc8c72 100644 --- a/src/riva_dga.c +++ b/src/riva_dga.c @@ -127,7 +127,7 @@ SECOND_PASS: Bool RivaDGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RivaPtr pRiva = RivaPTR(pScrn); DGAModePtr modes = NULL; int num = 0; @@ -184,8 +184,8 @@ Riva_SetMode( memcpy(&pRiva->CurrentLayout, &SavedLayouts[index], sizeof(RivaFBLayout)); pScrn->currentMode = pRiva->CurrentLayout.mode; - RivaSwitchMode(index, pScrn->currentMode, 0); - RivaAdjustFrame(index, pScrn->frameX0, pScrn->frameY0, 0); + RivaSwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode)); + RivaAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); pRiva->DGAactive = FALSE; } else { if(!pRiva->DGAactive) { /* save the old parameters */ @@ -202,7 +202,7 @@ Riva_SetMode( pRiva->CurrentLayout.weight.green = BitsSet(pMode->green_mask); pRiva->CurrentLayout.weight.blue = BitsSet(pMode->blue_mask); /* RivaModeInit() will set the mode field */ - RivaSwitchMode(index, pMode->mode, 0); + RivaSwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode)); } return TRUE; @@ -227,7 +227,7 @@ Riva_SetViewport( ){ RivaPtr pRiva = RivaPTR(pScrn); - RivaAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + RivaAdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y)); while(VGA_RD08(pRiva->riva.PCIO, 0x3da) & 0x08); while(!(VGA_RD08(pRiva->riva.PCIO, 0x3da) & 0x08)); diff --git a/src/riva_driver.c b/src/riva_driver.c index b52f476..b429464 100644 --- a/src/riva_driver.c +++ b/src/riva_driver.c @@ -37,17 +37,16 @@ */ /* Mandatory functions */ static Bool RivaPreInit(ScrnInfoPtr pScrn, int flags); -static Bool RivaScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool RivaEnterVT(int scrnIndex, int flags); -static Bool RivaEnterVTFBDev(int scrnIndex, int flags); -static void RivaLeaveVT(int scrnIndex, int flags); -static Bool RivaCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool RivaScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool RivaEnterVT(VT_FUNC_ARGS_DECL); +static Bool RivaEnterVTFBDev(VT_FUNC_ARGS_DECL); +static void RivaLeaveVT(VT_FUNC_ARGS_DECL); +static Bool RivaCloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool RivaSaveScreen(ScreenPtr pScreen, int mode); /* Optional functions */ -static void RivaFreeScreen(int scrnIndex, int flags); -static ModeStatus RivaValidMode(int scrnIndex, DisplayModePtr mode, +static void RivaFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus RivaValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); /* Internally used functions */ @@ -162,9 +161,10 @@ RivaGetScrnInfoRec(PciChipsets *chips, int chip) /* Usually mandatory */ Bool -RivaSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +RivaSwitchMode(SWITCH_MODE_ARGS_DECL) { - return RivaModeInit(xf86Screens[scrnIndex], mode); + SCRN_INFO_PTR(arg); + return RivaModeInit(pScrn, mode); } /* @@ -173,9 +173,9 @@ RivaSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) */ /* Usually mandatory */ void -RivaAdjustFrame(int scrnIndex, int x, int y, int flags) +RivaAdjustFrame(ADJUST_FRAME_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); int startAddr; RivaPtr pRiva = RivaPTR(pScrn); RivaFBLayout *pLayout = &pRiva->CurrentLayout; @@ -197,21 +197,22 @@ RivaAdjustFrame(int scrnIndex, int x, int y, int flags) /* Mandatory */ static Bool -RivaEnterVT(int scrnIndex, int flags) +RivaEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); if (!RivaModeInit(pScrn, pScrn->currentMode)) return FALSE; - RivaAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + RivaAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); return TRUE; } static Bool -RivaEnterVTFBDev(int scrnIndex, int flags) +RivaEnterVTFBDev(VT_FUNC_ARGS_DECL) { - fbdevHWEnterVT(scrnIndex,flags); + SCRN_INFO_PTR(arg); + fbdevHWEnterVT(VT_FUNC_ARGS); return TRUE; } @@ -224,9 +225,9 @@ RivaEnterVTFBDev(int scrnIndex, int flags) /* Mandatory */ static void -RivaLeaveVT(int scrnIndex, int flags) +RivaLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); RivaPtr pRiva = RivaPTR(pScrn); RivaRestore(pScrn); @@ -244,9 +245,9 @@ RivaLeaveVT(int scrnIndex, int flags) /* Mandatory */ static Bool -RivaCloseScreen(int scrnIndex, ScreenPtr pScreen) +RivaCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RivaPtr pRiva = RivaPTR(pScrn); if (pScrn->vtSema) { @@ -269,22 +270,23 @@ RivaCloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = pRiva->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } /* Free up any persistent data structures */ /* Optional */ static void -RivaFreeScreen(int scrnIndex, int flags) +RivaFreeScreen(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]); - RivaFreeRec(xf86Screens[scrnIndex]); + vgaHWFreeHWRec(pScrn); + RivaFreeRec(pScrn); } @@ -292,7 +294,7 @@ RivaFreeScreen(int scrnIndex, int flags) /* Optional */ static ModeStatus -RivaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +RivaValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { return (MODE_OK); } @@ -999,7 +1001,7 @@ RivaDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) /* This gets called at the start of each server generation */ static Bool -RivaScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +RivaScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; vgaHWPtr hwp; @@ -1014,7 +1016,7 @@ RivaScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* * First get the ScrnInfoRec */ - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); hwp = VGAHWPTR(pScrn); @@ -1052,7 +1054,7 @@ RivaScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ RivaSaveScreen(pScreen, SCREEN_SAVER_ON); - pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); /* @@ -1121,7 +1123,7 @@ RivaScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) displayWidth, pScrn->bitsPerPixel); break; default: - xf86DrvMsg(scrnIndex, X_ERROR, + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) in RivaScreenInit\n", pScrn->bitsPerPixel); ret = FALSE; diff --git a/src/riva_include.h b/src/riva_include.h index 16fd40d..a381e60 100644 --- a/src/riva_include.h +++ b/src/riva_include.h @@ -53,6 +53,7 @@ #include "region.h" +#include "compat-api.h" #include "riva_local.h" #include "riva_type.h" #include "riva_proto.h" diff --git a/src/riva_proto.h b/src/riva_proto.h index e9d7261..e55f79d 100644 --- a/src/riva_proto.h +++ b/src/riva_proto.h @@ -2,8 +2,8 @@ #define __RIVA_PROTO_H__ /* in riva_driver.c */ -Bool RivaSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -void RivaAdjustFrame(int scrnIndex, int x, int y, int flags); +Bool RivaSwitchMode(SWITCH_MODE_ARGS_DECL); +void RivaAdjustFrame(ADJUST_FRAME_ARGS_DECL); Bool RivaI2CInit(ScrnInfoPtr pScrn); const OptionInfoRec * RivaAvailableOptions(int chipid, int busid); Bool RivaGetScrnInfoRec(PciChipsets *chips, int chip); diff --git a/src/riva_setup.c b/src/riva_setup.c index 64726f7..533f6e8 100644 --- a/src/riva_setup.c +++ b/src/riva_setup.c @@ -168,9 +168,9 @@ RivaProbeDDC (ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Probing for EDID...\n"); #ifdef EDID_COMPLETE_RAWDATA - MonInfo = xf86DoEEDID(pScrn->scrnIndex, pRiva->I2C, TRUE); + MonInfo = xf86DoEEDID(XF86_SCRN_ARG(pScrn), pRiva->I2C, TRUE); #else - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pRiva->I2C); + MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), pRiva->I2C); #endif if (MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, diff --git a/src/riva_shadow.c b/src/riva_shadow.c index 24933f9..91398f1 100644 --- a/src/riva_shadow.c +++ b/src/riva_shadow.c @@ -42,9 +42,9 @@ RivaRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } void -RivaPointerMoved(int index, int x, int y) +RivaPointerMoved(SCRN_ARG_TYPE arg, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; + SCRN_INFO_PTR(arg); RivaPtr pRiva = RivaPTR(pScrn); int newX, newY; @@ -56,7 +56,7 @@ RivaPointerMoved(int index, int x, int y) newY = pScrn->pScreen->width - x - 1; } - (*pRiva->PointerMoved)(index, newX, newY); + (*pRiva->PointerMoved)(arg, newX, newY); } void diff --git a/src/riva_type.h b/src/riva_type.h index 456f813..9f0c808 100644 --- a/src/riva_type.h +++ b/src/riva_type.h @@ -86,7 +86,7 @@ typedef struct { void (*Save)(ScrnInfoPtr, vgaRegPtr, RivaRegPtr, Bool); void (*Restore)(ScrnInfoPtr, vgaRegPtr, RivaRegPtr, 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; Bool FBDev; /* Color expansion */ @@ -117,7 +117,7 @@ void RivaRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void RivaRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void RivaRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void RivaRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); -void RivaPointerMoved(int index, int x, int y); +void RivaPointerMoved(SCRN_ARG_TYPE arg, int x, int y); int RivaGetConfig(RivaPtr); diff --git a/src/riva_xaa.c b/src/riva_xaa.c index 0b361b4..ac0a830 100644 --- a/src/riva_xaa.c +++ b/src/riva_xaa.c @@ -457,7 +457,7 @@ Bool RivaAccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RivaPtr pRiva = RivaPTR(pScrn); pRiva->AccelInfoRec = infoPtr = XAACreateInfoRec(); |