2 * Copyright © 2003 Anders Carlsson
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Anders Carlsson not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Anders Carlsson makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #include <kdrive-config.h>
28 CARD8 r128SolidRop
[16] = {
29 /* GXclear */ 0x00, /* 0 */
30 /* GXand */ 0xa0, /* src AND dst */
31 /* GXandReverse */ 0x50, /* src AND NOT dst */
32 /* GXcopy */ 0xf0, /* src */
33 /* GXandInverted*/ 0x0a, /* NOT src AND dst */
34 /* GXnoop */ 0xaa, /* dst */
35 /* GXxor */ 0x5a, /* src XOR dst */
36 /* GXor */ 0xfa, /* src OR dst */
37 /* GXnor */ 0x05, /* NOT src AND NOT dst */
38 /* GXequiv */ 0xa5, /* NOT src XOR dst */
39 /* GXinvert */ 0x55, /* NOT dst */
40 /* GXorReverse */ 0xf5, /* src OR NOT dst */
41 /* GXcopyInverted*/ 0x0f, /* NOT src */
42 /* GXorInverted */ 0xaf, /* NOT src OR dst */
43 /* GXnand */ 0x5f, /* NOT src OR NOT dst */
44 /* GXset */ 0xff, /* 1 */
47 CARD8 r128BltRop
[16] = {
48 /* GXclear */ 0x00, /* 0 */
49 /* GXand */ 0x88, /* src AND dst */
50 /* GXandReverse */ 0x44, /* src AND NOT dst */
51 /* GXcopy */ 0xcc, /* src */
52 /* GXandInverted*/ 0x22, /* NOT src AND dst */
53 /* GXnoop */ 0xaa, /* dst */
54 /* GXxor */ 0x66, /* src XOR dst */
55 /* GXor */ 0xee, /* src OR dst */
56 /* GXnor */ 0x11, /* NOT src AND NOT dst */
57 /* GXequiv */ 0x99, /* NOT src XOR dst */
58 /* GXinvert */ 0x55, /* NOT dst */
59 /* GXorReverse */ 0xdd, /* src OR NOT dst */
60 /* GXcopyInverted*/ 0x33, /* NOT src */
61 /* GXorInverted */ 0xbb, /* NOT src OR dst */
62 /* GXnand */ 0x77, /* NOT src OR NOT dst */
63 /* GXset */ 0xff, /* 1 */
75 while ((fifo_size
= R128_IN32 (mmio
, R128_REG_GUI_STAT
) & 0xfff) < n
)
92 if ((R128_IN32 (mmio
, R128_REG_GUI_STAT
) & R128_GUI_ACTIVE
) == 0)
96 R128_OUT32 (mmio
, R128_REG_PC_NGUI_CTLSTAT
,
97 R128_IN32 (mmio
, R128_REG_PC_NGUI_CTLSTAT
| 0xff));
102 if ((R128_IN32 (mmio
, R128_REG_PC_NGUI_CTLSTAT
) & R128_PC_BUSY
) != R128_PC_BUSY
)
109 r128WaitMarker (ScreenPtr pScreen
, int marker
)
111 KdScreenPriv (pScreen
);
112 r128CardInfo (pScreenPriv
);
114 mmio
= r128c
->reg_base
;
120 r128Setup (ScreenPtr pScreen
, int wait
)
122 KdScreenPriv (pScreen
);
123 r128ScreenInfo (pScreenPriv
);
124 r128CardInfo (pScreenPriv
);
128 mmio
= r128c
->reg_base
;
134 R128_OUT32 (mmio
, R128_REG_DEFAULT_OFFSET
, 0);
135 R128_OUT32 (mmio
, R128_REG_DEFAULT_PITCH
, r128s
->pitch
);
138 R128_OUT32 (mmio
, R128_AUX_SC_CNTL
, 0);
139 R128_OUT32 (mmio
, R128_DEFAULT_SC_BOTTOM_RIGHT
, (R128_DEFAULT_SC_RIGHT_MAX
140 | R128_DEFAULT_SC_BOTTOM_MAX
));
141 R128_OUT32 (mmio
, R128_SC_TOP_LEFT
, 0);
142 R128_OUT32 (mmio
, R128_SC_BOTTOM_RIGHT
, (R128_DEFAULT_SC_RIGHT_MAX
143 | R128_DEFAULT_SC_BOTTOM_MAX
));
144 r128WaitAvail (wait
);
149 r128PrepareSolid (PixmapPtr pPixmap
, int alu
, Pixel pm
, Pixel fg
)
151 KdScreenPriv (pPixmap
->drawable
.pScreen
);
152 r128ScreenInfo (pScreenPriv
);
154 r128Setup (pPixmap
->drawable
.pScreen
, 4);
155 R128_OUT32 (mmio
, R128_REG_DP_GUI_MASTER_CNTL
, r128s
->dp_gui_master_cntl
156 | R128_GMC_BRUSH_SOLID_COLOR
157 | R128_GMC_SRC_DATATYPE_COLOR
158 | (r128SolidRop
[alu
] << R128_GMC_ROP3_SHIFT
));
159 R128_OUT32 (mmio
, R128_REG_DP_BRUSH_FRGD_CLR
, fg
);
160 R128_OUT32 (mmio
, R128_REG_DP_WRITE_MASK
, pm
);
161 R128_OUT32 (mmio
, R128_REG_DP_CNTL
,
162 (R128_DST_X_LEFT_TO_RIGHT
| R128_DST_Y_TOP_TO_BOTTOM
));
168 r128Solid (int x1
, int y1
, int x2
, int y2
)
171 R128_OUT32 (mmio
, R128_REG_DST_Y_X
, (y1
<< 16) | x1
);
172 R128_OUT32 (mmio
, R128_REG_DST_WIDTH_HEIGHT
, ((x2
- x1
) << 16) | (y2
- y1
));
182 r128PrepareCopy (PixmapPtr pSrc
, PixmapPtr pDst
, int dx
, int dy
, int alu
, Pixel pm
)
184 KdScreenPriv (pSrc
->drawable
.pScreen
);
185 r128ScreenInfo (pScreenPriv
);
190 r128Setup (pSrc
->drawable
.pScreen
, 3);
191 R128_OUT32 (mmio
, R128_REG_DP_GUI_MASTER_CNTL
, r128s
->dp_gui_master_cntl
192 | R128_GMC_BRUSH_SOLID_COLOR
193 | R128_GMC_SRC_DATATYPE_COLOR
194 | (r128BltRop
[alu
] << R128_GMC_ROP3_SHIFT
)
195 | R128_DP_SRC_SOURCE_MEMORY
);
196 R128_OUT32 (mmio
, R128_REG_DP_WRITE_MASK
, pm
);
197 R128_OUT32 (mmio
, R128_REG_DP_CNTL
,
198 ((dx
>= 0 ? R128_DST_X_LEFT_TO_RIGHT
: 0)
199 | (dy
>= 0 ? R128_DST_Y_TOP_TO_BOTTOM
: 0)));
206 r128Copy (int srcX
, int srcY
, int dstX
, int dstY
, int w
, int h
)
221 R128_OUT32 (mmio
, R128_REG_SRC_Y_X
, (srcY
<< 16) | srcX
);
222 R128_OUT32 (mmio
, R128_REG_DST_Y_X
, (dstY
<< 16) | dstX
);
223 R128_OUT32 (mmio
, R128_REG_DST_HEIGHT_WIDTH
, (h
<< 16) | w
);
233 r128DrawInit (ScreenPtr pScreen
)
235 KdScreenPriv (pScreen
);
236 r128ScreenInfo (pScreenPriv
);
238 memset(&r128s
->kaa
, 0, sizeof(KaaScreenInfoRec
));
239 r128s
->kaa
.waitMarker
= r128WaitMarker
;
240 r128s
->kaa
.PrepareSolid
= r128PrepareSolid
;
241 r128s
->kaa
.Solid
= r128Solid
;
242 r128s
->kaa
.DoneSolid
= r128DoneSolid
;
243 r128s
->kaa
.PrepareCopy
= r128PrepareCopy
;
244 r128s
->kaa
.Copy
= r128Copy
;
245 r128s
->kaa
.DoneCopy
= r128DoneCopy
;
247 if (!kaaDrawInit (pScreen
, &r128s
->kaa
))
254 r128DrawEnable (ScreenPtr pScreen
)
256 KdScreenPriv (pScreen
);
257 r128ScreenInfo (pScreenPriv
);
259 r128s
->pitch
= pScreenPriv
->screen
->width
>> 3;
261 switch (pScreenPriv
->screen
->fb
[0].depth
) {
278 FatalError ("unsupported pixel format");
281 r128s
->dp_gui_master_cntl
= ((r128s
->datatype
<< R128_GMC_DST_DATATYPE_SHIFT
)
282 | R128_GMC_CLR_CMP_CNTL_DIS
283 | R128_GMC_AUX_CLIP_DIS
);
285 kaaMarkSync (pScreen
);
289 r128DrawDisable (ScreenPtr pScreen
)
294 r128DrawFini (ScreenPtr pScreen
)