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)
This commit is contained in:
Brent Cook 2004-04-04 07:30:07 +00:00
parent 530371ceaf
commit 920e6ff81b
7 changed files with 452 additions and 304 deletions

View File

@ -1,6 +1,17 @@
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 = \ INCLUDES = \
@KDRIVE_INCS@ \ @KDRIVE_INCS@ \
-I$(top_srcdir)/hw/kdrive/vesa \ $(FBDEV_INCLUDES) \
$(VESA_INCLUDES) \
@XSERVER_CFLAGS@ @XSERVER_CFLAGS@
bin_PROGRAMS = Xneomagic bin_PROGRAMS = Xneomagic
@ -8,6 +19,8 @@ bin_PROGRAMS = Xneomagic
noinst_LIBRARIES = libneomagic.a noinst_LIBRARIES = libneomagic.a
libneomagic_a_SOURCES = \ libneomagic_a_SOURCES = \
backend.h \
backend.c \
neomagic.c \ neomagic.c \
neomagic.h \ neomagic.h \
neo_draw.c neo_draw.c
@ -17,7 +30,8 @@ Xneomagic_SOURCES = \
NEOMAGIC_LIBS = \ NEOMAGIC_LIBS = \
libneomagic.a \ libneomagic.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \ ${FBDEV_LIBS} \
${VESA_LIBS} \
@KDRIVE_LIBS@ @KDRIVE_LIBS@
Xneomagic_LDADD = \ Xneomagic_LDADD = \

View File

@ -0,0 +1,84 @@
/*
* 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@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;
}

View File

@ -0,0 +1,70 @@
/*
* 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@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

View File

@ -39,7 +39,7 @@
#include "miline.h" #include "miline.h"
#include "picturestr.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; int i = 0;
@ -47,8 +47,7 @@ static inline void neoWaitIdle( NeoCardInfo *neoc)
if (i>=10000) DBGOUT("Wait Idle timeout"); if (i>=10000) DBGOUT("Wait Idle timeout");
} }
static inline void neoWaitFifo(NeoCardInfo *neoc, static inline void neoWaitFifo(NeoCardInfo *neoc, int requested_fifo_space)
int requested_fifo_space )
{ {
neoWaitIdle( neoc ); neoWaitIdle( neoc );
} }
@ -65,12 +64,9 @@ static Bool neoPrepareSolid(PixmapPtr pPixmap,
{ {
FbBits depthMask = FbFullMask(pPixmap->drawable.depth); FbBits depthMask = FbFullMask(pPixmap->drawable.depth);
if ((pm & depthMask) != depthMask) if ((pm & depthMask) != depthMask) {
{
return FALSE; return FALSE;
} } else {
else
{
fgColor = fg; fgColor = fg;
neoWaitIdle(card); neoWaitIdle(card);
/* set blt control */ /* set blt control */
@ -85,8 +81,7 @@ static Bool neoPrepareSolid(PixmapPtr pPixmap,
} }
} }
void static void neoSolid (int x1, int y1, int x2, int y2)
neoSolid (int x1, int y1, int x2, int y2)
{ {
DBGOUT("Solid (%i, %i) - (%i, %i). \n", x1, y1, x2, y2); DBGOUT("Solid (%i, %i) - (%i, %i). \n", x1, y1, x2, y2);
int x, y, w, h; int x, y, w, h;
@ -94,13 +89,11 @@ neoSolid (int x1, int y1, int x2, int y2)
y = y1; y = y1;
w = x2-x1 + 1; w = x2-x1 + 1;
h = y2-y1 + 1; h = y2-y1 + 1;
if (x1>x2) if (x1>x2) {
{
x = x2; x = x2;
w = -w; w = -w;
} }
if (y1>y2) if (y1>y2) {
{
y = y2; y = y2;
h = -h; h = -h;
} }
@ -109,39 +102,26 @@ neoSolid (int x1, int y1, int x2, int y2)
mmio->dstStart = (y <<16) | (x & 0xffff); mmio->dstStart = (y <<16) | (x & 0xffff);
mmio->xyExt = (h << 16) | (w & 0xffff); mmio->xyExt = (h << 16) | (w & 0xffff);
DBGOUT("Solid (%i, %i) - (%i, %i). Color %x\n", x, y, w, h, fgColor); DBGOUT("Solid (%i, %i) - (%i, %i). Color %li\n", x, y, w, h, fgColor);
DBGOUT("Offset %lx. Extent %lx\n",mmio->dstStart, mmio->xyExt); DBGOUT("Offset %lx. Extent %lx\n",mmio->dstStart, mmio->xyExt);
} }
void static void neoDoneSolid(void)
neoDoneSolid(void)
{ {
} }
Bool static Bool neoPrepareCopy (PixmapPtr pSrcPixpam, PixmapPtr pDstPixmap,
neoPrepareCopy (PixmapPtr pSrcPixpam, int dx, int dy, int alu, Pixel pm)
PixmapPtr pDstPixmap,
int dx,
int dy,
int alu,
Pixel pm)
{ {
return TRUE; return TRUE;
} }
void static void neoCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
neoCopy (int srcX,
int srcY,
int dstX,
int dstY,
int w,
int h)
{ {
} }
void static void neoDoneCopy (void)
neoDoneCopy (void)
{ {
} }
@ -155,15 +135,15 @@ KaaScreenInfoRec neoKaa = {
neoDoneCopy neoDoneCopy
}; };
Bool Bool neoDrawInit (ScreenPtr pScreen)
neoDrawInit (ScreenPtr pScreen)
{ {
ENTER(); ENTER();
// SetupNeo(pScreen); // SetupNeo(pScreen);
// PictureScreenPtr ps = GetPictureScreen(pScreen); // PictureScreenPtr ps = GetPictureScreen(pScreen);
if (!kaaDrawInit (pScreen, &neoKaa)) if (!kaaDrawInit (pScreen, &neoKaa)) {
return FALSE; return FALSE;
}
// if (ps && tridents->off_screen) // if (ps && tridents->off_screen)
// ps->Composite = tridentComposite; // ps->Composite = tridentComposite;
@ -171,37 +151,33 @@ neoDrawInit (ScreenPtr pScreen)
return TRUE; return TRUE;
} }
void void neoDrawEnable (ScreenPtr pScreen)
neoDrawEnable (ScreenPtr pScreen)
{ {
ENTER(); ENTER();
SetupNeo(pScreen); SetupNeo(pScreen);
screen = neos; screen = neos;
card = neoc; card = neoc;
mmio = neoc->mmio; mmio = neoc->mmio;
DBGOUT("NEO AA MMIO=%lx\n", mmio); DBGOUT("NEO AA MMIO=%p\n", mmio);
screen->depth = screen->vesa.mode.BitsPerPixel/8; // screen->depth = screen->vesa.mode.BitsPerPixel/8;
screen->pitch = screen->vesa.mode.BytesPerScanLine; // screen->pitch = screen->vesa.mode.BytesPerScanLine;
DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch); // DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch);
LEAVE(); LEAVE();
} }
void void neoDrawDisable (ScreenPtr pScreen)
neoDrawDisable (ScreenPtr pScreen)
{ {
ENTER(); ENTER();
LEAVE(); LEAVE();
} }
void void neoDrawFini (ScreenPtr pScreen)
neoDrawFini (ScreenPtr pScreen)
{ {
ENTER(); ENTER();
LEAVE(); LEAVE();
} }
void void neoDrawSync (ScreenPtr pScreen)
neoDrawSync (ScreenPtr pScreen)
{ {
ENTER(); ENTER();
SetupNeo(pScreen); SetupNeo(pScreen);

View File

@ -56,11 +56,11 @@ neoCardInit (KdCardInfo *card)
struct NeoChipInfo *chip; struct NeoChipInfo *chip;
neoc = (NeoCardInfo *) xalloc (sizeof (NeoCardInfo)); neoc = (NeoCardInfo *) xalloc (sizeof (NeoCardInfo));
if (!neoc) if (!neoc) {
return FALSE; return FALSE;
}
if (!vesaInitialize (card, &neoc->vesa)) if (!backendInitialize(card, &neoc->backendCard)) {
{
xfree (neoc); xfree (neoc);
return FALSE; return FALSE;
} }
@ -74,7 +74,6 @@ neoCardInit (KdCardInfo *card)
ErrorF("Using Neomagic card: %s\n", neoc->chip->name); ErrorF("Using Neomagic card: %s\n", neoc->chip->name);
iopl (3);
neoMapReg (card, neoc); neoMapReg (card, neoc);
card->driver = neoc; card->driver = neoc;
@ -90,34 +89,40 @@ neoScreenInit (KdScreenInfo *screen)
int screen_size, memory; int screen_size, memory;
neos = (NeoScreenInfo *) xalloc (sizeof (NeoScreenInfo)); neos = (NeoScreenInfo *) xalloc (sizeof (NeoScreenInfo));
if (!neos) if (!neos) {
return FALSE; return FALSE;
}
memset (neos, '\0', sizeof (NeoScreenInfo)); memset (neos, '\0', sizeof (NeoScreenInfo));
if (!vesaScreenInitialize (screen, &neos->vesa))
{ if (!backendScreenInitialize (screen, &neos->backendScreen, &neoc->backendCard)) {
xfree (neos); xfree (neos);
return FALSE; 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 screen->softCursor = TRUE; // no hardware color cursor available
neos->screen = neos->vesa.fb;
memory = neos->vesa.fb_size; 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; screen_size = screen->fb[0].byteStride * screen->height;
memory -= screen_size; memory -= screen_size;
if (memory > screen->fb[0].byteStride)
{ if (memory > screen->fb[0].byteStride) {
neos->off_screen = neos->screen + screen_size; neos->off_screen = neos->screen + screen_size;
neos->off_screen_size = memory; neos->off_screen_size = memory;
} } else {
else
{
neos->off_screen = 0; neos->off_screen = 0;
neos->off_screen_size = 0; neos->off_screen_size = 0;
} }
screen->driver = neos; screen->driver = neos;
return TRUE; return TRUE;
} }
@ -173,16 +178,15 @@ static void neoUnlock(NeoCardInfo *neoc){
Bool Bool
neoMapReg (KdCardInfo *card, NeoCardInfo *neoc) neoMapReg (KdCardInfo *card, NeoCardInfo *neoc)
{ {
iopl (3);
ENTER(); ENTER();
neoc->reg_base = card->attr.address[1] & 0xFFF80000; neoc->reg_base = card->attr.address[1] & 0xFFF80000;
if (!neoc->reg_base) if (!neoc->reg_base) {
{
return FALSE; return FALSE;
} }
neoc->mmio = KdMapDevice(neoc->reg_base, NEO_REG_SIZE(card)); neoc->mmio = KdMapDevice(neoc->reg_base, NEO_REG_SIZE(card));
if (!neoc->mmio) if (!neoc->mmio) {
{
return FALSE; return FALSE;
} }
@ -210,7 +214,7 @@ neoUnmapReg (KdCardInfo *card, NeoCardInfo *neoc)
LEAVE(); LEAVE();
} }
void static void
neoSetMMIO (KdCardInfo *card, NeoCardInfo *neoc) neoSetMMIO (KdCardInfo *card, NeoCardInfo *neoc)
{ {
if (!neoc->reg_base) if (!neoc->reg_base)
@ -218,7 +222,7 @@ neoSetMMIO (KdCardInfo *card, NeoCardInfo *neoc)
neoUnlock (neoc); neoUnlock (neoc);
} }
void static void
neoResetMMIO (KdCardInfo *card, NeoCardInfo *neoc) neoResetMMIO (KdCardInfo *card, NeoCardInfo *neoc)
{ {
neoUnmapReg (card, neoc); neoUnmapReg (card, neoc);
@ -283,40 +287,38 @@ neoCardFini (KdCardInfo *card)
vesaCardFini (card); vesaCardFini (card);
} }
#define neoCursorInit 0 // initCursor
#define neoCursorInit 0 /* initCursor */ #define neoCursorEnable 0 // enableCursor
#define neoCursorEnable 0 /* enableCursor */ #define neoCursorDisable 0 // disableCursor
#define neoCursorDisable 0 /* disableCursor */ #define neoCursorFini 0 // finiCursor */
#define neoCursorFini 0 /* finiCursor */ #define neoRecolorCursor 0 // recolorCursor */
#define neoRecolorCursor 0 /* recolorCursor */
KdCardFuncs neoFuncs = { KdCardFuncs neoFuncs = {
neoCardInit, /* cardinit */ neoCardInit, // cardinit
neoScreenInit, /* scrinit */ neoScreenInit, // scrinit
neoInitScreen, /* initScreen */ neoInitScreen, // initScreen
neoFinishInitScreen, /* finishInitScreen */ neoFinishInitScreen, // finishInitScreen
vesaCreateResources, /* createRes */ vesaCreateResources, // createRes
neoPreserve, /* preserve */ neoPreserve, // preserve
neoEnable, /* enable */ neoEnable, // enable
neoDPMS, /* dpms */ neoDPMS, // dpms
neoDisable, /* disable */ neoDisable, // disable
neoRestore, /* restore */ neoRestore, // restore
neoScreenFini, /* scrfini */ neoScreenFini, // scrfini
neoCardFini, /* cardfini */ neoCardFini, // cardfini
neoCursorInit, /* initCursor */ neoCursorInit, // initCursor
neoCursorEnable, /* enableCursor */ neoCursorEnable, // enableCursor
neoCursorDisable, /* disableCursor */ neoCursorDisable, // disableCursor
neoCursorFini, /* finiCursor */ neoCursorFini, // finiCursor
neoRecolorCursor, /* recolorCursor */ neoRecolorCursor, // recolorCursor
neoDrawInit, /* initAccel */ neoDrawInit, // initAccel
neoDrawEnable, /* enableAccel */ neoDrawEnable, // enableAccel
neoDrawSync, /* syncAccel */ neoDrawSync, // syncAccel
neoDrawDisable, /* disableAccel */ neoDrawDisable, // disableAccel
neoDrawFini, /* finiAccel */ neoDrawFini, // finiAccel
vesaGetColors, /* getColors */ vesaGetColors, // getColors
vesaPutColors, /* putColors */ vesaPutColors, // putColors
}; };

View File

@ -23,7 +23,7 @@
#ifndef _NEOMAGIC_H_ #ifndef _NEOMAGIC_H_
#define _NEOMAGIC_H_ #define _NEOMAGIC_H_
#include <vesa.h> #include <backend.h>
#include "kxv.h" #include "kxv.h"
#include "klinux.h" #include "klinux.h"
@ -110,7 +110,8 @@ typedef volatile struct {
} NeoMMIO; } NeoMMIO;
typedef struct _neoCardInfo { typedef struct _neoCardInfo {
VesaCardPrivRec vesa; BackendInfo backendCard;
CARD32 reg_base; CARD32 reg_base;
NeoMMIO *mmio; NeoMMIO *mmio;
int dstOrg; int dstOrg;
@ -145,7 +146,8 @@ struct NeoChipInfo {
#define neoCardInfo(kd) NeoCardInfo *neoc = getNeoCardInfo(kd) #define neoCardInfo(kd) NeoCardInfo *neoc = getNeoCardInfo(kd)
typedef struct _neoScreenInfo { typedef struct _neoScreenInfo {
VesaScreenPrivRec vesa; BackendScreen backendScreen;
CARD8 *screen; CARD8 *screen;
CARD8 *off_screen; CARD8 *off_screen;
int off_screen_size; int off_screen_size;