[PATCH 5/5] xfree86: vgaarb: hide arbiter device inside ddx privates

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


The arbiter decide doesn't need to be exported to driver. Neither it should be
in the common header files because not all systems want VGA arbitration.

API break.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 hw/xfree86/common/xf86VGAarbiter.c     |   28 ++++++++++++++++++++++------
 hw/xfree86/common/xf86VGAarbiterPriv.h |   11 -----------
 hw/xfree86/common/xf86str.h            |    1 -
 3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 776946a..3e388ea 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -62,6 +62,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
     VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
 };
 
+static int xf86VGAarbiterPrivateIndex;
+#define XF86_VGAARB_DEV_PTR(p) \
+    ((struct pci_device *) ((p)->privates[xf86VGAarbiterPrivateIndex].ptr))
+
 static int VGAarbiterKeyIndex;
 static DevPrivateKey VGAarbiterScreenKey = &VGAarbiterKeyIndex;
 static int VGAarbiterGCIndex;
@@ -90,7 +94,7 @@ xf86VGAarbiterLock(ScrnInfoPtr pScrn)
 {
     if (vga_no_arb)
 	return;
-    pci_device_vgaarb_set_target(pScrn->vgaDev);
+    pci_device_vgaarb_set_target(XF86_VGAARB_DEV_PTR(pScrn));
     pci_device_vgaarb_lock();
 }
 
@@ -111,7 +115,7 @@ Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
     if (vga_no_arb)
 	return TRUE;
 
-    pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
+    pci_device_vgaarb_get_info(XF86_VGAARB_DEV_PTR(pScrn), &vga_count, &rsrc_decodes);
     if (vga_count > 1) {
         if (rsrc_decodes) {
             return FALSE;
@@ -123,7 +127,6 @@ Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
 void
 xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
 {
-    struct pci_device *dev;
     EntityPtr pEnt;
 
     if (vga_no_arb)
@@ -133,8 +136,8 @@ xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
     if (pEnt->bus.type != BUS_PCI)
 	return;
 
-    dev = pEnt->bus.id.pci;
-    pScrn->vgaDev = dev;
+    xf86VGAarbiterPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+    pScrn->privates[xf86VGAarbiterPrivateIndex].ptr = pEnt->bus.id.pci;
 }
 
 void
@@ -142,7 +145,7 @@ xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc)
 {
     if (vga_no_arb)
 	return;
-    pci_device_vgaarb_set_target(pScrn->vgaDev);
+    pci_device_vgaarb_set_target(XF86_VGAARB_DEV_PTR(pScrn));
     pci_device_vgaarb_decodes(rsrc);
 }
 
@@ -215,6 +218,19 @@ xf86VGAarbiterWrapFunctions(void)
     return TRUE;
 }
 
+static inline void
+VGAGet(ScreenPtr pScreen) {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+    pci_device_vgaarb_set_target(XF86_VGAARB_DEV_PTR(pScrn));
+    pci_device_vgaarb_lock();
+}
+
+static inline void
+VGAPut(void) {
+    pci_device_vgaarb_unlock();
+}
+
 /* Screen funcs */
 static Bool
 VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 2920fb5..10c3663 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -93,17 +93,6 @@
     (VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
     (x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
 
-static inline void
-VGAGet(ScreenPtr pScreen) {
-    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
-    pci_device_vgaarb_lock();
-}
-
-static inline void
-VGAPut(void) {
-    pci_device_vgaarb_unlock();
-}
-
 typedef struct _VGAarbiterScreen {
     CreateGCProcPtr             CreateGC;
     CloseScreenProcPtr          CloseScreen;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index c9b261d..078e459 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -782,7 +782,6 @@ typedef struct _ScrnInfoRec {
     int			reservedInt[NUM_RESERVED_INTS];
 
     int *		entityInstanceList;
-    struct pci_device   *vgaDev;
 
     pointer		reservedPtr[NUM_RESERVED_POINTERS];
 
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list