2
* $Id: sis_draw.c,v 1.3 2005/12/27 08:29:48 ajax Exp $
4
* Copyright ļæ½ 2003 Eric Anholt
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 Eric Anholt not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Eric Anholt 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
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL ERIC ANHOLT 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.
24
/* $Header: /cvs/xorg/xserver/xorg/hw/kdrive/sis300/sis_draw.c,v 1.3 2005/12/27 08:29:48 ajax Exp $ */
29
#include <kdrive-config.h>
36
#define SIS_FALLBACK(x) \
42
#define SIS_FALLBACK(x) return FALSE
45
CARD8 SiSSolidRop[16] = {
46
/* GXclear */ 0x00, /* 0 */
47
/* GXand */ 0xa0, /* src AND dst */
48
/* GXandReverse */ 0x50, /* src AND NOT dst */
49
/* GXcopy */ 0xf0, /* src */
50
/* GXandInverted*/ 0x0a, /* NOT src AND dst */
51
/* GXnoop */ 0xaa, /* dst */
52
/* GXxor */ 0x5a, /* src XOR dst */
53
/* GXor */ 0xfa, /* src OR dst */
54
/* GXnor */ 0x05, /* NOT src AND NOT dst */
55
/* GXequiv */ 0xa5, /* NOT src XOR dst */
56
/* GXinvert */ 0x55, /* NOT dst */
57
/* GXorReverse */ 0xf5, /* src OR NOT dst */
58
/* GXcopyInverted*/ 0x0f, /* NOT src */
59
/* GXorInverted */ 0xaf, /* NOT src OR dst */
60
/* GXnand */ 0x5f, /* NOT src OR NOT dst */
61
/* GXset */ 0xff, /* 1 */
64
CARD8 SiSBltRop[16] = {
65
/* GXclear */ 0x00, /* 0 */
66
/* GXand */ 0x88, /* src AND dst */
67
/* GXandReverse */ 0x44, /* src AND NOT dst */
68
/* GXcopy */ 0xcc, /* src */
69
/* GXandInverted*/ 0x22, /* NOT src AND dst */
70
/* GXnoop */ 0xaa, /* dst */
71
/* GXxor */ 0x66, /* src XOR dst */
72
/* GXor */ 0xee, /* src OR dst */
73
/* GXnor */ 0x11, /* NOT src AND NOT dst */
74
/* GXequiv */ 0x99, /* NOT src XOR dst */
75
/* GXinvert */ 0x55, /* NOT dst */
76
/* GXorReverse */ 0xdd, /* src OR NOT dst */
77
/* GXcopyInverted*/ 0x33, /* NOT src */
78
/* GXorInverted */ 0xbb, /* NOT src OR dst */
79
/* GXnand */ 0x77, /* NOT src OR NOT dst */
80
/* GXset */ 0xff, /* 1 */
85
SiSScreenInfo *accel_siss;
91
SiSWaitAvailMMIO(int n)
93
while (fifo_size < n) {
94
fifo_size = MMIO_IN32(mmio, REG_CommandQueue) & MASK_QueueLen;
104
engineState = MMIO_IN32(mmio, REG_CommandQueue);
105
} while ((engineState & SiS_EngIdle) != SiS_EngIdle);
109
SiSPrepareSolid(PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
111
KdScreenPriv(pPixmap->drawable.pScreen);
112
SiSScreenInfo(pScreenPriv);
113
SiSCardInfo(pScreenPriv);
115
/* No acceleration for other formats (yet) */
116
if (pPixmap->drawable.bitsPerPixel !=
117
pScreenPriv->screen->fb[0].bitsPerPixel)
120
if ((pm & 0x00ffffff) != 0x00ffffff) /* XXX */
121
SIS_FALLBACK(("Unsupported planemask 0x%x\n", pm));
124
mmio = sisc->reg_base;
127
MMIO_OUT32(mmio, REG_BLT_PATFG, fg);
128
MMIO_OUT32(mmio, REG_BLT_DSTRECT, (-1 << 16) | pPixmap->devKind);
129
MMIO_OUT32(mmio, REG_BLT_SRCPITCH, siss->depthSet);
130
MMIO_OUT32(mmio, REG_BLT_DSTBASE, ((CARD8 *)pPixmap->devPrivate.ptr -
131
pScreenPriv->screen->memory_base));
133
blitCmd = BLT_CMD_BITBLT | BLT_PAT_FG | BLT_X_INC | BLT_Y_INC |
134
BLT_NOCLIP | (SiSSolidRop[alu] << 8);
140
SiSSolid(int x1, int y1, int x2, int y2)
143
MMIO_OUT32(mmio, REG_BLT_DSTXY, (x1 << 16) | y1);
144
MMIO_OUT32(mmio, REG_BLT_H_W, ((y2 - y1) << 16) | (x2 - x1));
145
MMIO_OUT32(mmio, REG_BLT_CMD, blitCmd);
154
SiSPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
157
KdScreenPriv(pDst->drawable.pScreen);
158
SiSScreenInfo(pScreenPriv);
159
SiSCardInfo(pScreenPriv);
161
/* No acceleration for other formats (yet) */
162
if (pDst->drawable.bitsPerPixel !=
163
pScreenPriv->screen->fb[0].bitsPerPixel)
166
if ((pm & 0x00ffffff) != 0x00ffffff) /* XXX */
167
SIS_FALLBACK(("Unsupported pixel mask 0x%x\n", pm));
170
mmio = sisc->reg_base;
173
MMIO_OUT32(mmio, REG_BLT_SRCPITCH, siss->depthSet | pSrc->devKind);
174
MMIO_OUT32(mmio, REG_BLT_DSTRECT, (-1 << 16) | pDst->devKind);
175
MMIO_OUT32(mmio, REG_BLT_SRCBASE, ((CARD8 *)pSrc->devPrivate.ptr -
176
pScreenPriv->screen->memory_base));
177
MMIO_OUT32(mmio, REG_BLT_DSTBASE, ((CARD8 *)pDst->devPrivate.ptr -
178
pScreenPriv->screen->memory_base));
180
blitCmd = BLT_CMD_BITBLT | BLT_PAT_FG | BLT_NOCLIP |
181
(SiSBltRop[alu] << 8);
183
if (pSrc != pDst || dx >= 0)
184
blitCmd |= BLT_X_INC;
185
if (pSrc != pDst || dy >= 0)
186
blitCmd |= BLT_Y_INC;
192
SiSCopy(int srcX, int srcY, int dstX, int dstY, int w, int h)
194
if (!(blitCmd & BLT_X_INC)) {
199
if (!(blitCmd & BLT_Y_INC)) {
205
MMIO_OUT32(mmio, REG_BLT_H_W, (h << 16) | w);
206
MMIO_OUT32(mmio, REG_BLT_SRCXY, (srcX << 16) | srcY);
207
MMIO_OUT32(mmio, REG_BLT_DSTXY, (dstX << 16) | dstY);
208
MMIO_OUT32(mmio, REG_BLT_CMD, blitCmd);
216
KaaScreenInfoRec SiSKaa = {
223
KAA_OFFSCREEN_PIXMAPS,
228
#define USE_TURBOQUEUE 0
231
SiSDrawInit(ScreenPtr pScreen)
233
KdScreenPriv(pScreen);
234
SiSScreenInfo(pScreenPriv);
240
switch (pScreenPriv->screen->fb[0].depth)
243
siss->depthSet = 0x00000000;
246
siss->depthSet = 0x40000000;
249
siss->depthSet = 0x80000000;
252
if (pScreenPriv->screen->fb[0].bitsPerPixel == 32) {
253
siss->depthSet = 0xc0000000;
258
ErrorF("Unsupported depth/bpp %d/%d\n",
259
pScreenPriv->screen->fb[0].depth,
260
pScreenPriv->screen->fb[0].bitsPerPixel);
265
outb(0x86, 0x3c5); /* unlock registers */
268
outb(0xA1, 0x3c5); /* enable pci linear addressing, MMIO, PCI_IO */
272
outb(tmp | 0x42 | 0x18, 0x3c5); /* Enable 2d and 3d */
275
tqsize = (pScreenPriv->screen->memory_size / 1024) / 64 - 8;
278
outb(tqsize & 0xff, 0x3c5);
281
outb(((tqsize >> 8) & 0x03) | (tmp & 0x0c) | 0xF0, 0x3c5);
283
/* XXX: Adjust offscreen size to avoid TQ area (last 512k) */
286
ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
287
pScreenPriv->screen->fb[0].bitsPerPixel);
289
if (!kaaDrawInit(pScreen, &SiSKaa))
296
SiSDrawEnable(ScreenPtr pScreen)
302
SiSDrawDisable(ScreenPtr pScreen)
307
SiSDrawFini(ScreenPtr pScreen)
309
kaaDrawFini (pScreen);
313
SiSDrawSync(ScreenPtr pScreen)
315
KdScreenPriv(pScreen);
316
SiSScreenInfo(pScreenPriv);
317
SiSCardInfo(pScreenPriv);
320
mmio = sisc->reg_base;