i128accel.c revision a73423d7
150806d53Smrg
250806d53Smrg/*
350806d53Smrg * Copyright 1997-2000 by Robin Cutshaw <robin@XFree86.Org>
450806d53Smrg *
550806d53Smrg * Permission to use, copy, modify, distribute, and sell this software and its
650806d53Smrg * documentation for any purpose is hereby granted without fee, provided that
750806d53Smrg * the above copyright notice appear in all copies and that both that
850806d53Smrg * copyright notice and this permission notice appear in supporting
950806d53Smrg * documentation, and that the name of Robin Cutshaw not be used in
1050806d53Smrg * advertising or publicity pertaining to distribution of the software without
1150806d53Smrg * specific, written prior permission.  Robin Cutshaw makes no representations
1250806d53Smrg * about the suitability of this software for any purpose.  It is provided
1350806d53Smrg * "as is" without express or implied warranty.
1450806d53Smrg *
1550806d53Smrg * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1650806d53Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1750806d53Smrg * EVENT SHALL ROBIN CUTSHAW BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1850806d53Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1950806d53Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
2050806d53Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2150806d53Smrg * PERFORMANCE OF THIS SOFTWARE.
2250806d53Smrg *
2350806d53Smrg */
2450806d53Smrg
2550806d53Smrg#ifdef HAVE_CONFIG_H
2650806d53Smrg#include "config.h"
2750806d53Smrg#endif
2850806d53Smrg
29a73423d7Smrg
3050806d53Smrg#include "xf86fbman.h"
3150806d53Smrg#include "miline.h"
3250806d53Smrg#include "servermd.h"
3350806d53Smrg
3450806d53Smrg#include "xf86.h"
3550806d53Smrg#include "xf86_OSproc.h"
3650806d53Smrg#include "xf86Pci.h"
3750806d53Smrg#include "xf86PciInfo.h"
3850806d53Smrg
3950806d53Smrg#include "i128.h"
4050806d53Smrg#include "i128reg.h"
4150806d53Smrg
42a73423d7Smrg#ifdef HAVE_XAA_H
43a73423d7Smrg#include "xaalocal.h"
44a73423d7Smrg
4550806d53Smrgstatic void I128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2,
4650806d53Smrg	int w, int h);
4750806d53Smrgstatic void I128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
4850806d53Smrg        int ydir, int rop, unsigned planemask, int transparency_color);
4950806d53Smrgstatic void I128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
5050806d53Smrg	int x2, int y2, int w, int h);
5150806d53Smrgstatic void I128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
5250806d53Smrg	unsigned planemask);
5350806d53Smrgstatic void I128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w,
5450806d53Smrg        int h);
5550806d53Smrgstatic void I128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1,
5650806d53Smrg        int x2, int y2, int flags);
5750806d53Smrgstatic void I128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1,
5850806d53Smrg	int x2, int y2);
5950806d53Smrgstatic void I128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop,
6050806d53Smrg	unsigned int planemask, int nBox, register BoxPtr pBoxI);
617965d9acSmrg#if 0
6250806d53Smrgstatic void I128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox,
6350806d53Smrg        DDXPointPtr pptSrc, BoxPtr pbox, int xdir, int ydir, int alu,
6450806d53Smrg        unsigned planemask);
657965d9acSmrg#endif
6650806d53Smrg
67a73423d7Smrg#endif
6850806d53Smrg#define ENG_PIPELINE_READY() { while (pI128->mem.rbase_a[BUSY] & BUSY_BUSY) ; }
6950806d53Smrg#define ENG_DONE() { while (pI128->mem.rbase_a[FLOW] & (FLOW_DEB | FLOW_MCB | FLOW_PRV)) ;}
7050806d53Smrg
7150806d53Smrg
7250806d53Smrg/* pre-shift rops and just or in as needed */
7350806d53Smrg
7450806d53Smrgstatic const CARD32 i128alu[16] =
7550806d53Smrg{
7650806d53Smrg   CR_CLEAR<<8,
7750806d53Smrg   CR_AND<<8,
7850806d53Smrg   CR_AND_REV<<8,
7950806d53Smrg   CR_COPY<<8,
8050806d53Smrg   CR_AND_INV<<8,
8150806d53Smrg   CR_NOOP<<8,
8250806d53Smrg   CR_XOR<<8,
8350806d53Smrg   CR_OR<<8,
8450806d53Smrg   CR_NOR<<8,
8550806d53Smrg   CR_EQUIV<<8,
8650806d53Smrg   CR_INVERT<<8,
8750806d53Smrg   CR_OR_REV<<8,
8850806d53Smrg   CR_COPY_INV<<8,
8950806d53Smrg   CR_OR_INV<<8,
9050806d53Smrg   CR_NAND<<8,
9150806d53Smrg   CR_SET<<8
9250806d53Smrg};
9350806d53Smrg                              /*  8bpp   16bpp  32bpp unused */
9450806d53Smrgstatic const int min_size[]   = { 0x62,  0x32,  0x1A, 0x00 };
9550806d53Smrgstatic const int max_size[]   = { 0x80,  0x40,  0x20, 0x00 };
9650806d53Smrgstatic const int split_size[] = { 0x20,  0x10,  0x08, 0x00 };
9750806d53Smrg
9850806d53Smrg
9950806d53Smrgvoid
10050806d53SmrgI128EngineDone(ScrnInfoPtr pScrn)
10150806d53Smrg{
10250806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
10350806d53Smrg	ENG_DONE();
10450806d53Smrg}
10550806d53Smrg
106a73423d7Smrg#ifdef HAVE_XAA_H
10750806d53Smrgstatic void
10850806d53SmrgI128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h)
10950806d53Smrg{
11050806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
11150806d53Smrg
11250806d53Smrg#if 0
11350806d53Smrg	if (pI128->Debug)
11450806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BB %d,%d %d,%d %d,%d 0x%x/0x%x\n", x1, y1, x2, y2, w, h, pI128->cmd);
11550806d53Smrg#endif
11650806d53Smrg
11750806d53Smrg	ENG_PIPELINE_READY();
11850806d53Smrg
11950806d53Smrg	pI128->mem.rbase_a[CMD] = pI128->cmd;
12050806d53Smrg	/*pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir;*/
12150806d53Smrg
12250806d53Smrg	if (pI128->blitdir & DIR_RL_TB) {
12350806d53Smrg		x1 += w; x1--;
12450806d53Smrg		x2 += w; x2--;
12550806d53Smrg	}
12650806d53Smrg	if (pI128->blitdir & DIR_LR_BT) {
12750806d53Smrg		y1 += h; y1--;
12850806d53Smrg		y2 += h; y2--;
12950806d53Smrg	}
13050806d53Smrg
13150806d53Smrg
13250806d53Smrg
13350806d53Smrg	if (pI128->Chipset == PCI_CHIP_I128) {
13450806d53Smrg		int bppi;
13550806d53Smrg
13650806d53Smrg		static int first_time_through = 1;
13750806d53Smrg
13850806d53Smrg		/* The I128-1 has a nasty bitblit bug
13950806d53Smrg		 * that occurs when dest is exactly 8 pages wide
14050806d53Smrg		 */
14150806d53Smrg
14250806d53Smrg		bppi = (pI128->mem.rbase_a[BUF_CTRL] & BC_PSIZ_MSK) >> 24;
14350806d53Smrg
14450806d53Smrg		if ((w >= min_size[bppi]) && (w <= max_size[bppi])) {
14550806d53Smrg			if (first_time_through) {
14650806d53Smrg	    			xf86DrvMsg(pScrn->scrnIndex, X_INFO,
14750806d53Smrg            				"Using I128-1 workarounds.\n");
14850806d53Smrg				first_time_through = 0;
14950806d53Smrg			}
15050806d53Smrg
15150806d53Smrg			bppi = split_size[bppi];
15250806d53Smrg#if 1
15350806d53Smrg			/* split method */
15450806d53Smrg
15550806d53Smrg			pI128->mem.rbase_a[XY2_WH] = (bppi<<16) | h;
15650806d53Smrg			pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1;	MB;
15750806d53Smrg			pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2;	MB;
15850806d53Smrg
15950806d53Smrg			ENG_PIPELINE_READY();
16050806d53Smrg
16150806d53Smrg			w -= bppi;
16250806d53Smrg
16350806d53Smrg			if (pI128->blitdir & DIR_RL_TB) {
16450806d53Smrg				/* right to left blit */
16550806d53Smrg				x1 -= bppi;
16650806d53Smrg				x2 -= bppi;
16750806d53Smrg			} else {
16850806d53Smrg				/* left to right blit */
16950806d53Smrg				x1 += bppi;
17050806d53Smrg				x2 += bppi;
17150806d53Smrg			}
17250806d53Smrg#else
17350806d53Smrg			/* clip method */
17450806d53Smrg			pI128->mem.rbase_a[CLPTL] = (x2<<16) | y2;
17550806d53Smrg			pI128->mem.rbase_a[CLPBR] = ((x2+w)<<16) | (y2+h);
17650806d53Smrg			w += bppi;
17750806d53Smrg#endif
17850806d53Smrg		}
17950806d53Smrg	}
18050806d53Smrg
18150806d53Smrg	pI128->mem.rbase_a[XY2_WH] = (w<<16) | h;
18250806d53Smrg	pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1;			MB;
18350806d53Smrg	pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2;			MB;
18450806d53Smrg}
18550806d53Smrg
18650806d53Smrgstatic void
18750806d53SmrgI128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
18850806d53Smrg	int rop, unsigned planemask, int transparency_color)
18950806d53Smrg{
19050806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
19150806d53Smrg
19250806d53Smrg#if 0
19350806d53Smrg	if (pI128->Debug)
19450806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SFSSC %d,%d %d 0x%x %d\n", xdir, ydir, rop, planemask, transparency_color);
19550806d53Smrg#endif
19650806d53Smrg
19750806d53Smrg	ENG_PIPELINE_READY();
19850806d53Smrg
19950806d53Smrg	if (planemask == -1)
20050806d53Smrg		pI128->mem.rbase_a[MASK] = -1;
20150806d53Smrg	else switch (pI128->bitsPerPixel) {
20250806d53Smrg		case 8:
20350806d53Smrg			pI128->mem.rbase_a[MASK] = planemask |
20450806d53Smrg					(planemask<<8) |
20550806d53Smrg					(planemask<<16) |
20650806d53Smrg					(planemask<<24);
20750806d53Smrg			break;
20850806d53Smrg		case 16:
20950806d53Smrg			pI128->mem.rbase_a[MASK] = planemask | (planemask<<16);
21050806d53Smrg			break;
21150806d53Smrg		case 24:
21250806d53Smrg		case 32:
21350806d53Smrg		default:
21450806d53Smrg			pI128->mem.rbase_a[MASK] = planemask;
21550806d53Smrg			break;
21650806d53Smrg	}
21750806d53Smrg
21850806d53Smrg
21950806d53Smrg	pI128->mem.rbase_a[CLPTL] = 0x00000000;
22050806d53Smrg	pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047;
22150806d53Smrg
22250806d53Smrg	if (transparency_color != -1)
22350806d53Smrg		pI128->mem.rbase_a[BACK] = transparency_color;
22450806d53Smrg
22550806d53Smrg
22650806d53Smrg	if (xdir == -1) {
22750806d53Smrg		if (ydir == -1) pI128->blitdir = DIR_RL_BT;
22850806d53Smrg		else            pI128->blitdir = DIR_RL_TB;
22950806d53Smrg	} else {
23050806d53Smrg		if (ydir == -1) pI128->blitdir = DIR_LR_BT;
23150806d53Smrg		else            pI128->blitdir = DIR_LR_TB;
23250806d53Smrg	}
23350806d53Smrg	pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir;
23450806d53Smrg
23550806d53Smrg	pI128->rop = i128alu[rop];
23650806d53Smrg	pI128->cmd = (transparency_color != -1 ? (CS_TRNSP<<16) : 0) |
23750806d53Smrg		  pI128->rop | CO_BITBLT;
23850806d53Smrg	pI128->mem.rbase_a[CMD] = pI128->cmd;
23950806d53Smrg}
24050806d53Smrg
24150806d53Smrgstatic void
24250806d53SmrgI128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
24350806d53Smrg	int x2, int y2, int w, int h)
24450806d53Smrg{
24550806d53Smrg	I128BitBlit(pScrn, x1, y1, x2, y2, w, h);
24650806d53Smrg}
24750806d53Smrg
24850806d53Smrgstatic void
24950806d53SmrgI128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask)
25050806d53Smrg{
25150806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
25250806d53Smrg
25350806d53Smrg#if 0
25450806d53Smrg	if (pI128->Debug)
25550806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SFSF color 0x%x rop 0x%x (I128rop 0x%x) pmask 0x%x\n", color, rop, i128alu[rop]>>8, planemask);
25650806d53Smrg#endif
25750806d53Smrg
25850806d53Smrg	ENG_PIPELINE_READY();
25950806d53Smrg
26050806d53Smrg	if (planemask == -1)
26150806d53Smrg		pI128->mem.rbase_a[MASK] = -1;
26250806d53Smrg	else switch (pI128->bitsPerPixel) {
26350806d53Smrg		case 8:
26450806d53Smrg			pI128->mem.rbase_a[MASK] = planemask |
26550806d53Smrg					(planemask<<8) |
26650806d53Smrg					(planemask<<16) |
26750806d53Smrg					(planemask<<24);
26850806d53Smrg			break;
26950806d53Smrg		case 16:
27050806d53Smrg			pI128->mem.rbase_a[MASK] = planemask | (planemask<<16);
27150806d53Smrg			break;
27250806d53Smrg		case 24:
27350806d53Smrg		case 32:
27450806d53Smrg		default:
27550806d53Smrg			pI128->mem.rbase_a[MASK] = planemask;
27650806d53Smrg			break;
27750806d53Smrg	}
27850806d53Smrg
27950806d53Smrg	pI128->mem.rbase_a[FORE] = color;
28050806d53Smrg
28150806d53Smrg	pI128->clptl = pI128->mem.rbase_a[CLPTL] = 0x00000000;
28250806d53Smrg	pI128->clpbr = pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ;
28350806d53Smrg
28450806d53Smrg	pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir = DIR_LR_TB;
28550806d53Smrg
28650806d53Smrg	pI128->rop = i128alu[rop];
28750806d53Smrg	pI128->cmd = (CS_SOLID<<16) | pI128->rop | CO_BITBLT;
28850806d53Smrg	pI128->mem.rbase_a[CMD] = pI128->cmd;
28950806d53Smrg}
29050806d53Smrg
29150806d53Smrgstatic void
29250806d53SmrgI128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h)
29350806d53Smrg{
29450806d53Smrg#if 0
29550806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
29650806d53Smrg
29750806d53Smrg	if (pI128->Debug)
29850806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SSFR %d,%d %d,%d\n", x, y, w, h);
29950806d53Smrg#endif
30050806d53Smrg	I128BitBlit(pScrn, 0, 0, x, y, w, h);
30150806d53Smrg}
30250806d53Smrg
30350806d53Smrgstatic void
30450806d53SmrgI128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2,
30550806d53Smrg	int y2, int flags)
30650806d53Smrg{
30750806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
30850806d53Smrg
30950806d53Smrg#if 0
31050806d53Smrg	if (pI128->Debug)
31150806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "STPL I128rop 0x%x  %d,%d %d,%d   clip %d,%d %d,%d\n", pI128->rop, x1, y1, x2, y2, pI128->clptl>>16, pI128->clptl&0xffff, (pI128->clpbr>>16)&0xffff, pI128->clpbr&0xffff);
31250806d53Smrg#endif
31350806d53Smrg
31450806d53Smrg	ENG_PIPELINE_READY();
31550806d53Smrg
31650806d53Smrg	pI128->mem.rbase_a[CMD] =
31750806d53Smrg			((flags&0x0100) ? (CP_NLST<<24) : 0) |
31850806d53Smrg			(CC_CLPRECI<<21) |
31950806d53Smrg			(CS_SOLID<<16) |
32050806d53Smrg			pI128->rop |
32150806d53Smrg			CO_LINE;
32250806d53Smrg
32350806d53Smrg	pI128->mem.rbase_a[CLPTL] = pI128->clptl;
32450806d53Smrg	pI128->mem.rbase_a[CLPBR] = pI128->clpbr;
32550806d53Smrg
32650806d53Smrg	pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1;			MB;
32750806d53Smrg	pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2;			MB;
32850806d53Smrg}
32950806d53Smrg
33050806d53Smrgstatic void
33150806d53SmrgI128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
33250806d53Smrg{
33350806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
33450806d53Smrg	int tmp;
33550806d53Smrg
33650806d53Smrg#if 0
33750806d53Smrg	if (pI128->Debug)
33850806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SCR  %d,%d %d,%d\n", x1, y1, x2, y2);
33950806d53Smrg#endif
34050806d53Smrg
34150806d53Smrg	if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
34250806d53Smrg	if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
34350806d53Smrg
34450806d53Smrg	pI128->clptl = (x1<<16) | y1;
34550806d53Smrg	pI128->clpbr = (x2<<16) | y2;
34650806d53Smrg}
34750806d53Smrg
34850806d53Smrg
34950806d53Smrgstatic void
35050806d53SmrgI128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask,
35150806d53Smrg	int nBox, register BoxPtr pBoxI)
35250806d53Smrg{
35350806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
35450806d53Smrg	register int w, h;
35550806d53Smrg
35650806d53Smrg#if 0
35750806d53Smrg	if (pI128->Debug)
35850806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FSR color 0x%x rop 0x%x (I128rop 0x%x) pmask 0x%x\n", fg, rop, i128alu[rop]>>8, planemask);
35950806d53Smrg#endif
36050806d53Smrg
36150806d53Smrg	ENG_PIPELINE_READY();
36250806d53Smrg
36350806d53Smrg	if (planemask != -1) {
36450806d53Smrg		if (pI128->bitsPerPixel == 8) {
36550806d53Smrg			planemask |= (planemask<<8)  |
36650806d53Smrg				     (planemask<<16) |
36750806d53Smrg				     (planemask<<24);
36850806d53Smrg		} else if (pI128->bitsPerPixel == 16)
36950806d53Smrg			planemask |= planemask<<16;
37050806d53Smrg	}
37150806d53Smrg
37250806d53Smrg	pI128->mem.rbase_a[MASK] = planemask;
37350806d53Smrg	pI128->mem.rbase_a[FORE] = fg;
37450806d53Smrg	pI128->mem.rbase_a[CMD] = (CS_SOLID<<16) | i128alu[rop] | CO_BITBLT;
37550806d53Smrg	pI128->mem.rbase_a[CLPTL] = 0x00000000;
37650806d53Smrg	pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047;
37750806d53Smrg
37850806d53Smrg	pI128->mem.rbase_a[XY3_DIR] = DIR_LR_TB;
37950806d53Smrg	pI128->mem.rbase_a[XY0_SRC] = 0x00000000;
38050806d53Smrg
38150806d53Smrg	while (nBox > 0) {
38250806d53Smrg		w = pBoxI->x2 - pBoxI->x1;
38350806d53Smrg		h = pBoxI->y2 - pBoxI->y1;
38450806d53Smrg		if (w > 0 && h > 0) {
38550806d53Smrg			pI128->mem.rbase_a[XY2_WH] = (w<<16) | h;	MB;
38650806d53Smrg			pI128->mem.rbase_a[XY1_DST] =
38750806d53Smrg				(pBoxI->x1<<16) | pBoxI->y1;		MB;
38850806d53Smrg
38950806d53Smrg			ENG_PIPELINE_READY();
39050806d53Smrg#if 0
39150806d53Smrg			if (pI128->Debug)
39250806d53Smrg				xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FSR x,y %d,%d w,h %d,%d\n", pBoxI->x1, pBoxI->y1, w, h);
39350806d53Smrg#endif
39450806d53Smrg
39550806d53Smrg		}
39650806d53Smrg		pBoxI++;
39750806d53Smrg		nBox--;
39850806d53Smrg	}
39950806d53Smrg
40050806d53Smrg	ENG_DONE();
40150806d53Smrg
40250806d53Smrg}
40350806d53Smrg
4047965d9acSmrg#if 0
40550806d53Smrgstatic void
40650806d53SmrgI128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, DDXPointPtr pptSrc,
40750806d53Smrg	BoxPtr pbox, int xdir, int ydir, int alu, unsigned planemask)
40850806d53Smrg{
40950806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
41050806d53Smrg        I128SetupForScreenToScreenCopy(pScrn, xdir, ydir, alu, planemask, -1);
41150806d53Smrg        for (; nbox; pbox++, pptSrc++, nbox--)
41250806d53Smrg            I128SubsequentScreenToScreenCopy(pScrn, pptSrc->x, pptSrc->y,
41350806d53Smrg                pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
41450806d53Smrg	ENG_DONE();
41550806d53Smrg}
4167965d9acSmrg#endif
41750806d53Smrg
418a73423d7Smrg#endif
419a73423d7Smrg
42050806d53SmrgBool
42150806d53SmrgI128XaaInit(ScreenPtr pScreen)
42250806d53Smrg{
423a73423d7Smrg#ifdef HAVE_XAA_H
42450806d53Smrg	XAAInfoRecPtr infoPtr;
425a73423d7Smrg	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
42650806d53Smrg	I128Ptr pI128 = I128PTR(pScrn);
42750806d53Smrg	BoxRec AvailFBArea;
42850806d53Smrg	CARD32 buf_ctrl;
42950806d53Smrg	int maxlines;
43050806d53Smrg
43150806d53Smrg	pI128->XaaInfoRec = infoPtr = XAACreateInfoRec();
43250806d53Smrg	if (!infoPtr) return FALSE;
43350806d53Smrg
43450806d53Smrg	infoPtr->Flags = 	PIXMAP_CACHE |
43550806d53Smrg				OFFSCREEN_PIXMAPS |
43650806d53Smrg				LINEAR_FRAMEBUFFER ;
43750806d53Smrg
43850806d53Smrg	infoPtr->Sync = I128EngineDone;
43950806d53Smrg
44050806d53Smrg	/* screen to screen copy */
44150806d53Smrg	infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY;
44250806d53Smrg	if (pI128->Chipset == PCI_CHIP_I128_T2R)
44350806d53Smrg		infoPtr->ScreenToScreenCopyFlags |= ONLY_LEFT_TO_RIGHT_BITBLT;
44450806d53Smrg
44550806d53Smrg	infoPtr->SetupForScreenToScreenCopy = I128SetupForScreenToScreenCopy;
44650806d53Smrg	infoPtr->SubsequentScreenToScreenCopy =
44750806d53Smrg					    I128SubsequentScreenToScreenCopy;
44850806d53Smrg
44950806d53Smrg#if 0
45050806d53Smrg	/* screen to screen color expansion */
45150806d53Smrg	if (pI128->Chipset == PCI_CHIP_I128_T2R)
45250806d53Smrg		infoPtr->ScreenToScreenColorExpandFillFlags |=
45350806d53Smrg			ONLY_LEFT_TO_RIGHT_BITBLT;
45450806d53Smrg
45550806d53Smrg	infoPtr->SetupForScreenToScreenColorExpandFill =
45650806d53Smrg		I128SetupForScreenToScreenColorExpandFill;
45750806d53Smrg	infoPtr->SubsequentScreenToScreenColorExpandFill =
45850806d53Smrg		I128SubsequentScreenToScreenColorExpandFill;
45950806d53Smrg#endif
46050806d53Smrg
46150806d53Smrg	/* solid fills */
46250806d53Smrg	infoPtr->SetupForSolidFill = I128SetupForSolidFill;
46350806d53Smrg	infoPtr->SubsequentSolidFillRect = I128SubsequentSolidFillRect;
46450806d53Smrg
46550806d53Smrg	infoPtr->FillSolidRects = I128FillSolidRects;
46650806d53Smrg
46750806d53Smrg	/* solid lines */
46850806d53Smrg	infoPtr->SubsequentSolidTwoPointLine = I128SubsequentSolidTwoPointLine;
46950806d53Smrg
47050806d53Smrg	/* clipping */
47150806d53Smrg	infoPtr->ClippingFlags = HARDWARE_CLIP_LINE;
47250806d53Smrg	infoPtr->SetClippingRectangle = I128SetClippingRectangle;
47350806d53Smrg
47450806d53Smrg	infoPtr->PolyFillRectSolidFlags = 0;
47550806d53Smrg
47650806d53Smrg	maxlines = ((pI128->MemorySize * 1024) - 1024) /
47750806d53Smrg			  (pScrn->displayWidth * pI128->bitsPerPixel / 8);
47850806d53Smrg	AvailFBArea.x1 = 0;
47950806d53Smrg	AvailFBArea.x2 = pI128->displayWidth;
48050806d53Smrg	AvailFBArea.y1 = 0;
48150806d53Smrg	AvailFBArea.y2 = maxlines;
48250806d53Smrg	xf86InitFBManager(pScreen, &AvailFBArea);
48350806d53Smrg	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
48450806d53Smrg		"Using %d lines for offscreen memory\n",
48550806d53Smrg		maxlines - pScrn->virtualY);
48650806d53Smrg
48750806d53Smrg	switch (pI128->bitsPerPixel) {
48850806d53Smrg		case 8:  buf_ctrl = BC_PSIZ_8B;  break;
48950806d53Smrg		case 16: buf_ctrl = BC_PSIZ_16B; break;
49050806d53Smrg		case 24:
49150806d53Smrg		case 32: buf_ctrl = BC_PSIZ_32B; break;
49250806d53Smrg		default: buf_ctrl = 0;           break; /* error */
49350806d53Smrg	}
49450806d53Smrg	if (pI128->Chipset == PCI_CHIP_I128_T2R) {
49550806d53Smrg		if (pI128->MemoryType == I128_MEMORY_SGRAM)
49650806d53Smrg			buf_ctrl |= BC_MDM_PLN;
49750806d53Smrg		else
49850806d53Smrg			buf_ctrl |= BC_BLK_ENA;
49950806d53Smrg	}
50050806d53Smrg	pI128->mem.rbase_a[BUF_CTRL] = buf_ctrl;
50150806d53Smrg
50250806d53Smrg	pI128->mem.rbase_a[DE_PGE] = 0x00;
50350806d53Smrg	pI128->mem.rbase_a[DE_SORG] = pI128->displayOffset;
50450806d53Smrg	pI128->mem.rbase_a[DE_DORG] = pI128->displayOffset;
50550806d53Smrg	pI128->mem.rbase_a[DE_MSRC] = 0x00;
50650806d53Smrg	pI128->mem.rbase_a[DE_WKEY] = 0x00;
50750806d53Smrg	pI128->mem.rbase_a[DE_SPTCH] = pI128->mem.rbase_g[DB_PTCH];
50850806d53Smrg	pI128->mem.rbase_a[DE_DPTCH] = pI128->mem.rbase_g[DB_PTCH];
50950806d53Smrg	if (pI128->Chipset == PCI_CHIP_I128_T2R4)
51050806d53Smrg		pI128->mem.rbase_a[DE_ZPTCH] = pI128->mem.rbase_g[DB_PTCH];
51150806d53Smrg	pI128->mem.rbase_a[RMSK] = 0x00000000;
51250806d53Smrg	pI128->mem.rbase_a[XY4_ZM] = ZOOM_NONE;
51350806d53Smrg	pI128->mem.rbase_a[LPAT] = 0xffffffff;  /* for lines */
51450806d53Smrg	pI128->mem.rbase_a[PCTRL] = 0x00000000; /* for lines */
51550806d53Smrg	pI128->mem.rbase_a[CLPTL] = 0x00000000;
51650806d53Smrg	pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ;
517b3e38ee4Smrg	if (pI128->Chipset == PCI_CHIP_I128_T2R ||
518b3e38ee4Smrg	    pI128->Chipset == PCI_CHIP_I128_T2R4)
519b3e38ee4Smrg		pI128->mem.rbase_a[ACNTRL] = 0x00000000;
52050806d53Smrg	pI128->mem.rbase_a[INTM] = 0x03;
52150806d53Smrg
52250806d53Smrg	if (pI128->Debug) {
52350806d53Smrg		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I128XaaInit done\n");
52450806d53Smrg		I128DumpActiveRegisters(pScrn);
52550806d53Smrg	}
52650806d53Smrg
52750806d53Smrg	return(XAAInit(pScreen, infoPtr));
528a73423d7Smrg#else
529a73423d7Smrg	return FALSE;
530a73423d7Smrg#endif
53150806d53Smrg}
532