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 = \
@KDRIVE_INCS@ \
-I$(top_srcdir)/hw/kdrive/vesa \
$(FBDEV_INCLUDES) \
$(VESA_INCLUDES) \
@XSERVER_CFLAGS@
bin_PROGRAMS = Xneomagic
@ -8,6 +19,8 @@ bin_PROGRAMS = Xneomagic
noinst_LIBRARIES = libneomagic.a
libneomagic_a_SOURCES = \
backend.h \
backend.c \
neomagic.c \
neomagic.h \
neo_draw.c
@ -17,7 +30,8 @@ Xneomagic_SOURCES = \
NEOMAGIC_LIBS = \
libneomagic.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
${FBDEV_LIBS} \
${VESA_LIBS} \
@KDRIVE_LIBS@
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 "picturestr.h"
static inline void neoWaitIdle( NeoCardInfo *neoc)
static inline void neoWaitIdle(NeoCardInfo *neoc)
{
// if MMIO is not working it may halt the machine
int i = 0;
@ -47,8 +47,7 @@ static inline void neoWaitIdle( NeoCardInfo *neoc)
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 );
}
@ -65,12 +64,9 @@ static Bool neoPrepareSolid(PixmapPtr pPixmap,
{
FbBits depthMask = FbFullMask(pPixmap->drawable.depth);
if ((pm & depthMask) != depthMask)
{
if ((pm & depthMask) != depthMask) {
return FALSE;
}
else
{
} else {
fgColor = fg;
neoWaitIdle(card);
/* set blt control */
@ -85,8 +81,7 @@ static Bool neoPrepareSolid(PixmapPtr pPixmap,
}
}
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;
@ -94,13 +89,11 @@ neoSolid (int x1, int y1, int x2, int y2)
y = y1;
w = x2-x1 + 1;
h = y2-y1 + 1;
if (x1>x2)
{
if (x1>x2) {
x = x2;
w = -w;
}
if (y1>y2)
{
if (y1>y2) {
y = y2;
h = -h;
}
@ -109,39 +102,26 @@ neoSolid (int x1, int y1, int x2, int y2)
mmio->dstStart = (y <<16) | (x & 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);
}
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;
}
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)
{
}
@ -155,15 +135,15 @@ KaaScreenInfoRec neoKaa = {
neoDoneCopy
};
Bool
neoDrawInit (ScreenPtr pScreen)
Bool neoDrawInit (ScreenPtr pScreen)
{
ENTER();
// SetupNeo(pScreen);
// PictureScreenPtr ps = GetPictureScreen(pScreen);
if (!kaaDrawInit (pScreen, &neoKaa))
if (!kaaDrawInit (pScreen, &neoKaa)) {
return FALSE;
}
// if (ps && tridents->off_screen)
// ps->Composite = tridentComposite;
@ -171,37 +151,33 @@ neoDrawInit (ScreenPtr pScreen)
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);

View File

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

View File

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