1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx2_accel.c,v 1.4tsi Exp $ */ 2/* 3 * $Workfile: nsc_gx2_accel.c $ 4 * $Revision: 1.1.1.1 $ 5 * $Author: mrg $ 6 * 7 * File Contents: This file is consists of main Xfree 8 * acceleration supported routines like solid fill used 9 * here. 10 * Project: Geode Xfree Frame buffer device driver. 11 * 12 * 13 */ 14 15/* 16 * NSC_LIC_ALTERNATIVE_PREAMBLE 17 * 18 * Revision 1.0 19 * 20 * National Semiconductor Alternative GPL-BSD License 21 * 22 * National Semiconductor Corporation licenses this software 23 * ("Software"): 24 * 25 * National Xfree frame buffer driver 26 * 27 * under one of the two following licenses, depending on how the 28 * Software is received by the Licensee. 29 * 30 * If this Software is received as part of the Linux Framebuffer or 31 * other GPL licensed software, then the GPL license designated 32 * NSC_LIC_GPL applies to this Software; in all other circumstances 33 * then the BSD-style license designated NSC_LIC_BSD shall apply. 34 * 35 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ 36 37/* NSC_LIC_BSD 38 * 39 * National Semiconductor Corporation Open Source License for 40 * 41 * National Xfree frame buffer driver 42 * 43 * (BSD License with Export Notice) 44 * 45 * Copyright (c) 1999-2001 46 * National Semiconductor Corporation. 47 * All rights reserved. 48 * 49 * Redistribution and use in source and binary forms, with or without 50 * modification, are permitted provided that the following conditions 51 * are met: 52 * 53 * * Redistributions of source code must retain the above copyright 54 * notice, this list of conditions and the following disclaimer. 55 * 56 * * Redistributions in binary form must reproduce the above 57 * copyright notice, this list of conditions and the following 58 * disclaimer in the documentation and/or other materials provided 59 * with the distribution. 60 * 61 * * Neither the name of the National Semiconductor Corporation nor 62 * the names of its contributors may be used to endorse or promote 63 * products derived from this software without specific prior 64 * written permission. 65 * 66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 67 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 68 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 69 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 70 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 71 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 72 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 73 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 74 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 75 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 76 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 77 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 78 * OF SUCH DAMAGE. 79 * 80 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 81 * YOUR JURISDICTION. It is licensee's responsibility to comply with 82 * any export regulations applicable in licensee's jurisdiction. Under 83 * CURRENT (2001) U.S. export regulations this software 84 * is eligible for export from the U.S. and can be downloaded by or 85 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 86 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 87 * Syria, Sudan, Afghanistan and any other country to which the U.S. 88 * has embargoed goods and services. 89 * 90 * END_NSC_LIC_BSD */ 91 92/* NSC_LIC_GPL 93 * 94 * National Semiconductor Corporation Gnu General Public License for 95 * 96 * National Xfree frame buffer driver 97 * 98 * (GPL License with Export Notice) 99 * 100 * Copyright (c) 1999-2001 101 * National Semiconductor Corporation. 102 * All rights reserved. 103 * 104 * Redistribution and use in source and binary forms, with or without 105 * modification, are permitted under the terms of the GNU General 106 * Public License as published by the Free Software Foundation; either 107 * version 2 of the License, or (at your option) any later version 108 * 109 * In addition to the terms of the GNU General Public License, neither 110 * the name of the National Semiconductor Corporation nor the names of 111 * its contributors may be used to endorse or promote products derived 112 * from this software without specific prior written permission. 113 * 114 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 115 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 116 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 117 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 118 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 119 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 120 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 121 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 122 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 123 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 124 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 125 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 126 * OF SUCH DAMAGE. See the GNU General Public License for more details. 127 * 128 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 129 * YOUR JURISDICTION. It is licensee's responsibility to comply with 130 * any export regulations applicable in licensee's jurisdiction. Under 131 * CURRENT (2001) U.S. export regulations this software 132 * is eligible for export from the U.S. and can be downloaded by or 133 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 134 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 135 * Syria, Sudan, Afghanistan and any other country to which the U.S. 136 * has embargoed goods and services. 137 * 138 * You should have received a copy of the GNU General Public License 139 * along with this file; if not, write to the Free Software Foundation, 140 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 141 * 142 * END_NSC_LIC_GPL */ 143 144#ifdef HAVE_CONFIG_H 145#include "config.h" 146#endif 147 148/* Xfree86 header files */ 149#include "vgaHW.h" 150#include "xf86.h" 151#include "xaalocal.h" 152#include "xf86fbman.h" 153#include "miline.h" 154#include "xaarop.h" 155#include "nsc.h" 156 157#define DASHED_SUPPORT 0 158#define IMGWRITE_SUPPORT 0 159#define SCR2SCREXP 0 160 161/* STATIC VARIABLES FOR THIS FILE 162 * Used to maintain state between setup and rendering calls. 163 */ 164 165static int GeodeTransparent; 166static int GeodeTransColor; 167static int Geodedstx; 168static int Geodedsty; 169static int Geodesrcx; 170static int Geodesrcy; 171static int Geodewidth; 172static int Geodeheight; 173static int GeodeCounter; 174 175#if !defined(STB_X) 176static unsigned int GeodeROP = 0; 177static unsigned short Geode_blt_mode = 0; 178static unsigned short Geode_vector_mode = 0; 179#endif 180static unsigned int gu2_xshift = 1; 181static unsigned int gu2_yshift = 1; 182static unsigned int gu2_bpp = 1; 183static unsigned int SetCPUToScreen = 0; 184#if IMGWRITE_SUPPORT 185static unsigned int SetImageWriteRect = 0; 186#endif 187static unsigned int ImgBufOffset; 188 189#define GU2_WAIT_PENDING while(READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_PENDING) 190#define GU2_WAIT_BUSY while(READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_BUSY) 191 192#define CALC_FBOFFSET(_SrcX, _SrcY) \ 193 (((unsigned int) (_SrcY) << gu2_yshift) |\ 194 (((unsigned int) (_SrcX)) << gu2_xshift)) 195 196#define GFX_PATTERN_FILL(_SrcX, _SrcY, _Width, _Height) \ 197{ \ 198 GU2_WAIT_PENDING;\ 199 WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET((_SrcX), (_SrcY)));\ 200 WRITE_GP32(MGP_WID_HEIGHT, \ 201 (((unsigned int) (_Width)) << 16) | (_Height));\ 202 WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode);\ 203} 204 205static XAAInfoRecPtr localRecPtr; 206 207Bool GX2AccelInit(ScreenPtr pScreen); 208void GX2AccelSync(ScrnInfoPtr pScreenInfo); 209void GX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, 210 unsigned int planemask); 211void GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, 212 int w, int h); 213void GX2SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, 214 int patternx, int patterny, 215 int rop, unsigned int planemask, 216 int trans_color); 217void GX2Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, 218 int patternx, int patterny, int x, 219 int y, int w, int h); 220void GX2SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, 221 int patterny, int fg, int bg, int rop, 222 unsigned int planemask); 223void GX2Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, 224 int patterny, int x, int y, int w, 225 int h); 226void GX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, 227 int ydir, int rop, unsigned int planemask, 228 int transparency_color); 229void GX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, int y1, 230 int x2, int y2, int w, int h); 231void GX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, 232 unsigned int planemask); 233void GX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, 234 unsigned int planemask, int length, 235 unsigned char *pattern); 236void GX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, 237 int absmaj, int absmin, int err, int len, 238 int octant); 239void GX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, int x0, int y0, 240 int x1, int y1, int flags); 241void GX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, int len, 242 int dir); 243 244void GX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, 245 int rop, unsigned int planemask, 246 int transparency_color, int bpp, 247 int depth); 248 249void GX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, 250 int x, int y, int w, int h, 251 int skipleft); 252 253void GX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); 254void GX2FillCacheBltRects(ScrnInfoPtr pScrn, int rop, unsigned int planemask, 255 int nBox, BoxPtr pBox, int xorg, int yorg, 256 XAACacheInfoPtr pCache); 257void GX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, 258 int rop, unsigned int planemask, 259 int transparency_color, int bpp, int depth); 260void GX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, 261 int x, int y, int w, int h, int skipleft); 262void GX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 263 int fg, int bg, int rop, 264 unsigned int planemask); 265void GX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 266 int x, int y, int w, int h, 267 int skipleft); 268void OPTGX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, 269 unsigned int planemask); 270void OPTGX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, 271 int w, int h); 272void OPTGX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, 273 int ydir, int rop, 274 unsigned int planemask, 275 int transparency_color); 276void OPTGX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, 277 int y1, int x2, int y2, int w, int h); 278void OPTGX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, 279 unsigned int planemask); 280void OPTGX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, 281 unsigned int planemask, int length, 282 unsigned char *pattern); 283void OPTGX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, 284 int absmaj, int absmin, int err, int len, 285 int octant); 286void OPTGX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, 287 int x0, int y0, int x1, int y1, 288 int flags); 289void OPTGX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, 290 int len, int dir); 291 292void OPTGX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, 293 int rop, unsigned int planemask, 294 int transparency_color, int bpp, 295 int depth); 296 297void OPTGX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, 298 int x, int y, int w, int h, 299 int skipleft); 300 301void OPTGX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); 302void OPTGX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 303 int fg, int bg, int rop, 304 unsigned int planemask); 305void OPTGX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 306 int x, int y, int w, int h, 307 int skipleft); 308void OPTGX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, 309 int rop, unsigned int planemask, 310 int transparency_color, int bpp, int depth); 311void OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, 312 int x, int y, int w, int h, int skipleft); 313 314/*---------------------------------------------------------------------------- 315 * GX2AccelSync. 316 * 317 * Description :This function is called to syncronize with the graphics 318 * engine and it waits the graphic engine is idle.This is 319 * required before allowing direct access to the 320 * framebuffer. 321 * Parameters. 322 * pScreenInfo:Screeen info pointer structure. 323 * 324 * Returns :none 325 * 326 * Comments :This function is called on geode_video routines. 327*---------------------------------------------------------------------------- 328*/ 329void 330GX2AccelSync(ScrnInfoPtr pScreenInfo) 331{ 332 if (SetCPUToScreen) { 333#if defined(OPT_ACCEL) 334 WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode | 335 MGP_BM_SRC_FB | MGP_BM_SRC_MONO); 336#else 337 GFX(mono_bitmap_to_screen_blt(0, 0, Geodedstx, Geodedsty, 338 Geodewidth, Geodeheight, 339 localRecPtr->ColorExpandBase, 340 ((Geodewidth + 31) >> 5) << 2)); 341#endif 342 343 SetCPUToScreen = 0; 344 } 345#if IMGWRITE_SUPPORT 346 if (SetImageWriteRect) { 347 unsigned long srcpitch; 348 349#if defined(OPT_ACCEL) 350 GeodePtr pGeode = GEODEPTR(pScreenInfo); 351 352 srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; 353 354 GU2_WAIT_PENDING; 355 WRITE_GP32(MGP_STRIDE, (srcpitch << 16) | pGeode->Pitch); 356 WRITE_GP32(MGP_SRC_OFFSET, ImgBufOffset); 357 WRITE_GP32(MGP_DST_OFFSET, 358 (CALC_FBOFFSET(Geodedstx, Geodedsty)) & 0x00FFFFFF); 359 WRITE_GP32(MGP_WID_HEIGHT, 360 ((unsigned long)Geodewidth << 16) | (unsigned long) 361 Geodeheight); 362/* 363 ErrorF("%d %d, %d\n", Geodewidth, Geodeheight, gu2_xshift); 364 ErrorF("%X , %X %X %X %X\n", srcpitch, ((srcpitch << 16) | 365 pGeode->Pitch), ImgBufOffset, 366 (CALC_FBOFFSET(Geodedstx, Geodedsty)) & 0x00FFFFFF, 367 ((unsigned long)Geodewidth << 16) | 368 (unsigned long)Geodeheight); 369*/ 370 WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode); 371#else 372 srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; 373 GFX2(set_source_stride(srcpitch)); 374 GFX2(screen_to_screen_blt(ImgBufOffset, 375 CALC_FBOFFSET(Geodedstx, Geodedsty), 376 Geodewidth, Geodeheight, 0)); 377#endif 378 SetImageWriteRect = 0; 379 } 380#endif /* IMGWRITE_SUPPORT */ 381 382 GFX(wait_until_idle()); 383} 384 385/*---------------------------------------------------------------------------- 386 * GX2SetupForFillRectSolid. 387 * 388 * Description :This routine is called to setup the solid pattern 389 * color for future rectangular fills or vectors. 390 * 391 * Parameters. 392 * pScreenInfo 393 * Ptr :Screen handler pointer having screen information. 394 * color :Specifies the color to be filled up in defined area. 395 * rop :Specifies the raster operation value. 396 * planemask :Specifies the masking value based rop srcdata. 397 * 398 * Returns :none 399 * 400 * Comments :none 401 * 402*---------------------------------------------------------------------------- 403*/ 404void 405GX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, 406 int color, int rop, unsigned int planemask) 407{ 408 GFX(set_solid_pattern((unsigned int)color)); 409 410 /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ 411 if (planemask == 0xFFFFFFFF) { 412 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 413 GFX(set_raster_operation(XAAGetPatternROP(rop))); 414 } else { 415 /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ 416 GFX(set_solid_source((unsigned int)planemask)); 417 GFX(set_raster_operation(XAAGetPatternROP(rop))); 418 } 419} 420 421 /*---------------------------------------------------------------------------- 422 * GX2SubsequentFillRectSolid. 423 * 424 * Description :This routine is used to fill the rectangle of previously 425 * specified solid pattern. 426 * 427 * Parameters. 428 * pScreenInfo :Screen handler pointer having screen information. 429 * x and y :Specifies the x and y co-ordinatesarea. 430 * w and h :Specifies width and height respectively. 431 * 432 * Returns :none 433 * 434 * Comments :desired pattern can be set before this function by 435 * gfx_set_solid_pattern. 436 * Sample application uses: 437 * - Window backgrounds. 438 * - x11perf: rectangle tests (-rect500). 439 * - x11perf: fill trapezoid tests (-trap100). 440 * - x11perf: horizontal line segments (-hseg500). 441 *---------------------------------------------------------------------------- 442*/ 443void 444GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, 445 int h) 446{ 447 DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, w, h)); 448 449 /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ 450 451 GFX(pattern_fill((unsigned short)x, (unsigned short)y, 452 (unsigned short)w, (unsigned short)h)); 453} 454 455/*---------------------------------------------------------------------------- 456 * GX2SetupFor8x8PatternColorExpand 457 * 458 * Description :This routine is called to fill the color pattern of 459 * 8x8. 460 * Parameters. 461 * pScreenInfo :Screen handler pointer having screen information. 462 * patternx :This is set from on rop data. 463 * patterny :This is set based on rop data. 464 * planemask :Specifies the value of masking from rop data 465 * trans_color :to be added. 466 * Returns :none. 467 * 468 * Comments :none. 469 * 470*---------------------------------------------------------------------------- 471*/ 472 473void 474GX2SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, 475 int patternx, int patterny, int rop, 476 unsigned int planemask, int trans_color) 477{ 478 /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ 479 if (planemask == 0xFFFFFFFF) { 480 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 481 GFX(set_raster_operation(XAAGetPatternROP(rop))); 482 } else { 483 /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ 484 GFX(set_solid_source((unsigned int)planemask)); 485 GFX(set_raster_operation(XAAGetPatternROP(rop))); 486 } 487} 488 489/*---------------------------------------------------------------------------- 490 * GX2Subsequent8x8PatternColorExpand 491 * 492 * Description :This routine is called to fill a rectangle with the 493 * color pattern of previously loaded pattern. 494 * 495 * Parameters. 496 * pScreenInfo :Screen handler pointer having screen information. 497 * patternx :This is set from on rop data. 498 * patterny :This is set based on rop data. 499 * x :x -coordinates of the destination rectangle 500 * y :y-co-ordinates of the destination rectangle 501 * w :Specifies width of the rectangle 502 * h :Height of the window of the rectangle 503 * 504 * Returns :none 505 * 506 * Comments :The patterns specified is ignored inside the function 507 * Sample application uses: 508 * - Patterned desktops 509 * - x11perf: stippled rectangle tests (-srect500). 510 * - x11perf: opaque stippled rectangle tests (-osrect500). 511*---------------------------------------------------------------------------- 512*/ 513void 514GX2Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, 515 int patternx, int patterny, int x, int y, 516 int w, int h) 517{ 518 GeodePtr pGeode = GEODEPTR(pScreenInfo); 519 520 DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h)); 521 522 /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ 523 /* Ignores specified pattern. */ 524 GFX(color_pattern_fill((unsigned short)x, (unsigned short)y, 525 (unsigned short)w, (unsigned short)h, 526 ((unsigned long *)((pGeode->FBBase + 527 (patterny << gu2_yshift)) + 528 patternx)))); 529} 530 531/*---------------------------------------------------------------------------- 532 * GX2SetupFor8x8PatternMonoExpand 533 * 534 * Description :This routine is called to fill the monochrome pattern of 535 * 8x8. 536 * Parameters. 537 * pScreenInfo :Screen handler pointer having screen information. 538 * patternx :This is set from on rop data. 539 * patterny :This is set based on rop data. 540 * fg :Specifies the foreground color 541 * bg :Specifies the background color 542 * planemask :Specifies the value of masking from rop data 543 544 * Returns :none. 545 * 546 * Comments :none. 547 * 548*---------------------------------------------------------------------------- 549*/ 550void 551GX2SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, 552 int patternx, int patterny, int fg, 553 int bg, int rop, unsigned int planemask) 554{ 555 int trans = (bg == -1); 556 557 /* LOAD PATTERN COLORS AND DATA */ 558 GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg, 559 (unsigned int)patternx, (unsigned int)patterny, 560 trans)); 561 562 /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ 563 if (planemask == 0xFFFFFFFF) { 564 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 565 GFX(set_raster_operation(XAAGetPatternROP(rop))); 566 } else { 567 /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ 568 GFX(set_solid_source((unsigned int)planemask)); 569 GFX(set_raster_operation(XAAGetPatternROP(rop))); 570 } 571} 572 573/*---------------------------------------------------------------------------- 574 * GX2Subsequent8x8PatternMonoExpand 575 * 576 * Description :This routine is called to fill a ractanglethe 577 * monochrome pattern of previusly loaded pattern. 578 * 579 * Parameters. 580 * pScreenInfo :Screen handler pointer having screen information. 581 * patternx :This is set from on rop data. 582 * patterny :This is set based on rop data. 583 * fg :Specifies the foreground color 584 * bg :Specifies the background color 585 * planemask :Specifies the value of masking from rop data 586 587 * Returns :none 588 * 589 * Comments :The patterns specified is ignored inside the function 590 * Sample application uses: 591 * - Patterned desktops 592 * - x11perf: stippled rectangle tests (-srect500). 593 * - x11perf: opaque stippled rectangle tests (-osrect500). 594*---------------------------------------------------------------------------- 595*/ 596void 597GX2Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, 598 int patternx, int patterny, int x, int y, 599 int w, int h) 600{ 601 DEBUGMSG(0, (0, 0, "8x8mono %d %d %dx%d\n", x, y, w, h)); 602 603 /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ 604 /* Ignores specified pattern. */ 605 GFX(pattern_fill((unsigned short)x, (unsigned short)y, 606 (unsigned short)w, (unsigned short)h)); 607} 608 609/*---------------------------------------------------------------------------- 610 * GX2SetupForScreenToScreenCopy 611 * 612 * Description :This function is used to set up the planemask and raster 613 * for future Bliting functionality. 614 * 615 * Parameters: 616 * pScreenInfo :Screen handler pointer having screen information. 617 * xdir :This is set based on rop data. 618 * ydir :This is set based on rop data. 619 * rop :sets the raster operation 620 * transparency:tobeadded 621 * planemask :Specifies the value of masking from rop data 622 623 * Returns :none 624 * 625 * Comments :The patterns specified is ignored inside the function 626*---------------------------------------------------------------------------- 627*/ 628void 629GX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, 630 int xdir, int ydir, int rop, 631 unsigned int planemask, int transparency_color) 632{ 633 GFX(set_solid_pattern(planemask)); 634 /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ 635 GFX(set_raster_operation(XAAGetCopyROP(rop))); 636 /* SAVE TRANSPARENCY FLAG */ 637 GeodeTransparent = (transparency_color == -1) ? 0 : 1; 638 GeodeTransColor = transparency_color; 639 640} 641 642/*---------------------------------------------------------------------------- 643 * GX2SubsquentScreenToScreenCopy 644 * 645 * Description :This function is called to perform a screen to screen 646 * BLT using the previously specified planemask,raster 647 * operation and * transparency flag 648 * 649 * Parameters. 650 * pScreenInfo :Screen handler pointer having screen information. 651 * x1 :x -coordinates of the source window 652 * y1 :y-co-ordinates of the source window 653 * x2 :x -coordinates of the destination window 654 * y2 :y-co-ordinates of the destination window 655 * w :Specifies width of the window to be copied 656 * h :Height of the window to be copied. 657 * Returns :none 658 * 659 * Comments :The patterns specified is ignored inside the function 660 * Sample application uses (non-transparent): 661 * - Moving windows. 662 * - x11perf: scroll tests (-scroll500). 663 * - x11perf: copy from window to window (-copywinwin500). 664 * 665 * No application found using transparency. 666*---------------------------------------------------------------------------- 667*/ 668void 669GX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, 670 int x1, int y1, int x2, int y2, int w, int h) 671{ 672 if (GeodeTransparent) { 673 /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT 674 * * Should only be called for the "copy" raster operation. 675 */ 676 GFX(screen_to_screen_xblt((unsigned short)x1, (unsigned short)y1, 677 (unsigned short)x2, (unsigned short)y2, 678 (unsigned short)w, (unsigned short)h, 679 GeodeTransColor)); 680 } else { 681 /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ 682 GFX(screen_to_screen_blt((unsigned short)x1, (unsigned short)y1, 683 (unsigned short)x2, (unsigned short)y2, 684 (unsigned short)w, (unsigned short)h)); 685 } 686} 687 688void 689GX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, 690 int rop, unsigned int planemask, 691 int transparency_color, int bpp, int depth) 692{ 693 GFX(set_solid_pattern((unsigned int)planemask)); 694 /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ 695 GFX(set_raster_operation(XAAGetCopyROP(rop))); 696 /* SAVE TRANSPARENCY FLAG */ 697 GeodeTransparent = (transparency_color == -1) ? 0 : 1; 698 GeodeTransColor = transparency_color; 699} 700 701void 702GX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, 703 int x, int y, int w, int h, int skipleft) 704{ 705 Geodedstx = x; 706 Geodedsty = y; 707 Geodewidth = w; 708 Geodeheight = h; 709#if IMGWRITE_SUPPORT 710 SetImageWriteRect = 1; 711#endif 712 713} 714 715/*---------------------------------------------------------------------------- 716 * GX2SetupForScanlineImageWrite 717 * 718 * Description :This function is used to set up the planemask and raster 719 * for future Bliting functionality. 720 * 721 * Parameters: 722 * pScreenInfo :Screen handler pointer having screen information. 723 * rop :sets the raster operation 724 * transparency_color :transparency color key. 725 * planemask :Specifies the value of masking from rop data 726 * bpp :bits per pixel of the source pixmap 727 * depth :depth of the source pixmap. 728 * Returns :none 729 * 730 * Comments :none 731 * x11perf -putimage10 732 * x11perf -putimage100 733 * x11perf -putimage500 734*---------------------------------------------------------------------------- 735*/ 736void 737GX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, 738 int rop, unsigned int planemask, 739 int transparency_color, int bpp, int depth) 740{ 741 GFX(set_solid_pattern((unsigned int)planemask)); 742 /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ 743 GFX(set_raster_operation(XAAGetCopyROP(rop & 0x0F))); 744 /* SAVE TRANSPARENCY FLAG */ 745 GeodeTransparent = (transparency_color == -1) ? 0 : 1; 746 GeodeTransColor = transparency_color; 747} 748 749/*---------------------------------------------------------------------------- 750 * GX2SubsequentScanlineImageWriteRect 751 * 752 * Description :This function is used to set up the x,y corordinates and width 753 * &height for future Bliting functionality. 754 * 755 * Parameters: 756 * pScreenInfo :Screen handler pointer having screen information. 757 * x :destination x 758 * y :destination y 759 * w :Specifies the width of the rectangle to be copied 760 * h :Specifies the height of the rectangle to be copied 761 * 762 * Returns :none 763 * 764 * Comments :none 765*---------------------------------------------------------------------------- 766*/ 767void 768GX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, 769 int x, int y, int w, int h, int skipleft) 770{ 771 Geodedstx = x; 772 Geodedsty = y; 773 Geodewidth = w; 774 Geodeheight = h; 775 GeodeCounter = 0; 776} 777 778/*---------------------------------------------------------------------------- 779 * GX2SubsquentImageWriteScanline 780 * 781 * Description :This function is called to 782 * BLT using the previously specified planemask,raster 783 * operation and transparency flag 784 * 785 * Parameters. 786 * pScreenInfo :Screen handler pointer having screen information. 787 * 788 * Returns :none 789 * 790 * Comments :The patterns specified is ignored inside the function 791 * Sample application uses (non-transparent): 792 * - Moving windows. 793 * - x11perf: scroll tests (-scroll500). 794 * - x11perf: copy from window to window (-copywinwin500). 795 * 796 * No application found using transparency. 797*---------------------------------------------------------------------------- 798*/ 799void 800GX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) 801{ 802 GeodePtr pGeode; 803 int blt_height = 0; 804 char blit = FALSE; 805 806 pGeode = GEODEPTR(pScreenInfo); 807 808 GeodeCounter++; 809 810 if ((Geodeheight <= pGeode->NoOfImgBuffers) && 811 (GeodeCounter == Geodeheight)) { 812 blit = TRUE; 813 blt_height = Geodeheight; 814 } else if ((Geodeheight > pGeode->NoOfImgBuffers) 815 && (GeodeCounter == pGeode->NoOfImgBuffers)) { 816 blit = TRUE; 817 Geodeheight -= pGeode->NoOfImgBuffers; 818 blt_height = pGeode->NoOfImgBuffers; 819 } else 820 return; 821 822 if (blit) { 823 blit = FALSE; 824 825 GeodeCounter = 0; 826 827 if (GeodeTransparent) { 828 /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT 829 * * Should only be called for the "copy" raster operation. 830 */ 831 GFX(screen_to_screen_xblt((unsigned short)Geodesrcx, 832 (unsigned short)Geodesrcy, 833 (unsigned short)Geodedstx, 834 (unsigned short)Geodedsty, 835 (unsigned short)Geodewidth, 836 (unsigned short)blt_height, 837 GeodeTransColor)); 838 } else { 839 /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ 840 GFX(screen_to_screen_blt((unsigned short)Geodesrcx, 841 (unsigned short)Geodesrcy, 842 (unsigned short)Geodedstx, 843 (unsigned short)Geodedsty, 844 (unsigned short)Geodewidth, 845 (unsigned short)blt_height)); 846 } 847 Geodedsty += blt_height; 848 GFX(wait_until_idle()); 849 } 850} 851 852/*---------------------------------------------------------------------------- 853 * GX2SetupForCPUToScreenColorExpandFill 854 * 855 * Description :This routine is called to setup the background and 856 * foreground colors,rop and plane mask for future 857 * color expansion blits from source patterns stored 858 * in system memory 859 * 860 * Parameters. 861 * pScreenInfo :Screen handler pointer having screen information. 862 * fg :Specifies the foreground color 863 * bg :Specifies the background color 864 * rop :Specifies rop values. 865 * planemask :Specifies the value of masking from rop data 866 * 867 * Returns :none. 868 * 869 * Comments : 870 * All the text gets rendered through this i/f. We have given 871 * the offscreen memory loaction to temporarily put the text 872 * bitmap. Generaly all the text comes as bitmap and then gets 873 * rendered via the HOST_SRC(similar to scratchpad in GX1). Now 874 * since we already have the bitmap in offscreen we can do a 875 * src_FB_EXPAND. This is the best possible you can do with GX2 876 * CPU-to-screen color expansion 877 *---------------------------------------------------------------------------- 878*/ 879void 880GX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 881 int fg, int bg, int rop, 882 unsigned int planemask) 883{ 884 GFX(set_solid_pattern(planemask)); 885 GFX(set_mono_source(bg, fg, (bg == -1))); 886 887 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 888 GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); 889 890 DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); 891} 892 893/*------------------------------------------------------------------------------- 894 * GX2SubsequentCPUToScreenColorExpandFill 895 * 896 * Description :This routine is used to perform color expansion blits from 897 * source patterns stored in system memory using the 898 * previously set rop and plane mask. 899 * 900 * Parameters. 901 * pScreenInfo :Screen handler pointer having screen information. 902 * x and y :Specifies the x and y co-ordinatesarea. 903 * w and h :Specifies width and height respectively. 904 * 905 * Returns :none 906 * 907 * Comments :none 908 *-------------------------------------------------------------------------------- 909 */ 910void 911GX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 912 int x, int y, int w, int h, 913 int skipleft) 914{ 915 Geodedstx = x; 916 Geodedsty = y; 917 Geodewidth = w; 918 Geodeheight = h; 919 SetCPUToScreen = 1; 920} 921 922#if SCR2SCREXP 923void 924GX2SetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, 925 int fg, int bg, int rop, 926 unsigned int planemask) 927{ 928 GFX(set_solid_pattern(planemask)); 929 GFX(set_mono_source(bg, fg, (bg == -1))); 930 931 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 932 GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); 933 934 DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); 935} 936 937void 938GX2SubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, 939 int x, int y, int w, int h, 940 int srcx, int srcy, int offset) 941{ 942 GeodePtr pGeode = GEODEPTR(pScrn); 943 944 GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h, 945 (unsigned char *)(pGeode->FBBase + 946 CALC_FBOFFSET(srcx, srcy)), 947 pGeode->Pitch)); 948} 949#endif 950 951static unsigned short vector_mode_table[] = { 952 VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR, 953 VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR, 954 VM_MAJOR_INC | VM_X_MAJOR, 955 VM_MINOR_INC | VM_Y_MAJOR, 956 VM_MINOR_INC | VM_X_MAJOR, 957 VM_MAJOR_INC | VM_Y_MAJOR, 958 VM_X_MAJOR, 959 VM_Y_MAJOR, 960}; 961 962/*---------------------------------------------------------------------------- 963 * GX2SetupForSolidLine 964 * 965 * Description :This function is used setup the solid line color for 966 * future line draws. 967 * 968 * 969 * Parameters. 970 * pScreenInfo :Screen handler pointer having screen information. 971 * color :Specifies the color value od line 972 * rop :Specifies rop values. 973 * Planemask :Specifies planemask value. 974 * Returns :none 975 * 976 * Comments :none 977*---------------------------------------------------------------------------- 978*/ 979void 980GX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, 981 int color, int rop, unsigned int planemask) 982{ 983 /* LOAD THE SOLID PATTERN COLOR */ 984 GFX(set_solid_pattern((unsigned int)color)); 985 986 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 987 GFX(set_raster_operation(XAAGetPatternROP(rop & 0x0F))); 988} 989 990/*--------------------------------------------------------------------------- 991 * GX2SubsequentBresenhamLine 992 * 993 * Description :This function is used to render a vector using the 994 * specified bresenham parameters. 995 * 996 * Parameters: 997 * pScreenInfo :Screen handler pointer having screen information. 998 * x1 :Specifies the starting x position 999 * y1 :Specifies starting y possition 1000 * absmaj :Specfies the Bresenman absolute major. 1001 * absmin :Specfies the Bresenman absolute minor. 1002 * err :Specifies the bresenham err term. 1003 * len :Specifies the length of the vector interms of pixels. 1004 * octant :not used in this function,may be added for standard 1005 * interface. 1006 * Returns :none 1007 * 1008 * Comments :none 1009 * Sample application uses: 1010 * - Window outlines on window move. 1011 * - x11perf: line segments (-line500). 1012 * - x11perf: line segments (-seg500). 1013*---------------------------------------------------------------------------- 1014*/ 1015void 1016GX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, 1017 int x1, int y1, int absmaj, int absmin, int err, 1018 int len, int octant) 1019{ 1020 int axial, init, diag; 1021 1022 DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", 1023 x1, y1, absmaj, absmin, err, len, octant)); 1024 1025 /* DETERMINE BRESENHAM PARAMETERS */ 1026 1027 axial = ((int)absmin << 1); 1028 init = axial - (int)absmaj; 1029 diag = init - (int)absmaj; 1030 1031 /* ADJUST INITIAL ERROR 1032 * * Adjust by -1 for certain directions so that the vector 1033 * * hits the same pixels when drawn in either direction. 1034 * * The Gamma value is assumed to account for the initial 1035 * * error adjustment for clipped lines. 1036 */ 1037 1038 init += err; 1039 1040 /* CALL ROUTINE TO DRAW VECTOR */ 1041 1042 GFX(bresenham_line((unsigned short)x1, 1043 (unsigned short)y1, 1044 (unsigned short)len, 1045 (unsigned short)init, 1046 (unsigned short)axial, 1047 (unsigned short)diag, 1048 (unsigned short)vector_mode_table[octant])); 1049 1050} 1051 1052#define ABS(_val1, _val2) (((_val1) > (_val2)) ? ((_val1)-(_val2)) : ((_val2) - (_val1))) 1053 1054void 1055GX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, 1056 int x0, int y0, int x1, int y1, int flags) 1057{ 1058 long dx, dy, dmaj, dmin; 1059 long axialerr, diagerr, initerr; 1060 unsigned short vec_flags = 0; 1061 1062 dx = ABS(x1, x0); 1063 dy = ABS(y1, y0); 1064 if (dx >= dy) { 1065 dmaj = dx; 1066 dmin = dy; 1067 vec_flags = VM_X_MAJOR; 1068 if (x1 > x0) 1069 vec_flags |= VM_MAJOR_INC; 1070 if (y1 > y0) 1071 vec_flags |= VM_MINOR_INC; 1072 } else { 1073 dmaj = dy; 1074 dmin = dx; 1075 vec_flags = VM_Y_MAJOR; 1076 if (x1 > x0) 1077 vec_flags |= VM_MINOR_INC; 1078 if (y1 > y0) 1079 vec_flags |= VM_MAJOR_INC; 1080 } 1081 axialerr = dmin << 1; 1082 diagerr = (dmin - dmaj) << 1; 1083 initerr = (dmin << 1) - dmaj; 1084 if (!(vec_flags & VM_MINOR_INC)) 1085 initerr--; 1086 1087 GFX(bresenham_line((unsigned short)x0, 1088 (unsigned short)y0, 1089 (unsigned short)dmaj, 1090 (unsigned short)initerr, 1091 (unsigned short)axialerr, 1092 (unsigned short)diagerr, vec_flags)); 1093} 1094 1095/*--------------------------------------------------------------------------- 1096 * GX2SubsequentHorVertLine 1097 * 1098 * This routine is called to render a vector using the specified Bresenham 1099 * parameters. 1100 * 1101 * Sample application uses: 1102 * - Window outlines on window move. 1103 * - x11perf: line segments (-hseg500). 1104 * - x11perf: line segments (-vseg500). 1105 *--------------------------------------------------------------------------- 1106 */ 1107void 1108GX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, 1109 int x, int y, int len, int dir) 1110{ 1111 DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); 1112 GFX(pattern_fill((unsigned short)x, (unsigned short)y, 1113 (unsigned short)((dir == DEGREES_0) ? len : 1), 1114 (unsigned short)((dir == DEGREES_0) ? 1 : len))); 1115} 1116 1117#if DASHED_SUPPORT 1118void 1119BuildPattern(CARD32 pat, int len, CARD32 * pat8x8) 1120{ 1121 unsigned long i, count; 1122 1123 /* find homany can fit comfortably */ 1124 count = 32 / len; 1125 /* add 1 for the residue */ 1126 count++; 1127 /* construct the mask and knock off the unwanted data */ 1128 i = ((CARD32) 0xFFFFFFFF) << (31 - len); 1129 pat &= i; 1130 /* init before the show */ 1131 pat8x8[0] = 0; 1132 /* loop and build the pattern aray data */ 1133 for (i = 0; i < count; i++) { 1134 pat8x8[0] |= (pat >> (len * i)); 1135 } 1136 1137 /* equate both the array's and then adjust */ 1138 pat8x8[1] = pat8x8[0]; 1139 1140 /* how many carried from last operation */ 1141 i = (len * count) - 32; 1142 pat8x8[1] >>= i; 1143 pat8x8[1] |= (pat << (len - i)); 1144} 1145 1146#define PAT_SHIFT(pat,n) pat >> n 1147 1148/*---------------------------------------------------------------------------- 1149 * GX2SetupForDashedLine 1150 * 1151 * Description :This function is used to setup for 1152 * future line draws. 1153 * 1154 * 1155 * Parameters. 1156 * pScreenInfo :Screen handler pointer having screen information. 1157 * Returns :none 1158 * 1159 * Comments :none 1160 * x11perf -dseg100 1161 * x11perf -dline100 1162 * x11perf -ddline100 1163*---------------------------------------------------------------------------- 1164*/ 1165void 1166GX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, 1167 unsigned int planemask, int length, 1168 unsigned char *pattern) 1169{ 1170 int trans = (bg == -1); 1171 CARD32 *pat = (CARD32 *) pattern; 1172 CARD32 pat8x8[2]; 1173 1174 pat8x8[0] = pat[0]; 1175 switch (length) { 1176 case 2: 1177 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ 1178 case 4: 1179 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ 1180 case 8: 1181 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ 1182 case 16: 1183 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); 1184 case 32: 1185 pat8x8[1] = pat8x8[0]; 1186 break; 1187 case 64: 1188 pat8x8[1] = pat[1]; 1189 break; 1190 default: 1191 BuildPattern(pat[0], length, pat8x8); 1192 } 1193/* 1194 ErrorF("%X %d, %X %X\n", pat[0], length, pat8x8[0], pat8x8[1]); 1195*/ 1196 /* LOAD PATTERN COLORS AND DATA */ 1197 1198 GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg, 1199 pat8x8[0], pat8x8[1], (unsigned char)trans)); 1200 1201 /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ 1202 1203 if (planemask == 0xFFFFFFFF) { 1204 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 1205 1206 GFX(set_raster_operation(windowsROPpat[rop & 0x0F])); 1207 } else { 1208 /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ 1209 1210 GFX(set_raster_operation(windowsROPsrcMask[rop & 0x0F])); 1211 } 1212} 1213 1214/*--------------------------------------------------------------------------- 1215 * GX2SubsequentDashedBresenhamLine 1216 * 1217 * Description :This function is used to render a vector using the 1218 * specified bresenham parameters. 1219 * 1220 * Parameters: 1221 * pScreenInfo :Screen handler pointer having screen information. 1222 * x1 :Specifies the starting x position 1223 * y1 :Specifies starting y possition 1224 * absmaj :Specfies the Bresenman absolute major. 1225 * absmin :Specfies the Bresenman absolute minor. 1226 * err :Specifies the bresenham err term. 1227 * len :Specifies the length of the vector interms of pixels. 1228 * octant :not used in this function,may be added for standard 1229 * interface. 1230 * Returns :none 1231 * 1232 * Comments :none 1233 * Sample application uses: 1234 * - Window outlines on window move. 1235 * - x11perf: line segments (-line500). 1236 * - x11perf: line segments (-seg500). 1237*---------------------------------------------------------------------------- 1238*/ 1239void 1240GX2SubsequentDashedBresenhamLine(ScrnInfoPtr pScreenInfo, 1241 int x1, int y1, int absmaj, int absmin, 1242 int err, int len, int octant) 1243{ 1244 int axial, init, diag; 1245 1246 DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", 1247 x1, y1, absmaj, absmin, err, len, octant)); 1248 1249 /* DETERMINE BRESENHAM PARAMETERS */ 1250 1251 axial = ((int)absmin << 1); 1252 init = axial - (int)absmaj; 1253 diag = init - (int)absmaj; 1254 1255 /* ADJUST INITIAL ERROR 1256 * * Adjust by -1 for certain directions so that the vector 1257 * * hits the same pixels when drawn in either direction. 1258 * * The Gamma value is assumed to account for the initial 1259 * * error adjustment for clipped lines. 1260 */ 1261 1262 init += err; 1263 1264 /* CALL ROUTINE TO DRAW VECTOR */ 1265 1266 gfx2_set_pattern_origin(x1, y1); 1267 gfx2_bresenham_line(CALC_FBOFFSET(x1, y1), 1268 (unsigned short)len, (unsigned short)init, 1269 (unsigned short)axial, (unsigned short)diag, 1270 (unsigned short)vector_mode_table[octant]); 1271 1272} 1273#endif 1274 1275#if !defined(STB_X) 1276/*---------------------------------------------------------------------------- 1277 * OPTGX2SetupForCPUToScreenColorExpandFill 1278 * 1279 * Description :This routine is called to setup the background and 1280 * foreground colors,rop and plane mask for future 1281 * color expansion blits from source patterns stored 1282 * in system memory(non durango version). 1283 * 1284 * Parameters. 1285 * pScreenInfo :Screen handler pointer having screen information. 1286 * fg :Specifies the foreground color 1287 * bg :Specifies the background color 1288 * rop :Specifies rop values. 1289 * planemask :Specifies the value of masking from rop data 1290 * 1291 * Returns :none. 1292 * 1293 * Comments : 1294 * All the text gets rendered through this i/f. We have given 1295 * the offscreen memory loaction to temporarily put the text 1296 * bitmap. Generaly all the text comes as bitmap and then gets 1297 * rendered via the HOST_SRC(similar to scratchpad in GX1). Now 1298 * since we already have the bitmap in offscreen we can do a 1299 * src_FB_EXPAND. This is the best possible you can do with GX2 1300 * CPU-to-screen color expansion 1301 * x11perf -ftext (pure indirect): 1302 * x11perf -oddsrect10 1303 * x11perf -oddsrect100 1304 * x11perf -bigsrect10 1305 * x11perf -bigsrect100 1306 * x11perf -polytext 1307 * x11perf -polytext16 1308 * x11perf -seg1 1309 * x11perf -copyplane10 1310 * x11perf -copyplane100 1311 * x11perf -putimagexy10 1312 * x11perf -putimagexy100 1313*---------------------------------------------------------------------------- 1314*/ 1315 1316void 1317OPTGX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 1318 int fg, int bg, int rop, 1319 unsigned int planemask) 1320{ 1321 int trans = (bg == -1); 1322 1323 GeodeROP = XAAGetCopyROP_PM(rop); 1324 1325 if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { 1326 Geode_blt_mode = MGP_BM_DST_REQ; 1327 } else { 1328 Geode_blt_mode = 0; 1329 } 1330 if (trans) 1331 GeodeROP |= MGP_RM_SRC_TRANS; 1332 1333 /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ 1334 1335 GU2_WAIT_PENDING; 1336 WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long)planemask); 1337 WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); 1338 WRITE_GP32(MGP_SRC_COLOR_FG, fg); 1339 WRITE_GP32(MGP_SRC_COLOR_BG, bg); 1340} 1341 1342/*------------------------------------------------------------------------------- 1343 * OPTGX2SubsequentCPUToScreenColorExpandFill 1344 * 1345 * Description :This routine is used to perform color expansion blits from 1346 * source patterns stored in system memory using the previously 1347 * set rop and plane mask.(non durango version) 1348 * 1349 * Parameters. 1350 * pScreenInfo :Screen handler pointer having screen information. 1351 * x and y :Specifies the x and y co-ordinatesarea. 1352 * w and h :Specifies width and height respectively. 1353 * 1354 * Returns :none 1355 * 1356 * Comments :none 1357 *-------------------------------------------------------------------------------- 1358 */ 1359void 1360OPTGX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, 1361 int x, int y, int w, int h, 1362 int skipleft) 1363{ 1364 GeodePtr pGeode = GEODEPTR(pScreenInfo); 1365 1366 GU2_WAIT_PENDING; 1367 WRITE_GP32(MGP_SRC_OFFSET, ((unsigned int)(localRecPtr->ColorExpandBase - 1368 pGeode->FBBase))); 1369 WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); 1370 WRITE_GP32(MGP_WID_HEIGHT, (((unsigned long)w) << 16) | h); 1371 WRITE_GP32(MGP_STRIDE, (((w + 31) >> 5) << 18) | pGeode->Pitch); 1372 SetCPUToScreen = 1; 1373} 1374 1375/*---------------------------------------------------------------------------- 1376 * OPTGX2SetupForFillRectSolid. 1377 * 1378 * Description :This routine is called to setup the solid pattern 1379 * color for future rectangular fills or vectors. 1380 * (non durango version) 1381 * 1382 * Parameters. 1383 * pScreenInfo 1384 * Ptr :Screen handler pointer having screen information. 1385 * color :Specifies the color to be filled up in defined area. 1386 * rop :Specifies the raster operation value. 1387 * planemask :Specifies the masking value based rop srcdata. 1388 * 1389 * Returns :none 1390 * 1391 * Comments :none 1392 * 1393*---------------------------------------------------------------------------- 1394*/ 1395void 1396OPTGX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, 1397 int color, int rop, unsigned int planemask) 1398{ 1399 GeodePtr pGeode = GEODEPTR(pScreenInfo); 1400 1401 GU2_WAIT_PENDING; 1402 WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long)color); 1403 1404 WRITE_GP32(MGP_STRIDE, pGeode->Pitch); 1405 1406 if (planemask == 0xFFFFFFFF) { 1407 GeodeROP = XAAGetPatternROP(rop); 1408 } else { 1409 WRITE_GP32(MGP_SRC_COLOR_FG, (unsigned long)planemask); 1410 GeodeROP = XAAGetPatternROP(rop); 1411 } 1412 1413 WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); 1414 1415 Geode_blt_mode = 0; 1416 if (!((GeodeROP & 0x33) ^ ((GeodeROP >> 2) & 0x33))) 1417 Geode_blt_mode = MGP_BM_SRC_MONO; 1418 1419 if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { 1420 Geode_blt_mode |= MGP_BM_DST_REQ; 1421 Geode_vector_mode = MGP_VM_DST_REQ; 1422 } else { 1423 Geode_vector_mode = 0; 1424 } 1425} 1426 1427 /*---------------------------------------------------------------------------- 1428 * OPTGX2SubsequentFillRectSolid. 1429 * 1430 * Description :This routine is used to fill the rectangle of previously 1431 * specified solid pattern. 1432 * (non durango version) 1433 * 1434 * Parameters. 1435 * pScreenInfo :Screen handler pointer having screen information. 1436 * x and y :Specifies the x and y co-ordinatesarea. 1437 * w and h :Specifies width and height respectively. 1438 * 1439 * Returns :none 1440 * 1441 * Comments :desired pattern can be set before this function by 1442 * gfx_set_solid_pattern. 1443 * Sample application uses: 1444 * - Window backgrounds. 1445 * - x11perf: rectangle tests (-rect500). 1446 * - x11perf: fill trapezoid tests (-trap100). 1447 * - x11perf: horizontal line segments (-hseg500). 1448 *---------------------------------------------------------------------------- 1449*/ 1450void 1451OPTGX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, 1452 int x, int y, int width, int height) 1453{ 1454 DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, width, height)); 1455 1456 GFX_PATTERN_FILL(x, y, width, height); 1457} 1458 1459/*---------------------------------------------------------------------------- 1460 * OPTGX2SetupForScreenToScreenCopy 1461 * 1462 * Description :This function is used to set up the planemask and raster 1463 * for future Bliting functionality. 1464 * (non durango version) 1465 * 1466 * Parameters: 1467 * pScreenInfo :Screen handler pointer having screen information. 1468 * xdir :This is set based on rop data. 1469 * ydir :This is set based on rop data. 1470 * rop :sets the raster operation 1471 * transparency:tobeadded 1472 * planemask :Specifies the value of masking from rop data 1473 1474 * Returns :none 1475 * 1476 * Comments :The patterns specified is ignored inside the function 1477*---------------------------------------------------------------------------- 1478*/ 1479void 1480OPTGX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, 1481 int xdir, int ydir, int rop, 1482 unsigned int planemask, 1483 int transparency_color) 1484{ 1485 GeodePtr pGeode = GEODEPTR(pScreenInfo); 1486 1487 GeodeROP = XAAGetCopyROP_PM(rop); 1488 1489 Geode_blt_mode = MGP_BM_SRC_FB; 1490 1491 /* CALCULATE THE DIRECTION OF THE BLT */ 1492 if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { 1493 Geode_blt_mode |= MGP_BM_DST_REQ; 1494 } 1495 1496 GU2_WAIT_PENDING; 1497 1498 if (transparency_color != -1) { 1499 WRITE_GP32(MGP_SRC_COLOR_FG, transparency_color); 1500 WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); 1501 GeodeROP = MGP_RM_SRC_TRANS | 0xCC; 1502 } 1503 WRITE_GP32(MGP_PAT_COLOR_0, planemask); 1504 WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); 1505 WRITE_GP32(MGP_STRIDE, pGeode->Pitch | (pGeode->Pitch << 16)); 1506} 1507 1508/*---------------------------------------------------------------------------- 1509 * OPTGX2SubsquentScreenToScreenCopy 1510 * 1511 * Description :This function is called to perform a screen to screen 1512 * BLT using the previously specified planemask,raster 1513 * operation and * transparency flag 1514 * (non durango version) 1515 * 1516 * Parameters. 1517 * pScreenInfo :Screen handler pointer having screen information. 1518 * srcx :x -coordinates of the source window 1519 * srcy :y-co-ordinates of the source window 1520 * dstx :x -coordinates of the destination window 1521 * dsty :y-co-ordinates of the destination window 1522 * width :Specifies width of the window to be copied 1523 * height :Height of the window to be copied. 1524 * Returns :none 1525 * 1526 * Comments :The patterns specified is ignored inside the function 1527 * Sample application uses (non-transparent): 1528 * - Moving windows. 1529 * - x11perf: scroll tests (-scroll500). 1530 * - x11perf: copy from window to window (-copywinwin500). 1531 * 1532 * No application found using transparency. 1533*---------------------------------------------------------------------------- 1534*/ 1535void 1536OPTGX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, 1537 int srcx, int srcy, int dstx, int dsty, 1538 int width, int height) 1539{ 1540 unsigned int srcoffset, dstoffset, blt_mode, size; 1541 1542 DEBUGMSG(0, (0, 0, "Scr2scr %d %d %d %d %dx%d\n", 1543 srcx, srcy, dstx, dsty, width, height)); 1544 1545 size = (((unsigned int)width) << 16) | height; 1546 1547 blt_mode = Geode_blt_mode; 1548 1549 if (dstx > srcx) { 1550 blt_mode |= MGP_BM_NEG_XDIR; 1551 srcx += width - 1; 1552 dstx += width - 1; 1553 } 1554 if (dsty > srcy) { 1555 blt_mode |= MGP_BM_NEG_YDIR; 1556 srcy += height - 1; 1557 dsty += height - 1; 1558 } 1559 1560 /* CALCULATE STARTING OFFSETS */ 1561 1562 srcoffset = CALC_FBOFFSET(srcx, srcy); 1563 dstoffset = CALC_FBOFFSET(dstx, dsty) & 0xFFFFFF; 1564 1565 /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ 1566 /* This is a quirk of the hardware. */ 1567 1568 if (Geode_blt_mode & MGP_BM_NEG_XDIR) { 1569 srcoffset += (1 << gu2_xshift) - 1; 1570 dstoffset += (1 << gu2_xshift) - 1; 1571 } 1572 /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ 1573 /* Put off poll for as long as possible (do most calculations first). */ 1574 1575 GU2_WAIT_PENDING; 1576 WRITE_GP32(MGP_SRC_OFFSET, srcoffset); 1577 WRITE_GP32(MGP_DST_OFFSET, dstoffset); 1578 WRITE_GP32(MGP_WID_HEIGHT, size); 1579 WRITE_GP32(MGP_BLT_MODE, blt_mode); 1580} 1581 1582/*---------------------------------------------------------------------------- 1583 * OPTGX2SetupForImageWrite 1584 * 1585 * Description :This function is used to set up the planemask and raster 1586 * for future Bliting functionality.(non durango version) 1587 * 1588 * Parameters: 1589 * pScreenInfo :Screen handler pointer having screen information. 1590 * rop :sets the raster operation 1591 * transparency_color :tobeadded 1592 * planemask :Specifies the value of masking from rop data 1593 * bpp :bits per pixel of the source pixmap 1594 * depth :depth of the source pixmap. 1595 * Returns :none 1596 * 1597 * Comments :none 1598*---------------------------------------------------------------------------- 1599*/ 1600void 1601OPTGX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, 1602 int rop, unsigned int planemask, 1603 int transparency_color, int bpp, int depth) 1604{ 1605 OPTGX2SetupForScreenToScreenCopy(pScreenInfo, 1606 0, 0, rop, planemask, transparency_color); 1607} 1608 1609void 1610OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, 1611 int x, int y, int w, int h, int skipleft) 1612{ 1613 Geodedstx = x; 1614 Geodedsty = y; 1615 Geodewidth = w; 1616 Geodeheight = h; 1617#if IMGWRITE_SUPPORT 1618 SetImageWriteRect = 1; 1619#endif 1620} 1621 1622/*---------------------------------------------------------------------------- 1623 * OPTGX2SetupForScanlineImageWrite 1624 * 1625 * Description :This function is used to set up the planemask and raster 1626 * for future Bliting functionality.(non durango version) 1627 * 1628 * Parameters: 1629 * pScreenInfo :Screen handler pointer having screen information. 1630 * rop :sets the raster operation 1631 * transparency_color:tobeadded 1632 * planemask :Specifies the value of masking from rop data 1633 * bpp :bits per pixel of the source pixmap 1634 * depth :depth of the source pixmap. 1635 * Returns :none 1636 * 1637 * Comments :none 1638*---------------------------------------------------------------------------- 1639*/ 1640void 1641OPTGX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, 1642 int rop, unsigned int planemask, 1643 int transparency_color, int bpp, int depth) 1644{ 1645 OPTGX2SetupForScreenToScreenCopy(pScreenInfo, 1646 0, 0, rop, planemask, transparency_color); 1647} 1648 1649/*---------------------------------------------------------------------------- 1650 * OPTGX2SubsequentScanlineImageWriteRect 1651 * 1652 * Description :This function is used to set up the x,y corordinates and width 1653 * &height for future Bliting functionality.(non durango version) 1654 * 1655 * Parameters: 1656 * pScreenInfo :Screen handler pointer having screen information. 1657 * x :destination x 1658 * y :destination y 1659 * w :Specifies the width of the rectangle to be copied 1660 * h :Specifies the height of the rectangle to be copied 1661 * Returns :none 1662 * 1663 * Comments :none 1664 *---------------------------------------------------------------------------- 1665*/ 1666void 1667OPTGX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, 1668 int x, int y, int w, int h, 1669 int skipleft) 1670{ 1671 Geodedstx = x; 1672 Geodedsty = y; 1673 Geodewidth = w; 1674 Geodeheight = h; 1675 GeodeCounter = 0; 1676} 1677 1678/*---------------------------------------------------------------------------- 1679 * OPTGX2SubsquentImageWriteScanline 1680 * 1681 * Description :This function is called to 1682 * BLT using the previously specified planemask,raster 1683 * operation and transparency flag(non durango version) 1684 * 1685 * Parameters. 1686 * pScreenInfo :Screen handler pointer having screen information. 1687 * 1688 * Returns :none 1689 * 1690 * Comments :The patterns specified is ignored inside the function 1691 * Sample application uses (non-transparent): 1692 * - Moving windows. 1693 * - x11perf: scroll tests (-scroll500). 1694 * - x11perf: copy from window to window (-copywinwin500). 1695 * 1696 * No application found using transparency. 1697*---------------------------------------------------------------------------- 1698*/ 1699 1700void 1701OPTGX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) 1702{ 1703 GeodePtr pGeode; 1704 1705 int blt_height = 0; 1706 char blit = FALSE; 1707 1708 pGeode = GEODEPTR(pScreenInfo); 1709 GeodeCounter++; 1710 1711 if ((Geodeheight <= pGeode->NoOfImgBuffers) && 1712 (GeodeCounter == Geodeheight)) { 1713 blit = TRUE; 1714 blt_height = Geodeheight; 1715 } else if ((Geodeheight > pGeode->NoOfImgBuffers) 1716 && (GeodeCounter == pGeode->NoOfImgBuffers)) { 1717 blit = TRUE; 1718 Geodeheight -= pGeode->NoOfImgBuffers; 1719 blt_height = pGeode->NoOfImgBuffers; 1720 } else 1721 return; 1722 1723 if (blit) { 1724 blit = FALSE; 1725 GeodeCounter = 0; 1726 OPTGX2SubsequentScreenToScreenCopy(pScreenInfo, 1727 Geodesrcx, Geodesrcy, Geodedstx, 1728 Geodedsty, Geodewidth, blt_height); 1729 Geodedsty += blt_height; 1730 GU2_WAIT_BUSY; 1731 } 1732} 1733 1734/*---------------------------------------------------------------------------- 1735 * OPTGX2SetupForSolidLine 1736 * 1737 * Description :This function is used setup the solid line color for 1738 * future line draws. 1739 * 1740 * 1741 * Parameters. 1742 * pScreenInfo :Screen handler pointer having screen information. 1743 * color :Specifies the color value od line 1744 * rop :Specifies rop values. 1745 * Planemask :Specifies planemask value. 1746 * Returns :none 1747 * 1748 * Comments :none 1749*---------------------------------------------------------------------------- 1750*/ 1751void 1752OPTGX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, 1753 int color, int rop, unsigned int planemask) 1754{ 1755 OPTGX2SetupForFillRectSolid(pScreenInfo, color, rop, planemask); 1756} 1757 1758/*--------------------------------------------------------------------------- 1759 * OPTGX2SubsequentBresenhamLine 1760 * 1761 * Description :This function is used to render a vector using the 1762 * specified bresenham parameters. 1763 * 1764 * Parameters: 1765 * pScreenInfo :Screen handler pointer having screen information. 1766 * x1 :Specifies the starting x position 1767 * y1 :Specifies starting y possition 1768 * absmaj :Specfies the Bresenman absolute major. 1769 * absmin :Specfies the Bresenman absolute minor. 1770 * err :Specifies the bresenham err term. 1771 * len :Specifies the length of the vector interms of pixels. 1772 * octant :not used in this function,may be added for standard 1773 * interface. 1774 * Returns :none 1775 * 1776 * Comments :none 1777 * Sample application uses: 1778 * - Window outlines on window move. 1779 * - x11perf: line segments (-seg500). 1780*---------------------------------------------------------------------------- 1781*/ 1782void 1783OPTGX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, 1784 int x1, int y1, int absmaj, int absmin, 1785 int err, int len, int octant) 1786{ 1787 int axial, init, diag; 1788 1789 DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", 1790 x1, y1, absmaj, absmin, err, len, octant)); 1791 1792 /* DETERMINE BRESENHAM PARAMETERS */ 1793 1794 axial = ((int)absmin << 1); 1795 init = axial - (int)absmaj; 1796 diag = init - (int)absmaj; 1797 1798 /* ADJUST INITIAL ERROR 1799 * * Adjust by -1 for certain directions so that the vector 1800 * * hits the same pixels when drawn in either direction. 1801 * * The Gamma value is assumed to account for the initial 1802 * * error adjustment for clipped lines. 1803 */ 1804 1805 init += err; 1806 1807 /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ 1808 /* Put off poll for as long as possible (do most calculations first). */ 1809 1810 GU2_WAIT_PENDING; 1811 WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x1, y1)); 1812 WRITE_GP32(MGP_VEC_ERR, 1813 (((unsigned long)axial) << 16) | (unsigned short)diag); 1814 WRITE_GP32(MGP_VEC_LEN, 1815 (((unsigned long)len) << 16) | (unsigned short)init); 1816 WRITE_GP32(MGP_VECTOR_MODE, 1817 (Geode_vector_mode | vector_mode_table[octant])); 1818} 1819 1820void 1821OPTGX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, 1822 int x0, int y0, int x1, int y1, int flags) 1823{ 1824 long dx, dy, dmaj, dmin; 1825 long axialerr, diagerr, initerr; 1826 unsigned short vec_flags = 0; 1827 1828 dx = ABS(x1, x0); 1829 dy = ABS(y1, y0); 1830 if (dx >= dy) { 1831 dmaj = dx; 1832 dmin = dy; 1833 vec_flags = VM_X_MAJOR; 1834 if (x1 > x0) 1835 vec_flags |= VM_MAJOR_INC; 1836 if (y1 > y0) 1837 vec_flags |= VM_MINOR_INC; 1838 } else { 1839 dmaj = dy; 1840 dmin = dx; 1841 vec_flags = VM_Y_MAJOR; 1842 if (x1 > x0) 1843 vec_flags |= VM_MINOR_INC; 1844 if (y1 > y0) 1845 vec_flags |= VM_MAJOR_INC; 1846 } 1847 1848 axialerr = dmin << 1; 1849 diagerr = (dmin - dmaj) << 1; 1850 initerr = (axialerr - dmaj); 1851 1852 if (!(vec_flags & VM_MINOR_INC)) 1853 initerr--; 1854 1855 GU2_WAIT_PENDING; 1856 WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x0, y0)); 1857 WRITE_GP32(MGP_VEC_ERR, 1858 (((unsigned long)axialerr) << 16) | (unsigned short)diagerr); 1859 WRITE_GP32(MGP_VEC_LEN, 1860 (((unsigned long)dmaj) << 16) | (unsigned short)initerr); 1861 WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); 1862} 1863 1864/*--------------------------------------------------------------------------- 1865 * OPTGX2SubsequentHorVertLine 1866 * 1867 * This routine is called to render a vector using the specified Bresenham 1868 * parameters. 1869 * 1870 * Sample application uses: 1871 * - Window outlines on window move. 1872 * - x11perf: line segments (-hseg500). 1873 * - x11perf: line segments (-vseg500). 1874 *--------------------------------------------------------------------------- 1875 */ 1876void 1877OPTGX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, 1878 int x, int y, int len, int dir) 1879{ 1880 DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); 1881#if 1 1882 GFX_PATTERN_FILL(x, y, 1883 (unsigned short)((dir == DEGREES_0) ? len : 1), 1884 (unsigned short)((dir == DEGREES_0) ? 1 : len)); 1885#else 1886 GU2_WAIT_PENDING; 1887 WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); 1888 WRITE_GP32(MGP_VEC_ERR, 0); 1889 WRITE_GP32(MGP_VEC_LEN, 1890 (((unsigned long)len) << 16) | (unsigned short)-len); 1891 WRITE_GP32(MGP_VECTOR_MODE, 1892 (Geode_vector_mode | 1893 vector_mode_table[(dir == DEGREES_0) ? 2 : 5])); 1894#endif 1895} 1896 1897#if DASHED_SUPPORT 1898/* Setup for XAA dashed lines. 1899 1900 Tests: xtest CH05/stdshs, XFree86/drwln 1901 1902 x11perf -dseg100 1903 x11perf -dline100 1904 x11perf -ddline100 1905*/ 1906void 1907OPTGX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, 1908 unsigned int planemask, int length, 1909 unsigned char *pattern) 1910{ 1911 GeodePtr pGeode = GEODEPTR(pScrn); 1912 CARD32 *pat = (CARD32 *) pattern; 1913 CARD32 pat8x8[2]; 1914 1915 pat8x8[0] = pat[0]; 1916 switch (length) { 1917 case 2: 1918 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ 1919 case 4: 1920 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ 1921 case 8: 1922 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ 1923 case 16: 1924 pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); 1925 case 32: 1926 pat8x8[1] = pat8x8[0]; 1927 break; 1928 case 64: 1929 pat8x8[1] = pat[1]; 1930 break; 1931 default: 1932 BuildPattern(pat[0], length, pat8x8); 1933 } 1934 /* LOAD PATTERN COLORS AND DATA */ 1935 1936 /* SET PATTERN FLAGS */ 1937 1938 if (planemask == 0xFFFFFFFF) { 1939 GeodeROP = XAAGetPatternROP(rop & 0x0F); 1940 } else { 1941 GeodeROP = XAAGetPatternROP_PM(rop & 0x0F); 1942 } 1943 if (bg == -1) 1944 GeodeROP |= MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS; 1945 else 1946 GeodeROP |= MGP_RM_PAT_MONO; 1947 1948 if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { 1949 Geode_blt_mode = MGP_BM_DST_REQ; 1950 Geode_vector_mode = MGP_VM_DST_REQ; 1951 } else { 1952 Geode_blt_mode = MGP_BM_SRC_MONO; 1953 Geode_vector_mode = 0; 1954 } 1955 1956 /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ 1957 1958 GU2_WAIT_PENDING; 1959 WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); 1960 WRITE_GP32(MGP_PAT_COLOR_0, bg); 1961 WRITE_GP32(MGP_PAT_COLOR_1, fg); 1962 WRITE_GP32(MGP_PAT_DATA_0, pat8x8[0]); 1963 WRITE_GP32(MGP_PAT_DATA_1, pat8x8[1]); 1964 WRITE_GP32(MGP_STRIDE, pGeode->Pitch); 1965 1966} 1967 1968void 1969OPTGX2SubsequentDashedBresenhamLine(ScrnInfoPtr pScreenInfo, 1970 int x1, int y1, int absmaj, int absmin, 1971 int err, int len, int octant) 1972{ 1973 int axial, init, diag; 1974 unsigned long gu2_pattern_origin; 1975 1976 DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", 1977 x1, y1, absmaj, absmin, err, len, octant)); 1978 1979 /* CHECK NULL LENGTH */ 1980 1981 if (!len) 1982 return; 1983 1984 /* DETERMINE BRESENHAM PARAMETERS */ 1985 1986 axial = ((int)absmin << 1); 1987 init = axial - (int)absmaj; 1988 diag = init - (int)absmaj; 1989 1990 /* ADJUST INITIAL ERROR 1991 * * Adjust by -1 for certain directions so that the vector 1992 * * hits the same pixels when drawn in either direction. 1993 * * The Gamma value is assumed to account for the initial 1994 * * error adjustment for clipped lines. 1995 */ 1996 1997 init += err; 1998 1999 /* CALL ROUTINE TO DRAW VECTOR */ 2000 2001 gu2_pattern_origin = (((unsigned long)(x1 & 7)) << 26) | 2002 (((unsigned long)(y1 & 7)) << 29); 2003 2004 /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ 2005 /* Put off poll for as long as possible (do most calculations first). */ 2006 2007 GU2_WAIT_PENDING; 2008 WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x1, y1) & 0x00FFFFFF) | 2009 gu2_pattern_origin); 2010 WRITE_GP32(MGP_VEC_ERR, 2011 (((unsigned long)axial) << 16) | (unsigned short)diag); 2012 WRITE_GP32(MGP_VEC_LEN, 2013 (((unsigned long)len) << 16) | (unsigned short)init); 2014 WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | 2015 vector_mode_table[octant])); 2016} 2017 2018void 2019OPTGX2SubsequentDashedTwoPointLine(ScrnInfoPtr pScreenInfo, 2020 int x0, int y0, int x1, int y1, int flags) 2021{ 2022 long dx, dy, dmaj, dmin; 2023 long axialerr, diagerr, initerr; 2024 unsigned long gu2_pattern_origin; 2025 unsigned short vec_flags = 0; 2026 2027 dx = ABS(x1, x0); 2028 dy = ABS(y1, y0); 2029 if (dx >= dy) { 2030 dmaj = dx; 2031 dmin = dy; 2032 vec_flags = VM_X_MAJOR; 2033 if (x1 > x0) 2034 vec_flags |= VM_MAJOR_INC; 2035 if (y1 > y0) 2036 vec_flags |= VM_MINOR_INC; 2037 } else { 2038 dmaj = dy; 2039 dmin = dx; 2040 vec_flags = VM_Y_MAJOR; 2041 if (x1 > x0) 2042 vec_flags |= VM_MINOR_INC; 2043 if (y1 > y0) 2044 vec_flags |= VM_MAJOR_INC; 2045 } 2046 2047 axialerr = dmin << 1; 2048 diagerr = (dmin - dmaj) << 1; 2049 initerr = (axialerr - dmaj); 2050 2051 if (!(vec_flags & VM_MINOR_INC)) 2052 initerr--; 2053 2054 /* CALL ROUTINE TO DRAW VECTOR */ 2055 2056 gu2_pattern_origin = (((unsigned long)(x0 & 7)) << 26) | 2057 (((unsigned long)(y0 & 7)) << 29); 2058 2059 GU2_WAIT_PENDING; 2060 WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x0, y0) & 0x00FFFFFF) | 2061 gu2_pattern_origin); 2062 WRITE_GP32(MGP_VEC_ERR, 2063 (((unsigned long)axialerr) << 16) | (unsigned short)diagerr); 2064 WRITE_GP32(MGP_VEC_LEN, 2065 (((unsigned long)dmaj) << 16) | (unsigned short)initerr); 2066 WRITE_GP16(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); 2067} 2068#endif /* DASHED_SUPPORT */ 2069#endif /* STB_X */ 2070 2071#if 0 2072void 2073GX2WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, 2074 unsigned char *src, int srcwidth, int skipleft, 2075 int fg, int bg, int rop, unsigned int planemask) 2076{ 2077 GFX(set_solid_pattern(planemask)); 2078 GFX(set_mono_source(bg, fg, (bg == -1))); 2079 2080 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 2081 GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); 2082 GFX(mono_bitmap_to_screen_blt_swp(0, 0, x, y, 2083 srcwidth << 3, h, src, srcwidth)); 2084} 2085 2086void 2087GX2WritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, /* bytes */ 2088 int rop, unsigned int planemask, int trans, int bpp, int depth) 2089{ 2090 /* 2091 * ErrorF("GX2WritePixmap %d %d %d %d %X %d %d %d, %d\n", 2092 * x, y, w, h, src, srcwidth, bpp, depth, trans); 2093 */ 2094 GFX(set_solid_pattern(planemask)); 2095 2096 /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ 2097 GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); 2098 if (trans == -1) { 2099 GFX(color_bitmap_to_screen_blt(0, 0, x, y, w, h, src, srcwidth)); 2100 } else { 2101 GFX(color_bitmap_to_screen_xblt(0, 0, x, y, w, h, src, 2102 srcwidth, trans)); 2103 } 2104} 2105 2106void 2107GX2ReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, 2108 unsigned char *dst, int dstwidth, int bpp, int depth) 2109{ 2110 ErrorF("GX2ReadPixmap %d %d %d %d %X %d %d %d\n", 2111 x, y, w, h, dst, dstwidth, bpp, depth); 2112} 2113#endif 2114/**************************************************************************/ 2115 2116/*---------------------------------------------------------------------------- 2117 * GX2AccelInit. 2118 * 2119 * Description :This function sets up the supported acceleration routines and 2120 * appropriate flags. 2121 * 2122 * Parameters: 2123 * pScreen :Screeen pointer structure. 2124 * 2125 * Returns :TRUE on success and FALSE on Failure 2126 * 2127 * Comments :This function is called in GX2ScreenInit in 2128 geode_driver.c to set * the acceleration. 2129*---------------------------------------------------------------------------- 2130*/ 2131Bool 2132GX2AccelInit(ScreenPtr pScreen) 2133{ 2134 GeodePtr pGeode; 2135 ScrnInfoPtr pScreenInfo; 2136 2137 pScreenInfo = xf86Screens[pScreen->myNum]; 2138 pGeode = GEODEPTR(pScreenInfo); 2139 2140 switch (pScreenInfo->bitsPerPixel) { 2141 case 8: 2142 gu2_bpp = MGP_RM_BPPFMT_332; 2143 break; 2144 case 16: 2145 gu2_bpp = MGP_RM_BPPFMT_565; 2146 break; 2147 case 32: 2148 gu2_bpp = MGP_RM_BPPFMT_8888; 2149 break; 2150 } 2151 2152 gu2_xshift = pScreenInfo->bitsPerPixel >> 4; 2153 2154 switch (pGeode->Pitch) { 2155 case 1024: 2156 gu2_yshift = 10; 2157 break; 2158 case 2048: 2159 gu2_yshift = 11; 2160 break; 2161 case 4096: 2162 gu2_yshift = 12; 2163 break; 2164 case 8192: 2165 gu2_yshift = 13; 2166 break; 2167 } 2168 2169 /* Getting the pointer for acceleration Inforecord */ 2170 pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec(); 2171 2172 /* SET ACCELERATION FLAGS */ 2173 localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; 2174 2175 /* HOOK SYNCRONIZARION ROUTINE */ 2176 localRecPtr->Sync = GX2AccelSync; 2177 2178 /* HOOK FILLED RECTANGLES */ 2179 localRecPtr->SetupForSolidFill = OPTACCEL(GX2SetupForFillRectSolid); 2180 localRecPtr->SubsequentSolidFillRect = 2181 OPTACCEL(GX2SubsequentFillRectSolid); 2182 localRecPtr->SolidFillFlags = 0; 2183 2184 /* HOOK 8x8 Mono EXPAND PATTERNS */ 2185 localRecPtr->SetupForMono8x8PatternFill = GX2SetupFor8x8PatternMonoExpand; 2186 localRecPtr->SubsequentMono8x8PatternFillRect = 2187 GX2Subsequent8x8PatternMonoExpand; 2188 localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST | 2189 HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; 2190 2191 localRecPtr->SetupForColor8x8PatternFill = 2192 GX2SetupFor8x8PatternColorExpand; 2193 localRecPtr->SubsequentColor8x8PatternFillRect = 2194 GX2Subsequent8x8PatternColorExpand; 2195 /* Color expansion */ 2196 localRecPtr->Color8x8PatternFillFlags = 2197 BIT_ORDER_IN_BYTE_MSBFIRST | 2198 SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN; 2199 2200 /* HOOK SCREEN TO SCREEN COPIES 2201 * * Set flag to only allow copy if transparency is enabled. 2202 */ 2203 localRecPtr->SetupForScreenToScreenCopy = 2204 OPTACCEL(GX2SetupForScreenToScreenCopy); 2205 localRecPtr->SubsequentScreenToScreenCopy = 2206 OPTACCEL(GX2SubsequentScreenToScreenCopy); 2207 localRecPtr->ScreenToScreenCopyFlags = 0; 2208 2209 /* HOOK BRESENHAM SOLID LINES */ 2210 /* Do not hook unless flag can be set preventing use of planemask. */ 2211 localRecPtr->SolidLineFlags = NO_PLANEMASK; 2212 localRecPtr->SetupForSolidLine = OPTACCEL(GX2SetupForSolidLine); 2213 localRecPtr->SubsequentSolidBresenhamLine = 2214 OPTACCEL(GX2SubsequentBresenhamLine); 2215 localRecPtr->SubsequentSolidHorVertLine = 2216 OPTACCEL(GX2SubsequentHorVertLine); 2217 localRecPtr->SubsequentSolidTwoPointLine = 2218 OPTACCEL(GX2SubsequentSolidTwoPointLine); 2219 localRecPtr->SolidBresenhamLineErrorTermBits = 15; 2220 2221#if DASHED_SUPPORT 2222 localRecPtr->SetupForDashedLine = OPTACCEL(GX2SetupForDashedLine); 2223 localRecPtr->SubsequentDashedBresenhamLine = 2224 OPTACCEL(GX2SubsequentDashedBresenhamLine); 2225 localRecPtr->SubsequentSolidTwoPointLine = 2226 OPTACCEL(GX2SubsequentDashedTwoPointLine); 2227 localRecPtr->DashedBresenhamLineErrorTermBits = 15; 2228 localRecPtr->DashPatternMaxLength = 64; 2229 localRecPtr->DashedLineFlags = NO_PLANEMASK | 2230 LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_MSBJUSTIFIED; 2231#endif 2232#if SCR2SCREXP 2233 /* Color expansion */ 2234 localRecPtr->ScreenToScreenColorExpandFillFlags = 2235 BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY; 2236 2237 localRecPtr->SetupForScreenToScreenColorExpandFill = 2238 (GX2SetupForScreenToScreenColorExpandFill); 2239 localRecPtr->SubsequentScreenToScreenColorExpandFill = 2240 (GX2SubsequentScreenToScreenColorExpandFill); 2241#endif 2242 /* 2243 * ImageWrite. 2244 * 2245 * SInce this uses off-screen scanline buffers, it is only of use when 2246 * complex ROPs are used. But since the current XAA pixmap cache code 2247 * only works when an ImageWrite is provided, the NO_GXCOPY flag is 2248 * temporarily disabled. 2249 */ 2250 if (pGeode->AccelImageWriteBufferOffsets) { 2251 /* Color expansion */ 2252 localRecPtr->CPUToScreenColorExpandFillFlags = 2253 BIT_ORDER_IN_BYTE_MSBFIRST | 2254 NO_PLANEMASK | SYNC_AFTER_COLOR_EXPAND | SCANLINE_PAD_DWORD; 2255 localRecPtr->ColorExpandBase = pGeode->AccelImageWriteBufferOffsets[0]; 2256 localRecPtr->ColorExpandRange = pGeode->NoOfImgBuffers << gu2_yshift; 2257 2258 localRecPtr->SetupForCPUToScreenColorExpandFill = 2259 OPTACCEL(GX2SetupForCPUToScreenColorExpandFill); 2260 localRecPtr->SubsequentCPUToScreenColorExpandFill = 2261 OPTACCEL(GX2SubsequentCPUToScreenColorExpandFill); 2262 2263#if IMGWRITE_SUPPORT 2264 localRecPtr->ImageWriteFlags = NO_PLANEMASK | 2265 SCANLINE_PAD_DWORD | SYNC_AFTER_IMAGE_WRITE; 2266 localRecPtr->ImageWriteBase = pGeode->AccelImageWriteBufferOffsets[0]; 2267 localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; 2268 localRecPtr->SetupForImageWrite = OPTACCEL(GX2SetupForImageWrite); 2269 localRecPtr->SubsequentImageWriteRect = 2270 OPTACCEL(GX2SubsequentImageWriteRect); 2271#endif /* IMGWRITE_SUPPORT */ 2272 2273 localRecPtr->ScanlineImageWriteFlags = 2274 localRecPtr->ScreenToScreenCopyFlags; 2275 localRecPtr->ScanlineImageWriteBuffers = 2276 pGeode->AccelImageWriteBufferOffsets; 2277 localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers; 2278 localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; 2279 localRecPtr->SetupForScanlineImageWrite = 2280 OPTACCEL(GX2SetupForScanlineImageWrite); 2281 localRecPtr->SubsequentScanlineImageWriteRect = 2282 OPTACCEL(GX2SubsequentScanlineImageWriteRect); 2283 localRecPtr->SubsequentImageWriteScanline = 2284 OPTACCEL(GX2SubsequentImageWriteScanline); 2285 2286 ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase; 2287 Geodesrcy = ImgBufOffset >> gu2_yshift; 2288 2289 Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1); 2290 Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3); 2291 } else { 2292 localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; 2293 } 2294#if 0 2295#if !defined(STB_X) 2296 localRecPtr->WriteBitmap = GX2WriteBitmap; 2297#endif 2298 localRecPtr->WritePixmap = GX2WritePixmap; 2299 localRecPtr->ReadPixmap = GX2ReadPixmap; 2300#endif 2301 2302 return (XAAInit(pScreen, localRecPtr)); 2303} 2304 2305/* END OF FILE */ 2306