[PATCH 2/2] xfree86: vgaarb: UNFINISHED: hide arbiter device inside dix private structure

Tiago Vignatti tiago.vignatti at nokia.com
Fri May 21 08:48:15 PDT 2010


Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---

This patch is not working so far because ScreenRec is not allocated yet when
dixSetPrivate is being called inside xf86VGAarbiterScrnInit. AddScreen is only
called afterwards.

Now I can think in two choices: either I hide vgaarb device inside DDX
privates (from ScrnInfoRec), or; I try to call AddScreen before, trying to
keep very close from xf86AllocateScreen. As I mentioned in the email I just
sent, seems we might want to deprecate ScrnInfoRec privates.


What are you guys think is more sensible?


 hw/xfree86/common/xf86VGAarbiter.c     |   24 +++++++++++++++++-------
 hw/xfree86/common/xf86VGAarbiterPriv.h |   10 ++++++----
 hw/xfree86/common/xf86str.h            |    1 -
 3 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 185b9c2..f7f3357 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -66,6 +66,8 @@ static DevPrivateKeyRec VGAarbiterScreenKeyRec;
 #define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
 static DevPrivateKeyRec VGAarbiterGCKeyRec;
 #define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
+static DevPrivateKeyRec VGAarbiterDevKeyRec;
+#define VGAarbiterDevKey (&VGAarbiterDevKeyRec)
 
 static int vga_no_arb = 0;
 void
@@ -88,11 +90,13 @@ xf86VGAarbiterFini(void)
 void
 xf86VGAarbiterLock(int scrnIdx)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIdx];
+	ScreenPtr pScreen = screenInfo.screens[scrnIdx];
+	struct pci_device *dev = (struct pci_device *)
+		dixLookupPrivate(&pScreen->devPrivates, VGAarbiterDevKey);
 
     if (vga_no_arb)
 	return;
-    pci_device_vgaarb_set_target(pScrn->vgaDev);
+    pci_device_vgaarb_set_target(dev);
     pci_device_vgaarb_lock();
 }
 
@@ -106,14 +110,15 @@ xf86VGAarbiterUnlock(void)
 
 Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
 {
+    struct pci_device *dev = (struct pci_device *)
+        dixLookupPrivate(&pScreen->devPrivates, VGAarbiterDevKey);
     int vga_count;
     int rsrc_decodes;
-    ScrnInfoPtr         pScrn = xf86Screens[pScreen->myNum];
 
     if (vga_no_arb)
 	return TRUE;
 
-    pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
+    pci_device_vgaarb_get_info(dev, &vga_count, &rsrc_decodes);
     if (vga_count > 1) {
         if (rsrc_decodes) {
             return FALSE;
@@ -126,7 +131,7 @@ void
 xf86VGAarbiterScrnInit(int scrnIdx)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIdx];
-    struct pci_device *dev;
+	ScreenPtr pScreen = screenInfo.screens[scrnIdx];
     EntityPtr pEnt;
 
     if (vga_no_arb)
@@ -136,8 +141,13 @@ xf86VGAarbiterScrnInit(int scrnIdx)
     if (pEnt->bus.type != BUS_PCI)
 	return;
 
-    dev = pEnt->bus.id.pci;
-    pScrn->vgaDev = dev;
+    if (!dixRegisterPrivateKey(&VGAarbiterDevKeyRec, PRIVATE_SCREEN, 0)) {
+	FatalError("%s: private request failed.\n", __FUNCTION__);
+	return;
+	}
+
+    dixSetPrivate(&pScreen->devPrivates, VGAarbiterDevKey,
+				  pEnt->bus.id.pci);
 }
 
 void
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 9b4a597..4fc6703 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -96,12 +96,14 @@
 #define GC_SCREEN register ScrnInfoPtr pScrn = \
     xf86Screens[pGC->pScreen->myNum]
 
-#define VGAGet(x)\
-    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev); \
+#define VGAGet(x) struct pci_device *dev = \
+    (struct pci_device *) dixLookupPrivate(&pScreen->devPrivates, VGAarbiterDevKey); \
+    pci_device_vgaarb_set_target(dev); \
     pci_device_vgaarb_lock();
 
-#define VGAGet_GC(x)\
-    pci_device_vgaarb_set_target(xf86Screens[pGC->pScreen->myNum]->vgaDev); \
+#define VGAGet_GC(x) struct pci_device *dev = \
+    (struct pci_device *) dixLookupPrivate(&pGC->pScreen->devPrivates, VGAarbiterDevKey); \
+    pci_device_vgaarb_set_target(dev); \
     pci_device_vgaarb_lock();
 
 #define VGAPut(x)\
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index de1f1b6..ef36c02 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -783,7 +783,6 @@ typedef struct _ScrnInfoRec {
     int			reservedInt[NUM_RESERVED_INTS];
 
     int *		entityInstanceList;
-    struct pci_device   *vgaDev;
 
     pointer		reservedPtr[NUM_RESERVED_POINTERS];
 
-- 
1.6.0.4



More information about the xorg-devel mailing list