hwcursor.c revision 880c7e28
1/* 2 * includes 3 */ 4 5#ifdef HAVE_CONFIG_H 6#include "config.h" 7#endif 8 9#include "rendition.h" 10#include "vtypes.h" 11#include "vramdac.h" 12 13#include "hwcursor.h" 14 15/* 16 * defines 17 */ 18 19#undef DEBUG 20 21/* use a 64x64 cursor, 32x32 otherwise */ 22/* note that V2K supports only 64x64 size */ 23#define BIGCURSOR 1 24 25/* 26 * local function prototypes 27 */ 28 29static Bool RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs); 30static void RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg); 31static void RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y); 32static void RENDITIONHideCursor(ScrnInfoPtr pScreenInfo); 33static void RENDITIONShowCursor(ScrnInfoPtr pScreenInfo); 34static void RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src); 35 36 37/* 38 * This is top-level initialization funtion 39 */ 40void 41RenditionHWCursorPreInit (ScrnInfoPtr pScreenInfo) 42{ 43 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 44 45#ifdef DEBUG 46 ErrorF ("Rendition: Debug RenditionHWCursorPreInit called\n"); 47#endif 48 49 pRendition->board.hwcursor_used = TRUE; 50 if (pRendition->board.chip==V1000_DEVICE){ 51 /* V1K uses special space on BT-485 RAMDAC */ 52 pRendition->board.hwcursor_vmemsize = 0; 53 pRendition->board.hwcursor_membase = 0 ; /* Not used on V1K */ 54 } 55 else{ 56 pRendition->board.hwcursor_vmemsize = 64*64*2/8 /* 1024 bytes used */; 57 pRendition->board.hwcursor_membase = (pRendition->board.fbOffset >> 10); 58 /* Last but not least, update offset-adress */ 59 pRendition->board.fbOffset += pRendition->board.hwcursor_vmemsize; 60 } 61} 62 63void 64RenditionHWCursorRelease (ScrnInfoPtr pScreenInfo) 65{ 66 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 67 68#ifdef DEBUG 69 ErrorF ("Rendition: Debug RenditionHWCursorRelease called\n"); 70#endif 71 72 xf86DestroyCursorInfoRec(pRendition->CursorInfoRec); 73 pRendition->CursorInfoRec=NULL; 74} 75 76 77Bool 78RenditionHWCursorInit(ScreenPtr pScreen) 79{ 80 ScrnInfoPtr pScreenInfo = xf86ScreenToScrn(pScreen); 81 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 82 xf86CursorInfoPtr infoPtr; 83 84#ifdef DEBUG 85 ErrorF ("Rendition: Debug RenditionHWCursorInit called\n"); 86#endif 87 88 infoPtr = xf86CreateCursorInfoRec(); 89 if(!infoPtr) return FALSE; 90 91 pRendition->CursorInfoRec = infoPtr; 92 93#ifdef BIGCURSOR 94 infoPtr->MaxWidth=64; 95 infoPtr->MaxHeight=64; 96#else 97 infoPtr->MaxWidth=32; 98 infoPtr->MaxHeight=32; 99#endif 100 101 infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | 102 HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | 103 HARDWARE_CURSOR_AND_SOURCE_WITH_MASK| 104 HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8; 105 106 107 infoPtr->SetCursorColors = RENDITIONSetCursorColors; 108 infoPtr->SetCursorPosition = RENDITIONSetCursorPosition; 109 infoPtr->LoadCursorImage = RENDITIONLoadCursorImage; 110 infoPtr->HideCursor = RENDITIONHideCursor; 111 infoPtr->ShowCursor = RENDITIONShowCursor; 112 infoPtr->UseHWCursor = RENDITIONUseHWCursor; 113 114 return xf86InitCursor(pScreen, infoPtr); 115} 116 117 118/* 119 * local functions 120 */ 121 122static Bool 123RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) 124{ 125#ifdef DEBUG 126 ErrorF ("Rendition: Debug RENDITIONUseHWCursor called\n"); 127#endif 128 129 /* have this return false for DoubleScan and Interlaced ? */ 130 return TRUE; 131} 132 133 134static void 135RENDITIONShowCursor(ScrnInfoPtr pScreenInfo) 136{ 137 /* renditionPtr pRendition = RENDITIONPTR(pScreenInfo); */ 138 139#ifdef DEBUG 140 ErrorF( "RENDITION: ShowCursor called\n"); 141#endif 142 143 /* enable cursor - X11 mode */ 144 verite_enablecursor(pScreenInfo, VERITE_3COLORS, 145#ifdef BIGCURSOR 146 VERITE_CURSOR64 147#else 148 VERITE_CURSOR32 149#endif 150 ); 151} 152 153 154 155static void 156RENDITIONHideCursor(ScrnInfoPtr pScreenInfo) 157{ 158#ifdef DEBUG 159 ErrorF( "RENDITION: HideCursor called\n"); 160#endif 161 162 /* Disable cursor */ 163 verite_enablecursor(pScreenInfo, VERITE_NOCURSOR, 0); 164} 165 166 167 168static void 169RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y) 170{ 171#ifdef DEBUG 172 ErrorF( "RENDITION: SetCursorPosition(%d, %d) called\n", x, y); 173#endif 174 175 verite_movecursor(pScreenInfo, x, y, 1 /* xorigin */, 1 /* yorigin */); 176} 177 178 179 180static void 181RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg) 182{ 183#ifdef DEBUG 184 ErrorF( "RENDITION: SetCursorColors(%x, %x) called\n", fg, bg); 185#endif 186 187 verite_setcursorcolor(pScreenInfo, bg, fg); 188} 189 190 191 192static void 193RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src) 194{ 195#ifdef DEBUG 196 ErrorF( "RENDITION: loadcursor called\n"); 197#endif 198 verite_loadcursor(pScreenInfo, 199#ifdef BIGCURSOR 200 VERITE_CURSOR64, 201#else 202 VERITE_CURSOR32, 203#endif 204 (vu8 *)src); 205} 206 207 208/* 209 * end of file hwcursor.c 210 */ 211