cg6_cursor.c revision 5eefee25
15eefee25Smacallan/* 25eefee25Smacallan * Hardware cursor support for GX or Turbo GX 35eefee25Smacallan * 45eefee25Smacallan * Copyright 2000 by Jakub Jelinek <jakub@redhat.com>. 55eefee25Smacallan * 65eefee25Smacallan * Permission to use, copy, modify, distribute, and sell this software 75eefee25Smacallan * and its documentation for any purpose is hereby granted without 85eefee25Smacallan * fee, provided that the above copyright notice appear in all copies 95eefee25Smacallan * and that both that copyright notice and this permission notice 105eefee25Smacallan * appear in supporting documentation, and that the name of Jakub 115eefee25Smacallan * Jelinek not be used in advertising or publicity pertaining to 125eefee25Smacallan * distribution of the software without specific, written prior 135eefee25Smacallan * permission. Jakub Jelinek makes no representations about the 145eefee25Smacallan * suitability of this software for any purpose. It is provided "as 155eefee25Smacallan * is" without express or implied warranty. 165eefee25Smacallan * 175eefee25Smacallan * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 185eefee25Smacallan * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 195eefee25Smacallan * FITNESS, IN NO EVENT SHALL JAKUB JELINEK BE LIABLE FOR ANY 205eefee25Smacallan * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 215eefee25Smacallan * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 225eefee25Smacallan * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 235eefee25Smacallan * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 245eefee25Smacallan * SOFTWARE. 255eefee25Smacallan */ 265eefee25Smacallan/* $XFree86:$ */ 275eefee25Smacallan 285eefee25Smacallan#ifdef HAVE_CONFIG_H 295eefee25Smacallan#include "config.h" 305eefee25Smacallan#endif 315eefee25Smacallan 325eefee25Smacallan#include "cg6.h" 335eefee25Smacallan 345eefee25Smacallanstatic void CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); 355eefee25Smacallanstatic void CG6ShowCursor(ScrnInfoPtr pScrn); 365eefee25Smacallanstatic void CG6HideCursor(ScrnInfoPtr pScrn); 375eefee25Smacallanstatic void CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y); 385eefee25Smacallanstatic void CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); 395eefee25Smacallan 405eefee25Smacallanstatic void 415eefee25SmacallanCG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) 425eefee25Smacallan{ 435eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 445eefee25Smacallan int i; 455eefee25Smacallan unsigned int *data = (unsigned int *)src; 465eefee25Smacallan 475eefee25Smacallan for (i = 0; i < 32; i++) 485eefee25Smacallan pCg6->thc->thc_cursmask[i] = *data++; 495eefee25Smacallan for (i = 0; i < 32; i++) 505eefee25Smacallan pCg6->thc->thc_cursbits[i] = *data++; 515eefee25Smacallan} 525eefee25Smacallan 535eefee25Smacallanstatic void 545eefee25SmacallanCG6ShowCursor(ScrnInfoPtr pScrn) 555eefee25Smacallan{ 565eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 575eefee25Smacallan 585eefee25Smacallan pCg6->thc->thc_cursxy = pCg6->CursorXY; 595eefee25Smacallan pCg6->CursorEnabled = TRUE; 605eefee25Smacallan} 615eefee25Smacallan 625eefee25Smacallanstatic void 635eefee25SmacallanCG6HideCursor(ScrnInfoPtr pScrn) 645eefee25Smacallan{ 655eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 665eefee25Smacallan 675eefee25Smacallan pCg6->thc->thc_cursxy = ((65536 - 32) << 16) | (65536 - 32); 685eefee25Smacallan pCg6->CursorEnabled = FALSE; 695eefee25Smacallan} 705eefee25Smacallan 715eefee25Smacallanstatic void 725eefee25SmacallanCG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) 735eefee25Smacallan{ 745eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 755eefee25Smacallan 765eefee25Smacallan pCg6->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff); 775eefee25Smacallan if (pCg6->CursorEnabled) 785eefee25Smacallan pCg6->thc->thc_cursxy = pCg6->CursorXY; 795eefee25Smacallan} 805eefee25Smacallan 815eefee25Smacallanstatic void 825eefee25SmacallanCG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) 835eefee25Smacallan{ 845eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 855eefee25Smacallan 865eefee25Smacallan if (bg != pCg6->CursorBg || fg != pCg6->CursorFg) { 875eefee25Smacallan xf86SbusSetOsHwCursorCmap(pCg6->psdp, bg, fg); 885eefee25Smacallan pCg6->CursorBg = bg; 895eefee25Smacallan pCg6->CursorFg = fg; 905eefee25Smacallan } 915eefee25Smacallan} 925eefee25Smacallan 935eefee25SmacallanBool 945eefee25SmacallanCG6HWCursorInit(ScreenPtr pScreen) 955eefee25Smacallan{ 965eefee25Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 975eefee25Smacallan Cg6Ptr pCg6; 985eefee25Smacallan xf86CursorInfoPtr infoPtr; 995eefee25Smacallan 1005eefee25Smacallan pCg6 = GET_CG6_FROM_SCRN(pScrn); 1015eefee25Smacallan pCg6->CursorXY = 0; 1025eefee25Smacallan pCg6->CursorBg = pCg6->CursorFg = 0; 1035eefee25Smacallan pCg6->CursorEnabled = FALSE; 1045eefee25Smacallan 1055eefee25Smacallan infoPtr = xf86CreateCursorInfoRec(); 1065eefee25Smacallan if(!infoPtr) return FALSE; 1075eefee25Smacallan 1085eefee25Smacallan pCg6->CursorInfoRec = infoPtr; 1095eefee25Smacallan 1105eefee25Smacallan infoPtr->MaxWidth = 32; 1115eefee25Smacallan infoPtr->MaxHeight = 32; 1125eefee25Smacallan infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | 1135eefee25Smacallan HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | 1145eefee25Smacallan HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED | 1155eefee25Smacallan HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; 1165eefee25Smacallan 1175eefee25Smacallan infoPtr->SetCursorColors = CG6SetCursorColors; 1185eefee25Smacallan infoPtr->SetCursorPosition = CG6SetCursorPosition; 1195eefee25Smacallan infoPtr->LoadCursorImage = CG6LoadCursorImage; 1205eefee25Smacallan infoPtr->HideCursor = CG6HideCursor; 1215eefee25Smacallan infoPtr->ShowCursor = CG6ShowCursor; 1225eefee25Smacallan infoPtr->UseHWCursor = NULL; 1235eefee25Smacallan 1245eefee25Smacallan return xf86InitCursor(pScreen, infoPtr); 1255eefee25Smacallan} 126