diff options
author | Keith Packard <keithp@keithp.com> | 2003-10-05 05:22:35 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2003-10-05 05:22:35 +0000 |
commit | adc5b8068d5532a6f3f23e64d3c668a22d5b1504 (patch) | |
tree | bda7d032fe6e3ff4c9cb1639faafc94e5a3844b0 | |
parent | f3d8476ced1e3ba4b4ca7c9e23e98c2cc7ffcc14 (diff) |
Fix fbdev server to allow accelerated servers on top to use RandR. Switch
smi server to fbdev (vesa bios doesnt work on the Acer I have here)
-rw-r--r-- | hw/kdrive/fbdev/fbdev.c | 184 | ||||
-rw-r--r-- | hw/kdrive/fbdev/fbdev.h | 3 | ||||
-rw-r--r-- | hw/kdrive/fbdev/fbinit.c | 32 | ||||
-rw-r--r-- | hw/kdrive/smi/Makefile.am | 4 | ||||
-rw-r--r-- | hw/kdrive/smi/smi.c | 69 | ||||
-rw-r--r-- | hw/kdrive/smi/smi.h | 26 | ||||
-rw-r--r-- | hw/kdrive/smi/smidraw.c | 41 | ||||
-rw-r--r-- | hw/kdrive/smi/smistub.c | 2 |
8 files changed, 200 insertions, 161 deletions
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c index 0a1c7e2d1..155478a67 100644 --- a/hw/kdrive/fbdev/fbdev.c +++ b/hw/kdrive/fbdev/fbdev.c @@ -192,6 +192,7 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) } screen->rate = 72; scrpriv->randr = screen->randr; + scrpriv->layerKind = LAYER_FB; #ifdef FAKE24_ON_16 if (screen->fb[0].depth == 24 && screen->fb[0].bitsPerPixel == 24 && @@ -339,18 +340,13 @@ fbdevUpdateFake24 (ScreenPtr pScreen, } #endif /* FAKE24_ON_16 */ -LayerPtr -fbdevLayerCreate (ScreenPtr pScreen) +void +fbdevConfigureScreen (ScreenPtr pScreen) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; FbdevPriv *priv = pScreenPriv->card->driver; FbdevScrPriv *scrpriv = screen->driver; - LayerPtr pLayer; - ShadowUpdateProc update; - ShadowWindowProc window; - PixmapPtr pPixmap; - int kind; KdMouseMatrix m; #ifdef FAKE24_ON_16 @@ -385,7 +381,22 @@ fbdevLayerCreate (ScreenPtr pScreen) pScreen->mmHeight = screen->width_mm; } KdSetMouseMatrix (&m); - +} + +LayerPtr +fbdevLayerCreate (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + FbdevPriv *priv = pScreenPriv->card->driver; + FbdevScrPriv *scrpriv = screen->driver; + LayerPtr pLayer; + ShadowUpdateProc update; + ShadowWindowProc window; + PixmapPtr pPixmap; + int kind; + KdMouseMatrix m; + if (scrpriv->shadow) { window = fbdevWindowLinear; @@ -410,7 +421,7 @@ fbdevLayerCreate (ScreenPtr pScreen) } else { - kind = LAYER_FB; + kind = scrpriv->layerKind; pPixmap = LAYER_SCREEN_PIXMAP; update = 0; window = 0; @@ -486,55 +497,76 @@ fbdevRandRSetConfig (ScreenPtr pScreen, KdScreenInfo *screen = pScreenPriv->screen; FbdevPriv *priv = pScreenPriv->card->driver; FbdevScrPriv *scrpriv = screen->driver; - int rotate; - int reflect; Bool wasEnabled = pScreenPriv->enabled; + FbdevScrPriv oldscr; + int oldwidth; + int oldheight; + int oldmmwidth; + int oldmmheight; + LayerPtr pNewLayer; + int newwidth, newheight; + + if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) + { + newwidth = pSize->width; + newheight = pSize->height; + } + else + { + newwidth = pSize->height; + newheight = pSize->width; + } + + if (wasEnabled) + KdDisableScreen (pScreen); + oldscr = *scrpriv; + + oldwidth = screen->width; + oldheight = screen->height; + oldmmwidth = pScreen->mmWidth; + oldmmheight = pScreen->mmHeight; + /* - * The only thing that can change is rotation + * Set new configuration */ - randr = KdAddRotation (randr, screen->randr); + + scrpriv->randr = KdAddRotation (screen->randr, randr); + + fbdevConfigureScreen (pScreen); + + pNewLayer = fbdevLayerCreate (pScreen); + if (!pNewLayer) + goto bail4; + if (WalkTree (pScreen, fbdevLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING) + goto bail5; + + WalkTree (pScreen, fbdevLayerRemove, (pointer) scrpriv->pLayer); + LayerDestroy (pScreen, scrpriv->pLayer); + + scrpriv->pLayer = pNewLayer; + + KdSetSubpixelOrder (pScreen, scrpriv->randr); + if (wasEnabled) + KdEnableScreen (pScreen); - if (scrpriv->randr != randr) - { - LayerPtr pNewLayer; - int kind; - int oldrandr = scrpriv->randr; - int oldshadow = scrpriv->shadow; - int oldwidth = pScreen->width; - int oldheight = pScreen->height; - PixmapPtr pPixmap; - - if (wasEnabled) - KdDisableScreen (pScreen); - - scrpriv->randr = randr; - pNewLayer = fbdevLayerCreate (pScreen); - if (!pNewLayer) - { - scrpriv->shadow = oldshadow; - scrpriv->randr = oldrandr; - } - if (WalkTree (pScreen, fbdevLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING) - { - WalkTree (pScreen, fbdevLayerRemove, (pointer) pNewLayer); - LayerDestroy (pScreen, pNewLayer); - scrpriv->randr = oldrandr; - scrpriv->shadow = oldshadow; - pScreen->width = oldwidth; - pScreen->height = oldheight; - if (wasEnabled) - KdEnableScreen (pScreen); - return FALSE; - } - WalkTree (pScreen, fbdevLayerRemove, (pointer) scrpriv->pLayer); - LayerDestroy (pScreen, scrpriv->pLayer); - scrpriv->pLayer = pNewLayer; - KdSetSubpixelOrder (pScreen, scrpriv->randr); - if (wasEnabled) - KdEnableScreen (pScreen); - } return TRUE; + +bail5: + WalkTree (pScreen, fbdevLayerRemove, (pointer) pNewLayer); + LayerDestroy (pScreen, pNewLayer); +bail4: + pScreen->width = oldwidth; + pScreen->height = oldheight; + pScreen->mmWidth = oldmmwidth; + pScreen->mmHeight = oldmmheight; +bail2: + *scrpriv = oldscr; +bail1: + if (wasEnabled) + KdEnableScreen (pScreen); +bail0: + return FALSE; } Bool @@ -590,10 +622,6 @@ Bool fbdevInitScreen (ScreenPtr pScreen) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - FbdevScrPriv *scrpriv = pScreenPriv->screen->driver; - ShadowUpdateProc update; - ShadowWindowProc window; #ifdef TOUCHSCREEN KdTsPhyScreen = pScreen->myNum; @@ -603,15 +631,30 @@ fbdevInitScreen (ScreenPtr pScreen) if (!LayerStartInit (pScreen)) return FALSE; + return TRUE; +} + +Bool +fbdevFinishInitScreen (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + FbdevPriv *priv = pScreenPriv->card->driver; + FbdevScrPriv *scrpriv = pScreenPriv->screen->driver; + + scrpriv->layerKind = LayerNewKind (pScreen); + if (!LayerFinishInit (pScreen)) return FALSE; + scrpriv->pLayer = fbdevLayerCreate (pScreen); if (!scrpriv->pLayer) return FALSE; + #ifdef RANDR if (!fbdevRandRInit (pScreen)) return FALSE; #endif + return TRUE; } @@ -789,32 +832,3 @@ fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) cmap.transp = 0; ioctl (priv->fd, FBIOPUTCMAP, &cmap); } - - -KdCardFuncs fbdevFuncs = { - fbdevCardInit, /* cardinit */ - fbdevScreenInit, /* scrinit */ - fbdevInitScreen, /* initScreen */ - fbdevPreserve, /* preserve */ - fbdevEnable, /* enable */ - fbdevDPMS, /* dpms */ - fbdevDisable, /* disable */ - fbdevRestore, /* restore */ - fbdevScreenFini, /* scrfini */ - fbdevCardFini, /* cardfini */ - - 0, /* initCursor */ - 0, /* enableCursor */ - 0, /* disableCursor */ - 0, /* finiCursor */ - 0, /* recolorCursor */ - - 0, /* initAccel */ - 0, /* enableAccel */ - 0, /* syncAccel */ - 0, /* disableAccel */ - 0, /* finiAccel */ - - fbdevGetColors, /* getColors */ - fbdevPutColors, /* putColors */ -}; diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h index a88111754..4b14bc2e8 100644 --- a/hw/kdrive/fbdev/fbdev.h +++ b/hw/kdrive/fbdev/fbdev.h @@ -50,6 +50,7 @@ typedef struct _fbdevPriv { typedef struct _fbdevScrPriv { Rotation randr; Bool shadow; + int layerKind; LayerPtr pLayer; } FbdevScrPriv; @@ -97,5 +98,7 @@ fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); void fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); +Bool +fbdevFinishInitScreen (ScreenPtr pScreen); #endif /* _FBDEV_H_ */ diff --git a/hw/kdrive/fbdev/fbinit.c b/hw/kdrive/fbdev/fbinit.c index aeb4d14b0..bc44b23fe 100644 --- a/hw/kdrive/fbdev/fbinit.c +++ b/hw/kdrive/fbdev/fbinit.c @@ -56,3 +56,35 @@ ddxProcessArgument (int argc, char **argv, int i) { return KdProcessArgument (argc, argv, i); } + + + +KdCardFuncs fbdevFuncs = { + fbdevCardInit, /* cardinit */ + fbdevScreenInit, /* scrinit */ + fbdevInitScreen, /* initScreen */ + fbdevPreserve, /* preserve */ + fbdevEnable, /* enable */ + fbdevDPMS, /* dpms */ + fbdevDisable, /* disable */ + fbdevRestore, /* restore */ + fbdevScreenFini, /* scrfini */ + fbdevCardFini, /* cardfini */ + + 0, /* initCursor */ + 0, /* enableCursor */ + 0, /* disableCursor */ + 0, /* finiCursor */ + 0, /* recolorCursor */ + + 0, /* initAccel */ + 0, /* enableAccel */ + 0, /* syncAccel */ + 0, /* disableAccel */ + 0, /* finiAccel */ + + fbdevGetColors, /* getColors */ + fbdevPutColors, /* putColors */ + + fbdevFinishInitScreen, /* finishInitScreen */ +}; diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am index 4e1d2ea33..f97037a8e 100644 --- a/hw/kdrive/smi/Makefile.am +++ b/hw/kdrive/smi/Makefile.am @@ -1,7 +1,7 @@ INCLUDES = \ -I$(top_srcdir)/fb \ -I$(top_srcdir)/hw/kdrive/src \ - -I$(top_srcdir)/hw/kdrive/vesa \ + -I$(top_srcdir)/hw/kdrive/fbdev \ -I$(top_srcdir)/mi \ -I$(top_srcdir)/miext/layer \ -I$(top_srcdir)/miext/shadow \ @@ -24,7 +24,7 @@ Xsmi_SOURCES = \ Xsmi_LDADD = \ $(top_builddir)/hw/kdrive/smi/libsmi.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a \ + $(top_builddir)/hw/kdrive/fbdev/libfbdev.a \ $(top_builddir)/dix/libdix.a \ $(top_builddir)/os/libos.a \ $(top_builddir)/miext/layer/liblayer.a \ diff --git a/hw/kdrive/smi/smi.c b/hw/kdrive/smi/smi.c index 811ae7cc6..83b512890 100644 --- a/hw/kdrive/smi/smi.c +++ b/hw/kdrive/smi/smi.c @@ -27,18 +27,6 @@ #include "smi.h" #include <sys/io.h> -#define DEBUG -#ifdef DEBUG -#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a) -#else -#define DBGOUT(fmt,a...) -#endif - -#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__) -#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__) - - - Bool smiCardInit (KdCardInfo *card) { @@ -48,10 +36,11 @@ smiCardInit (KdCardInfo *card) smic = (SmiCardInfo *) xalloc (sizeof (SmiCardInfo)); if (!smic) return FALSE; + memset (smic, '\0', sizeof (SmiCardInfo)); (void) smiMapReg (card, smic); - if (!vesaInitialize (card, &smic->vesa)) + if (!fbdevInitialize (card, &smic->fbdev)) { xfree (smic); return FALSE; @@ -67,37 +56,21 @@ smiScreenInit (KdScreenInfo *screen) { SmiCardInfo *smic = screen->card->driver; SmiScreenInfo *smis; - int screen_size, memory; ENTER(); smis = (SmiScreenInfo *) xalloc (sizeof (SmiScreenInfo)); if (!smis) return FALSE; memset (smis, '\0', sizeof (SmiScreenInfo)); - if (!vesaScreenInitialize (screen, &smis->vesa)) + if (!fbdevScreenInitialize (screen, &smis->fbdev)) { xfree (smis); return FALSE; } if (!smic->reg_base) screen->dumb = TRUE; - if (smis->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - smis->screen = smis->vesa.fb; - memory = smis->vesa.fb_size; - screen_size = screen->fb[0].byteStride * screen->height; screen->softCursor = TRUE; - memory -= screen_size; - if (memory > screen->fb[0].byteStride) - { - smis->off_screen = smis->screen + screen_size; - smis->off_screen_size = memory; - } - else - { - smis->off_screen = 0; - smis->off_screen_size = 0; - } + smis->screen = smic->fbdev.fb; screen->driver = smis; LEAVE(); return TRUE; @@ -116,8 +89,9 @@ smiInitScreen (ScreenPtr pScreen) smiInitVideo(pScreen); #endif #endif - ret = vesaInitScreen (pScreen); + ret = fbdevInitScreen (pScreen); LEAVE(); + return ret; } #ifdef RANDR @@ -132,7 +106,7 @@ smiRandRSetConfig (ScreenPtr pScreen, ENTER (); KdCheckSync (pScreen); - ret = vesaRandRSetConfig (pScreen, randr, rate, pSize); + ret = fbdevRandRSetConfig (pScreen, randr, rate, pSize); LEAVE(); return ret; } @@ -152,15 +126,12 @@ smiRandRInit (ScreenPtr pScreen) Bool smiFinishInitScreen (ScreenPtr pScreen) { - ENTER (); - if (!vesaFinishInitScreen (pScreen)) - return FALSE; + Bool ret; + ret = fbdevFinishInitScreen (pScreen); #ifdef RANDR - if (!smiRandRInit (pScreen)) - return FALSE; + smiRandRInit (pScreen); #endif - LEAVE (); - return TRUE; + return ret; } void @@ -169,7 +140,7 @@ smiPreserve (KdCardInfo *card) SmiCardInfo *smic = card->driver; ENTER (); - vesaPreserve(card); + fbdevPreserve(card); LEAVE(); } @@ -261,7 +232,7 @@ smiEnable (ScreenPtr pScreen) SmiCardInfo *smic = pScreenPriv->card->driver; ENTER (); - if (!vesaEnable (pScreen)) + if (!fbdevEnable (pScreen)) return FALSE; smiSetMMIO (pScreenPriv->card, smic); @@ -286,7 +257,7 @@ smiDisable (ScreenPtr pScreen) KdXVDisable (pScreen); #endif smiResetMMIO (pScreenPriv->card, smic); - vesaDisable (pScreen); + fbdevDisable (pScreen); LEAVE (); } @@ -295,7 +266,7 @@ smiDPMS (ScreenPtr pScreen, int mode) { Bool ret; ENTER (); - ret = vesaDPMS (pScreen, mode); + ret = fbdevDPMS (pScreen, mode); LEAVE (); return ret; } @@ -306,7 +277,7 @@ smiRestore (KdCardInfo *card) SmiCardInfo *smic = card->driver; ENTER (); - vesaRestore (card); + fbdevRestore (card); LEAVE(); } @@ -316,7 +287,7 @@ smiScreenFini (KdScreenInfo *screen) SmiScreenInfo *smis = (SmiScreenInfo *) screen->driver; ENTER (); - vesaScreenFini (screen); + fbdevScreenFini (screen); xfree (smis); screen->driver = 0; LEAVE (); @@ -329,7 +300,7 @@ smiCardFini (KdCardInfo *card) ENTER (); smiUnmapReg (card, smic); - vesaCardFini (card); + fbdevCardFini (card); LEAVE (); } @@ -363,8 +334,8 @@ KdCardFuncs smiFuncs = { smiDrawDisable, /* disableAccel */ smiDrawFini, /* finiAccel */ - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ + fbdevGetColors, /* getColors */ + fbdevPutColors, /* putColors */ smiFinishInitScreen, /* finishInitScreen */ }; diff --git a/hw/kdrive/smi/smi.h b/hw/kdrive/smi/smi.h index 5092988d7..8a6aa09ff 100644 --- a/hw/kdrive/smi/smi.h +++ b/hw/kdrive/smi/smi.h @@ -25,9 +25,19 @@ #ifndef _SMI_H_ #define _SMI_H_ -#include <vesa.h> +#include <fbdev.h> #include "kxv.h" +#define DEBUG +#ifdef DEBUG +#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a) +#else +#define DBGOUT(fmt,a...) +#endif + +#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__) +#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__) + /* * offset from ioport beginning */ @@ -114,7 +124,7 @@ typedef struct _DPR { #define VGA_SEQ_DATA 0x3C5 typedef struct _smiCardInfo { - VesaCardPrivRec vesa; + FbdevPriv fbdev; CARD16 io_base; CARD8 *reg_base; DPR *dpr; @@ -125,13 +135,11 @@ typedef struct _smiCardInfo { #define smiCardInfo(kd) SmiCardInfo *smic = getSmiCardInfo(kd) typedef struct _smiScreenInfo { - VesaScreenPrivRec vesa; - CARD8 *screen; - CARD8 *off_screen; - int off_screen_size; - CARD32 stride; - CARD32 data_format; - CARD8 dpr_vpr_enable; + FbdevScrPriv fbdev; + CARD8 *screen; + CARD32 stride; + CARD32 data_format; + CARD8 dpr_vpr_enable; } SmiScreenInfo; #define getSmiScreenInfo(kd) ((SmiScreenInfo *) ((kd)->screen->driver)) diff --git a/hw/kdrive/smi/smidraw.c b/hw/kdrive/smi/smidraw.c index 62059f898..a4cf4f52e 100644 --- a/hw/kdrive/smi/smidraw.c +++ b/hw/kdrive/smi/smidraw.c @@ -86,18 +86,6 @@ CARD8 smiSolidRop[16] = { #define ENGINE_IDLE_EMPTY(smic) ((GET_STATUS(smic) & 0x18) == 0x10) #define FIFO_EMPTY(smic) ((GET_STATUS(smic) & 0x10) == 0x10) -static void -smiSleep (int ms) -{ - struct timespec req; - - req.tv_sec = ms / 1000; - req.tv_nsec = (ms % 1000) * 1000000; - while (req.tv_sec || req.tv_nsec) - if (nanosleep (&req, &req) == 0) - break; -} - #define MAX_FIFO 16 void @@ -126,7 +114,7 @@ static DPR *dpr; static CARD32 accel_cmd; static Bool -smiSetup (ScreenPtr pScreen, int wait) +smiSetup (ScreenPtr pScreen, int wait) { KdScreenPriv(pScreen); @@ -259,13 +247,29 @@ Bool smiDrawInit (ScreenPtr pScreen) { KdScreenPriv(pScreen); + smiCardInfo (pScreenPriv); + smiScreenInfo (pScreenPriv); + ENTER (); if (pScreenPriv->screen->fb[0].depth == 4) + { + LEAVE (); return FALSE; + } + if (!smic->dpr) + { + LEAVE (); + return FALSE; + } + if (!kaaDrawInit (pScreen, &smiKaa)) + { + LEAVE (); return FALSE; + } + LEAVE (); return TRUE; } @@ -276,10 +280,13 @@ smiDrawEnable (ScreenPtr pScreen) int i; static const int xyAddress[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 }; + ENTER (); smis = getSmiScreenInfo (pScreenPriv); smic = getSmiCardInfo(pScreenPriv); dpr = smic->dpr; + iopl(3); + smis->stride = pScreenPriv->screen->fb[0].byteStride; smis->dpr_vpr_enable = smiGetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21) & ~0x03; @@ -310,23 +317,27 @@ smiDrawEnable (ScreenPtr pScreen) } } - smiSetup (pScreen, 0); - KdMarkSync (pScreen); + LEAVE (); } void smiDrawDisable (ScreenPtr pScreen) { + ENTER (); smic = 0; smis = 0; dpr = 0; accel_cmd = 0; + iopl (0); + LEAVE (); } void smiDrawFini (ScreenPtr pScreen) { + ENTER (); + LEAVE (); } void diff --git a/hw/kdrive/smi/smistub.c b/hw/kdrive/smi/smistub.c index d6433666e..cfbce20df 100644 --- a/hw/kdrive/smi/smistub.c +++ b/hw/kdrive/smi/smistub.c @@ -55,7 +55,7 @@ ddxProcessArgument (int argc, char **argv, int i) { int ret; - if (!(ret = vesaProcessArgument (argc, argv, i))) +/* if (!(ret = vesaProcessArgument (argc, argv, i))) */ ret = KdProcessArgument(argc, argv, i); return ret; } |