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