xserver/hw/kdrive/neomagic backend.c, NONE, 1.1 backend.h, NONE, 1.1 Makefile.am, 1.1, 1.2 neo_draw.c, 1.1, 1.2 neomagic.c, 1.2, 1.3 neomagic.h, 1.2, 1.3 neomagicstub.c, 1.2, 1.3

Brent Cook xserver-commit at pdx.freedesktop.org
Sat Apr 3 23:30:10 PST 2004


Committed by: busterb

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

Modified Files:
	Makefile.am neo_draw.c neomagic.c neomagic.h neomagicstub.c 
Added Files:
	backend.c backend.h 
Log Message:
Begin separating VESA calls into a more generic backend wrapper like the ati
driver, cascading between VESA and FBDEV.
We only have init functions done so far; need to add all of the others.
Fixed some compiler warnings.
Whitespace and formatting cleanups (using 4 spaces, no tabs)


--- NEW FILE: backend.c ---
/*
 * Generic card driving functions.
 * Essentially, cascades calls to fbdev and vesa to initialize cards that
 * do not have hardware-specific routines yet. Copied from the ati driver.
 *
 * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
 *
 * This code is licensed under the GPL.  See the file COPYING in the root
 * directory of the sources for details.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "backend.h"

Bool
backendInitialize(KdCardInfo *card, BackendInfo *backend)
{
    Bool success = FALSE;

#ifdef KDRIVEFBDEV
    if (!success && fbdevInitialize(card, &backend->priv.fbdev)) {
        success = TRUE;
        backend->type = FBDEV;
        backend->cardfini = fbdevCardFini;
        backend->scrfini = fbdevScreenFini;
        backend->initScreen = fbdevInitScreen;
        backend->finishInitScreen = fbdevFinishInitScreen;
        backend->createRes = fbdevCreateResources;
        backend->preserve = fbdevPreserve;
        backend->restore = fbdevRestore;
        backend->dpms = fbdevDPMS;
        backend->enable = fbdevEnable;
        backend->disable = fbdevDisable;
        backend->getColors = fbdevGetColors;
        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)
{
    Bool success = FALSE;

#ifdef KDRIVEFBDEV
    if (backendCard->type == FBDEV) {
        success = fbdevScreenInitialize(screen, &backendScreen->fbdev);
        screen->memory_size = backendCard->priv.fbdev.fix.smem_len;
        screen->off_screen_base = backendCard->priv.fbdev.var.yres_virtual
                                * screen->fb[0].byteStride;
    }
#endif
#ifdef KDRIVEVESA
    if (backendCard->type == VESA) {
        if (screen->fb[0].depth == 0) {
            screen->fb[0].depth = 16;
        }
        success = vesaScreenInitialize(screen, &backendScreen->vesa);
    }
#endif
    return success;
}

--- NEW FILE: backend.h ---
/*
 * Generic card driving functions.
 * Essentially, cascades calls to fbdev and vesa to initialize cards that
 * do not have hardware-specific routines yet. Copied from the ati driver.
 *
 * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
 *
 * This code is licensed under the GPL.  See the file COPYING in the root
 * directory of the sources for details.
 */

#ifndef _BACKEND_H_
#define _BACKEND_H_
#include "kdrive.h"

#ifdef KDRIVEFBDEV
#include <fbdev.h>
#endif
#ifdef KDRIVEVESA
#include <vesa.h>
#endif

typedef enum _BackendType {VESA, FBDEV} BackendType;

typedef struct _BackendInfo {
    // backend info
    BackendType type;

    // backend internal structures
    union {
#ifdef KDRIVEFBDEV
        FbdevPriv fbdev;
#endif
#ifdef KDRIVEVESA
        VesaCardPrivRec vesa;
#endif
    } priv;

    // pointers to helper functions for this backend
    void (*cardfini)(KdCardInfo *);
    void (*scrfini)(KdScreenInfo *);
    Bool (*initScreen)(ScreenPtr);
    Bool (*finishInitScreen)(ScreenPtr pScreen);
    Bool (*createRes)(ScreenPtr);
    void (*preserve)(KdCardInfo *);
    void (*restore)(KdCardInfo *);
    Bool (*dpms)(ScreenPtr, int);
    Bool (*enable)(ScreenPtr);
    void (*disable)(ScreenPtr);
    void (*getColors)(ScreenPtr, int, int, xColorItem *);
    void (*putColors)(ScreenPtr, int, int, xColorItem *);
} BackendInfo;

typedef union _BackendScreen {
#ifdef KDRIVEFBDEV
    FbdevScrPriv fbdev;
#endif
#ifdef KDRIVEVESA
    VesaScreenPrivRec vesa;
#endif
} BackendScreen;

Bool
backendInitialize(KdCardInfo *card, BackendInfo *backend);

Bool
backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
                        BackendInfo *backendCard);

#endif

Index: Makefile.am
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- a/Makefile.am	3 Apr 2004 22:22:48 -0000	1.1
+++ b/Makefile.am	4 Apr 2004 07:30:07 -0000	1.2
@@ -1,28 +1,42 @@
-INCLUDES = 					\
-	@KDRIVE_INCS@				\
-	-I$(top_srcdir)/hw/kdrive/vesa		\
+if KDRIVEFBDEV
+FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
+FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+endif
+
+if KDRIVEVESA
+VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+endif
+
+INCLUDES =                      \
+	@KDRIVE_INCS@               \
+	$(FBDEV_INCLUDES)           \
+	$(VESA_INCLUDES)            \
 	@XSERVER_CFLAGS@
 
 bin_PROGRAMS = Xneomagic
 
 noinst_LIBRARIES = libneomagic.a
 
-libneomagic_a_SOURCES = 	\
-	neomagic.c	\
-	neomagic.h	\
+libneomagic_a_SOURCES =         \
+	backend.h                   \
+	backend.c                   \
+	neomagic.c                  \
+	neomagic.h                  \
 	neo_draw.c
 
 Xneomagic_SOURCES = \
 	neomagicstub.c
 
-NEOMAGIC_LIBS =					\
-	libneomagic.a 				\
-	$(top_builddir)/hw/kdrive/vesa/libvesa.a \
+NEOMAGIC_LIBS =                 \
+	libneomagic.a               \
+	${FBDEV_LIBS}               \
+	${VESA_LIBS}                \
 	@KDRIVE_LIBS@
 
 Xneomagic_LDADD = \
-	$(NEOMAGIC_LIBS)				\
-	@KDRIVE_LIBS@				\
+	$(NEOMAGIC_LIBS)            \
+	@KDRIVE_LIBS@               \
 	@XSERVER_LIBS@
 
 Xneomagic_DEPENDENCIES = $(NEOMAGIC_LIBS) @KDRIVE_LIBS@

Index: neo_draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neo_draw.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- a/neo_draw.c	3 Apr 2004 22:22:48 -0000	1.1
+++ b/neo_draw.c	4 Apr 2004 07:30:07 -0000	1.2
@@ -26,126 +26,106 @@
 #endif
 #include "neomagic.h"
 
-#include	<X11/Xmd.h>
-#include	"gcstruct.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"regionstr.h"
-#include	"mistruct.h"
-#include	"fontstruct.h"
-#include	"dixfontstr.h"
-#include	"fb.h"
-#include	"migc.h"
-#include	"miline.h"
-#include	"picturestr.h"
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
 
-static inline void neoWaitIdle( NeoCardInfo *neoc)
+static inline void neoWaitIdle(NeoCardInfo *neoc)
 {
-	// if MMIO is not working it may halt the machine
+    // if MMIO is not working it may halt the machine
     int i = 0;
     while ((neoc->mmio->bltStat & 1) && ++i<10000);
     if (i>=10000) DBGOUT("Wait Idle timeout");
 }
 
-static inline void neoWaitFifo(NeoCardInfo *neoc,
-                                     int requested_fifo_space )
+static inline void neoWaitFifo(NeoCardInfo *neoc, int requested_fifo_space)
 {
-  neoWaitIdle( neoc );
+    neoWaitIdle( neoc );
 }
 
-NeoMMIO           *mmio;
+NeoMMIO       *mmio;
 NeoScreenInfo *screen;
-NeoCardInfo *card;
-CARD32	fgColor;
+NeoCardInfo   *card;
+CARD32        fgColor;
 
-static Bool neoPrepareSolid(PixmapPtr    pPixmap,
-		     int	    alu,
-		     Pixel	    pm,
-		     Pixel	    fg)
+static Bool neoPrepareSolid(PixmapPtr pPixmap,
+                            int alu,
+                            Pixel pm,
+                            Pixel fg)
 {
-	FbBits  depthMask = FbFullMask(pPixmap->drawable.depth);
-	
-	if ((pm & depthMask) != depthMask)
-	{
-		return FALSE;
-	}
-	else
-	{
-		fgColor = fg;
-		neoWaitIdle(card);
-		/* set blt control */
-		mmio->bltCntl = 
-			NEO_BC0_SRC_IS_FG    |
-			NEO_BC3_SRC_XY_ADDR |
-			NEO_BC3_DST_XY_ADDR |
-			NEO_BC3_SKIP_MAPPING |  0x0c0000;
-		
-		mmio->fgColor = fgColor;
-		return TRUE;
-	}
+    FbBits depthMask = FbFullMask(pPixmap->drawable.depth);
+
+    if ((pm & depthMask) != depthMask) {
+        return FALSE;
+    } else {
+        fgColor = fg;
+        neoWaitIdle(card);
+        /* set blt control */
+        mmio->bltCntl =
+            NEO_BC0_SRC_IS_FG    |
+            NEO_BC3_SRC_XY_ADDR |
+            NEO_BC3_DST_XY_ADDR |
+            NEO_BC3_SKIP_MAPPING |  0x0c0000;
+
+        mmio->fgColor = fgColor;
+        return TRUE;
+    }
 }
 
-void
-neoSolid (int x1, int y1, int x2, int y2)
+static void neoSolid (int x1, int y1, int x2, int y2)
 {
-	DBGOUT("Solid (%i, %i) - (%i, %i).  \n", x1, y1, x2, y2);		
-	int x, y, w, h;
-	x = x1;
-	y = y1;
-	w = x2-x1 + 1;
-	h = y2-y1 + 1;
-	if (x1>x2)
-	{
-		x = x2;
-		w = -w;
-	}
-	if (y1>y2)
-	{
-		y = y2;
-		h = -h;
-	}
-	
-	neoWaitIdle(card);
-	mmio->dstStart = (y <<16) | (x & 0xffff);
+    DBGOUT("Solid (%i, %i) - (%i, %i).  \n", x1, y1, x2, y2);
+    int x, y, w, h;
+    x = x1;
+    y = y1;
+    w = x2-x1 + 1;
+    h = y2-y1 + 1;
+    if (x1>x2) {
+        x = x2;
+        w = -w;
+    }
+    if (y1>y2) {
+        y = y2;
+        h = -h;
+    }
 
-	mmio->xyExt    = (h << 16) | (w & 0xffff);
-	DBGOUT("Solid (%i, %i) - (%i, %i).  Color %x\n", x, y, w, h, fgColor);		
-	DBGOUT("Offset %lx. Extent %lx\n",mmio->dstStart, mmio->xyExt);		
+    neoWaitIdle(card);
+    mmio->dstStart = (y <<16) | (x & 0xffff);
+
+    mmio->xyExt    = (h << 16) | (w & 0xffff);
+    DBGOUT("Solid (%i, %i) - (%i, %i).  Color %li\n", x, y, w, h, fgColor);
+    DBGOUT("Offset %lx. Extent %lx\n",mmio->dstStart, mmio->xyExt);
 }
 
 
-void
-neoDoneSolid(void)
+static void neoDoneSolid(void)
 {
 }
 
-Bool
-neoPrepareCopy (PixmapPtr	pSrcPixpam,
-		    PixmapPtr	pDstPixmap,
-		    int		dx,
-		    int		dy,
-		    int		alu,
-		    Pixel	pm)
+static Bool neoPrepareCopy (PixmapPtr pSrcPixpam, PixmapPtr pDstPixmap,
+                     int dx, int dy, int alu, Pixel pm)
 {
-	return TRUE;
+    return TRUE;
 }
 
-void
-neoCopy (int srcX,
-	     int srcY,
-	     int dstX,
-	     int dstY,
-	     int w,
-	     int h)
+static void neoCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
 {
 }
 
-void
-neoDoneCopy (void)
+static void neoDoneCopy (void)
 {
 }
 
-KaaScreenInfoRec    neoKaa = {
+KaaScreenInfoRec neoKaa = {
     neoPrepareSolid,
     neoSolid,
     neoDoneSolid,
@@ -155,57 +135,53 @@
     neoDoneCopy
 };
 
-Bool
-neoDrawInit (ScreenPtr pScreen)
+Bool neoDrawInit (ScreenPtr pScreen)
 {
     ENTER();
 //    SetupNeo(pScreen);
 //    PictureScreenPtr    ps = GetPictureScreen(pScreen);
-    
-    if (!kaaDrawInit (pScreen, &neoKaa))
-	return FALSE;
+
+    if (!kaaDrawInit (pScreen, &neoKaa)) {
+        return FALSE;
+    }
 
 //    if (ps && tridents->off_screen)
-//	ps->Composite = tridentComposite;
+//    ps->Composite = tridentComposite;
     LEAVE();
     return TRUE;
 }
 
-void
-neoDrawEnable (ScreenPtr pScreen)
+void neoDrawEnable (ScreenPtr pScreen)
 {
     ENTER();
     SetupNeo(pScreen);
     screen = neos;
     card = neoc;
     mmio = neoc->mmio;
-    DBGOUT("NEO AA MMIO=%lx\n", mmio);
-    screen->depth = screen->vesa.mode.BitsPerPixel/8;
-    screen->pitch = screen->vesa.mode.BytesPerScanLine;
-    DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch);
+    DBGOUT("NEO AA MMIO=%p\n", mmio);
+//    screen->depth = screen->vesa.mode.BitsPerPixel/8;
+//    screen->pitch = screen->vesa.mode.BytesPerScanLine;
+//    DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch);
     LEAVE();
 }
 
-void
-neoDrawDisable (ScreenPtr pScreen)
+void neoDrawDisable (ScreenPtr pScreen)
 {
     ENTER();
     LEAVE();
 }
 
-void
-neoDrawFini (ScreenPtr pScreen)
+void neoDrawFini (ScreenPtr pScreen)
 {
     ENTER();
     LEAVE();
 }
 
-void
-neoDrawSync (ScreenPtr pScreen)
+void neoDrawSync (ScreenPtr pScreen)
 {
     ENTER();
     SetupNeo(pScreen);
-    
+
     neoWaitIdle(neoc);
     LEAVE();
 }

Index: neomagic.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neomagic.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/neomagic.c	3 Apr 2004 22:26:37 -0000	1.2
+++ b/neomagic.c	4 Apr 2004 07:30:07 -0000	1.3
@@ -52,18 +52,18 @@
 static Bool
 neoCardInit (KdCardInfo *card)
 {
-	NeoCardInfo	*neoc;
+    NeoCardInfo    *neoc;
     struct NeoChipInfo *chip;
-	
-	neoc = (NeoCardInfo *) xalloc (sizeof (NeoCardInfo));
-	if (!neoc)
-		return FALSE;
-    
-	if (!vesaInitialize (card, &neoc->vesa))
-	{
-		xfree (neoc);
-		return FALSE;
-	}
+
+    neoc = (NeoCardInfo *) xalloc (sizeof (NeoCardInfo));
+    if (!neoc) {
+        return FALSE;
+    }
+
+    if (!backendInitialize(card, &neoc->backendCard)) {
+        xfree (neoc);
+        return FALSE;
+    }
 
     for (chip = neoChips; chip->name != NULL; ++chip) {
         if (chip->device == card->attr.deviceID) {
@@ -74,51 +74,56 @@
 
     ErrorF("Using Neomagic card: %s\n", neoc->chip->name);
 
-    iopl (3);
-	neoMapReg (card, neoc);
+    neoMapReg (card, neoc);
 
     card->driver = neoc;
-    
+
     return TRUE;
 }
 
 static Bool
 neoScreenInit (KdScreenInfo *screen)
 {
-	NeoCardInfo	*neoc = screen->card->driver;
-	NeoScreenInfo	*neos;
-	int			screen_size, memory;
-	
-	neos = (NeoScreenInfo *) xalloc (sizeof (NeoScreenInfo));
-	if (!neos)
-		return FALSE;
-	memset (neos, '\0', sizeof (NeoScreenInfo));
-	if (!vesaScreenInitialize (screen, &neos->vesa))
-	{
-		xfree (neos);
-		return FALSE;
-	}
-	if (!neoc->reg_base)
-		screen->dumb = TRUE; 
-	if (neos->vesa.mapping != VESA_LINEAR)
-		screen->dumb = TRUE;
-	screen->softCursor = TRUE;	// no hardware color cursor available
-	neos->screen = neos->vesa.fb;
-	memory = neos->vesa.fb_size;
-	screen_size = screen->fb[0].byteStride * screen->height;
-	memory -= screen_size;
-	if (memory > screen->fb[0].byteStride)
-	{
-		neos->off_screen = neos->screen + screen_size;
-		neos->off_screen_size = memory;
-	}
-	else
-	{
-		neos->off_screen = 0;
-		neos->off_screen_size = 0;
-	}
-	screen->driver = neos;
-	return TRUE;
+    NeoCardInfo *neoc = screen->card->driver;
+    NeoScreenInfo *neos;
+    int screen_size, memory;
+
+    neos = (NeoScreenInfo *) xalloc (sizeof (NeoScreenInfo));
+    if (!neos) {
+        return FALSE;
+    }
+    memset (neos, '\0', sizeof (NeoScreenInfo));
+
+    if (!backendScreenInitialize (screen, &neos->backendScreen, &neoc->backendCard)) {
+        xfree (neos);
+        return FALSE;
+    }
+
+    screen->softCursor = TRUE;    // no hardware color cursor available
+
+    switch (neoc->backendCard.type) {
+        case VESA:
+            neos->screen = neos->backendScreen.vesa.fb;
+            break;
+        case FBDEV:
+            neos->screen = neoc->backendCard.priv.fbdev.fb;
+            break;
+    }
+
+    memory = neoc->chip->linearSize * 1024;
+    screen_size = screen->fb[0].byteStride * screen->height;
+    memory -= screen_size;
+
+    if (memory > screen->fb[0].byteStride) {
+        neos->off_screen = neos->screen + screen_size;
+        neos->off_screen_size = memory;
+    } else {
+        neos->off_screen = 0;
+        neos->off_screen_size = 0;
+    }
+    screen->driver = neos;
+
+    return TRUE;
 }
 
 static Bool
@@ -130,7 +135,7 @@
 static Bool
 neoFinishInitScreen (ScreenPtr pScreen)
 {
-    Bool    ret;
+    Bool ret;
     ret = vesaFinishInitScreen (pScreen);
     return ret;
 }
@@ -151,74 +156,73 @@
 void
 neoSetIndex (NeoCardInfo *nvidiac, CARD16 addr,  CARD8 index, CARD8 val)
 {
-	outb(index, addr);
-	outb(val, addr+1);
+    outb(index, addr);
+    outb(val, addr+1);
 }
 
 static void neoLock(NeoCardInfo *neoc){
-	CARD8 cr11;
-	neoSetIndex(neoc, 0x3ce,  0x09, 0x00);
-	cr11 = neoGetIndex (neoc, 0x3d4, 0x11);
-	neoSetIndex (neoc, 0x3d4, 0x11, cr11 | 0x80);
+    CARD8 cr11;
+    neoSetIndex(neoc, 0x3ce,  0x09, 0x00);
+    cr11 = neoGetIndex (neoc, 0x3d4, 0x11);
+    neoSetIndex (neoc, 0x3d4, 0x11, cr11 | 0x80);
 }
 
 static void neoUnlock(NeoCardInfo *neoc){
-	CARD8 cr11;
-	cr11 = neoGetIndex (neoc, 0x3d4, 0x11);
-	neoSetIndex (neoc, 0x3d4, 0x11, cr11 & 0x7F);
-	neoSetIndex(neoc, 0x3ce,  0x09, 0x26);
+    CARD8 cr11;
+    cr11 = neoGetIndex (neoc, 0x3d4, 0x11);
+    neoSetIndex (neoc, 0x3d4, 0x11, cr11 & 0x7F);
+    neoSetIndex(neoc, 0x3ce,  0x09, 0x26);
 }
 
 
 Bool
 neoMapReg (KdCardInfo *card, NeoCardInfo *neoc)
 {
-	ENTER();
-	neoc->reg_base = card->attr.address[1] & 0xFFF80000;
-	if (!neoc->reg_base)
-	{
-		return FALSE;
-	}	
-	
-	neoc->mmio = KdMapDevice(neoc->reg_base, NEO_REG_SIZE(card));
-	if (!neoc->mmio)
-	{
-		return FALSE;
-	}	
-	
-	KdSetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
-	
-	// if you see the cursor sprite them MMIO is working
-	
-	*(((CARD32 *)neoc->mmio)+0x400) = (CARD32)8;
-	//neoSetIndex(neoc, 0x3ce, 0x82,8);
-	LEAVE();
-	return TRUE;
+    iopl (3);
+    ENTER();
+    neoc->reg_base = card->attr.address[1] & 0xFFF80000;
+    if (!neoc->reg_base) {
+        return FALSE;
+    }
+
+    neoc->mmio = KdMapDevice(neoc->reg_base, NEO_REG_SIZE(card));
+    if (!neoc->mmio) {
+        return FALSE;
+    }
+
+    KdSetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
+
+    // if you see the cursor sprite them MMIO is working
+
+    *(((CARD32 *)neoc->mmio)+0x400) = (CARD32)8;
+    //neoSetIndex(neoc, 0x3ce, 0x82,8);
+    LEAVE();
+    return TRUE;
 }
 
 void
 neoUnmapReg (KdCardInfo *card, NeoCardInfo *neoc)
 {
-	ENTER();
-	if (neoc->reg_base)
-	{
-		neoSetIndex(neoc, 0x3ce, 0x82,0);
-		KdResetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
-		KdUnmapDevice ((void *)neoc->mmio, NEO_REG_SIZE(card));
-		neoc->reg_base = 0;
-	}
-	LEAVE();
+    ENTER();
+    if (neoc->reg_base)
+    {
+        neoSetIndex(neoc, 0x3ce, 0x82,0);
+        KdResetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
+        KdUnmapDevice ((void *)neoc->mmio, NEO_REG_SIZE(card));
+        neoc->reg_base = 0;
+    }
+    LEAVE();
 }
 
-void
+static void
 neoSetMMIO (KdCardInfo *card, NeoCardInfo *neoc)
 {
-	if (!neoc->reg_base)
-		neoMapReg (card, neoc);
-		neoUnlock (neoc);
+    if (!neoc->reg_base)
+        neoMapReg (card, neoc);
+        neoUnlock (neoc);
 }
 
-void
+static void
 neoResetMMIO (KdCardInfo *card, NeoCardInfo *neoc)
 {
     neoUnmapReg (card, neoc);
@@ -230,10 +234,10 @@
 neoEnable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
-    NeoCardInfo	*neoc = pScreenPriv->card->driver;
+    NeoCardInfo *neoc = pScreenPriv->card->driver;
 
     if (!vesaEnable (pScreen))
-		return FALSE;
+        return FALSE;
     neoSetMMIO (pScreenPriv->card, neoc);
     return TRUE;
 }
@@ -243,7 +247,7 @@
 {
     KdScreenPriv(pScreen);
 
-    NeoCardInfo	*neoc = pScreenPriv->card->driver;
+    NeoCardInfo *neoc = pScreenPriv->card->driver;
     neoResetMMIO (pScreenPriv->card, neoc);
 
     vesaDisable (pScreen);
@@ -258,7 +262,7 @@
 static void
 neoRestore (KdCardInfo *card)
 {
-    NeoCardInfo	*neoc = card->driver;
+    NeoCardInfo *neoc = card->driver;
 
     neoResetMMIO (card, neoc);
     vesaRestore (card);
@@ -267,7 +271,7 @@
 static void
 neoScreenFini (KdScreenInfo *screen)
 {
-    NeoScreenInfo	*neos = (NeoScreenInfo *) screen->driver;
+    NeoScreenInfo *neos = (NeoScreenInfo *) screen->driver;
 
     vesaScreenFini (screen);
     xfree (neos);
@@ -277,46 +281,44 @@
 static void
 neoCardFini (KdCardInfo *card)
 {
-	NeoCardInfo	*neos = card->driver;
+    NeoCardInfo *neos = card->driver;
 
     neoUnmapReg (card, neos);
     vesaCardFini (card);
 }
 
+#define neoCursorInit 0       // initCursor
+#define neoCursorEnable 0     // enableCursor
+#define neoCursorDisable 0    // disableCursor
+#define neoCursorFini 0       // finiCursor */
+#define neoRecolorCursor 0    // recolorCursor */
 
-#define     neoCursorInit 0	    /* initCursor */
-#define     neoCursorEnable 0	    /* enableCursor */
-#define     neoCursorDisable 0  /* disableCursor */
-#define     neoCursorFini 0	    /* finiCursor */
-#define     neoRecolorCursor 0    /* recolorCursor */
+KdCardFuncs    neoFuncs = {
+    neoCardInit,              // cardinit
+    neoScreenInit,            // scrinit
+    neoInitScreen,            // initScreen
+    neoFinishInitScreen,      // finishInitScreen
+    vesaCreateResources,      // createRes
+    neoPreserve,              // preserve
+    neoEnable,                // enable
+    neoDPMS,                  // dpms
+    neoDisable,               // disable
+    neoRestore,               // restore
+    neoScreenFini,            // scrfini
+    neoCardFini,              // cardfini
 
+    neoCursorInit,            // initCursor
+    neoCursorEnable,          // enableCursor
+    neoCursorDisable,         // disableCursor
+    neoCursorFini,            // finiCursor
+    neoRecolorCursor,         // recolorCursor
 
-KdCardFuncs	neoFuncs = {
-    neoCardInit,	    /* cardinit */
-    neoScreenInit,	    /* scrinit */
-    neoInitScreen,	    /* initScreen */
-    neoFinishInitScreen, /* finishInitScreen */
-    vesaCreateResources,    /* createRes */
-    neoPreserve,	    /* preserve */
-    neoEnable,	    /* enable */
-    neoDPMS,		    /* dpms */
-    neoDisable,	    /* disable */
-    neoRestore,	    /* restore */
-    neoScreenFini,	    /* scrfini */
-    neoCardFini,	    /* cardfini */
-    
-    neoCursorInit,	    /* initCursor */
-    neoCursorEnable,	    /* enableCursor */
-    neoCursorDisable,    /* disableCursor */
-    neoCursorFini,	    /* finiCursor */
-    neoRecolorCursor,    /* recolorCursor */
-    
-    neoDrawInit,	    /* initAccel */
-    neoDrawEnable,	    /* enableAccel */
-    neoDrawSync,	    /* syncAccel */
-    neoDrawDisable,	    /* disableAccel */
-    neoDrawFini,	    /* finiAccel */
-    
-    vesaGetColors,    	    /* getColors */
-    vesaPutColors,	    /* putColors */
+    neoDrawInit,              // initAccel
+    neoDrawEnable,            // enableAccel
+    neoDrawSync,              // syncAccel
+    neoDrawDisable,           // disableAccel
+    neoDrawFini,              // finiAccel
+
+    vesaGetColors,            // getColors
+    vesaPutColors,            // putColors
 };

Index: neomagic.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neomagic.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/neomagic.h	3 Apr 2004 22:26:37 -0000	1.2
+++ b/neomagic.h	4 Apr 2004 07:30:07 -0000	1.3
@@ -23,7 +23,7 @@
 
 #ifndef _NEOMAGIC_H_
 #define _NEOMAGIC_H_
-#include <vesa.h>
+#include <backend.h>
 #include "kxv.h"
 #include "klinux.h"
 
@@ -35,7 +35,7 @@
 #define DBGOUT(fmt,a...)
 #endif
 
-#define ENTER()	DBGOUT("Enter %s\n", __FUNCTION__)
+#define ENTER()    DBGOUT("Enter %s\n", __FUNCTION__)
 #define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
 
 #define NEO_VENDOR 0x10c8
@@ -79,51 +79,52 @@
 #define NEO_BC3_BLT_ON_ADDR     0x10000000
 #define NEO_BC3_SKIP_MAPPING    0x80000000
 
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
+typedef volatile CARD8    VOL8;
+typedef volatile CARD16    VOL16;
+typedef volatile CARD32    VOL32;
 
-#define NEO_REG_SIZE(c)	    (0x200000L)
+#define NEO_REG_SIZE(c)        (0x200000L)
 
 typedef volatile struct {
-  CARD32 bltStat;
-  CARD32 bltCntl;
-  CARD32 xpColor;
-  CARD32 fgColor;
-  CARD32 bgColor;
-  CARD32 pitch;
-  CARD32 clipLT;
-  CARD32 clipRB;
-  CARD32 srcBitOffset;
-  CARD32 srcStart;
-  CARD32 reserved0;
-  CARD32 dstStart;
-  CARD32 xyExt;
+    CARD32 bltStat;
+    CARD32 bltCntl;
+    CARD32 xpColor;
+    CARD32 fgColor;
+    CARD32 bgColor;
+    CARD32 pitch;
+    CARD32 clipLT;
+    CARD32 clipRB;
+    CARD32 srcBitOffset;
+    CARD32 srcStart;
+    CARD32 reserved0;
+    CARD32 dstStart;
+    CARD32 xyExt;
 
-  CARD32 reserved1[19];
+    CARD32 reserved1[19];
 
-  CARD32 pageCntl;
-  CARD32 pageBase;
-  CARD32 postBase;
-  CARD32 postPtr;
-  CARD32 dataPtr;
+    CARD32 pageCntl;
+    CARD32 pageBase;
+    CARD32 postBase;
+    CARD32 postPtr;
+    CARD32 dataPtr;
 } NeoMMIO;
 
 typedef struct _neoCardInfo {
-	VesaCardPrivRec	vesa;
-	CARD32		reg_base;
-	NeoMMIO		*mmio;
-	int dstOrg;
-	int dstPitch;
-	int dstPixelWidth;
+    BackendInfo backendCard;
 
-	int srcOrg;
-	int srcPitch;
-	int srcPixelWidth;
+    CARD32 reg_base;
+    NeoMMIO *mmio;
+    int dstOrg;
+    int dstPitch;
+    int dstPixelWidth;
+
+    int srcOrg;
+    int srcPitch;
+    int srcPixelWidth;
 
     struct NeoChipInfo *chip;
-	
-	CARD32 bltCntl;
+
+    CARD32 bltCntl;
 
 } NeoCardInfo;
 
@@ -140,26 +141,27 @@
     int maxWidth;
     int maxHeight;
 };
-    
-#define getNeoCardInfo(kd)	((NeoCardInfo *) ((kd)->card->driver))
-#define neoCardInfo(kd)	NeoCardInfo	*neoc = getNeoCardInfo(kd)
+
+#define getNeoCardInfo(kd) ((NeoCardInfo *) ((kd)->card->driver))
+#define neoCardInfo(kd) NeoCardInfo    *neoc = getNeoCardInfo(kd)
 
 typedef struct _neoScreenInfo {
-    VesaScreenPrivRec		vesa;
-    CARD8			*screen;
-    CARD8			*off_screen;
-    int		off_screen_size;
-	int		pitch;
-	int 		depth;
-    KdVideoAdaptorPtr		pAdaptor;
+    BackendScreen backendScreen;
+
+    CARD8 *screen;
+    CARD8 *off_screen;
+    int off_screen_size;
+    int pitch;
+    int depth;
+    KdVideoAdaptorPtr pAdaptor;
 } NeoScreenInfo;
 
 #define getNeoScreenInfo(kd) ((NeoScreenInfo *) ((kd)->screen->driver))
-#define neoScreenInfo(kd)    NeoScreenInfo *neos = getNeoScreenInfo(kd)
+#define neoScreenInfo(kd) NeoScreenInfo *neos = getNeoScreenInfo(kd)
 
 #define SetupNeo(s) KdScreenPriv(s); \
-		    neoCardInfo(pScreenPriv); \
-			neoScreenInfo(pScreenPriv);
+                    neoCardInfo(pScreenPriv); \
+                    neoScreenInfo(pScreenPriv);
 
 void
 neoPreserve (KdCardInfo *card);

Index: neomagicstub.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/neomagic/neomagicstub.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/neomagicstub.c	3 Apr 2004 22:26:37 -0000	1.2
+++ b/neomagicstub.c	4 Apr 2004 07:30:07 -0000	1.3
@@ -31,7 +31,7 @@
 void
 InitCard (char *name)
 {
-    KdCardAttr	attr;
+    KdCardAttr attr;
     struct NeoChipInfo *chip;
 
     for (chip = neoChips; chip->name != NULL; ++chip) {
@@ -67,9 +67,9 @@
 int
 ddxProcessArgument (int argc, char **argv, int i)
 {
-    int	ret;
-    
+    int ret;
+
     if (!(ret = vesaProcessArgument (argc, argv, i)))
-	ret = KdProcessArgument(argc, argv, i);
+    ret = KdProcessArgument(argc, argv, i);
     return ret;
 }




More information about the xserver-commit mailing list