xserver/hw/kdrive/neomagic backend.c, 1.3, 1.3.2.1 backend.h, 1.1, 1.1.2.1 neomagic.c, 1.5, 1.5.2.1 neomagic.h, 1.4, 1.4.2.1

Brent Cook xserver-commit at pdx.freedesktop.org
Wed Apr 7 21:26:04 PDT 2004


Committed by: busterb

Update of /cvs/xserver/xserver/hw/kdrive/neomagic
In directory pdx:/tmp/cvs-serv9113

Modified Files:
      Tag: bcook-backend
	backend.c backend.h neomagic.c neomagic.h 
Log Message:
Fixed backend segfaults by reordering the BackendCard struct to include the
backend's PrivRec structure first. Maybe now I'll read the xserver website
more carefully.

Also, some additions to make adding random testing cards a bit easier, with
CAP_NONE (meaning no acceleration essentially).


Index: backend.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/backend.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- a/backend.c	5 Apr 2004 18:19:34 -0000	1.3
+++ b/backend.c	8 Apr 2004 04:26:01 -0000	1.3.2.1
@@ -15,28 +15,10 @@
 #include "backend.h"
 
 Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend)
+backendInitialize(KdCardInfo *card, BackendCard *backend)
 {
     Bool success = FALSE;
 
-#ifdef KDRIVEVESA
-    if (!success && vesaInitialize(card, &backend->priv.vesa)) {
-        success = TRUE;
-        backend->type = VESA;
-        backend->cardfini = vesaCardFini;
-        backend->scrfini = vesaScreenFini;
-        backend->initScreen = vesaInitScreen;
-        backend->finishInitScreen = vesaFinishInitScreen;
-        backend->createRes = vesaCreateResources;
-        backend->preserve = vesaPreserve;
-        backend->restore = vesaRestore;
-        backend->dpms = vesaDPMS;
-        backend->enable = vesaEnable;
-        backend->disable = vesaDisable;
-        backend->getColors = vesaGetColors;
-        backend->putColors = vesaPutColors;
-    }
-#endif
 #ifdef KDRIVEFBDEV
     if (!success && fbdevInitialize(card, &backend->priv.fbdev)) {
         success = TRUE;
@@ -55,12 +37,30 @@
         backend->putColors = fbdevPutColors;
     }
 #endif
+#ifdef KDRIVEVESA
+    if (!success && vesaInitialize(card, &backend->priv.vesa)) {
+        success = TRUE;
+        backend->type = VESA;
+        backend->cardfini = vesaCardFini;
+        backend->scrfini = vesaScreenFini;
+        backend->initScreen = vesaInitScreen;
+        backend->finishInitScreen = vesaFinishInitScreen;
+        backend->createRes = vesaCreateResources;
+        backend->preserve = vesaPreserve;
+        backend->restore = vesaRestore;
+        backend->dpms = vesaDPMS;
+        backend->enable = vesaEnable;
+        backend->disable = vesaDisable;
+        backend->getColors = vesaGetColors;
+        backend->putColors = vesaPutColors;
+    }
+#endif
     return success;
 }
 
 Bool
 backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard)
+                        BackendCard *backendCard)
 {
     Bool success = FALSE;
 

Index: backend.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/backend.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- a/backend.h	4 Apr 2004 07:30:07 -0000	1.1
+++ b/backend.h	8 Apr 2004 04:26:01 -0000	1.1.2.1
@@ -22,11 +22,9 @@
 
 typedef enum _BackendType {VESA, FBDEV} BackendType;
 
-typedef struct _BackendInfo {
-    // backend info
-    BackendType type;
-
-    // backend internal structures
+typedef struct _BackendCard {
+    // backend internal structures, priv must come first for the backend
+    // routines to find it correctly
     union {
 #ifdef KDRIVEFBDEV
         FbdevPriv fbdev;
@@ -36,6 +34,9 @@
 #endif
     } priv;
 
+    // backend info
+    BackendType type;
+
     // pointers to helper functions for this backend
     void (*cardfini)(KdCardInfo *);
     void (*scrfini)(KdScreenInfo *);
@@ -49,7 +50,7 @@
     void (*disable)(ScreenPtr);
     void (*getColors)(ScreenPtr, int, int, xColorItem *);
     void (*putColors)(ScreenPtr, int, int, xColorItem *);
-} BackendInfo;
+} BackendCard;
 
 typedef union _BackendScreen {
 #ifdef KDRIVEFBDEV
@@ -61,10 +62,10 @@
 } BackendScreen;
 
 Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend);
+backendInitialize(KdCardInfo *card, BackendCard *backend);
 
 Bool
 backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard);
+                        BackendCard *backendCard);
 
 #endif

Index: neomagic.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neomagic.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- a/neomagic.c	5 Apr 2004 18:19:34 -0000	1.5
+++ b/neomagic.c	8 Apr 2004 04:26:01 -0000	1.5.2.1
@@ -77,7 +77,9 @@
 
     iopl(3);
 
-    neoMapReg(card, neoc);
+    if (neoc->chip->caps != CAP_NONE) {
+        neoMapReg(card, neoc);
+    }
 
     card->driver = neoc;
 
@@ -98,9 +100,6 @@
         return FALSE;
     }
 
-	memset (neos, '\0', sizeof (NeoScreenInfo));
-
-
     if(!backendScreenInitialize(screen, &neos->backendScreen, &neoc->backendCard)) {
         xfree(neos);
         return FALSE;
@@ -273,7 +272,9 @@
         return FALSE;
     }
 
-    neoSetMMIO(pScreenPriv->card, neoc);
+    if (neoc->chip->caps != CAP_NONE) {
+        neoSetMMIO(pScreenPriv->card, neoc);
+    }
 
     return TRUE;
 }
@@ -284,7 +285,9 @@
     KdScreenPriv(pScreen);
     neoCardInfo(pScreenPriv);
 
-    neoResetMMIO(pScreenPriv->card, neoc);
+    if (neoc->chip->caps != CAP_NONE) {
+        neoResetMMIO(pScreenPriv->card, neoc);
+    }
 
     neoc->backendCard.disable(pScreen);
 }
@@ -321,7 +324,9 @@
 {
     NeoCardInfo *neoc = card->driver;
 
-    neoResetMMIO(card, neoc);
+    if (neoc->chip->caps != CAP_NONE) {
+        neoResetMMIO(card, neoc);
+    }
     neoc->backendCard.restore(card);
 }
 
@@ -341,7 +346,9 @@
 {
     NeoCardInfo *neoc = card->driver;
 
-    neoUnmapReg(card, neoc);
+    if (neoc->chip->caps != CAP_NONE) {
+        neoUnmapReg(card, neoc);
+    }
     neoc->backendCard.cardfini(card);
 }
 
@@ -351,7 +358,7 @@
 #define neoCursorFini 0       // finiCursor */
 #define neoRecolorCursor 0    // recolorCursor */
 
-KdCardFuncs    neoFuncs = {
+KdCardFuncs neoFuncs = {
     neoCardInit,              // cardinit
     neoScreenInit,            // scrinit
     neoInitScreen,            // initScreen

Index: neomagic.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neomagic.h,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- a/neomagic.h	5 Apr 2004 02:52:35 -0000	1.4
+++ b/neomagic.h	8 Apr 2004 04:26:01 -0000	1.4.2.1
@@ -39,6 +39,7 @@
 #define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
 
 #define NEO_VENDOR 0x10c8
+#define CAP_NONE    0x00 /* Disables all acceleration */
 #define CAP_NM2070  0x01 /* If it's a NM2070 series */
 #define CAP_NM2090  0x02 /* If it's a NM2090 series */
 #define CAP_NM2097  0x03 /* If it's a NM2097 series */
@@ -110,7 +111,7 @@
 } NeoMMIO;
 
 typedef struct _neoCardInfo {
-    BackendInfo backendCard;
+    BackendCard backendCard;
 
     CARD32 reg_base;
     NeoMMIO *mmio;




More information about the xserver-commit mailing list