#include "rendition.h"
#include "vtypes.h"
#include "vramdac.h"
#include "hwcursor.h"
#undef DEBUG
#define BIGCURSOR 1
static Bool RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
static void RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg);
static void RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y);
static void RENDITIONHideCursor(ScrnInfoPtr pScreenInfo);
static void RENDITIONShowCursor(ScrnInfoPtr pScreenInfo);
static void RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src);
void
RenditionHWCursorPreInit (ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
#ifdef DEBUG
ErrorF ("Rendition: Debug RenditionHWCursorPreInit called\n");
#endif
pRendition->board.hwcursor_used = TRUE;
if (pRendition->board.chip==V1000_DEVICE){
pRendition->board.hwcursor_vmemsize = 0;
pRendition->board.hwcursor_membase = 0 ;
}
else{
pRendition->board.hwcursor_vmemsize = 64*64*2/8 ;
pRendition->board.hwcursor_membase = (pRendition->board.fbOffset >> 10);
pRendition->board.fbOffset += pRendition->board.hwcursor_vmemsize;
}
}
void
RenditionHWCursorRelease (ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
#ifdef DEBUG
ErrorF ("Rendition: Debug RenditionHWCursorRelease called\n");
#endif
xf86DestroyCursorInfoRec(pRendition->CursorInfoRec);
pRendition->CursorInfoRec=NULL;
}
Bool
RenditionHWCursorInit(int scrnIndex, ScreenPtr pScreen)
{
ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
xf86CursorInfoPtr infoPtr;
#ifdef DEBUG
ErrorF ("Rendition: Debug RenditionHWCursorInit called\n");
#endif
infoPtr = xf86CreateCursorInfoRec();
if(!infoPtr) return FALSE;
pRendition->CursorInfoRec = infoPtr;
#ifdef BIGCURSOR
infoPtr->MaxWidth=64;
infoPtr->MaxHeight=64;
#else
infoPtr->MaxWidth=32;
infoPtr->MaxHeight=32;
#endif
infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
HARDWARE_CURSOR_AND_SOURCE_WITH_MASK|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8;
infoPtr->SetCursorColors = RENDITIONSetCursorColors;
infoPtr->SetCursorPosition = RENDITIONSetCursorPosition;
infoPtr->LoadCursorImage = RENDITIONLoadCursorImage;
infoPtr->HideCursor = RENDITIONHideCursor;
infoPtr->ShowCursor = RENDITIONShowCursor;
infoPtr->UseHWCursor = RENDITIONUseHWCursor;
return xf86InitCursor(pScreen, infoPtr);
}
static Bool
RENDITIONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
#ifdef DEBUG
ErrorF ("Rendition: Debug RENDITIONUseHWCursor called\n");
#endif
return TRUE;
}
static void
RENDITIONShowCursor(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF( "RENDITION: ShowCursor called\n");
#endif
verite_enablecursor(pScreenInfo, VERITE_3COLORS,
#ifdef BIGCURSOR
VERITE_CURSOR64
#else
VERITE_CURSOR32
#endif
);
}
static void
RENDITIONHideCursor(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF( "RENDITION: HideCursor called\n");
#endif
verite_enablecursor(pScreenInfo, VERITE_NOCURSOR, 0);
}
static void
RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y)
{
#ifdef DEBUG
ErrorF( "RENDITION: SetCursorPosition(%d, %d) called\n", x, y);
#endif
verite_movecursor(pScreenInfo, x, y, 1 , 1 );
}
static void
RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg)
{
#ifdef DEBUG
ErrorF( "RENDITION: SetCursorColors(%x, %x) called\n", fg, bg);
#endif
verite_setcursorcolor(pScreenInfo, bg, fg);
}
static void
RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src)
{
#ifdef DEBUG
ErrorF( "RENDITION: loadcursor called\n");
#endif
verite_loadcursor(pScreenInfo,
#ifdef BIGCURSOR
VERITE_CURSOR64,
#else
VERITE_CURSOR32,
#endif
(vu8 *)src);
}