2
* $XFree86: xc/programs/Xserver/hw/kdrive/igs/igscurs.c,v 1.1 2000/05/24 23:52:48 keithp Exp $
4
* Copyright � 2000 Keith Packard
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of Keith Packard not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Keith Packard makes no
13
* representations about the suitability of this software for any purpose. It
14
* is provided "as is" without express or implied warranty.
16
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
* PERFORMANCE OF THIS SOFTWARE.
26
#include "cursorstr.h"
28
#define SetupCursor(s) KdScreenPriv(s); \
29
igsCardInfo(pScreenPriv); \
30
igsScreenInfo(pScreenPriv); \
31
IgsCursor *pCurPriv = &igss->cursor; \
32
IgsVga *igsvga = &igsc->igsvga
35
_igsMoveCursor (ScreenPtr pScreen, int x, int y)
55
igsSet (igsvga, igs_sprite_x, x);
56
igsSet (igsvga, igs_sprite_preset_x, xoff);
57
igsSet (igsvga, igs_sprite_y, y);
58
igsSet (igsvga, igs_sprite_preset_y, yoff);
62
igsMoveCursor (ScreenPtr pScreen, int x, int y)
64
SetupCursor (pScreen);
66
if (!pCurPriv->has_cursor)
69
if (!pScreenPriv->enabled)
72
_igsMoveCursor (pScreen, x, y);
73
VgaFlush (&igsvga->card);
78
igsSetCursorColors (ScreenPtr pScreen)
80
SetupCursor (pScreen);
81
CursorPtr pCursor = pCurPriv->pCursor;
83
igsSetImm (igsvga, igs_cursor_write_index, 0);
84
igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8);
85
igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8);
86
igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8);
87
igsSetImm (igsvga, igs_cursor_write_index, 1);
88
igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8);
89
igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8);
90
igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8);
93
#if BITMAP_BIT_ORDER == MSBFirst
94
#define IgsAdjustCursor(v) { \
95
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
96
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
97
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
98
v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \
99
v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \
102
#define IgsAdjustCursor(v)
105
#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1))
106
#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \
107
(ExplodeBits2((v) & 0x3)))
108
#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \
109
(ExplodeBits4((v) & 0xf)))
110
#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \
111
(ExplodeBits8((v) & 0xff)))
113
igsLoadCursor (ScreenPtr pScreen, int x, int y)
115
SetupCursor(pScreen);
116
CursorPtr pCursor = pCurPriv->pCursor;
117
CursorBitsPtr bits = pCursor->bits;
119
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
123
unsigned char ramdac_control_;
127
pCurPriv->pCursor = pCursor;
128
pCurPriv->xhot = pCursor->bits->xhot;
129
pCurPriv->yhot = pCursor->bits->yhot;
132
* Stick new image into cursor memory
134
ram = (CARD32 *) igss->cursor_base;
135
mskLine = (CARD32 *) bits->mask;
136
srcLine = (CARD32 *) bits->source;
139
if (h > IGS_CURSOR_HEIGHT)
140
h = IGS_CURSOR_HEIGHT;
142
lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
144
for (i = 0; i < IGS_CURSOR_HEIGHT; i++) {
149
for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) {
153
if (i < h && j < lwsrc)
167
b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1);
168
b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1);
175
igsSetCursorColors (pScreen);
177
/* Set address for cursor bits */
178
offset = igss->cursor_offset;
180
igsSet (igsvga, igs_sprite_addr, offset);
182
/* Assume TV interpolation off */
183
igsSet (igsvga, igs_hcshf, 3);
184
/* Enable the cursor */
185
igsSet (igsvga, igs_sprite_visible, 1);
186
igsSet (igsvga, igs_sprite_64x64, 1);
187
/* Move to new position */
188
_igsMoveCursor (pScreen, x, y);
190
VgaFlush (&igsvga->card);
194
igsUnloadCursor (ScreenPtr pScreen)
196
SetupCursor (pScreen);
199
igsSet (igsvga, igs_sprite_visible, 0);
200
VgaFlush (&igsvga->card);
204
igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
206
SetupCursor(pScreen);
208
if (!pScreenPriv->enabled)
211
/* miRecolorCursor does this */
212
if (pCurPriv->pCursor == pCursor)
218
miPointerPosition (&x, &y);
219
igsLoadCursor (pScreen, x, y);
226
igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
232
igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
234
SetupCursor(pScreen);
236
pCurPriv->pCursor = pCursor;
238
if (!pScreenPriv->enabled)
242
igsLoadCursor (pScreen, x, y);
244
igsUnloadCursor (pScreen);
247
miPointerSpriteFuncRec igsPointerSpriteFuncs = {
255
igsQueryBestSize (int class,
256
unsigned short *pwidth, unsigned short *pheight,
259
SetupCursor (pScreen);
264
if (*pwidth > pCurPriv->width)
265
*pwidth = pCurPriv->width;
266
if (*pheight > pCurPriv->height)
267
*pheight = pCurPriv->height;
268
if (*pwidth > pScreen->width)
269
*pwidth = pScreen->width;
270
if (*pheight > pScreen->height)
271
*pheight = pScreen->height;
274
fbQueryBestSize (class, pwidth, pheight, pScreen);
280
igsCursorInit (ScreenPtr pScreen)
282
SetupCursor (pScreen);
284
if (!igss->cursor_base)
286
pCurPriv->has_cursor = FALSE;
290
pCurPriv->width = IGS_CURSOR_WIDTH;
291
pCurPriv->height= IGS_CURSOR_HEIGHT;
292
pScreen->QueryBestSize = igsQueryBestSize;
293
miPointerInitialize (pScreen,
294
&igsPointerSpriteFuncs,
295
&kdPointerScreenFuncs,
297
pCurPriv->has_cursor = TRUE;
298
pCurPriv->pCursor = NULL;
303
igsCursorEnable (ScreenPtr pScreen)
305
SetupCursor (pScreen);
307
if (pCurPriv->has_cursor)
309
if (pCurPriv->pCursor)
313
miPointerPosition (&x, &y);
314
igsLoadCursor (pScreen, x, y);
317
igsUnloadCursor (pScreen);
322
igsCursorDisable (ScreenPtr pScreen)
324
SetupCursor (pScreen);
326
if (!pScreenPriv->enabled)
329
if (pCurPriv->has_cursor)
331
if (pCurPriv->pCursor)
333
igsUnloadCursor (pScreen);
339
igsCursorFini (ScreenPtr pScreen)
341
SetupCursor (pScreen);
343
pCurPriv->pCursor = NULL;