1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
Voodoo Banshee driver version 1.0.2
Author: Daryll Strauss
Copyright: 1998,1999
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86fbman.h"
#include "tdfx.h"
static void TDFXLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
static void TDFXShowCursor(ScrnInfoPtr pScrn);
static void TDFXHideCursor(ScrnInfoPtr pScrn);
static void TDFXSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
static void TDFXSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
static Bool TDFXUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
Bool
TDFXCursorInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn;
TDFXPtr pTDFX;
xf86CursorInfoPtr infoPtr;
TDFXTRACECURS("TDFXCursorInit start\n");
pScrn = xf86ScreenToScrn(pScreen);
pTDFX = TDFXPTR(pScrn);
pTDFX->CursorInfoRec = infoPtr = xf86CreateCursorInfoRec();
if (!infoPtr) return FALSE;
infoPtr->MaxWidth = 64;
infoPtr->MaxHeight = 64;
infoPtr->Flags =
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
#endif
HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK|
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
infoPtr->SetCursorColors = TDFXSetCursorColors;
infoPtr->SetCursorPosition = TDFXSetCursorPosition;
infoPtr->LoadCursorImage = TDFXLoadCursorImage;
infoPtr->HideCursor = TDFXHideCursor;
infoPtr->ShowCursor = TDFXShowCursor;
infoPtr->UseHWCursor = TDFXUseHWCursor;
pTDFX->ModeReg.cursloc = pTDFX->cursorOffset;
pTDFX->writeLong(pTDFX, HWCURPATADDR, pTDFX->cursorOffset);
return xf86InitCursor(pScreen, infoPtr);
}
#if X_BYTE_ORDER == X_BIG_ENDIAN
static unsigned int TDFXSwap(TDFXPtr pTDFX, unsigned int val) {
switch (pTDFX->cpp) {
default:
return val;
case 2:
return ((val & 0x00ff00ff) << 8) |
((val & 0xff00ff00) >> 8);
case 3:
case 4:
return BE_BSWAP32(val);
}
}
#endif
static void
TDFXLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{
TDFXPtr pTDFX;
TDFXTRACECURS("TDFXLoadCursorImage start\n");
pTDFX = TDFXPTR(pScrn);
#if X_BYTE_ORDER == X_BIG_ENDIAN
{
int i;
unsigned int *ptr=(unsigned int *)(pTDFX->FbBase+pTDFX->cursorOffset);
for (i=0; i<256; i++) {
unsigned int val = ((unsigned int *)src)[i];
*ptr++ = TDFXSwap(pTDFX, val);
}
}
#else
memcpy(pTDFX->FbBase+pTDFX->cursorOffset, src, 1024);
#endif
}
static void
TDFXShowCursor(ScrnInfoPtr pScrn)
{
TDFXPtr pTDFX;
TDFXTRACECURS("TDFXShowCursor start\n");
pTDFX = TDFXPTR(pScrn);
pTDFX->ModeReg.vidcfg|=BIT(27);
pTDFX->writeLong(pTDFX, VIDPROCCFG, pTDFX->ModeReg.vidcfg);
}
void
TDFXHideCursor(ScrnInfoPtr pScrn)
{
TDFXPtr pTDFX;
TDFXTRACECURS("TDFXHideCursor start\n");
pTDFX = TDFXPTR(pScrn);
pTDFX->ModeReg.vidcfg&=~BIT(27);
pTDFX->writeLong(pTDFX, VIDPROCCFG, pTDFX->ModeReg.vidcfg);
}
static void
TDFXSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
TDFXPtr pTDFX;
/* TDFXTRACECURS("TDFXSetCursorPosition start\n"); */
pTDFX = TDFXPTR(pScrn);
pTDFX->writeLong(pTDFX, HWCURLOC, ((y+64)<<16)|(x+64));
}
static void
TDFXSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
TDFXPtr pTDFX;
TDFXTRACECURS("TDFXSetCursorColors start\n");
pTDFX = TDFXPTR(pScrn);
pTDFX->writeLong(pTDFX, HWCURC0, bg);
pTDFX->writeLong(pTDFX, HWCURC1, fg);
}
static Bool
TDFXUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
ScrnInfoPtr pScrn;
TDFXPtr pTDFX;
TDFXTRACECURS("TDFXUseHWCursor start\n");
pScrn = xf86ScreenToScrn(pScreen);
pTDFX = TDFXPTR(pScrn);
if (pScrn->currentMode->Flags&V_DBLSCAN)
return FALSE;
if (!pTDFX->CursorInfoRec) return FALSE;
return TRUE;
}
|