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