[PATCH xf86-video-r128] Separate EXA and XAA initialization

Kevin Brace kevinbrace at gmx.com
Tue Jul 24 20:43:59 UTC 2018


Starting the process of separating legacy XAA and newer EXA
initialization code.

Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
---
 src/r128.h        |  3 ++-
 src/r128_accel.c  | 44 +++++++-------------------------------------
 src/r128_driver.c | 51 ++++++++++++++++++++++++++++++++++-----------------
 src/r128_exa.c    | 31 +++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 55 deletions(-)

diff --git a/src/r128.h b/src/r128.h
index e88e8ec..7438757 100644
--- a/src/r128.h
+++ b/src/r128.h
@@ -514,7 +514,7 @@ extern void        R128EngineFlush(ScrnInfoPtr pScrn);
 extern unsigned    R128INPLL(ScrnInfoPtr pScrn, int addr);
 extern void        R128WaitForVerticalSync(ScrnInfoPtr pScrn);
 
-extern Bool        R128AccelInit(ScreenPtr pScreen);
+extern Bool R128XAAAccelInit(ScreenPtr pScreen);
 extern void        R128EngineInit(ScrnInfoPtr pScrn);
 extern Bool        R128CursorInit(ScreenPtr pScreen);
 
@@ -601,6 +601,7 @@ extern int         R128CCEStop(ScrnInfoPtr pScrn);
 extern void	   R128CopySwap(uint8_t *dst, uint8_t *src, unsigned int size, int swap);
 
 #ifdef USE_EXA
+extern Bool R128EXAAccelInit(ScreenPtr pScreen);
 extern Bool	   R128EXAInit(ScreenPtr pScreen);
 extern Bool	   R128GetDatatypeBpp(int bpp, uint32_t *type);
 extern Bool	   R128GetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset);
diff --git a/src/r128_accel.c b/src/r128_accel.c
index 72cc443..bfadaf6 100644
--- a/src/r128_accel.c
+++ b/src/r128_accel.c
@@ -1901,55 +1901,25 @@ void R128CopySwap(uint8_t *dst, uint8_t *src, unsigned int size, int swap)
 
 /* Initialize XAA for supported acceleration and also initialize the
    graphics hardware for acceleration. */
-Bool R128AccelInit(ScreenPtr pScreen)
+#ifdef HAVE_XAA_H
+Bool
+R128XAAAccelInit(ScreenPtr pScreen)
 {
     ScrnInfoPtr   pScrn = xf86ScreenToScrn(pScreen);
     R128InfoPtr   info  = R128PTR(pScrn);
-
-#ifdef USE_EXA
-    if (info->useEXA) {
-        int errmaj = 0, errmin = 0;
-
-        info->exaReq.majorversion = EXA_VERSION_MAJOR;
-        info->exaReq.minorversion = EXA_VERSION_MINOR;
-
-        xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Loading EXA module...\n");
-        if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, &info->exaReq, &errmaj, &errmin)) {
-            LoaderErrorMsg(NULL, "exa", errmaj, errmin);
-            return FALSE;
-        }
-
-	/* Don't init EXA here because it'll be taken care of in mm init */
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating EXA driver...\n");
-	info->ExaDriver = exaDriverAlloc();
-	if (!info->ExaDriver) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Could not allocate EXA driver...\n");
-	    info->accelOn = FALSE;
-	}
-
-	return TRUE;
-    }
-#endif
-
-#ifndef HAVE_XAA_H
-    return FALSE;
-#else
     XAAInfoRecPtr a;
 
-    if (!info->useEXA) {
-        if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE;
-    }
-
+    if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE;
     if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
 
 #ifdef R128DRI
     if (info->directRenderingEnabled)
-	R128CCEAccelInit(pScrn, a);
+        R128CCEAccelInit(pScrn, a);
     else
 #endif
-	R128MMIOAccelInit(pScrn, a);
+    R128MMIOAccelInit(pScrn, a);
 
     R128EngineInit(pScrn);
     return XAAInit(pScreen, a);
-#endif
 }
+#endif
diff --git a/src/r128_driver.c b/src/r128_driver.c
index 4cc95e6..9725ee2 100644
--- a/src/r128_driver.c
+++ b/src/r128_driver.c
@@ -1565,24 +1565,41 @@ Bool R128VerboseInitEXA(ScreenPtr pScreen)
 }
 #endif
 
-void R128VerboseInitAccel(Bool noAccel, ScreenPtr pScreen)
+void
+R128AccelInit(Bool noAccel, ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn  = xf86ScreenToScrn(pScreen);
     R128InfoPtr info   = R128PTR(pScrn);
 
+    /* Initially, assume that acceleration is off. */
+    info->accelOn = FALSE;
+
     if (!noAccel) {
-	if (R128AccelInit(pScreen)) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration enabled\n");
-	    info->accelOn = TRUE;
-	} else {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Acceleration initialization failed\n");
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration disabled\n");
-	    info->accelOn = FALSE;
-	}
-    } else {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration disabled\n");
-	info->accelOn = FALSE;
+        if (info->useEXA) {
+#ifdef USE_EXA
+            if (R128EXAAccelInit(pScreen)) {
+                info->accelOn = TRUE;
+                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "EXA acceleration enabled.\n");
+            }
+#endif
+        }
+
+        if ((!info->useEXA) ||
+            ((info->useEXA) && (!info->accelOn))) {
+#ifdef HAVE_XAA_H
+            if (R128XAAAccelInit(pScreen)) {
+                info->accelOn = TRUE;
+                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "XAA acceleration enabled.\n");
+            }
+#endif
+        }
+
+        if (!info->accelOn) {
+            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Acceleration disabled.\n");
+        }
     }
 }
 
@@ -1826,7 +1843,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL)
 				width, height);
 	        }
 
-		R128VerboseInitAccel(noAccel, pScreen);
+                R128AccelInit(noAccel, pScreen);
 	    }
 	}
 #ifdef USE_EXA
@@ -1834,7 +1851,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL)
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		       "Filling in EXA memory info\n");
 
-	    R128VerboseInitAccel(noAccel, pScreen);
+            R128AccelInit(noAccel, pScreen);
 	    info->ExaDriver->offScreenBase = pScrn->virtualY * width_bytes;
 
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -1999,7 +2016,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL)
 				width, height);
 	        }
 
-		R128VerboseInitAccel(noAccel, pScreen);
+                R128AccelInit(noAccel, pScreen);
 	    }
 	}
 #ifdef USE_EXA
@@ -2007,7 +2024,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL)
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		       "Filling in EXA memory info\n");
 
-	    R128VerboseInitAccel(noAccel, pScreen);
+            R128AccelInit(noAccel, pScreen);
 	    info->ExaDriver->offScreenBase = pScrn->virtualY * width_bytes;
 
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
diff --git a/src/r128_exa.c b/src/r128_exa.c
index b7501ac..425fd64 100644
--- a/src/r128_exa.c
+++ b/src/r128_exa.c
@@ -394,6 +394,37 @@ R128CCESync(ScreenPtr pScreen, int marker)
 #endif
 
 Bool
+R128EXAAccelInit(ScreenPtr pScreen)
+{
+    ScrnInfoPtr   pScrn = xf86ScreenToScrn(pScreen);
+    R128InfoPtr   info  = R128PTR(pScrn);
+    int errmaj = 0, errmin = 0;
+
+    info->exaReq.majorversion = EXA_VERSION_MAJOR;
+    info->exaReq.minorversion = EXA_VERSION_MINOR;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                "Loading EXA module...\n");
+    if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL,
+                    &info->exaReq, &errmaj, &errmin)) {
+        LoaderErrorMsg(NULL, "exa", errmaj, errmin);
+        return FALSE;
+    }
+
+    /* Don't init EXA here because it'll be taken care of in mm init */
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                "Allocating EXA driver...\n");
+    info->ExaDriver = exaDriverAlloc();
+    if (!info->ExaDriver) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                    "Could not allocate EXA driver...\n");
+        info->accelOn = FALSE;
+    }
+
+    return TRUE;
+}
+
+Bool
 R128EXAInit(ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-- 
2.7.4



More information about the xorg-driver-ati mailing list