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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
/*
* Copyright 2001 Ani Joshi <ajoshi@unixbox.com>
*
* XFree86 4.x driver for S3 chipsets
*
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation and
* that the name of Ani Joshi not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Ani Joshi makes no representations
* about the suitability of this software for any purpose. It is provided
* "as-is" without express or implied warranty.
*
* ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANI JOSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*
*/
/* $XFree86: $ */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
#include "compiler.h"
#include "s3.h"
#include "s3_reg.h"
static void S3SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
S3Ptr pS3 = S3PTR(pScrn);
int vgaCRIndex = pS3->vgaCRIndex, vgaCRReg = pS3->vgaCRReg;
unsigned short packfg, packbg;
switch (pS3->s3Bpp) {
case 1:
/* XXX Trio series only */
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4a);
outb(vgaCRReg, fg);
outb(vgaCRReg, fg);
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4b);
outb(vgaCRReg, bg);
outb(vgaCRReg, bg);
break;
case 2:
/* XXX depth 16 */
packfg = ((fg & 0x00f80000) >> 19) | ((fg & 0x0000fc00) >> 5) |
((fg & 0x000000f8) << 8);
packbg = ((bg & 0x00f80000) >> 19) | ((bg & 0x0000fc00) >> 5) |
((bg & 0x000000f8) << 8);
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4a);
outb(vgaCRReg, packfg);
outb(vgaCRReg, packfg >> 8);
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4b);
outb(vgaCRReg, packbg);
outb(vgaCRReg, packbg >> 8);
break;
default:
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4a);
outb(vgaCRReg, (fg & 0x00ff0000) >> 16);
outb(vgaCRReg, (fg & 0x0000ff00) >> 8);
outb(vgaCRReg, (fg & 0x000000ff));
outb(vgaCRIndex, 0x45);
inb(vgaCRReg);
outb(vgaCRIndex, 0x4b);
outb(vgaCRReg, (bg & 0x00ff0000) >> 16);
outb(vgaCRReg, (bg & 0x0000ff00) >> 8);
outb(vgaCRReg, (bg & 0x000000ff));
break;
}
}
static void S3SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
S3Ptr pS3 = S3PTR(pScrn);
int vgaCRIndex = pS3->vgaCRIndex, vgaCRReg = pS3->vgaCRReg;
outb(vgaCRIndex, 0x39);
outb(vgaCRReg, 0xa5);
outb(vgaCRIndex, 0x46);
outb(vgaCRReg, x >> 8);
outb(vgaCRIndex, 0x47);
outb(vgaCRReg, x);
outb(vgaCRIndex, 0x49);
outb(vgaCRReg, y);
outb(vgaCRIndex, 0x48);
outb(vgaCRReg, y >> 8);
}
static void S3HideCursor(ScrnInfoPtr pScrn)
{
S3Ptr pS3 = S3PTR(pScrn);
int vgaCRIndex = pS3->vgaCRIndex, vgaCRReg = pS3->vgaCRReg;
unsigned char tmp;
outb(vgaCRIndex, 0x45);
tmp = inb(vgaCRReg);
outb(vgaCRReg, tmp & ~0x01);
}
static void S3ShowCursor(ScrnInfoPtr pScrn)
{
S3Ptr pS3 = S3PTR(pScrn);
int vgaCRIndex = pS3->vgaCRIndex, vgaCRReg = pS3->vgaCRReg;
unsigned char tmp;
outb(vgaCRIndex, 0x39);
outb(vgaCRReg, 0xa5);
outb(vgaCRIndex, 0x55);
tmp = inb(vgaCRReg);
outb(vgaCRReg, tmp | 0x10);
outb(vgaCRIndex, 0x4c);
outb(vgaCRReg, pS3->FBCursorOffset >> 8);
outb(vgaCRIndex, 0x4d);
outb(vgaCRReg, pS3->FBCursorOffset);
outb(vgaCRIndex, 0x45);
tmp = inb(vgaCRReg);
outb(vgaCRReg, tmp | 0x01);
}
static void S3LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image)
{
S3Ptr pS3 = S3PTR(pScrn);
int vgaCRIndex = pS3->vgaCRIndex, vgaCRReg = pS3->vgaCRReg;
unsigned char cr45;
outb(vgaCRIndex, 0x39);
outb(vgaCRReg, 0xa5);
WaitIdle();
VerticalRetraceWait();
outb(vgaCRIndex, 0x45);
cr45 = inb(vgaCRReg);
outb(vgaCRReg, cr45 & 0xfe);
outb(vgaCRIndex, 0x46);
outb(vgaCRReg, 0xff);
outb(vgaCRIndex, 0x47);
outb(vgaCRReg, 0x7f);
outb(vgaCRIndex, 0x49);
outb(vgaCRReg, 0xff);
outb(vgaCRIndex, 0x4e);
outb(vgaCRReg, 0x3f);
outb(vgaCRIndex, 0x4f);
outb(vgaCRReg, 0x3f);
outb(vgaCRIndex, 0x48);
outb(vgaCRReg, 0x7f);
memcpy(pS3->FBBase + (pS3->FBCursorOffset * 1024), image, 1024);
VerticalRetraceWait();
outb(vgaCRIndex, 0x45);
outb(vgaCRReg, cr45);
}
static Bool S3UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
S3Ptr pS3 = S3PTR(pScrn);
return (pS3->hwCursor);
}
Bool S3_CursorInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
S3Ptr pS3 = S3PTR(pScrn);
xf86CursorInfoPtr pCurs;
if (!(pCurs = pS3->pCurs = xf86CreateCursorInfoRec()))
return FALSE;
pCurs->MaxWidth = 64;
pCurs->MaxHeight = 64;
pCurs->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
HARDWARE_CURSOR_BIT_ORDER_MSBFIRST;
pCurs->SetCursorColors = S3SetCursorColors;
pCurs->SetCursorPosition = S3SetCursorPosition;
pCurs->LoadCursorImage = S3LoadCursorImage;
pCurs->HideCursor = S3HideCursor;
pCurs->ShowCursor = S3ShowCursor;
pCurs->UseHWCursor = S3UseHWCursor;
return xf86InitCursor(pScreen, pCurs);
}
|