Commit 42238011 authored by Keith Packard's avatar Keith Packard
Browse files

Add overlay support for savage. Make sis setup code work on nIc

parent 325fb002
......@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.3 2000/02/23 20:30:01 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.4 2000/05/06 22:17:44 keithp Exp $ */
#include "s3.h"
......@@ -226,11 +226,12 @@ s3ModeUsable (KdScreenInfo *screen)
screen->fb[fb].bitsPerPixel = 8;
}
byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
pixel_width = screen->width;
screen->fb[fb].pixelStride = pixel_width;
screen->fb[fb].byteStride = byte_width;
screen_size += byte_width * screen->height;
/*
* SGRAM requires stride % 64 == 0
*/
screen->fb[fb].pixelStride = (screen->width + 63) & ~63;
screen->fb[fb].byteStride = screen->fb[fb].pixelStride * (screen->fb[fb].bitsPerPixel >> 3);
screen_size += screen->fb[fb].byteStride * screen->height;
}
return screen_size <= s3c->memory;
......@@ -340,6 +341,12 @@ s3ScreenInit (KdScreenInfo *screen)
screen->fb[fb].frameBuffer = s3c->frameBuffer + screen_size;
screen_size += screen->fb[fb].byteStride * screen->height;
REGION_INIT(pScreen, (&s3s->region[fb]), NullBox, 0);
if (screen->fb[fb].bitsPerPixel == 8)
s3s->fb[ma].chroma_key = 0xff;
else
s3s->fb[ma].chroma_key = 0;
/*
* Use remaining memory for off-screen storage, but only use
* one piece (either right or bottom).
......@@ -1101,6 +1108,9 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_sequential_addressing_mode, 1);
s3Set (s3vga, s3_select_chain_4_mode, 1);
s3Set (s3vga, s3_linear_addressing_control, 1);
s3Set (s3vga, s3_enable_gamma_correction, 0);
s3Set (s3vga, s3_enable_8_bit_luts, 1);
s3Set (s3vga, s3_dclk_invert, 0);
......@@ -1150,7 +1160,6 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_eclk_r, r);
#endif
s3s->manage_border = FALSE;
/*
* Compute character lengths for horizontal timing values
*/
......@@ -1189,10 +1198,6 @@ s3Enable (ScreenPtr pScreen)
h_blank_start_adjust = -3;
h_blank_end_adjust = -4;
s3Set (s3vga, s3_border_select, 0);
#if 0
s3s->manage_border = TRUE;
/* s3Set (s3vga, s3_border_color, pScreen->blackPixel); */
#endif
}
break;
case 16:
......@@ -1522,6 +1527,8 @@ s3Enable (ScreenPtr pScreen)
VgaFlush(&s3vga->card);
VgaSetImm (&s3vga->card, s3_clock_load_imm, 1);
VgaSetImm(&s3vga->card, s3_clock_load_imm, 0);
if (s3s->use_streams)
{
fb = s3s->fbmap[0];
......@@ -1537,7 +1544,7 @@ s3Enable (ScreenPtr pScreen)
fb = s3s->fbmap[1];
s3->blend_control = 5 << 24;
if (s3s->fb[0].accel_bpp == 8)
s3->chroma_key_control = 0x330000ff;
s3->chroma_key_control = 0x33000000 | s3s->fb[0].chroma_key;
else
s3->chroma_key_control = 0x13010101;
s3->secondary_stream_control = control[1] | screen->width;
......@@ -1758,97 +1765,26 @@ s3DPMS (ScreenPtr pScreen, int mode)
return TRUE;
}
void
s3DumbPaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
Bool
s3InitScreen(ScreenPtr pScreen)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
KdScreenPriv(pScreen);
KdCardInfo *card = pScreenPriv->card;
KdScreenInfo *screen = pScreenPriv->screen;
s3CardInfo (pScreenPriv);
s3ScreenInfo (pScreenPriv);
if (pWin->drawable.depth != s3s->primary_depth)
int ma, fb;
if (screen->fb[1].depth)
{
int nBox = REGION_NUM_RECTS(pRegion);
BoxPtr pBox = REGION_RECTS(pRegion);
PixmapPtr pPixmap;
FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
FbBits *dst;
FbStride dstStride;
int dstBpp;
if (pScrPriv->pLayer[0]->drawable.depth == pWin->drawable.depth)
pPixmap = pScrPriv->pLayer[1];
else
pPixmap = pScrPriv->pLayer[0];
fbGetDrawable (&pPixmap->drawable, dst, dstStride, dstBpp);
while (nBox--)
FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
{
fbSolid (dst + pBox->y1 * dstStride,
dstStride,
pBox->x1 * dstBpp,
dstBpp,
(pBox->x2 - pBox->x1) * dstBpp,
(pBox->y2 - pBox->y1),
0x0, FB_ALLONES);
pBox++;
fb = s3s->fbmap[ma];
pScrPriv->layer[fb].key = s3s->fb[ma].chroma_key;
}
}
}
void
s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
{
s3DumbPaintChromaKey (pWin, pRegion);
fbPaintWindow (pWin, pRegion, what);
}
void
s3DumbCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionRec rgnDst;
int dx, dy;
PixmapPtr pPixmap;
FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
int fb;
KdCheckSync (pScreen);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
for (fb = 0; fb < pScrPriv->nlayers; fb++)
{
pPixmap = pScrPriv->pLayer[fb];
fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
0,
&rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
}
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
fbValidateDrawable (&pWin->drawable);
}
Bool
s3InitScreen(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdCardInfo *card = pScreenPriv->card;
KdScreenInfo *screen = pScreenPriv->screen;
s3CardInfo (pScreenPriv);
s3ScreenInfo (pScreenPriv);
pScreen->PaintWindowBackground = s3DumbPaintWindow;
pScreen->PaintWindowBorder = s3DumbPaintWindow;
pScreen->CopyWindow = s3DumbCopyWindow;
return TRUE;
}
......
......@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.3 2000/02/23 20:30:02 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
#ifndef _S3_H_
#define _S3_H_
......@@ -439,18 +439,19 @@ typedef struct _s3FbInfo {
CARD32 bitmap_offset;
int accel_stride;
int accel_bpp;
CARD32 chroma_key;
} S3FBInfo;
typedef struct _s3ScreenInfo {
CARD8 *cursor_base; /* pointer to cursor area */
S3Cursor cursor;
Bool manage_border;
Bool managing_border;
Bool use_streams;
int primary_depth;
int current_ma;
CARD32 border_pixel;
S3FBInfo fb[KD_MAX_FB];
RegionRec region[KD_MAX_FB];
int fbmap[KD_MAX_FB+1]; /* map from fb to stream */
} S3ScreenInfo;
......
......@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.3 2000/02/23 20:30:02 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
#include "s3.h"
......@@ -43,15 +43,51 @@ s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
}
}
#ifndef S3_TRIO
#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
void
s3SetTrueChromaKey (ScreenPtr pScreen, int pfb, xColorItem *pdef)
{
FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
KdScreenPriv(pScreen);
s3ScreenInfo(pScreenPriv);
int fb, ma;
CARD32 key;
int r, g, b;
for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
{
fb = s3s->fbmap[ma];
if (fb != pfb && pScreenPriv->screen->fb[fb].redMask)
{
r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask);
g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask);
b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask);
key = ((Shift(pdef->red,r) & pScreenPriv->screen->fb[fb].redMask) |
(Shift(pdef->green,g) & pScreenPriv->screen->fb[fb].greenMask) |
(Shift(pdef->blue,b) & pScreenPriv->screen->fb[fb].blueMask));
if (pScrPriv->layer[fb].key != key)
{
pScrPriv->layer[fb].key = key;
(*pScrPriv->PaintKey) (&pScrPriv->layer[fb].u.run.pixmap->drawable,
&pScrPriv->layer[pfb].u.run.region,
pScrPriv->layer[fb].key, fb);
}
}
}
}
#endif
void
s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
s3ScreenInfo(pScreenPriv);
S3Vga *s3vga = &s3c->s3vga;
Bool hit_border = FALSE;
Bool check_border = FALSE;
S3Vga *s3vga = &s3c->s3vga;
xColorItem *chroma = 0;
CARD32 key;
#if 0
_s3WaitVRetrace (s3vga);
......@@ -59,34 +95,28 @@ s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
S3Ptr s3 = s3c->s3;
_s3WaitVRetraceFast(s3);
#endif
if (pScreenPriv->enabled && s3s->manage_border && !s3s->managing_border)
check_border = TRUE;
#ifndef S3_TRIO
if (pScreenPriv->screen->fb[1].depth)
{
FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
key = pScrPriv->layer[fb].key;
}
#endif
else
key = ~0;
while (ndef--)
{
if (check_border && pdefs->pixel == s3s->border_pixel)
{
if (pdefs->red || pdefs->green || pdefs->blue)
hit_border = TRUE;
}
if (pdefs->pixel == key)
chroma = pdefs;
s3SetImm (s3vga, s3_dac_write_index, pdefs->pixel);
s3SetImm (s3vga, s3_dac_data, pdefs->red >> 8);
s3SetImm (s3vga, s3_dac_data, pdefs->green >> 8);
s3SetImm (s3vga, s3_dac_data, pdefs->blue >> 8);
pdefs++;
}
if (hit_border)
{
xColorItem black;
black.red = 0;
black.green = 0;
black.blue = 0;
s3s->managing_border = TRUE;
FakeAllocColor (pScreenPriv->pInstalledmap[fb],
&black);
s3s->border_pixel = black.pixel;
FakeFreeColor (pScreenPriv->pInstalledmap[fb], s3s->border_pixel);
/* s3SetImm (&s3c->s3vga, s3_border_color, (VGA8) s3s->border_pixel); */
}
#ifndef S3_TRIO
if (chroma && !pScreenPriv->closed)
s3SetTrueChromaKey (pScreen, fb, chroma);
#endif
}
......@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.3 2000/02/23 20:30:03 dawes Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.4 2000/05/06 22:17:46 keithp Exp $ */
#include "s3.h"
#include "s3draw.h"
......@@ -491,7 +491,6 @@ s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
BoxPtr pboxClippedBase;
BoxPtr pextent;
BoxRec stackRects[NUM_STACK_RECTS];
FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
int numRects;
int n;
int xorg, yorg;
......@@ -712,7 +711,6 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
int nTmp;
int *pwidthFree;/* copies of the pointers to free */
DDXPointPtr pptFree;
FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
BoxPtr extents;
S3PatternCache *cache;
RegionPtr pClip = fbGetCompositeClip (pGC);
......@@ -994,17 +992,19 @@ s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
}
void
s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
int mode, int countInit, DDXPointPtr ptsIn)
s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape,
int mode, int countInit, DDXPointPtr ptsIn)
{
SetupS3(pDrawable->pScreen);
FbGCPrivPtr fbPriv;
int nwidth;
int maxy;
int origin;
int count;
register int vertex1, vertex2;
int c;
RegionPtr pClip = fbGetCompositeClip(pGC);
BoxPtr extents;
int clip;
int y, sy;
int *vertex1p, *vertex2p;
int *endp;
......@@ -1018,17 +1018,21 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
int l, r;
int nmiddle;
if (mode == CoordModePrevious)
if (mode == CoordModePrevious || REGION_NUM_RECTS(pClip) != 1)
{
KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
fbPriv = fbGetGCPrivate(pGC);
sy = pDrawable->y;
sx = pDrawable->x;
extents = &fbGetCompositeClip(pGC)->extents;
origin = *((int *) &pDrawable->x);
origin -= (origin & 0x8000) << 1;
extents = &pClip->extents;
vertex1 = *((int *) &extents->x1) - origin;
vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
clip = 0;
y = 32767;
maxy = 0;
......@@ -1040,14 +1044,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
while (count--)
{
c = *vertex2p;
/*
* Check for negative or over S3 limits
*/
if (c & 0xe000e000)
{
KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
clip |= (c - vertex1) | (vertex2 - c);
c = intToY(c);
DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c));
if (c < y)
......@@ -1070,14 +1067,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
while (count--)
{
c = *vertex2p;
/*
* Check for negative or over S3 limits
*/
if (c & 0xe000e000)
{
KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
clip |= (c - vertex1) | (vertex2 - c);
c = intToY(c);
DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c));
if (c < y)
......@@ -1111,16 +1101,17 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
if (x1 != dx2)
yFlip++;
if (yFlip != 2)
{
KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
clip = 0x8000;
}
if (y == maxy)
return;
if (clip & 0x80008000)
{
KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
return;
}
_s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
_s3SetClip(s3,extents);
vertex2p = vertex1p;
vertex2 = vertex1 = *vertex2p++;
......@@ -1236,7 +1227,6 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
if (y == maxy)
break;
}
_s3ResetClip (s3, pDrawable->pScreen);
MarkSyncS3 (pDrawable->pScreen);
}
......@@ -2162,15 +2152,8 @@ s3CreateWindow (WindowPtr pWin)
KdScreenPriv(pWin->drawable.pScreen);
s3ScreenInfo(pScreenPriv);
if (!KdCreateWindow (pWin))
return FALSE;
pWin->devPrivates[s3WindowPrivateIndex].ptr = 0;
#ifndef S3_TRIO
if (pWin->drawable.depth != s3s->primary_depth)
return fbOverlayCreateWindow (pWin);
else
#endif
return fbCreateWindow (pWin);
return KdCreateWindow (pWin);
}
Bool
......@@ -2217,27 +2200,34 @@ s3ChangeWindowAttributes (WindowPtr pWin, Mask mask)
return ret;
}
#ifndef S3_TRIO
void
s3PaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
s3PaintKey (DrawablePtr pDrawable,
RegionPtr pRegion,
CARD32 pixel,
int fb)
{
SetupS3 (pWin->drawable.pScreen);
SetupS3 (pDrawable->pScreen);
s3ScreenInfo (pScreenPriv);
int nBox = REGION_NUM_RECTS(pRegion);
BoxPtr pBox = REGION_RECTS(pRegion);
int ma;
if (pWin->drawable.depth != s3s->primary_depth)
if (!nBox)
return;
for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
if (s3s->fbmap[ma] == fb)
break;
s3SetGlobalBitmap (pDrawable->pScreen, ma);
_s3SetSolidFill (s3, pixel, GXcopy, 0xffffffff);
while (nBox--)
{
int nBox = REGION_NUM_RECTS(pRegion);
BoxPtr pBox = REGION_RECTS(pRegion);
s3SetGlobalBitmap (pWin->drawable.pScreen, 0);
_s3SetSolidFill(s3,0xffffffff,GXcopy,0xffffffff);
while (nBox--)
{
_s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
pBox++;
}
MarkSyncS3 (pWin->drawable.pScreen);
_s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
pBox++;
}
MarkSyncS3 (pDrawable->pScreen);
}
#endif
......@@ -2245,6 +2235,7 @@ void
s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
{
SetupS3(pWin->drawable.pScreen);
s3ScreenInfo(pScreenPriv);
s3PatternPtr pPattern;
DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
......@@ -2254,9 +2245,6 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
REGION_NUM_RECTS(pRegion)));
if (!REGION_NUM_RECTS(pRegion))
return;
#ifndef S3_TRIO
s3PaintChromaKey (pWin, pRegion);
#endif
switch (what) {
case PW_BACKGROUND:
switch (pWin->backgroundState) {
......@@ -2289,6 +2277,12 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
}
break;
case PW_BORDER:
#ifndef S3_TRIO
if (s3s->fbmap[1] >= 0)
fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
fbOverlayWindowLayer (pWin),
pRegion);
#endif
if (pWin->borderIsPixel)
{
s3FillBoxSolid((DrawablePtr)pWin,
......@@ -2302,19 +2296,6 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
KdCheckPaintWindow (pWin, pRegion, what);
}
void
s3RestoreAreas(PixmapPtr pPixmap,
RegionPtr prgnRestore,
int xorg,
int yorg,
WindowPtr pWin)
{
#ifndef S3_TRIO
s3PaintChromaKey (pWin, prgnRestore);
#endif
KdCheckRestoreAreas (pPixmap, prgnRestore, xorg, yorg, pWin);
}
void
s3CopyWindowProc (DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
......@@ -2330,86 +2311,94 @@ s3CopyWindowProc (DrawablePtr pSrcDrawable,
{
SetupS3(pDstDrawable->pScreen);
s3ScreenInfo(pScreenPriv);
int srcX, srcY, dstX, dstY;
int x1, x2;
int w, h;
int flags;
int ma;
BoxPtr pbox;
int nbox;
KdScreenInfo *screen = pScreenPriv->screen;
int srcX, srcY, dstX, dstY;
int x1, x2;
int w, h;
int flags;
int fb = (int) closure;
int ma;
BoxPtr pbox;
int nbox;
int bitsPerPixel;
if (pSrcDrawable->bitsPerPixel == 24)
dx *= 3;
#ifdef S3_TRIO
ma = 0;
#else
for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
if (s3s->fbmap[ma] == fb)
break;
#endif
bitsPerPixel = screen->fb[fb].bitsPerPixel;
if (bitsPerPixel == 24)
dx *= 3;
nbox = nboxOrig;
pbox = pboxOrig;
s3SetGlobalBitmap (pDstDrawable->pScreen, ma);
_s3SetBlt(s3,GXcopy,~0);