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 275eefee25Smacallan#ifdef HAVE_CONFIG_H 285eefee25Smacallan#include "config.h" 295eefee25Smacallan#endif 305eefee25Smacallan 315eefee25Smacallan#include "cg6.h" 325eefee25Smacallan 335eefee25Smacallanstatic void CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); 345eefee25Smacallanstatic void CG6ShowCursor(ScrnInfoPtr pScrn); 355eefee25Smacallanstatic void CG6HideCursor(ScrnInfoPtr pScrn); 365eefee25Smacallanstatic void CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y); 375eefee25Smacallanstatic void CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); 385eefee25Smacallan 395eefee25Smacallanstatic void 405eefee25SmacallanCG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) 415eefee25Smacallan{ 425eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 435eefee25Smacallan int i; 445eefee25Smacallan unsigned int *data = (unsigned int *)src; 455eefee25Smacallan 465eefee25Smacallan for (i = 0; i < 32; i++) 475eefee25Smacallan pCg6->thc->thc_cursmask[i] = *data++; 485eefee25Smacallan for (i = 0; i < 32; i++) 495eefee25Smacallan pCg6->thc->thc_cursbits[i] = *data++; 505eefee25Smacallan} 515eefee25Smacallan 525eefee25Smacallanstatic void 535eefee25SmacallanCG6ShowCursor(ScrnInfoPtr pScrn) 545eefee25Smacallan{ 555eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 565eefee25Smacallan 575eefee25Smacallan pCg6->thc->thc_cursxy = pCg6->CursorXY; 585eefee25Smacallan pCg6->CursorEnabled = TRUE; 595eefee25Smacallan} 605eefee25Smacallan 615eefee25Smacallanstatic void 625eefee25SmacallanCG6HideCursor(ScrnInfoPtr pScrn) 635eefee25Smacallan{ 645eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 655eefee25Smacallan 665eefee25Smacallan pCg6->thc->thc_cursxy = ((65536 - 32) << 16) | (65536 - 32); 675eefee25Smacallan pCg6->CursorEnabled = FALSE; 685eefee25Smacallan} 695eefee25Smacallan 705eefee25Smacallanstatic void 715eefee25SmacallanCG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) 725eefee25Smacallan{ 735eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 745eefee25Smacallan 755eefee25Smacallan pCg6->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff); 765eefee25Smacallan if (pCg6->CursorEnabled) 775eefee25Smacallan pCg6->thc->thc_cursxy = pCg6->CursorXY; 785eefee25Smacallan} 795eefee25Smacallan 805eefee25Smacallanstatic void 815eefee25SmacallanCG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) 825eefee25Smacallan{ 835eefee25Smacallan Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 845eefee25Smacallan 855eefee25Smacallan if (bg != pCg6->CursorBg || fg != pCg6->CursorFg) { 865eefee25Smacallan xf86SbusSetOsHwCursorCmap(pCg6->psdp, bg, fg); 875eefee25Smacallan pCg6->CursorBg = bg; 885eefee25Smacallan pCg6->CursorFg = fg; 895eefee25Smacallan } 905eefee25Smacallan} 915eefee25Smacallan 925eefee25SmacallanBool 935eefee25SmacallanCG6HWCursorInit(ScreenPtr pScreen) 945eefee25Smacallan{ 955eefee25Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 965eefee25Smacallan Cg6Ptr pCg6; 975eefee25Smacallan xf86CursorInfoPtr infoPtr; 985eefee25Smacallan 995eefee25Smacallan pCg6 = GET_CG6_FROM_SCRN(pScrn); 1005eefee25Smacallan pCg6->CursorXY = 0; 1015eefee25Smacallan pCg6->CursorBg = pCg6->CursorFg = 0; 1025eefee25Smacallan pCg6->CursorEnabled = FALSE; 1035eefee25Smacallan 1045eefee25Smacallan infoPtr = xf86CreateCursorInfoRec(); 1055eefee25Smacallan if(!infoPtr) return FALSE; 1065eefee25Smacallan 1075eefee25Smacallan pCg6->CursorInfoRec = infoPtr; 1085eefee25Smacallan 1095eefee25Smacallan infoPtr->MaxWidth = 32; 1105eefee25Smacallan infoPtr->MaxHeight = 32; 1115eefee25Smacallan infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | 1125eefee25Smacallan HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | 1135eefee25Smacallan HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED | 1145eefee25Smacallan HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; 1155eefee25Smacallan 1165eefee25Smacallan infoPtr->SetCursorColors = CG6SetCursorColors; 1175eefee25Smacallan infoPtr->SetCursorPosition = CG6SetCursorPosition; 1185eefee25Smacallan infoPtr->LoadCursorImage = CG6LoadCursorImage; 1195eefee25Smacallan infoPtr->HideCursor = CG6HideCursor; 1205eefee25Smacallan infoPtr->ShowCursor = CG6ShowCursor; 1215eefee25Smacallan infoPtr->UseHWCursor = NULL; 1225eefee25Smacallan 1235eefee25Smacallan return xf86InitCursor(pScreen, infoPtr); 1245eefee25Smacallan} 125