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,28 +1,42 @@
INCLUDES = \ if KDRIVEFBDEV
@KDRIVE_INCS@ \ FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
-I$(top_srcdir)/hw/kdrive/vesa \ 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@ @XSERVER_CFLAGS@
bin_PROGRAMS = Xneomagic bin_PROGRAMS = Xneomagic
noinst_LIBRARIES = libneomagic.a noinst_LIBRARIES = libneomagic.a
libneomagic_a_SOURCES = \ libneomagic_a_SOURCES = \
neomagic.c \ backend.h \
neomagic.h \ backend.c \
neomagic.c \
neomagic.h \
neo_draw.c neo_draw.c
Xneomagic_SOURCES = \ Xneomagic_SOURCES = \
neomagicstub.c neomagicstub.c
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 = \
$(NEOMAGIC_LIBS) \ $(NEOMAGIC_LIBS) \
@KDRIVE_LIBS@ \ @KDRIVE_LIBS@ \
@XSERVER_LIBS@ @XSERVER_LIBS@
Xneomagic_DEPENDENCIES = $(NEOMAGIC_LIBS) @KDRIVE_LIBS@ Xneomagic_DEPENDENCIES = $(NEOMAGIC_LIBS) @KDRIVE_LIBS@

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

@ -26,126 +26,106 @@
#endif #endif
#include "neomagic.h" #include "neomagic.h"
#include <X11/Xmd.h> #include <X11/Xmd.h>
#include "gcstruct.h" #include "gcstruct.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "regionstr.h" #include "regionstr.h"
#include "mistruct.h" #include "mistruct.h"
#include "fontstruct.h" #include "fontstruct.h"
#include "dixfontstr.h" #include "dixfontstr.h"
#include "fb.h" #include "fb.h"
#include "migc.h" #include "migc.h"
#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;
while ((neoc->mmio->bltStat & 1) && ++i<10000); while ((neoc->mmio->bltStat & 1) && ++i<10000);
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 );
} }
NeoMMIO *mmio; NeoMMIO *mmio;
NeoScreenInfo *screen; NeoScreenInfo *screen;
NeoCardInfo *card; NeoCardInfo *card;
CARD32 fgColor; CARD32 fgColor;
static Bool neoPrepareSolid(PixmapPtr pPixmap, static Bool neoPrepareSolid(PixmapPtr pPixmap,
int alu, int alu,
Pixel pm, Pixel pm,
Pixel fg) Pixel fg)
{ {
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 {
} fgColor = fg;
else neoWaitIdle(card);
{ /* set blt control */
fgColor = fg; mmio->bltCntl =
neoWaitIdle(card); NEO_BC0_SRC_IS_FG |
/* set blt control */ NEO_BC3_SRC_XY_ADDR |
mmio->bltCntl = NEO_BC3_DST_XY_ADDR |
NEO_BC0_SRC_IS_FG | NEO_BC3_SKIP_MAPPING | 0x0c0000;
NEO_BC3_SRC_XY_ADDR |
NEO_BC3_DST_XY_ADDR | mmio->fgColor = fgColor;
NEO_BC3_SKIP_MAPPING | 0x0c0000; return TRUE;
}
mmio->fgColor = fgColor;
return TRUE;
}
} }
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;
x = x1; x = x1;
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;
{ h = -h;
y = y2; }
h = -h;
}
neoWaitIdle(card);
mmio->dstStart = (y <<16) | (x & 0xffff);
mmio->xyExt = (h << 16) | (w & 0xffff); neoWaitIdle(card);
DBGOUT("Solid (%i, %i) - (%i, %i). Color %x\n", x, y, w, h, fgColor); mmio->dstStart = (y <<16) | (x & 0xffff);
DBGOUT("Offset %lx. Extent %lx\n",mmio->dstStart, mmio->xyExt);
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 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)
{ {
} }
KaaScreenInfoRec neoKaa = { KaaScreenInfoRec neoKaa = {
neoPrepareSolid, neoPrepareSolid,
neoSolid, neoSolid,
neoDoneSolid, neoDoneSolid,
@ -155,57 +135,53 @@ 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;
LEAVE(); LEAVE();
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);
neoWaitIdle(neoc); neoWaitIdle(neoc);
LEAVE(); LEAVE();
} }

View File

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

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"
@ -35,7 +35,7 @@
#define DBGOUT(fmt,a...) #define DBGOUT(fmt,a...)
#endif #endif
#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__) #define ENTER() DBGOUT("Enter %s\n", __FUNCTION__)
#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__) #define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
#define NEO_VENDOR 0x10c8 #define NEO_VENDOR 0x10c8
@ -79,51 +79,52 @@
#define NEO_BC3_BLT_ON_ADDR 0x10000000 #define NEO_BC3_BLT_ON_ADDR 0x10000000
#define NEO_BC3_SKIP_MAPPING 0x80000000 #define NEO_BC3_SKIP_MAPPING 0x80000000
typedef volatile CARD8 VOL8; typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16; typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32; typedef volatile CARD32 VOL32;
#define NEO_REG_SIZE(c) (0x200000L) #define NEO_REG_SIZE(c) (0x200000L)
typedef volatile struct { typedef volatile struct {
CARD32 bltStat; CARD32 bltStat;
CARD32 bltCntl; CARD32 bltCntl;
CARD32 xpColor; CARD32 xpColor;
CARD32 fgColor; CARD32 fgColor;
CARD32 bgColor; CARD32 bgColor;
CARD32 pitch; CARD32 pitch;
CARD32 clipLT; CARD32 clipLT;
CARD32 clipRB; CARD32 clipRB;
CARD32 srcBitOffset; CARD32 srcBitOffset;
CARD32 srcStart; CARD32 srcStart;
CARD32 reserved0; CARD32 reserved0;
CARD32 dstStart; CARD32 dstStart;
CARD32 xyExt; CARD32 xyExt;
CARD32 reserved1[19]; CARD32 reserved1[19];
CARD32 pageCntl; CARD32 pageCntl;
CARD32 pageBase; CARD32 pageBase;
CARD32 postBase; CARD32 postBase;
CARD32 postPtr; CARD32 postPtr;
CARD32 dataPtr; CARD32 dataPtr;
} NeoMMIO; } NeoMMIO;
typedef struct _neoCardInfo { typedef struct _neoCardInfo {
VesaCardPrivRec vesa; BackendInfo backendCard;
CARD32 reg_base;
NeoMMIO *mmio;
int dstOrg;
int dstPitch;
int dstPixelWidth;
int srcOrg; CARD32 reg_base;
int srcPitch; NeoMMIO *mmio;
int srcPixelWidth; int dstOrg;
int dstPitch;
int dstPixelWidth;
int srcOrg;
int srcPitch;
int srcPixelWidth;
struct NeoChipInfo *chip; struct NeoChipInfo *chip;
CARD32 bltCntl; CARD32 bltCntl;
} NeoCardInfo; } NeoCardInfo;
@ -140,26 +141,27 @@ struct NeoChipInfo {
int maxWidth; int maxWidth;
int maxHeight; int maxHeight;
}; };
#define getNeoCardInfo(kd) ((NeoCardInfo *) ((kd)->card->driver)) #define getNeoCardInfo(kd) ((NeoCardInfo *) ((kd)->card->driver))
#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 *off_screen; CARD8 *screen;
int off_screen_size; CARD8 *off_screen;
int pitch; int off_screen_size;
int depth; int pitch;
KdVideoAdaptorPtr pAdaptor; int depth;
KdVideoAdaptorPtr pAdaptor;
} NeoScreenInfo; } NeoScreenInfo;
#define getNeoScreenInfo(kd) ((NeoScreenInfo *) ((kd)->screen->driver)) #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); \ #define SetupNeo(s) KdScreenPriv(s); \
neoCardInfo(pScreenPriv); \ neoCardInfo(pScreenPriv); \
neoScreenInfo(pScreenPriv); neoScreenInfo(pScreenPriv);
void void
neoPreserve (KdCardInfo *card); neoPreserve (KdCardInfo *card);

View File

@ -31,7 +31,7 @@ extern struct NeoChipInfo neoChips[];
void void
InitCard (char *name) InitCard (char *name)
{ {
KdCardAttr attr; KdCardAttr attr;
struct NeoChipInfo *chip; struct NeoChipInfo *chip;
for (chip = neoChips; chip->name != NULL; ++chip) { for (chip = neoChips; chip->name != NULL; ++chip) {
@ -67,9 +67,9 @@ ddxUseMsg (void)
int int
ddxProcessArgument (int argc, char **argv, int i) ddxProcessArgument (int argc, char **argv, int i)
{ {
int ret; int ret;
if (!(ret = vesaProcessArgument (argc, argv, i))) if (!(ret = vesaProcessArgument (argc, argv, i)))
ret = KdProcessArgument(argc, argv, i); ret = KdProcessArgument(argc, argv, i);
return ret; return ret;
} }