~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to hw/kdrive/mach64/mach64draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Id: mach64draw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $
 
3
 *
 
4
 * Copyright � 1999 Keith Packard
 
5
 *
 
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.
 
15
 *
 
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.
 
23
 */
 
24
/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.6 2001/07/23 03:44:17 keithp Exp $ */
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
#include <kdrive-config.h>
 
28
#endif
 
29
#include "mach64.h"
 
30
#include "mach64draw.h"
 
31
 
 
32
#include        <X11/Xmd.h>
 
33
#include        "gcstruct.h"
 
34
#include        "scrnintstr.h"
 
35
#include        "pixmapstr.h"
 
36
#include        "regionstr.h"
 
37
#include        "mistruct.h"
 
38
#include        "dixfontstr.h"
 
39
#include        "fb.h"
 
40
#include        "migc.h"
 
41
#include        "miline.h"
 
42
#include        "picturestr.h"
 
43
#include        "kaa.h"
 
44
 
 
45
CARD8 mach64Rop[16] = {
 
46
    /* GXclear      */      0x01,         /* 0 */
 
47
    /* GXand        */      0x0c,         /* src AND dst */
 
48
    /* GXandReverse */      0x0d,         /* src AND NOT dst */
 
49
    /* GXcopy       */      0x07,         /* src */
 
50
    /* GXandInverted*/      0x0e,         /* NOT src AND dst */
 
51
    /* GXnoop       */      0x03,         /* dst */
 
52
    /* GXxor        */      0x05,         /* src XOR dst */
 
53
    /* GXor         */      0x0b,         /* src OR dst */
 
54
    /* GXnor        */      0x0f,         /* NOT src AND NOT dst */
 
55
    /* GXequiv      */      0x06,         /* NOT src XOR dst */
 
56
    /* GXinvert     */      0x00,         /* NOT dst */
 
57
    /* GXorReverse  */      0x0a,         /* src OR NOT dst */
 
58
    /* GXcopyInverted*/     0x04,         /* NOT src */
 
59
    /* GXorInverted */      0x09,         /* NOT src OR dst */
 
60
    /* GXnand       */      0x08,         /* NOT src OR NOT dst */
 
61
    /* GXset        */      0x02,         /* 1 */
 
62
};
 
63
 
 
64
#define MACH64_DRAW_COMBO_SOLID 0x1
 
65
#define MACH64_DRAW_COMBO_COPY  0x8
 
66
 
 
67
#define SYNC_ALWAYS 0
 
68
static Reg      *reg;
 
69
static CARD32   avail;
 
70
static CARD32   triple;
 
71
 
 
72
#define IDX(reg,n)  (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP)
 
73
 
 
74
void
 
75
mach64WaitAvail(Reg *reg, int n)
 
76
{
 
77
    if (avail < n)
 
78
    {
 
79
        while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n)
 
80
            ;
 
81
    }
 
82
    avail -= n;
 
83
}
 
84
 
 
85
void
 
86
mach64WaitIdle (Reg *reg)
 
87
{
 
88
    while (reg->GUI_STAT & 1)
 
89
        ;
 
90
}
 
91
 
 
92
#define PIX_FORMAT_MONO 0
 
93
#define PIX_FORMAT_PSEUDO_8     2
 
94
#define PIX_FORMAT_TRUE_1555    3
 
95
#define PIX_FORMAT_TRUE_565     4
 
96
#define PIX_FORMAT_TRUE_8888    6
 
97
#define PIX_FORMAT_TRUE_332     7
 
98
#define PIX_FORMAT_GRAY_8       8
 
99
#define PIX_FORMAT_YUV_422      0xb
 
100
#define PIX_FORMAT_YUV_444      0xe
 
101
#define PIX_FORMAT_TRUE_4444    0xf
 
102
 
 
103
typedef struct _mach64AccelReg {
 
104
    int         depth;
 
105
    int         bitsPerPixel;
 
106
    CARD32      DP_PIX_WIDTH;
 
107
    CARD32      DP_SET_GUI_ENGINE;    
 
108
} Mach64AccelReg;
 
109
 
 
110
static const Mach64AccelReg     mach64AccelReg[] = {
 
111
    { 1, 1,
 
112
        /* DP_PIX_WIDTH */
 
113
        ((PIX_FORMAT_MONO << 0) |       /* DP_DST_PIX_WIDTH */
 
114
         (PIX_FORMAT_MONO << 4) |       /* COMPOSITE_PIX_WIDTH */
 
115
         (PIX_FORMAT_MONO << 8) |       /* DP_SRC_PIX_WIDTH */
 
116
         (0 << 13) |                    /* DP_HOST_TRIPLE_EN */
 
117
         (0 << 14) |                    /* DP_PALETTE_TYPE */
 
118
         (PIX_FORMAT_MONO << 16) |      /* DP_HOST_PIX_WIDTH */
 
119
         (0 << 20) |                    /* DP_C14_RGB_INDEX */
 
120
         (0 << 24) |                    /* DP_BYTE_PIX_ORDER */
 
121
         (0 << 25) |                    /* DP_CONVERSION_TEMP */
 
122
         (0 << 26) |                    /* DP_C14_RGB_LOW_NIBBLE */
 
123
         (0 << 27) |                    /* DP_C14_RGB_HIGH_NIBBLE */
 
124
         (PIX_FORMAT_MONO << 28) |      /* DP_SCALE_PIX_WIDTH */
 
125
         0),
 
126
        /* DP_SET_GUI_ENGINE */
 
127
        ((PIX_FORMAT_MONO << 3) |
 
128
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
129
         (6 << 7) |             /* SET_DST_OFFSET */
 
130
         (0 << 10) |            /* SET_DST_PITCH */
 
131
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
132
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
133
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
134
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
135
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
136
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
137
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
138
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
139
         (0 << 29) |            /* FAST_FILL_EN */
 
140
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
141
         0)
 
142
    },
 
143
    { 8, 8,
 
144
        /* DP_PIX_WIDTH */
 
145
        ((PIX_FORMAT_PSEUDO_8 << 0) |   /* DP_DST_PIX_WIDTH */
 
146
         (PIX_FORMAT_PSEUDO_8 << 4) |   /* COMPOSITE_PIX_WIDTH */
 
147
         (PIX_FORMAT_PSEUDO_8 << 8) |   /* DP_SRC_PIX_WIDTH */
 
148
         (0 << 13) |                    /* DP_HOST_TRIPLE_EN */
 
149
         (0 << 14) |                    /* DP_PALETTE_TYPE */
 
150
         (PIX_FORMAT_PSEUDO_8 << 16) |  /* DP_HOST_PIX_WIDTH */
 
151
         (0 << 20) |                    /* DP_C14_RGB_INDEX */
 
152
         (0 << 24) |                    /* DP_BYTE_PIX_ORDER */
 
153
         (0 << 25) |                    /* DP_CONVERSION_TEMP */
 
154
         (0 << 26) |                    /* DP_C14_RGB_LOW_NIBBLE */
 
155
         (0 << 27) |                    /* DP_C14_RGB_HIGH_NIBBLE */
 
156
         (PIX_FORMAT_PSEUDO_8 << 28) |  /* DP_SCALE_PIX_WIDTH */
 
157
         0),
 
158
        /* DP_SET_GUI_ENGINE */
 
159
        ((PIX_FORMAT_PSEUDO_8 << 3) |
 
160
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
161
         (6 << 7) |             /* SET_DST_OFFSET */
 
162
         (0 << 10) |            /* SET_DST_PITCH */
 
163
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
164
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
165
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
166
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
167
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
168
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
169
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
170
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
171
         (0 << 29) |            /* FAST_FILL_EN */
 
172
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
173
         0)
 
174
    },
 
175
    { 15, 16,
 
176
        /* DP_PIX_WIDTH */
 
177
        ((PIX_FORMAT_TRUE_1555 << 0) |  /* DP_DST_PIX_WIDTH */
 
178
         (PIX_FORMAT_TRUE_1555 << 4) |  /* COMPOSITE_PIX_WIDTH */
 
179
         (PIX_FORMAT_TRUE_1555 << 8) |  /* DP_SRC_PIX_WIDTH */
 
180
         (0 << 13) |                    /* DP_HOST_TRIPLE_EN */
 
181
         (0 << 14) |                    /* DP_PALETTE_TYPE */
 
182
         (PIX_FORMAT_TRUE_1555 << 16) | /* DP_HOST_PIX_WIDTH */
 
183
         (0 << 20) |                    /* DP_C14_RGB_INDEX */
 
184
         (0 << 24) |                    /* DP_BYTE_PIX_ORDER */
 
185
         (0 << 25) |                    /* DP_CONVERSION_TEMP */
 
186
         (0 << 26) |                    /* DP_C14_RGB_LOW_NIBBLE */
 
187
         (0 << 27) |                    /* DP_C14_RGB_HIGH_NIBBLE */
 
188
         (PIX_FORMAT_TRUE_1555 << 28) | /* DP_SCALE_PIX_WIDTH */
 
189
         0),
 
190
        /* DP_SET_GUI_ENGINE */
 
191
        ((PIX_FORMAT_TRUE_1555 << 3) |
 
192
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
193
         (6 << 7) |             /* SET_DST_OFFSET */
 
194
         (0 << 10) |            /* SET_DST_PITCH */
 
195
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
196
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
197
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
198
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
199
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
200
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
201
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
202
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
203
         (0 << 29) |            /* FAST_FILL_EN */
 
204
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
205
         0)
 
206
    },
 
207
    { 16, 16,
 
208
        /* DP_PIX_WIDTH */
 
209
        ((PIX_FORMAT_TRUE_565 << 0) |   /* DP_DST_PIX_WIDTH */
 
210
         (PIX_FORMAT_TRUE_565 << 4) |   /* COMPOSITE_PIX_WIDTH */
 
211
         (PIX_FORMAT_TRUE_565 << 8) |   /* DP_SRC_PIX_WIDTH */
 
212
         (0 << 13) |                    /* DP_HOST_TRIPLE_EN */
 
213
         (0 << 14) |                    /* DP_PALETTE_TYPE */
 
214
         (PIX_FORMAT_TRUE_565 << 16) |  /* DP_HOST_PIX_WIDTH */
 
215
         (0 << 20) |                    /* DP_C14_RGB_INDEX */
 
216
         (0 << 24) |                    /* DP_BYTE_PIX_ORDER */
 
217
         (0 << 25) |                    /* DP_CONVERSION_TEMP */
 
218
         (0 << 26) |                    /* DP_C14_RGB_LOW_NIBBLE */
 
219
         (0 << 27) |                    /* DP_C14_RGB_HIGH_NIBBLE */
 
220
         (PIX_FORMAT_TRUE_565 << 28) |  /* DP_SCALE_PIX_WIDTH */
 
221
         0),
 
222
        /* DP_SET_GUI_ENGINE */
 
223
        ((PIX_FORMAT_TRUE_565 << 3) |
 
224
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
225
         (6 << 7) |             /* SET_DST_OFFSET */
 
226
         (0 << 10) |            /* SET_DST_PITCH */
 
227
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
228
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
229
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
230
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
231
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
232
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
233
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
234
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
235
         (0 << 29) |            /* FAST_FILL_EN */
 
236
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
237
         0)
 
238
    },
 
239
    { 24, 24,
 
240
        /* DP_PIX_WIDTH */
 
241
        ((PIX_FORMAT_PSEUDO_8 << 0) |    /* DP_DST_PIX_WIDTH */
 
242
         (PIX_FORMAT_PSEUDO_8 << 4) |    /* COMPOSITE_PIX_WIDTH */
 
243
         (PIX_FORMAT_PSEUDO_8 << 8) |    /* DP_SRC_PIX_WIDTH */
 
244
         (0 << 13) |                        /* DP_HOST_TRIPLE_EN */
 
245
         (0 << 14) |                        /* DP_PALETTE_TYPE */
 
246
         (PIX_FORMAT_PSEUDO_8 << 16) |   /* DP_HOST_PIX_WIDTH */
 
247
         (0 << 20) |                        /* DP_C14_RGB_INDEX */
 
248
         (0 << 24) |                        /* DP_BYTE_PIX_ORDER */
 
249
         (0 << 25) |                        /* DP_CONVERSION_TEMP */
 
250
         (0 << 26) |                        /* DP_C14_RGB_LOW_NIBBLE */
 
251
         (0 << 27) |                        /* DP_C14_RGB_HIGH_NIBBLE */
 
252
         (PIX_FORMAT_PSEUDO_8 << 28) |  /* DP_SCALE_PIX_WIDTH */
 
253
         0),
 
254
        /* DP_SET_GUI_ENGINE */
 
255
        ((PIX_FORMAT_PSEUDO_8 << 3) |
 
256
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
257
         (6 << 7) |             /* SET_DST_OFFSET */
 
258
         (0 << 10) |            /* SET_DST_PITCH */
 
259
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
260
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
261
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
262
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
263
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
264
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
265
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
266
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
267
         (0 << 29) |            /* FAST_FILL_EN */
 
268
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
269
         0)
 
270
    },
 
271
    { 24, 32,
 
272
        /* DP_PIX_WIDTH */
 
273
        ((PIX_FORMAT_TRUE_8888 << 0) |   /* DP_DST_PIX_WIDTH */
 
274
         (PIX_FORMAT_TRUE_8888 << 4) |   /* COMPOSITE_PIX_WIDTH */
 
275
         (PIX_FORMAT_TRUE_8888 << 8) |   /* DP_SRC_PIX_WIDTH */
 
276
         (0 << 13) |                        /* DP_HOST_TRIPLE_EN */
 
277
         (0 << 14) |                        /* DP_PALETTE_TYPE */
 
278
         (PIX_FORMAT_TRUE_8888 << 16) |  /* DP_HOST_PIX_WIDTH */
 
279
         (0 << 20) |                        /* DP_C14_RGB_INDEX */
 
280
         (0 << 24) |                        /* DP_BYTE_PIX_ORDER */
 
281
         (0 << 25) |                        /* DP_CONVERSION_TEMP */
 
282
         (0 << 26) |                        /* DP_C14_RGB_LOW_NIBBLE */
 
283
         (0 << 27) |                        /* DP_C14_RGB_HIGH_NIBBLE */
 
284
         (PIX_FORMAT_TRUE_8888 << 28) |  /* DP_SCALE_PIX_WIDTH */
 
285
         0),
 
286
        /* DP_SET_GUI_ENGINE */
 
287
        ((PIX_FORMAT_TRUE_8888 << 3) |
 
288
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
289
         (6 << 7) |             /* SET_DST_OFFSET */
 
290
         (0 << 10) |            /* SET_DST_PITCH */
 
291
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
292
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
293
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
294
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
295
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
296
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
297
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
298
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
299
         (0 << 29) |            /* FAST_FILL_EN */
 
300
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
301
         0)
 
302
    },
 
303
    { 32, 32,
 
304
        /* DP_PIX_WIDTH */
 
305
        ((PIX_FORMAT_TRUE_8888 << 0) |   /* DP_DST_PIX_WIDTH */
 
306
         (PIX_FORMAT_TRUE_8888 << 4) |   /* COMPOSITE_PIX_WIDTH */
 
307
         (PIX_FORMAT_TRUE_8888 << 8) |   /* DP_SRC_PIX_WIDTH */
 
308
         (0 << 13) |                        /* DP_HOST_TRIPLE_EN */
 
309
         (0 << 14) |                        /* DP_PALETTE_TYPE */
 
310
         (PIX_FORMAT_TRUE_8888 << 16) |  /* DP_HOST_PIX_WIDTH */
 
311
         (0 << 20) |                        /* DP_C14_RGB_INDEX */
 
312
         (0 << 24) |                        /* DP_BYTE_PIX_ORDER */
 
313
         (0 << 25) |                        /* DP_CONVERSION_TEMP */
 
314
         (0 << 26) |                        /* DP_C14_RGB_LOW_NIBBLE */
 
315
         (0 << 27) |                        /* DP_C14_RGB_HIGH_NIBBLE */
 
316
         (PIX_FORMAT_TRUE_8888 << 28) |  /* DP_SCALE_PIX_WIDTH */
 
317
         0),
 
318
        /* DP_SET_GUI_ENGINE */
 
319
        ((PIX_FORMAT_TRUE_8888 << 3) |
 
320
         (1 << 6) |             /* SET_DP_SRC_PIX_WIDTH */
 
321
         (6 << 7) |             /* SET_DST_OFFSET */
 
322
         (0 << 10) |            /* SET_DST_PITCH */
 
323
         (0 << 14) |            /* SET_DST_PITCH_BY_2 */
 
324
         (0 << 15) |            /* SET_SRC_OFFPITCH_COPY */
 
325
         (0 << 16) |            /* SET_SRC_HGTWID1_2 */
 
326
         (0 << 20) |            /* SET_DRAWING_COMBO */
 
327
         (1 << 24) |            /* SET_BUS_MASTER_OP */
 
328
         (0 << 26) |            /* SET_BUS_MASTER_EN */
 
329
         (0 << 27) |            /* SET_BUS_MASTER_SYNC */
 
330
         (0 << 28) |            /* DP_HOST_TRIPLE_EN */
 
331
         (0 << 29) |            /* FAST_FILL_EN */
 
332
         (0 << 30) |            /* BLOCK_WRITE_EN */
 
333
         0)
 
334
    }
 
335
};
 
336
 
 
337
#define NACCELREG (sizeof mach64AccelReg / sizeof mach64AccelReg[0])
 
338
 
 
339
static void
 
340
mach64WaitMarker (ScreenPtr pScreen, int marker)
 
341
{
 
342
    KdScreenPriv(pScreen);
 
343
    mach64CardInfo(pScreenPriv);
 
344
    reg = mach64c->reg;
 
345
    
 
346
    mach64WaitIdle (reg);
 
347
}
 
348
 
 
349
static Bool
 
350
mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait)
 
351
{
 
352
    ScreenPtr pScreen = pDst->drawable.pScreen;
 
353
    KdScreenPriv(pScreen);
 
354
    mach64CardInfo(pScreenPriv);
 
355
    CARD32  DST_PITCH;
 
356
    CARD32  DST_OFFSET;
 
357
    CARD32  SRC_PITCH;
 
358
    CARD32  SRC_OFFSET;
 
359
    CARD32  DP_PIX_WIDTH;
 
360
    CARD32  DP_SET_GUI_ENGINE;
 
361
    int     i;
 
362
 
 
363
    for (i = 0; i < NACCELREG; i++)
 
364
        if (mach64AccelReg[i].depth == pDst->drawable.depth &&
 
365
            mach64AccelReg[i].bitsPerPixel == pDst->drawable.bitsPerPixel)
 
366
            break;
 
367
    if (i == NACCELREG)
 
368
        return FALSE;
 
369
    DP_PIX_WIDTH = mach64AccelReg[i].DP_PIX_WIDTH;
 
370
    DP_SET_GUI_ENGINE = mach64AccelReg[i].DP_SET_GUI_ENGINE;
 
371
 
 
372
    reg = mach64c->reg;
 
373
    if (!reg)
 
374
        return FALSE;
 
375
    
 
376
    triple = (pDst->drawable.bitsPerPixel == 24);
 
377
    
 
378
    if (triple)
 
379
    {
 
380
        /* bytes / 8 = bytes >> 3 */
 
381
        DST_PITCH = pDst->devKind >> 3;
 
382
    }
 
383
    else
 
384
    {
 
385
        /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
 
386
        DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel;
 
387
    }
 
388
    
 
389
    /* bytes / 8 */
 
390
    DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
 
391
    
 
392
    mach64WaitAvail(reg, wait + (pSrc ? 5 : 4));
 
393
    reg->DP_SET_GUI_ENGINE = DP_SET_GUI_ENGINE | (combo << 20);
 
394
    reg->DP_PIX_WIDTH = DP_PIX_WIDTH;
 
395
    reg->DST_OFF_PITCH = ((DST_OFFSET << 0) |   /* USR1_DST_OFFSET */
 
396
                          (DST_PITCH << 22) |   /* USR1_DST_PITCH */
 
397
                          0);
 
398
    if (pSrc)
 
399
    {
 
400
        if (triple)
 
401
        {
 
402
            SRC_PITCH = pSrc->devKind >> 3;
 
403
        }
 
404
        else
 
405
        {
 
406
            /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
 
407
            SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel;
 
408
        }
 
409
        /* bytes / 8 */
 
410
        SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
 
411
        
 
412
        reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) |
 
413
                              (SRC_PITCH << 22) |
 
414
                              0);
 
415
    }
 
416
    return TRUE;
 
417
}
 
418
 
 
419
static Bool
 
420
mach64PrepareSolid (PixmapPtr   pPixmap,
 
421
                    int         alu,
 
422
                    Pixel       pm,
 
423
                    Pixel       fg)
 
424
{
 
425
    if (!mach64Setup (pPixmap, 0, 1, 3))
 
426
        return FALSE;
 
427
    reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
 
428
    reg->DP_WRITE_MSK = pm;
 
429
    reg->DP_FRGD_CLR = fg;
 
430
    return TRUE;
 
431
}
 
432
 
 
433
static void
 
434
mach64Solid (int x1, int y1, int x2, int y2)
 
435
{
 
436
    if (triple)
 
437
    {
 
438
        CARD32  traj;
 
439
 
 
440
        x1 *= 3;
 
441
        x2 *= 3;
 
442
 
 
443
        traj = (DST_X_DIR | 
 
444
                DST_Y_DIR |
 
445
                DST_24_ROT_EN | 
 
446
                DST_24_ROT((x1 / 4) % 6));
 
447
        mach64WaitAvail (reg, 1);
 
448
        reg->GUI_TRAJ_CNTL = traj;
 
449
    }
 
450
    mach64WaitAvail(reg,2);
 
451
    reg->DST_X_Y = MACH64_XY(x1,y1);
 
452
    reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1);
 
453
}
 
454
 
 
455
static void
 
456
mach64DoneSolid (void)
 
457
{
 
458
#if SYNC_ALWAYS
 
459
    mach64WaitIdle (reg);
 
460
#endif
 
461
}
 
462
 
 
463
static int copyDx;
 
464
static int copyDy;
 
465
static CARD32   copyCombo;
 
466
 
 
467
static Bool
 
468
mach64PrepareCopy (PixmapPtr    pSrcPixmap,
 
469
                   PixmapPtr    pDstPixmap,
 
470
                   int          dx,
 
471
                   int          dy,
 
472
                   int          alu,
 
473
                   Pixel        pm)
 
474
{
 
475
    copyCombo = 8 | 2 | 1;
 
476
    copyDx = dx;
 
477
    copyDy = dy;
 
478
    
 
479
    /*
 
480
     * Avoid going backwards when copying pixmaps to the screen.
 
481
     * This should reduce tearing somewhat
 
482
     */
 
483
    if (pSrcPixmap == pDstPixmap)
 
484
    {
 
485
        if (dx <= 0)
 
486
            copyCombo &= ~1;
 
487
        if (dy <= 0)
 
488
            copyCombo &= ~2;
 
489
    }
 
490
 
 
491
    if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2))
 
492
        return FALSE;
 
493
    
 
494
    reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
 
495
    reg->DP_WRITE_MSK = pm;
 
496
    return TRUE;
 
497
}
 
498
 
 
499
static void
 
500
mach64Copy (int srcX,
 
501
            int srcY,
 
502
            int dstX,
 
503
            int dstY,
 
504
            int w,
 
505
            int h)
 
506
{
 
507
    if (triple)
 
508
    {
 
509
        CARD32  traj;
 
510
 
 
511
        srcX *= 3;
 
512
        dstX *= 3;
 
513
        w *= 3;
 
514
 
 
515
        traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6);
 
516
        
 
517
        if (copyCombo & 1)
 
518
            traj |= 1;
 
519
        if (copyCombo & 2)
 
520
            traj |= 2;
 
521
        
 
522
        mach64WaitAvail (reg, 1);
 
523
        reg->GUI_TRAJ_CNTL = traj;
 
524
    }
 
525
    if ((copyCombo & 1) == 0)
 
526
    {
 
527
        srcX += w - 1;
 
528
        dstX += w - 1;
 
529
    }
 
530
    if ((copyCombo & 2) == 0)
 
531
    {
 
532
        srcY += h - 1;
 
533
        dstY += h - 1;
 
534
    }
 
535
    mach64WaitAvail (reg, 4);
 
536
    reg->SRC_Y_X = MACH64_YX(srcX, srcY);
 
537
    reg->SRC_WIDTH1 = w;
 
538
    reg->DST_Y_X = MACH64_YX(dstX, dstY);
 
539
    reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h);
 
540
}
 
541
 
 
542
static void
 
543
mach64DoneCopy (void)
 
544
{
 
545
#if SYNC_ALWAYS
 
546
    mach64WaitIdle (reg);
 
547
#endif
 
548
}
 
549
 
 
550
 
 
551
Bool
 
552
mach64DrawInit (ScreenPtr pScreen)
 
553
{
 
554
    KdScreenPriv(pScreen);
 
555
    mach64ScreenInfo(pScreenPriv);
 
556
 
 
557
    memset(&mach64s->kaa, 0, sizeof(KaaScreenInfoRec));
 
558
    mach64s->kaa.waitMarker     = mach64WaitMarker;
 
559
    mach64s->kaa.PrepareSolid   = mach64PrepareSolid;
 
560
    mach64s->kaa.Solid          = mach64Solid;
 
561
    mach64s->kaa.DoneSolid      = mach64DoneSolid;
 
562
    mach64s->kaa.PrepareCopy    = mach64PrepareCopy;
 
563
    mach64s->kaa.Copy           = mach64Copy;
 
564
    mach64s->kaa.DoneCopy       = mach64DoneCopy;
 
565
    mach64s->kaa.offsetAlign    = 64;
 
566
    mach64s->kaa.pitchAlign     = 64;
 
567
    mach64s->kaa.flags          = KAA_OFFSCREEN_PIXMAPS;
 
568
 
 
569
    if (pScreenPriv->screen->fb[0].depth == 4)
 
570
        return FALSE;
 
571
    
 
572
    if (!kaaDrawInit (pScreen, &mach64s->kaa))
 
573
        return FALSE;
 
574
 
 
575
    return TRUE;
 
576
}
 
577
 
 
578
void
 
579
mach64DrawEnable (ScreenPtr pScreen)
 
580
{
 
581
    kaaMarkSync (pScreen);
 
582
}
 
583
 
 
584
void
 
585
mach64DrawDisable (ScreenPtr pScreen)
 
586
{
 
587
}
 
588
 
 
589
void
 
590
mach64DrawFini (ScreenPtr pScreen)
 
591
{
 
592
    kaaDrawFini (pScreen);
 
593
}