1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c,v 1.40 2002/11/25 14:04:58 eich Exp $ */
3
* Copyright 1996, 1997, 1998 by David Bateman <dbateman@ee.uts.edu.au>
4
* Modified 1997, 1998 by Nozomi Ytow
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 the authors not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. The authors makes no representations
13
* about the suitability of this software for any purpose. It is provided
14
* "as is" without express or implied warranty.
16
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL THE AUTHORS 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.
26
* When monochrome tiles/stipples are cached on the HiQV chipsets the
27
* pitch of the monochrome data is the displayWidth. The HiQV manuals
28
* state that the source pitch is ignored with monochrome data, and so
29
* "offically" there the XAA cached monochrome data can't be used. But
30
* it appears that by not setting the monochrome source alignment in
31
* BR03, the monochrome source pitch is forced to the displayWidth!!
33
* To enable the use of this undocumented feature, uncomment the define
36
#define UNDOCUMENTED_FEATURE
38
/* All drivers should typically include these */
40
#include "xf86_OSproc.h"
41
#include "xf86_ansic.h"
44
/* Drivers that need to access the PCI config space directly need this */
47
/* Drivers for PCI hardware need this */
48
#include "xf86PciInfo.h"
50
/* Drivers that use XAA need this */
51
#include "xf86fbman.h"
53
/* Our driver specific include file */
54
#include "ct_driver.h"
56
#if !defined(UNIXCPP) || defined(ANSICPP)
57
#define CATNAME(prefix,subname) prefix##subname
59
#define CATNAME(prefix,subname) prefix/**/subname
64
#include "ct_BltHiQV.h"
65
#define CTNAME(subname) CATNAME(CHIPSHiQV,subname)
67
#include "ct_BlitMM.h"
68
#define CTNAME(subname) CATNAME(CHIPSMMIO,subname)
71
#include "ct_Blitter.h"
72
#define CTNAME(subname) CATNAME(CHIPS,subname)
76
# define DEBUG_P(x) ErrorF(x"\n");
78
# define DEBUG_P(x) snprintf(CTNAME(accel_debug),1024,x"\n");
80
# define DEBUG_P(x) /**/
84
static char CTNAME(accel_debug)[1024];
88
static void CTNAME(DepthChange)(ScrnInfoPtr pScrn, int depth);
90
static void CTNAME(8SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
91
int rop, unsigned int planemask);
92
static void CTNAME(16SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
93
int rop, unsigned int planemask);
94
static void CTNAME(24SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
95
int rop, unsigned int planemask);
96
static void CTNAME(SubsequentSolidFillRect)(ScrnInfoPtr pScrn,
97
int x, int y, int w, int h);
99
static void CTNAME(24SubsequentSolidFillRect)(ScrnInfoPtr pScrn,
100
int x, int y, int w, int h);
102
static void CTNAME(32SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
103
int rop, unsigned int planemask);
104
static void CTNAME(32SubsequentSolidFillRect)(ScrnInfoPtr pScrn,
105
int x, int y, int w, int h);
107
static void CTNAME(SetupForScreenToScreenCopy)(ScrnInfoPtr pScrn, int xdir,
108
int ydir, int rop, unsigned int planemask,
110
static void CTNAME(SubsequentScreenToScreenCopy)(ScrnInfoPtr pScrn,
111
int srcX, int srcY, int dstX, int dstY,
113
static void CTNAME(SetupForCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, int fg,
114
int bg, int rop, unsigned int planemask);
115
static void CTNAME(SubsequentCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn,
116
int x, int y, int w, int h, int skipleft);
118
static XAACacheInfoPtr CTNAME(CacheMonoStipple)(ScrnInfoPtr pScrn,
121
#if !defined(CHIPS_HIQV) || defined(UNDOCUMENTED_FEATURE)
122
static void CTNAME(SetupForScreenToScreenColorExpandFill)(ScrnInfoPtr pScrn,
123
int fg, int bg, int rop,
124
unsigned int planemask);
125
static void CTNAME(SubsequentScreenToScreenColorExpandFill)(ScrnInfoPtr pScrn,
126
int x, int y, int w, int h,
127
int srcx, int srcy, int skipleft);
129
static void CTNAME(SetupForMono8x8PatternFill)(ScrnInfoPtr pScrn,
130
int patx, int paty, int fg, int bg,
131
int rop, unsigned int planemask);
132
static void CTNAME(SubsequentMono8x8PatternFillRect)(ScrnInfoPtr pScrn,
134
int x, int y, int w, int h );
135
static void CTNAME(SetupForColor8x8PatternFill)(ScrnInfoPtr pScrn,
136
int patx, int paty, int rop,
137
unsigned int planemask, int trans);
138
static void CTNAME(SubsequentColor8x8PatternFillRect)(ScrnInfoPtr pScrn,
140
int x, int y, int w, int h );
142
static void CTNAME(SetupForImageWrite)(ScrnInfoPtr pScrn, int rop,
143
unsigned int planemask,
144
int transparency_color, int bpp, int depth);
145
static void CTNAME(SubsequentImageWriteRect)(ScrnInfoPtr pScrn,
146
int x, int y, int w, int h, int skipleft);
148
static void CTNAME(WritePixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
149
unsigned char *src, int srcwidth, int rop,
150
unsigned int planemask, int trans, int bpp, int depth);
152
static void CTNAME(ReadPixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
153
unsigned char *dst, int dstwidth, int bpp, int depth);
159
CTNAME(AccelInit)(ScreenPtr pScreen)
161
XAAInfoRecPtr infoPtr;
162
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
163
CHIPSPtr cPtr = CHIPSPTR(pScrn);
164
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
166
DEBUG_P("AccelInit");
167
cPtr->AccelInfoRec = infoPtr = XAACreateInfoRec();
168
if(!infoPtr) return FALSE;
171
* Setup some global variables
173
cAcl->BytesPerPixel = pScrn->bitsPerPixel >> 3;
174
cAcl->BitsPerPixel = pScrn->bitsPerPixel;
175
cAcl->PitchInBytes = pScrn->displayWidth * cAcl->BytesPerPixel;
176
cAcl->planemask = -1;
182
* Set up the main acceleration flags.
184
if (cAcl->CacheEnd > cAcl->CacheStart) infoPtr->Flags = PIXMAP_CACHE;
186
if (cPtr->Flags & ChipsLinearSupport)
187
infoPtr->Flags |= OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER;
189
infoPtr->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
192
* The following line installs a "Sync" function, that waits for
193
* all coprocessor operations to complete.
195
infoPtr->Sync = CTNAME(Sync);
198
* Setup a Screen to Screen copy (BitBLT) primitive
201
infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY;
202
if (cAcl->BitsPerPixel == 24)
203
infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK;
205
infoPtr->ScreenToScreenCopyFlags = 0;
206
if ((cAcl->BitsPerPixel == 24) || (cAcl->BitsPerPixel == 32))
207
infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK;
209
/* A Chips and Technologies application notes says that some
210
* 65550 have a bug that prevents 16bpp transparency. It probably
211
* applies to 24 bpp as well (Someone with a 65550 care to check?).
212
* Selection of this controlled in Probe.
214
if (!(cPtr->Flags & ChipsColorTransparency))
215
infoPtr->ScreenToScreenCopyFlags |= NO_TRANSPARENCY;
218
infoPtr->SetupForScreenToScreenCopy = CTNAME(SetupForScreenToScreenCopy);
219
infoPtr->SubsequentScreenToScreenCopy =
220
CTNAME(SubsequentScreenToScreenCopy);
223
* Install the low-level functions for drawing solid filled rectangles.
225
infoPtr->SolidFillFlags |= NO_PLANEMASK;
226
switch (cAcl->BitsPerPixel) {
228
infoPtr->SetupForSolidFill = CTNAME(8SetupForSolidFill);
229
infoPtr->SubsequentSolidFillRect = CTNAME(SubsequentSolidFillRect);
232
infoPtr->SetupForSolidFill = CTNAME(16SetupForSolidFill);
233
infoPtr->SubsequentSolidFillRect = CTNAME(SubsequentSolidFillRect);
236
infoPtr->SetupForSolidFill = CTNAME(24SetupForSolidFill);
238
infoPtr->SubsequentSolidFillRect = CTNAME(SubsequentSolidFillRect);
241
* The version of this function here uses three different
242
* algorithms in an attempt to maximise performance. One
243
* for RGB_EQUAL, another for !RGB_EQUAL && GXCOPY_ONLY
244
* and yet another for !RGB_EQUAL && !GXCOPY_ONLY. The
245
* first two versions use the 8bpp engine for the fill,
246
* whilst the second uses a framebuffer routine to create
247
* one scanline of the fill in off screen memory which is
248
* then used by a CopyArea function with a complex ROP.
250
infoPtr->SubsequentSolidFillRect = CTNAME(24SubsequentSolidFillRect);
251
if (cAcl->ScratchAddress < 0)
252
infoPtr->ScreenToScreenCopyFlags |= GXCOPY_ONLY;
257
if (cAcl->ScratchAddress > 0) {
258
infoPtr->SetupForSolidFill = CTNAME(32SetupForSolidFill);
259
infoPtr->SubsequentSolidFillRect =
260
CTNAME(32SubsequentSolidFillRect);
267
/* At 32bpp we can't use the other acceleration */
268
if (cAcl->BitsPerPixel == 32) goto chips_imagewrite;
272
* Setup the functions that perform monochrome colour expansion
276
infoPtr->CPUToScreenColorExpandFillFlags =
277
BIT_ORDER_IN_BYTE_MSBFIRST | CPU_TRANSFER_PAD_QWORD |
278
LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X |
280
#ifdef UNDOCUMENTED_FEATURE
281
infoPtr->ScreenToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST
282
| LEFT_EDGE_CLIPPING;
284
if (cAcl->BitsPerPixel == 24) {
285
infoPtr->CPUToScreenColorExpandFillFlags |= NO_PLANEMASK;
286
#ifdef UNDOCUMENTED_FEATURE
287
infoPtr->ScreenToScreenColorExpandFillFlags |= NO_PLANEMASK;
290
/* The ct65550 has problems with transparency which leads to video
291
* corruption unless disabled.
293
if (!(cPtr->Flags & ChipsColorTransparency)) {
294
infoPtr->CPUToScreenColorExpandFillFlags |= NO_TRANSPARENCY;
295
#ifdef UNDOCUMENTED_FEATURE
296
infoPtr->ScreenToScreenColorExpandFillFlags |= NO_TRANSPARENCY;
300
infoPtr->CPUToScreenColorExpandFillFlags =
301
BIT_ORDER_IN_BYTE_MSBFIRST | CPU_TRANSFER_PAD_DWORD |
303
infoPtr->ScreenToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST;
304
infoPtr->CacheColorExpandDensity = 8;
306
if (cAcl->BitsPerPixel == 24)
307
infoPtr->CPUToScreenColorExpandFillFlags |= TRIPLE_BITS_24BPP |
308
RGB_EQUAL | NO_PLANEMASK;
311
infoPtr->SetupForCPUToScreenColorExpandFill =
312
CTNAME(SetupForCPUToScreenColorExpandFill);
313
infoPtr->SubsequentCPUToScreenColorExpandFill =
314
CTNAME(SubsequentCPUToScreenColorExpandFill);
317
if (cAcl->BitsPerPixel != 24) {
319
#if !defined(CHIPS_HIQV) || defined(UNDOCUMENTED_FEATURE)
320
infoPtr->SetupForScreenToScreenColorExpandFill =
321
CTNAME(SetupForScreenToScreenColorExpandFill);
322
infoPtr->SubsequentScreenToScreenColorExpandFill =
323
CTNAME(SubsequentScreenToScreenColorExpandFill);
326
infoPtr->CacheMonoStipple = CTNAME(CacheMonoStipple);
330
infoPtr->ColorExpandBase = (unsigned char *)cAcl->BltDataWindow;
331
infoPtr->ColorExpandRange = 64 * 1024;
333
/* Mono 8x8 pattern fills */
334
infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK |
335
BIT_ORDER_IN_BYTE_MSBFIRST | HARDWARE_PATTERN_SCREEN_ORIGIN;
338
infoPtr->SetupForMono8x8PatternFill =
339
CTNAME(SetupForMono8x8PatternFill);
340
infoPtr->SubsequentMono8x8PatternFillRect =
341
CTNAME(SubsequentMono8x8PatternFillRect);
342
if (cAcl->BitsPerPixel == 24)
343
infoPtr->MonoPatternPitch = 8; /* Need 8 byte alignment */
345
if (cAcl->BitsPerPixel != 24) {
346
infoPtr->SetupForMono8x8PatternFill =
347
CTNAME(SetupForMono8x8PatternFill);
348
infoPtr->SubsequentMono8x8PatternFillRect =
349
CTNAME(SubsequentMono8x8PatternFillRect);
353
/* Color 8x8 pattern fills, must have a displayWidth divisible by 64 */
354
if (!(pScrn->displayWidth % 64)) {
356
infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK |
357
HARDWARE_PATTERN_SCREEN_ORIGIN;
358
if (!(cPtr->Flags & ChipsColorTransparency))
359
infoPtr->Color8x8PatternFillFlags |= NO_TRANSPARENCY;
361
infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK |
362
HARDWARE_PATTERN_SCREEN_ORIGIN | NO_TRANSPARENCY;
365
if (cAcl->BitsPerPixel != 24) {
366
infoPtr->SetupForColor8x8PatternFill =
367
CTNAME(SetupForColor8x8PatternFill);
368
infoPtr->SubsequentColor8x8PatternFillRect =
369
CTNAME(SubsequentColor8x8PatternFillRect);
377
/* Setup for the Image Write functions */
379
infoPtr->WritePixmapFlags = CPU_TRANSFER_PAD_QWORD | LEFT_EDGE_CLIPPING
380
| LEFT_EDGE_CLIPPING_NEGATIVE_X | ROP_NEEDS_SOURCE;
382
if (!(cPtr->Flags & ChipsColorTransparency))
383
infoPtr->WritePixmapFlags |= NO_TRANSPARENCY;
384
if ((cAcl->BitsPerPixel == 24) || (cAcl->BitsPerPixel == 32))
385
infoPtr->WritePixmapFlags |= NO_PLANEMASK;
387
infoPtr->WritePixmap = CTNAME(WritePixmap);
388
#if 0 /* Not used by XAA as yet, but coming soon */
389
if (cPtr->Flags & ChipsImageReadSupport) {
390
infoPtr->ReadPixmapFlags = CPU_TRANSFER_PAD_QWORD | ROP_NEEDS_SOURCE;
391
infoPtr->ReadPixmap = CTNAME(ReadPixmap);
396
infoPtr->SetupForImageWrite = CTNAME(SetupForImageWrite);
397
infoPtr->SubsequentImageWriteRect = CTNAME(SubsequentImageWriteRect);
398
infoPtr->ImageWriteBase = (unsigned char *)cAcl->BltDataWindow;
399
infoPtr->ImageWriteRange = 64 * 1024;
400
infoPtr->ImageWriteFlags = NO_TRANSPARENCY | CPU_TRANSFER_PAD_DWORD
402
if ((cAcl->BitsPerPixel == 24) || (cAcl->BitsPerPixel == 32))
403
infoPtr->ImageWriteFlags |= NO_PLANEMASK;
408
if (XAAInit(pScreen, infoPtr)) {
409
if (cPtr->Flags & ChipsOverlay8plus16)
410
return(XAAInitDualFramebufferOverlay(pScreen,
411
CTNAME(DepthChange)));
417
return(XAAInit(pScreen, infoPtr));
423
CTNAME(DepthChange)(ScrnInfoPtr pScrn, int depth)
425
CHIPSPtr cPtr = CHIPSPTR(pScrn);
426
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
429
DEBUG_P("DepthChange");
432
cPtr->AccelInfoRec->SetupForSolidFill = CTNAME(8SetupForSolidFill);
433
mode = 0x00; /* BitBLT engine to 8bpp */
434
cAcl->BytesPerPixel = 1;
436
cAcl->BitsPerPixel = 8;
439
cPtr->AccelInfoRec->SetupForSolidFill = CTNAME(16SetupForSolidFill);
440
mode = 0x10; /* BitBLT engine to 16bpp */
441
cAcl->BytesPerPixel = 2;
442
cAcl->FbOffset = cPtr->FbOffset16;
443
cAcl->BitsPerPixel = 16;
446
cAcl->PitchInBytes = pScrn->displayWidth * cAcl->BytesPerPixel;
448
cPtr->writeXR(cPtr, 0x20, mode); /* Change BitBLT engine mode */
453
CTNAME(Sync)(ScrnInfoPtr pScrn)
455
CHIPSPtr cPtr = CHIPSPTR(pScrn);
461
CTNAME(8SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
462
int rop, unsigned int planemask)
464
CHIPSPtr cPtr = CHIPSPTR(pScrn);
465
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
467
DEBUG_P("8SetupForSolidFill");
469
ctSETBGCOLOR8(color);
470
ctSETFGCOLOR8(color);
471
ctSETROP(ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM | ctLEFT2RIGHT |
472
ctPATSOLID | ctPATMONO);
473
ctSETPITCH(0, cAcl->PitchInBytes);
477
CTNAME(16SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
478
int rop, unsigned int planemask)
480
CHIPSPtr cPtr = CHIPSPTR(pScrn);
481
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
483
DEBUG_P("16SetupForSolidFill");
485
ctSETBGCOLOR16(color);
486
ctSETFGCOLOR16(color);
487
ctSETROP(ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM | ctLEFT2RIGHT |
488
ctPATSOLID | ctPATMONO);
489
ctSETPITCH(0, cAcl->PitchInBytes);
494
CTNAME(24SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
495
int rop, unsigned int planemask)
497
CHIPSPtr cPtr = CHIPSPTR(pScrn);
498
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
500
DEBUG_P("24SetupForSolidFill");
502
ctSETBGCOLOR24(color);
503
ctSETFGCOLOR24(color);
504
ctSETROP(ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM | ctLEFT2RIGHT |
505
ctPATSOLID | ctPATMONO);
506
ctSETPITCH(0, cAcl->PitchInBytes);
510
CTNAME(32SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
511
int rop, unsigned int planemask)
513
CHIPSPtr cPtr = CHIPSPTR(pScrn);
514
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
516
DEBUG_P("32SetupForSolidFill");
518
memset((unsigned char *)cPtr->FbBase + cAcl->ScratchAddress, 0xAA, 8);
519
ctSETFGCOLOR16((color & 0xFFFF));
520
ctSETBGCOLOR16(((color >> 16) & 0xFFFF));
521
ctSETROP(ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM | ctLEFT2RIGHT |
523
ctSETPATSRCADDR(cAcl->ScratchAddress);
524
ctSETPITCH(1, cAcl->PitchInBytes);
528
CTNAME(32SubsequentSolidFillRect)(ScrnInfoPtr pScrn, int x, int y, int w,
531
CHIPSPtr cPtr = CHIPSPTR(pScrn);
533
unsigned int destaddr;
534
destaddr = (y * pScrn->displayWidth + x) << 2;
536
DEBUG_P("32SubsequentSolidFillRect");
538
ctSETDSTADDR(destaddr);
539
ctSETHEIGHTWIDTHGO(h, w);
544
CTNAME(24SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
545
int rop, unsigned int planemask)
547
unsigned char pixel1, pixel2, pixel3;
548
CHIPSPtr cPtr = CHIPSPTR(pScrn);
549
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
551
DEBUG_P("24SetupForSolidFill");
552
cAcl->rgb24equal = (((((color & 0xFF) == ((color & 0xFF00) >> 8)) &&
553
((color & 0xFF) == ((color & 0xFF0000) >> 16)))) ||
554
/* Check the rop for paranoid reasons */
555
(rop == GXclear) || (rop == GXnoop) ||
556
(rop == GXinvert) || (rop == GXset));
557
if (cAcl->rgb24equal) {
558
cAcl->CommandFlags = ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM |
559
ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
561
ctSETFGCOLOR8(color&0xFF);
562
ctSETBGCOLOR8(color&0xFF);
563
ctSETPITCH(0, cAcl->PitchInBytes);
565
cAcl->rop24bpp = rop;
567
pixel3 = color & 0xFF;
568
pixel2 = (color >> 8) & 0xFF;
569
pixel1 = (color >> 16) & 0xFF;
570
cAcl->fgpixel = pixel1;
571
cAcl->bgpixel = pixel2;
573
cAcl->fastfill = FALSE;
575
/* Test for the special case where two of the byte of the
576
* 24bpp colour are the same. This can double the speed
578
if (pixel1 == pixel2) {
579
cAcl->fgpixel = pixel3;
580
cAcl->bgpixel = pixel1;
581
cAcl->fastfill = TRUE;
583
} else if (pixel1 == pixel3) {
584
cAcl->fgpixel = pixel2;
585
cAcl->bgpixel = pixel1;
586
cAcl->fastfill = TRUE;
588
} else if (pixel2 == pixel3) {
589
cAcl->fastfill = TRUE;
591
cAcl->xorpixel = pixel2 ^ pixel3;
594
cAcl->CommandFlags = ctSRCMONO | ctSRCSYSTEM | ctTOP2BOTTOM |
597
if (cAcl->fastfill) {
598
ctSETFGCOLOR8(cAcl->fgpixel);
600
ctSETBGCOLOR8(cAcl->bgpixel);
602
ctSETPITCH(0, cAcl->PitchInBytes);
604
if (cAcl->color24bpp != color) {
605
cAcl->color24bpp = color;
606
cAcl->width24bpp = 0;
608
cAcl->rop24bpp = rop;
610
ctSETROP(ctTOP2BOTTOM | ctLEFT2RIGHT | ChipsAluConv[rop & 0xF]);
611
ctSETPITCH(cAcl->PitchInBytes, cAcl->PitchInBytes);
617
CTNAME(24SubsequentSolidFillRect)(ScrnInfoPtr pScrn, int x, int y, int w,
620
static unsigned int dwords[3] = { 0x24499224, 0x92244992, 0x49922449};
621
int srcaddr, destaddr, line, i;
623
CHIPSPtr cPtr = CHIPSPTR(pScrn);
624
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
626
DEBUG_P("24SubsequentSolidFillRect");
627
if (cAcl->rgb24equal) {
628
destaddr = y * pScrn->displayWidth + x;
629
destaddr += destaddr << 1;
631
ctSETROP(cAcl->CommandFlags);
632
ctSETDSTADDR(destaddr);
633
ctSETHEIGHTWIDTHGO(h, (w + (w << 1)));
635
if (cAcl->rop24bpp == GXcopy ) {
636
unsigned int *base = (unsigned int *)cAcl->BltDataWindow;
637
destaddr = y * cAcl->PitchInBytes + x * 3;
639
width = ((w + 31) & ~31) >> 5;
642
ctSETDSTADDR(destaddr);
644
if (!cAcl->fastfill) ctSETFGCOLOR8(cAcl->fgpixel);
645
ctSETROP(cAcl->CommandFlags | ChipsAluConv[GXcopy & 0xF]);
646
ctSETDSTADDR(destaddr);
647
if (cAcl->fastfill) {
648
ctSETHEIGHTWIDTHGO(h, w);
651
base = (unsigned int *)cAcl->BltDataWindow;
652
for (i = 0; i < width; i++) {
653
*base++ = dwords[((cAcl->fillindex + i) % 3)];
658
ctSETHEIGHTWIDTHGO(1, w);
661
*base++ = dwords[(i++ % 3)];
663
for(line = 0; (h >> line ) > 1; line++){;}
666
ctSETFGCOLOR8(cAcl->xorpixel);
667
ctSETROP(cAcl->CommandFlags | ChipsAluConv[GXxor & 0xF] |
669
ctSETDSTADDR(destaddr);
670
ctSETHEIGHTWIDTHGO(1, w);
671
base = (unsigned int *)cAcl->BltDataWindow;
673
*base++ = dwords[((++i) % 3)];
679
ctSETROP(ctTOP2BOTTOM | ctLEFT2RIGHT |
680
ChipsAluConv[GXcopy & 0xF]);
681
ctSETPITCH(cAcl->PitchInBytes, cAcl->PitchInBytes);
682
ctSETSRCADDR(srcaddr);
685
destaddr = srcaddr + (cAcl->PitchInBytes << i);
687
ctSETDSTADDR(destaddr);
688
ctSETHEIGHTWIDTHGO((1 << i), w);
693
destaddr = srcaddr + (cAcl->PitchInBytes << line);
695
ctSETDSTADDR(destaddr);
696
ctSETHEIGHTWIDTHGO(h-(1 << line), w);
700
ctSETROP(ctSRCMONO | ctSRCSYSTEM | ctTOP2BOTTOM |
701
ctLEFT2RIGHT | ChipsAluConv[GXcopy & 0xF]);
703
ctSETPITCH(0, cAcl->PitchInBytes);
707
register unsigned char *base;
708
if (cAcl->width24bpp < w) {
709
base = (unsigned char *)cPtr->FbBase + cAcl->ScratchAddress +
710
((3 * cAcl->width24bpp + 3) & ~0x3);
711
width = w - cAcl->width24bpp;
713
/* Load of a single scanline into framebuffer */
715
*(unsigned int *)base = cAcl->color24bpp |
716
(cAcl->color24bpp << 24);
717
*(unsigned int *)(base + 4) = (cAcl->color24bpp >> 8) |
718
(cAcl->color24bpp << 16);
719
*(unsigned int *)(base + 8) = (cAcl->color24bpp >> 16) |
720
(cAcl->color24bpp << 8);
724
cAcl->width24bpp = w - width;
727
destaddr = 3 * (y * pScrn->displayWidth + x);
728
w *= cAcl->BytesPerPixel;
731
ctSETSRCADDR(cAcl->ScratchAddress);
732
ctSETDSTADDR(destaddr);
733
ctSETHEIGHTWIDTHGO(1, w);
734
destaddr += (3 * pScrn->displayWidth);
743
CTNAME(SubsequentSolidFillRect)(ScrnInfoPtr pScrn, int x, int y, int w,
746
CHIPSPtr cPtr = CHIPSPTR(pScrn);
747
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
750
DEBUG_P("SubsequentSolidFillRect");
751
destaddr = (y * pScrn->displayWidth + x) * cAcl->BytesPerPixel;
753
destaddr += cAcl->FbOffset;
755
w *= cAcl->BytesPerPixel;
757
ctSETDSTADDR(destaddr);
758
ctSETHEIGHTWIDTHGO(h, w);
762
* Screen-to-screen BitBLT.
767
CTNAME(SetupForScreenToScreenCopy)(ScrnInfoPtr pScrn, int xdir, int ydir,
768
int rop, unsigned int planemask, int trans)
770
CHIPSPtr cPtr = CHIPSPTR(pScrn);
771
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
773
DEBUG_P("SetupForScreenToScreenCopy");
774
cAcl->CommandFlags = 0;
776
/* Set up the blit direction. */
778
cAcl->CommandFlags |= ctBOTTOM2TOP;
780
cAcl->CommandFlags |= ctTOP2BOTTOM;
782
cAcl->CommandFlags |= ctRIGHT2LEFT;
784
cAcl->CommandFlags |= ctLEFT2RIGHT;
787
cAcl->CommandFlags |= ctCOLORTRANSENABLE | ctCOLORTRANSROP |
790
/* BR03[0x27] sometimes set after reset, so must ensure it is zero */
791
ctSETMONOCTL(ctDWORDALIGN);
792
switch (cAcl->BitsPerPixel) {
794
ctSETBGCOLOR8(trans);
797
ctSETBGCOLOR16(trans);
800
ctSETBGCOLOR24(trans);
806
switch (cAcl->BitsPerPixel) {
809
if ((planemask & 0xFF) == 0xFF) {
810
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
812
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
813
ctSETPATSRCADDR(cAcl->ScratchAddress);
814
ctWRITEPLANEMASK8(planemask, cAcl->ScratchAddress);
818
if ((planemask & 0xFFFF) == 0xFFFF) {
819
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
821
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
822
ctSETPATSRCADDR(cAcl->ScratchAddress);
823
ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress);
828
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
831
ctSETPITCH(cAcl->PitchInBytes, cAcl->PitchInBytes);
835
CTNAME(SubsequentScreenToScreenCopy)(ScrnInfoPtr pScrn, int srcX, int srcY,
836
int dstX, int dstY, int w, int h)
838
CHIPSPtr cPtr = CHIPSPTR(pScrn);
839
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
840
unsigned int srcaddr, destaddr;
842
DEBUG_P("SubsequentScreenToScreenCopy");
844
if (cAcl->CommandFlags & ctBOTTOM2TOP) {
845
srcaddr = (srcY + h - 1) * pScrn->displayWidth;
846
destaddr = (dstY + h - 1) * pScrn->displayWidth;
848
srcaddr = srcY * pScrn->displayWidth;
849
destaddr = dstY * pScrn->displayWidth;
851
if (cAcl->CommandFlags & ctRIGHT2LEFT) {
852
srcaddr = ( srcaddr + srcX + w ) * cAcl->BytesPerPixel - 1 ;
853
destaddr = ( destaddr + dstX + w ) * cAcl->BytesPerPixel - 1;
855
srcaddr = (srcaddr + srcX) * cAcl->BytesPerPixel;
856
destaddr = (destaddr + dstX) * cAcl->BytesPerPixel;
858
srcaddr += cAcl->FbOffset;
859
destaddr += cAcl->FbOffset;
861
if (cAcl->CommandFlags & ctTOP2BOTTOM) {
862
srcaddr = srcY * pScrn->displayWidth;
863
destaddr = dstY * pScrn->displayWidth;
865
srcaddr = (srcY + h - 1) * pScrn->displayWidth;
866
destaddr = (dstY + h - 1) * pScrn->displayWidth;
868
if (cAcl->CommandFlags & ctLEFT2RIGHT) {
869
srcaddr = (srcaddr + srcX) * cAcl->BytesPerPixel;
870
destaddr = (destaddr + dstX) * cAcl->BytesPerPixel;
872
srcaddr = ( srcaddr + srcX + w ) * cAcl->BytesPerPixel - 1 ;
873
destaddr = ( destaddr + dstX + w ) * cAcl->BytesPerPixel - 1;
876
w *= cAcl->BytesPerPixel;
878
ctSETSRCADDR(srcaddr);
879
ctSETDSTADDR(destaddr);
880
ctSETHEIGHTWIDTHGO(h, w);
885
CTNAME(SetupForCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, int fg,
886
int bg, int rop, unsigned int planemask)
888
CHIPSPtr cPtr = CHIPSPTR(pScrn);
889
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
891
DEBUG_P("SetupForCPUToScreenColorExpandFill");
893
cAcl->CommandFlags = 0;
895
cAcl->CommandFlags |= ctBGTRANSPARENT; /* Background = Destination */
896
switch (cAcl->BitsPerPixel) {
913
switch (cAcl->BitsPerPixel) {
935
ctSETMONOCTL(ctDWORDALIGN);
940
switch (cAcl->BitsPerPixel) {
942
if ((planemask & 0xFF) == 0xFF) {
943
ctSETROP(ctSRCSYSTEM | ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
944
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
946
ctSETROP(ctSRCSYSTEM | ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
947
ChipsAluConv3[rop & 0xF] | cAcl->CommandFlags);
948
ctSETPATSRCADDR(cAcl->ScratchAddress);
949
ctWRITEPLANEMASK8(planemask, cAcl->ScratchAddress);
953
if ((planemask & 0xFFFF) == 0xFFFF) {
954
ctSETROP(ctSRCSYSTEM | ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
955
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
957
ctSETROP(ctSRCSYSTEM | ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
958
ChipsAluConv3[rop & 0xF] | cAcl->CommandFlags);
959
ctSETPATSRCADDR(cAcl->ScratchAddress);
960
ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress);
964
ctSETROP(ctSRCSYSTEM | ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
965
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
968
ctSETPITCH(0, cAcl->PitchInBytes);
972
CTNAME(SubsequentCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn,
973
int x, int y, int w, int h, int skipleft)
975
CHIPSPtr cPtr = CHIPSPTR(pScrn);
976
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
979
DEBUG_P("SubsequentCPUToScreenColorExpandFill");
980
destaddr = (y * pScrn->displayWidth + x + skipleft) *
983
destaddr += cAcl->FbOffset;
985
w = (w - skipleft) * cAcl->BytesPerPixel;
987
ctSETDSTADDR(destaddr);
989
ctSETMONOCTL(ctDWORDALIGN | ctCLIPLEFT(skipleft));
991
ctSETHEIGHTWIDTHGO(h, w);
994
#if !defined(CHIPS_HIQV) || defined(UNDOCUMENTED_FEATURE)
996
CTNAME(SetupForScreenToScreenColorExpandFill)(ScrnInfoPtr pScrn,
997
int fg, int bg, int rop,
998
unsigned int planemask)
1000
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1001
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1003
DEBUG_P("SetupForScreenToScreenColorExpandFill");
1004
cAcl->CommandFlags = 0;
1007
cAcl->CommandFlags |= ctBGTRANSPARENT; /* Background = Destination */
1008
switch (cAcl->BitsPerPixel) {
1025
switch (cAcl->BitsPerPixel) {
1046
switch (cAcl->BitsPerPixel) {
1048
if ((planemask & 0xFF) == 0xFF) {
1049
ctSETROP(ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1050
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
1052
ctSETROP(ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1053
ChipsAluConv3[rop & 0xF] | cAcl->CommandFlags);
1054
ctSETPATSRCADDR(cAcl->ScratchAddress);
1055
ctWRITEPLANEMASK8(planemask, cAcl->ScratchAddress);
1059
if ((planemask & 0xFFFF) == 0xFFFF) {
1060
ctSETROP(ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1061
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
1063
ctSETROP(ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1064
ChipsAluConv3[rop & 0xF] | cAcl->CommandFlags);
1065
ctSETPATSRCADDR(cAcl->ScratchAddress);
1066
ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress);
1070
ctSETROP(ctSRCMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1071
ChipsAluConv[rop & 0xF] | cAcl->CommandFlags);
1074
ctSETPITCH(cAcl->PitchInBytes, cAcl->PitchInBytes);
1079
* The non-HiQV chips don't have left-edge clippling of monochrome sources.
1080
* However you can have the monochrome source starting on a byte boundary.
1081
* Hence have 8 rotated copies of the monochrome source to simulate left
1082
* edge clipping with these chips. This requires the XAACacheMonoStipple
1083
* function to be replaced, if we are to use ScreenToScreenColorExpand.
1086
static XAACacheInfoPtr
1087
CTNAME(CacheMonoStipple)(ScrnInfoPtr pScrn, PixmapPtr pPix)
1089
int w = pPix->drawable.width;
1090
int h = pPix->drawable.height;
1091
XAAInfoRecPtr infoRec = (CHIPSPTR(pScrn))->AccelInfoRec;
1092
XAAPixmapCachePrivatePtr pCachePriv =
1093
(XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
1094
XAACacheInfoPtr pCache, cacheRoot = NULL;
1095
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1096
int i, j, max = 0, funcNo, pad, dwords, bpp = cAcl->BitsPerPixel;
1098
StippleScanlineProcPtr StippleFunc;
1099
unsigned char *data, *srcPtr, *dstPtr;
1101
DEBUG_P("CacheMonoStipple");
1102
if((h <= 128) && (w <= 128 * bpp / 8)) {
1103
if(pCachePriv->Info128) {
1104
cacheRoot = pCachePriv->Info128;
1105
max = pCachePriv->Num128x128;
1106
current = &pCachePriv->Current128;
1108
cacheRoot = pCachePriv->InfoPartial;
1109
max = pCachePriv->NumPartial;
1110
current = &pCachePriv->CurrentPartial;
1112
} else if((h <= 256) && (w <= 256 * bpp / 8)){
1113
cacheRoot = pCachePriv->Info256;
1114
max = pCachePriv->Num256x256;
1115
current = &pCachePriv->Current256;
1116
} else if((h <= 512) && (w <= 512 * bpp / 8)){
1117
cacheRoot = pCachePriv->Info512;
1118
max = pCachePriv->Num512x512;
1119
current = &pCachePriv->Current512;
1120
} else { /* something's wrong */
1121
ErrorF("Something's wrong in XAACacheMonoStipple()\n");
1122
return pCachePriv->Info128;
1127
/* lets look for it */
1128
for(i = 0; i < max; i++, pCache++) {
1129
if((pCache->serialNumber == pPix->drawable.serialNumber) &&
1130
(pCache->fg == -1) && (pCache->bg == -1)) {
1131
pCache->trans_color = -1;
1133
cAcl->SlotWidth = ((pCache->w * bpp) >> 5) >> 1;
1138
pCache = &cacheRoot[(*current)++];
1139
if(*current >= max) *current = 0;
1141
pCache->serialNumber = pPix->drawable.serialNumber;
1142
pCache->trans_color = pCache->bg = pCache->fg = -1;
1143
pCache->orig_w = w; pCache->orig_h = h;
1146
if(w & (w - 1)) funcNo = 1;
1150
pad = (((pCache->w * bpp) + 31) >> 5) << 2;
1151
dstPtr = data = (unsigned char*)ALLOCATE_LOCAL(pad * pCache->h);
1152
srcPtr = (unsigned char*)pPix->devPrivate.ptr;
1153
StippleFunc = XAAStippleScanlineFuncMSBFirst[funcNo];
1155
dwords = ((pCache->w * bpp) >> 5) >> 3;
1156
cAcl->SlotWidth = dwords << 2;
1158
for(i = 0; i < h; i++) {
1159
for(j = 0; j < 8; j++) {
1160
(*StippleFunc)((CARD32*)dstPtr + j * dwords,
1161
(CARD32*)srcPtr, j, w, dwords);
1163
srcPtr += pPix->devKind;
1167
while((h<<1) <= pCache->h) {
1168
memcpy(data + (pad * h), data, pad * h);
1173
memcpy(data + (pad * h), data, pad * (pCache->h - h));
1175
(*infoRec->WritePixmapToCache)(
1176
pScrn, pCache->x, pCache->y, pCache->w, pCache->h, data,
1177
pad, bpp, pScrn->depth);
1179
DEALLOCATE_LOCAL(data);
1184
#if !defined(CHIPS_HIQV) || defined(UNDOCUMENTED_FEATURE)
1186
CTNAME(SubsequentScreenToScreenColorExpandFill)(ScrnInfoPtr pScrn,
1187
int x, int y, int w, int h,
1188
int srcx, int srcy, int skipleft)
1190
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1191
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1192
int srcaddr, destaddr;
1194
DEBUG_P("SubsequentScreenToScreenColorExpandFill");
1196
srcaddr = (srcy * pScrn->displayWidth + srcx) * cAcl->BytesPerPixel
1197
+ ((skipleft & ~0x3F) >> 3);
1198
if ( y < pScrn->virtualY)
1199
srcaddr += cAcl->FbOffset;
1201
srcaddr += cPtr->FbOffset16;
1203
srcaddr = (srcy * pScrn->displayWidth + srcx) * cAcl->BytesPerPixel
1204
+ ((skipleft & 0x07) * cAcl->SlotWidth)
1205
+ ((skipleft & ~0x07) >> 3);
1207
destaddr = (y * pScrn->displayWidth + x) * cAcl->BytesPerPixel;
1209
destaddr += cAcl->FbOffset;
1211
w *= cAcl->BytesPerPixel;
1214
if ((y >= pScrn->virtualY) && (cPtr->Flags & ChipsOverlay8plus16) &&
1215
(pScrn->depth == 8))
1216
ctSETPITCH(cAcl->PitchInBytes << 1, cAcl->PitchInBytes);
1218
ctSETSRCADDR(srcaddr);
1219
ctSETDSTADDR(destaddr);
1221
ctSETMONOCTL(ctCLIPLEFT(skipleft & 0x3F));
1223
ctSETHEIGHTWIDTHGO(h, w);
1227
CTNAME(SetupForColor8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty,
1228
int rop, unsigned int planemask,
1231
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1232
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1233
unsigned int patternaddr;
1235
DEBUG_P("SetupForColor8x8PatternFill");
1236
cAcl->CommandFlags = ChipsAluConv2[rop & 0xF] | ctTOP2BOTTOM |
1238
patternaddr = (paty * pScrn->displayWidth +
1239
(patx & ~0x3F)) * cAcl->BytesPerPixel;
1240
cAcl->patternyrot = (patx & 0x3F) >> 3;
1242
if (cPtr->Flags & ChipsOverlay8plus16)
1243
patternaddr += cPtr->FbOffset16;
1247
ctSETPATSRCADDR(patternaddr);
1250
cAcl->CommandFlags |= ctCOLORTRANSENABLE | ctCOLORTRANSROP |
1252
ctSETMONOCTL(ctDWORDALIGN);
1253
switch (cAcl->BitsPerPixel) {
1255
ctSETBGCOLOR8(trans);
1258
ctSETBGCOLOR16(trans);
1261
ctSETBGCOLOR24(trans);
1266
ctSETPITCH(8 * cAcl->BytesPerPixel, cAcl->PitchInBytes);
1270
CTNAME(SubsequentColor8x8PatternFillRect)(ScrnInfoPtr pScrn, int patx, int paty,
1271
int x, int y, int w, int h)
1273
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1274
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1275
unsigned int destaddr;
1277
DEBUG_P("SubsequentColor8x8PatternFillRect");
1278
destaddr = (y * pScrn->displayWidth + x) * cAcl->BytesPerPixel;
1280
destaddr += cAcl->FbOffset;
1282
w *= cAcl->BytesPerPixel;
1284
ctSETDSTADDR(destaddr);
1286
ctSETROP(cAcl->CommandFlags | (((y + cAcl->patternyrot) & 0x7) << 20));
1288
ctSETROP(cAcl->CommandFlags | (((y + cAcl->patternyrot) & 0x7) << 16));
1290
ctSETHEIGHTWIDTHGO(h, w);
1294
CTNAME(SetupForMono8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty,
1295
int fg, int bg, int rop,
1296
unsigned int planemask)
1298
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1299
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1300
unsigned int patternaddr;
1302
DEBUG_P("SetupForMono8x8PatternFill");
1303
cAcl->CommandFlags = ctPATMONO | ctTOP2BOTTOM | ctLEFT2RIGHT |
1304
ChipsAluConv2[rop & 0xF];
1307
patternaddr = paty * pScrn->displayWidth + patx;
1308
if (cPtr->Flags & ChipsOverlay8plus16)
1309
patternaddr = patternaddr * 2 + cPtr->FbOffset16;
1311
patternaddr *= cAcl->BytesPerPixel;
1313
patternaddr = (paty * pScrn->displayWidth + patx) * cAcl->BytesPerPixel;
1316
ctSETPATSRCADDR(patternaddr);
1318
cAcl->CommandFlags |= ctBGTRANSPARENT; /* Background = Destination */
1319
switch (cAcl->BitsPerPixel) {
1332
switch (cAcl->BitsPerPixel) {
1348
ctSETMONOCTL(ctDWORDALIGN);
1350
ctSETPITCH(1,cAcl->PitchInBytes);
1354
CTNAME(SubsequentMono8x8PatternFillRect)(ScrnInfoPtr pScrn, int patx,
1355
int paty, int x, int y, int w, int h )
1357
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1358
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1360
DEBUG_P("SubsequentMono8x8PatternFillRect");
1361
destaddr = (y * pScrn->displayWidth + x) * cAcl->BytesPerPixel;
1363
destaddr += cAcl->FbOffset;
1365
w *= cAcl->BytesPerPixel;
1368
ctSETDSTADDR(destaddr);
1370
ctSETROP(cAcl->CommandFlags | ((y & 0x7) << 20));
1372
ctSETROP(cAcl->CommandFlags | ((y & 0x7) << 16));
1374
ctSETHEIGHTWIDTHGO(h, w);
1379
CTNAME(SetupForImageWrite)(ScrnInfoPtr pScrn, int rop, unsigned int planemask,
1380
int transparency_color, int bpp, int depth)
1382
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1383
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1385
DEBUG_P("SetupForImageWrite");
1386
cAcl->CommandFlags = ctSRCSYSTEM | ctTOP2BOTTOM | ctLEFT2RIGHT;
1389
switch (cAcl->BitsPerPixel) {
1391
if ((planemask & 0xFF) == 0xFF) {
1392
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1394
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
1395
ctSETPATSRCADDR(cAcl->ScratchAddress);
1396
ctWRITEPLANEMASK8(planemask, cAcl->ScratchAddress);
1400
if ((planemask & 0xFFFF) == 0xFFFF) {
1401
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1403
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
1404
ctSETPATSRCADDR(cAcl->ScratchAddress);
1405
ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress);
1409
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1416
CTNAME(SubsequentImageWriteRect)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
1419
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1420
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1421
int destaddr = (y * pScrn->displayWidth + x) * cAcl->BytesPerPixel;
1422
DEBUG_P("SubsequentImageWriteRect");
1423
w *= cAcl->BytesPerPixel;
1425
ctSETPITCH(((w + 3) & ~0x3), cAcl->PitchInBytes);
1426
ctSETDSTADDR(destaddr);
1427
ctSETHEIGHTWIDTHGO(h, w);
1433
* Digital Equipment Corporation. All rights reserved.
1434
* This software is furnished under license and may be used and copied only in
1435
* accordance with the following terms and conditions. Subject to these
1436
* conditions, you may download, copy, install, use, modify and distribute
1437
* this software in source and/or binary form. No title or ownership is
1438
* transferred hereby.
1439
* 1) Any source code used, modified or distributed must reproduce and retain
1440
* this copyright notice and list of conditions as they appear in the
1443
* 2) No right is granted to use any trade name, trademark, or logo of Digital
1444
* Equipment Corporation. Neither the "Digital Equipment Corporation" name
1445
* nor any trademark or logo of Digital Equipment Corporation may be used
1446
* to endorse or promote products derived from this software without the
1447
* prior written permission of Digital Equipment Corporation.
1449
* 3) This software is provided "AS-IS" and any express or implied warranties,
1450
* including but not limited to, any implied warranties of merchantability,
1451
* fitness for a particular purpose, or non-infringement are disclaimed. In
1452
* no event shall DIGITAL be liable for any damages whatsoever, and in
1453
* particular, DIGITAL shall not be liable for special, indirect,
1454
* consequential, or incidental damages or damages for lost profits, loss
1455
* of revenue or loss of use, whether such damages arise in contract,
1456
* negligence, tort, under statute, in equity, at law or otherwise, even if
1457
* advised of the possibility of such damage.
1460
/* The code below comes from the idea supplied by the people at DEC, like
1461
* the copyright above says. But its had to go through a large evolution
1462
* to fit it into the new design for XFree86 4.0
1466
MoveDWORDS(register CARD32* dest, register CARD32* src, register int dwords )
1468
while(dwords & ~0x03) {
1470
*(dest + 1) = *(src + 1);
1471
*(dest + 2) = *(src + 2);
1472
*(dest + 3) = *(src + 3);
1483
*(dest + 1) = *(src + 1);
1487
*(dest + 1) = *(src + 1);
1488
*(dest + 2) = *(src + 2);
1493
static __inline__ void
1494
MoveDataFromCPU(unsigned char *src, unsigned char *dest, int srcwidth,
1495
int window, int h, int dwords)
1497
if(srcwidth == (dwords << 2)) {
1498
int decrement = window / dwords;
1499
while(h > decrement) {
1500
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords * decrement);
1501
src += (srcwidth * decrement);
1505
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords * h);
1509
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords);
1515
static __inline__ void
1516
MoveDataToCPU(unsigned char *src, unsigned char *dest, int dstwidth,
1517
int window, int h, int dwords)
1519
if(dstwidth == (dwords << 2)) {
1520
int decrement = window / dwords;
1521
while(h > decrement) {
1522
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords * decrement);
1523
dest += (dstwidth * decrement);
1527
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords * h);
1531
MoveDWORDS((CARD32*)dest, (CARD32*)src, dwords);
1538
CTNAME(WritePixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
1539
unsigned char *src, int srcwidth, int rop,
1540
unsigned int planemask, int trans, int bpp, int depth)
1542
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1543
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1544
unsigned int bytesPerLine;
1545
unsigned int byteWidthSrc;
1546
unsigned int destpitch;
1551
DEBUG_P("WritePixmap");
1553
ErrorF("WritePixmap x %d, y %d, w %d, h %d, src 0x%X, srcwidth %d, rop 0x%X, planemask 0x%X, trans 0x%X, bpp %d, depth %d\n", x, y, w, h, src, srcwidth, rop, planemask, trans, bpp, depth);
1555
bytesPerLine = w * (bpp >> 3);
1556
byteWidthSrc = ((srcwidth * (bpp >> 3) + 3L) & ~0x3L);
1557
cAcl->CommandFlags = ctSRCSYSTEM | ctLEFT2RIGHT | ctTOP2BOTTOM;
1558
skipleft = (unsigned long)src & 0x7;
1559
src = (unsigned char *)((unsigned long)src & ~0x7L);
1560
dwords = (((skipleft + bytesPerLine + 0x7) & ~0x7)) >> 2;
1561
destaddr = (y * pScrn->displayWidth + x) * (bpp >> 3);
1562
destpitch = pScrn->displayWidth * (bpp >> 3);
1563
if ((y >= pScrn->virtualY) && (cPtr->Flags & ChipsOverlay8plus16))
1564
destaddr += cPtr->FbOffset16;
1566
destaddr += cAcl->FbOffset;
1571
cAcl->CommandFlags |= ctCOLORTRANSENABLE | ctCOLORTRANSROP |
1573
ctSETMONOCTL(ctDWORDALIGN);
1574
switch (cAcl->BitsPerPixel) {
1576
ctSETBGCOLOR8(trans);
1579
ctSETBGCOLOR16(trans);
1582
ctSETBGCOLOR24(trans);
1587
switch (cAcl->BitsPerPixel) {
1589
if ((planemask & 0xFF) == 0xFF) {
1590
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1592
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
1593
ctSETPATSRCADDR(cAcl->ScratchAddress);
1594
ctWRITEPLANEMASK8(planemask, cAcl->ScratchAddress);
1598
if ((planemask & 0xFFFF) == 0xFFFF) {
1599
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1601
ctSETROP(cAcl->CommandFlags | ChipsAluConv3[rop & 0xF]);
1602
ctSETPATSRCADDR(cAcl->ScratchAddress);
1603
ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress);
1607
ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]);
1613
* CT6555X requires quad-word padding, but XAA provides double-word
1614
* padding. If the width of a region to be transferred happens to be
1615
* quad-word aligned, the transfer is straightforward. If the
1616
* region is double-word aligned, a pair of contiguous scanlines
1617
* is quad-word aligned. In latter case, we can use interleaved
1618
* transfer twice. It is faster than transfer line by line.
1622
ctSETSRCADDR(skipleft);
1623
ctSETDSTADDR(destaddr);
1625
if ((byteWidthSrc & 0x7) == 0) { /* quad-word aligned */
1627
ctSETPITCH(byteWidthSrc, destpitch);
1628
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1630
MoveDataFromCPU((unsigned char *)src,
1631
(unsigned char *)cAcl->BltDataWindow,
1632
srcwidth, 16384, h, dwords);
1635
unsigned int vert = h;
1637
h = (vert + 1) >> 1;
1639
ctSETPITCH(byteWidthSrc << 1, destpitch << 1);
1640
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1642
MoveDataFromCPU((unsigned char *)src,
1643
(unsigned char *)cAcl->BltDataWindow,
1644
srcwidth<<1, 16384, h, dwords);
1650
destaddr = (y * pScrn->displayWidth + x) * (bpp >> 3);
1651
if ((y >= pScrn->virtualY) && (cPtr->Flags & ChipsOverlay8plus16))
1652
destaddr += cPtr->FbOffset16;
1654
destaddr += cAcl->FbOffset;
1657
ctSETDSTADDR(destaddr);
1658
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1660
MoveDataFromCPU((unsigned char *)src,
1661
(unsigned char *)cAcl->BltDataWindow,
1662
srcwidth<<1, 16384, h, dwords);
1665
cPtr->AccelInfoRec->NeedToSync = TRUE;
1670
CTNAME(ReadPixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
1671
unsigned char *dst, int dstwidth, int bpp, int depth)
1673
CHIPSPtr cPtr = CHIPSPTR(pScrn);
1674
CHIPSACLPtr cAcl = CHIPSACLPTR(pScrn);
1675
unsigned int bytesPerLine;
1676
unsigned int byteWidthDst;
1677
unsigned int srcpitch;
1681
DEBUG_P("ReadPixmap");
1682
bytesPerLine = w * (bpp >> 3);
1683
byteWidthDst = ((dstwidth * (bpp >> 3) + 3L) & ~0x3L);
1684
dwords = (((bytesPerLine + 0x7) & ~0x7)) >> 2;
1685
srcaddr = (y * pScrn->displayWidth + x) * (bpp >> 3);
1686
srcpitch = pScrn->displayWidth * (bpp >> 3);
1687
if ((y >= pScrn->virtualY) && (cPtr->Flags & ChipsOverlay8plus16))
1688
srcaddr += cPtr->FbOffset16;
1690
srcaddr += cAcl->FbOffset;
1693
ctSETROP( ctDSTSYSTEM | ctLEFT2RIGHT | ctTOP2BOTTOM |
1694
ChipsAluConv[GXcopy & 0xF]);
1696
ctSETSRCADDR(srcaddr);
1698
if ((byteWidthDst & 0x7) == 0) { /* quad-word aligned */
1700
ctSETPITCH(srcpitch, byteWidthDst);
1701
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1703
MoveDataToCPU((unsigned char *)cAcl->BltDataWindow,
1704
(unsigned char *)dst, dstwidth, 16384, h, dwords);
1707
unsigned int vert = h;
1709
h = (vert + 1) >> 1;
1711
ctSETPITCH(srcpitch << 1, byteWidthDst << 1);
1712
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1714
MoveDataToCPU((unsigned char *)cAcl->BltDataWindow,
1715
(unsigned char *)dst, dstwidth<<1, 16384, h, dwords);
1720
srcaddr = (y * pScrn->displayWidth + x) * (bpp >> 3);
1721
if ((y >= pScrn->virtualY) && (cPtr->Flags & ChipsOverlay8plus16))
1722
srcaddr += cPtr->FbOffset16;
1724
srcaddr += cAcl->FbOffset;
1726
ctSETSRCADDR(srcaddr);
1727
ctSETHEIGHTWIDTHGO(h, bytesPerLine);
1729
MoveDataToCPU((unsigned char *)cAcl->BltDataWindow,
1730
(unsigned char *)dst, dstwidth<<1, 16384, h, dwords);
1733
cPtr->AccelInfoRec->NeedToSync = TRUE;
1735
#endif /* ReadPixmap */