1/* 2 * XGI hardware cursor handling 3 * Definitions 4 * 5 * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1) Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2) Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3) The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * Author: Thomas Winischhofer <thomas@winischhofer.net> 30 * 31 * Idea based on code by Can-Ru Yeou, XGI Inc. 32 * 33 */ 34#include "xgi_regs.h" 35#define CS(x) (0x8500 + (x << 2)) 36 37/* 300 series, CRT1 */ 38 39/* 80000000 = RGB(1) - MONO(0) 40 * 40000000 = enable(1) - disable(0) 41 * 20000000 = 32(1) / 16(1) bit RGB 42 * 10000000 = "ghost"(1) - [other effect](0) 43 */ 44 45#define xgiG1CRT1_DisableHWCursor()\ 46 {\ 47 XGIMMIOLONG(0x8500) &= BE_SWAP32( ~(1<<30)) ; \ 48 } 49 50#define xgiG1CRT1_SetCursorBGColor(color)\ 51 {\ 52 XGIMMIOLONG(0x8504) =BE_SWAP32(color) ;\ 53 } 54 55#define xgiG1CRT1_SetCursorFGColor(color)\ 56 {\ 57 XGIMMIOLONG(0x8508) = BE_SWAP32(color) ;\ 58 } 59 60#define xgiG1CRT1_SetCursorPositionX(x,preset)\ 61 {\ 62 XGIMMIOLONG(0x850C) = BE_SWAP32((x) | ((preset)<<16));\ 63 } 64 65#define xgiG1CRT1_SetCursorPositionY(y,preset)\ 66 {\ 67 XGIMMIOLONG(0x8510) =BE_SWAP32((y) | ((preset)<<16));\ 68 } 69 70/* Jill, read MMIO need swap, 2006/6/22*/ 71#define xgiG2CRT1_SetCursorAddressPattern(address,pat_id) \ 72{\ 73 unsigned long ulTemp ;\ 74 ulTemp = BE_SWAP32(XGIMMIOLONG(0x8500)) ;\ 75 ulTemp &= 0xF0FC0000 ;\ 76 ulTemp |= (address) & 0x3FFFF ;\ 77 ulTemp |= ((pat_id)&0xF)<<24 ;\ 78 XGIMMIOLONG(0x8500) = BE_SWAP32(ulTemp) ;\ 79} 80 81/* Jill, read MMIO need swap, 2006/6/22*/ 82#define xgiG2CRT2_SetCursorAddressPattern(address,pat_id) \ 83{\ 84 unsigned long ulTemp ;\ 85 ulTemp = XGIMMIOLONG(0x8520) ;\ 86 ulTemp = BE_SWAP32(ulTemp) ;\ 87 ulTemp &= 0xF0FC0000 ;\ 88 ulTemp |= (address) & 0x3FFFF ;\ 89 ulTemp |= ((pat_id)&0xF)<<24 ;\ 90 XGIMMIOLONG(0x8520) =BE_SWAP32(ulTemp) ;\ 91} 92 93/* Jill, read MMIO need swap, 2006/6/22*/ 94#define xgiG2CRT1_SetCursorAddress(address)\ 95 {\ 96 unsigned long ulTemp ;\ 97 ulTemp = XGIMMIOLONG(0x8500) ;\ 98 ulTemp = BE_SWAP32(ulTemp) ;\ 99 ulTemp &= 0xFFFC0000 ;\ 100 ulTemp |= (address) & 0x3FFFF ;\ 101 XGIMMIOLONG(0x8500) = BE_SWAP32(ulTemp) ;\ 102 } 103 104/* Jill, read MMIO need swap, 2006/6/22*/ 105#define xgiG2CRT1_SetCursorPatternSelect(pat_id)\ 106 {\ 107 unsigned long ulTemp ;\ 108 ulTemp = XGIMMIOLONG(0x8500) ;\ 109 ulTemp = BE_SWAP32(ulTemp) ;\ 110 ulTemp &= 0xF0FFFFFF ;\ 111 ulTemp |= ((pat_id)&0xF)<<24 ;\ 112 XGIMMIOLONG(0x8500) = BE_SWAP32(ulTemp) ;\ 113 } 114 115#define xgiG1CRT2_DisableHWCursor()\ 116 {\ 117 XGIMMIOLONG(0x8520) &=BE_SWAP32(~(1<<30));\ 118 } 119 120#define xgiG1CRT2_SetCursorBGColor(color)\ 121 {\ 122 XGIMMIOLONG(0x8524) = BE_SWAP32(color) ;\ 123 } 124 125#define xgiG1CRT2_SetCursorFGColor(color)\ 126 {\ 127 XGIMMIOLONG(0x8528) = BE_SWAP32(color) ;\ 128 } 129 130#define xgiG1CRT2_SetCursorPositionX(x,preset)\ 131 {\ 132 XGIMMIOLONG(0x852C) = BE_SWAP32((x) | ((preset)<<16));\ 133 } 134 135#define xgiG1CRT2_SetCursorPositionY(y,preset)\ 136 {\ 137 XGIMMIOLONG(0x8530) = BE_SWAP32((y) | ((preset)<<16));\ 138 } 139 140/* Jill, read MMIO need swap, 2006/6/22*/ 141#define xgiG1CRT2_SetCursorAddress(address)\ 142 {\ 143 unsigned long ulTemp ;\ 144 ulTemp = XGIMMIOLONG(0x8520) ;\ 145 ulTemp = BE_SWAP32(ulTemp) ;\ 146 ulTemp &= 0xFFFC0000 ;\ 147 ulTemp |= (address) & 0x3FFFF ;\ 148 XGIMMIOLONG(0x8520) = BE_SWAP32(ulTemp) ;\ 149 } 150 151/* Jill, read MMIO need swap, 2006/6/22*/ 152#define xgiG1CRT2_SetCursorPatternSelect(pat_id)\ 153 {\ 154 unsigned long ulTemp ;\ 155 ulTemp = XGIMMIOLONG(0x8520) ;\ 156 ulTemp = BE_SWAP32(ulTemp) ;\ 157 ulTemp &= 0xF0FFFFFF ;\ 158 ulTemp |= ((pat_id)&0xF) << 24 ;\ 159 XGIMMIOLONG(0x8520) = BE_SWAP32(ulTemp) ;\ 160 } 161 162/* Jill, read MMIO need swap, 2006/6/22*/ 163#define xgiG2CRT1_EnableHWCursor(cursor_base,pat_id)\ 164 {\ 165 CARD32 ulTemp ;\ 166 ulTemp = XGIMMIOLONG(0x8500) ;\ 167 ulTemp = BE_SWAP32(ulTemp) ;\ 168 ulTemp &= 0x00FC0000 ;\ 169 ulTemp |= 1<<30 ;\ 170 ulTemp |= (cursor_base) & 0x3FFFF ;\ 171 ulTemp |= ((pat_id)&0xF)<<24 ;\ 172 XGIMMIOLONG(0x8500) = BE_SWAP32(ulTemp) ;\ 173 } 174 175#define xgiG2CRT1_DisableHWCursor()\ 176 {\ 177 XGIMMIOLONG(0x8500) &= BE_SWAP32(~(1<<30));\ 178 } 179 180/* Jill, read MMIO need swap, 2006/6/22*/ 181#define xgiG2CRT2_EnableHWCursor(cursor_base,pat_id)\ 182 {\ 183 CARD32 ulTemp ;\ 184 ulTemp = XGIMMIOLONG(0x8520) ;\ 185 ulTemp = BE_SWAP32(ulTemp) ;\ 186 ulTemp &= 0x00FC0000 ;\ 187 ulTemp |= 1<<30 ;\ 188 ulTemp |= (cursor_base) & 0x3FFFF ;\ 189 ulTemp |= ((pat_id)&0xF)<<24 ;\ 190 XGIMMIOLONG(0x8520) =BE_SWAP32(ulTemp) ;\ 191 } 192 193/* Jong 09/19/2007; added for ??? */ 194#define xgiG2CRT1_EnableARGBHWCursor(cursor_base,pat_id)\ 195 {\ 196 CARD32 ulTemp ;\ 197 ulTemp = XGIMMIOLONG(0x8500) ;\ 198 ulTemp &= 0x00FC0000 ;\ 199 ulTemp |= 0xE<<28 ;\ 200 ulTemp |= (cursor_base) & 0x3FFFF ;\ 201 ulTemp |= ((pat_id)&0xF)<<24 ;\ 202 XGIMMIOLONG(0x8500) = ulTemp ;\ 203 } 204 205#define xgiG2CRT2_EnableARGBHWCursor(cursor_base,pat_id)\ 206 {\ 207 CARD32 ulTemp ;\ 208 ulTemp = XGIMMIOLONG(0x8500) ;\ 209 ulTemp &= 0x00FC0000 ;\ 210 ulTemp |= 0xE<<28 ;\ 211 ulTemp |= (cursor_base) & 0x3FFFF ;\ 212 ulTemp |= ((pat_id)&0xF)<<24 ;\ 213 XGIMMIOLONG(0x8500) = ulTemp ;\ 214 } 215 216/*******************************************************************/ 217