Try to avoid hitting hardware during server reset when not active, add

KdPicture code
This commit is contained in:
Keith Packard 2000-08-26 00:24:38 +00:00
parent 4223801110
commit 83a388c96d
9 changed files with 168 additions and 49 deletions

View File

@ -3,13 +3,13 @@ XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/Imakefile,v 1.1 1999/11/19 13:53:4
#include <Server.tmpl> #include <Server.tmpl>
SRCS = kcmap.c kcolor.c kdrive.c kinfo.c kinput.c kmap.c knoop.c ktest.c \ SRCS = kcmap.c kcolor.c kdrive.c kinfo.c kinput.c kmap.c knoop.c ktest.c \
vga.c kasync.c kmode.c kcurscol.c vga.c kasync.c kmode.c kcurscol.c kpict.c
OBJS = kcmap.o kcolor.o kdrive.o kinfo.o kinput.o kmap.o knoop.o ktest.o \ OBJS = kcmap.o kcolor.o kdrive.o kinfo.o kinput.o kmap.o knoop.o ktest.o \
vga.o kasync.o kmode.o kcurscol.o vga.o kasync.o kmode.o kcurscol.o kpict.o
INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \ INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-I../../fb -I../../mi -I../../include -I../../os \ -I../../fb -I../../mi -I../../render -I../../include -I../../os \
-I$(EXTINCSRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(XINCLUDESRC)
NormalLibraryObjectRule() NormalLibraryObjectRule()

View File

@ -85,8 +85,6 @@ LinuxInit ()
} }
close(fd); close(fd);
/* ErrorF("(using VT number %d)\n\n", vtno); */
sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */ sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0) if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
@ -184,11 +182,49 @@ LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr)
} }
void void
LinuxEnable (void) LinuxSetSwitchMode (int mode)
{ {
struct sigaction act; struct sigaction act;
struct vt_mode VT; struct vt_mode VT;
if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0)
{
FatalError ("LinuxInit: VT_GETMODE failed\n");
}
if (mode == VT_PROCESS)
{
act.sa_handler = LinuxVTRequest;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
act.sa_restorer = 0;
sigaction (SIGUSR1, &act, 0);
VT.mode = mode;
VT.relsig = SIGUSR1;
VT.acqsig = SIGUSR1;
}
else
{
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
act.sa_restorer = 0;
sigaction (SIGUSR1, &act, 0);
VT.mode = mode;
VT.relsig = 0;
VT.acqsig = 0;
}
if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0)
{
FatalError("LinuxInit: VT_SETMODE failed\n");
}
}
void
LinuxEnable (void)
{
if (enabled) if (enabled)
return; return;
if (kdSwitchPending) if (kdSwitchPending)
@ -199,32 +235,16 @@ LinuxEnable (void)
/* /*
* now get the VT * now get the VT
*/ */
LinuxSetSwitchMode (VT_AUTO);
if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0) if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
{ {
ErrorF("LinuxInit: VT_ACTIVATE failed\n"); FatalError("LinuxInit: VT_ACTIVATE failed\n");
} }
if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0) if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
{ {
ErrorF("LinuxInit: VT_WAITACTIVE failed\n"); FatalError("LinuxInit: VT_WAITACTIVE failed\n");
}
if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0)
{
FatalError ("LinuxInit: VT_GETMODE failed\n");
}
act.sa_handler = LinuxVTRequest;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
act.sa_restorer = 0;
sigaction (SIGUSR1, &act, 0);
VT.mode = VT_PROCESS;
VT.relsig = SIGUSR1;
VT.acqsig = SIGUSR1;
if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0)
{
FatalError("LinuxInit: VT_SETMODE VT_PROCESS failed\n");
} }
LinuxSetSwitchMode (VT_PROCESS);
if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{ {
FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n"); FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");

View File

@ -141,7 +141,6 @@ KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
fbPolyFillRect (pDrawable, pGC, nrect, prect); fbPolyFillRect (pDrawable, pGC, nrect, prect);
} }
#if 0
void void
KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC, KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
int narcs, xArc *pArcs) int narcs, xArc *pArcs)
@ -149,7 +148,6 @@ KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
KdCheckSync(pDrawable->pScreen); KdCheckSync(pDrawable->pScreen);
fbPolyFillArc (pDrawable, pGC, narcs, pArcs); fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
} }
#endif
void void
KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,

View File

@ -300,6 +300,9 @@ ddxGiveUp ()
AbortDDX (); AbortDDX ();
} }
Bool kdDumbDriver;
Bool kdSoftCursor;
void void
KdParseScreen (KdScreenInfo *screen, KdParseScreen (KdScreenInfo *screen,
char *arg) char *arg)
@ -307,6 +310,10 @@ KdParseScreen (KdScreenInfo *screen,
char *bpp; char *bpp;
int fb; int fb;
screen->dumb = kdDumbDriver;
screen->softCursor = kdSoftCursor;
kdDumbDriver = FALSE;
kdSoftCursor = FALSE;
screen->width = 0; screen->width = 0;
screen->height = 0; screen->height = 0;
screen->rate = 0; screen->rate = 0;
@ -360,9 +367,6 @@ KdParseScreen (KdScreenInfo *screen,
arg++; arg++;
} }
Bool kdDumbDriver;
Bool kdSoftCursor;
int int
KdProcessArgument (int argc, char **argv, int i) KdProcessArgument (int argc, char **argv, int i)
{ {
@ -389,10 +393,6 @@ KdProcessArgument (int argc, char **argv, int i)
} }
screen = KdScreenInfoAdd (card); screen = KdScreenInfoAdd (card);
KdParseScreen (screen, argv[i+1]); KdParseScreen (screen, argv[i+1]);
screen->dumb = kdDumbDriver;
screen->softCursor = kdSoftCursor;
kdDumbDriver = FALSE;
kdSoftCursor = FALSE;
} }
else else
UseMsg (); UseMsg ();
@ -493,7 +493,10 @@ KdCloseScreen (int index, ScreenPtr pScreen)
* Restore video hardware when last screen is closed * Restore video hardware when last screen is closed
*/ */
if (screen == card->screenList) if (screen == card->screenList)
{
if (kdEnabled)
(*card->cfuncs->restore) (card); (*card->cfuncs->restore) (card);
}
if (!pScreenPriv->screen->dumb) if (!pScreenPriv->screen->dumb)
(*card->cfuncs->finiAccel) (pScreen); (*card->cfuncs->finiAccel) (pScreen);
@ -686,11 +689,17 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
(void) p8Init (pScreen, PSEUDO8_USE_DEFAULT); (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
#endif #endif
#if 0
fbInitValidateTree (pScreen);
#endif
#if 0
pScreen->backingStoreSupport = Always; pScreen->backingStoreSupport = Always;
#ifdef FB_OLD_SCREEN #ifdef FB_OLD_SCREEN
miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs); miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs);
#else #else
miInitializeBackingStore (pScreen); miInitializeBackingStore (pScreen);
#endif
#endif #endif
/* /*
* Wrap CloseScreen, the order now is: * Wrap CloseScreen, the order now is:
@ -710,6 +719,9 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
miDCInitialize(pScreen, &kdPointerScreenFuncs); miDCInitialize(pScreen, &kdPointerScreenFuncs);
} }
if (!KdPictureInit (pScreen, 0, 0))
return FALSE;
if (!fbCreateDefColormap (pScreen)) if (!fbCreateDefColormap (pScreen))
{ {
return FALSE; return FALSE;

View File

@ -297,7 +297,9 @@ void
KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
int nrect, xRectangle *prect); int nrect, xRectangle *prect);
#define KdCheckPolyFillArc miPolyFillArc void
KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
int narcs, xArc *pArcs);
void void
KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,

View File

@ -42,6 +42,7 @@ static Bool kdTimeoutPending;
static int kdBellPitch; static int kdBellPitch;
static int kdBellDuration; static int kdBellDuration;
static int kdLeds; static int kdLeds;
static Bool kdInputEnabled;
int kdMinScanCode; int kdMinScanCode;
int kdMaxScanCode; int kdMaxScanCode;
@ -172,15 +173,22 @@ KdDisableInput (void)
KdRemoveFd (kdMouseFd); KdRemoveFd (kdMouseFd);
if (kdKeyboardFd >= 0) if (kdKeyboardFd >= 0)
KdRemoveFd (kdKeyboardFd); KdRemoveFd (kdKeyboardFd);
kdInputEnabled = FALSE;
} }
void void
KdEnableInput (void) KdEnableInput (void)
{ {
xEvent xE;
kdInputEnabled = TRUE;
if (kdMouseFd >= 0) if (kdMouseFd >= 0)
KdAddFd (kdMouseFd); KdAddFd (kdMouseFd);
if (kdKeyboardFd >= 0) if (kdKeyboardFd >= 0)
KdAddFd (kdKeyboardFd); KdAddFd (kdKeyboardFd);
/* reset screen saver */
xE.u.keyButtonPointer.time = GetTimeInMillis ();
NoticeEventTime (&xE);
} }
static int static int
@ -210,7 +218,7 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
if (kdMouseFuncs) if (kdMouseFuncs)
{ {
kdMouseFd = (*kdMouseFuncs->Init) (); kdMouseFd = (*kdMouseFuncs->Init) ();
if (kdMouseFd >= 0) if (kdMouseFd >= 0 && kdInputEnabled)
KdAddFd (kdMouseFd); KdAddFd (kdMouseFd);
} }
break; break;
@ -222,6 +230,7 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
pKdPointer = 0; pKdPointer = 0;
if (kdMouseFd >= 0) if (kdMouseFd >= 0)
{ {
if (kdInputEnabled)
KdRemoveFd (kdMouseFd); KdRemoveFd (kdMouseFd);
(*kdMouseFuncs->Fini) (kdMouseFd); (*kdMouseFuncs->Fini) (kdMouseFd);
kdMouseFd = -1; kdMouseFd = -1;
@ -241,6 +250,7 @@ LegalModifier(unsigned int key, DevicePtr pDev)
static void static void
KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something) KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
{ {
if (kdInputEnabled)
(*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration); (*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration);
} }
@ -248,6 +258,7 @@ KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
static void static void
KdSetLeds (void) KdSetLeds (void)
{ {
if (kdInputEnabled)
(*kdKeyboardFuncs->Leds) (kdLeds); (*kdKeyboardFuncs->Leds) (kdLeds);
} }
@ -297,7 +308,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
if (kdKeyboardFuncs) if (kdKeyboardFuncs)
{ {
kdKeyboardFd = (*kdKeyboardFuncs->Init) (); kdKeyboardFd = (*kdKeyboardFuncs->Init) ();
if (kdKeyboardFd >= 0) if (kdKeyboardFd >= 0 && kdInputEnabled)
KdAddFd (kdKeyboardFd); KdAddFd (kdKeyboardFd);
} }
break; break;
@ -309,6 +320,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
pDev->on = FALSE; pDev->on = FALSE;
if (kdKeyboardFd >= 0) if (kdKeyboardFd >= 0)
{ {
if (kdInputEnabled)
KdRemoveFd (kdKeyboardFd); KdRemoveFd (kdKeyboardFd);
(*kdKeyboardFuncs->Fini) (kdKeyboardFd); (*kdKeyboardFuncs->Fini) (kdKeyboardFd);
kdKeyboardFd = -1; kdKeyboardFd = -1;
@ -413,6 +425,7 @@ KdInitInput(KdMouseFuncs *pMouseFuncs,
kdLeds = 0; kdLeds = 0;
kdBellPitch = 1000; kdBellPitch = 1000;
kdBellDuration = 200; kdBellDuration = 200;
kdInputEnabled = TRUE;
KdInitModMap (); KdInitModMap ();
KdInitAutoRepeats (); KdInitAutoRepeats ();
KdResetInputMachine (); KdResetInputMachine ();
@ -710,7 +723,7 @@ xEvent kdHeldEvent;
int kdEmulationDx, kdEmulationDy; int kdEmulationDx, kdEmulationDy;
#define EMULATION_WINDOW 10 #define EMULATION_WINDOW 10
#define EMULATION_TIMEOUT 30 #define EMULATION_TIMEOUT 100
#define EventX(e) ((e)->u.keyButtonPointer.rootX) #define EventX(e) ((e)->u.keyButtonPointer.rootX)
#define EventY(e) ((e)->u.keyButtonPointer.rootY) #define EventY(e) ((e)->u.keyButtonPointer.rootY)
@ -1003,7 +1016,9 @@ KdReleaseAllKeys (void)
xE.u.keyButtonPointer.time = GetTimeInMillis(); xE.u.keyButtonPointer.time = GetTimeInMillis();
xE.u.u.type = KeyRelease; xE.u.u.type = KeyRelease;
xE.u.u.detail = key; xE.u.u.detail = key;
KdBlockSigio ();
KdHandleKeyboardEvent (&xE); KdHandleKeyboardEvent (&xE);
KdUnblockSigio ();
} }
} }
@ -1082,12 +1097,14 @@ KdEnqueueKeyboardEvent(unsigned char scan_code,
return; return;
} }
} }
#if 0
if (xE.u.u.type == KeyRelease && !IsKeyDown (key_code)) if (xE.u.u.type == KeyRelease && !IsKeyDown (key_code))
{ {
xE.u.u.type = KeyPress; xE.u.u.type = KeyPress;
KdHandleKeyboardEvent (&xE); KdHandleKeyboardEvent (&xE);
xE.u.u.type = KeyRelease; xE.u.u.type = KeyRelease;
} }
#endif
KdCheckSpecialKeys (&xE); KdCheckSpecialKeys (&xE);
KdHandleKeyboardEvent (&xE); KdHandleKeyboardEvent (&xE);
} }

66
hw/kdrive/src/kpict.c Normal file
View File

@ -0,0 +1,66 @@
/*
* $Id$
*
* Copyright © 1999 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "kdrive.h"
#include "picturestr.h"
void
KdCheckComposite (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height)
{
KdCheckSync (pDst->pDrawable->pScreen);
fbComposite (op,
pSrc,
pMask,
pDst,
xSrc,
ySrc,
xMask,
yMask,
xDst,
yDst,
width,
height);
}
KdPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
PictureScreenPtr ps;
if (!fbPictureInit (pScreen, formats, nformats))
return FALSE;
ps = GetPictureScreen(pScreen);
ps->Composite = KdCheckComposite;
return TRUE;
}

View File

@ -1,5 +1,5 @@
/* /*
* Id: trident.c,v 1.2 1999/11/02 08:17:24 keithp Exp $ * $Id$
* *
* Copyright © 1999 Keith Packard * Copyright © 1999 Keith Packard
* *
@ -115,7 +115,7 @@ tridentPause ()
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 200 * 1000; tv.tv_usec = 50 * 1000;
select (1, 0, 0, 0, &tv); select (1, 0, 0, 0, &tv);
} }
@ -125,6 +125,7 @@ tridentPreserve (KdCardInfo *card)
TridentCardInfo *tridentc = card->driver; TridentCardInfo *tridentc = card->driver;
fbdevPreserve (card); fbdevPreserve (card);
tridentPause ();
tridentc->save.reg_3c4_0e = tridentReadIndex (tridentc, 0x3c4, 0x0e); tridentc->save.reg_3c4_0e = tridentReadIndex (tridentc, 0x3c4, 0x0e);
tridentc->save.reg_3d4_36 = tridentReadIndex (tridentc, 0x3d4, 0x36); tridentc->save.reg_3d4_36 = tridentReadIndex (tridentc, 0x3d4, 0x36);
tridentc->save.reg_3d4_39 = tridentReadIndex (tridentc, 0x3d4, 0x39); tridentc->save.reg_3d4_39 = tridentReadIndex (tridentc, 0x3d4, 0x39);
@ -189,7 +190,9 @@ tridentResetMMIO (TridentCardInfo *tridentc)
#ifdef TRI_DEBUG #ifdef TRI_DEBUG
fprintf (stderr, "Reset MMIO\n"); fprintf (stderr, "Reset MMIO\n");
#endif #endif
tridentPause ();
tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21); tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21);
tridentPause ();
tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62); tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62);
tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39); tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39);
tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36); tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36);
@ -229,6 +232,7 @@ tridentDPMS (ScreenPtr pScreen, int mode)
TridentCardInfo *tridentc = pScreenPriv->card->driver; TridentCardInfo *tridentc = pScreenPriv->card->driver;
tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentDPMSModes[mode]); tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentDPMSModes[mode]);
tridentPause ();
return TRUE; return TRUE;
} }

View File

@ -636,7 +636,7 @@ static const GCOps tridentOps = {
KdCheckPolyArc, KdCheckPolyArc,
miFillPolygon, miFillPolygon,
tridentPolyFillRect, tridentPolyFillRect,
KdCheckPolyFillArc, miPolyFillArc,
miPolyText8, miPolyText8,
miPolyText16, miPolyText16,
miImageText8, miImageText8,