1c35d236eSmrg/* 2c35d236eSmrg * Copyright 1998 by Alan Hourihane, Wigan, England. 3c35d236eSmrg * 4c35d236eSmrg * Permission to use, copy, modify, distribute, and sell this software and its 5c35d236eSmrg * documentation for any purpose is hereby granted without fee, provided that 6c35d236eSmrg * the above copyright notice appear in all copies and that both that 7c35d236eSmrg * copyright notice and this permission notice appear in supporting 8c35d236eSmrg * documentation, and that the name of Alan Hourihane not be used in 9c35d236eSmrg * advertising or publicity pertaining to distribution of the software without 10c35d236eSmrg * specific, written prior permission. Alan Hourihane makes no representations 11c35d236eSmrg * about the suitability of this software for any purpose. It is provided 12c35d236eSmrg * "as is" without express or implied warranty. 13c35d236eSmrg * 14c35d236eSmrg * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15c35d236eSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16c35d236eSmrg * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17c35d236eSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18c35d236eSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19c35d236eSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20c35d236eSmrg * PERFORMANCE OF THIS SOFTWARE. 21c35d236eSmrg * 22c35d236eSmrg * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> 23c35d236eSmrg * 24c35d236eSmrg * glintOutIBMRGBIndReg() and glintInIBMRGBIndReg() are used to access 25c35d236eSmrg * the indirect IBM RAMDAC registers only. 26c35d236eSmrg */ 27c35d236eSmrg 28c35d236eSmrg#ifdef HAVE_CONFIG_H 29c35d236eSmrg#include "config.h" 30c35d236eSmrg#endif 31c35d236eSmrg 32c35d236eSmrg#include "xf86.h" 33c35d236eSmrg#include "xf86_OSproc.h" 34c35d236eSmrg 35c35d236eSmrg#include "xf86Pci.h" 36c35d236eSmrg 37c35d236eSmrg#include "IBM.h" 38c35d236eSmrg#include "glint_regs.h" 39c35d236eSmrg#include "glint.h" 40c35d236eSmrg 41c35d236eSmrg#define IBMRGB_WRITE_ADDR 0x4000 42c35d236eSmrg#define IBMRGB_RAMDAC_DATA 0x4008 43c35d236eSmrg#define IBMRGB_PIXEL_MASK 0x4010 44c35d236eSmrg#define IBMRGB_READ_ADDR 0x4018 45c35d236eSmrg#define IBMRGB_INDEX_LOW 0x4020 46c35d236eSmrg#define IBMRGB_INDEX_HIGH 0x4028 47c35d236eSmrg#define IBMRGB_INDEX_DATA 0x4030 48c35d236eSmrg#define IBMRGB_INDEX_CONTROL 0x4038 49c35d236eSmrg 50c35d236eSmrgvoid 51c35d236eSmrgglintOutIBMRGBIndReg(ScrnInfoPtr pScrn, 52c35d236eSmrg CARD32 reg, unsigned char mask, unsigned char data) 53c35d236eSmrg{ 54c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 55c35d236eSmrg unsigned char tmp = 0x00; 56c35d236eSmrg 57c35d236eSmrg GLINT_SLOW_WRITE_REG((reg>>8) & 0xff, IBMRGB_INDEX_HIGH); 58c35d236eSmrg GLINT_SLOW_WRITE_REG (reg & 0xFF, IBMRGB_INDEX_LOW); 59c35d236eSmrg 60c35d236eSmrg if (mask != 0x00) 61c35d236eSmrg tmp = GLINT_READ_REG (IBMRGB_INDEX_DATA) & mask; 62c35d236eSmrg 63c35d236eSmrg GLINT_SLOW_WRITE_REG (tmp | data, IBMRGB_INDEX_DATA); 64c35d236eSmrg} 65c35d236eSmrg 66c35d236eSmrgunsigned char 67c35d236eSmrgglintInIBMRGBIndReg (ScrnInfoPtr pScrn, CARD32 reg) 68c35d236eSmrg{ 69c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 70c35d236eSmrg unsigned char ret; 71c35d236eSmrg 72c35d236eSmrg GLINT_SLOW_WRITE_REG(reg & 0xFF, IBMRGB_INDEX_LOW); 73c35d236eSmrg GLINT_SLOW_WRITE_REG((reg>>8) & 0xff, IBMRGB_INDEX_HIGH); 74c35d236eSmrg ret = GLINT_READ_REG(IBMRGB_INDEX_DATA); 75c35d236eSmrg return (ret); 76c35d236eSmrg} 77c35d236eSmrg 78c35d236eSmrgvoid 79c35d236eSmrgglintIBMWriteAddress (ScrnInfoPtr pScrn, CARD32 index) 80c35d236eSmrg{ 81c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 82c35d236eSmrg 83c35d236eSmrg GLINT_SLOW_WRITE_REG(index, IBMRGB_WRITE_ADDR); 84c35d236eSmrg} 85c35d236eSmrg 86c35d236eSmrgvoid 87c35d236eSmrgglintIBMWriteData (ScrnInfoPtr pScrn, unsigned char data) 88c35d236eSmrg{ 89c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 90c35d236eSmrg 91c35d236eSmrg GLINT_SLOW_WRITE_REG(data, IBMRGB_RAMDAC_DATA); 92c35d236eSmrg} 93c35d236eSmrg 94c35d236eSmrgvoid 95c35d236eSmrgglintIBMReadAddress (ScrnInfoPtr pScrn, CARD32 index) 96c35d236eSmrg{ 97c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 98c35d236eSmrg 99c35d236eSmrg GLINT_SLOW_WRITE_REG(0xFF, IBMRGB_PIXEL_MASK); 100c35d236eSmrg GLINT_SLOW_WRITE_REG(index, IBMRGB_READ_ADDR); 101c35d236eSmrg} 102c35d236eSmrg 103c35d236eSmrgunsigned char 104c35d236eSmrgglintIBMReadData (ScrnInfoPtr pScrn) 105c35d236eSmrg{ 106c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 107c35d236eSmrg 108c35d236eSmrg return(GLINT_READ_REG(IBMRGB_RAMDAC_DATA)); 109c35d236eSmrg} 110c35d236eSmrg 111c35d236eSmrgBool 112c35d236eSmrgglintIBMHWCursorInit(ScreenPtr pScreen) 113c35d236eSmrg{ 1141fb744b4Smrg ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 115c35d236eSmrg GLINTPtr pGlint = GLINTPTR(pScrn); 116c35d236eSmrg xf86CursorInfoPtr infoPtr; 117c35d236eSmrg 118c35d236eSmrg infoPtr = xf86CreateCursorInfoRec(); 119c35d236eSmrg if(!infoPtr) return FALSE; 120c35d236eSmrg 121c35d236eSmrg pGlint->CursorInfoRec = infoPtr; 122c35d236eSmrg 123c35d236eSmrg (*pGlint->RamDac->HWCursorInit)(infoPtr); 124c35d236eSmrg 125c35d236eSmrg return(xf86InitCursor(pScreen, infoPtr)); 126c35d236eSmrg} 127