kdrive: Add primitive ct65550 server. Update kdrive/vesa code to support

DPMS using VESA bios routines. Include support for Toshiba SMM DPMS as
    well
This commit is contained in:
Keith Packard 2001-09-05 07:12:43 +00:00
parent f856b952ec
commit 216090d1ae
12 changed files with 1137 additions and 16 deletions

14
hw/kdrive/chips/Imakefile Normal file
View File

@ -0,0 +1,14 @@
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/chips/Imakefile,v 1.6 2000/10/20 00:19:51 keithp Exp $
KDRIVE=..
#include "../Kdrive.tmpl"
SRCS = chips.c chipsdraw.c chipsstub.c
OBJS = chips.o chipsdraw.o chipsstub.o
INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/vesa
NormalLibraryObjectRule()
NormalLibraryTarget(chips,$(OBJS))
DependTarget()

302
hw/kdrive/chips/chips.c Normal file
View File

@ -0,0 +1,302 @@
/*
* Copyright © 2001 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.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.18 2001/06/04 09:45:42 keithp Exp $ */
#include "chips.h"
#include <sys/io.h>
#undef CHIPS_DEBUG
Bool
chipsCardInit (KdCardInfo *card)
{
int k;
char *pixels;
ChipsCardInfo *chipsc;
CARD8 r00, r01, r02;
CARD8 r39;
chipsc = (ChipsCardInfo *) xalloc (sizeof (ChipsCardInfo));
if (!chipsc)
return FALSE;
iopl (3);
if (!vesaInitialize (card, &chipsc->vesa))
{
xfree (chipsc);
return FALSE;
}
#ifdef USE_PCI
chipsc->window = (CARD32 *) (chipsc->cop_base + 0x10000);
#else
chipsc->window = 0;
#endif
card->driver = chipsc;
return TRUE;
}
Bool
chipsScreenInit (KdScreenInfo *screen)
{
ChipsCardInfo *chipsc = screen->card->driver;
ChipsScreenInfo *chipss;
int screen_size, memory;
CARD32 mmio_base;
CARD32 mmio_size;
chipss = (ChipsScreenInfo *) xalloc (sizeof (ChipsScreenInfo));
if (!chipss)
return FALSE;
memset (chipss, '\0', sizeof (ChipsScreenInfo));
if (!vesaScreenInitialize (screen, &chipss->vesa))
{
xfree (chipss);
return FALSE;
}
if (chipss->vesa.mapping != VESA_LINEAR)
screen->dumb = TRUE;
if (!screen->dumb)
{
chipss->mmio_base = (CARD8 *) KdMapDevice (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss));
if (chipss->mmio_base)
{
KdSetMappedMode (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss),
KD_MAPPED_MODE_REGISTERS);
}
else
screen->dumb = TRUE;
}
else
chipss->mmio_base = 0;
chipss->screen = chipss->vesa.fb;
memory = chipss->vesa.fb_size;
screen_size = screen->fb[0].byteStride * screen->height;
if (chipss->screen && memory >= screen_size + 2048)
{
memory -= 2048;
chipss->cursor_base = chipss->screen + memory - 2048;
}
else
chipss->cursor_base = 0;
memory -= screen_size;
if (memory > screen->fb[0].byteStride)
{
chipss->off_screen = chipss->screen + screen_size;
chipss->off_screen_size = memory;
}
else
{
chipss->off_screen = 0;
chipss->off_screen_size = 0;
}
screen->driver = chipss;
return TRUE;
}
Bool
chipsInitScreen (ScreenPtr pScreen)
{
return vesaInitScreen (pScreen);
}
Bool
chipsFinishInitScreen (ScreenPtr pScreen)
{
return vesaFinishInitScreen (pScreen);
}
CARD8
chipsReadXR (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3d6);
value = inb (0x3d7);
return value;
}
void
chipsWriteXR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3d6);
outb (value, 0x3d7);
}
CARD8
chipsReadFR (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3d0);
value = inb (0x3d1);
return value;
}
void
chipsWriteFR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3d0);
outb (value, 0x3d1);
}
CARD8
chipsReadSeq (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3c4);
value = inb (0x3c5);
return value;
}
void
chipsWriteSeq (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3c4);
outb (value, 0x3c5);
}
void
chipsPreserve (KdCardInfo *card)
{
ChipsCardInfo *chipss = card->driver;
vesaPreserve(card);
}
void
chipsSetMMIO (ChipsCardInfo *chipsc)
{
}
void
chipsResetMMIO (ChipsCardInfo *chipsc)
{
}
Bool
chipsEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ChipsCardInfo *chipsc = pScreenPriv->card->driver;
if (!vesaEnable (pScreen))
return FALSE;
chipsSetMMIO (chipsc);
return TRUE;
}
Bool
chipsDPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
ErrorF ("seqreg 0x01 0x%x\n", chipsReadSeq (chipss, 0x1));
ErrorF ("dpmsreg XR61 0x%x\n", chipsReadXR (chipss, 0x61));
ErrorF ("dpmsreg XR73 0x%x\n", chipsReadXR (chipss, 0x73));
ErrorF ("flat panel FR05 0x%x\n", chipsReadFR (chipss, 0x5));
ErrorF ("flat panel XR52 0x%x\n", chipsReadXR (chipss, 0x52));
return TRUE;
}
void
chipsDisable (ScreenPtr pScreen)
{
vesaDisable (pScreen);
}
void
chipsRestore (KdCardInfo *card)
{
ChipsCardInfo *chipsc = card->driver;
chipsResetMMIO (chipsc);
vesaRestore (card);
}
void
chipsScreenFini (KdScreenInfo *screen)
{
ChipsScreenInfo *chipss = (ChipsScreenInfo *) screen->driver;
if (chipss->mmio_base)
{
KdUnmapDevice ((void *) chipss->mmio_base, CHIPS_MMIO_SIZE(chipss));
KdResetMappedMode (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss),
KD_MAPPED_MODE_REGISTERS);
}
vesaScreenFini (screen);
xfree (chipss);
screen->driver = 0;
}
void
chipsCardFini (KdCardInfo *card)
{
ChipsCardInfo *chipsc = card->driver;
vesaCardFini (card);
}
#define chipsCursorInit (void *) 0
#define chipsCursorEnable (void *) 0
#define chipsCursorDisable (void *) 0
#define chipsCursorFini (void *) 0
#define chipsRecolorCursor (void *) 0
KdCardFuncs chipsFuncs = {
chipsCardInit, /* cardinit */
chipsScreenInit, /* scrinit */
chipsInitScreen, /* initScreen */
chipsPreserve, /* preserve */
chipsEnable, /* enable */
vesaDPMS, /* dpms */
chipsDisable, /* disable */
chipsRestore, /* restore */
chipsScreenFini, /* scrfini */
chipsCardFini, /* cardfini */
chipsCursorInit, /* initCursor */
chipsCursorEnable, /* enableCursor */
chipsCursorDisable, /* disableCursor */
chipsCursorFini, /* finiCursor */
chipsRecolorCursor, /* recolorCursor */
chipsDrawInit, /* initAccel */
chipsDrawEnable, /* enableAccel */
chipsDrawSync, /* syncAccel */
chipsDrawDisable, /* disableAccel */
chipsDrawFini, /* finiAccel */
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
chipsFinishInitScreen /* finishInitScreen */
};

122
hw/kdrive/chips/chips.h Normal file
View File

@ -0,0 +1,122 @@
/*
* Id: chips.h,v 1.2 1999/11/02 08:17:24 keithp Exp $
*
* 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.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/chips/chips.h,v 1.9 2000/11/29 08:42:25 keithp Exp $ */
#ifndef _CHIPS_H_
#define _CHIPS_H_
#include <vesa.h>
/*
* offset from ioport beginning
*/
#define HIQV
#ifdef HIQV
#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x400000)
#else
#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x200000)
#endif
#define CHIPS_MMIO_SIZE(c) (0x20000)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _chipsSave {
int dummy;
} ChipsSave;
typedef struct _chipsCardInfo {
VesaCardPrivRec vesa;
CARD32 *window;
Bool mmio;
ChipsSave save;
} ChipsCardInfo;
#define getChipsCardInfo(kd) ((ChipsCardInfo *) ((kd)->card->driver))
#define chipsCardInfo(kd) ChipsCardInfo *chipsc = getChipsCardInfo(kd)
typedef struct _chipsCursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
} ChipsCursor;
#define CHIPS_CURSOR_WIDTH 64
#define CHIPS_CURSOR_HEIGHT 64
typedef struct _chipsScreenInfo {
VesaScreenPrivRec vesa;
CARD8 *mmio_base;
CARD8 *cursor_base;
CARD8 *screen;
CARD8 *off_screen;
int off_screen_size;
ChipsCursor cursor;
} ChipsScreenInfo;
#define getChipsScreenInfo(kd) ((ChipsScreenInfo *) ((kd)->screen->driver))
#define chipsScreenInfo(kd) ChipsScreenInfo *chipss = getChipsScreenInfo(kd)
Bool
chipsDrawInit (ScreenPtr pScreen);
void
chipsDrawEnable (ScreenPtr pScreen);
void
chipsDrawSync (ScreenPtr pScreen);
void
chipsDrawDisable (ScreenPtr pScreen);
void
chipsDrawFini (ScreenPtr pScreen);
CARD8
chipsReadXR (ChipsScreenInfo *chipsc, CARD8 index);
void
chipsWriteXR (ChipsScreenInfo *chipsc, CARD8 index, CARD8 value);
Bool
chipsCursorInit (ScreenPtr pScreen);
void
chipsCursorEnable (ScreenPtr pScreen);
void
chipsCursorDisable (ScreenPtr pScreen);
void
chipsCursorFini (ScreenPtr pScreen);
void
chipsRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
extern KdCardFuncs chipsFuncs;
#endif /* _CHIPS_H_ */

490
hw/kdrive/chips/chipsdraw.c Normal file
View File

@ -0,0 +1,490 @@
/*
* Id: tridentdraw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $
*
* 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.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.10 2001/06/03 18:48:19 keithp Exp $ */
#include "chips.h"
#include "Xmd.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "fontstruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
CARD8 chipsBltRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0x88, /* src AND dst */
/* GXandReverse */ 0x44, /* src AND NOT dst */
/* GXcopy */ 0xcc, /* src */
/* GXandInverted*/ 0x22, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x66, /* src XOR dst */
/* GXor */ 0xee, /* src OR dst */
/* GXnor */ 0x11, /* NOT src AND NOT dst */
/* GXequiv */ 0x99, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xdd, /* src OR NOT dst */
/* GXcopyInverted*/ 0x33, /* NOT src */
/* GXorInverted */ 0xbb, /* NOT src OR dst */
/* GXnand */ 0x77, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
CARD8 chipsSolidRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0xa0, /* src AND dst */
/* GXandReverse */ 0x50, /* src AND NOT dst */
/* GXcopy */ 0xf0, /* src */
/* GXandInverted*/ 0x0a, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x5a, /* src XOR dst */
/* GXor */ 0xfa, /* src OR dst */
/* GXnor */ 0x05, /* NOT src AND NOT dst */
/* GXequiv */ 0xa5, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xf5, /* src OR NOT dst */
/* GXcopyInverted*/ 0x0f, /* NOT src */
/* GXorInverted */ 0xaf, /* NOT src OR dst */
/* GXnand */ 0x5f, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
/* Definitions for the Chips and Technology BitBLT engine communication. */
/* These are done using Memory Mapped IO, of the registers */
/* BitBLT modes for register 93D0. */
#ifdef HIQV
#define ctPATCOPY 0xF0
#define ctLEFT2RIGHT 0x000
#define ctRIGHT2LEFT 0x100
#define ctTOP2BOTTOM 0x000
#define ctBOTTOM2TOP 0x200
#define ctSRCSYSTEM 0x400
#define ctDSTSYSTEM 0x800
#define ctSRCMONO 0x1000
#define ctBGTRANSPARENT 0x22000
#define ctCOLORTRANSENABLE 0x4000
#define ctCOLORTRANSDISABLE 0x0
#define ctCOLORTRANSDST 0x8000
#define ctCOLORTRANSROP 0x0
#define ctCOLORTRANSEQUAL 0x10000L
#define ctCOLORTRANSNEQUAL 0x0
#define ctPATMONO 0x40000L
#define ctPATSOLID 0x80000L
#define ctPATSTART0 0x000000L
#define ctPATSTART1 0x100000L
#define ctPATSTART2 0x200000L
#define ctPATSTART3 0x300000L
#define ctPATSTART4 0x400000L
#define ctPATSTART5 0x500000L
#define ctPATSTART6 0x600000L
#define ctPATSTART7 0x700000L
#define ctSRCFG 0x000000L /* Where is this for the 65550?? */
#else
#define ctPATCOPY 0xF0
#define ctTOP2BOTTOM 0x100
#define ctBOTTOM2TOP 0x000
#define ctLEFT2RIGHT 0x200
#define ctRIGHT2LEFT 0x000
#define ctSRCFG 0x400
#define ctSRCMONO 0x800
#define ctPATMONO 0x1000
#define ctBGTRANSPARENT 0x2000
#define ctSRCSYSTEM 0x4000
#define ctPATSOLID 0x80000L
#define ctPATSTART0 0x00000L
#define ctPATSTART1 0x10000L
#define ctPATSTART2 0x20000L
#define ctPATSTART3 0x30000L
#define ctPATSTART4 0x40000L
#define ctPATSTART5 0x50000L
#define ctPATSTART6 0x60000L
#define ctPATSTART7 0x70000L
#endif
#define chipsFillPix(bpp,pixel) {\
if (bpp == 8) \
{ \
pixel = pixel & 0xff; \
} \
else if (bpp == 16) \
{ \
pixel = pixel & 0xffff; \
} \
}
static VOL8 *mmio;
static CARD32 byteStride;
static CARD32 bytesPerPixel;
static CARD32 pixelStride;
void
chipsSet (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
mmio = chipss->mmio_base;
byteStride = pScreenPriv->screen->fb[0].byteStride;
bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
pixelStride = pScreenPriv->screen->fb[0].pixelStride;
}
#ifdef HIQV
#define CHIPS_BR0 0x00 /* offset */
#define CHIPS_BR1 0x04 /* bg */
#define CHIPS_BR2 0x08 /* fg */
#define CHIPS_BR3 0x0c /* monochrome */
#define CHIPS_BR4 0x10 /* bitblt */
#define CHIPS_BR5 0x14 /* pattern addr */
#define CHIPS_BR6 0x18 /* source addr */
#define CHIPS_BR7 0x1c /* dst addr */
#define CHIPS_BR8 0x20 /* dst w/h */
#else
#define CHIPS_DR0 0x83d0
#define CHIPS_DR1 0x87d0
#define CHIPS_DR2 0x8bd0
#define CHIPS_DR3 0x8fd0
#define CHIPS_DR4 0x93d0
#define CHIPS_DR5 0x97d0
#define CHIPS_DR6 0x9bd0
#define CHIPS_DR7 0x9fd0
#endif
#define DBG(x)
void
chipsPitch (int src, int dst)
{
CARD32 p;
p = ((dst & 0xffff) << 16) | (src & 0xffff);
DBG(ErrorF ("\tpitch 0x%x\n", p));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR0) = p;
#else
*(VOL32 *) (mmio + CHIPS_DR0) = p;
#endif
}
void
chipsBg (Pixel bg)
{
DBG(ErrorF ("\tbg 0x%x\n", bg));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff;
#else
*(VOL32 *) (mmio + CHIPS_DR2) = bg;
#endif
}
void
chipsFg (Pixel fg)
{
DBG(ErrorF ("\tfg 0x%x\n", fg));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR2) = fg;
#else
*(VOL32 *) (mmio + CHIPS_DR3) = fg;
#endif
}
void
chipsOp (CARD32 op)
{
DBG(ErrorF ("\top 0x%x\n", op));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR4) = op;
#else
*(VOL32 *) (mmio + CHIPS_DR4) = op;
#endif
}
void
chipsRopSolid (int rop)
{
CARD32 op;
op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
chipsOp (op);
}
void
chipsSrc (int addr)
{
DBG(ErrorF ("\tsrc 0x%x\n", addr));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR6) = addr;
#else
*(VOL32 *) (mmio + CHIPS_DR5) = addr;
#endif
}
void
chipsDst (int addr)
{
DBG(ErrorF ("\tdst 0x%x\n", addr));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR7) = addr;
#else
*(VOL32 *) (mmio + CHIPS_DR6) = addr;
#endif
}
void
chipsWidthHeightGo (int w, int h)
{
DBG(ErrorF ("\twidth height %d/%d\n", w, h));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff);
#else
*(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff);
#endif
}
void
chipsWaitIdle ()
{
#ifdef HIQV
int timeout = 0;
CARD8 tmp;
VOL32 *br4 = (VOL32 *) (mmio + CHIPS_BR4);
DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4));
DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20)));
for (;;)
{
if ((*br4 & 0x80000000) == 0)
break;
tmp = chipsReadXR (0, 0x20);
if ((tmp & 1) == 0)
break;
if (++timeout > 1000000)
{
ErrorF ("timeout\n");
tmp = chipsReadXR (0, 0x20);
chipsWriteXR (0, 0x20, tmp | 2);
sleep (1);
chipsWriteXR (0, 0x20, tmp);
sleep (1);
}
}
#else
while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000)
;
#endif
}
Bool
chipsPrepareSolid (DrawablePtr pDrawable,
int alu,
Pixel pm,
Pixel fg)
{
FbBits depthMask;
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
depthMask = FbFullMask(pDrawable->depth);
if ((pm & depthMask) != depthMask)
return FALSE;
else
{
chipsSet (pDrawable->pScreen);
chipsWaitIdle ();
chipsFillPix(pDrawable->bitsPerPixel,fg);
chipsFg (fg);
chipsBg (fg);
chipsRopSolid (alu);
chipsPitch (byteStride, byteStride);
return TRUE;
}
}
void
chipsSolid (int x1, int y1, int x2, int y2)
{
CARD32 dst;
int w, h;
DBG(ErrorF (" Solid %dx%d %dx%d\n", x1, y1, x2, y2));
dst = y1 * byteStride + x1 * bytesPerPixel;
w = (x2 - x1) * bytesPerPixel;
h = (y2 - y1);
chipsWaitIdle ();
chipsDst (dst);
chipsWidthHeightGo (w, h);
}
void
chipsDoneSolid (void)
{
}
static CARD32 copyOp;
Bool
chipsPrepareCopy (DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
int dx,
int dy,
int alu,
Pixel pm)
{
FbBits depthMask;
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
depthMask = FbFullMask(pDstDrawable->depth);
if ((pm & depthMask) != depthMask)
return FALSE;
else
{
copyOp = chipsBltRop[alu];
if (dy >= 0)
copyOp |= ctTOP2BOTTOM;
else
copyOp |= ctBOTTOM2TOP;
if (dx >= 0)
copyOp |= ctLEFT2RIGHT;
else
copyOp |= ctRIGHT2LEFT;
chipsSet (pDstDrawable->pScreen);
chipsWaitIdle ();
chipsOp (copyOp);
chipsPitch (byteStride, byteStride);
return TRUE;
}
}
void
chipsCopy (int srcX,
int srcY,
int dstX,
int dstY,
int w,
int h)
{
int src, dst;
if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP)
{
src = (srcY + h - 1) * byteStride;
dst = (dstY + h - 1) * byteStride;
}
else
{
src = srcY * byteStride;
dst = dstY * byteStride;
}
if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT)
{
src = src + (srcX + w) * bytesPerPixel - 1;
dst = dst + (dstX + w) * bytesPerPixel - 1;
}
else
{
src = src + srcX * bytesPerPixel;
dst = dst + dstX * bytesPerPixel;
}
chipsWaitIdle ();
chipsSrc (src);
chipsDst (dst);
chipsWidthHeightGo (w * bytesPerPixel, h);
}
void
chipsDoneCopy (void)
{
}
KaaScreenPrivRec chipsKaa = {
chipsPrepareSolid,
chipsSolid,
chipsDoneSolid,
chipsPrepareCopy,
chipsCopy,
chipsDoneCopy,
};
Bool
chipsDrawInit (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
case 16:
break;
default:
return FALSE;
}
if (!kaaDrawInit (pScreen, &chipsKaa))
return FALSE;
return TRUE;
}
void
chipsDrawEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
CARD8 mode;
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
mode = 0x00;
break;
case 16:
mode = 0x10;
break;
}
chipsSet (pScreen);
chipsWaitIdle ();
chipsWriteXR (chipss, 0x20, mode);
KdMarkSync (pScreen);
}
void
chipsDrawDisable (ScreenPtr pScreen)
{
}
void
chipsDrawFini (ScreenPtr pScreen)
{
}
void
chipsDrawSync (ScreenPtr pScreen)
{
chipsSet (pScreen);
chipsWaitIdle ();
}

View File

@ -0,0 +1,59 @@
/*
* Id: chipsstub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $
*
* Copyright 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/chips/chipsstub.c,v 1.5 2000/11/29 08:42:25 keithp Exp $ */
#include "chips.h"
extern int chips_clk, chips_mclk;
void
InitCard (char *name)
{
KdCardAttr attr;
KdCardInfoAdd (&chipsFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
if (!(ret = vesaProcessArgument (argc, argv, i)))
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.7 2000/11/19 20:51:12 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.9 2001/05/29 04:54:12 keithp Exp $ */
#include "vesa.h" #include "vesa.h"
@ -251,7 +251,7 @@ VbeGetMode(Vm86InfoPtr vi, int *mode)
} }
void * void *
VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size) VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys)
{ {
U8 *fb; U8 *fb;
VbeInfoBlock vib; VbeInfoBlock vib;
@ -270,6 +270,7 @@ VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size)
size = 1024 * 64L * vib.TotalMemory; size = 1024 * 64L * vib.TotalMemory;
*ret_size = size; *ret_size = size;
*ret_phys = vmib.PhysBasePtr;
before = vmib.PhysBasePtr % pagesize; before = vmib.PhysBasePtr % pagesize;
after = pagesize - ((vmib.PhysBasePtr + size) % pagesize); after = pagesize - ((vmib.PhysBasePtr + size) % pagesize);
@ -501,6 +502,48 @@ windowB:
return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset; return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset;
} }
static const int VbeDPMSModes[4] = {
0x00, /* KD_DPMS_NORMAL */
0x01, /* KD_DPMS_STANDBY */
0x02, /* KD_DPMS_SUSPEND */
0x04, /* KD_DPMS_POWERDOWN */
};
Bool
VbeDPMS(Vm86InfoPtr vi, VbeInfoBlock *vib, int mode)
{
int code;
/*
* Check which modes are supported
*/
vi->vms.regs.eax = 0x4f10;
vi->vms.regs.ebx = 0x0000;
vi->vms.regs.es = 0;
vi->vms.regs.edi = 0;
code = VbeDoInterrupt10 (vi);
if (code < 0)
{
ErrorF ("No DPMS Support\n");
return FALSE;
}
/* Skip this stage if it's not supported */
if (((vi->vms.regs.ebx >> 4) & VbeDPMSModes[mode]) != VbeDPMSModes[mode])
return FALSE;
/* Select this mode */
vi->vms.regs.eax = 0x4f10;
vi->vms.regs.ebx = (VbeDPMSModes[mode] << 8) | 0x01;
code = VbeDoInterrupt10 (vi);
if (code < 0)
{
ErrorF ("DPMS failed %d\n", code);
return FALSE;
}
return TRUE;
}
int int
VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib) VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib)
{ {

View File

@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.5 2000/10/20 00:19:50 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.6 2001/05/29 04:54:12 keithp Exp $ */
#ifndef _VBE_H #ifndef _VBE_H
#define _VBE_H #define _VBE_H
@ -134,7 +134,7 @@ int
VbeGetMode(Vm86InfoPtr vi, int *mode); VbeGetMode(Vm86InfoPtr vi, int *mode);
void * void *
VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size); VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size, CARD32 *phys);
void void
VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb); VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb);

View File

@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.15 2001/07/20 19:35:30 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.16 2001/07/24 19:06:04 keithp Exp $ */
#include "vesa.h" #include "vesa.h"
#ifdef RANDR #ifdef RANDR
@ -33,6 +33,7 @@ Bool vesa_shadow = FALSE;
Bool vesa_linear_fb = TRUE; Bool vesa_linear_fb = TRUE;
Bool vesa_restore = FALSE; Bool vesa_restore = FALSE;
Bool vesa_verbose = FALSE; Bool vesa_verbose = FALSE;
Bool vesa_force_text = FALSE;
#define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver) #define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver)
@ -959,11 +960,13 @@ vesaMapFramebuffer (KdScreenInfo *screen)
if (pscr->mode.vbe) if (pscr->mode.vbe)
pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
pscr->mode.mode, pscr->mode.mode,
&pscr->fb_size); &pscr->fb_size,
&pscr->fb_phys);
else else
pscr->fb = VgaMapFramebuffer (priv->vi, pscr->fb = VgaMapFramebuffer (priv->vi,
pscr->mode.mode, pscr->mode.mode,
&pscr->fb_size); &pscr->fb_size,
&pscr->fb_phys);
if (!pscr->fb) if (!pscr->fb)
return FALSE; return FALSE;
break; break;
@ -1451,11 +1454,13 @@ vesaEnable(ScreenPtr pScreen)
if (pscr->mode.vbe) if (pscr->mode.vbe)
pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
pscr->mode.mode, pscr->mode.mode,
&pscr->fb_size); &pscr->fb_size,
&pscr->fb_phys);
else else
pscr->fb = VgaMapFramebuffer (priv->vi, pscr->fb = VgaMapFramebuffer (priv->vi,
pscr->mode.mode, pscr->mode.mode,
&pscr->fb_size); &pscr->fb_size,
&pscr->fb_phys);
if (!pscr->fb) if (!pscr->fb)
return FALSE; return FALSE;
screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb); screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
@ -1501,6 +1506,77 @@ vesaEnable(ScreenPtr pScreen)
return TRUE; return TRUE;
} }
#ifndef TOSHIBA_SMM
# ifdef linux
# define TOSHIBA_SMM 1
# endif
# ifndef TOSHIBA_SMM
# define TOSHIBA_SMM 0
# endif
#endif
#if TOSHIBA_SMM
/*
* Toshiba laptops use a special interface to operate the backlight
*/
#include <sys/ioctl.h>
#define TOSH_PROC "/proc/toshiba"
#define TOSH_DEVICE "/dev/toshiba"
#define TOSH_SMM _IOWR('t', 0x90, 24)
typedef struct {
unsigned int eax;
unsigned int ebx __attribute__ ((packed));
unsigned int ecx __attribute__ ((packed));
unsigned int edx __attribute__ ((packed));
unsigned int esi __attribute__ ((packed));
unsigned int edi __attribute__ ((packed));
} SMMRegisters;
#define HCI_BACKLIGHT 0x0002
#define HCI_DISABLE 0x0000
#define HCI_ENABLE 0x0001
#define HCI_GET 0xfe00,
#define HCI_SET 0xff00
Bool
toshibaDPMS (ScreenPtr pScreen, int mode)
{
SMMRegisters regs;
static int fd;
if (!fd)
fd = open (TOSH_DEVICE, 2);
if (fd < 0)
return FALSE;
regs.eax = HCI_SET;
regs.ebx = HCI_BACKLIGHT;
regs.ecx = mode ? HCI_DISABLE : HCI_ENABLE;
if (ioctl (fd, TOSH_SMM, &regs) < 0)
return FALSE;
return TRUE;
}
#endif /* TOSHIBA_SMM */
Bool
vesaDPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
VesaCardPrivPtr priv = pScreenPriv->card->driver;
VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
#if TOSHIBA_SMM
if (toshibaDPMS (pScreen, mode))
return TRUE;
#endif
if (pscr->mode.vbe)
return VbeDPMS (priv->vi, priv->vbeInfo, mode);
return FALSE;
}
void void
vesaDisable(ScreenPtr pScreen) vesaDisable(ScreenPtr pScreen)
{ {
@ -1569,6 +1645,13 @@ vesaRestore(KdCardInfo *card)
VesaCardPrivPtr priv = card->driver; VesaCardPrivPtr priv = card->driver;
int n; int n;
if (vesa_force_text)
{
if (vesa_verbose)
ErrorF ("Forcing switch back to mode 3 text\n");
priv->old_vbe_mode = -1;
priv->old_vga_mode = 3;
}
for (n = 0; n < priv->nmode; n++) for (n = 0; n < priv->nmode; n++)
if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff)) if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff))
break; break;
@ -1774,6 +1857,9 @@ vesaProcessArgument (int argc, char **argv, int i)
} else if(!strcmp(argv[i], "-verbose")) { } else if(!strcmp(argv[i], "-verbose")) {
vesa_verbose = TRUE; vesa_verbose = TRUE;
return 1; return 1;
} else if(!strcmp(argv[i], "-force-text")) {
vesa_force_text = TRUE;
return 1;
} }
return 0; return 0;

View File

@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.10 2001/06/04 09:45:42 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.11 2001/07/20 19:35:30 keithp Exp $ */
#ifndef _VESA_H_ #ifndef _VESA_H_
#define _VESA_H_ #define _VESA_H_
@ -101,6 +101,7 @@ typedef struct _VesaScreenPriv {
int layerKind; int layerKind;
void *fb; void *fb;
int fb_size; int fb_size;
CARD32 fb_phys;
LayerPtr pLayer; LayerPtr pLayer;
} VesaScreenPrivRec, *VesaScreenPrivPtr; } VesaScreenPrivRec, *VesaScreenPrivPtr;
@ -137,6 +138,9 @@ vesaFinishInitScreen(ScreenPtr pScreen);
Bool Bool
vesaEnable(ScreenPtr pScreen); vesaEnable(ScreenPtr pScreen);
Bool
vesaDPMS (ScreenPtr pScreen, int mode);
void void
vesaDisable(ScreenPtr pScreen); vesaDisable(ScreenPtr pScreen);

View File

@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.5 2000/12/08 21:40:29 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.6 2001/06/04 09:45:42 keithp Exp $ */
#include "vesa.h" #include "vesa.h"
@ -29,7 +29,7 @@ const KdCardFuncs vesaFuncs = {
vesaInitScreen, /* initScreen */ vesaInitScreen, /* initScreen */
vesaPreserve, /* preserve */ vesaPreserve, /* preserve */
vesaEnable, /* enable */ vesaEnable, /* enable */
0, /* dpms */ vesaDPMS, /* dpms */
vesaDisable, /* disable */ vesaDisable, /* disable */
vesaRestore, /* restore */ vesaRestore, /* restore */
vesaScreenFini, /* scrfini */ vesaScreenFini, /* scrfini */

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86$ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.c,v 1.1 2000/10/20 00:19:51 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -225,12 +225,13 @@ VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size)
} }
void * void *
VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size) VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *ret_phys)
{ {
if (VGA_FB(vmode) == 0xa0000) if (VGA_FB(vmode) == 0xa0000)
*size = 0x10000; *size = 0x10000;
else else
*size = 0x4000; *size = 0x4000;
*ret_phys = VGA_FB(vmode);
return &LM(vi,VGA_FB(vmode)); return &LM(vi,VGA_FB(vmode));
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86$ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.h,v 1.1 2000/10/20 00:19:51 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -53,7 +53,7 @@ void *
VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size); VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size);
void * void *
VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size); VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *phys);
void void
VgaUnmapFramebuffer (Vm86InfoPtr vi); VgaUnmapFramebuffer (Vm86InfoPtr vi);