1/* 2 * 2D acceleration for 5597/5598 and 6326 3 * Definitions for the SIS engine communication 4 * 5 * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. 6 * Parts Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria. 7 * 8 * Licensed under the following terms: 9 * 10 * Permission to use, copy, modify, distribute, and sell this software and its 11 * documentation for any purpose is hereby granted without fee, provided that 12 * the above copyright notice appears in all copies and that both that copyright 13 * notice and this permission notice appear in supporting documentation, and 14 * and that the name of the copyright holder not be used in advertising 15 * or publicity pertaining to distribution of the software without specific, 16 * written prior permission. The copyright holder makes no representations 17 * about the suitability of this software for any purpose. It is provided 18 * "as is" without expressed or implied warranty. 19 * 20 * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 21 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 22 * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR 23 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 24 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 25 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 26 * PERFORMANCE OF THIS SOFTWARE. 27 * 28 * Authors: Alan Hourihane <alanh@fairlite.demon.co.uk>, 29 * Mike Chapman <mike@paranoia.com>, 30 * Juanjo Santamarta <santamarta@ctv.es>, 31 * Mitani Hiroshi <hmitani@drl.mei.co.jp>, 32 * David Thomas <davtom@dream.org.uk>, 33 * Thomas Winischhofer <thomas@winischhofer.net>. 34 */ 35 36 37/* Definitions for the SIS engine communication. ------------------------------------ */ 38 39/* For pre-530 chipsets only!!! */ 40 41/* Engine Registers for 1st generation engines (5597/5598/6326) */ 42const int sisReg32MMIO[] = { 43 0x8280,0x8284,0x8288,0x828C,0x8290,0x8294, 44 0x8298,0x829C,0x82A0,0x82A4,0x82A8,0x82AC 45}; 46 47#define BR(x) sisReg32MMIO[x] 48 49/* These are done using Memory Mapped IO, of the registers */ 50/* 51 * Modified for Sis by Xavier Ducoin (xavier@rd.lectra.fr) 52 * 53 */ 54 55/* Command Reg 0 (0x82aa, [15:0]) */ 56#define sisSRCBG 0x0000 /* source select */ 57#define sisSRCFG 0x0001 58#define sisSRCVIDEO 0x0002 59#define sisSRCSYSTEM 0x0003 60 61#define sisPATFG 0x0004 /* pattern select */ 62#define sisPATREG 0x0008 63#define sisPATBG 0x0000 64 65#define sisLEFT2RIGHT 0x0010 /* Direction select */ 66#define sisRIGHT2LEFT 0x0000 67#define sisTOP2BOTTOM 0x0020 68#define sisBOTTOM2TOP 0x0000 69#define sisXINCREASE sisLEFT2RIGHT 70#define sisYINCREASE sisTOP2BOTTOM 71 72#define sisCLIPENABL 0x0040 /* Clipping select */ 73#define sisCLIPINTRN 0x0080 74#define sisCLIPEXTRN 0x0000 75 76#define sisCMDBLT 0x0000 /* Command select */ 77#define sisCMDBLTMSK 0x0100 78#define sisCMDCOLEXP 0x0200 79#define sisCMDLINE 0x0300 80#define sisFLGECOLEXP 0x2000 81#define sisCMDECOLEXP (sisCMDCOLEXP | sisFLGECOLEXP) 82 83#define sisLASTPIX 0x0800 /* Line parameters */ 84#define sisXMAJOR 0x0400 85 86 87/* Macros to do useful things with the SIS BitBLT engine */ 88 89#define sisBLTSync \ 90 while(SIS_MMIO_IN16(pSiS->IOBase, BR(10) + 2) & 0x4000) {} 91 92/* According to SiS 6326 2D programming guide, 16 bits position at */ 93/* 0x82A8 returns queue free. But this don't work, so don't wait */ 94/* anything when turbo-queue is enabled. If there are frequent syncs */ 95/* this should work. But not for xaa_benchmark :-( */ 96 97/* TW: Bit 16 only applies to the hardware queue, not the software 98 * (=turbo) queue. 99 */ 100 101#define sisBLTWAIT \ 102 if(!pSiS->TurboQueue) { \ 103 while(SIS_MMIO_IN16(pSiS->IOBase, BR(10) + 2) & 0x4000) {} \ 104 } else { \ 105 sisBLTSync \ 106 } 107 108#define sisSETPATREG() \ 109 ((UChar *)(pSiS->IOBase + BR(11))) 110 111#define sisSETPATREGL() \ 112 ((ULong *)(pSiS->IOBase + BR(11))) 113 114/* trigger command */ 115#define sisSETCMD(op) \ 116 { \ 117 ULong temp; \ 118 SIS_MMIO_OUT16(pSiS->IOBase, BR(10) + 2, op); \ 119 temp = SIS_MMIO_IN32(pSiS->IOBase, BR(10)); \ 120 (void)temp; \ 121 } 122 123/* set foreground color and fg ROP */ 124#define sisSETFGROPCOL(rop, color) \ 125 SIS_MMIO_OUT32(pSiS->IOBase, BR(4), ((rop << 24) | (color & 0xFFFFFF))); 126 127/* set background color and bg ROP */ 128#define sisSETBGROPCOL(rop, color) \ 129 SIS_MMIO_OUT32(pSiS->IOBase, BR(5), ((rop << 24) | (color & 0xFFFFFF))); 130 131/* background color */ 132#define sisSETBGCOLOR(bgColor) \ 133 SIS_MMIO_OUT32(pSiS->IOBase, BR(5), (bgColor)); 134 135/* foreground color */ 136#define sisSETFGCOLOR(fgColor) \ 137 SIS_MMIO_OUT32(pSiS->IOBase, BR(4), (fgcolor)); 138 139/* ROP */ 140#define sisSETROPFG(op) \ 141 SIS_MMIO_OUT8(pSiS->IOBase, BR(4) + 3, op); 142 143#define sisSETROPBG(op) \ 144 SIS_MMIO_OUT8(pSiS->IOBase, BR(5) + 3, op); 145 146#define sisSETROP(op) \ 147 sisSETROPFG(op); sisSETROPBG(op); 148 149/* source and dest address */ 150#define sisSETSRCADDR(srcAddr) \ 151 SIS_MMIO_OUT32(pSiS->IOBase, BR(0), (srcAddr & 0x3FFFFFL)); 152 153#define sisSETDSTADDR(dstAddr) \ 154 SIS_MMIO_OUT32(pSiS->IOBase, BR(1), (dstAddr & 0x3FFFFFL)); 155 156/* pitch */ 157#define sisSETPITCH(srcPitch,dstPitch) \ 158 SIS_MMIO_OUT32(pSiS->IOBase, BR(2), ((((dstPitch) & 0xFFFF) << 16) | ((srcPitch) & 0xFFFF))); 159 160#define sisSETSRCPITCH(srcPitch) \ 161 SIS_MMIO_OUT16(pSiS->IOBase, BR(2), ((srcPitch) & 0xFFFF)); 162 163#define sisSETDSTPITCH(dstPitch) \ 164 SIS_MMIO_OUT16(pSiS->IOBase, BR(2) + 2, ((dstPitch) & 0xFFFF)); 165 166/* Height and width 167 * According to SIS 2D Engine Programming Guide 168 * height -1, width - 1 independant of Bpp 169 */ 170#define sisSETHEIGHTWIDTH(Height, Width) \ 171 SIS_MMIO_OUT32(pSiS->IOBase, BR(3), ((((Height) & 0xFFFF) << 16) | ((Width) & 0xFFFF))); 172 173/* Clipping */ 174#define sisSETCLIPTOP(x, y) \ 175 SIS_MMIO_OUT32(pSiS->IOBase, BR(8), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))); 176 177#define sisSETCLIPBOTTOM(x, y) \ 178 SIS_MMIO_OUT32(pSiS->IOBase, BR(9), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))); 179 180/* Line drawing */ 181#define sisSETXStart(XStart) \ 182 SIS_MMIO_OUT32(pSiS->IOBase, BR(0), ((XStart) & 0xFFFF)); 183 184#define sisSETYStart(YStart) \ 185 SIS_MMIO_OUT32(pSiS->IOBase, BR(1), ((YStart) & 0xFFFF)); 186 187#define sisSETLineMajorCount(MajorAxisCount) \ 188 SIS_MMIO_OUT32(pSiS->IOBase, BR(3), ((MajorAxisCount) & 0xFFFF)); 189 190#define sisSETLineSteps(K1,K2) \ 191 SIS_MMIO_OUT32(pSiS->IOBase, BR(6), ((((K1) & 0xFFFF) << 16) | ((K2) & 0xFFFF))); 192 193#define sisSETLineErrorTerm(ErrorTerm) \ 194 SIS_MMIO_OUT16(pSiS->IOBase, BR(7), (ErrorTerm)); 195