[PATCH 2/3] xfree86: vgaarb: rework wrapping function

Tiago Vignatti tiago.vignatti at nokia.com
Thu Sep 10 07:52:33 PDT 2009


No semantical changes.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 hw/xfree86/common/xf86Bus.c        |   19 +------
 hw/xfree86/common/xf86VGAarbiter.c |  107 +++++++++++++++++++++---------------
 hw/xfree86/common/xf86VGAarbiter.h |    2 +-
 3 files changed, 66 insertions(+), 62 deletions(-)

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index f0a0723..9d243c1 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -521,30 +521,15 @@ xf86PostProbe(void)
 void
 xf86PostScreenInit(void)
 {
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
-    int vga_count;
-#endif
     if (doFramebufferMode) {
 	SetSIGIOForState(OPERATING);
 	return;
     }
 
-    /*
-     * we need to wrap the arbiter if we have more than
-     * one VGA card - hotplug cries.
-     */
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
-    pci_device_vgaarb_get_info(NULL, &vga_count, NULL);
-    if (vga_count > 1 && xf86Screens) {
-	int i;
-	xf86Msg(X_INFO,"Number of VGA devices: %d: arbiter wrapping enabled\n", vga_count);
-        for (i = 0; i < xf86NumScreens; i++)
-	    xf86VGAarbiterWrapFunctions(xf86Screens[i]->pScreen);
-    }
-#endif
+    xf86VGAarbiterWrapFunctions();
+
     DebugF("PostScreenInit  generation: %i\n",serverGeneration);
     xf86EnterServerState(OPERATING);
-    
 }
 
 /*
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index c389739..9b72331 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -35,6 +35,7 @@
 #ifdef HAVE_PCI_DEVICE_VGAARB_INIT
 #include "xf86VGAarbiterPriv.h"
 #include "xf86Bus.h"
+#include "xf86Priv.h"
 #include "pciaccess.h"
 
 #ifdef DEBUG
@@ -153,59 +154,77 @@ xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn)
 }
 
 Bool
-xf86VGAarbiterWrapFunctions(ScreenPtr pScreen)
+xf86VGAarbiterWrapFunctions(void)
 {
     ScrnInfoPtr pScrn;
     VGAarbiterScreenPtr pScreenPriv;
     miPointerScreenPtr PointPriv;
 #ifdef RENDER
-    PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
+    PictureScreenPtr    ps;
 #endif
+    ScreenPtr pScreen;
+    int vga_count, i;
 
     if (vga_no_arb)
-	return FALSE;
-
-    pScrn = xf86Screens[pScreen->myNum];
-    PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
-    DPRINT_S("VGAarbiterWrapFunctions",pScreen->myNum);
-
-    if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
-    	return FALSE;
-
-    if (!(pScreenPriv = xalloc(sizeof(VGAarbiterScreenRec))))
-    	return FALSE;
-
-    dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);
-
-    WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen);
-    WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen);
-    WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler);
-    WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler);
-    WRAP_SCREEN(CreateGC, VGAarbiterCreateGC);
-    WRAP_SCREEN(GetImage, VGAarbiterGetImage);
-    WRAP_SCREEN(GetSpans, VGAarbiterGetSpans);
-    WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate);
-    WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow);
-    WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground);
-    WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap);
-    WRAP_SCREEN(StoreColors, VGAarbiterStoreColors);
-    WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor);
-    WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor);
-    WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
-    WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
-    WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
+        return FALSE;
+
+    /*
+     * we need to wrap the arbiter if we have more than
+     * one VGA card - hotplug cries.
+     */
+    pci_device_vgaarb_get_info(NULL, &vga_count, NULL);
+    if (vga_count < 2 || !xf86Screens)
+        return FALSE;
+
+    xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n",
+            vga_count);
+
+    for (i = 0; i < xf86NumScreens; i++) {
+        pScreen = xf86Screens[i]->pScreen;
+        ps = GetPictureScreenIfSet(pScreen);
+        pScrn = xf86Screens[pScreen->myNum];
+        PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+        DPRINT_S("VGAarbiterWrapFunctions",pScreen->myNum);
+
+        if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
+            return FALSE;
+
+        if (!(pScreenPriv = xalloc(sizeof(VGAarbiterScreenRec))))
+            return FALSE;
+
+        dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);
+
+        WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen);
+        WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen);
+        WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler);
+        WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler);
+        WRAP_SCREEN(CreateGC, VGAarbiterCreateGC);
+        WRAP_SCREEN(GetImage, VGAarbiterGetImage);
+        WRAP_SCREEN(GetSpans, VGAarbiterGetSpans);
+        WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate);
+        WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow);
+        WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground);
+        WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap);
+        WRAP_SCREEN(StoreColors, VGAarbiterStoreColors);
+        WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor);
+        WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor);
+        WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
+        WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
+        WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
 #ifdef RENDER
-    WRAP_PICT(Composite,VGAarbiterComposite);
-    WRAP_PICT(Glyphs,VGAarbiterGlyphs);
-    WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
+        WRAP_PICT(Composite,VGAarbiterComposite);
+        WRAP_PICT(Glyphs,VGAarbiterGlyphs);
+        WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
 #endif
-    WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
-    WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
-    WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
-    WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT);
-    WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen);
-    WRAP_SPRITE;
+        WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
+        WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
+        WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
+        WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT);
+        WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen);
+        WRAP_SPRITE;
+    }
+
     return TRUE;
 }
 
@@ -1152,6 +1171,6 @@ void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
 Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
 void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
 void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn) {}
-Bool xf86VGAarbiterWrapFunctions(ScreenPtr pScreen) { return FALSE; }
+Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
 
 #endif
diff --git a/hw/xfree86/common/xf86VGAarbiter.h b/hw/xfree86/common/xf86VGAarbiter.h
index 145d31c..904b6b0 100644
--- a/hw/xfree86/common/xf86VGAarbiter.h
+++ b/hw/xfree86/common/xf86VGAarbiter.h
@@ -34,7 +34,7 @@
 extern void xf86VGAarbiterInit(void);
 extern void xf86VGAarbiterFini(void);
 void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn);
-extern Bool xf86VGAarbiterWrapFunctions(ScreenPtr pScreen);
+extern Bool xf86VGAarbiterWrapFunctions(void);
 extern void xf86VGAarbiterLock(ScrnInfoPtr pScrn);
 extern void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn);
 
-- 
1.5.6.3



More information about the xorg-devel mailing list