apm_accel.c revision 17a48c7c
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c,v 1.20tsi Exp $ */
2
3#ifdef HAVE_CONFIG_H
4#include "config.h"
5#endif
6
7#include "apm.h"
8#include "miline.h"
9
10/* Defines */
11#define MAXLOOP 1000000
12
13/* Translation from X ROP's to APM ROP's. */
14static unsigned char apmROP[] = {
15  0,
16  0x88,
17  0x44,
18  0xCC,
19  0x22,
20  0xAA,
21  0x66,
22  0xEE,
23  0x11,
24  0x99,
25  0x55,
26  0xDD,
27  0x33,
28  0xBB,
29  0x77,
30  0xFF
31};
32
33
34#include "apm_funcs.c"
35
36#define IOP_ACCESS
37#include "apm_funcs.c"
38
39#define PSZ	24
40#include "apm_funcs.c"
41
42#define PSZ	24
43#define IOP_ACCESS
44#include "apm_funcs.c"
45
46static void
47ApmRemoveStipple(FBAreaPtr area)
48{
49    ((struct ApmStippleCacheRec *)area->devPrivate.ptr)->apmStippleCached = FALSE;
50}
51
52static void
53ApmMoveStipple(FBAreaPtr from, FBAreaPtr to)
54{
55    struct ApmStippleCacheRec *pApm = (struct ApmStippleCacheRec *)to->devPrivate.ptr;
56
57    pApm->apmStippleCache.x = to->box.x1;
58    pApm->apmStippleCache.y += to->box.y1 - from->box.y1;
59    /* TODO : move data */
60}
61
62/*
63 * ApmCacheMonoStipple
64 * because my poor AT3D needs stipples stored linearly in memory.
65 */
66static XAACacheInfoPtr
67ApmCacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
68{
69    APMDECL(pScrn);
70    int		w = pPix->drawable.width, W = (w + 31) & ~31;
71    int		h = pPix->drawable.height;
72    int		i, j, dwords, mem, width, funcNo;
73    FBAreaPtr	draw;
74    struct ApmStippleCacheRec	*pCache;
75    unsigned char	*srcPtr;
76    CARD32		*dstPtr;
77    static StippleScanlineProcPtr *StippleTab = NULL;
78
79    if (!StippleTab)
80        StippleTab = XAAGetStippleScanlineFuncMSBFirst();
81
82    for (i = 0; i < APM_CACHE_NUMBER; i++)
83	if ((pApm->apmCache[i].apmStippleCache.serialNumber == pPix->drawable.serialNumber)
84		&& pApm->apmCache[i].apmStippleCached &&
85		(pApm->apmCache[i].apmStippleCache.fg == -1) &&
86		(pApm->apmCache[i].apmStippleCache.bg == -1)) {
87	    pApm->apmCache[i].apmStippleCache.trans_color = -1;
88	    return &pApm->apmCache[i].apmStippleCache;
89	}
90    if ((i = ++pApm->apmCachePtr) >= APM_CACHE_NUMBER)
91	i = pApm->apmCachePtr = 0;
92    pCache = &pApm->apmCache[i];
93    if (pCache->apmStippleCached) {
94	pCache->apmStippleCached = FALSE;
95	xf86FreeOffscreenArea(pCache->area);
96    }
97
98    draw = xf86AllocateLinearOffscreenArea(pApm->pScreen, (W * h + 7) / 8,
99				    (pApm->CurrentLayout.mask32 + 1) << 1,
100				    ApmMoveStipple, ApmRemoveStipple, pCache);
101    if (!draw)
102	return NULL;	/* Let's hope this will never happen... */
103
104    pCache->area = draw;
105    pCache->apmStippleCache.serialNumber = pPix->drawable.serialNumber;
106    pCache->apmStippleCache.trans_color =
107	pCache->apmStippleCache.bg =
108	pCache->apmStippleCache.fg = -1;
109    pCache->apmStippleCache.orig_w = w;
110    pCache->apmStippleCache.orig_h = h;
111    pCache->apmStippleCache.x = draw->box.x1;
112    pCache->apmStippleCache.y = draw->box.y1 + ((pCache - pApm->apmCache) + 1) * pApm->CurrentLayout.Scanlines;
113    mem = ((draw->box.x2 - draw->box.x1) * (draw->box.y2 - draw->box.y1) *
114			pScrn->bitsPerPixel) / (W * h);
115    width = 2;
116    while (width * width <= mem)
117	width++;
118    width--;
119    pCache->apmStippleCache.w = (width * W + pScrn->bitsPerPixel - 1) /
120			pScrn->bitsPerPixel;
121    pCache->apmStippleCache.h = ((draw->box.x2 - draw->box.x1) *
122			(draw->box.y2 - draw->box.y1)) /
123			pCache->apmStippleCache.w;
124    pCache->apmStippleCached = TRUE;
125
126    if (w < 32) {
127	if (w & (w - 1))	funcNo = 1;
128	else			funcNo = 0;
129    } else			funcNo = 2;
130
131    dstPtr = ((CARD32 *)pApm->FbBase) + (draw->box.x1 +
132			draw->box.y1*pApm->CurrentLayout.bytesPerScanline) / 4;
133    j = 0;
134    dwords = (pCache->apmStippleCache.w * pScrn->bitsPerPixel) / 32;
135    while (j + h <= pCache->apmStippleCache.h) {
136	srcPtr = (unsigned char *)pPix->devPrivate.ptr;
137	for (i = h; --i >= 0; ) {
138	    StippleTab[funcNo](dstPtr, (CARD32 *)srcPtr, 0, w, dwords);
139	    srcPtr += pPix->devKind;
140	    dstPtr += dwords;
141	}
142	j += h;
143    }
144    srcPtr = (unsigned char *)pPix->devPrivate.ptr;
145    for (i = pCache->apmStippleCache.h - j ; --i >= 0; ) {
146	StippleTab[funcNo](dstPtr, (CARD32 *)srcPtr, 0, w, dwords);
147	srcPtr += pPix->devKind;
148	dstPtr += dwords;
149    }
150
151    return &pCache->apmStippleCache;
152}
153
154#if 0
155extern GCOps XAAPixmapOps;
156static RegionPtr (*SaveCopyAreaPixmap)(DrawablePtr, DrawablePtr, GC *, int, int, int, int, int, int);
157
158static RegionPtr
159ApmCopyAreaPixmap(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC,
160		int srcx, int srcy,
161		int width, int height,
162		int dstx, int dsty )
163{
164    register int Scanlines;
165    int is;
166    int id;
167    int sx = 0, sy = 0, dx = 0, dy = 0, pitch;
168    RegionPtr pReg;
169
170    if (APMPTR(xf86Screens[(pGC)->pScreen->myNum])->Chipset == AT3D) {
171	Scanlines = APMPTR(xf86Screens[(pGC)->pScreen->myNum])->CurrentLayout.Scanlines;
172	is = (pSrcDrawable->type == DRAWABLE_PIXMAP) ? APM_GET_PIXMAP_PRIVATE(pSrcDrawable)->num : 0;
173	id = (pDstDrawable->type == DRAWABLE_PIXMAP) ? APM_GET_PIXMAP_PRIVATE(pDstDrawable)->num : 0;
174	if (is) {
175	    sx = pSrcDrawable->x;
176	    sy = pSrcDrawable->y % Scanlines;
177	    pitch = 2 * pSrcDrawable->width;
178	    pSrcDrawable->x = (sx + ((PixmapPtr)pSrcDrawable)->devKind * sy) % pitch;
179	    pSrcDrawable->y = (sx + ((PixmapPtr)pSrcDrawable)->devKind * sy) / pitch;
180	    ((PixmapPtr)pSrcDrawable)->devKind = pitch;
181	    pSrcDrawable->depth = 16;
182	}
183	if (id) {
184	    dx = pDstDrawable->x;
185	    dy = pDstDrawable->y % Scanlines;
186	    pitch = 2 * pDstDrawable->width;
187	    pDstDrawable->x = (dx + ((PixmapPtr)pDstDrawable)->devKind * dy) % pitch;
188	    pDstDrawable->y = (dx + ((PixmapPtr)pDstDrawable)->devKind * dy) / pitch;
189	    ((PixmapPtr)pDstDrawable)->devKind = pitch;
190	    pDstDrawable->depth = 16;
191	}
192	pReg = (*SaveCopyAreaPixmap)(pSrcDrawable, pDstDrawable, pGC,
193					    srcx, srcy % Scanlines,
194					    width, height,
195					    dstx, dsty % Scanlines);
196	if (is) {
197	    pSrcDrawable->x = sx;
198	    pSrcDrawable->y = sy + is * Scanlines;
199	}
200	if (id) {
201	    pDstDrawable->x = dx;
202	    pDstDrawable->y = dy + id * Scanlines;
203	}
204	return pReg;
205    }
206    return (*SaveCopyAreaPixmap)(pSrcDrawable, pDstDrawable, pGC,
207					srcx, srcy,
208					width, height,
209					dstx, dsty);
210}
211#endif
212
213void ApmAccelReserveSpace(ApmPtr pApm)
214{
215    memType	mem, ScratchMemOffset;
216
217    mem			= xf86Screens[pApm->pScreen->myNum]->videoRam << 10;
218    /*
219     * Reserve at least four lines for mono to color expansion
220     */
221    ScratchMemOffset	= ((mem - pApm->OffscreenReserved) /
222			pApm->CurrentLayout.bytesPerScanline - 4) *
223			pApm->CurrentLayout.bytesPerScanline;
224    pApm->ScratchMemSize= mem - ScratchMemOffset - pApm->OffscreenReserved;
225    pApm->ScratchMemPtr	= pApm->ScratchMemOffset
226			= (memType)pApm->FbBase + ScratchMemOffset;
227    pApm->ScratchMemEnd	= (memType)pApm->FbBase + mem - pApm->OffscreenReserved;
228}
229
230/*********************************************************************************************/
231
232int
233ApmAccelInit(ScreenPtr pScreen)
234{
235    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
236    APMDECL(pScrn);
237    XAAInfoRecPtr	pXAAinfo;
238    BoxRec		AvailFBArea;
239    memType		mem, ScratchMemOffset;
240    int			i, stat;
241
242    pApm->AccelInfoRec	= pXAAinfo = XAACreateInfoRec();
243    if (!pXAAinfo)
244	return FALSE;
245
246    mem			= pScrn->videoRam << 10;
247    ScratchMemOffset	= pApm->ScratchMemOffset - (memType)pApm->FbBase;
248    switch (pApm->CurrentLayout.bitsPerPixel) {
249    case 8:
250    case 24:
251	pApm->ScratchMemWidth =
252		(mem - ScratchMemOffset - pApm->OffscreenReserved) / 1;
253	pApm->ScratchMem =
254		((ScratchMemOffset & 0xFFF000) << 4) |
255		    (ScratchMemOffset & 0xFFF);
256	break;
257
258    case 16:
259	pApm->ScratchMemWidth =
260		(mem - ScratchMemOffset - pApm->OffscreenReserved) / 2;
261	pApm->ScratchMem =
262		((ScratchMemOffset & 0xFFE000) << 3) |
263		    ((ScratchMemOffset & 0x1FFE) >> 1);
264	break;
265
266    case 32:
267	pApm->ScratchMemWidth =
268		(mem - ScratchMemOffset - pApm->OffscreenReserved) / 4;
269	pApm->ScratchMem =
270		((ScratchMemOffset & 0xFFC000) << 2) |
271		    ((ScratchMemOffset & 0x3FFC) >> 2);
272	break;
273    }
274    pApm->OffscreenReserved = mem - ScratchMemOffset;
275
276    /*
277     * Abort
278     */
279    if (pApm->Chipset == AP6422)
280	i = 4;
281    else
282	i = 8;
283    if (pApm->noLinear) {
284	stat = RDXL_IOP(0x1FC);
285	while ((stat & (STATUS_HOSTBLTBUSY | STATUS_ENGINEBUSY)) ||
286		((stat & STATUS_FIFO) < i)) {
287	    WRXB_IOP(0x1FC, 0);
288	    stat = RDXL_IOP(0x1FC);
289	}
290    }
291    else {
292	stat = RDXL_M(0x1FC);
293	while ((stat & (STATUS_HOSTBLTBUSY | STATUS_ENGINEBUSY)) ||
294		((stat & STATUS_FIFO) < i)) {
295	    WRXB_M(0x1FC, 0);
296	    stat = RDXL_M(0x1FC);
297	}
298    }
299
300    /* Setup current register values */
301    for (i = 0; i < sizeof(pApm->regcurr) / 4; i++)
302	((CARD32 *)curr)[i] = RDXL(0x30 + 4*i);
303
304    SETCLIP_CTRL(1);
305    SETCLIP_CTRL(0);
306    SETBYTEMASK(0x00);
307    SETBYTEMASK(0xFF);
308    SETROP(ROP_S_xor_D);
309    SETROP(ROP_S);
310
311#if 0
312    if (XAAPixmapOps.CopyArea != ApmCopyAreaPixmap) {
313	SaveCopyAreaPixmap = XAAPixmapOps.CopyArea;
314	XAAPixmapOps.CopyArea = ApmCopyAreaPixmap;
315    }
316#endif
317
318    ApmSetupXAAInfo(pApm, pXAAinfo);
319
320    if (!pApm->noLinear) {
321	pApm->SetupForSolidFill			= ApmSetupForSolidFill;
322	pApm->SubsequentSolidFillRect		= ApmSubsequentSolidFillRect;
323	pApm->SetupForSolidFill24		= ApmSetupForSolidFill24;
324	pApm->SubsequentSolidFillRect24		= ApmSubsequentSolidFillRect24;
325	pApm->SetupForScreenToScreenCopy	= ApmSetupForScreenToScreenCopy;
326	pApm->SubsequentScreenToScreenCopy	= ApmSubsequentScreenToScreenCopy;
327	pApm->SetupForScreenToScreenCopy24	= ApmSetupForScreenToScreenCopy24;
328	pApm->SubsequentScreenToScreenCopy24	= ApmSubsequentScreenToScreenCopy24;
329    }
330    else {
331	pApm->SetupForSolidFill			= ApmSetupForSolidFill_IOP;
332	pApm->SubsequentSolidFillRect		= ApmSubsequentSolidFillRect_IOP;
333	pApm->SetupForSolidFill24		= ApmSetupForSolidFill24_IOP;
334	pApm->SubsequentSolidFillRect24		= ApmSubsequentSolidFillRect24_IOP;
335	pApm->SetupForScreenToScreenCopy	= ApmSetupForScreenToScreenCopy_IOP;
336	pApm->SubsequentScreenToScreenCopy	= ApmSubsequentScreenToScreenCopy_IOP;
337	pApm->SetupForScreenToScreenCopy24	= ApmSetupForScreenToScreenCopy24_IOP;
338	pApm->SubsequentScreenToScreenCopy24	= ApmSubsequentScreenToScreenCopy24_IOP;
339    }
340
341    /*
342     * Init Rush extension.
343     * Must be initialized once per generation.
344     */
345#ifdef XF86RUSH_EXT
346    if (!pApm->CreatePixmap) {
347	pApm->CreatePixmap	= pScreen->CreatePixmap;
348	pApm->DestroyPixmap	= pScreen->DestroyPixmap;
349    }
350    XFree86RushExtensionInit(pScreen);
351#endif
352
353    /* Pixmap cache setup */
354    pXAAinfo->CachePixelGranularity = (pApm->CurrentLayout.mask32 + 1) << 1;
355    AvailFBArea.x1 = 0;
356    AvailFBArea.y1 = 0;
357    AvailFBArea.x2 = pScrn->displayWidth;
358    AvailFBArea.y2 = (pScrn->videoRam * 1024 - pApm->OffscreenReserved) /
359	(pScrn->displayWidth * ((pScrn->bitsPerPixel + 7) >> 3));
360
361    xf86InitFBManager(pScreen, &AvailFBArea);
362
363    bzero(pApm->apmCache, sizeof pApm->apmCache);
364
365    return XAAInit(pScreen, pXAAinfo);
366}
367
368void ApmSetupXAAInfo(ApmPtr pApm, XAAInfoRecPtr pXAAinfo)
369{
370    pApm->CurrentLayout.Setup_DEC = 0;
371    switch(pApm->CurrentLayout.bitsPerPixel)
372    {
373      case 8:
374           pApm->CurrentLayout.Setup_DEC |= DEC_BITDEPTH_8;
375           break;
376      case 16:
377           pApm->CurrentLayout.Setup_DEC |= DEC_BITDEPTH_16;
378           break;
379      case 24:
380	   /* Note : in 24 bpp, the accelerator wants linear coordinates */
381           pApm->CurrentLayout.Setup_DEC |= DEC_BITDEPTH_24 | DEC_SOURCE_LINEAR |
382				   DEC_DEST_LINEAR;
383           break;
384      case 32:
385           pApm->CurrentLayout.Setup_DEC |= DEC_BITDEPTH_32;
386           break;
387      default:
388           xf86DrvMsg(xf86Screens[pApm->pScreen->myNum]->scrnIndex, X_WARNING,
389		    "Cannot set up drawing engine control for bpp = %d\n",
390		    pApm->CurrentLayout.bitsPerPixel);
391           break;
392    }
393
394    switch(pApm->CurrentLayout.displayWidth)
395    {
396      case 640:
397           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_640;
398           break;
399      case 800:
400           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_800;
401           break;
402      case 1024:
403           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_1024;
404           break;
405      case 1152:
406           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_1152;
407           break;
408      case 1280:
409           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_1280;
410           break;
411      case 1600:
412           pApm->CurrentLayout.Setup_DEC |= DEC_WIDTH_1600;
413           break;
414      default:
415           xf86DrvMsg(xf86Screens[pApm->pScreen->myNum]->scrnIndex, X_WARNING,
416		       "Cannot set up drawing engine control "
417		       "for screen width = %d\n", pApm->CurrentLayout.displayWidth);
418           break;
419    }
420
421    if (!pXAAinfo)
422	return;
423
424    /*
425     * Set up the main acceleration flags.
426     */
427    pXAAinfo->Flags = PIXMAP_CACHE | LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS;
428    pXAAinfo->CacheMonoStipple = ApmCacheMonoStipple;
429
430    if (pApm->CurrentLayout.bitsPerPixel != 24) {
431	if (!pApm->noLinear) {
432#define	XAA(s)		pXAAinfo->s = Apm##s
433	    if (pApm->Chipset < AT24)
434		pXAAinfo->Sync = ApmSync6422;
435	    else
436		XAA(Sync);
437
438	    /* Accelerated filled rectangles */
439	    pXAAinfo->SolidFillFlags = NO_PLANEMASK;
440	    XAA(SetupForSolidFill);
441	    XAA(SubsequentSolidFillRect);
442
443	    /* Accelerated screen to screen color expansion */
444	    pXAAinfo->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK;
445	    XAA(SetupForScreenToScreenColorExpandFill);
446	    XAA(SubsequentScreenToScreenColorExpandFill);
447
448#if 0
449	    The constraints of the transfer range are incompatible with the
450	    XAA architecture. I rewrote the XAA functions using ImageWrite
451	    /* Accelerated CPU to screen color expansion */
452	    if ((pApm->Chipset == AT24 && pApm->ChipRev >= 4) ||
453		    pApm->Chipset == AT3D) {
454		pXAAinfo->CPUToScreenColorExpandFillFlags =
455		  NO_PLANEMASK | SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD
456		  | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING |
457		  LEFT_EDGE_CLIPPING_NEGATIVE_X | SYNC_AFTER_COLOR_EXPAND;
458		XAA(SetupForCPUToScreenColorExpandFill);
459		XAA(SubsequentCPUToScreenColorExpandFill);
460		pXAAinfo->ColorExpandBase	= pApm->BltMap;
461		pXAAinfo->ColorExpandRange	= (pApm->Chipset >= AT3D) ? 32*1024 : 30*1024;
462	    }
463
464	    /* Accelerated image transfers */
465	    pXAAinfo->ImageWriteFlags	=
466			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
467			    SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD |
468			    LEFT_EDGE_CLIPPING_NEGATIVE_X |
469			    SYNC_AFTER_IMAGE_WRITE;
470	    pXAAinfo->ImageWriteBase	= pApm->BltMap;
471	    pXAAinfo->ImageWriteRange	= (pApm->Chipset >= AT3D) ? 32*1024 : 30*1024;
472	    XAA(SetupForImageWrite);
473	    XAA(SubsequentImageWriteRect);
474#endif
475	    pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
476			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
477	    XAA(WritePixmap);
478	    pXAAinfo->FillImageWriteRectsFlags	=
479			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
480			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
481	    XAA(FillImageWriteRects);
482	    pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
483			    LEFT_EDGE_CLIPPING_NEGATIVE_X |
484			    BIT_ORDER_IN_BYTE_LSBFIRST;
485	    XAA(WriteBitmap);
486	    pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
487			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
488	    XAA(TEGlyphRenderer);
489
490	    /* Accelerated screen-screen bitblts */
491	    pXAAinfo->ScreenToScreenCopyFlags = NO_PLANEMASK;
492	    XAA(SetupForScreenToScreenCopy);
493	    XAA(SubsequentScreenToScreenCopy);
494
495	    /* Accelerated Line drawing */
496	    pXAAinfo->SolidLineFlags = NO_PLANEMASK | HARDWARE_CLIP_LINE;
497	    XAA(SetClippingRectangle);
498	    pXAAinfo->SolidBresenhamLineErrorTermBits = 15;
499
500	    if (pApm->Chipset >= AT24) {
501		XAA(SubsequentSolidBresenhamLine);
502
503		/* Pattern fill */
504		pXAAinfo->Mono8x8PatternFillFlags = NO_PLANEMASK |
505				HARDWARE_PATTERN_PROGRAMMED_BITS |
506				HARDWARE_PATTERN_SCREEN_ORIGIN;
507		XAA(SetupForMono8x8PatternFill);
508		XAA(SubsequentMono8x8PatternFillRect);
509		if (pApm->CurrentLayout.bitsPerPixel == 8) {
510		    pXAAinfo->Color8x8PatternFillFlags = NO_PLANEMASK |
511				    HARDWARE_PATTERN_SCREEN_ORIGIN;
512		    XAA(SetupForColor8x8PatternFill);
513		    XAA(SubsequentColor8x8PatternFillRect);
514		}
515	    }
516	    else
517		pXAAinfo->SubsequentSolidBresenhamLine =
518		    ApmSubsequentSolidBresenhamLine6422;
519#undef XAA
520	}
521	else {
522#define	XAA(s)		pXAAinfo->s = Apm##s##_IOP
523	    if (pApm->Chipset < AT24)
524		pXAAinfo->Sync = ApmSync6422_IOP;
525	    else
526		XAA(Sync);
527
528	    /* Accelerated filled rectangles */
529	    pXAAinfo->SolidFillFlags = NO_PLANEMASK;
530	    XAA(SetupForSolidFill);
531	    XAA(SubsequentSolidFillRect);
532
533	    /* Accelerated screen to screen color expansion */
534	    pXAAinfo->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK;
535	    XAA(SetupForScreenToScreenColorExpandFill);
536	    XAA(SubsequentScreenToScreenColorExpandFill);
537
538#if 0
539	    The constraints of the transfer range are incompatible with the
540	    XAA architecture. I rewrote the XAA functions using ImageWrite
541	    /* Accelerated CPU to screen color expansion */
542	    if ((pApm->Chipset == AT24 && pApm->ChipRev >= 4) ||
543		    pApm->Chipset == AT3D) {
544		pXAAinfo->CPUToScreenColorExpandFillFlags =
545		  NO_PLANEMASK | SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD
546		  | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING |
547		  LEFT_EDGE_CLIPPING_NEGATIVE_X | SYNC_AFTER_COLOR_EXPAND;
548		XAA(SetupForCPUToScreenColorExpandFill);
549		XAA(SubsequentCPUToScreenColorExpandFill);
550		pXAAinfo->ColorExpandBase	= pApm->BltMap;
551		pXAAinfo->ColorExpandRange	= (pApm->Chipset >= AT3D) ? 32*1024 : 30*1024;
552	    }
553
554	    /* Accelerated image transfers */
555	    pXAAinfo->ImageWriteFlags	=
556			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
557			    SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD;
558	    pXAAinfo->ImageWriteBase	= pApm->BltMap;
559	    pXAAinfo->ImageWriteRange	= (pApm->Chipset >= AT3D) ? 32*1024 : 30*1024;
560	    XAA(SetupForImageWrite);
561	    XAA(SubsequentImageWriteRect);
562#endif
563	    pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
564			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
565	    XAA(WritePixmap);
566	    pXAAinfo->FillImageWriteRectsFlags	=
567			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
568			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
569	    XAA(FillImageWriteRects);
570	    pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
571			    LEFT_EDGE_CLIPPING_NEGATIVE_X |
572			    BIT_ORDER_IN_BYTE_LSBFIRST;
573	    XAA(WriteBitmap);
574	    pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
575			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
576	    XAA(TEGlyphRenderer);
577
578	    /* Accelerated screen-screen bitblts */
579	    pXAAinfo->ScreenToScreenCopyFlags = NO_PLANEMASK;
580	    XAA(SetupForScreenToScreenCopy);
581	    XAA(SubsequentScreenToScreenCopy);
582
583	    /* Accelerated Line drawing */
584	    pXAAinfo->SolidLineFlags = NO_PLANEMASK | HARDWARE_CLIP_LINE;
585	    XAA(SetClippingRectangle);
586	    pXAAinfo->SolidBresenhamLineErrorTermBits = 15;
587
588	    if (pApm->Chipset >= AT24) {
589		XAA(SubsequentSolidBresenhamLine);
590
591		/* Pattern fill */
592		pXAAinfo->Mono8x8PatternFillFlags = NO_PLANEMASK |
593				HARDWARE_PATTERN_PROGRAMMED_BITS |
594				HARDWARE_PATTERN_SCREEN_ORIGIN;
595		XAA(SetupForMono8x8PatternFill);
596		XAA(SubsequentMono8x8PatternFillRect);
597		if (pApm->CurrentLayout.bitsPerPixel == 8) {
598		    pXAAinfo->Color8x8PatternFillFlags = NO_PLANEMASK |
599				    HARDWARE_PATTERN_SCREEN_ORIGIN;
600		    XAA(SetupForColor8x8PatternFill);
601		    XAA(SubsequentColor8x8PatternFillRect);
602		}
603	    }
604	    else
605		pXAAinfo->SubsequentSolidBresenhamLine =
606		    ApmSubsequentSolidBresenhamLine6422_IOP;
607#undef XAA
608	}
609    }
610    else {
611	if (!pApm->noLinear) {
612#define	XAA(s)		pXAAinfo->s = Apm##s##24
613	    XAA(Sync);
614
615	    /* Accelerated filled rectangles */
616	    pXAAinfo->SolidFillFlags = NO_PLANEMASK;
617	    XAA(SetupForSolidFill);
618	    XAA(SubsequentSolidFillRect);
619
620#if 0
621	    /* Accelerated screen to screen color expansion */
622	    pXAAinfo->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK;
623	    XAA(SetupForScreenToScreenColorExpandFill);
624	    XAA(SubsequentScreenToScreenColorExpandFill);
625
626#if 0
627	    The constraints of the transfer range are incompatible with the
628	    XAA architecture. I rewrote the XAA functions using ImageWrite
629	    /* Accelerated CPU to screen color expansion */
630	    if (pApm->Chipset == AT3D && pApm->ChipRev >= 4) {
631		pXAAinfo->CPUToScreenColorExpandFillFlags =
632		  NO_PLANEMASK | SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD
633		  | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING |
634		  LEFT_EDGE_CLIPPING_NEGATIVE_X | SYNC_AFTER_COLOR_EXPAND;
635		XAA(SetupForCPUToScreenColorExpandFill);
636		XAA(SubsequentCPUToScreenColorExpandFill);
637		pXAAinfo->ColorExpandBase	= pApm->BltMap;
638		pXAAinfo->ColorExpandRange	= 32*1024;
639	    }
640
641	    /* Accelerated image transfers */
642	    pXAAinfo->ImageWriteFlags	=
643			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
644			    SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD |
645			    SYNC_AFTER_IMAGE_WRITE;
646	    pXAAinfo->ImageWriteBase	= pApm->BltMap;
647	    pXAAinfo->ImageWriteRange	= 32*1024;
648	    XAA(SetupForImageWrite);
649	    XAA(SubsequentImageWriteRect);
650#endif
651	    pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
652			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
653	    XAA(WritePixmap);
654	    pXAAinfo->FillImageWriteRectsFlags	=
655			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
656			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
657	    XAA(FillImageWriteRects);
658	    pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
659			    LEFT_EDGE_CLIPPING_NEGATIVE_X |
660			    BIT_ORDER_IN_BYTE_LSBFIRST;
661	    XAA(WriteBitmap);
662	    pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
663			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
664	    XAA(TEGlyphRenderer);
665
666	    /* Accelerated Line drawing */
667	    pXAAinfo->SolidLineFlags = NO_PLANEMASK | HARDWARE_CLIP_LINE;
668	    XAA(SubsequentSolidBresenhamLine);
669	    XAA(SetClippingRectangle);
670	    pXAAinfo->SolidBresenhamLineErrorTermBits = 15;
671
672	    /* Pattern fill */
673	    pXAAinfo->Mono8x8PatternFillFlags = NO_PLANEMASK | NO_TRANSPARENCY |
674			    HARDWARE_PATTERN_PROGRAMMED_BITS |
675			    HARDWARE_PATTERN_SCREEN_ORIGIN;
676	    XAA(SetupForMono8x8PatternFill);
677	    XAA(SubsequentMono8x8PatternFillRect);
678#endif
679
680	    /* Accelerated screen-screen bitblts */
681	    pXAAinfo->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY;
682	    XAA(SetupForScreenToScreenCopy);
683	    XAA(SubsequentScreenToScreenCopy);
684#undef XAA
685	}
686	else {
687#define	XAA(s)		pXAAinfo->s = Apm##s##24##_IOP
688	    XAA(Sync);
689
690	    /* Accelerated filled rectangles */
691	    pXAAinfo->SolidFillFlags = NO_PLANEMASK;
692	    XAA(SetupForSolidFill);
693	    XAA(SubsequentSolidFillRect);
694
695#if 0
696	    /* Accelerated screen to screen color expansion */
697	    pXAAinfo->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK;
698	    XAA(SetupForScreenToScreenColorExpandFill);
699	    XAA(SubsequentScreenToScreenColorExpandFill);
700
701#if 0
702	    The constraints of the transfer range are incompatible with the
703	    XAA architecture. I rewrote the XAA functions using ImageWrite
704	    /* Accelerated CPU to screen color expansion */
705	    if (pApm->Chipset == AT3D && pApm->ChipRev >= 4) {
706		pXAAinfo->CPUToScreenColorExpandFillFlags =
707		  NO_PLANEMASK | SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD
708		  | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING |
709		  LEFT_EDGE_CLIPPING_NEGATIVE_X | SYNC_AFTER_COLOR_EXPAND;
710		XAA(SetupForCPUToScreenColorExpandFill);
711		XAA(SubsequentCPUToScreenColorExpandFill);
712		pXAAinfo->ColorExpandBase	= pApm->BltMap;
713		pXAAinfo->ColorExpandRange	= 32*1024;
714	    }
715
716	    /* Accelerated image transfers */
717	    pXAAinfo->ImageWriteFlags	=
718			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
719			    SCANLINE_PAD_DWORD | CPU_TRANSFER_PAD_QWORD;
720	    pXAAinfo->ImageWriteBase	= pApm->BltMap;
721	    pXAAinfo->ImageWriteRange	= 32*1024;
722	    XAA(SetupForImageWrite);
723	    XAA(SubsequentImageWriteRect);
724#endif
725	    pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
726			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
727	    XAA(WritePixmap);
728	    pXAAinfo->FillImageWriteRectsFlags	=
729			    LEFT_EDGE_CLIPPING | NO_PLANEMASK |
730			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
731	    XAA(FillImageWriteRects);
732	    pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
733			    LEFT_EDGE_CLIPPING_NEGATIVE_X |
734			    BIT_ORDER_IN_BYTE_LSBFIRST;
735	    XAA(WriteBitmap);
736	    pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
737			    LEFT_EDGE_CLIPPING_NEGATIVE_X;
738	    XAA(TEGlyphRenderer);
739
740	    /* Accelerated Line drawing */
741	    pXAAinfo->SolidLineFlags = NO_PLANEMASK | HARDWARE_CLIP_LINE;
742	    XAA(SubsequentSolidBresenhamLine);
743	    XAA(SetClippingRectangle);
744	    pXAAinfo->SolidBresenhamLineErrorTermBits = 15;
745
746	    /* Pattern fill */
747	    pXAAinfo->Mono8x8PatternFillFlags = NO_PLANEMASK | NO_TRANSPARENCY |
748			    HARDWARE_PATTERN_PROGRAMMED_BITS |
749			    HARDWARE_PATTERN_SCREEN_ORIGIN;
750	    XAA(SetupForMono8x8PatternFill);
751	    XAA(SubsequentMono8x8PatternFillRect);
752#endif
753
754	    /* Accelerated screen-screen bitblts */
755	    pXAAinfo->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY;
756	    XAA(SetupForScreenToScreenCopy);
757	    XAA(SubsequentScreenToScreenCopy);
758#undef XAA
759	}
760    }
761}
762