1/* $XdotOrg: driver/xf86-video-nsc/src/nsc_gx1_accel.c,v 1.5 2005/07/11 02:29:55 ajax Exp $ */
2/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx1_accel.c,v 1.7 2003/12/07 22:40:38 alanh Exp $ */
3/*
4 * $Workfile: nsc_gx1_accel.c $
5 * $Revision: 1.1.1.1 $
6 * $Author: mrg $
7 *
8 * File Contents: This file is consists of main Xfree
9 *                acceleration supported routines like solid fill used
10 *                here.
11 * Project:       Geode Xfree Frame buffer device driver.
12 *
13 *
14 */
15
16/*
17 * NSC_LIC_ALTERNATIVE_PREAMBLE
18 *
19 * Revision 1.0
20 *
21 * National Semiconductor Alternative GPL-BSD License
22 *
23 * National Semiconductor Corporation licenses this software
24 * ("Software"):
25 *
26 * National Xfree frame buffer driver
27 *
28 * under one of the two following licenses, depending on how the
29 * Software is received by the Licensee.
30 *
31 * If this Software is received as part of the Linux Framebuffer or
32 * other GPL licensed software, then the GPL license designated
33 * NSC_LIC_GPL applies to this Software; in all other circumstances
34 * then the BSD-style license designated NSC_LIC_BSD shall apply.
35 *
36 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
37
38/* NSC_LIC_BSD
39 *
40 * National Semiconductor Corporation Open Source License for
41 *
42 * National Xfree frame buffer driver
43 *
44 * (BSD License with Export Notice)
45 *
46 * Copyright (c) 1999-2001
47 * National Semiconductor Corporation.
48 * All rights reserved.
49 *
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 *
54 *   * Redistributions of source code must retain the above copyright
55 *     notice, this list of conditions and the following disclaimer.
56 *
57 *   * Redistributions in binary form must reproduce the above
58 *     copyright notice, this list of conditions and the following
59 *     disclaimer in the documentation and/or other materials provided
60 *     with the distribution.
61 *
62 *   * Neither the name of the National Semiconductor Corporation nor
63 *     the names of its contributors may be used to endorse or promote
64 *     products derived from this software without specific prior
65 *     written permission.
66 *
67 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
68 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
69 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
70 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
71 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
72 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
73 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
74 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
75 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
76 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
77 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
78 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
79 * OF SUCH DAMAGE.
80 *
81 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
82 * YOUR JURISDICTION. It is licensee's responsibility to comply with
83 * any export regulations applicable in licensee's jurisdiction. Under
84 * CURRENT (2001) U.S. export regulations this software
85 * is eligible for export from the U.S. and can be downloaded by or
86 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
87 * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
88 * Syria, Sudan, Afghanistan and any other country to which the U.S.
89 * has embargoed goods and services.
90 *
91 * END_NSC_LIC_BSD */
92
93/* NSC_LIC_GPL
94 *
95 * National Semiconductor Corporation Gnu General Public License for
96 *
97 * National Xfree frame buffer driver
98 *
99 * (GPL License with Export Notice)
100 *
101 * Copyright (c) 1999-2001
102 * National Semiconductor Corporation.
103 * All rights reserved.
104 *
105 * Redistribution and use in source and binary forms, with or without
106 * modification, are permitted under the terms of the GNU General
107 * Public License as published by the Free Software Foundation; either
108 * version 2 of the License, or (at your option) any later version
109 *
110 * In addition to the terms of the GNU General Public License, neither
111 * the name of the National Semiconductor Corporation nor the names of
112 * its contributors may be used to endorse or promote products derived
113 * from this software without specific prior written permission.
114 *
115 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
116 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
117 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
118 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
119 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
120 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
121 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
122 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
123 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
124 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
125 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
126 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
127 * OF SUCH DAMAGE. See the GNU General Public License for more details.
128 *
129 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
130 * YOUR JURISDICTION. It is licensee's responsibility to comply with
131 * any export regulations applicable in licensee's jurisdiction. Under
132 * CURRENT (2001) U.S. export regulations this software
133 * is eligible for export from the U.S. and can be downloaded by or
134 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
135 * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
136 * Syria, Sudan, Afghanistan and any other country to which the U.S.
137 * has embargoed goods and services.
138 *
139 * You should have received a copy of the GNU General Public License
140 * along with this file; if not, write to the Free Software Foundation,
141 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
142 *
143 * END_NSC_LIC_GPL */
144
145/*
146 * Fixes by
147 * Alan Hourihane <alanh@fairlite.demon.co.uk>
148 */
149
150#ifdef HAVE_CONFIG_H
151#include "config.h"
152#endif
153
154/* Xfree86 header files */
155#include "vgaHW.h"
156#include "xf86.h"
157#include "xaalocal.h"
158#include "xf86fbman.h"
159#include "miline.h"
160#include "xaarop.h"
161#include "nsc.h"
162
163#define SCR2SCREXP 0
164
165/* STATIC VARIABLES FOR THIS FILE
166 * Used to maintain state between setup and rendering calls.
167 */
168
169static int GeodeTransparent;
170static int GeodeTransColor;
171static int Geodedstx;
172static int Geodedsty;
173static int Geodesrcx;
174static int Geodesrcy;
175static int Geodewidth;
176static int Geodeheight;
177static int GeodeCounter;
178
179#if !defined(STB_X)
180static unsigned int GeodeROP = 0;
181static unsigned short Geode_blt_mode = 0;
182static unsigned short Geode_vector_mode = 0;
183static unsigned short Geode_buffer_width = 0;
184#endif
185static unsigned int gu1_bpp = 0;
186#if SCR2SCREXP
187static unsigned int gu1_xshift = 1;
188#endif
189static unsigned int gu1_yshift = 1;
190static unsigned short GeodebufferWidthPixels;
191static unsigned int ImgBufOffset;
192static unsigned short Geodebb0Base;
193static unsigned short Geodebb1Base;
194static XAAInfoRecPtr localRecPtr;
195
196#if SCR2SCREXP
197#define CALC_FBOFFSET(_SrcX, _SrcY) \
198	(((unsigned int) (_SrcY) << gu1_yshift) |\
199		(((unsigned int) (_SrcX)) << gu1_xshift))
200#endif
201
202#define GFX_WAIT_BUSY while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_BUSY) { ; }
203#define GFX_WAIT_PENDING while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING) { ; }
204
205#define BB0_BASE_3K		0x400
206#define BB1_BASE_3K		0x930
207
208Bool GX1AccelInit(ScreenPtr pScreen);
209void GX1AccelSync(ScrnInfoPtr pScreenInfo);
210void GX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop,
211			      unsigned int planemask);
212void GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y,
213				int w, int h);
214void GX1SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo,
215				      int patternx, int patterny,
216				      int rop, unsigned int planemask,
217				      int trans_color);
218void GX1Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo,
219					int patternx, int patterny, int x,
220					int y, int w, int h);
221void GX1SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx,
222				     int patterny, int fg, int bg, int rop,
223				     unsigned int planemask);
224void GX1Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx,
225				       int patterny, int x, int y, int w,
226				       int h);
227void GX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir,
228				   int ydir, int rop, unsigned int planemask,
229				   int transparency_color);
230void GX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, int y1,
231				     int x2, int y2, int w, int h);
232void GX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop,
233			  unsigned int planemask);
234void GX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
235			   unsigned int planemask, int length,
236			   unsigned char *pattern);
237void GX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1,
238				int absmaj, int absmin, int err, int len,
239				int octant);
240void GX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, int x0, int y0,
241				    int x1, int y1, int flags);
242void GX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, int len,
243			      int dir);
244
245void GX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo,
246				   int rop, unsigned int planemask,
247				   int transparency_color, int bpp,
248				   int depth);
249
250void GX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo,
251					 int x, int y, int w, int h,
252					 int skipleft);
253
254void GX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno);
255void GX1FillCacheBltRects(ScrnInfoPtr pScrn, int rop, unsigned int planemask,
256			  int nBox, BoxPtr pBox, int xorg, int yorg,
257			  XAACacheInfoPtr pCache);
258void OPTGX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop,
259				 unsigned int planemask);
260void OPTGX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y,
261				   int w, int h);
262void OPTGX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir,
263				      int ydir, int rop,
264				      unsigned int planemask,
265				      int transparency_color);
266void OPTGX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1,
267					int y1, int x2, int y2, int w, int h);
268void OPTGX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop,
269			     unsigned int planemask);
270void OPTGX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
271			      unsigned int planemask, int length,
272			      unsigned char *pattern);
273void OPTGX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1,
274				   int absmaj, int absmin, int err, int len,
275				   int octant);
276void OPTGX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo,
277				       int x0, int y0, int x1, int y1,
278				       int flags);
279#if 0 /* disabled due to bugs */
280void OPTGX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y,
281				 int len, int dir);
282
283#endif
284void OPTGX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo,
285				      int rop, unsigned int planemask,
286				      int transparency_color, int bpp,
287				      int depth);
288
289void OPTGX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo,
290					    int x, int y, int w, int h,
291					    int skipleft);
292
293void OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno);
294
295/*----------------------------------------------------------------------------
296 * GX1AccelSync.
297 *
298 * Description	:This function is called to syncronize with the graphics
299 *               engine and it waits the graphic engine is idle.This is
300 *               required before allowing   direct access to the
301 *               framebuffer.
302 * Parameters.
303 *   pScreenInfo:Screeen info pointer structure.
304 *
305 * Returns		:none
306 *
307 * Comments		:This function is called on geode_video routines.
308*----------------------------------------------------------------------------
309*/
310void
311GX1AccelSync(ScrnInfoPtr pScreenInfo)
312{
313   GFX(wait_until_idle());
314}
315
316/*----------------------------------------------------------------------------
317 * GX1SetupForFillRectSolid.
318 *
319 * Description	:This routine is called to setup the solid pattern
320 *               color for   future  rectangular fills or vectors.
321 *
322 * Parameters.
323 * pScreenInfo
324 *		Ptr		:Screen handler pointer having screen information.
325 *    color     :Specifies the color to be filled up in defined area.
326 *    rop       :Specifies the raster operation value.
327 *   planemask	:Specifies the masking value based rop srcdata.
328 *
329 * Returns		:none
330 *
331 * Comments		:none
332 *
333*----------------------------------------------------------------------------
334*/
335void
336GX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo,
337			 int color, int rop, unsigned int planemask)
338{
339   GFX(set_solid_pattern((unsigned long)color));
340
341   /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
342   if (planemask == 0xFFFFFFFF) {
343      /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
344      GFX(set_raster_operation(XAAGetPatternROP(rop)));
345   } else {
346      /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */
347      GFX(set_solid_source((unsigned long)planemask));
348      GFX(set_raster_operation(XAAGetPatternROP_PM(rop)));
349   }
350}
351
352 /*----------------------------------------------------------------------------
353 * GX1SubsequentFillRectSolid.
354 *
355 * Description	:This routine is used to fill the rectangle of previously
356 *               specified  solid pattern.
357 *
358 * Parameters.
359 *  pScreenInfo :Screen handler pointer having screen information.
360 *     x and y	:Specifies the x and y co-ordinatesarea.
361 *      w and h	:Specifies width and height respectively.
362 *
363 * Returns		:none
364 *
365 * Comments		:desired pattern can be set before this function by
366 *               gfx_set_solid_pattern.
367 * Sample application uses:
368 *   - Window backgrounds.
369 *   - x11perf: rectangle tests (-rect500).
370 *   - x11perf: fill trapezoid tests (-trap100).
371 *   - x11perf: horizontal line segments (-hseg500).
372 *----------------------------------------------------------------------------
373*/
374void
375GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w,
376			   int h)
377{
378   /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */
379   GeodePtr pGeode;
380
381   pGeode = GEODEPTR(pScreenInfo);
382
383   if (pGeode->TV_Overscan_On) {
384      x += pGeode->TVOx;
385      y += pGeode->TVOy;
386   }
387
388   GFX(pattern_fill((unsigned short)x, (unsigned short)y,
389		    (unsigned short)w, (unsigned short)h));
390}
391
392/*----------------------------------------------------------------------------
393 * GX1SetupFor8x8PatternColorExpand
394 *
395 * Description	:This routine is called to fill the color pattern of
396 *                 8x8.
397 * Parameters.
398 *		pScreenInfo :Screen handler pointer having screen information.
399 *		patternx	:This is set from on rop data.
400 *      patterny	:This is set based on rop data.
401 *		planemask	:Specifies the value of masking from rop data
402 *		trans_color :to be added.
403 * Returns		:none.
404 *
405 * Comments     :none.
406 *
407*----------------------------------------------------------------------------
408*/
409
410void
411GX1SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo,
412				 int patternx, int patterny,
413				 int rop, unsigned int planemask,
414				 int trans_color)
415{
416   /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
417   if (planemask == 0xFFFFFFFF) {
418      /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
419      GFX(set_raster_operation(XAAGetPatternROP(rop)));
420   } else {
421      /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */
422      GFX(set_solid_source((unsigned int)planemask));
423      GFX(set_raster_operation(XAAGetPatternROP_PM(rop)));
424   }
425}
426
427/*----------------------------------------------------------------------------
428 * GX1Subsequent8x8PatternColorExpand
429 *
430 * Description	:This routine is called to fill  a rectangle with the
431 *               color pattern of previously loaded pattern.
432 *
433 * Parameters.
434 *	pScreenInfo	:Screen handler pointer having screen information.
435 *  patternx	:This is set from on rop data.
436 *  patterny	:This is set based on rop data.
437 *      x		:x -coordinates of the destination rectangle
438 *      y       :y-co-ordinates of the destination rectangle
439 *      w	    :Specifies width of the rectangle
440 *      h       :Height of the window of the rectangle
441 *
442 * Returns		:none
443 *
444 * Comments		:The patterns specified is ignored inside the function
445 * Sample application uses:
446 *   - Patterned desktops
447 *   - x11perf: stippled rectangle tests (-srect500).
448 *   - x11perf: opaque stippled rectangle tests (-osrect500).
449*----------------------------------------------------------------------------
450*/
451void
452GX1Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo,
453				   int patternx, int patterny, int x, int y,
454				   int w, int h)
455{
456   GeodePtr pGeode = GEODEPTR(pScreenInfo);
457
458   DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h));
459   if (pGeode->TV_Overscan_On) {
460      x += pGeode->TVOx;
461      y += pGeode->TVOy;
462   }
463   /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */
464   /* Ignores specified pattern. */
465   GFX(color_pattern_fill((unsigned short)x, (unsigned short)y,
466			  (unsigned short)w, (unsigned short)h,
467			  ((unsigned long *)((pGeode->FBBase +
468					      (patterny << gu1_yshift)) +
469					     patternx))));
470}
471
472/*----------------------------------------------------------------------------
473 * GX1SetupFor8x8PatternMonoExpand
474 *
475 * Description	:This routine is called to fill the monochrome pattern of
476 *                 8x8.
477 * Parameters.
478 * 	pScreenInfo :Screen handler pointer having screen information.
479 *      patternx:This is set from on rop data.
480 *      patterny:This is set based on rop data.
481 *       fg		:Specifies the foreground color
482 *       bg     :Specifies the background color
483 *	planemask	:Specifies the value of masking from rop data
484 *
485 * Returns		:none.
486 *
487 * Comments     :none.
488 *
489*----------------------------------------------------------------------------
490*/
491void
492GX1SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo,
493				int patternx, int patterny, int fg,
494				int bg, int rop, unsigned int planemask)
495{
496   int trans = (bg == -1);
497
498   /* LOAD PATTERN COLORS AND DATA */
499   GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg,
500			(unsigned int)patternx, (unsigned int)patterny,
501			trans));
502
503   GFX(set_mono_source((unsigned int)bg, (unsigned int)fg, trans));
504
505   /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
506   if (planemask == 0xFFFFFFFF) {
507      /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
508      GFX(set_raster_operation(XAAGetPatternROP(rop)));
509   } else {
510      /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */
511      GFX(set_solid_source((unsigned int)planemask));
512      GFX(set_raster_operation(XAAGetPatternROP_PM(rop)));
513   }
514}
515
516/*----------------------------------------------------------------------------
517 * GX1Subsequent8x8PatternMonoExpand
518 *
519 * Description	:This routine is called to fill  a ractanglethe
520 *                 monochrome pattern of previusly loaded pattern.
521 *
522 * Parameters.
523 *	pScreenInfo	:Screen handler pointer having screen information.
524 *  patternx	:This is set from on rop data.
525 *  patterny	:This is set based on rop data.
526 *       fg		:Specifies the foreground color
527 *       bg		:Specifies the background color
528 *  planemask	:Specifies the value of masking from rop data
529
530 * Returns		:none
531 *
532 * Comments		:The patterns specified is ignored inside the function
533 * Sample application uses:
534 *   - Patterned desktops
535 *   - x11perf: stippled rectangle tests (-srect500).
536 *   - x11perf: opaque stippled rectangle tests (-osrect500).
537*----------------------------------------------------------------------------
538*/
539void
540GX1Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo,
541				  int patternx, int patterny, int x, int y,
542				  int w, int h)
543{
544   GeodePtr pGeode = GEODEPTR(pScreenInfo);
545
546   if (pGeode->TV_Overscan_On) {
547      x += pGeode->TVOx;
548      y += pGeode->TVOy;
549   }
550
551   /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */
552   /* Ignores specified pattern. */
553   GFX(pattern_fill((unsigned short)x, (unsigned short)y,
554		    (unsigned short)w, (unsigned short)h));
555}
556
557/*----------------------------------------------------------------------------
558 * GX1SetupForScreenToScreenCopy
559 *
560 * Description	:This function is used to set up the planemask and raster
561 *                 for future Bliting functionality.
562 *
563 * Parameters:
564 *	pScreenInfo :Screen handler pointer having screen information.
565 *      xdir	:This is set based on rop data.
566 *      ydir    :This is set based on rop data.
567 *      rop		:sets the raster operation
568 *	transparency:tobeadded
569 *  planemask	:Specifies the value of masking from rop data
570
571 * Returns		:none
572 *
573 * Comments		:The patterns specified is ignored inside the function
574*----------------------------------------------------------------------------
575*/
576void
577GX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
578			      int xdir, int ydir, int rop,
579			      unsigned int planemask, int transparency_color)
580{
581   GFX(set_solid_pattern(planemask));
582   /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */
583   GFX(set_raster_operation(XAAGetCopyROP(rop)));
584   /* SAVE TRANSPARENCY FLAG */
585   GeodeTransparent = (transparency_color == -1) ? 0 : 1;
586   GeodeTransColor = transparency_color;
587
588}
589
590/*----------------------------------------------------------------------------
591 * GX1SubsquentScreenToScreenCopy
592 *
593 * Description	:This function is called to perform a screen to screen
594 *                 BLT  using the previously  specified planemask,raster
595 *                 operation and  * transparency flag
596 *
597 * Parameters.
598 * 	pScreenInfo :Screen handler pointer having screen information.
599 *  	x1	 	:x -coordinates of the source window
600 *      y1      :y-co-ordinates of the source window
601 *      x2		:x -coordinates of the destination window
602 *      y2      :y-co-ordinates of the destination window
603 *      w	    :Specifies width of the window to be copied
604 *      h       :Height of the window to be copied.
605 * Returns		:none
606 *
607 * Comments		:The patterns specified is ignored inside the function
608 * Sample application uses (non-transparent):
609 *   - Moving windows.
610 *   - x11perf: scroll tests (-scroll500).
611 *   - x11perf: copy from window to window (-copywinwin500).
612 *
613 * No application found using transparency.
614*----------------------------------------------------------------------------
615*/
616
617void
618GX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
619				int x1, int y1, int x2, int y2, int w, int h)
620{
621   GeodePtr pGeode = GEODEPTR(pScreenInfo);
622
623   if (pGeode->TV_Overscan_On) {
624      if ((x1 < pScreenInfo->virtualX) && (y1 < pScreenInfo->virtualY)) {
625	 x1 += pGeode->TVOx;
626	 y1 += pGeode->TVOy;
627      }
628      x2 += pGeode->TVOx;
629      y2 += pGeode->TVOy;
630   }
631
632   if (GeodeTransparent) {
633      /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT
634       * * Should only be called for the "copy" raster operation.
635       */
636      GFX(screen_to_screen_xblt((unsigned short)x1, (unsigned short)y1,
637				(unsigned short)x2, (unsigned short)y2,
638				(unsigned short)w, (unsigned short)h,
639				GeodeTransColor));
640   } else {
641      /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */
642      GFX(screen_to_screen_blt((unsigned short)x1, (unsigned short)y1,
643			       (unsigned short)x2, (unsigned short)y2,
644			       (unsigned short)w, (unsigned short)h));
645   }
646}
647
648/*----------------------------------------------------------------------------
649 * GX1SetupForScanlineImageWrite
650 *
651 * Description	:This function is used to set up the planemask and raster
652 *               for future Bliting functionality.
653 *
654 * Parameters:
655 *		pScreenInfo			:Screen handler pointer having screen information.
656 *		rop					:sets the raster operation
657 *		transparency_color	:transparency color key.
658 *		planemask			:Specifies the value of masking from rop data
659 *      bpp					:bits per pixel of the source pixmap
660 *		depth				:depth of the source pixmap.
661 * Returns		:none
662 *
663 * Comments		:none
664 *  x11perf -putimage10
665 *  x11perf -putimage100
666 *  x11perf -putimage500
667*----------------------------------------------------------------------------
668*/
669
670void
671GX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo,
672			      int rop, unsigned int planemask,
673			      int transparency_color, int bpp, int depth)
674{
675   GFX(set_solid_pattern((unsigned int)planemask));
676   /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */
677   GFX(set_raster_operation(XAAGetCopyROP_PM(rop)));
678   /* SAVE TRANSPARENCY FLAG */
679   GeodeTransparent = (transparency_color == -1) ? 0 : 1;
680   GeodeTransColor = transparency_color;
681}
682
683/*----------------------------------------------------------------------------
684 * GX1SubsequentScanlineImageWriteRect
685 *
686 * Description	:This function is used to set up the x,y corordinates and width
687 *               &height for future Bliting functionality.
688 *
689 * Parameters:
690 *	pScreenInfo :Screen handler pointer having screen information.
691 *      x		:destination x
692 *	    y		:destination y
693 *		w		:Specifies the width of the rectangle to be  copied
694 *		h		:Specifies the height of the rectangle to be  copied
695 *
696 * Returns		:none
697 *
698 * Comments		:none
699*----------------------------------------------------------------------------
700*/
701void
702GX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo,
703				    int x, int y, int w, int h, int skipleft)
704{
705
706   Geodedstx = x;
707   Geodedsty = y;
708   Geodewidth = w;
709   Geodeheight = h;
710   GeodeCounter = 0;
711}
712
713/*----------------------------------------------------------------------------
714 * GX1SubsquentImageWriteScanline
715 *
716 * Description	:This function is called to
717 *               BLT  using the previously  specified planemask,raster
718 *               operation and   transparency flag
719 *
720 * Parameters.
721 * 	pScreenInfo :Screen handler pointer having screen information.
722 *
723 * Returns		:none
724 *
725 * Comments		:The patterns specified is ignored inside the function
726 * Sample application uses (non-transparent):
727 *   - Moving windows.
728 *   - x11perf: scroll tests (-scroll500).
729 *   - x11perf: copy from window to window (-copywinwin500).
730 *
731 * No application found using transparency.
732*----------------------------------------------------------------------------
733*/
734
735void
736GX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno)
737{
738   GeodePtr pGeode = GEODEPTR(pScreenInfo);
739   int blt_height = 0;
740   char blit = FALSE;
741
742   GeodeCounter++;
743
744   if ((Geodeheight <= pGeode->NoOfImgBuffers) &&
745       (GeodeCounter == Geodeheight)) {
746      blit = TRUE;
747      blt_height = Geodeheight;
748   } else if ((Geodeheight > pGeode->NoOfImgBuffers)
749	      && (GeodeCounter == pGeode->NoOfImgBuffers)) {
750      blit = TRUE;
751      Geodeheight -= pGeode->NoOfImgBuffers;
752      blt_height = pGeode->NoOfImgBuffers;
753   } else
754      return;
755
756   if (blit) {
757      blit = FALSE;
758
759      GeodeCounter = 0;
760
761      if (GeodeTransparent) {
762	 /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT
763	  * * Should only be called for the "copy" raster operation.
764	  */
765	 GFX(screen_to_screen_xblt((unsigned short)Geodesrcx,
766				   (unsigned short)Geodesrcy,
767				   (unsigned short)Geodedstx,
768				   (unsigned short)Geodedsty,
769				   (unsigned short)Geodewidth,
770				   (unsigned short)blt_height,
771				   GeodeTransColor));
772      } else {
773	 /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */
774	 GFX(screen_to_screen_blt((unsigned short)Geodesrcx,
775				  (unsigned short)Geodesrcy,
776				  (unsigned short)Geodedstx,
777				  (unsigned short)Geodedsty,
778				  (unsigned short)Geodewidth,
779				  (unsigned short)blt_height));
780      }
781      Geodedsty += blt_height;
782      GFX(wait_until_idle());
783   }
784}
785
786static unsigned short vector_mode_table[] = {
787   VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR,
788   VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR,
789   VM_MAJOR_INC | VM_X_MAJOR,
790   VM_MINOR_INC | VM_Y_MAJOR,
791   VM_MINOR_INC | VM_X_MAJOR,
792   VM_MAJOR_INC | VM_Y_MAJOR,
793   VM_X_MAJOR,
794   VM_Y_MAJOR,
795};
796
797/*----------------------------------------------------------------------------
798 * GX1SetupForSolidLine
799 *
800 * Description	:This function is used setup the solid line color for
801 *               future line draws.
802 *
803 *
804 * Parameters.
805 * 	pScreenInfo :Screen handler pointer having screen information.
806 *      color	:Specifies the color value od line
807 *      rop     :Specifies rop values.
808 *  Planemask	:Specifies planemask value.
809 * Returns		:none
810 *
811 * Comments		:none
812*----------------------------------------------------------------------------
813*/
814void
815GX1SetupForSolidLine(ScrnInfoPtr pScreenInfo,
816		     int color, int rop, unsigned int planemask)
817{
818   /* LOAD THE SOLID PATTERN COLOR */
819   GFX(set_solid_pattern((unsigned int)color));
820
821   /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
822   GFX(set_raster_operation(XAAGetPatternROP(rop)));
823}
824
825/*---------------------------------------------------------------------------
826 * GX1SubsequentBresenhamLine
827 *
828 * Description	:This function is used to render a vector using the
829 *                 specified bresenham parameters.
830 *
831 * Parameters:
832 * pScreenInfo 	:Screen handler pointer having screen information.
833 *      x1  	:Specifies the starting x position
834 *      y1      :Specifies starting y possition
835 *      absmaj	:Specfies the Bresenman absolute major.
836 *	  absmin	:Specfies the Bresenman absolute minor.
837 *	  err       :Specifies the bresenham err term.
838 *	  len       :Specifies the length of the vector interms of pixels.
839 *	  octant    :not used in this function,may be added for standard
840 *                    interface.
841 * Returns		:none
842 *
843 * Comments     :none
844 * Sample application uses:
845 *   - Window outlines on window move.
846 *   - x11perf: line segments (-line500).
847 *   - x11perf: line segments (-seg500).
848*----------------------------------------------------------------------------
849*/
850void
851GX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo,
852			   int x1, int y1, int absmaj, int absmin, int err,
853			   int len, int octant)
854{
855   int axial, init, diag;
856
857   DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n",
858		x1, y1, absmaj, absmin, err, len, octant));
859
860   /* DETERMINE BRESENHAM PARAMETERS */
861
862   axial = ((int)absmin << 1);
863   init = axial - (int)absmaj;
864   diag = init - (int)absmaj;
865
866   /* ADJUST INITIAL ERROR
867    * * Adjust by -1 for certain directions so that the vector
868    * * hits the same pixels when drawn in either direction.
869    * * The Gamma value is assumed to account for the initial
870    * * error adjustment for clipped lines.
871    */
872
873   init += err;
874
875   /* CALL ROUTINE TO DRAW VECTOR */
876
877   GFX(bresenham_line((unsigned short)x1,
878		      (unsigned short)y1,
879		      (unsigned short)len,
880		      (unsigned short)init,
881		      (unsigned short)axial,
882		      (unsigned short)diag,
883		      (unsigned short)vector_mode_table[octant]));
884
885}
886
887#define ABS(_val1, _val2) (((_val1) > (_val2)) ? ((_val1)-(_val2)) : ((_val2) - (_val1)))
888
889void
890GX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo,
891			       int x0, int y0, int x1, int y1, int flags)
892{
893   long dx, dy, dmaj, dmin;
894   long axialerr, diagerr, initerr;
895   unsigned short vec_flags = 0;
896
897   dx = ABS(x1, x0);
898   dy = ABS(y1, y0);
899   if (dx >= dy) {
900      dmaj = dx;
901      dmin = dy;
902      vec_flags = VM_X_MAJOR;
903      if (x1 > x0)
904	 vec_flags |= VM_MAJOR_INC;
905      if (y1 > y0)
906	 vec_flags |= VM_MINOR_INC;
907   } else {
908      dmaj = dy;
909      dmin = dx;
910      vec_flags = VM_Y_MAJOR;
911      if (x1 > x0)
912	 vec_flags |= VM_MINOR_INC;
913      if (y1 > y0)
914	 vec_flags |= VM_MAJOR_INC;
915   }
916   axialerr = dmin << 1;
917   diagerr = (dmin - dmaj) << 1;
918   initerr = (dmin << 1) - dmaj;
919   if (!(vec_flags & VM_MINOR_INC))
920      initerr--;
921
922   GFX(bresenham_line((unsigned short)x0,
923		      (unsigned short)y0,
924		      (unsigned short)dmaj,
925		      (unsigned short)initerr,
926		      (unsigned short)axialerr,
927		      (unsigned short)diagerr, vec_flags));
928}
929
930/*---------------------------------------------------------------------------
931 * GX1SubsequentHorVertLine
932 *
933 * This routine is called to render a vector using the specified Bresenham
934 * parameters.
935 *
936 * Sample application uses:
937 *   - Window outlines on window move.
938 *   - x11perf: line segments (-hseg500).
939 *   - x11perf: line segments (-vseg500).
940 *---------------------------------------------------------------------------
941 */
942void
943GX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo,
944			 int x, int y, int len, int dir)
945{
946   GeodePtr pGeode = GEODEPTR(pScreenInfo);
947
948   if (pGeode->TV_Overscan_On) {
949      x += pGeode->TVOx;
950      y += pGeode->TVOy;
951   }
952   GFX(pattern_fill((unsigned short)x, (unsigned short)y,
953		    (unsigned short)((dir == DEGREES_0) ? len : 1),
954		    (unsigned short)((dir == DEGREES_0) ? 1 : len)));
955}
956
957void
958GX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
959		      unsigned int planemask, int length,
960		      unsigned char *pattern)
961{
962   int trans = (bg == -1);
963   unsigned long *pat = (unsigned long *)pattern;
964
965   /* LOAD PATTERN COLORS AND DATA */
966
967   GFX(set_mono_pattern((unsigned long)bg, (unsigned long)fg,
968			(unsigned long)pat, (unsigned long)pat,
969			(unsigned char)trans));
970
971   /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
972
973   if (planemask == (unsigned int)-1) {
974      /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
975
976      GFX(set_raster_operation(XAAGetPatternROP(rop)));
977   } else {
978      /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */
979
980      GFX(set_solid_source((unsigned long)planemask));
981      GFX(set_raster_operation(XAAGetPatternROP_PM(rop)));
982   }
983}
984
985#if SCR2SCREXP
986void
987GX1SetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
988					 int fg, int bg, int rop,
989					 unsigned int planemask)
990{
991   GFX(set_solid_pattern(planemask));
992   GFX(set_mono_source(bg, fg, (bg == -1)));
993
994   /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */
995   GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F)));
996
997   DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask));
998}
999
1000void
1001GX1SubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
1002					   int x, int y, int w, int h,
1003					   int srcx, int srcy, int offset)
1004{
1005   GeodePtr pGeode = GEODEPTR(pScrn);
1006
1007   GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h,
1008				 (unsigned char *)(pGeode->FBBase +
1009						   CALC_FBOFFSET(srcx, srcy)),
1010				 pGeode->Pitch));
1011}
1012#endif
1013
1014#if !defined(STB_X)
1015/*----------------------------------------------------------------------------
1016 * OPTGX1SetupForFillRectSolid.
1017 *
1018 * Description	:This routine is called to setup the solid pattern
1019 *               color for   future  rectangular fills or vectors.
1020 *				 (non durango version)
1021 *
1022 * Parameters.
1023 * pScreenInfo
1024 *		Ptr		:Screen handler pointer having screen information.
1025 *    color     :Specifies the color to be filled up in defined area.
1026 *    rop       :Specifies the raster operation value.
1027 *   planemask	:Specifies the masking value based rop srcdata.
1028 *
1029 * Returns		:none
1030 *
1031 * Comments		:none
1032 *
1033*----------------------------------------------------------------------------
1034*/
1035void
1036OPTGX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo,
1037			    int color, int rop, unsigned int planemask)
1038{
1039   unsigned short rop16;
1040
1041   if (gu1_bpp == 8) {
1042      color &= 0x00FF;
1043      color |= (color << 8);
1044   }
1045
1046   /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
1047
1048   if (planemask == 0xFFFFFFFF) {
1049      if (gu1_bpp == 8) {
1050	 planemask &= 0x00FF;
1051	 planemask |= (planemask << 8);
1052      }
1053
1054      rop16 = XAAGetPatternROP(rop);
1055
1056      /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */
1057
1058      GFX_WAIT_PENDING;
1059      WRITE_REG32(GP_SRC_COLOR_0, (planemask << 16) | planemask);
1060   } else {
1061      rop16 = XAAGetPatternROP_PM(rop);
1062   }
1063
1064   Geode_blt_mode = 0;
1065
1066   /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
1067   /* Only one operation can be pending at a time. */
1068
1069   GFX_WAIT_PENDING;
1070   WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color);
1071   WRITE_REG16(GP_RASTER_MODE, rop16);
1072}
1073
1074 /*----------------------------------------------------------------------------
1075 * OPTGX1SubsequentFillRectSolid.
1076 *
1077 * Description	:This routine is used to fill the rectangle of previously
1078 *               specified  solid pattern.
1079 *				 (non durango version)
1080 *
1081 * Parameters.
1082 *  pScreenInfo :Screen handler pointer having screen information.
1083 *     x and y	:Specifies the x and y co-ordinatesarea.
1084 *      w and h	:Specifies width and height respectively.
1085 *
1086 * Returns		:none
1087 *
1088 * Comments		:desired pattern can be set before this function by
1089 *               gfx_set_solid_pattern.
1090 * Sample application uses:
1091 *   - Window backgrounds.
1092 *   - x11perf: rectangle tests (-rect500).
1093 *   - x11perf: fill trapezoid tests (-trap100).
1094 *   - x11perf: horizontal line segments (-hseg500).
1095 *----------------------------------------------------------------------------
1096*/
1097void
1098OPTGX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo,
1099			      int x, int y, int width, int height)
1100{
1101   unsigned short section;
1102   GeodePtr pGeode = GEODEPTR(pScreenInfo);
1103
1104   if (pGeode->TV_Overscan_On) {
1105      x += pGeode->TVOx;
1106      y += pGeode->TVOy;
1107   }
1108
1109   /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
1110   /* Only one operation can be pending at a time. */
1111
1112   GFX_WAIT_PENDING;
1113
1114   /* SET REGISTERS TO DRAW RECTANGLE */
1115   WRITE_REG32(GP_DST_XCOOR, (y << 16) | x);
1116
1117   WRITE_REG16(GP_HEIGHT, height);
1118
1119   /* CHECK WIDTH FOR GX BUG WORKAROUND */
1120
1121   if (width <= 16) {
1122      /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */
1123
1124      WRITE_REG16(GP_WIDTH, width);
1125      WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode);
1126   } else {
1127      /* DRAW FIRST PART OF RECTANGLE */
1128      /* Get to a 16 pixel boundary. */
1129
1130      section = 0x10 - (x & 0x0F);
1131      WRITE_REG16(GP_WIDTH, section);
1132      WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode);
1133
1134      /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */
1135
1136      GFX_WAIT_PENDING;
1137
1138      WRITE_REG32(GP_DST_XCOOR, (y << 16) | (x + section));
1139      WRITE_REG16(GP_WIDTH, width - section);
1140      WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode);
1141   }
1142}
1143
1144/*----------------------------------------------------------------------------
1145 * OPTGX1SetupForScreenToScreenCopy
1146 *
1147 * Description	:This function is used to set up the planemask and raster
1148 *                 for future Bliting functionality.
1149 *				 (non durango version)
1150 *
1151 * Parameters:
1152 *	pScreenInfo :Screen handler pointer having screen information.
1153 *      xdir	:This is set based on rop data.
1154 *      ydir    :This is set based on rop data.
1155 *      rop		:sets the raster operation
1156 *	transparency:tobeadded
1157 *  planemask	:Specifies the value of masking from rop data
1158
1159 * Returns		:none
1160 *
1161 * Comments		:The patterns specified is ignored inside the function
1162*----------------------------------------------------------------------------
1163*/
1164void
1165OPTGX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
1166				 int xdir, int ydir, int rop,
1167				 unsigned int planemask,
1168				 int transparency_color)
1169{
1170   int GFXusesDstData;
1171   unsigned short rop16 = XAAGetCopyROP(rop);
1172
1173   /* FORMAT 8 BPP COLOR */
1174   /* GX requires 8BPP color data be duplicated into bits [15:8]. */
1175
1176   if (gu1_bpp == 8) {
1177      planemask &= 0x00FF;
1178      planemask |= (planemask << 8);
1179   }
1180
1181   /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */
1182   /* True if even bits (0:2:4:6) do not equal the correspinding */
1183   /* even bits (1:3:5:7). */
1184
1185   GFXusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55));
1186
1187   Geode_blt_mode = GFXusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB :
1188	 BM_READ_SRC_FB;
1189
1190   /* CHECK AVAILABLE BLT BUFFER SIZE */
1191   /* Can use both BLT buffers if no destination data is required. */
1192
1193   Geode_buffer_width = GFXusesDstData ? GeodebufferWidthPixels :
1194	 GeodebufferWidthPixels << 1;
1195
1196   /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
1197   /* Only one operation can be pending at a time. */
1198
1199   GFX_WAIT_PENDING;
1200
1201   WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)planemask);
1202   WRITE_REG16(GP_RASTER_MODE, rop16);
1203
1204   GeodeTransparent = (transparency_color == -1) ? 0 : 1;
1205   GeodeTransColor = transparency_color;
1206}
1207
1208/*----------------------------------------------------------------------------
1209 * OPTGX1SubsquentScreenToScreenCopy
1210 *
1211 * Description	:This function is called to perform a screen to screen
1212 *                 BLT  using the previously  specified planemask,raster
1213 *                 operation and  * transparency flag
1214 *				 (non durango version)
1215 *
1216 * Parameters.
1217 * 	pScreenInfo :Screen handler pointer having screen information.
1218 *  	srcx	:x -coordinates of the source window
1219 *      srcy    :y-co-ordinates of the source window
1220 *      dstx	:x -coordinates of the destination window
1221 *      dsty    :y-co-ordinates of the destination window
1222 *      width	:Specifies width of the window to be copied
1223 *      height  :Height of the window to be copied.
1224 * Returns		:none
1225 *
1226 * Comments		:The patterns specified is ignored inside the function
1227 * Sample application uses (non-transparent):
1228 *   - Moving windows.
1229 *   - x11perf: scroll tests (-scroll500).
1230 *   - x11perf: copy from window to window (-copywinwin500).
1231 *
1232 * No application found using transparency.
1233*----------------------------------------------------------------------------
1234*/
1235void
1236OPTGX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
1237				   int srcx, int srcy, int dstx, int dsty,
1238				   int width, int height)
1239{
1240   unsigned short section;
1241   unsigned short blit_mode = 0;
1242   GeodePtr pGeode = GEODEPTR(pScreenInfo);
1243
1244   if (pGeode->TV_Overscan_On) {
1245      if ((srcx < pScreenInfo->virtualX) && (srcy < pScreenInfo->virtualY)) {
1246	 srcx += pGeode->TVOx;
1247	 srcy += pGeode->TVOy;
1248      }
1249      dstx += pGeode->TVOx;
1250      dsty += pGeode->TVOy;
1251   }
1252   if (GeodeTransparent) {
1253      if (gu1_bpp == 8) {
1254	 GeodeTransColor &= 0x00FF;
1255	 GeodeTransColor |= (GeodeTransColor << 8);
1256      }
1257      GeodeTransColor =
1258	    (GeodeTransColor & 0x0000FFFF) | (GeodeTransColor << 16);
1259
1260      /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */
1261      /* Need to make sure any previous BLT using BB1 is complete. */
1262      /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */
1263
1264      GFX_WAIT_BUSY;
1265      WRITE_SCRATCH32(Geodebb1Base, GeodeTransColor);
1266
1267      /* DO BOGUS BLT TO LATCH DATA FROM BB1 */
1268      /* Already know graphics pipeline is idle. */
1269      /* Only need to latch data into the holding registers for the current */
1270      /* data from BB1.  A 1 pixel wide BLT will suffice. */
1271
1272      WRITE_REG32(GP_DST_XCOOR, 0);
1273      WRITE_REG32(GP_SRC_XCOOR, 0);
1274      WRITE_REG32(GP_WIDTH, 0x00010001);
1275      WRITE_REG16(GP_RASTER_MODE, 0x00CC);
1276      WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1);
1277
1278      /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */
1279
1280      GFX_WAIT_PENDING;
1281      WRITE_REG16(GP_HEIGHT, height);
1282      WRITE_REG16(GP_RASTER_MODE, 0x10C6);
1283      WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF);
1284
1285   }
1286
1287   /* CHECK Y DIRECTION */
1288   /* Hardware has support for negative Y direction. */
1289
1290   if (dsty > srcy) {
1291      blit_mode = BM_REVERSE_Y;
1292      srcy += height - 1;
1293      dsty += height - 1;
1294   }
1295
1296   /* CHECK X DIRECTION */
1297   /* Hardware does not support negative X direction since at the time */
1298   /* of development all supported resolutions could fit a scanline of */
1299   /* data at once into the BLT buffers (using both BB0 and BB1).  This */
1300   /* code is more generic to allow for any size BLT buffer. */
1301
1302   if (dstx > srcx) {
1303      srcx += width;
1304      dstx += width;
1305   }
1306
1307   /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
1308   /* Write the registers that do not change for each section. */
1309
1310   GFX_WAIT_PENDING;
1311   WRITE_REG16(GP_HEIGHT, height);
1312
1313   /* REPEAT UNTIL FINISHED WITH RECTANGLE */
1314   /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */
1315   /* Hardware does not split the operations, so software must do it to */
1316   /* avoid large scanlines that would overflow the BLT buffers. */
1317
1318   while (width > 0) {
1319      /* CHECK WIDTH OF CURRENT SECTION */
1320
1321      if (width > Geode_buffer_width)
1322	 section = Geode_buffer_width;
1323      else
1324	 section = width;
1325
1326      /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */
1327
1328      GFX_WAIT_PENDING;
1329      WRITE_REG16(GP_SRC_YCOOR, srcy);
1330      WRITE_REG16(GP_DST_YCOOR, dsty);
1331      WRITE_REG16(GP_WIDTH, section);
1332
1333      /* CHECK X DIRECTION */
1334
1335      if (dstx > srcx) {
1336	 /* NEGATIVE X DIRECTION */
1337	 /* Still positive X direction within the section. */
1338
1339	 srcx -= section;
1340	 dstx -= section;
1341	 WRITE_REG16(GP_SRC_XCOOR, srcx);
1342	 WRITE_REG16(GP_DST_XCOOR, dstx);
1343      } else {
1344	 /* POSITIVE X DIRECTION */
1345
1346	 WRITE_REG16(GP_SRC_XCOOR, srcx);
1347	 WRITE_REG16(GP_DST_XCOOR, dstx);
1348	 dstx += section;
1349	 srcx += section;
1350      }
1351      WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode | blit_mode);
1352      width -= section;
1353   }
1354}
1355
1356/*----------------------------------------------------------------------------
1357 * OPTGX1SetupForScanlineImageWrite
1358 *
1359 * Description	:This function is used to set up the planemask and raster
1360 *               for future Bliting functionality.(non durango version)
1361 *
1362 * Parameters:
1363 *		pScreenInfo			:Screen handler pointer having screen information.
1364 *      rop					:sets the raster operation
1365 *		transparency_color	:tobeadded
1366 *		planemask			:Specifies the value of masking from rop data
1367 *      bpp					:bits per pixel of the source pixmap
1368 *		depth				:depth of the source pixmap.
1369 * Returns		:none
1370 *
1371 * Comments		:none
1372*----------------------------------------------------------------------------
1373*/
1374void
1375OPTGX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo,
1376				 int rop, unsigned int planemask,
1377				 int transparency_color, int bpp, int depth)
1378{
1379   OPTGX1SetupForScreenToScreenCopy(pScreenInfo,
1380				    0, 0, rop, planemask, transparency_color);
1381}
1382
1383/*----------------------------------------------------------------------------
1384 * OPTGX1SubsequentScanlineImageWriteRect
1385 *
1386 * Description	:This function is used to set up the x,y corordinates and width
1387 *                &height for future Bliting functionality.(non durango version)
1388 *
1389 * Parameters:
1390 *	pScreenInfo :Screen handler pointer having screen information.
1391 *      x		:destination x
1392 *	    y		:destination y
1393 *		w		:Specifies the width of the rectangle to be  copied
1394 *		h		:Specifies the height of the rectangle to be  copied
1395 * Returns		:none
1396 *
1397 * Comments		:none
1398 *----------------------------------------------------------------------------
1399*/
1400void
1401OPTGX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo,
1402				       int x, int y, int w, int h,
1403				       int skipleft)
1404{
1405
1406   Geodedstx = x;
1407   Geodedsty = y;
1408   Geodewidth = w;
1409   Geodeheight = h;
1410   GeodeCounter = 0;
1411}
1412
1413/*----------------------------------------------------------------------------
1414 * OPTGX1SubsquentImageWriteScanline
1415 *
1416 * Description	:This function is called to
1417 *               BLT  using the previously  specified planemask,raster
1418 *               operation and transparency flag(non durango version)
1419 *
1420 * Parameters.
1421 * 	pScreenInfo :Screen handler pointer having screen information.
1422 *
1423 * Returns		:none
1424 *
1425 * Comments		:The patterns specified is ignored inside the function
1426 * Sample application uses (non-transparent):
1427 *   - Moving windows.
1428 *   - x11perf: scroll tests (-scroll500).
1429 *   - x11perf: copy from window to window (-copywinwin500).
1430 *
1431 * No application found using transparency.
1432*----------------------------------------------------------------------------
1433*/
1434
1435void
1436OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno)
1437{
1438   GeodePtr pGeode = GEODEPTR(pScreenInfo);
1439   int blt_height = 0;
1440   char blit = FALSE;
1441
1442   GeodeCounter++;
1443
1444   if ((Geodeheight <= pGeode->NoOfImgBuffers) &&
1445       (GeodeCounter == Geodeheight)) {
1446      blit = TRUE;
1447      blt_height = Geodeheight;
1448   } else if ((Geodeheight > pGeode->NoOfImgBuffers)
1449	      && (GeodeCounter == pGeode->NoOfImgBuffers)) {
1450      blit = TRUE;
1451      Geodeheight -= pGeode->NoOfImgBuffers;
1452      blt_height = pGeode->NoOfImgBuffers;
1453   } else
1454      return;
1455
1456   if (blit) {
1457      blit = FALSE;
1458      GeodeCounter = 0;
1459      OPTGX1SubsequentScreenToScreenCopy(pScreenInfo,
1460					 Geodesrcx, Geodesrcy, Geodedstx,
1461					 Geodedsty, Geodewidth, blt_height);
1462      Geodedsty += blt_height;
1463      GFX_WAIT_BUSY;
1464   }
1465}
1466
1467/*----------------------------------------------------------------------------
1468 * OPTGX1SetupForSolidLine
1469 *
1470 * Description	:This function is used setup the solid line color for
1471 *               future line draws.
1472 *
1473 *
1474 * Parameters.
1475 * 	pScreenInfo :Screen handler pointer having screen information.
1476 *      color	:Specifies the color value od line
1477 *      rop     :Specifies rop values.
1478 *  Planemask	:Specifies planemask value.
1479 * Returns		:none
1480 *
1481 * Comments		:none
1482*----------------------------------------------------------------------------
1483*/
1484void
1485OPTGX1SetupForSolidLine(ScrnInfoPtr pScreenInfo,
1486			int color, int rop, unsigned int planemask)
1487{
1488   if (gu1_bpp == 8) {
1489      color &= 0x00FF;
1490      color |= (color << 8);
1491   }
1492
1493   GeodeROP = XAAGetPatternROP(rop);
1494
1495   /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
1496   GFX_WAIT_PENDING;
1497   WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color);
1498   WRITE_REG16(GP_RASTER_MODE, GeodeROP);
1499
1500   if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) {
1501      Geode_vector_mode = VM_READ_DST_FB;
1502      Geode_blt_mode = BM_READ_DST_FB1 | BM_READ_SRC_FB;
1503   } else {
1504      Geode_vector_mode = 0;
1505      Geode_blt_mode = BM_READ_SRC_FB;
1506   }
1507}
1508
1509/*---------------------------------------------------------------------------
1510 * OPTGX1SubsequentBresenhamLine
1511 *
1512 * Description	:This function is used to render a vector using the
1513 *                 specified bresenham parameters.
1514 *
1515 * Parameters:
1516 * pScreenInfo 	:Screen handler pointer having screen information.
1517 *      x1  	:Specifies the starting x position
1518 *      y1      :Specifies starting y possition
1519 *      absmaj	:Specfies the Bresenman absolute major.
1520 *	  absmin	:Specfies the Bresenman absolute minor.
1521 *	  err       :Specifies the bresenham err term.
1522 *	  len       :Specifies the length of the vector interms of pixels.
1523 *	  octant    :not used in this function,may be added for standard
1524 *                    interface.
1525 * Returns		:none
1526 *
1527 * Comments     :none
1528 * Sample application uses:
1529 *   - Window outlines on window move.
1530 *   - x11perf: line segments (-seg500).
1531*----------------------------------------------------------------------------
1532*/
1533void
1534OPTGX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo,
1535			      int x1, int y1, int absmaj, int absmin, int err,
1536			      int len, int octant)
1537{
1538   int axial, init, diag;
1539
1540   DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n",
1541		x1, y1, absmaj, absmin, err, len, octant));
1542
1543   /* DETERMINE BRESENHAM PARAMETERS */
1544
1545   axial = ((int)absmin << 1);
1546   init = axial - (int)absmaj;
1547   diag = init - (int)absmaj;
1548
1549   /* ADJUST INITIAL ERROR
1550    * * Adjust by -1 for certain directions so that the vector
1551    * * hits the same pixels when drawn in either direction.
1552    * * The Gamma value is assumed to account for the initial
1553    * * error adjustment for clipped lines.
1554    */
1555
1556   init += err;
1557
1558   /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
1559   /* Put off poll for as long as possible (do most calculations first). */
1560
1561   GFX_WAIT_PENDING;
1562   WRITE_REG32(GP_DST_XCOOR, (y1 << 16) | x1);
1563   WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long)init) << 16) |
1564	       ((unsigned short)len));
1565   WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long)diag) << 16) |
1566	       ((unsigned short)axial));
1567   WRITE_REG16(GP_VECTOR_MODE,
1568	       (Geode_vector_mode | vector_mode_table[octant]));
1569}
1570
1571void
1572OPTGX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo,
1573				  int x0, int y0, int x1, int y1, int flags)
1574{
1575   long dx, dy, dmaj, dmin;
1576   long axialerr, diagerr, initerr;
1577   unsigned short vec_flags = 0;
1578
1579   dx = ABS(x1, x0);
1580   dy = ABS(y1, y0);
1581   if (dx >= dy) {
1582      dmaj = dx;
1583      dmin = dy;
1584      vec_flags = VM_X_MAJOR;
1585      if (x1 > x0)
1586	 vec_flags |= VM_MAJOR_INC;
1587      if (y1 > y0)
1588	 vec_flags |= VM_MINOR_INC;
1589   } else {
1590      dmaj = dy;
1591      dmin = dx;
1592      vec_flags = VM_Y_MAJOR;
1593      if (x1 > x0)
1594	 vec_flags |= VM_MINOR_INC;
1595      if (y1 > y0)
1596	 vec_flags |= VM_MAJOR_INC;
1597   }
1598
1599   axialerr = dmin << 1;
1600   diagerr = (dmin - dmaj) << 1;
1601   initerr = (axialerr - dmaj);
1602
1603   if (!(vec_flags & VM_MINOR_INC))
1604      initerr--;
1605
1606   GFX_WAIT_PENDING;
1607   WRITE_REG32(GP_DST_XCOOR, (y0 << 16) | x0);
1608   WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long)initerr) << 16) |
1609	       ((unsigned short)dmaj));
1610   WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long)diagerr) << 16) |
1611	       ((unsigned short)axialerr));
1612   WRITE_REG16(GP_VECTOR_MODE, (Geode_vector_mode | vec_flags));
1613}
1614
1615#if 0 /* disabled due to bugs - can't fallback to fillrectsolid */
1616/*---------------------------------------------------------------------------
1617 * OPTGX1SubsequentHorVertLine
1618 *
1619 * This routine is called to render a vector using the specified Bresenham
1620 * parameters.
1621 *
1622 * Sample application uses:
1623 *   - Window outlines on window move.
1624 *   - x11perf: line segments (-hseg500).
1625 *   - x11perf: line segments (-vseg500).
1626 *---------------------------------------------------------------------------
1627 */
1628void
1629OPTGX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo,
1630			    int x, int y, int len, int dir)
1631{
1632
1633   DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir));
1634
1635   OPTGX1SubsequentFillRectSolid(pScreenInfo,
1636				 (unsigned short)x, (unsigned short)y,
1637				 (unsigned short)((dir == DEGREES_0) ? len :
1638						  1),
1639				 (unsigned short)((dir == DEGREES_0) ? 1 :
1640						  len));
1641}
1642#endif
1643#endif
1644
1645/*----------------------------------------------------------------------------
1646 * GX1AccelInit.
1647 *
1648 * Description	:This function sets up the supported acceleration routines and
1649 *                 appropriate flags.
1650 *
1651 * Parameters:
1652 *      pScreen	:Screeen pointer structure.
1653 *
1654 * Returns		:TRUE on success and FALSE on Failure
1655 *
1656 * Comments		:This function is called in GX1ScreenInit in
1657                     geode_driver.c to set  * the acceleration.
1658*----------------------------------------------------------------------------
1659*/
1660Bool
1661GX1AccelInit(ScreenPtr pScreen)
1662{
1663   GeodePtr pGeode;
1664   ScrnInfoPtr pScreenInfo;
1665
1666   pScreenInfo = xf86Screens[pScreen->myNum];
1667   pGeode = GEODEPTR(pScreenInfo);
1668
1669   switch (pScreenInfo->bitsPerPixel) {
1670   case 8:
1671      gu1_bpp = 8;
1672      break;
1673   case 16:
1674      gu1_bpp = 16;
1675      break;
1676   }
1677
1678#if SCR2SCREXP
1679   gu1_xshift = pScreenInfo->bitsPerPixel >> 4;
1680#endif
1681
1682   switch (pGeode->Pitch) {
1683   case 1024:
1684      gu1_yshift = 10;
1685      break;
1686   case 2048:
1687      gu1_yshift = 11;
1688      break;
1689   case 4096:
1690      gu1_yshift = 12;
1691      break;
1692   }
1693
1694   Geodebb0Base = BB0_BASE_3K;
1695   Geodebb1Base = BB1_BASE_3K;
1696   GeodebufferWidthPixels = Geodebb1Base - Geodebb0Base - 16;
1697
1698   if (gu1_bpp > 8) {
1699      /* If 16bpp, divide GFXbufferWidthPixels by 2 */
1700      GeodebufferWidthPixels >>= 1;
1701   }
1702   /* Getting the pointer for acceleration Inforecord */
1703   pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec();
1704
1705   /* SET ACCELERATION FLAGS */
1706   localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER;
1707   localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES;
1708
1709   /* HOOK SYNCRONIZARION ROUTINE */
1710   localRecPtr->Sync = GX1AccelSync;
1711
1712   /* HOOK FILLED RECTANGLES */
1713   localRecPtr->SetupForSolidFill = (GX1SetupForFillRectSolid);
1714   localRecPtr->SubsequentSolidFillRect = (GX1SubsequentFillRectSolid);
1715   localRecPtr->SolidFillFlags = 0;
1716
1717   /* HOOK 8x8 MonoEXPAND PATTERNS */
1718   localRecPtr->SetupForMono8x8PatternFill = GX1SetupFor8x8PatternMonoExpand;
1719   localRecPtr->SubsequentMono8x8PatternFillRect =
1720	 GX1Subsequent8x8PatternMonoExpand;
1721   localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST |
1722	 HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN;
1723
1724   localRecPtr->SetupForColor8x8PatternFill =
1725	 GX1SetupFor8x8PatternColorExpand;
1726   localRecPtr->SubsequentColor8x8PatternFillRect =
1727	 GX1Subsequent8x8PatternColorExpand;
1728   /* Color expansion */
1729   localRecPtr->Color8x8PatternFillFlags =
1730	 BIT_ORDER_IN_BYTE_MSBFIRST |
1731	 SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN;
1732
1733   /* HOOK SCREEN TO SCREEN COPIES
1734    * * Set flag to only allow copy if transparency is enabled.
1735    */
1736   localRecPtr->SetupForScreenToScreenCopy =
1737	 OPTACCEL(GX1SetupForScreenToScreenCopy);
1738   localRecPtr->SubsequentScreenToScreenCopy =
1739	 OPTACCEL(GX1SubsequentScreenToScreenCopy);
1740   localRecPtr->ScreenToScreenCopyFlags = 0;
1741
1742   /* HOOK BRESENHAM SOLID LINES */
1743   /* Do not hook unless flag can be set preventing use of planemask. */
1744   localRecPtr->SolidLineFlags = NO_PLANEMASK;
1745   localRecPtr->SetupForSolidLine = OPTACCEL(GX1SetupForSolidLine);
1746   localRecPtr->SubsequentSolidBresenhamLine =
1747	 OPTACCEL(GX1SubsequentBresenhamLine);
1748#if !defined(OPT_ACCEL)
1749   localRecPtr->SubsequentSolidHorVertLine =
1750	 OPTACCEL(GX1SubsequentHorVertLine);
1751#endif
1752   localRecPtr->SubsequentSolidTwoPointLine =
1753	 OPTACCEL(GX1SubsequentSolidTwoPointLine);
1754   localRecPtr->SolidBresenhamLineErrorTermBits = 15;
1755
1756#if SCR2SCREXP
1757   /* Color expansion */
1758   localRecPtr->ScreenToScreenColorExpandFillFlags =
1759	 BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY;
1760
1761   localRecPtr->SetupForScreenToScreenColorExpandFill =
1762	 (GX1SetupForScreenToScreenColorExpandFill);
1763   localRecPtr->SubsequentScreenToScreenColorExpandFill =
1764	 (GX1SubsequentScreenToScreenColorExpandFill);
1765#endif
1766
1767   /*
1768    * ImageWrite.
1769    *
1770    * SInce this uses off-screen scanline buffers, it is only of use when
1771    * complex ROPs are used. But since the current XAA pixmap cache code
1772    * only works when an ImageWrite is provided, the NO_GXCOPY flag is
1773    * temporarily disabled.
1774    */
1775   if (pGeode->AccelImageWriteBufferOffsets) {
1776
1777      localRecPtr->ScanlineImageWriteFlags =
1778	    localRecPtr->ScreenToScreenCopyFlags;
1779      localRecPtr->ScanlineImageWriteBuffers =
1780	    pGeode->AccelImageWriteBufferOffsets;
1781      localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers;
1782      localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu1_yshift;
1783      localRecPtr->SetupForScanlineImageWrite =
1784	    OPTACCEL(GX1SetupForScanlineImageWrite);
1785      localRecPtr->SubsequentScanlineImageWriteRect =
1786	    OPTACCEL(GX1SubsequentScanlineImageWriteRect);
1787      localRecPtr->SubsequentImageWriteScanline =
1788	    OPTACCEL(GX1SubsequentImageWriteScanline);
1789
1790      ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase;
1791      Geodesrcy = ImgBufOffset >> gu1_yshift;
1792
1793      Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1);
1794      Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3);
1795   }
1796
1797   return (XAAInit(pScreen, localRecPtr));
1798}
1799
1800/* END OF FILE */
1801