nv_xaa.c revision a8c27980
1/* 2 * Copyright (c) 2003 NVIDIA, Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24#ifdef HAVE_CONFIG_H 25#include "config.h" 26#endif 27 28#include "nv_include.h" 29#ifdef HAVE_XAA_H 30#include "xaalocal.h" 31#endif 32#include "miline.h" 33#include "nv_dma.h" 34 35static const int NVCopyROP[16] = 36{ 37 0x00, /* GXclear */ 38 0x88, /* GXand */ 39 0x44, /* GXandReverse */ 40 0xCC, /* GXcopy */ 41 0x22, /* GXandInverted */ 42 0xAA, /* GXnoop */ 43 0x66, /* GXxor */ 44 0xEE, /* GXor */ 45 0x11, /* GXnor */ 46 0x99, /* GXequiv */ 47 0x55, /* GXinvert*/ 48 0xDD, /* GXorReverse */ 49 0x33, /* GXcopyInverted */ 50 0xBB, /* GXorInverted */ 51 0x77, /* GXnand */ 52 0xFF /* GXset */ 53}; 54 55static const int NVCopyROP_PM[16] = 56{ 57 0x0A, /* GXclear */ 58 0x8A, /* GXand */ 59 0x4A, /* GXandReverse */ 60 0xCA, /* GXcopy */ 61 0x2A, /* GXandInverted */ 62 0xAA, /* GXnoop */ 63 0x6A, /* GXxor */ 64 0xEA, /* GXor */ 65 0x1A, /* GXnor */ 66 0x9A, /* GXequiv */ 67 0x5A, /* GXinvert*/ 68 0xDA, /* GXorReverse */ 69 0x3A, /* GXcopyInverted */ 70 0xBA, /* GXorInverted */ 71 0x7A, /* GXnand */ 72 0xFA /* GXset */ 73}; 74 75#ifdef HAVE_XAA_H 76static const int NVPatternROP[16] = 77{ 78 0x00, 79 0xA0, 80 0x50, 81 0xF0, 82 0x0A, 83 0xAA, 84 0x5A, 85 0xFA, 86 0x05, 87 0xA5, 88 0x55, 89 0xF5, 90 0x0F, 91 0xAF, 92 0x5F, 93 0xFF 94}; 95#endif 96 97void 98NVDmaKickoff(NVPtr pNv) 99{ 100 if(pNv->dmaCurrent != pNv->dmaPut) { 101 pNv->dmaPut = pNv->dmaCurrent; 102 WRITE_PUT(pNv, pNv->dmaPut); 103 } 104} 105 106 107/* There is a HW race condition with videoram command buffers. 108 You can't jump to the location of your put offset. We write put 109 at the jump offset + SKIPS dwords with noop padding in between 110 to solve this problem */ 111#define SKIPS 8 112 113void 114NVDmaWait ( 115 NVPtr pNv, 116 int size 117){ 118 int dmaGet; 119 120 size++; 121 122 while(pNv->dmaFree < size) { 123 dmaGet = READ_GET(pNv); 124 125 if(pNv->dmaPut >= dmaGet) { 126 pNv->dmaFree = pNv->dmaMax - pNv->dmaCurrent; 127 if(pNv->dmaFree < size) { 128 NVDmaNext(pNv, 0x20000000); 129 if(dmaGet <= SKIPS) { 130 if(pNv->dmaPut <= SKIPS) /* corner case - will be idle */ 131 WRITE_PUT(pNv, SKIPS + 1); 132 do { dmaGet = READ_GET(pNv); } 133 while(dmaGet <= SKIPS); 134 } 135 WRITE_PUT(pNv, SKIPS); 136 pNv->dmaCurrent = pNv->dmaPut = SKIPS; 137 pNv->dmaFree = dmaGet - (SKIPS + 1); 138 } 139 } else 140 pNv->dmaFree = dmaGet - pNv->dmaCurrent - 1; 141 } 142} 143 144void 145NVWaitVSync(NVPtr pNv) 146{ 147 NVDmaStart(pNv, 0x0000A12C, 1); 148 NVDmaNext (pNv, 0); 149 NVDmaStart(pNv, 0x0000A134, 1); 150 NVDmaNext (pNv, pNv->CRTCnumber); 151 NVDmaStart(pNv, 0x0000A100, 1); 152 NVDmaNext (pNv, 0); 153 NVDmaStart(pNv, 0x0000A130, 1); 154 NVDmaNext (pNv, 0); 155} 156 157/* 158 currentRop = 0-15 solid fill 159 16-31 8x8 pattern fill 160 32-47 solid fill with planemask 161*/ 162 163static void 164NVSetPattern( 165 ScrnInfoPtr pScrn, 166 CARD32 clr0, 167 CARD32 clr1, 168 CARD32 pat0, 169 CARD32 pat1 170) 171{ 172 NVPtr pNv = NVPTR(pScrn); 173 174 NVDmaStart(pNv, PATTERN_COLOR_0, 4); 175 NVDmaNext (pNv, clr0); 176 NVDmaNext (pNv, clr1); 177 NVDmaNext (pNv, pat0); 178 NVDmaNext (pNv, pat1); 179} 180 181void 182NVSetRopSolid(ScrnInfoPtr pScrn, CARD32 rop, CARD32 planemask) 183{ 184 NVPtr pNv = NVPTR(pScrn); 185 186 if(planemask != ~0) { 187 NVSetPattern(pScrn, 0, planemask, ~0, ~0); 188 if(pNv->currentRop != (rop + 32)) { 189 NVDmaStart(pNv, ROP_SET, 1); 190 NVDmaNext (pNv, NVCopyROP_PM[rop]); 191 pNv->currentRop = rop + 32; 192 } 193 } else 194 if (pNv->currentRop != rop) { 195 if(pNv->currentRop >= 16) 196 NVSetPattern(pScrn, ~0, ~0, ~0, ~0); 197 NVDmaStart(pNv, ROP_SET, 1); 198 NVDmaNext (pNv, NVCopyROP[rop]); 199 pNv->currentRop = rop; 200 } 201} 202 203void NVResetGraphics(ScrnInfoPtr pScrn) 204{ 205 NVPtr pNv = NVPTR(pScrn); 206 CARD32 surfaceFormat, patternFormat, rectFormat, lineFormat; 207 int pitch, i; 208 209 if(pNv->NoAccel) return; 210 211 pitch = pNv->CurrentLayout.displayWidth * 212 (pNv->CurrentLayout.bitsPerPixel >> 3); 213 214 pNv->dmaBase = (CARD32*)(&pNv->FbStart[pNv->FbUsableSize]); 215 216 for(i = 0; i < SKIPS; i++) 217 pNv->dmaBase[i] = 0x00000000; 218 219 pNv->dmaBase[0x0 + SKIPS] = 0x00040000; 220 pNv->dmaBase[0x1 + SKIPS] = 0x80000010; 221 pNv->dmaBase[0x2 + SKIPS] = 0x00042000; 222 pNv->dmaBase[0x3 + SKIPS] = 0x80000011; 223 pNv->dmaBase[0x4 + SKIPS] = 0x00044000; 224 pNv->dmaBase[0x5 + SKIPS] = 0x80000012; 225 pNv->dmaBase[0x6 + SKIPS] = 0x00046000; 226 pNv->dmaBase[0x7 + SKIPS] = 0x80000013; 227 pNv->dmaBase[0x8 + SKIPS] = 0x00048000; 228 pNv->dmaBase[0x9 + SKIPS] = 0x80000014; 229 pNv->dmaBase[0xA + SKIPS] = 0x0004A000; 230 pNv->dmaBase[0xB + SKIPS] = 0x80000015; 231 pNv->dmaBase[0xC + SKIPS] = 0x0004C000; 232 pNv->dmaBase[0xD + SKIPS] = 0x80000016; 233 pNv->dmaBase[0xE + SKIPS] = 0x0004E000; 234 pNv->dmaBase[0xF + SKIPS] = 0x80000017; 235 236 pNv->dmaPut = 0; 237 pNv->dmaCurrent = 16 + SKIPS; 238 pNv->dmaMax = 8191; 239 pNv->dmaFree = pNv->dmaMax - pNv->dmaCurrent; 240 241 switch(pNv->CurrentLayout.depth) { 242 case 24: 243 surfaceFormat = SURFACE_FORMAT_DEPTH24; 244 patternFormat = PATTERN_FORMAT_DEPTH24; 245 rectFormat = RECT_FORMAT_DEPTH24; 246 lineFormat = LINE_FORMAT_DEPTH24; 247 break; 248 case 16: 249 case 15: 250 surfaceFormat = SURFACE_FORMAT_DEPTH16; 251 patternFormat = PATTERN_FORMAT_DEPTH16; 252 rectFormat = RECT_FORMAT_DEPTH16; 253 lineFormat = LINE_FORMAT_DEPTH16; 254 break; 255 default: 256 surfaceFormat = SURFACE_FORMAT_DEPTH8; 257 patternFormat = PATTERN_FORMAT_DEPTH8; 258 rectFormat = RECT_FORMAT_DEPTH8; 259 lineFormat = LINE_FORMAT_DEPTH8; 260 break; 261 } 262 263 NVDmaStart(pNv, SURFACE_FORMAT, 4); 264 NVDmaNext (pNv, surfaceFormat); 265 NVDmaNext (pNv, pitch | (pitch << 16)); 266 NVDmaNext (pNv, 0); 267 NVDmaNext (pNv, 0); 268 269 NVDmaStart(pNv, PATTERN_FORMAT, 1); 270 NVDmaNext (pNv, patternFormat); 271 272 NVDmaStart(pNv, RECT_FORMAT, 1); 273 NVDmaNext (pNv, rectFormat); 274 275 NVDmaStart(pNv, LINE_FORMAT, 1); 276 NVDmaNext (pNv, lineFormat); 277 278 pNv->currentRop = ~0; /* set to something invalid */ 279 NVSetRopSolid(pScrn, GXcopy, ~0); 280 281 NVDmaKickoff(pNv); 282} 283 284void NVSync(ScrnInfoPtr pScrn) 285{ 286 NVPtr pNv = NVPTR(pScrn); 287 int bail = 10000000; 288 289 if(pNv->DMAKickoffCallback) 290 (*pNv->DMAKickoffCallback)(pScrn); 291 292 while((READ_GET(pNv) != pNv->dmaPut) && (bail > 0)) bail--; 293 if (bail == 0) { 294 xf86Msg(X_ERROR, "DMA drain timeout\n"); 295 goto crap; 296 } 297 298 bail = 10000000; 299 while((pNv->PGRAPH[0x0700/4]) && (bail > 0)) bail--; 300 if (bail == 0) { 301 xf86Msg(X_ERROR, "engine stalled\n"); 302 goto crap; 303 } 304 return; 305 306crap: 307 NVResetGraphics(pScrn); 308} 309 310void 311NVDMAKickoffCallback (ScrnInfoPtr pScrn) 312{ 313 NVPtr pNv = NVPTR(pScrn); 314 315 NVDmaKickoff(pNv); 316 pNv->DMAKickoffCallback = NULL; 317} 318 319#ifdef HAVE_XAA_H 320static void 321NVSetupForScreenToScreenCopy( 322 ScrnInfoPtr pScrn, 323 int xdir, int ydir, 324 int rop, 325 unsigned planemask, 326 int transparency_color 327) 328{ 329 NVPtr pNv = NVPTR(pScrn); 330 331 planemask |= ~0 << pNv->CurrentLayout.depth; 332 333 NVSetRopSolid(pScrn, rop, planemask); 334 335 pNv->DMAKickoffCallback = NVDMAKickoffCallback; 336} 337 338static void 339NVSubsequentScreenToScreenCopy( 340 ScrnInfoPtr pScrn, 341 int x1, int y1, 342 int x2, int y2, 343 int w, int h 344) 345{ 346 NVPtr pNv = NVPTR(pScrn); 347 348 NVDmaStart(pNv, BLIT_POINT_SRC, 3); 349 NVDmaNext (pNv, (y1 << 16) | x1); 350 NVDmaNext (pNv, (y2 << 16) | x2); 351 NVDmaNext (pNv, (h << 16) | w); 352 353 if((w * h) >= 512) 354 NVDmaKickoff(pNv); 355} 356 357static void 358NVSetupForSolidFill( 359 ScrnInfoPtr pScrn, 360 int color, 361 int rop, 362 unsigned planemask 363) 364{ 365 NVPtr pNv = NVPTR(pScrn); 366 367 planemask |= ~0 << pNv->CurrentLayout.depth; 368 369 NVSetRopSolid(pScrn, rop, planemask); 370 NVDmaStart(pNv, RECT_SOLID_COLOR, 1); 371 NVDmaNext (pNv, color); 372 373 pNv->DMAKickoffCallback = NVDMAKickoffCallback; 374} 375 376static void 377NVSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) 378{ 379 NVPtr pNv = NVPTR(pScrn); 380 381 NVDmaStart(pNv, RECT_SOLID_RECTS(0), 2); 382 NVDmaNext (pNv, (x << 16) | y); 383 NVDmaNext (pNv, (w << 16) | h); 384 385 if((w * h) >= 512) 386 NVDmaKickoff(pNv); 387} 388 389static void 390NVSetupForMono8x8PatternFill ( 391 ScrnInfoPtr pScrn, 392 int patternx, int patterny, 393 int fg, int bg, 394 int rop, 395 unsigned planemask 396) 397{ 398 NVPtr pNv = NVPTR(pScrn); 399 400 planemask = ~0 << pNv->CurrentLayout.depth; 401 402 fg |= planemask; 403 if(bg == -1) bg = 0; 404 else bg |= planemask; 405 406 if (pNv->currentRop != (rop + 16)) { 407 NVDmaStart(pNv, ROP_SET, 1); 408 NVDmaNext (pNv, NVPatternROP[rop]); 409 pNv->currentRop = rop + 16; 410 } 411 412 NVSetPattern(pScrn, bg, fg, patternx, patterny); 413 NVDmaStart(pNv, RECT_SOLID_COLOR, 1); 414 NVDmaNext (pNv, fg); 415 416 pNv->DMAKickoffCallback = NVDMAKickoffCallback; 417} 418 419static void 420NVSubsequentMono8x8PatternFillRect( 421 ScrnInfoPtr pScrn, 422 int patternx, int patterny, 423 int x, int y, 424 int w, int h 425) 426{ 427 NVPtr pNv = NVPTR(pScrn); 428 429 NVDmaStart(pNv, RECT_SOLID_RECTS(0), 2); 430 NVDmaNext (pNv, (x << 16) | y); 431 NVDmaNext (pNv, (w << 16) | h); 432 433 if((w * h) >= 512) 434 NVDmaKickoff(pNv); 435} 436 437static CARD32 _bg_pixel; 438static CARD32 _fg_pixel; 439static Bool _transparent; 440static CARD32 _color_expand_dwords; 441static CARD32 _color_expand_offset; 442static int _remaining; 443static unsigned char *_storage_buffer[1]; 444 445static void 446NVSetupForScanlineCPUToScreenColorExpandFill ( 447 ScrnInfoPtr pScrn, 448 int fg, int bg, 449 int rop, 450 unsigned int planemask 451) 452{ 453 NVPtr pNv = NVPTR(pScrn); 454 455 CARD32 mask = ~0 << pNv->CurrentLayout.depth; 456 457 planemask |= mask; 458 _fg_pixel = fg | mask; 459 460 if(bg == -1) { 461 _transparent = TRUE; 462 } else { 463 _transparent = FALSE; 464 _bg_pixel = bg | mask; 465 } 466 467 NVSetRopSolid (pScrn, rop, planemask); 468} 469 470static void 471NVSubsequentScanlineCPUToScreenColorExpandFill ( 472 ScrnInfoPtr pScrn, 473 int x, int y, 474 int w, int h, 475 int skipleft 476) 477{ 478 NVPtr pNv = NVPTR(pScrn); 479 int bw = (w + 31) & ~31; 480 481 _color_expand_dwords = bw >> 5; 482 _remaining = h; 483 484 if(_transparent) { 485 NVDmaStart(pNv, RECT_EXPAND_ONE_COLOR_CLIP, 5); 486 NVDmaNext (pNv, (y << 16) | ((x + skipleft) & 0xFFFF)); 487 NVDmaNext (pNv, ((y + h) << 16) | ((x + w) & 0xFFFF)); 488 NVDmaNext (pNv, _fg_pixel); 489 NVDmaNext (pNv, (h << 16) | bw); 490 NVDmaNext (pNv, (y << 16) | (x & 0xFFFF)); 491 _color_expand_offset = RECT_EXPAND_ONE_COLOR_DATA(0); 492 } else { 493 NVDmaStart(pNv, RECT_EXPAND_TWO_COLOR_CLIP, 7); 494 NVDmaNext (pNv, (y << 16) | ((x + skipleft) & 0xFFFF)); 495 NVDmaNext (pNv, ((y + h) << 16) | ((x + w) & 0xFFFF)); 496 NVDmaNext (pNv, _bg_pixel); 497 NVDmaNext (pNv, _fg_pixel); 498 NVDmaNext (pNv, (h << 16) | bw); 499 NVDmaNext (pNv, (h << 16) | bw); 500 NVDmaNext (pNv, (y << 16) | (x & 0xFFFF)); 501 _color_expand_offset = RECT_EXPAND_TWO_COLOR_DATA(0); 502 } 503 504 NVDmaStart(pNv, _color_expand_offset, _color_expand_dwords); 505 _storage_buffer[0] = (unsigned char*)&pNv->dmaBase[pNv->dmaCurrent]; 506} 507 508static void 509NVSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) 510{ 511 NVPtr pNv = NVPTR(pScrn); 512 513 pNv->dmaCurrent += _color_expand_dwords; 514 515 if(--_remaining) { 516 NVDmaStart(pNv, _color_expand_offset, _color_expand_dwords); 517 _storage_buffer[0] = (unsigned char*)&pNv->dmaBase[pNv->dmaCurrent]; 518 } else { 519 /* hardware bug workaround */ 520 NVDmaStart(pNv, BLIT_POINT_SRC, 1); 521 NVDmaNext (pNv, 0); 522 NVDmaKickoff(pNv); 523 } 524} 525 526static void 527NVSetupForScanlineImageWrite( 528 ScrnInfoPtr pScrn, int rop, 529 unsigned int planemask, 530 int trans_color, 531 int bpp, int depth 532) 533{ 534 NVPtr pNv = NVPTR(pScrn); 535 536 planemask |= ~0 << pNv->CurrentLayout.depth; 537 538 NVSetRopSolid (pScrn, rop, planemask); 539} 540 541static CARD32 _image_size; 542static CARD32 _image_srcpoint; 543static CARD32 _image_dstpoint; 544static CARD32 _image_dstpitch; 545 546static void 547NVSubsequentScanlineImageWriteRect( 548 ScrnInfoPtr pScrn, 549 int x, int y, 550 int w, int h, 551 int skipleft 552) 553{ 554 NVPtr pNv = NVPTR(pScrn); 555 int Bpp = pNv->CurrentLayout.bitsPerPixel >> 3; 556 int image_srcpitch; 557 558 _image_size = (1 << 16) | (w - skipleft); 559 _image_srcpoint = skipleft; 560 _image_dstpoint = (y << 16) | (x + skipleft); 561 _remaining = h; 562 _image_dstpitch = pNv->CurrentLayout.displayWidth * Bpp; 563 image_srcpitch = ((w * Bpp) + 63) & ~63; 564 _storage_buffer[0] = pNv->FbStart + pNv->ScratchBufferStart; 565 566 NVSync(pScrn); 567 568 NVDmaStart(pNv, SURFACE_PITCH, 2); 569 NVDmaNext (pNv, (_image_dstpitch << 16) | image_srcpitch); 570 NVDmaNext (pNv, pNv->ScratchBufferStart); 571} 572 573static void NVSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) 574{ 575 NVPtr pNv = NVPTR(pScrn); 576 577 NVDmaStart(pNv, BLIT_POINT_SRC, 3); 578 NVDmaNext (pNv, _image_srcpoint); 579 NVDmaNext (pNv, _image_dstpoint); 580 NVDmaNext (pNv, _image_size); 581 NVDmaKickoff(pNv); 582 583 if(--_remaining) { 584 _image_dstpoint += (1 << 16); 585 NVSync(pScrn); 586 } else { 587 NVDmaStart(pNv, SURFACE_PITCH, 2); 588 NVDmaNext (pNv, _image_dstpitch | (_image_dstpitch << 16)); 589 NVDmaNext (pNv, 0); 590 } 591} 592 593static void 594NVSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) 595{ 596 NVPtr pNv = NVPTR(pScrn); 597 598 planemask |= ~0 << pNv->CurrentLayout.depth; 599 600 NVSetRopSolid(pScrn, rop, planemask); 601 602 _fg_pixel = color; 603 604 pNv->DMAKickoffCallback = NVDMAKickoffCallback; 605} 606 607static void 608NVSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) 609{ 610 NVPtr pNv = NVPTR(pScrn); 611 612 NVDmaStart(pNv, LINE_COLOR, 1); 613 NVDmaNext (pNv, _fg_pixel); 614 NVDmaStart(pNv, LINE_LINES(0), 2); 615 NVDmaNext (pNv, (y << 16) | ( x & 0xffff)); 616 if(dir == DEGREES_0) { 617 NVDmaNext (pNv, (y << 16) | ((x + len) & 0xffff)); 618 } else { 619 NVDmaNext (pNv, ((y + len) << 16) | (x & 0xffff)); 620 } 621} 622 623static void 624NVSubsequentSolidTwoPointLine( 625 ScrnInfoPtr pScrn, 626 int x1, int y1, 627 int x2, int y2, 628 int flags 629) 630{ 631 NVPtr pNv = NVPTR(pScrn); 632 Bool drawLast = !(flags & OMIT_LAST); 633 634 NVDmaStart(pNv, LINE_COLOR, 1); 635 NVDmaNext (pNv, _fg_pixel); 636 NVDmaStart(pNv, LINE_LINES(0), drawLast ? 4 : 2); 637 NVDmaNext (pNv, (y1 << 16) | (x1 & 0xffff)); 638 NVDmaNext (pNv, (y2 << 16) | (x2 & 0xffff)); 639 if(drawLast) { 640 NVDmaNext (pNv, (y2 << 16) | (x2 & 0xffff)); 641 NVDmaNext (pNv, ((y2 + 1) << 16) | (x2 & 0xffff)); 642 } 643} 644 645static void 646NVSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) 647{ 648 NVPtr pNv = NVPTR(pScrn); 649 int h = y2 - y1 + 1; 650 int w = x2 - x1 + 1; 651 652 NVDmaStart(pNv, CLIP_POINT, 2); 653 NVDmaNext (pNv, (y1 << 16) | x1); 654 NVDmaNext (pNv, (h << 16) | w); 655} 656 657static void 658NVDisableClipping(ScrnInfoPtr pScrn) 659{ 660 NVPtr pNv = NVPTR(pScrn); 661 662 NVDmaStart(pNv, CLIP_POINT, 2); 663 NVDmaNext (pNv, 0); 664 NVDmaNext (pNv, 0x7FFF7FFF); 665} 666 667#endif 668 669/* Initialize XAA acceleration info */ 670Bool 671NVAccelInit(ScreenPtr pScreen) 672{ 673#ifdef HAVE_XAA_H 674 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 675 NVPtr pNv = NVPTR(pScrn); 676 XAAInfoRecPtr accel; 677 678 accel = pNv->AccelInfoRec = XAACreateInfoRec(); 679 if(!accel) return FALSE; 680 681 accel->Flags = LINEAR_FRAMEBUFFER | PIXMAP_CACHE | OFFSCREEN_PIXMAPS; 682 accel->Sync = NVSync; 683 684 accel->ScreenToScreenCopyFlags = NO_TRANSPARENCY; 685 accel->SetupForScreenToScreenCopy = NVSetupForScreenToScreenCopy; 686 accel->SubsequentScreenToScreenCopy = NVSubsequentScreenToScreenCopy; 687 688 accel->SolidFillFlags = 0; 689 accel->SetupForSolidFill = NVSetupForSolidFill; 690 accel->SubsequentSolidFillRect = NVSubsequentSolidFillRect; 691 692 accel->Mono8x8PatternFillFlags = HARDWARE_PATTERN_SCREEN_ORIGIN | 693 HARDWARE_PATTERN_PROGRAMMED_BITS | 694 NO_PLANEMASK; 695 accel->SetupForMono8x8PatternFill = NVSetupForMono8x8PatternFill; 696 accel->SubsequentMono8x8PatternFillRect = NVSubsequentMono8x8PatternFillRect; 697 698 accel->ScanlineCPUToScreenColorExpandFillFlags = 699 BIT_ORDER_IN_BYTE_LSBFIRST | 700 CPU_TRANSFER_PAD_DWORD | 701 LEFT_EDGE_CLIPPING | 702 LEFT_EDGE_CLIPPING_NEGATIVE_X; 703 accel->NumScanlineColorExpandBuffers = 1; 704 accel->SetupForScanlineCPUToScreenColorExpandFill = 705 NVSetupForScanlineCPUToScreenColorExpandFill; 706 accel->SubsequentScanlineCPUToScreenColorExpandFill = 707 NVSubsequentScanlineCPUToScreenColorExpandFill; 708 accel->SubsequentColorExpandScanline = 709 NVSubsequentColorExpandScanline; 710 accel->ScanlineColorExpandBuffers = _storage_buffer; 711 712 accel->ScanlineImageWriteFlags = NO_GXCOPY | 713 NO_TRANSPARENCY | 714 LEFT_EDGE_CLIPPING | 715 LEFT_EDGE_CLIPPING_NEGATIVE_X; 716 accel->NumScanlineImageWriteBuffers = 1; 717 accel->SetupForScanlineImageWrite = NVSetupForScanlineImageWrite; 718 accel->SubsequentScanlineImageWriteRect = NVSubsequentScanlineImageWriteRect; 719 accel->SubsequentImageWriteScanline = NVSubsequentImageWriteScanline; 720 accel->ScanlineImageWriteBuffers = _storage_buffer; 721 722 accel->SolidLineFlags = 0; 723 accel->SetupForSolidLine = NVSetupForSolidLine; 724 accel->SubsequentSolidHorVertLine = NVSubsequentSolidHorVertLine; 725 accel->SubsequentSolidTwoPointLine = NVSubsequentSolidTwoPointLine; 726 accel->SetClippingRectangle = NVSetClippingRectangle; 727 accel->DisableClipping = NVDisableClipping; 728 accel->ClippingFlags = HARDWARE_CLIP_SOLID_LINE; 729 730 miSetZeroLineBias(pScreen, OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6); 731 732 return (XAAInit(pScreen, accel)); 733#else 734 return FALSE; 735#endif 736} 737