[PATCH 1/5] xfree86: vgaarb: change macros by inline functions to ease debug

Tiago Vignatti tiago.vignatti at nokia.com
Thu Jun 3 01:34:10 PDT 2010


Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
Reviewed-by: Jamey Sharp <jamey at minilop.net>
---
 hw/xfree86/common/xf86VGAarbiter.c     |  100 ++++++++++++++++----------------
 hw/xfree86/common/xf86VGAarbiterPriv.h |   21 +++++--
 2 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 4a736fc..05ae3e3 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -263,7 +263,7 @@ VGAarbiterBlockHandler(int i,
 {
     ScreenPtr pScreen = screenInfo.screens[i];
     SCREEN_PROLOG(BlockHandler);
-    VGAGet();
+    VGAGet(pScreen);
     pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
     VGAPut();
     SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler);
@@ -274,7 +274,7 @@ VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer
 {
     ScreenPtr pScreen = screenInfo.screens[i];
     SCREEN_PROLOG(WakeupHandler);
-    VGAGet();
+    VGAGet(pScreen);
     pScreen->WakeupHandler(i, blockData, result, pReadmask);
     VGAPut();
     SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler);
@@ -292,7 +292,7 @@ VGAarbiterGetImage (
     ScreenPtr pScreen = pDrawable->pScreen;
     SCREEN_PROLOG(GetImage);
 //    if (xf86Screens[pScreen->myNum]->vtSema) {
-    VGAGet();
+    VGAGet(pScreen);
 //    }
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
               format, planemask, pdstLine);
@@ -313,7 +313,7 @@ VGAarbiterGetSpans (
     ScreenPtr       pScreen = pDrawable->pScreen;
 
     SCREEN_PROLOG (GetSpans);
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
     VGAPut();
     SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans);
@@ -326,7 +326,7 @@ VGAarbiterSourceValidate (
 {
     ScreenPtr   pScreen = pDrawable->pScreen;
     SCREEN_PROLOG (SourceValidate);
-    VGAGet();
+    VGAGet(pScreen);
     if (pScreen->SourceValidate)
     (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
     VGAPut();
@@ -342,7 +342,7 @@ VGAarbiterCopyWindow(
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
     SCREEN_PROLOG (CopyWindow);
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
     VGAPut();
     SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow);
@@ -358,7 +358,7 @@ VGAarbiterClearToBackground (
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
     SCREEN_PROLOG ( ClearToBackground);
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
     VGAPut();
     SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
@@ -370,7 +370,7 @@ VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usag
     PixmapPtr pPix;
 
     SCREEN_PROLOG ( CreatePixmap);
-    VGAGet();
+    VGAGet(pScreen);
     pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
     VGAPut();
     SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
@@ -384,7 +384,7 @@ VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
     Bool val;
 
     SCREEN_PROLOG (SaveScreen);
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreen->SaveScreen) (pScreen, unblank);
     VGAPut();
     SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen);
@@ -401,7 +401,7 @@ VGAarbiterStoreColors (
     ScreenPtr pScreen = pmap->pScreen;
 
     SCREEN_PROLOG (StoreColors);
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreen->StoreColors) (pmap,ndef,pdefs);
     VGAPut();
     SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors);
@@ -416,7 +416,7 @@ VGAarbiterRecolorCursor (
     )
 {
     SCREEN_PROLOG (RecolorCursor);
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
     VGAPut();
     SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor);
@@ -432,7 +432,7 @@ VGAarbiterRealizeCursor (
     Bool val;
 
     SCREEN_PROLOG (RealizeCursor);
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
     VGAPut();
     SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor);
@@ -449,7 +449,7 @@ VGAarbiterUnrealizeCursor (
     Bool val;
 
     SCREEN_PROLOG (UnrealizeCursor);
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
     VGAPut();
     SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor);
@@ -466,7 +466,7 @@ VGAarbiterDisplayCursor (
     Bool val;
 
     SCREEN_PROLOG (DisplayCursor);
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
     VGAPut();
     SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor);
@@ -483,7 +483,7 @@ VGAarbiterSetCursorPosition (
     Bool val;
 
     SCREEN_PROLOG (SetCursorPosition);
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
     VGAPut();
     SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition);
@@ -497,7 +497,7 @@ VGAarbiterAdjustFrame(int index, int x, int y, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreenPriv->AdjustFrame)(index, x, y, flags);
     VGAPut();
 }
@@ -510,7 +510,7 @@ VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreenPriv->SwitchMode)(index, mode, flags);
     VGAPut();
     return val;
@@ -524,7 +524,7 @@ VGAarbiterEnterVT(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    VGAGet();
+    VGAGet(pScreen);
     val = (*pScreenPriv->EnterVT)(index, flags);
     VGAPut();
     return val;
@@ -537,7 +537,7 @@ VGAarbiterLeaveVT(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreenPriv->LeaveVT)(index, flags);
     VGAPut();
 }
@@ -549,7 +549,7 @@ VGAarbiterFreeScreen(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*pScreenPriv->FreeScreen)(index, flags);
     VGAPut();
 }
@@ -562,7 +562,7 @@ VGAarbiterCreateGC(GCPtr pGC)
     Bool         ret;
 
     SCREEN_PROLOG(CreateGC);
-    VGAGet();
+    VGAGet(pScreen);
     ret = (*pScreen->CreateGC)(pGC);
     VGAPut();
     GC_WRAP(pGC);
@@ -652,7 +652,7 @@ VGAarbiterFillSpans(
     int fSorted )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -669,7 +669,7 @@ VGAarbiterSetSpans(
     int         fSorted )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -686,7 +686,7 @@ VGAarbiterPutImage(
     char    *pImage )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
               leftPad, format, pImage);
     VGAPut_GC();
@@ -705,7 +705,7 @@ VGAarbiterCopyArea(
     RegionPtr ret;
 
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     ret = (*pGC->ops->CopyArea)(pSrc, pDst,
                 pGC, srcx, srcy, width, height, dstx, dsty);
     VGAPut_GC();
@@ -726,7 +726,7 @@ VGAarbiterCopyPlane(
     RegionPtr ret;
 
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
                  width, height, dstx, dsty, bitPlane);
     VGAPut_GC();
@@ -743,7 +743,7 @@ VGAarbiterPolyPoint(
     xPoint *pptInit )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -759,7 +759,7 @@ VGAarbiterPolylines(
     DDXPointPtr pptInit )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -773,7 +773,7 @@ VGAarbiterPolySegment(
     xSegment    *pSeg )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -787,7 +787,7 @@ VGAarbiterPolyRectangle(
     xRectangle  *pRectsInit )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -801,7 +801,7 @@ VGAarbiterPolyArc(
     xArc    *parcs )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -817,7 +817,7 @@ VGAarbiterFillPolygon(
     DDXPointPtr ptsIn )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -831,7 +831,7 @@ VGAarbiterPolyFillRect(
     xRectangle  *prectInit)
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -845,7 +845,7 @@ VGAarbiterPolyFillArc(
     xArc    *parcs )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -863,7 +863,7 @@ VGAarbiterPolyText8(
     int ret;
 
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -882,7 +882,7 @@ VGAarbiterPolyText16(
     int ret;
 
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -899,7 +899,7 @@ VGAarbiterImageText8(
     char    *chars )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -915,7 +915,7 @@ VGAarbiterImageText16(
     unsigned short *chars )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -932,7 +932,7 @@ VGAarbiterImageGlyphBlt(
     pointer pglyphBase )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
                    nglyph, ppci, pglyphBase);
     VGAPut_GC();
@@ -949,7 +949,7 @@ VGAarbiterPolyGlyphBlt(
     pointer pglyphBase )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
                   nglyph, ppci, pglyphBase);
     VGAPut_GC();
@@ -964,7 +964,7 @@ VGAarbiterPushPixels(
     int dx, int dy, int xOrg, int yOrg )
 {
     GC_UNWRAP(pGC);
-    VGAGet_GC();
+    VGAGet_GC(pGC);
     (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
     VGAPut_GC();
     GC_WRAP(pGC);
@@ -977,7 +977,7 @@ VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pC
 {
     Bool val;
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
     VGAPut();
     SPRITE_EPILOG;
@@ -989,7 +989,7 @@ VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr
 {
     Bool val;
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
     VGAPut();
     SPRITE_EPILOG;
@@ -1000,7 +1000,7 @@ static void
 VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
 {
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y);
     VGAPut();
     SPRITE_EPILOG;
@@ -1010,7 +1010,7 @@ static void
 VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
 {
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y);
     VGAPut();
     SPRITE_EPILOG;
@@ -1021,7 +1021,7 @@ VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     Bool val;
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
     VGAPut();
     SPRITE_EPILOG;
@@ -1032,7 +1032,7 @@ static void
 VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     SPRITE_PROLOG;
-    VGAGet();
+    VGAGet(pScreen);
     PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
     VGAPut();
     SPRITE_EPILOG;
@@ -1049,7 +1049,7 @@ VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
 
     PICTURE_PROLOGUE(Composite);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
               yDst, width, height);
     VGAPut();
@@ -1066,7 +1066,7 @@ VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 
     PICTURE_PROLOGUE(Glyphs);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
     VGAPut();
     PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs);
@@ -1081,7 +1081,7 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe
 
     PICTURE_PROLOGUE(CompositeRects);
 
-    VGAGet();
+    VGAGet(pScreen);
     (*ps->CompositeRects)(op, pDst, color, nRect, rects);
     VGAPut();
     PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 9b4a597..badac55 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -96,20 +96,27 @@
 #define GC_SCREEN register ScrnInfoPtr pScrn = \
     xf86Screens[pGC->pScreen->myNum]
 
-#define VGAGet(x)\
-    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev); \
+static inline void
+VGAGet(ScreenPtr pScreen) {
+    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
     pci_device_vgaarb_lock();
+}
 
-#define VGAGet_GC(x)\
-    pci_device_vgaarb_set_target(xf86Screens[pGC->pScreen->myNum]->vgaDev); \
+static inline void
+VGAGet_GC(GC *pGC) {
+    pci_device_vgaarb_set_target(xf86Screens[pGC->pScreen->myNum]->vgaDev);
     pci_device_vgaarb_lock();
+}
 
-#define VGAPut(x)\
+static inline void
+VGAPut(void) {
     pci_device_vgaarb_unlock();
+}
 
-#define VGAPut_GC(x)\
+static inline void
+VGAPut_GC(void) {
     pci_device_vgaarb_unlock();
-
+}
 
 typedef struct _VGAarbiterScreen {
     CreateGCProcPtr             CreateGC;
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list