1#ifdef HAVE_XORG_CONFIG_H
2#include <xorg-config.h>
3#endif
4
5#include <string.h>
6
7#include "misc.h"
8#include "xf86.h"
9#include "xf86_OSproc.h"
10
11#include <X11/X.h>
12#include "scrnintstr.h"
13#include "xf86str.h"
14#include "xaa.h"
15#include "xaalocal.h"
16#include "xf86fbman.h"
17#include "servermd.h"
18
19/*
20 * XAA Config options
21 */
22
23typedef enum {
24    XAAOPT_SCREEN_TO_SCREEN_COPY,
25    XAAOPT_SOLID_FILL_RECT,
26    XAAOPT_SOLID_FILL_TRAP,
27    XAAOPT_SOLID_TWO_POINT_LINE,
28    XAAOPT_SOLID_BRESENHAM_LINE,
29    XAAOPT_SOLID_HORVERT_LINE,
30    XAAOPT_DASHED_TWO_POINT_LINE,
31    XAAOPT_DASHED_BRESENHAM_LINE,
32    XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
33    XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
34    XAAOPT_COL_8x8_PATTERN_FILL_RECT,
35    XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
36    XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
37    XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
38    XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
39    XAAOPT_IMAGE_WRITE_RECT,
40    XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
41    XAAOPT_WRITE_BITMAP,
42    XAAOPT_WRITE_PIXMAP,
43    XAAOPT_PIXMAP_CACHE,
44    XAAOPT_OFFSCREEN_PIXMAPS,
45    XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE
46} XAAOpts;
47
48static const OptionInfoRec XAAOptions[] = {
49    {XAAOPT_SCREEN_TO_SCREEN_COPY,	"XaaNoScreenToScreenCopy",
50				OPTV_BOOLEAN,	{0}, FALSE },
51    {XAAOPT_SOLID_FILL_RECT,		"XaaNoSolidFillRect",
52				OPTV_BOOLEAN,	{0}, FALSE },
53    {XAAOPT_SOLID_FILL_TRAP,		"XaaNoSolidFillTrap",
54				OPTV_BOOLEAN,	{0}, FALSE },
55    {XAAOPT_SOLID_TWO_POINT_LINE,	"XaaNoSolidTwoPointLine",
56				OPTV_BOOLEAN,	{0}, FALSE },
57    {XAAOPT_SOLID_BRESENHAM_LINE,	"XaaNoSolidBresenhamLine",
58				OPTV_BOOLEAN,	{0}, FALSE },
59    {XAAOPT_SOLID_HORVERT_LINE,		"XaaNoSolidHorVertLine",
60				OPTV_BOOLEAN,	{0}, FALSE },
61    {XAAOPT_DASHED_TWO_POINT_LINE,	"XaaNoDashedTwoPointLine",
62				OPTV_BOOLEAN,	{0}, FALSE },
63    {XAAOPT_DASHED_BRESENHAM_LINE,	"XaaNoDashedBresenhamLine",
64				OPTV_BOOLEAN,	{0}, FALSE },
65    {XAAOPT_MONO_8x8_PATTERN_FILL_RECT,	"XaaNoMono8x8PatternFillRect",
66				OPTV_BOOLEAN,	{0}, FALSE },
67    {XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,	"XaaNoMono8x8PatternFillTrap",
68				OPTV_BOOLEAN,	{0}, FALSE },
69    {XAAOPT_COL_8x8_PATTERN_FILL_RECT,	"XaaNoColor8x8PatternFillRect",
70				OPTV_BOOLEAN,	{0}, FALSE },
71    {XAAOPT_COL_8x8_PATTERN_FILL_TRAP,	"XaaNoColor8x8PatternFillTrap",
72				OPTV_BOOLEAN,	{0}, FALSE },
73    {XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,	"XaaNoCPUToScreenColorExpandFill",
74				OPTV_BOOLEAN,	{0}, FALSE },
75    {XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,"XaaNoScanlineCPUToScreenColorExpandFill",
76				OPTV_BOOLEAN,	{0}, FALSE },
77    {XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,	"XaaNoScreenToScreenColorExpandFill",
78				OPTV_BOOLEAN,	{0}, FALSE },
79    {XAAOPT_IMAGE_WRITE_RECT,		"XaaNoImageWriteRect",
80				OPTV_BOOLEAN,	{0}, FALSE },
81    {XAAOPT_SCANLINE_IMAGE_WRITE_RECT,	"XaaNoScanlineImageWriteRect",
82				OPTV_BOOLEAN,	{0}, FALSE },
83    {XAAOPT_WRITE_BITMAP,		"XaaNoWriteBitmap",
84				OPTV_BOOLEAN,	{0}, FALSE },
85    {XAAOPT_WRITE_PIXMAP,		"XaaNoWritePixmap",
86				OPTV_BOOLEAN,	{0}, FALSE },
87    {XAAOPT_PIXMAP_CACHE,		"XaaNoPixmapCache",
88				OPTV_BOOLEAN,	{0}, FALSE },
89    {XAAOPT_OFFSCREEN_PIXMAPS,		"XaaNoOffscreenPixmaps",
90				OPTV_BOOLEAN,	{0}, FALSE },
91    {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps",
92				OPTV_BOOLEAN,   {0}, FALSE },
93    { -1,				NULL,
94				OPTV_NONE,	{0}, FALSE }
95};
96
97static XF86ModuleVersionInfo xaaVersRec =
98{
99	"xaa",
100	MODULEVENDORSTRING,
101	MODINFOSTRING1,
102	MODINFOSTRING2,
103	XORG_VERSION_CURRENT,
104	XAA_VERSION_MAJOR,
105	XAA_VERSION_MINOR,
106	XAA_VERSION_RELEASE,
107	ABI_CLASS_VIDEODRV,		/* requires the video driver ABI */
108	ABI_VIDEODRV_VERSION,
109	MOD_CLASS_NONE,
110	{0,0,0,0}
111};
112
113_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL };
114
115Bool
116XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
117{
118    int index = pScreen->myNum;
119    ScrnInfoPtr pScrn = xf86Screens[index];
120    Bool HaveScreenToScreenCopy = FALSE;
121    Bool HaveColorExpansion = FALSE;
122    Bool HaveScanlineColorExpansion = FALSE;
123    Bool HaveSolidFillRect = FALSE;
124    Bool HaveMono8x8PatternFillRect = FALSE;
125    Bool HaveColor8x8PatternFillRect = FALSE;
126    Bool HaveSolidFillTrap = FALSE;
127    Bool HaveMono8x8PatternFillTrap = FALSE;
128    Bool HaveColor8x8PatternFillTrap = FALSE;
129    Bool HaveSolidTwoPointLine = FALSE;
130    Bool HaveSolidBresenhamLine = FALSE;
131    Bool HaveSolidHorVertLine = FALSE;
132    Bool HaveDashedTwoPointLine = FALSE;
133    Bool HaveDashedBresenhamLine = FALSE;
134    Bool HaveImageWriteRect = FALSE;
135    Bool HaveScanlineImageWriteRect = FALSE;
136    Bool HaveScreenToScreenColorExpandFill = FALSE;
137    OptionInfoPtr options;
138    int is_shared = 0;
139    int i;
140
141    options = xnfalloc(sizeof(XAAOptions));
142    (void)memcpy(options, XAAOptions, sizeof(XAAOptions));
143    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
144
145    infoRec->pScrn = pScrn;
146    infoRec->NeedToSync = FALSE;
147
148    /* must have a Sync function */
149    if(!infoRec->Sync) return FALSE;
150    for(i = 0; i < pScrn->numEntities; i++) {
151        if(xf86IsEntityShared(pScrn->entityList[i])) is_shared = 1;
152    }
153
154    /* If this PCI entity has IS_SHARED_ACCEL set in entityProp
155     * then a RestoreAccelState function is required
156     */
157    if(!infoRec->RestoreAccelState && is_shared) return FALSE;
158
159    if(infoRec->RestoreAccelState) {
160        if(!XAAInitStateWrap(pScreen, infoRec)) return FALSE;
161    }
162
163    if (serverGeneration == 1)
164	xf86DrvMsg(index, X_INFO,
165		"Using XFree86 Acceleration Architecture (XAA)\n");
166
167
168    /************** Low Level *************/
169
170    if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping) {
171	infoRec->ClippingFlags = 0;
172	infoRec->SetClippingRectangle = NULL;
173	infoRec->DisableClipping = NULL;
174    }
175
176    /**** CopyArea ****/
177
178    if(infoRec->SetupForScreenToScreenCopy &&
179       infoRec->SubsequentScreenToScreenCopy &&
180       !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COPY, FALSE)) {
181	HaveScreenToScreenCopy = TRUE;
182    } else {
183	infoRec->ScreenToScreenCopyFlags = 0;
184	infoRec->SetupForScreenToScreenCopy = NULL;
185	infoRec->SubsequentScreenToScreenCopy = NULL;
186    }
187
188    /**** Solid Filled Rects ****/
189
190    if(infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
191       !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_RECT, FALSE)) {
192		HaveSolidFillRect = TRUE;
193	if(infoRec->SubsequentSolidFillTrap &&
194	   !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_TRAP, FALSE))
195		HaveSolidFillTrap = TRUE;
196	else
197		infoRec->SubsequentSolidFillTrap = NULL;
198    } else {
199	infoRec->SolidFillFlags = 0;
200	infoRec->SetupForSolidFill = NULL;
201	infoRec->SubsequentSolidFillRect = NULL;
202	infoRec->SubsequentSolidFillTrap = NULL;
203    }
204
205    /**** Solid lines ****/
206
207    if(infoRec->SetupForSolidLine) {
208	if(infoRec->SubsequentSolidTwoPointLine &&
209		!xf86ReturnOptValBool(options,
210		                      XAAOPT_SOLID_TWO_POINT_LINE, FALSE))
211	    HaveSolidTwoPointLine = TRUE;
212	if(infoRec->SubsequentSolidBresenhamLine &&
213		!xf86ReturnOptValBool(options, XAAOPT_SOLID_BRESENHAM_LINE, FALSE)) {
214	    HaveSolidBresenhamLine = TRUE;
215
216	    if(infoRec->SolidBresenhamLineErrorTermBits)
217		infoRec->SolidBresenhamLineErrorTermBits =
218			~((1 << infoRec->SolidBresenhamLineErrorTermBits) - 1);
219	}
220
221	if(infoRec->SubsequentSolidHorVertLine &&
222		!xf86ReturnOptValBool(options,
223		                      XAAOPT_SOLID_HORVERT_LINE, FALSE))
224	    HaveSolidHorVertLine = TRUE;
225	else if(HaveSolidTwoPointLine) {
226	    infoRec->SubsequentSolidHorVertLine =
227			XAASolidHorVertLineAsTwoPoint;
228	    HaveSolidHorVertLine = TRUE;
229	} else if(HaveSolidBresenhamLine) {
230	    infoRec->SubsequentSolidHorVertLine =
231			XAASolidHorVertLineAsBresenham;
232	    HaveSolidHorVertLine = TRUE;
233	}
234    }
235
236    /* XXX Should this also check for XAAOPT_SOLID_HORVERT_LINE? */
237    if (!HaveSolidTwoPointLine &&
238	!HaveSolidBresenhamLine &&
239	!HaveSolidHorVertLine &&
240	HaveSolidFillRect) {
241	infoRec->SetupForSolidLine = infoRec->SetupForSolidFill;
242	infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsRects;
243	infoRec->SolidLineFlags = infoRec->SolidFillFlags;
244	HaveSolidHorVertLine = TRUE;
245    }
246
247    if (!HaveSolidTwoPointLine)
248	infoRec->SubsequentSolidTwoPointLine = NULL;
249    if (!HaveSolidBresenhamLine)
250	infoRec->SubsequentSolidBresenhamLine = NULL;
251    if (!HaveSolidHorVertLine)
252	infoRec->SubsequentSolidHorVertLine = NULL;
253
254    /* Disable all if nothing left over */
255    if (!HaveSolidTwoPointLine &&
256	!HaveSolidBresenhamLine &&
257	!HaveSolidHorVertLine) {
258	infoRec->SolidLineFlags = 0;
259	infoRec->SetupForSolidLine = NULL;
260    }
261
262    /**** 8x8 Mono Pattern Filled Rects ****/
263
264   if(infoRec->SetupForMono8x8PatternFill &&
265		infoRec->SubsequentMono8x8PatternFillRect &&
266		!xf86ReturnOptValBool(options,
267		                      XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
268		                      FALSE)) {
269	HaveMono8x8PatternFillRect = TRUE;
270	if(infoRec->SubsequentMono8x8PatternFillTrap &&
271		!xf86ReturnOptValBool(options,
272		                      XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
273		                      FALSE))
274		HaveMono8x8PatternFillTrap = TRUE;
275
276        if(infoRec->Mono8x8PatternFillFlags &
277				HARDWARE_PATTERN_PROGRAMMED_BITS) {
278	    infoRec->CanDoMono8x8 = TRUE;
279	} else {	/* others require caching */
280           int min_pitch;
281	   infoRec->PixmapCacheFlags |= CACHE_MONO_8x8;
282
283	   switch(pScrn->bitsPerPixel) {
284	   case 32: min_pitch = 2; break;
285	   case 24: min_pitch = 3; break;
286	   case 16: min_pitch = 4; break;
287	   default: min_pitch = 8; break;
288	   }
289
290           if(min_pitch > infoRec->MonoPatternPitch)
291		infoRec->MonoPatternPitch = min_pitch;
292
293	   if(infoRec->Mono8x8PatternFillFlags &
294				HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
295		if(!infoRec->CacheWidthMono8x8Pattern ||
296		   !infoRec->CacheHeightMono8x8Pattern) {
297			infoRec->CacheWidthMono8x8Pattern =
298						infoRec->MonoPatternPitch;
299			infoRec->CacheHeightMono8x8Pattern = 1;
300		}
301	   } else {
302		int numPerLine = 128/infoRec->MonoPatternPitch;
303
304		if(!infoRec->CacheWidthMono8x8Pattern ||
305		   !infoRec->CacheHeightMono8x8Pattern) {
306			infoRec->CacheWidthMono8x8Pattern =
307				numPerLine * infoRec->MonoPatternPitch;
308			infoRec->CacheHeightMono8x8Pattern =
309				(64 + numPerLine - 1)/numPerLine;
310		}
311	   }
312	}
313   } else {
314	infoRec->Mono8x8PatternFillFlags = 0;
315	infoRec->SetupForMono8x8PatternFill = NULL;
316	infoRec->SubsequentMono8x8PatternFillRect = NULL;
317   }
318
319    /**** Dashed lines ****/
320
321    if(infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) {
322	if(infoRec->SubsequentDashedTwoPointLine &&
323		!xf86ReturnOptValBool(options, XAAOPT_DASHED_TWO_POINT_LINE,
324		                      FALSE))
325	    HaveDashedTwoPointLine = TRUE;
326	if(infoRec->SubsequentDashedBresenhamLine &&
327		!xf86ReturnOptValBool(options, XAAOPT_DASHED_BRESENHAM_LINE,
328		                      FALSE)) {
329	    HaveDashedBresenhamLine = TRUE;
330
331	    if(infoRec->DashedBresenhamLineErrorTermBits)
332		infoRec->DashedBresenhamLineErrorTermBits =
333			~((1 << infoRec->DashedBresenhamLineErrorTermBits) - 1);
334	}
335    }
336
337    if (!HaveDashedTwoPointLine)
338	infoRec->SubsequentDashedTwoPointLine = NULL;
339    if (!HaveDashedBresenhamLine)
340	infoRec->SubsequentDashedBresenhamLine = NULL;
341
342    /* Disable all if nothing left over */
343    if (!HaveDashedTwoPointLine && !HaveDashedBresenhamLine) {
344	infoRec->DashedLineFlags = 0;
345	infoRec->SetupForDashedLine = NULL;
346    }
347
348    /**** 8x8 Color Pattern Filled Rects ****/
349
350   if(infoRec->SetupForColor8x8PatternFill &&
351      infoRec->SubsequentColor8x8PatternFillRect &&
352      !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT, FALSE)) {
353	HaveColor8x8PatternFillRect = TRUE;
354	if(infoRec->SubsequentColor8x8PatternFillTrap &&
355	   !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
356	                         FALSE))
357		HaveColor8x8PatternFillTrap = TRUE;
358	else
359		infoRec->SubsequentColor8x8PatternFillTrap = NULL;
360
361	infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8;
362
363	if(infoRec->Color8x8PatternFillFlags &
364				HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
365	    if(!infoRec->CacheWidthColor8x8Pattern ||
366	       !infoRec->CacheHeightColor8x8Pattern) {
367		infoRec->CacheWidthColor8x8Pattern = 64;
368		infoRec->CacheHeightColor8x8Pattern = 1;
369	    }
370	} else {
371	    if(!infoRec->CacheWidthColor8x8Pattern ||
372	       !infoRec->CacheHeightColor8x8Pattern) {
373		infoRec->CacheWidthColor8x8Pattern = 128;
374		infoRec->CacheHeightColor8x8Pattern = 8;
375	    }
376	}
377   } else {
378	infoRec->Color8x8PatternFillFlags = 0;
379	infoRec->SetupForColor8x8PatternFill = NULL;
380	infoRec->SubsequentColor8x8PatternFillRect = NULL;
381	infoRec->SubsequentColor8x8PatternFillTrap = NULL;
382   }
383
384    /**** Color Expansion ****/
385
386    if(infoRec->SetupForCPUToScreenColorExpandFill &&
387	infoRec->ColorExpandBase &&
388       	infoRec->SubsequentCPUToScreenColorExpandFill &&
389        !xf86ReturnOptValBool(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
390	                      FALSE)) {
391	int dwordsNeeded = pScrn->virtualX;
392
393	infoRec->ColorExpandRange >>= 2;	/* convert to DWORDS */
394	HaveColorExpansion = TRUE;
395
396	if(infoRec->CPUToScreenColorExpandFillFlags &
397				LEFT_EDGE_CLIPPING_NEGATIVE_X)
398	    dwordsNeeded += 31;
399	dwordsNeeded = (dwordsNeeded + 31) >> 5;
400	if(dwordsNeeded > infoRec->ColorExpandRange)
401	   infoRec->CPUToScreenColorExpandFillFlags |= CPU_TRANSFER_BASE_FIXED;
402    } else {
403	infoRec->CPUToScreenColorExpandFillFlags = 0;
404	infoRec->SetupForCPUToScreenColorExpandFill = NULL;
405	infoRec->SubsequentCPUToScreenColorExpandFill = NULL;
406    }
407
408    /**** Scanline Color Expansion ****/
409
410    if(infoRec->SetupForScanlineCPUToScreenColorExpandFill &&
411       infoRec->SubsequentScanlineCPUToScreenColorExpandFill &&
412       infoRec->SubsequentColorExpandScanline &&
413       infoRec->ScanlineColorExpandBuffers &&
414       (infoRec->NumScanlineColorExpandBuffers > 0) &&
415       !xf86ReturnOptValBool(options,
416                             XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
417                             FALSE)) {
418	HaveScanlineColorExpansion = TRUE;
419    } else {
420	infoRec->ScanlineCPUToScreenColorExpandFillFlags = 0;
421	infoRec->SetupForScanlineCPUToScreenColorExpandFill = NULL;
422	infoRec->SubsequentScanlineCPUToScreenColorExpandFill = NULL;
423	infoRec->SubsequentColorExpandScanline = NULL;
424    }
425
426    /**** Screen to Screen Color Expansion ****/
427
428    if(infoRec->SetupForScreenToScreenColorExpandFill &&
429       infoRec->SubsequentScreenToScreenColorExpandFill &&
430       !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
431                             FALSE)) {
432	HaveScreenToScreenColorExpandFill = TRUE;
433	if (!infoRec->CacheColorExpandDensity)
434	    infoRec->CacheColorExpandDensity = 1;
435    } else {
436	infoRec->ScreenToScreenColorExpandFillFlags = 0;
437	infoRec->SetupForScreenToScreenColorExpandFill = NULL;
438	infoRec->SubsequentScreenToScreenColorExpandFill = NULL;
439    }
440
441    /**** Image Writes ****/
442
443    if(infoRec->SetupForImageWrite && infoRec->ImageWriteBase &&
444       infoRec->SubsequentImageWriteRect &&
445       !xf86ReturnOptValBool(options, XAAOPT_IMAGE_WRITE_RECT, FALSE)) {
446
447	infoRec->ImageWriteRange >>= 2;	/* convert to DWORDS */
448	if(infoRec->ImageWriteFlags & CPU_TRANSFER_BASE_FIXED)
449	   infoRec->ImageWriteRange = 0;
450	HaveImageWriteRect = TRUE;
451    } else {
452	infoRec->ImageWriteFlags = 0;
453	infoRec->SetupForImageWrite = NULL;
454	infoRec->SubsequentImageWriteRect = NULL;
455    }
456
457    /**** Scanline Image Writes ****/
458
459    if(infoRec->SetupForScanlineImageWrite &&
460       infoRec->SubsequentScanlineImageWriteRect &&
461       infoRec->SubsequentImageWriteScanline &&
462       infoRec->ScanlineImageWriteBuffers &&
463       (infoRec->NumScanlineImageWriteBuffers > 0) &&
464       !xf86ReturnOptValBool(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
465                             FALSE)) {
466	HaveScanlineImageWriteRect = TRUE;
467    } else {
468	infoRec->ScanlineImageWriteFlags = 0;
469	infoRec->SetupForScanlineImageWrite = NULL;
470	infoRec->SubsequentScanlineImageWriteRect = NULL;
471	infoRec->SubsequentImageWriteScanline = NULL;
472    }
473
474#ifndef __i386__
475   /* XAA makes some unaligned accesses when clipping is not available */
476#  define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X)
477   if(HaveImageWriteRect &&
478      ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
479   {
480        HaveImageWriteRect = FALSE;
481   }
482   if(HaveScanlineImageWriteRect &&
483      ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
484   {
485        HaveScanlineImageWriteRect = FALSE;
486   }
487#endif
488
489    if (serverGeneration == 1) {
490	if(HaveScreenToScreenCopy)
491	    xf86ErrorF("\tScreen to screen bit blits\n");
492	if(HaveSolidFillRect)
493	    xf86ErrorF("\tSolid filled rectangles\n");
494	if(HaveSolidFillTrap)
495	    xf86ErrorF("\tSolid filled trapezoids\n");
496	if(HaveMono8x8PatternFillRect)
497	    xf86ErrorF("\t8x8 mono pattern filled rectangles\n");
498	if(HaveMono8x8PatternFillTrap)
499	    xf86ErrorF("\t8x8 mono pattern filled trapezoids\n");
500	if(HaveColor8x8PatternFillRect)
501	    xf86ErrorF("\t8x8 color pattern filled rectangles\n");
502	if(HaveColor8x8PatternFillTrap)
503	    xf86ErrorF("\t8x8 color pattern filled trapezoids\n");
504
505	if(HaveColorExpansion)
506	    xf86ErrorF("\tCPU to Screen color expansion\n");
507	else if(HaveScanlineColorExpansion)
508	    xf86ErrorF("\tIndirect CPU to Screen color expansion\n");
509
510	if(HaveScreenToScreenColorExpandFill)
511	    xf86ErrorF("\tScreen to Screen color expansion\n");
512
513	if(HaveSolidTwoPointLine || HaveSolidBresenhamLine)
514	    xf86ErrorF("\tSolid Lines\n");
515	else if(HaveSolidHorVertLine)
516	    xf86ErrorF("\tSolid Horizontal and Vertical Lines\n");
517
518	if(HaveDashedTwoPointLine || HaveDashedBresenhamLine)
519	    xf86ErrorF("\tDashed Lines\n");
520
521	if(HaveImageWriteRect)
522	    xf86ErrorF("\tImage Writes\n");
523	else if(HaveScanlineImageWriteRect)
524	    xf86ErrorF("\tScanline Image Writes\n");
525
526    }
527
528#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
529
530    if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
531		xf86ReturnOptValBool(options,
532				     XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE,
533				     FALSE))
534    {
535	XAAMSG("\tOffscreen Pixmaps\n");
536    } else {
537	infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
538    }
539
540
541    /************** Mid Level *************/
542
543    /**** ScreenToScreenBitBlt ****/
544
545    if(infoRec->ScreenToScreenBitBlt) {
546	XAAMSG("\tDriver provided ScreenToScreenBitBlt replacement\n");
547    } else if(HaveScreenToScreenCopy) {
548	infoRec->ScreenToScreenBitBlt = XAAScreenToScreenBitBlt;
549	infoRec->ScreenToScreenBitBltFlags = infoRec->ScreenToScreenCopyFlags;
550    }
551
552    /**** FillSolidRects ****/
553
554    if(infoRec->FillSolidRects) {
555	XAAMSG("\tDriver provided FillSolidRects replacement\n");
556    } else if(HaveSolidFillRect) {
557	infoRec->FillSolidRects = XAAFillSolidRects;
558	infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags;
559    }
560
561    /**** FillSolidSpans ****/
562
563    if(infoRec->FillSolidSpans) {
564	XAAMSG("\tDriver provided FillSolidSpans replacement\n");
565    } else if(HaveSolidFillRect) {
566	infoRec->FillSolidSpans = XAAFillSolidSpans;
567	infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags;
568    }
569
570    /**** FillMono8x8PatternRects ****/
571
572    if(infoRec->FillMono8x8PatternRects) {
573	XAAMSG("\tDriver provided FillMono8x8PatternRects replacement\n");
574    } else if(HaveMono8x8PatternFillRect) {
575	infoRec->FillMono8x8PatternRects =
576	  (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
577	  XAAFillMono8x8PatternRectsScreenOrigin :
578	  XAAFillMono8x8PatternRects;
579
580	infoRec->FillMono8x8PatternRectsFlags =
581			infoRec->Mono8x8PatternFillFlags;
582    }
583
584    /**** FillMono8x8PatternSpans ****/
585
586    if(infoRec->FillMono8x8PatternSpans) {
587	XAAMSG("\tDriver provided FillMono8x8PatternSpans replacement\n");
588    } else if(HaveMono8x8PatternFillRect) {
589	infoRec->FillMono8x8PatternSpans =
590	  (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
591	  XAAFillMono8x8PatternSpansScreenOrigin:
592	  XAAFillMono8x8PatternSpans;
593
594	infoRec->FillMono8x8PatternSpansFlags =
595		infoRec->Mono8x8PatternFillFlags;
596    }
597
598    /**** FillColor8x8Rects ****/
599
600    if(infoRec->FillColor8x8PatternRects) {
601	XAAMSG("\tDriver provided FillColor8x8PatternRects replacement\n");
602    } else if(HaveColor8x8PatternFillRect) {
603	infoRec->FillColor8x8PatternRects =
604	  (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
605	  XAAFillColor8x8PatternRectsScreenOrigin :
606	  XAAFillColor8x8PatternRects;
607
608	infoRec->FillColor8x8PatternRectsFlags =
609			infoRec->Color8x8PatternFillFlags;
610    }
611
612    /**** FillColor8x8Spans ****/
613
614    if(infoRec->FillColor8x8PatternSpans) {
615	XAAMSG("\tDriver provided FillColor8x8PatternSpans replacement\n");
616    } else if(HaveColor8x8PatternFillRect) {
617	infoRec->FillColor8x8PatternSpans =
618	  (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
619	  XAAFillColor8x8PatternSpansScreenOrigin:
620	  XAAFillColor8x8PatternSpans;
621
622	infoRec->FillColor8x8PatternSpansFlags =
623		infoRec->Color8x8PatternFillFlags;
624    }
625
626    /**** FillCacheBltRects ****/
627
628    if(infoRec->FillCacheBltRects) {
629	XAAMSG("\tDriver provided FillCacheBltRects replacement\n");
630    } else if(HaveScreenToScreenCopy) {
631	infoRec->FillCacheBltRects = XAAFillCacheBltRects;
632	infoRec->FillCacheBltRectsFlags = infoRec->ScreenToScreenCopyFlags;
633    }
634
635    /**** FillCacheBltSpans ****/
636
637    if(infoRec->FillCacheBltSpans) {
638	XAAMSG("\tDriver provided FillCacheBltSpans replacement\n");
639    } else if(HaveScreenToScreenCopy) {
640	infoRec->FillCacheBltSpans = XAAFillCacheBltSpans;
641	infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags;
642    }
643
644    /**** FillCacheExpandRects ****/
645
646    if(infoRec->FillCacheExpandRects) {
647	XAAMSG("\tDriver provided FillCacheExpandRects replacement\n");
648    } else if(HaveScreenToScreenColorExpandFill) {
649	infoRec->FillCacheExpandRects = XAAFillCacheExpandRects;
650	infoRec->FillCacheExpandRectsFlags =
651		infoRec->ScreenToScreenColorExpandFillFlags;
652    }
653
654    /**** FillCacheExpandSpans ****/
655
656    if(infoRec->FillCacheExpandSpans) {
657	XAAMSG("\tDriver provided FillCacheExpandSpans replacement\n");
658    } else if(HaveScreenToScreenColorExpandFill) {
659	infoRec->FillCacheExpandSpans = XAAFillCacheExpandSpans;
660	infoRec->FillCacheExpandSpansFlags =
661		infoRec->ScreenToScreenColorExpandFillFlags;
662    }
663
664    /**** FillColorExpandRects ****/
665
666    if(infoRec->FillColorExpandRects) {
667	XAAMSG("\tDriver provided FillColorExpandRects replacement\n");
668    } else if(HaveColorExpansion) {
669	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
670	    if(infoRec->CPUToScreenColorExpandFillFlags &
671					BIT_ORDER_IN_BYTE_MSBFIRST) {
672		if(infoRec->CPUToScreenColorExpandFillFlags &
673					CPU_TRANSFER_BASE_FIXED)
674		    infoRec->FillColorExpandRects =
675			XAAFillColorExpandRects3MSBFirstFixedBase;
676		else
677		    infoRec->FillColorExpandRects =
678			XAAFillColorExpandRects3MSBFirst;
679	    } else {
680		if(infoRec->CPUToScreenColorExpandFillFlags &
681					CPU_TRANSFER_BASE_FIXED)
682		    infoRec->FillColorExpandRects =
683			XAAFillColorExpandRects3LSBFirstFixedBase;
684		else
685		    infoRec->FillColorExpandRects =
686			XAAFillColorExpandRects3LSBFirst;
687	    }
688	} else {
689	    if(infoRec->CPUToScreenColorExpandFillFlags &
690					BIT_ORDER_IN_BYTE_MSBFIRST) {
691		if(infoRec->CPUToScreenColorExpandFillFlags &
692					CPU_TRANSFER_BASE_FIXED)
693		    infoRec->FillColorExpandRects =
694			XAAFillColorExpandRectsMSBFirstFixedBase;
695		else
696		    infoRec->FillColorExpandRects =
697				XAAFillColorExpandRectsMSBFirst;
698	    } else {
699		if(infoRec->CPUToScreenColorExpandFillFlags &
700					CPU_TRANSFER_BASE_FIXED)
701		    infoRec->FillColorExpandRects =
702			XAAFillColorExpandRectsLSBFirstFixedBase;
703		else
704		    infoRec->FillColorExpandRects =
705			XAAFillColorExpandRectsLSBFirst;
706	    }
707	}
708	infoRec->FillColorExpandRectsFlags =
709	    infoRec->CPUToScreenColorExpandFillFlags;
710    } else if(HaveScanlineColorExpansion) {
711	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
712					TRIPLE_BITS_24BPP) {
713	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
714					BIT_ORDER_IN_BYTE_MSBFIRST)
715		infoRec->FillColorExpandRects =
716		    XAAFillScanlineColorExpandRects3MSBFirst;
717	    else
718		infoRec->FillColorExpandRects =
719		    XAAFillScanlineColorExpandRects3LSBFirst;
720	} else {
721	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
722					BIT_ORDER_IN_BYTE_MSBFIRST)
723		infoRec->FillColorExpandRects =
724		    XAAFillScanlineColorExpandRectsMSBFirst;
725	    else
726		infoRec->FillColorExpandRects =
727		    XAAFillScanlineColorExpandRectsLSBFirst;
728	}
729	infoRec->FillColorExpandRectsFlags =
730	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
731    }
732
733    /**** FillColorExpandSpans ****/
734
735    if(infoRec->FillColorExpandSpans) {
736	XAAMSG("\tDriver provided FillColorExpandSpans replacement\n");
737    } else if(HaveColorExpansion) {
738	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
739	    if(infoRec->CPUToScreenColorExpandFillFlags &
740					BIT_ORDER_IN_BYTE_MSBFIRST) {
741		if(infoRec->CPUToScreenColorExpandFillFlags &
742					CPU_TRANSFER_BASE_FIXED)
743		    infoRec->FillColorExpandSpans =
744			XAAFillColorExpandSpans3MSBFirstFixedBase;
745		else
746		    infoRec->FillColorExpandSpans =
747			XAAFillColorExpandSpans3MSBFirst;
748	    } else {
749		if(infoRec->CPUToScreenColorExpandFillFlags &
750					CPU_TRANSFER_BASE_FIXED)
751		    infoRec->FillColorExpandSpans =
752			XAAFillColorExpandSpans3LSBFirstFixedBase;
753		else
754		    infoRec->FillColorExpandSpans =
755			XAAFillColorExpandSpans3LSBFirst;
756	    }
757	} else {
758	    if(infoRec->CPUToScreenColorExpandFillFlags &
759					BIT_ORDER_IN_BYTE_MSBFIRST) {
760		if(infoRec->CPUToScreenColorExpandFillFlags &
761					CPU_TRANSFER_BASE_FIXED)
762		    infoRec->FillColorExpandSpans =
763			XAAFillColorExpandSpansMSBFirstFixedBase;
764		else
765		    infoRec->FillColorExpandSpans =
766				XAAFillColorExpandSpansMSBFirst;
767	    } else {
768		if(infoRec->CPUToScreenColorExpandFillFlags &
769					CPU_TRANSFER_BASE_FIXED)
770		    infoRec->FillColorExpandSpans =
771			XAAFillColorExpandSpansLSBFirstFixedBase;
772		else
773		    infoRec->FillColorExpandSpans =
774			XAAFillColorExpandSpansLSBFirst;
775	    }
776	}
777	infoRec->FillColorExpandSpansFlags =
778	    infoRec->CPUToScreenColorExpandFillFlags;
779    } else if(HaveScanlineColorExpansion) {
780	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
781					TRIPLE_BITS_24BPP) {
782	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
783					BIT_ORDER_IN_BYTE_MSBFIRST)
784		infoRec->FillColorExpandSpans =
785		    XAAFillScanlineColorExpandSpans3MSBFirst;
786	    else
787		infoRec->FillColorExpandSpans =
788		    XAAFillScanlineColorExpandSpans3LSBFirst;
789	} else {
790	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
791					BIT_ORDER_IN_BYTE_MSBFIRST)
792		infoRec->FillColorExpandSpans =
793		    XAAFillScanlineColorExpandSpansMSBFirst;
794	    else
795		infoRec->FillColorExpandSpans =
796		    XAAFillScanlineColorExpandSpansLSBFirst;
797	}
798	infoRec->FillColorExpandSpansFlags =
799	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
800    }
801
802    /**** FillImageWriteRects ****/
803
804    if(infoRec->FillImageWriteRects) {
805	XAAMSG("\tDriver provided FillImageWriteRects replacement\n");
806    } else if(HaveImageWriteRect &&
807		(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
808		(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
809	infoRec->FillImageWriteRects = XAAFillImageWriteRects;
810	infoRec->FillImageWriteRectsFlags = infoRec->ImageWriteFlags;
811    }
812
813    /**** FillScanlineImageWriteRects ****/
814
815    if(!infoRec->FillImageWriteRects) {
816        if(HaveScanlineImageWriteRect &&
817               (infoRec->ScanlineImageWriteFlags &
818                LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
819               (infoRec->ScanlineImageWriteFlags & LEFT_EDGE_CLIPPING)) {
820           infoRec->FillImageWriteRects = XAAFillScanlineImageWriteRects;
821           infoRec->FillImageWriteRectsFlags =
822               infoRec->ScanlineImageWriteFlags;
823       }
824    }
825
826    /**** WriteBitmap ****/
827
828    if(infoRec->WriteBitmap &&
829      !xf86ReturnOptValBool(options, XAAOPT_WRITE_BITMAP, FALSE)) {
830	XAAMSG("\tDriver provided WriteBitmap replacement\n");
831    } else if(HaveColorExpansion) {
832	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
833	    if(infoRec->CPUToScreenColorExpandFillFlags &
834					BIT_ORDER_IN_BYTE_MSBFIRST) {
835		if(infoRec->CPUToScreenColorExpandFillFlags &
836					CPU_TRANSFER_BASE_FIXED)
837		    infoRec->WriteBitmap =
838			XAAWriteBitmapColorExpand3MSBFirstFixedBase;
839		else
840		    infoRec->WriteBitmap = XAAWriteBitmapColorExpand3MSBFirst;
841	    } else {
842		if(infoRec->CPUToScreenColorExpandFillFlags &
843					CPU_TRANSFER_BASE_FIXED)
844		    infoRec->WriteBitmap =
845			XAAWriteBitmapColorExpand3LSBFirstFixedBase;
846		else
847		    infoRec->WriteBitmap = XAAWriteBitmapColorExpand3LSBFirst;
848	    }
849	} else {
850	    if(infoRec->CPUToScreenColorExpandFillFlags &
851					BIT_ORDER_IN_BYTE_MSBFIRST) {
852		if(infoRec->CPUToScreenColorExpandFillFlags &
853					CPU_TRANSFER_BASE_FIXED)
854		    infoRec->WriteBitmap =
855			XAAWriteBitmapColorExpandMSBFirstFixedBase;
856		else
857		    infoRec->WriteBitmap = XAAWriteBitmapColorExpandMSBFirst;
858	    } else {
859		if(infoRec->CPUToScreenColorExpandFillFlags &
860					CPU_TRANSFER_BASE_FIXED)
861		    infoRec->WriteBitmap =
862			XAAWriteBitmapColorExpandLSBFirstFixedBase;
863		else
864		    infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst;
865	    }
866	}
867	infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags;
868    } else if(HaveScanlineColorExpansion) {
869	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
870					TRIPLE_BITS_24BPP) {
871	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
872					BIT_ORDER_IN_BYTE_MSBFIRST)
873		infoRec->WriteBitmap =
874		    XAAWriteBitmapScanlineColorExpand3MSBFirst;
875	    else
876		infoRec->WriteBitmap =
877		    XAAWriteBitmapScanlineColorExpand3LSBFirst;
878	} else {
879	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
880					BIT_ORDER_IN_BYTE_MSBFIRST)
881		infoRec->WriteBitmap =
882		    XAAWriteBitmapScanlineColorExpandMSBFirst;
883	    else
884		infoRec->WriteBitmap =
885		    XAAWriteBitmapScanlineColorExpandLSBFirst;
886	}
887	infoRec->WriteBitmapFlags =
888		infoRec->ScanlineCPUToScreenColorExpandFillFlags;
889    } else
890	infoRec->WriteBitmap = NULL;
891
892    /**** TE Glyphs ****/
893
894    if (infoRec->TEGlyphRenderer) {
895	XAAMSG("\tDriver provided TEGlyphRenderer replacement\n");
896    } else if (HaveColorExpansion) {
897	infoRec->TEGlyphRendererFlags =
898	    infoRec->CPUToScreenColorExpandFillFlags;
899
900	if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
901	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
902		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
903		    infoRec->TEGlyphRenderer =
904			XAATEGlyphRenderer3MSBFirstFixedBase;
905		else
906		    infoRec->TEGlyphRenderer = XAATEGlyphRenderer3MSBFirst;
907	    } else {
908		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
909		    infoRec->TEGlyphRenderer =
910			XAATEGlyphRenderer3LSBFirstFixedBase;
911		else
912		    infoRec->TEGlyphRenderer = XAATEGlyphRenderer3LSBFirst;
913	    }
914
915	    if (!HaveSolidFillRect &&
916		(infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
917		infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
918		XAAMSG("WARNING:  TEGlyphRenderer cannot support RGB_EQUAL"
919		       " without solid fills\n");
920	    }
921	} else {
922	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
923		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
924		    infoRec->TEGlyphRenderer =
925			XAATEGlyphRendererMSBFirstFixedBase;
926		else
927		    infoRec->TEGlyphRenderer = XAATEGlyphRendererMSBFirst;
928	    } else {
929		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
930		    infoRec->TEGlyphRenderer =
931			XAATEGlyphRendererLSBFirstFixedBase;
932		else
933		    infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst;
934	    }
935	}
936
937	if (!HaveSolidFillRect &&
938	    (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
939	    infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
940	    XAAMSG("WARNING:  TEGlyphRenderer cannot support TRANPARENCY_ONLY"
941		   " without solid fills\n");
942	}
943
944    } else if (HaveScanlineColorExpansion) {
945	infoRec->TEGlyphRendererFlags =
946	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
947
948	if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
949	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
950		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3MSBFirst;
951	    else
952		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3LSBFirst;
953
954	    if (!HaveSolidFillRect &&
955		(infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
956		infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
957		XAAMSG("WARNING:  TEGlyphRenderer cannot support RGB_EQUAL"
958		       " without solid fills\n");
959	    }
960	} else {
961	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
962		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst;
963	    else
964		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst;
965	}
966
967	if (!HaveSolidFillRect &&
968	    (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
969	    infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
970	    XAAMSG("WARNING:  TEGlyphRenderer cannot support TRANPARENCY_ONLY"
971		   " without solid fills\n");
972	}
973    }
974
975    /**** NonTE Glyphs ****/
976
977    if(infoRec->NonTEGlyphRenderer) {
978	XAAMSG("\tDriver provided NonTEGlyphRenderer replacement\n");
979    } else if(infoRec->WriteBitmap &&
980	!(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
981	infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer;
982	infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags;
983    }
984
985    /**** WritePixmap ****/
986
987    if(infoRec->WritePixmap &&
988      !xf86ReturnOptValBool(options, XAAOPT_WRITE_PIXMAP, FALSE)) {
989	XAAMSG("\tDriver provided WritePixmap replacement\n");
990    } else if(HaveImageWriteRect) {
991	infoRec->WritePixmap = XAAWritePixmap;
992	infoRec->WritePixmapFlags =
993		infoRec->ImageWriteFlags | CONVERT_32BPP_TO_24BPP;
994    } else if(HaveScanlineImageWriteRect) {
995	infoRec->WritePixmap = XAAWritePixmapScanline;
996	infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags;
997    } else
998	infoRec->WritePixmap = NULL;
999
1000    /**** ReadPixmap ****/
1001
1002    if(infoRec->ReadPixmap) {
1003	XAAMSG("\tDriver provided ReadPixmap replacement\n");
1004    }
1005
1006
1007    /************** GC Level *************/
1008
1009    /**** CopyArea ****/
1010
1011    if(infoRec->CopyArea) {
1012	XAAMSG("\tDriver provided GC level CopyArea replacement\n");
1013    } else if(infoRec->ScreenToScreenBitBlt) {
1014	infoRec->CopyArea = XAACopyArea;
1015	infoRec->CopyAreaFlags = infoRec->ScreenToScreenBitBltFlags;
1016
1017	/* most GC level primitives use one mid-level primitive so
1018	   the GC level primitive gets the mid-level primitive flag
1019	   and we use that at GC validation time.  But CopyArea uses
1020	   more than one mid-level primitive so we have to essentially
1021	   do a GC validation every time that primitive is used.
1022	   The CopyAreaFlags would only be used for filtering out the
1023	   common denominators.  Here we assume that if you don't do
1024	   ScreenToScreenBitBlt you aren't going to do the others.
1025	   We also assume that ScreenToScreenBitBlt has the least
1026	   restrictions. */
1027    }
1028
1029    if(infoRec->CopyPlane) {
1030	XAAMSG("\tDriver provided GC level CopyPlane replacement\n");
1031    } else if(infoRec->WriteBitmap &&
1032		!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) {
1033	infoRec->CopyPlane = XAACopyPlaneColorExpansion;
1034	infoRec->CopyPlaneFlags = infoRec->WriteBitmapFlags;
1035    }
1036
1037    if(infoRec->PushPixelsSolid) {
1038	XAAMSG("\tDriver provided GC level PushPixelsSolid replacement\n");
1039    } else if(infoRec->WriteBitmap &&
1040		!(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
1041	infoRec->PushPixelsSolid = XAAPushPixelsSolidColorExpansion;
1042	infoRec->PushPixelsFlags = infoRec->WriteBitmapFlags;
1043    }
1044
1045    if(infoRec->FillSolidRects) {
1046	if(!infoRec->PolyFillRectSolid) {
1047	    infoRec->PolyFillRectSolid = XAAPolyFillRect;
1048	    infoRec->PolyFillRectSolidFlags = infoRec->FillSolidRectsFlags;
1049	}
1050    }
1051    if(infoRec->FillSolidSpans) {
1052	if(!infoRec->FillSpansSolid) {
1053	    infoRec->FillSpansSolid = XAAFillSpans;
1054	    infoRec->FillSpansSolidFlags = infoRec->FillSolidSpansFlags;
1055	}
1056    }
1057
1058    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1059	infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
1060	infoRec->FillCacheExpandRects) {
1061	if(!infoRec->PolyFillRectStippled) {
1062
1063	    infoRec->PolyFillRectStippled = XAAPolyFillRect;
1064	    infoRec->PolyFillRectStippledFlags = 0;
1065	}
1066    }
1067
1068    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1069	infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
1070	infoRec->FillCacheExpandSpans) {
1071	if(!infoRec->FillSpansStippled) {
1072
1073	    infoRec->FillSpansStippled = XAAFillSpans;
1074	    infoRec->FillSpansStippledFlags = 0;
1075	}
1076    }
1077
1078    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1079	infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
1080	infoRec->FillCacheExpandRects) {
1081	if(!infoRec->PolyFillRectOpaqueStippled) {
1082
1083	    infoRec->PolyFillRectOpaqueStippled = XAAPolyFillRect;
1084	    infoRec->PolyFillRectOpaqueStippledFlags = 0;
1085	}
1086    }
1087
1088    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1089	infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
1090	infoRec->FillCacheExpandSpans) {
1091	if(!infoRec->FillSpansOpaqueStippled) {
1092
1093	    infoRec->FillSpansOpaqueStippled = XAAFillSpans;
1094	    infoRec->FillSpansOpaqueStippledFlags = 0;
1095	}
1096    }
1097
1098    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1099	infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) {
1100	if(!infoRec->PolyFillRectTiled) {
1101
1102	    infoRec->PolyFillRectTiled = XAAPolyFillRect;
1103	    infoRec->PolyFillRectTiledFlags = 0;
1104	}
1105    }
1106
1107    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1108	infoRec->FillCacheBltSpans) {
1109	if(!infoRec->FillSpansTiled) {
1110
1111	    infoRec->FillSpansTiled = XAAFillSpans;
1112	    infoRec->FillSpansTiledFlags = 0;
1113	}
1114    }
1115
1116    if(infoRec->TEGlyphRenderer &&
1117	!(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) {
1118
1119	if(!infoRec->PolyText8TE) {
1120	    infoRec->PolyText8TE = XAAPolyText8TEColorExpansion;
1121	    infoRec->PolyText8TEFlags = infoRec->TEGlyphRendererFlags;
1122	}
1123
1124	if(!infoRec->PolyText16TE) {
1125	    infoRec->PolyText16TE = XAAPolyText16TEColorExpansion;
1126	    infoRec->PolyText16TEFlags = infoRec->TEGlyphRendererFlags;
1127	}
1128
1129	if(!infoRec->PolyGlyphBltTE) {
1130	    infoRec->PolyGlyphBltTE = XAAPolyGlyphBltTEColorExpansion;
1131	    infoRec->PolyGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
1132	}
1133    }
1134
1135    if(infoRec->TEGlyphRenderer &&
1136	!(infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
1137
1138	if(!infoRec->ImageText8TE) {
1139	    infoRec->ImageText8TE = XAAImageText8TEColorExpansion;
1140	    infoRec->ImageText8TEFlags = infoRec->TEGlyphRendererFlags;
1141	}
1142
1143	if(!infoRec->ImageText16TE) {
1144	    infoRec->ImageText16TE = XAAImageText16TEColorExpansion;
1145	    infoRec->ImageText16TEFlags = infoRec->TEGlyphRendererFlags;
1146	}
1147
1148	if(!infoRec->ImageGlyphBltTE) {
1149	    infoRec->ImageGlyphBltTE = XAAImageGlyphBltTEColorExpansion;
1150	    infoRec->ImageGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
1151	}
1152    }
1153
1154    if(infoRec->NonTEGlyphRenderer) {
1155	if(!infoRec->PolyText8NonTE) {
1156	    infoRec->PolyText8NonTE = XAAPolyText8NonTEColorExpansion;
1157	    infoRec->PolyText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1158	}
1159
1160	if(!infoRec->PolyText16NonTE) {
1161	    infoRec->PolyText16NonTE = XAAPolyText16NonTEColorExpansion;
1162	    infoRec->PolyText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1163	}
1164	if(!infoRec->PolyGlyphBltNonTE) {
1165	    infoRec->PolyGlyphBltNonTE = XAAPolyGlyphBltNonTEColorExpansion;
1166	    infoRec->PolyGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
1167	}
1168    }
1169
1170    if(infoRec->NonTEGlyphRenderer && HaveSolidFillRect) {
1171	if(!infoRec->ImageText8NonTE) {
1172	    infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion;
1173	    infoRec->ImageText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1174	}
1175
1176	if(!infoRec->ImageText16NonTE) {
1177	    infoRec->ImageText16NonTE = XAAImageText16NonTEColorExpansion;
1178	    infoRec->ImageText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1179	}
1180
1181	if(!infoRec->ImageGlyphBltNonTE) {
1182	    infoRec->ImageGlyphBltNonTE = XAAImageGlyphBltNonTEColorExpansion;
1183	    infoRec->ImageGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
1184	}
1185    }
1186
1187    if(!infoRec->PolyRectangleThinSolid && HaveSolidHorVertLine) {
1188	infoRec->PolyRectangleThinSolid = XAAPolyRectangleThinSolid;
1189	infoRec->PolyRectangleThinSolidFlags = infoRec->SolidLineFlags;
1190    }
1191
1192    if(!infoRec->FillPolygonSolid && HaveSolidFillRect) {
1193	infoRec->FillPolygonSolid = XAAFillPolygonSolid;
1194	infoRec->FillPolygonSolidFlags = infoRec->SolidFillFlags;
1195    }
1196
1197    if(!infoRec->FillPolygonStippled && (HaveMono8x8PatternFillRect ||
1198	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1199	infoRec->FillPolygonStippled = XAAFillPolygonStippled;
1200	infoRec->FillPolygonStippledFlags = infoRec->SolidFillFlags;
1201    }
1202
1203    if(!infoRec->FillPolygonOpaqueStippled && (HaveMono8x8PatternFillRect ||
1204	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1205	infoRec->FillPolygonOpaqueStippled = XAAFillPolygonStippled;
1206	infoRec->FillPolygonOpaqueStippledFlags = infoRec->SolidFillFlags;
1207    }
1208
1209    if(!infoRec->FillPolygonTiled && (HaveMono8x8PatternFillRect ||
1210	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1211	infoRec->FillPolygonTiled = XAAFillPolygonTiled;
1212	infoRec->FillPolygonTiledFlags = infoRec->SolidFillFlags;
1213    }
1214
1215
1216    if(!infoRec->PolyFillArcSolid && HaveSolidFillRect) {
1217	infoRec->PolyFillArcSolid = XAAPolyFillArcSolid;
1218	infoRec->PolyFillArcSolidFlags = infoRec->SolidFillFlags;
1219    }
1220
1221    if(!infoRec->PolylinesWideSolid && HaveSolidFillRect) {
1222	infoRec->PolylinesWideSolid = XAAPolylinesWideSolid;
1223	infoRec->PolylinesWideSolidFlags =
1224			infoRec->SolidFillFlags | GXCOPY_ONLY;
1225    }
1226
1227    if(!infoRec->PutImage && (infoRec->WritePixmap ||
1228	(infoRec->WriteBitmap &&
1229			!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)))) {
1230	infoRec->PutImage = XAAPutImage;
1231
1232	/* See comment for CopyArea above.  But here we make fewer
1233	   assumptions.  The driver can provide the PutImageFlags if
1234	   it wants too */
1235    }
1236
1237    if(HaveSolidHorVertLine &&
1238      (HaveSolidBresenhamLine || (HaveSolidTwoPointLine &&
1239		(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE)))){
1240	if(!infoRec->PolylinesThinSolid) {
1241	   infoRec->PolylinesThinSolid = XAAPolyLines;
1242	   infoRec->PolylinesThinSolidFlags = infoRec->SolidLineFlags;
1243	}
1244	if(!infoRec->PolySegmentThinSolid) {
1245	   infoRec->PolySegmentThinSolid = XAAPolySegment;
1246	   infoRec->PolySegmentThinSolidFlags = infoRec->SolidLineFlags;
1247	}
1248    }
1249
1250    if(HaveDashedBresenhamLine || (HaveDashedTwoPointLine &&
1251		(infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE))){
1252	if(!infoRec->PolylinesThinDashed) {
1253	   infoRec->PolylinesThinDashed = XAAPolyLinesDashed;
1254	   infoRec->PolylinesThinDashedFlags = infoRec->DashedLineFlags;
1255	}
1256	if(!infoRec->PolySegmentThinDashed) {
1257	   infoRec->PolySegmentThinDashed = XAAPolySegmentDashed;
1258	   infoRec->PolySegmentThinDashedFlags = infoRec->DashedLineFlags;
1259	}
1260    }
1261
1262    if(infoRec->PolylinesThinDashed || infoRec->PolySegmentThinDashed) {
1263	if(!infoRec->ComputeDash)
1264	   infoRec->ComputeDash = XAAComputeDash;
1265    }
1266
1267    {
1268	Bool haveTexture = infoRec->CPUToScreenTextureFormats &&
1269			   infoRec->CPUToScreenTextureDstFormats &&
1270	                   infoRec->SetupForCPUToScreenTexture2 &&
1271	                   infoRec->SubsequentCPUToScreenTexture;
1272        Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats &&
1273                                infoRec->CPUToScreenAlphaTextureDstFormats &&
1274                                infoRec->SetupForCPUToScreenAlphaTexture2 &&
1275                                infoRec->SubsequentCPUToScreenAlphaTexture;
1276
1277	if(!infoRec->Composite && (haveTexture || haveAlphaTexture))
1278	    infoRec->Composite = XAADoComposite;
1279
1280	if(!infoRec->Glyphs && infoRec->WriteBitmap &&
1281	   !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY))
1282        {
1283            infoRec->Glyphs = XAADoGlyphs;
1284        }
1285    }
1286
1287    /************  Validation Functions **************/
1288
1289    if(!infoRec->ValidateCopyArea && infoRec->CopyArea) {
1290	infoRec->CopyAreaMask = GCWhenForced;
1291	if((infoRec->CopyAreaFlags & GXCOPY_ONLY) ||
1292		(infoRec->CopyAreaFlags & ROP_NEEDS_SOURCE))
1293	    infoRec->CopyAreaMask |= GCFunction;
1294	if(infoRec->CopyAreaFlags & NO_PLANEMASK)
1295	    infoRec->CopyAreaMask |= GCPlaneMask;
1296	infoRec->ValidateCopyArea = XAAValidateCopyArea;
1297    }
1298
1299    if(!infoRec->ValidateCopyPlane && infoRec->CopyPlane) {
1300	infoRec->CopyPlaneMask = GCWhenForced;
1301	if((infoRec->CopyPlaneFlags & GXCOPY_ONLY) ||
1302		(infoRec->CopyPlaneFlags & ROP_NEEDS_SOURCE))
1303	    infoRec->CopyPlaneMask |= GCFunction;
1304	if(infoRec->CopyPlaneFlags & NO_PLANEMASK)
1305	    infoRec->CopyPlaneMask |= GCPlaneMask;
1306	if(infoRec->CopyPlaneFlags & RGB_EQUAL)
1307	    infoRec->CopyPlaneMask |= GCForeground | GCBackground;
1308	infoRec->ValidateCopyPlane = XAAValidateCopyPlane;
1309    }
1310
1311    if(!infoRec->ValidatePutImage && infoRec->PutImage) {
1312	infoRec->PutImageMask = GCWhenForced;
1313	if((infoRec->PutImageFlags & GXCOPY_ONLY) ||
1314		(infoRec->PutImageFlags & ROP_NEEDS_SOURCE))
1315	    infoRec->PutImageMask |= GCFunction;
1316	if(infoRec->PutImageFlags & NO_PLANEMASK)
1317	    infoRec->PutImageMask |= GCPlaneMask;
1318	if(infoRec->PutImageFlags & RGB_EQUAL)
1319	    infoRec->PutImageMask |= GCForeground | GCBackground;
1320	infoRec->ValidatePutImage = XAAValidatePutImage;
1321    }
1322
1323
1324    if(!infoRec->ValidatePushPixels && infoRec->PushPixelsSolid) {
1325	infoRec->PushPixelsMask = GCFillStyle;
1326	if((infoRec->PushPixelsFlags & GXCOPY_ONLY) ||
1327		(infoRec->PushPixelsFlags & ROP_NEEDS_SOURCE) ||
1328		(infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY))
1329	    infoRec->PushPixelsMask |= GCFunction;
1330	if(infoRec->PushPixelsFlags & NO_PLANEMASK)
1331	    infoRec->PushPixelsMask |= GCPlaneMask;
1332	if(infoRec->PushPixelsFlags & RGB_EQUAL)
1333	    infoRec->PushPixelsMask |= GCForeground;
1334	infoRec->ValidatePushPixels = XAAValidatePushPixels;
1335    }
1336
1337    /* By default XAA assumes the FillSpans, PolyFillRects, FillPolygon
1338	and PolyFillArcs have the same restrictions.  If you supply GC
1339	level replacements for any of these and alter this relationship
1340	you may need to supply replacement validation routines */
1341
1342    if(!infoRec->ValidateFillSpans &&
1343	(infoRec->FillSpansSolid || infoRec->FillSpansStippled ||
1344	infoRec->FillSpansOpaqueStippled || infoRec->FillSpansTiled)) {
1345
1346        int compositeFlags = 	infoRec->FillSpansSolidFlags |
1347				infoRec->FillSpansStippledFlags |
1348				infoRec->FillSpansOpaqueStippledFlags |
1349				infoRec->FillSpansTiledFlags;
1350
1351	infoRec->FillSpansMask = GCFillStyle | GCTile | GCStipple;
1352
1353	if((compositeFlags & GXCOPY_ONLY) ||
1354		(compositeFlags & ROP_NEEDS_SOURCE))
1355	    infoRec->FillSpansMask |= GCFunction;
1356	if(compositeFlags & NO_PLANEMASK)
1357	    infoRec->FillSpansMask |= GCPlaneMask;
1358	if(compositeFlags & RGB_EQUAL)
1359	    infoRec->FillSpansMask |= GCForeground;
1360	infoRec->ValidateFillSpans = XAAValidateFillSpans;
1361    }
1362
1363    /* By default XAA only provides Validations for the GlyphBlt
1364	functions and not the text higher up. This is because the
1365	Text8/16 and GlyphBlt are linked.  If you break this linkage,
1366	you may need to have the driver supply its own Validation
1367	routines */
1368
1369    if(!infoRec->ValidatePolyGlyphBlt &&
1370	(infoRec->PolyGlyphBltTE || infoRec->PolyGlyphBltNonTE)) {
1371        int compositeFlags = 	infoRec->PolyGlyphBltTEFlags |
1372				infoRec->PolyGlyphBltNonTEFlags;
1373
1374	infoRec->PolyGlyphBltMask = GCFillStyle | GCFont;
1375	if((compositeFlags & GXCOPY_ONLY) ||
1376		(compositeFlags & ROP_NEEDS_SOURCE) ||
1377		(infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY))
1378	    infoRec->PolyGlyphBltMask |= GCFunction;
1379	if(compositeFlags & NO_PLANEMASK)
1380	    infoRec->PolyGlyphBltMask |= GCPlaneMask;
1381	if(compositeFlags & RGB_EQUAL)
1382	    infoRec->PolyGlyphBltMask |= GCForeground;
1383	infoRec->ValidatePolyGlyphBlt = XAAValidatePolyGlyphBlt;
1384    }
1385
1386    if(!infoRec->ValidateImageGlyphBlt &&
1387	(infoRec->ImageGlyphBltTE || infoRec->ImageGlyphBltNonTE)) {
1388        int compositeFlags = 	infoRec->ImageGlyphBltTEFlags |
1389				infoRec->ImageGlyphBltNonTEFlags;
1390
1391        if(infoRec->ImageGlyphBltNonTE)
1392	    compositeFlags |= infoRec->SolidFillFlags;
1393
1394	infoRec->ImageGlyphBltMask = GCFont;
1395	if(compositeFlags & NO_PLANEMASK)
1396	    infoRec->ImageGlyphBltMask |= GCPlaneMask;
1397	if(compositeFlags & RGB_EQUAL)
1398	    infoRec->ImageGlyphBltMask |= GCForeground | GCBackground;
1399	infoRec->ValidateImageGlyphBlt = XAAValidateImageGlyphBlt;
1400    }
1401
1402    /* By default XAA only provides a Validation function for the
1403	Polylines and does segments and polylines at the same time */
1404
1405    if(!infoRec->ValidatePolylines && infoRec->ValidateFillSpans) {
1406	int compositeFlags = 	infoRec->PolyRectangleThinSolidFlags |
1407				infoRec->PolylinesWideSolidFlags |
1408				infoRec->PolylinesThinSolidFlags |
1409				infoRec->PolySegmentThinSolidFlags |
1410				infoRec->PolySegmentThinDashedFlags |
1411				infoRec->PolylinesThinDashedFlags;
1412
1413	infoRec->ValidatePolylines = XAAValidatePolylines;
1414	infoRec->PolylinesMask =
1415		infoRec->FillSpansMask | GCLineStyle | GCLineWidth;
1416
1417	if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed)
1418	    infoRec->PolylinesMask |= GCDashList;
1419	if(compositeFlags & NO_PLANEMASK)
1420	    infoRec->PolylinesMask |= GCPlaneMask;
1421	if((compositeFlags & GXCOPY_ONLY) ||
1422		(compositeFlags & ROP_NEEDS_SOURCE))
1423	    infoRec->PolylinesMask |= GCFunction;
1424	if(compositeFlags & RGB_EQUAL)
1425	    infoRec->PolylinesMask |= GCForeground;
1426    }
1427
1428
1429    /**** Fill choosers ****/
1430
1431    if(!infoRec->StippledFillChooser)
1432	infoRec->StippledFillChooser = XAAStippledFillChooser;
1433
1434    if(!infoRec->OpaqueStippledFillChooser)
1435	infoRec->OpaqueStippledFillChooser = XAAOpaqueStippledFillChooser;
1436
1437    if(!infoRec->TiledFillChooser)
1438	infoRec->TiledFillChooser = XAATiledFillChooser;
1439
1440
1441    /**** Setup the pixmap cache ****/
1442
1443    if(infoRec->WriteBitmapToCache) {}
1444    else if(infoRec->WriteBitmap &&
1445	!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))
1446	infoRec->WriteBitmapToCache = XAAWriteBitmapToCache;
1447    else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
1448	infoRec->WriteBitmapToCache = XAAWriteBitmapToCacheLinear;
1449    else
1450	infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
1451
1452    if(infoRec->WritePixmapToCache) {}
1453    else if(infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY))
1454	infoRec->WritePixmapToCache = XAAWritePixmapToCache;
1455    else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
1456	infoRec->WritePixmapToCache = XAAWritePixmapToCacheLinear;
1457    else
1458	infoRec->Flags &= ~PIXMAP_CACHE;
1459
1460    if (xf86ReturnOptValBool(options, XAAOPT_PIXMAP_CACHE, FALSE))
1461	infoRec->Flags &= ~PIXMAP_CACHE;
1462
1463    if(infoRec->WriteMono8x8PatternToCache) {}
1464    else if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) {
1465	if(infoRec->WritePixmapToCache)
1466	  infoRec->WriteMono8x8PatternToCache = XAAWriteMono8x8PatternToCache;
1467	else
1468	   infoRec->PixmapCacheFlags &= ~CACHE_MONO_8x8;
1469    }
1470
1471    if(infoRec->WriteColor8x8PatternToCache) {}
1472    else if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) {
1473	if(infoRec->WritePixmapToCache && infoRec->WriteBitmapToCache)
1474	  infoRec->WriteColor8x8PatternToCache = XAAWriteColor8x8PatternToCache;
1475	else
1476	   infoRec->PixmapCacheFlags &= ~CACHE_COLOR_8x8;
1477    }
1478
1479    if(infoRec->CachePixelGranularity < 0) {
1480	switch(pScrn->bitsPerPixel) {
1481	case 24:
1482	case 8:  infoRec->CachePixelGranularity = 4;  break;
1483	case 16: infoRec->CachePixelGranularity = 2;  break;
1484	case 32: infoRec->CachePixelGranularity = 1;  break;
1485	default: break;
1486	}
1487
1488	if(BITMAP_SCANLINE_PAD == 64)
1489	    infoRec->CachePixelGranularity *= 2;
1490    }
1491
1492    free(options);
1493
1494    if(!infoRec->CacheTile && infoRec->WritePixmapToCache)
1495	infoRec->CacheTile = XAACacheTile;
1496    if(!infoRec->CacheMonoStipple && infoRec->WritePixmapToCache)
1497	infoRec->CacheMonoStipple = XAACacheMonoStipple;
1498    if(!infoRec->CacheStipple && infoRec->WriteBitmapToCache)
1499	infoRec->CacheStipple = XAACacheStipple;
1500    if(!infoRec->CacheMono8x8Pattern && infoRec->WriteMono8x8PatternToCache)
1501	infoRec->CacheMono8x8Pattern = XAACacheMono8x8Pattern;
1502    if(!infoRec->CacheColor8x8Pattern && infoRec->WriteColor8x8PatternToCache)
1503	infoRec->CacheColor8x8Pattern = XAACacheColor8x8Pattern;
1504
1505    if((infoRec->Flags & PIXMAP_CACHE) && !infoRec->InitPixmapCache) {
1506	infoRec->InitPixmapCache = XAAInitPixmapCache;
1507	infoRec->ClosePixmapCache = XAAClosePixmapCache;
1508    }
1509
1510    return TRUE;
1511}
1512