i128accel.c revision 7965d9ac
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 2950806d53Smrg#include "xaa.h" 3050806d53Smrg#include "xaalocal.h" 3150806d53Smrg#include "xf86fbman.h" 3250806d53Smrg#include "miline.h" 3350806d53Smrg#include "servermd.h" 3450806d53Smrg 3550806d53Smrg#include "xf86.h" 3650806d53Smrg#include "xf86_OSproc.h" 3750806d53Smrg#include "xf86Pci.h" 3850806d53Smrg#include "xf86PciInfo.h" 3950806d53Smrg 4050806d53Smrg#include "i128.h" 4150806d53Smrg#include "i128reg.h" 4250806d53Smrg 4350806d53Smrgstatic void I128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, 4450806d53Smrg int w, int h); 4550806d53Smrgstatic void I128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, 4650806d53Smrg int ydir, int rop, unsigned planemask, int transparency_color); 4750806d53Smrgstatic void I128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, 4850806d53Smrg int x2, int y2, int w, int h); 4950806d53Smrgstatic void I128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, 5050806d53Smrg unsigned planemask); 5150806d53Smrgstatic void I128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, 5250806d53Smrg int h); 5350806d53Smrgstatic void I128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, 5450806d53Smrg int x2, int y2, int flags); 5550806d53Smrgstatic void I128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, 5650806d53Smrg int x2, int y2); 5750806d53Smrgstatic void I128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, 5850806d53Smrg unsigned int planemask, int nBox, register BoxPtr pBoxI); 597965d9acSmrg#if 0 6050806d53Smrgstatic void I128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, 6150806d53Smrg DDXPointPtr pptSrc, BoxPtr pbox, int xdir, int ydir, int alu, 6250806d53Smrg unsigned planemask); 637965d9acSmrg#endif 6450806d53Smrg 6550806d53Smrg#define ENG_PIPELINE_READY() { while (pI128->mem.rbase_a[BUSY] & BUSY_BUSY) ; } 6650806d53Smrg#define ENG_DONE() { while (pI128->mem.rbase_a[FLOW] & (FLOW_DEB | FLOW_MCB | FLOW_PRV)) ;} 6750806d53Smrg 6850806d53Smrg 6950806d53Smrg/* pre-shift rops and just or in as needed */ 7050806d53Smrg 7150806d53Smrgstatic const CARD32 i128alu[16] = 7250806d53Smrg{ 7350806d53Smrg CR_CLEAR<<8, 7450806d53Smrg CR_AND<<8, 7550806d53Smrg CR_AND_REV<<8, 7650806d53Smrg CR_COPY<<8, 7750806d53Smrg CR_AND_INV<<8, 7850806d53Smrg CR_NOOP<<8, 7950806d53Smrg CR_XOR<<8, 8050806d53Smrg CR_OR<<8, 8150806d53Smrg CR_NOR<<8, 8250806d53Smrg CR_EQUIV<<8, 8350806d53Smrg CR_INVERT<<8, 8450806d53Smrg CR_OR_REV<<8, 8550806d53Smrg CR_COPY_INV<<8, 8650806d53Smrg CR_OR_INV<<8, 8750806d53Smrg CR_NAND<<8, 8850806d53Smrg CR_SET<<8 8950806d53Smrg}; 9050806d53Smrg /* 8bpp 16bpp 32bpp unused */ 9150806d53Smrgstatic const int min_size[] = { 0x62, 0x32, 0x1A, 0x00 }; 9250806d53Smrgstatic const int max_size[] = { 0x80, 0x40, 0x20, 0x00 }; 9350806d53Smrgstatic const int split_size[] = { 0x20, 0x10, 0x08, 0x00 }; 9450806d53Smrg 9550806d53Smrg 9650806d53Smrgvoid 9750806d53SmrgI128EngineDone(ScrnInfoPtr pScrn) 9850806d53Smrg{ 9950806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 10050806d53Smrg ENG_DONE(); 10150806d53Smrg} 10250806d53Smrg 10350806d53Smrg 10450806d53Smrgstatic void 10550806d53SmrgI128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h) 10650806d53Smrg{ 10750806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 10850806d53Smrg 10950806d53Smrg#if 0 11050806d53Smrg if (pI128->Debug) 11150806d53Smrg 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); 11250806d53Smrg#endif 11350806d53Smrg 11450806d53Smrg ENG_PIPELINE_READY(); 11550806d53Smrg 11650806d53Smrg pI128->mem.rbase_a[CMD] = pI128->cmd; 11750806d53Smrg /*pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir;*/ 11850806d53Smrg 11950806d53Smrg if (pI128->blitdir & DIR_RL_TB) { 12050806d53Smrg x1 += w; x1--; 12150806d53Smrg x2 += w; x2--; 12250806d53Smrg } 12350806d53Smrg if (pI128->blitdir & DIR_LR_BT) { 12450806d53Smrg y1 += h; y1--; 12550806d53Smrg y2 += h; y2--; 12650806d53Smrg } 12750806d53Smrg 12850806d53Smrg 12950806d53Smrg 13050806d53Smrg if (pI128->Chipset == PCI_CHIP_I128) { 13150806d53Smrg int bppi; 13250806d53Smrg 13350806d53Smrg static int first_time_through = 1; 13450806d53Smrg 13550806d53Smrg /* The I128-1 has a nasty bitblit bug 13650806d53Smrg * that occurs when dest is exactly 8 pages wide 13750806d53Smrg */ 13850806d53Smrg 13950806d53Smrg bppi = (pI128->mem.rbase_a[BUF_CTRL] & BC_PSIZ_MSK) >> 24; 14050806d53Smrg 14150806d53Smrg if ((w >= min_size[bppi]) && (w <= max_size[bppi])) { 14250806d53Smrg if (first_time_through) { 14350806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, 14450806d53Smrg "Using I128-1 workarounds.\n"); 14550806d53Smrg first_time_through = 0; 14650806d53Smrg } 14750806d53Smrg 14850806d53Smrg bppi = split_size[bppi]; 14950806d53Smrg#if 1 15050806d53Smrg /* split method */ 15150806d53Smrg 15250806d53Smrg pI128->mem.rbase_a[XY2_WH] = (bppi<<16) | h; 15350806d53Smrg pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; 15450806d53Smrg pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; 15550806d53Smrg 15650806d53Smrg ENG_PIPELINE_READY(); 15750806d53Smrg 15850806d53Smrg w -= bppi; 15950806d53Smrg 16050806d53Smrg if (pI128->blitdir & DIR_RL_TB) { 16150806d53Smrg /* right to left blit */ 16250806d53Smrg x1 -= bppi; 16350806d53Smrg x2 -= bppi; 16450806d53Smrg } else { 16550806d53Smrg /* left to right blit */ 16650806d53Smrg x1 += bppi; 16750806d53Smrg x2 += bppi; 16850806d53Smrg } 16950806d53Smrg#else 17050806d53Smrg /* clip method */ 17150806d53Smrg pI128->mem.rbase_a[CLPTL] = (x2<<16) | y2; 17250806d53Smrg pI128->mem.rbase_a[CLPBR] = ((x2+w)<<16) | (y2+h); 17350806d53Smrg w += bppi; 17450806d53Smrg#endif 17550806d53Smrg } 17650806d53Smrg } 17750806d53Smrg 17850806d53Smrg pI128->mem.rbase_a[XY2_WH] = (w<<16) | h; 17950806d53Smrg pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; 18050806d53Smrg pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; 18150806d53Smrg} 18250806d53Smrg 18350806d53Smrgstatic void 18450806d53SmrgI128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, 18550806d53Smrg int rop, unsigned planemask, int transparency_color) 18650806d53Smrg{ 18750806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 18850806d53Smrg 18950806d53Smrg#if 0 19050806d53Smrg if (pI128->Debug) 19150806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SFSSC %d,%d %d 0x%x %d\n", xdir, ydir, rop, planemask, transparency_color); 19250806d53Smrg#endif 19350806d53Smrg 19450806d53Smrg ENG_PIPELINE_READY(); 19550806d53Smrg 19650806d53Smrg if (planemask == -1) 19750806d53Smrg pI128->mem.rbase_a[MASK] = -1; 19850806d53Smrg else switch (pI128->bitsPerPixel) { 19950806d53Smrg case 8: 20050806d53Smrg pI128->mem.rbase_a[MASK] = planemask | 20150806d53Smrg (planemask<<8) | 20250806d53Smrg (planemask<<16) | 20350806d53Smrg (planemask<<24); 20450806d53Smrg break; 20550806d53Smrg case 16: 20650806d53Smrg pI128->mem.rbase_a[MASK] = planemask | (planemask<<16); 20750806d53Smrg break; 20850806d53Smrg case 24: 20950806d53Smrg case 32: 21050806d53Smrg default: 21150806d53Smrg pI128->mem.rbase_a[MASK] = planemask; 21250806d53Smrg break; 21350806d53Smrg } 21450806d53Smrg 21550806d53Smrg 21650806d53Smrg pI128->mem.rbase_a[CLPTL] = 0x00000000; 21750806d53Smrg pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047; 21850806d53Smrg 21950806d53Smrg if (transparency_color != -1) 22050806d53Smrg pI128->mem.rbase_a[BACK] = transparency_color; 22150806d53Smrg 22250806d53Smrg 22350806d53Smrg if (xdir == -1) { 22450806d53Smrg if (ydir == -1) pI128->blitdir = DIR_RL_BT; 22550806d53Smrg else pI128->blitdir = DIR_RL_TB; 22650806d53Smrg } else { 22750806d53Smrg if (ydir == -1) pI128->blitdir = DIR_LR_BT; 22850806d53Smrg else pI128->blitdir = DIR_LR_TB; 22950806d53Smrg } 23050806d53Smrg pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir; 23150806d53Smrg 23250806d53Smrg pI128->rop = i128alu[rop]; 23350806d53Smrg pI128->cmd = (transparency_color != -1 ? (CS_TRNSP<<16) : 0) | 23450806d53Smrg pI128->rop | CO_BITBLT; 23550806d53Smrg pI128->mem.rbase_a[CMD] = pI128->cmd; 23650806d53Smrg} 23750806d53Smrg 23850806d53Smrgstatic void 23950806d53SmrgI128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, 24050806d53Smrg int x2, int y2, int w, int h) 24150806d53Smrg{ 24250806d53Smrg I128BitBlit(pScrn, x1, y1, x2, y2, w, h); 24350806d53Smrg} 24450806d53Smrg 24550806d53Smrgstatic void 24650806d53SmrgI128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) 24750806d53Smrg{ 24850806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 24950806d53Smrg 25050806d53Smrg#if 0 25150806d53Smrg if (pI128->Debug) 25250806d53Smrg 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); 25350806d53Smrg#endif 25450806d53Smrg 25550806d53Smrg ENG_PIPELINE_READY(); 25650806d53Smrg 25750806d53Smrg if (planemask == -1) 25850806d53Smrg pI128->mem.rbase_a[MASK] = -1; 25950806d53Smrg else switch (pI128->bitsPerPixel) { 26050806d53Smrg case 8: 26150806d53Smrg pI128->mem.rbase_a[MASK] = planemask | 26250806d53Smrg (planemask<<8) | 26350806d53Smrg (planemask<<16) | 26450806d53Smrg (planemask<<24); 26550806d53Smrg break; 26650806d53Smrg case 16: 26750806d53Smrg pI128->mem.rbase_a[MASK] = planemask | (planemask<<16); 26850806d53Smrg break; 26950806d53Smrg case 24: 27050806d53Smrg case 32: 27150806d53Smrg default: 27250806d53Smrg pI128->mem.rbase_a[MASK] = planemask; 27350806d53Smrg break; 27450806d53Smrg } 27550806d53Smrg 27650806d53Smrg pI128->mem.rbase_a[FORE] = color; 27750806d53Smrg 27850806d53Smrg pI128->clptl = pI128->mem.rbase_a[CLPTL] = 0x00000000; 27950806d53Smrg pI128->clpbr = pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ; 28050806d53Smrg 28150806d53Smrg pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir = DIR_LR_TB; 28250806d53Smrg 28350806d53Smrg pI128->rop = i128alu[rop]; 28450806d53Smrg pI128->cmd = (CS_SOLID<<16) | pI128->rop | CO_BITBLT; 28550806d53Smrg pI128->mem.rbase_a[CMD] = pI128->cmd; 28650806d53Smrg} 28750806d53Smrg 28850806d53Smrgstatic void 28950806d53SmrgI128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) 29050806d53Smrg{ 29150806d53Smrg#if 0 29250806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 29350806d53Smrg 29450806d53Smrg if (pI128->Debug) 29550806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SSFR %d,%d %d,%d\n", x, y, w, h); 29650806d53Smrg#endif 29750806d53Smrg I128BitBlit(pScrn, 0, 0, x, y, w, h); 29850806d53Smrg} 29950806d53Smrg 30050806d53Smrgstatic void 30150806d53SmrgI128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, 30250806d53Smrg int y2, int flags) 30350806d53Smrg{ 30450806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 30550806d53Smrg 30650806d53Smrg#if 0 30750806d53Smrg if (pI128->Debug) 30850806d53Smrg 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); 30950806d53Smrg#endif 31050806d53Smrg 31150806d53Smrg ENG_PIPELINE_READY(); 31250806d53Smrg 31350806d53Smrg pI128->mem.rbase_a[CMD] = 31450806d53Smrg ((flags&0x0100) ? (CP_NLST<<24) : 0) | 31550806d53Smrg (CC_CLPRECI<<21) | 31650806d53Smrg (CS_SOLID<<16) | 31750806d53Smrg pI128->rop | 31850806d53Smrg CO_LINE; 31950806d53Smrg 32050806d53Smrg pI128->mem.rbase_a[CLPTL] = pI128->clptl; 32150806d53Smrg pI128->mem.rbase_a[CLPBR] = pI128->clpbr; 32250806d53Smrg 32350806d53Smrg pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; 32450806d53Smrg pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; 32550806d53Smrg} 32650806d53Smrg 32750806d53Smrgstatic void 32850806d53SmrgI128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) 32950806d53Smrg{ 33050806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 33150806d53Smrg int tmp; 33250806d53Smrg 33350806d53Smrg#if 0 33450806d53Smrg if (pI128->Debug) 33550806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SCR %d,%d %d,%d\n", x1, y1, x2, y2); 33650806d53Smrg#endif 33750806d53Smrg 33850806d53Smrg if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; } 33950806d53Smrg if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; } 34050806d53Smrg 34150806d53Smrg pI128->clptl = (x1<<16) | y1; 34250806d53Smrg pI128->clpbr = (x2<<16) | y2; 34350806d53Smrg} 34450806d53Smrg 34550806d53Smrg 34650806d53Smrgstatic void 34750806d53SmrgI128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask, 34850806d53Smrg int nBox, register BoxPtr pBoxI) 34950806d53Smrg{ 35050806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 35150806d53Smrg register int w, h; 35250806d53Smrg 35350806d53Smrg#if 0 35450806d53Smrg if (pI128->Debug) 35550806d53Smrg 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); 35650806d53Smrg#endif 35750806d53Smrg 35850806d53Smrg ENG_PIPELINE_READY(); 35950806d53Smrg 36050806d53Smrg if (planemask != -1) { 36150806d53Smrg if (pI128->bitsPerPixel == 8) { 36250806d53Smrg planemask |= (planemask<<8) | 36350806d53Smrg (planemask<<16) | 36450806d53Smrg (planemask<<24); 36550806d53Smrg } else if (pI128->bitsPerPixel == 16) 36650806d53Smrg planemask |= planemask<<16; 36750806d53Smrg } 36850806d53Smrg 36950806d53Smrg pI128->mem.rbase_a[MASK] = planemask; 37050806d53Smrg pI128->mem.rbase_a[FORE] = fg; 37150806d53Smrg pI128->mem.rbase_a[CMD] = (CS_SOLID<<16) | i128alu[rop] | CO_BITBLT; 37250806d53Smrg pI128->mem.rbase_a[CLPTL] = 0x00000000; 37350806d53Smrg pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047; 37450806d53Smrg 37550806d53Smrg pI128->mem.rbase_a[XY3_DIR] = DIR_LR_TB; 37650806d53Smrg pI128->mem.rbase_a[XY0_SRC] = 0x00000000; 37750806d53Smrg 37850806d53Smrg while (nBox > 0) { 37950806d53Smrg w = pBoxI->x2 - pBoxI->x1; 38050806d53Smrg h = pBoxI->y2 - pBoxI->y1; 38150806d53Smrg if (w > 0 && h > 0) { 38250806d53Smrg pI128->mem.rbase_a[XY2_WH] = (w<<16) | h; MB; 38350806d53Smrg pI128->mem.rbase_a[XY1_DST] = 38450806d53Smrg (pBoxI->x1<<16) | pBoxI->y1; MB; 38550806d53Smrg 38650806d53Smrg ENG_PIPELINE_READY(); 38750806d53Smrg#if 0 38850806d53Smrg if (pI128->Debug) 38950806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FSR x,y %d,%d w,h %d,%d\n", pBoxI->x1, pBoxI->y1, w, h); 39050806d53Smrg#endif 39150806d53Smrg 39250806d53Smrg } 39350806d53Smrg pBoxI++; 39450806d53Smrg nBox--; 39550806d53Smrg } 39650806d53Smrg 39750806d53Smrg ENG_DONE(); 39850806d53Smrg 39950806d53Smrg} 40050806d53Smrg 4017965d9acSmrg#if 0 40250806d53Smrgstatic void 40350806d53SmrgI128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, DDXPointPtr pptSrc, 40450806d53Smrg BoxPtr pbox, int xdir, int ydir, int alu, unsigned planemask) 40550806d53Smrg{ 40650806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 40750806d53Smrg I128SetupForScreenToScreenCopy(pScrn, xdir, ydir, alu, planemask, -1); 40850806d53Smrg for (; nbox; pbox++, pptSrc++, nbox--) 40950806d53Smrg I128SubsequentScreenToScreenCopy(pScrn, pptSrc->x, pptSrc->y, 41050806d53Smrg pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); 41150806d53Smrg ENG_DONE(); 41250806d53Smrg} 4137965d9acSmrg#endif 41450806d53Smrg 41550806d53SmrgBool 41650806d53SmrgI128XaaInit(ScreenPtr pScreen) 41750806d53Smrg{ 41850806d53Smrg XAAInfoRecPtr infoPtr; 41950806d53Smrg ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 42050806d53Smrg I128Ptr pI128 = I128PTR(pScrn); 42150806d53Smrg BoxRec AvailFBArea; 42250806d53Smrg CARD32 buf_ctrl; 42350806d53Smrg int maxlines; 42450806d53Smrg 42550806d53Smrg pI128->XaaInfoRec = infoPtr = XAACreateInfoRec(); 42650806d53Smrg if (!infoPtr) return FALSE; 42750806d53Smrg 42850806d53Smrg infoPtr->Flags = PIXMAP_CACHE | 42950806d53Smrg OFFSCREEN_PIXMAPS | 43050806d53Smrg LINEAR_FRAMEBUFFER ; 43150806d53Smrg 43250806d53Smrg infoPtr->Sync = I128EngineDone; 43350806d53Smrg 43450806d53Smrg /* screen to screen copy */ 43550806d53Smrg infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; 43650806d53Smrg if (pI128->Chipset == PCI_CHIP_I128_T2R) 43750806d53Smrg infoPtr->ScreenToScreenCopyFlags |= ONLY_LEFT_TO_RIGHT_BITBLT; 43850806d53Smrg 43950806d53Smrg infoPtr->SetupForScreenToScreenCopy = I128SetupForScreenToScreenCopy; 44050806d53Smrg infoPtr->SubsequentScreenToScreenCopy = 44150806d53Smrg I128SubsequentScreenToScreenCopy; 44250806d53Smrg 44350806d53Smrg#if 0 44450806d53Smrg /* screen to screen color expansion */ 44550806d53Smrg if (pI128->Chipset == PCI_CHIP_I128_T2R) 44650806d53Smrg infoPtr->ScreenToScreenColorExpandFillFlags |= 44750806d53Smrg ONLY_LEFT_TO_RIGHT_BITBLT; 44850806d53Smrg 44950806d53Smrg infoPtr->SetupForScreenToScreenColorExpandFill = 45050806d53Smrg I128SetupForScreenToScreenColorExpandFill; 45150806d53Smrg infoPtr->SubsequentScreenToScreenColorExpandFill = 45250806d53Smrg I128SubsequentScreenToScreenColorExpandFill; 45350806d53Smrg#endif 45450806d53Smrg 45550806d53Smrg /* solid fills */ 45650806d53Smrg infoPtr->SetupForSolidFill = I128SetupForSolidFill; 45750806d53Smrg infoPtr->SubsequentSolidFillRect = I128SubsequentSolidFillRect; 45850806d53Smrg 45950806d53Smrg infoPtr->FillSolidRects = I128FillSolidRects; 46050806d53Smrg 46150806d53Smrg /* solid lines */ 46250806d53Smrg infoPtr->SubsequentSolidTwoPointLine = I128SubsequentSolidTwoPointLine; 46350806d53Smrg 46450806d53Smrg /* clipping */ 46550806d53Smrg infoPtr->ClippingFlags = HARDWARE_CLIP_LINE; 46650806d53Smrg infoPtr->SetClippingRectangle = I128SetClippingRectangle; 46750806d53Smrg 46850806d53Smrg infoPtr->PolyFillRectSolidFlags = 0; 46950806d53Smrg 47050806d53Smrg maxlines = ((pI128->MemorySize * 1024) - 1024) / 47150806d53Smrg (pScrn->displayWidth * pI128->bitsPerPixel / 8); 47250806d53Smrg AvailFBArea.x1 = 0; 47350806d53Smrg AvailFBArea.x2 = pI128->displayWidth; 47450806d53Smrg AvailFBArea.y1 = 0; 47550806d53Smrg AvailFBArea.y2 = maxlines; 47650806d53Smrg xf86InitFBManager(pScreen, &AvailFBArea); 47750806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, 47850806d53Smrg "Using %d lines for offscreen memory\n", 47950806d53Smrg maxlines - pScrn->virtualY); 48050806d53Smrg 48150806d53Smrg switch (pI128->bitsPerPixel) { 48250806d53Smrg case 8: buf_ctrl = BC_PSIZ_8B; break; 48350806d53Smrg case 16: buf_ctrl = BC_PSIZ_16B; break; 48450806d53Smrg case 24: 48550806d53Smrg case 32: buf_ctrl = BC_PSIZ_32B; break; 48650806d53Smrg default: buf_ctrl = 0; break; /* error */ 48750806d53Smrg } 48850806d53Smrg if (pI128->Chipset == PCI_CHIP_I128_T2R) { 48950806d53Smrg if (pI128->MemoryType == I128_MEMORY_SGRAM) 49050806d53Smrg buf_ctrl |= BC_MDM_PLN; 49150806d53Smrg else 49250806d53Smrg buf_ctrl |= BC_BLK_ENA; 49350806d53Smrg } 49450806d53Smrg pI128->mem.rbase_a[BUF_CTRL] = buf_ctrl; 49550806d53Smrg 49650806d53Smrg pI128->mem.rbase_a[DE_PGE] = 0x00; 49750806d53Smrg pI128->mem.rbase_a[DE_SORG] = pI128->displayOffset; 49850806d53Smrg pI128->mem.rbase_a[DE_DORG] = pI128->displayOffset; 49950806d53Smrg pI128->mem.rbase_a[DE_MSRC] = 0x00; 50050806d53Smrg pI128->mem.rbase_a[DE_WKEY] = 0x00; 50150806d53Smrg pI128->mem.rbase_a[DE_SPTCH] = pI128->mem.rbase_g[DB_PTCH]; 50250806d53Smrg pI128->mem.rbase_a[DE_DPTCH] = pI128->mem.rbase_g[DB_PTCH]; 50350806d53Smrg if (pI128->Chipset == PCI_CHIP_I128_T2R4) 50450806d53Smrg pI128->mem.rbase_a[DE_ZPTCH] = pI128->mem.rbase_g[DB_PTCH]; 50550806d53Smrg pI128->mem.rbase_a[RMSK] = 0x00000000; 50650806d53Smrg pI128->mem.rbase_a[XY4_ZM] = ZOOM_NONE; 50750806d53Smrg pI128->mem.rbase_a[LPAT] = 0xffffffff; /* for lines */ 50850806d53Smrg pI128->mem.rbase_a[PCTRL] = 0x00000000; /* for lines */ 50950806d53Smrg pI128->mem.rbase_a[CLPTL] = 0x00000000; 51050806d53Smrg pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ; 51150806d53Smrg pI128->mem.rbase_a[ACNTRL] = 0x00000000; 51250806d53Smrg pI128->mem.rbase_a[INTM] = 0x03; 51350806d53Smrg 51450806d53Smrg if (pI128->Debug) { 51550806d53Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I128XaaInit done\n"); 51650806d53Smrg I128DumpActiveRegisters(pScrn); 51750806d53Smrg } 51850806d53Smrg 51950806d53Smrg return(XAAInit(pScreen, infoPtr)); 52050806d53Smrg} 521