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