1 diff -ruN XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile
2 --- XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile Wed Jun 23 08:37:21 1999
3 +++ XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile Sat Oct 24 03:54:44 1998
5 -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile,v 1.1.2.9 1999/06/23 12:37:21 hohndel Exp $
6 +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/Imakefile,v 1.1.2.8 1998/10/22 04:31:05 hohndel Exp $
8 XCOMM This is an Imakefile for the cyrix driver.
11 #include <Server.tmpl>
13 SRCS = cyrix_driver.c cyrix_accel.c cyrix_cursor.c cyrix_cmap.c cyrix_bank.s \
14 - cyrix_asm.s gxrender.c
17 OBJS = cyrix_driver.o cyrix_accel.o cyrix_cursor.o cyrix_cmap.o cyrix_bank.o \
18 - cyrix_asm.o gxrender.o
24 InstallLinkKitNonExecFile(cyrix_driver.c,$(LINKKITDIR)/drivers/vga256/cyrix)
25 InstallLinkKitNonExecFile(cyrix_bank.s,$(LINKKITDIR)/drivers/vga256/cyrix)
26 InstallLinkKitNonExecFile(cyrix_asm.s,$(LINKKITDIR)/drivers/vga256/cyrix)
27 -InstallLinkKitNonExecFile(gxrender.c,$(LINKKITDIR)/drivers/vga256/cyrix)
28 InstallLinkKitNonExecFile(Imakefile,$(LINKKITDIR)/drivers/vga256/cyrix)
32 XCOMM Install Link Kit Non Exec File(Imakefile,$(LINKKITDIR)/drivers/vga16/cyrix)
36 diff -ruN XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h
37 --- XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h Tue Dec 22 02:49:58 1998
38 +++ XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h Fri Nov 6 11:41:51 1998
41 -/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h,v 1.1.2.6 1998/12/22 07:49:58 hohndel Exp $ */
42 +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix.h,v 1.1.2.5 1998/11/06 09:47:02 hohndel Exp $ */
44 /* this code is partly based on the MediaGX sources from the GGI project
45 based on CYRIX example code (gxvideo.c) and included with CYRIX and
47 #define CYRIXsetVectorMode() \
48 GX_REG(GP_VECTOR_MODE) = (vectorMode)
50 -#define IfDest(rop, planemask, val) \
51 - (( (((rop) & 0x5) ^ (((rop) & 0xA) >> 1)) \
52 - || (~((planemask) & 0xFF)) \
54 +#define IfDest(xrop, val) ((((xrop) & 0x5) ^ (((xrop) & 0xA) >> 1)) ? (val) : 0)
58 /* Generic MediaGX hardware register and value definitions */
60 diff -ruN XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c
61 --- XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c Wed Jun 23 08:37:21 1999
62 +++ XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c Fri Nov 6 11:41:51 1998
64 -/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c,v 1.1.2.6 1999/06/23 12:37:21 hohndel Exp $ */
65 +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_accel.c,v 1.1.2.3 1998/11/06 09:47:04 hohndel Exp $ */
68 - * Copyright 1999 by Brian Falardeau.
69 * Copyright 1998 by Annius Groenink, Amsterdam.
71 * Permission to use, copy, modify, distribute, and sell this software and its
77 /* size of color expand source area (embedded in frame buffer) */
78 #define CYRIXexpandSize 32768
81 upper nybble inverted X raster operation (bits 0 - 3 correspond to
82 bits 3 - 0 and 7 - 4 in Windows style ROP). In some routines,
83 the role of source and pattern is inverted. */
85 -/* The following ROPs only use pattern and destination data. */
86 -/* They are used when the planemask specifies all planes (no mask). */
88 -static const int windowsROPpat[16] = {
89 - 0x00, /* GXclear = 0 */
90 - 0xA0, /* GXand = pat AND dst */
91 - 0x50, /* GXandReverse = pat AND NOT dst */
92 - 0xF0, /* GXcopy = pat */
93 - 0x0A, /* GXandInverted = NOT pat AND dst */
94 - 0xAA, /* GXnoop = dst */
95 - 0x5A, /* GXxor = pat XOR dst */
96 - 0xFA, /* GXor = pat OR dst */
97 - 0x05, /* GXnor = NOT pat AND NOT dst */
98 - 0xA5, /* GXequiv = NOT pat XOR dst */
99 - 0x55, /* GXinvert = NOT dst */
100 - 0xF5, /* GXorReverse = pat OR NOT dst */
101 - 0x0F, /* GXcopyInverted = NOT pat */
102 - 0xAF, /* GXorInverted = NOT pat OR dst */
103 - 0x5F, /* GXnand = NOT pat OR NOT dst */
104 - 0xFF, /* GXset = 1 */
107 -/* The following ROPs use source data to specify a planemask. */
108 -/* If the planemask (src) is one, then the result is the appropriate */
109 -/* combination of pattern and destination data. If the planemask (src) */
110 -/* is zero, then the result is always just destination data. */
112 -static const int windowsROPsrcMask[16] = {
113 - 0x22, /* GXclear => 0 if src = 1, dst if src = 0 */
114 - 0xA2, /* GXand = pat AND dst if src = 1, dst if src = 0 */
115 - 0x62, /* GXandReverse = pat AND NOT dst if src = 1, dst if src = 0 */
116 - 0xE2, /* GXcopy = pat if src = 1, dst if src = 0 */
117 - 0x2A, /* GXandInverted = NOT pat AND dst if src = 1, dst if src = 0 */
118 - 0xAA, /* GXnoop = dst if src = 1, dst if src = 0 */
119 - 0x6A, /* GXxor = pat XOR dst if src = 1, dst if src = 0 */
120 - 0xEA, /* GXor = pat OR dst if src = 1, dst if src = 0 */
121 - 0x26, /* GXnor = NOT pat AND NOT dst if src = 1, dst if src = 0 */
122 - 0xA6, /* GXequiv = NOT pat XOR dst if src = 1, dst if src = 0 */
123 - 0x66, /* GXinvert = NOT dst if src = 1, dst if src = 0 */
124 - 0xE6, /* GXorReverse = pat OR NOT dst if src = 1, dst if src = 0 */
125 - 0x2E, /* GXcopyInverted = NOT pat if src = 1, dst if src = 0 */
126 - 0xAE, /* GXorInverted = NOT pat OR dst if src = 1, dst if src = 0 */
127 - 0x6E, /* GXnand = NOT pat OR NOT dst if src = 1, dst if src = 0 */
128 - 0xEE, /* GXset = 1 if src = 1, dst if src = 0 */
131 -/* The following ROPs use pattern data to specify a planemask. */
132 -/* If the planemask (pat) is one, then the result is the appropriate */
133 -/* combination of source and destination data. If the planemask (pat) */
134 -/* is zero, then the result is always just destination data. */
136 static const int windowsROPpatMask[16] = { 0x0A, 0x8A, 0x4A, 0xCA,
137 0x2A, 0xAA, 0x6A, 0xEA,
138 0x1A, 0x9A, 0x5A, 0xDA,
139 0x3A, 0xBA, 0x7A, 0xFA };
141 +static const int windowsROPsrcMask[16] = { 0x22, 0xA2, 0x62, 0xE2,
142 + 0x2A, 0xAA, 0x6A, 0xEA,
143 + 0x26, 0xA6, 0x66, 0xE6,
144 + 0x2E, 0xAE, 0x6E, 0xEE };
146 +static int bltBufWidth;
149 static int vectorMode;
152 static int setBlitModeOnSync = 0;
154 -/* STATIC VARIABLES FOR THIS FILE */
155 -/* Used to maintain state between setup and rendering calls. */
157 -static int CYRIXsavedROP;
158 -static int CYRIXtransparent;
159 -static int CYRIXtransColor;
160 -static int CYRIXstartMonoExpand = 0;
162 -static unsigned short CYRIXsaveX, CYRIXsaveY, CYRIXsaveW, CYRIXsaveH;
164 /* Forward declaration of functions used in the driver */
166 void CYRIXAccelSync();
167 void CYRIXAccelInit();
168 void CYRIXSetupForFillRectSolid();
169 void CYRIXSubsequentFillRectSolid();
170 -void CYRIXSetupFor8x8PatternColorExpand();
171 -void CYRIXSubsequent8x8PatternColorExpand();
172 void CYRIXSetupForScreenToScreenCopy();
173 void CYRIXSubsequentScreenToScreenCopy();
175 void CYRIXSubsequentBresenhamLine();
176 +void CYRIXSetupFor8x8PatternColorExpand();
177 +void CYRIXSubsequent8x8PatternColorExpand();
178 void CYRIXSetupForCPUToScreenColorExpand();
179 void CYRIXSubsequentCPUToScreenColorExpand();
181 -/* Routines in GXRENDER.C */
183 -void gxr_initialize(unsigned char *regptr, unsigned short bpp,
184 - unsigned short BB0base, unsigned short BB1base,
185 - unsigned short BBwidthPixels);
187 -void gxr_wait_until_idle(void);
189 -void gxr_load_solid_source(unsigned short color);
191 -void gxr_load_mono_source(unsigned short bgcolor, unsigned short fgcolor,
192 - unsigned short transparent);
194 -void gxr_load_solid_pattern(unsigned short color);
196 -void gxr_load_mono_pattern(unsigned short bgcolor, unsigned short fgcolor,
197 - unsigned long data0, unsigned long data1, unsigned char transparency);
199 -void gxr_load_raster_operation(unsigned char rop);
201 -void gxr_pattern_fill(unsigned short x, unsigned short y,
202 - unsigned short width, unsigned short height);
204 -void gxr_screen_to_screen_blt(unsigned short srcx, unsigned short srcy,
205 - unsigned short dstx, unsigned short dsty, unsigned short width,
206 - unsigned short height);
208 -void gxr_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy,
209 - unsigned short dstx, unsigned short dsty, unsigned short width,
210 - unsigned short height, unsigned short color);
212 -void gxr_text_glyph(unsigned short srcx, unsigned short srcy,
213 - unsigned short dstx, unsigned short dsty, unsigned short width,
214 - unsigned short height, unsigned char *data, unsigned short pitch);
216 -void gxr_bresenham_line(unsigned short x, unsigned short y,
217 - unsigned short length, unsigned short initerr,
218 - unsigned short axialerr, unsigned short diagerr,
219 - unsigned short flags);
222 -//---------------------------------------------------------------------------
225 -// This routine hooks the acceleration routines and sets appropriate flags.
226 -//---------------------------------------------------------------------------
229 +/* Acceleration init function, sets up pointers to our accelerated functions */
235 - /* General acceleration flags */
236 +{ /* General acceleration flags */
237 xf86AccelInfoRec.Flags = PIXMAP_CACHE
238 | BACKGROUND_OPERATIONS
239 | HARDWARE_PATTERN_SCREEN_ORIGIN
240 @@ -245,344 +138,232 @@
242 /* calculate the pixel width of a blit buffer for convenience */
243 bltBufWidth = CYRIXbltBufSize / (vgaBitsPerPixel / 8);
246 - /* pass parameters to GXRENDER.C file */
248 - gxr_initialize((unsigned char *) GXregisters,
249 - (unsigned short) vgaBitsPerPixel,
250 - (unsigned short) CYRIXbltBuf0Address,
251 - (unsigned short) CYRIXbltBuf1Address,
252 - (unsigned short) bltBufWidth);
254 +/* set colors - called through access macros in cyrix.h */
255 +static __inline__ void CYRIXsetColors01(reg, col0, col1)
259 +{ if (vgaBitsPerPixel == 16)
260 + GX_REG(reg) = ((col1 & 0xFFFF) << 16) | (col0 & 0xFFFF);
264 + GX_REG(reg) = (col1 << 24) | (col1 << 16) | (col0 << 8) | col0;
268 -//---------------------------------------------------------------------------
271 -// This routine is called before accessing the frame buffer directly to
272 -// make sure that the graphics pipeline is idle. It is also called after
273 -// loading the monochrome data into BB0 for bitmap to screen BLTs.
274 -//---------------------------------------------------------------------------
277 +/* The generic Sync() function that waits for everything to
278 + be completed (e.g. before writing to the frame buffer
283 - /* CHECK IF END TO CPU TO SCREEN EXPAND BLT */
285 - if (CYRIXstartMonoExpand)
287 - /* START CPU TO SCREEN EXPAND BLT */
288 - /* Data has already been loaded into BB0, so use NULL pointer. */
290 - /* this is formally incorrect: XAA may use both BB0 and BB1
291 - for the text source bitmap, so READ_DST_FB1 should not be
292 - used. So far, this problem has not manifested itself in
295 - CYRIXstartMonoExpand = 0;
296 - gxr_text_glyph(0, 0, CYRIXsaveX, CYRIXsaveY, CYRIXsaveW,
298 +{ if (setBlitModeOnSync)
299 + { setBlitModeOnSync = 0;
301 + CYRIXsetBlitMode();
304 - /* WAIT UNTIL IDLE */
306 - gxr_wait_until_idle();
307 + while (GX_REG(GP_BLIT_STATUS) &
308 + (BS_BLIT_BUSY|BS_PIPELINE_BUSY|BS_BLIT_PENDING));
313 -//---------------------------------------------------------------------------
314 -// CYRIXSetupForFillRectSolid
316 -// This routine is called to setup the solid pattern color for future
317 -// rectangular fills or vectors.
318 -//---------------------------------------------------------------------------
321 +/* Solid rectangles */
323 CYRIXSetupForFillRectSolid(color, rop, planemask)
325 unsigned int planemask;
327 - /* LOAD THE SOLID PATTERN COLOR */
329 - gxr_load_solid_pattern((unsigned short) color);
331 - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
333 - if (planemask == (unsigned int) -1)
335 - /* use normal pattern ROPs if all planes are enabled */
337 - gxr_load_raster_operation(windowsROPpat[rop & 0x0F]);
341 - /* select ROP that uses planemask in src data */
343 - gxr_load_solid_source((unsigned short) planemask);
344 - gxr_load_raster_operation(windowsROPsrcMask[rop & 0x0F]);
347 + CYRIXsetSourceColors01(color, color);
348 + CYRIXsetPatColors01(planemask, 0);
349 + CYRIXsetPatMode(rop, RM_PAT_DISABLE);
350 + blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND
351 + | IfDest(rop, BM_READ_DST_FB0);
352 + vectorMode = IfDest(rop, VM_READ_DST_FB);
356 -//---------------------------------------------------------------------------
357 -// CYRIXSubsequentFillRectSolid
359 -// This routine is called to fill a rectangular region using the previously
360 -// specified solid pattern and raster operation.
362 -// Sample application uses:
363 -// - Window backgrounds.
364 -// - x11perf: rectangle tests (-rect500).
365 -// - x11perf: fill trapezoid tests (-trap100).
366 -// - x11perf: horizontal line segments (-hseg500).
367 -//---------------------------------------------------------------------------
371 CYRIXSubsequentFillRectSolid(x, y, w, h)
374 - /* call routine to fill rectangular region */
376 - gxr_pattern_fill((unsigned short) x, (unsigned short) y,
377 - (unsigned short) w, (unsigned short) h);
381 -//---------------------------------------------------------------------------
382 -// CYRIXSetupFor8x8PatternColorExpand
384 -// This routine is called to setup the monochrome pattern (8x8) and raster
385 -// operation for future rectangular fills.
386 -//---------------------------------------------------------------------------
389 -void CYRIXSetupFor8x8PatternColorExpand(patternx, patterny, bg, fg, rop, planemask)
390 -int patternx, patterny;
392 -unsigned int planemask;
393 -{ int trans = (bg == -1);
395 - /* LOAD PATTERN COLORS AND DATA */
397 - gxr_load_mono_pattern((unsigned short) bg, (unsigned short) fg,
398 - (unsigned long) patternx, (unsigned long) patterny,
399 - (unsigned char) trans);
401 - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */
403 - if (planemask == (unsigned int) -1)
405 - /* use normal pattern ROPs if all planes are enabled */
407 - gxr_load_raster_operation(windowsROPpat[rop & 0x0F]);
411 - /* select ROP that uses planemask in src data */
413 - gxr_load_solid_source((unsigned short) planemask);
414 - gxr_load_raster_operation(windowsROPsrcMask[rop & 0x0F]);
415 +{ /* divide the operation into columns if required; use twice the
416 + blit buffer width because buffer 0 will overflow into buffer 1 */
417 + while (w > 2 * bltBufWidth)
418 + { CYRIXSubsequentFillRectSolid(x, y, 2 * bltBufWidth, h);
419 + x += 2 * bltBufWidth;
420 + w -= 2 * bltBufWidth;
423 + CYRIXsetDstXY(x, y);
425 + CYRIXsetBlitMode();
429 -//---------------------------------------------------------------------------
430 -// CYRIXSubsequent8x8PatternColorExpand
432 -// This routine is called to fill a rectangular region using the previously
433 -// specified monochrome pattern (8x8) and raster operation.
435 -// Sample application uses:
436 -// - Patterned desktops
437 -// - x11perf: stippled rectangle tests (-srect500).
438 -// - x11perf: opaque stippled rectangle tests (-osrect500).
439 -//---------------------------------------------------------------------------
442 -void CYRIXSubsequent8x8PatternColorExpand(patternx, patterny, x, y, w, h)
443 -int patternx, patterny;
446 - /* call routine to fill rectangular region */
448 - gxr_pattern_fill((unsigned short) x, (unsigned short) y,
449 - (unsigned short) w, (unsigned short) h);
453 -//---------------------------------------------------------------------------
454 -// CYRIXSetupForScreenToScreenCopy
456 -// This routine is called to setup the planemask and raster operation
457 -// for future screen to screen BLTs.
458 -//---------------------------------------------------------------------------
461 +/* Screen to screen copies */
463 CYRIXSetupForScreenToScreenCopy(xdir, ydir, rop, planemask, transparency_color)
466 unsigned int planemask;
467 int transparency_color;
469 - /* LOAD PLANEMASK INTO PATTERN DATA */
471 + CYRIXsetPatColors01(planemask, 0);
473 - gxr_load_solid_pattern((unsigned short) planemask);
475 - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */
476 + if (transparency_color == -1)
477 + { CYRIXsetPatMode(rop, RM_PAT_DISABLE);
481 + { CYRIXsetPatModeTrans(RM_PAT_DISABLE);
484 - gxr_load_raster_operation(windowsROPpatMask[rop & 0x0F]);
485 + /* fill blit buffer 1 with the transparency color */
486 + if (vgaBitsPerPixel == 16)
487 + { int k = CYRIXbltBufSize / 4;
488 + CARD32 val = (transparency_color << 16) |
489 + transparency_color;
490 + volatile CARD32* buf = &(GX_REG(CYRIXbltBuf1Address));
492 + while (--k >= 0) buf[k] = val;
495 + memset(GXregisters + CYRIXbltBuf1Address,
496 + transparency_color, CYRIXbltBufSize);
499 - /* SAVE TRANSPARENCY FLAG */
500 + blitMode = BM_READ_SRC_FB | BM_WRITE_FB | BM_SOURCE_COLOR
501 + | (transMode ? IfDest(rop, BM_READ_DST_FB1) : BM_READ_DST_NONE)
502 + | (ydir < 0 ? BM_REVERSE_Y : 0);
504 - CYRIXtransparent = (transparency_color == -1) ? 0 : 1;
505 - CYRIXtransColor = transparency_color;
510 -//---------------------------------------------------------------------------
511 -// CYRIXSubsequentScreenToScreenCopy
513 -// This routine is called to perform a screen to screen BLT using the
514 -// previously specified planemask, raster operation, and transparency flag.
516 -// Sample application uses (non-transparent):
517 -// - Moving windows.
518 -// - x11perf: scroll tests (-scroll500).
519 -// - x11perf: copy from window to window (-copywinwin500).
521 -// No application found using transparency.
522 -//---------------------------------------------------------------------------
526 CYRIXSubsequentScreenToScreenCopy(x1, y1, x2, y2, w, h)
527 int x1, y1, x2, y2, w, h;
529 - if (CYRIXtransparent)
531 - /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT */
532 - /* Should only be called for the "copy" raster operation. */
534 - gxr_screen_to_screen_xblt(
535 - (unsigned short) x1, (unsigned short) y1,
536 - (unsigned short) x2, (unsigned short) y2,
537 - (unsigned short) w, (unsigned short) h,
538 - (unsigned short) CYRIXtransColor);
539 +{ int up = (blitMode & BM_REVERSE_Y);
541 + /* divide the operation into columns when necessary */
543 + { int x_offset = w - bltBufWidth;
545 + while (x_offset > 0)
546 + { CYRIXSubsequentScreenToScreenCopy(x1 + x_offset, y1,
549 + x_offset -= bltBufWidth;
552 + else while (w > bltBufWidth)
553 + { CYRIXSubsequentScreenToScreenCopy(x1, y1, x2, y2,
561 - /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */
563 - gxr_screen_to_screen_blt(
564 - (unsigned short) x1, (unsigned short) y1,
565 - (unsigned short) x2, (unsigned short) y2,
566 - (unsigned short) w, (unsigned short) h);
568 + CYRIXsetSrcXY(x1, (up ? (y1 + h - 1) : y1));
569 + CYRIXsetDstXY(x2, (up ? (y2 + h - 1) : y2));
571 + /* in transparent mode, one line reads the transparency color
572 + into a processor-internal register, and the remaining lines
573 + can be done in a single second pass */
575 + { blitMode |= BM_READ_DST_BB1;
577 + CYRIXsetBlitMode();
580 + if (up) { y1--; y2--; }
581 + else { y1++; y2++; }
583 + blitMode &= ~(BM_READ_DST_BB1);
586 + CYRIXsetBlitMode();
590 -//---------------------------------------------------------------------------
591 -// CYRIXSubsequentBresenhamLine
593 -// This routine is called to render a vector using the specified Bresenham
596 -// Sample application uses:
597 -// - Window outlines on window move.
598 -// - x11perf: line segments (-seg500).
599 -//---------------------------------------------------------------------------
602 +/* Bresenham lines */
604 CYRIXSubsequentBresenhamLine(x1, y1, octant, err, e1, e2, length)
605 int x1, y1, octant, err, e1, e2, length;
607 - unsigned short flags;
609 - /* DETERMINE YMAJOR AND DIRECTION FLAGS */
611 - if (octant & YMAJOR)
612 - { flags = VM_Y_MAJOR;
613 - if (!(octant & XDECREASING)) flags |= VM_MINOR_INC;
614 - if (!(octant & YDECREASING)) flags |= VM_MAJOR_INC;
615 +{ if (octant & YMAJOR)
616 + { vectorMode = (vectorMode & VM_READ_DST_FB) | VM_Y_MAJOR;
617 + if (!(octant & XDECREASING)) vectorMode |= VM_MINOR_INC;
618 + if (!(octant & YDECREASING)) vectorMode |= VM_MAJOR_INC;
621 - { flags = VM_X_MAJOR;
622 - if (!(octant & XDECREASING)) flags |= VM_MAJOR_INC;
623 - if (!(octant & YDECREASING)) flags |= VM_MINOR_INC;
624 + { vectorMode = (vectorMode & VM_READ_DST_FB) | VM_X_MAJOR;
625 + if (!(octant & XDECREASING)) vectorMode |= VM_MAJOR_INC;
626 + if (!(octant & YDECREASING)) vectorMode |= VM_MINOR_INC;
629 - /* CALL ROUTINE TO DRAW VECTOR */
631 - gxr_bresenham_line((unsigned short) x1, (unsigned short) y1,
632 - (unsigned short) length, (unsigned short) err,
633 - (unsigned short) e1, (unsigned short) e2, (unsigned short) flags);
635 + CYRIXsetDstXY(x1, y1);
636 + CYRIXsetWH(length, (err & 0xFFFF));
637 + CYRIXsetSrcXY((e1 & 0xFFFF), (e2 & 0xFFFF));
638 + CYRIXsetVectorMode();
642 -//---------------------------------------------------------------------------
643 -// CYRIXSetupForCPUToScreenColorExpand
645 -// This routine is called to setup the planemask, colors, and raster
646 -// operation for future monocrome bitmap to screen BLTs.
647 -//---------------------------------------------------------------------------
650 -void CYRIXSetupForCPUToScreenColorExpand(bg, fg, rop, planemask)
651 +/* 8x8 pattern color expand */
652 +void CYRIXSetupFor8x8PatternColorExpand(patternx, patterny, bg, fg, rop, planemask)
653 +int patternx, patterny;
655 unsigned int planemask;
656 { int trans = (bg == -1);
658 - /* LOAD SOURCE COLORS */
660 + CYRIXsetSourceColors01(planemask, planemask);
661 + CYRIXsetPatColors01(trans ? 0 : bg, fg);
662 + CYRIXsetPatData(patternx, patterny);
663 + CYRIXsetPatModeX(rop, RM_PAT_MONO | (trans ? RM_PAT_TRANSPARENT : 0));
665 - gxr_load_mono_source((unsigned short) bg, (unsigned short) fg,
666 - (unsigned short) trans);
667 + blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND
668 + | (trans ? IfDest(rop, BM_READ_DST_FB0) : BM_READ_DST_NONE);
671 - /* LOAD PLANEMASK INTO PATTERN DATA */
672 +void CYRIXSubsequent8x8PatternColorExpand(patternx, patterny, x, y, w, h)
673 +int patternx, patterny;
675 +{ CYRIXSubsequentFillRectSolid(x, y, w, h);
678 - gxr_load_solid_pattern((unsigned short) planemask);
680 - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */
682 - gxr_load_raster_operation(windowsROPpatMask[rop & 0x0F]);
684 +/* CPU-to-screen color expansion */
685 +void CYRIXSetupForCPUToScreenColorExpand(bg, fg, rop, planemask)
687 +unsigned int planemask;
688 +{ int trans = (bg == -1);
691 -//---------------------------------------------------------------------------
692 -// CYRIXSubsequentCPUToScreenColorExpand
694 -// This routine is called to render expanded monocrome bitmap data to the
695 -// screen using the previously specified colors and raster operation. Since
696 -// the server loads the monochrome data into BB0, not the driver, this
697 -// routine just sets a flag and saves the parameters to use when the server
698 -// is done loading the data and calls the CYRIXAccelSync function.
700 -// Sample application uses:
701 -// - Text in windows.
702 -// - x11perf: text (-ftext, -f8text, -f9text, ...).
703 -//---------------------------------------------------------------------------
706 + CYRIXsetSourceColors01(trans ? 0 : bg, fg);
707 + CYRIXsetPatColors01(planemask, 0);
709 + CYRIXsetPatMode(rop, RM_PAT_DISABLE | (trans ? RM_SRC_TRANSPARENT : 0));
711 + /* this is formally incorrect: XAA may use both BB0 and BB1
712 + for the text source bitmap, so READ_DST_FB1 should not be
713 + used. So far, this problem has not manifested itself in
715 + blitMode = BM_READ_SRC_BB0 | BM_WRITE_FB | BM_SOURCE_EXPAND
716 + | (trans ? IfDest(rop, BM_READ_DST_FB1) : BM_READ_DST_NONE);
719 void CYRIXSubsequentCPUToScreenColorExpand(x, y, w, h, skipleft)
723 - CYRIXstartMonoExpand = 1;
729 - /* WAIT UNTIL IDLE BEFORE ALLOWING WRITES TO BLT BUFFERS */
730 - /* Server will load the monochrome data into BB0 after this. */
732 + CYRIXsetSrcXY(0, 0);
733 + CYRIXsetDstXY(x, y);
736 - gxr_wait_until_idle();
738 + setBlitModeOnSync = 1;
743 diff -ruN XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c
744 --- XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c Wed Jun 23 08:37:22 1999
745 +++ XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c Fri Nov 6 11:41:51 1998
747 -/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c,v 1.1.2.7 1999/06/23 12:37:22 hohndel Exp $ */
748 +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/cyrix_driver.c,v 1.1.2.6 1998/11/06 09:47:08 hohndel Exp $ */
750 - * Copyright 1999 by Brian Falardeau
751 * Copyright 1998 by Annius V. Groenink (A.V.Groenink@zfc.nl, avg@cwi.nl),
752 * Dirk H. Hohndel (hohndel@suse.de),
753 * Portions: the GGI project & confidential CYRIX databooks.
755 - * Substitute Brian Falardeau into a copy of the following legal jargon...
757 * Permission to use, copy, modify, distribute, and sell this software and its
758 * documentation for any purpose is hereby granted without fee, provided that
759 * the above copyright notice appear in all copies and that both that
761 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
762 * PERFORMANCE OF THIS SOFTWARE.
764 +/* $XConsortium: $ */
766 /*************************************************************************/
769 Log for the cyrix driver source as a whole
771 - May 1999, Brian Falardeau:
772 - - Fixed interaction with SoftVGA for setting 2K pitch at 1280x1024.
773 - - Added CRTC tables for 60 Hz and 75 Hz modes.
774 - - Removed enabling display compression directly for VSA1.
776 5th Nov 1998 avg - Fixed blit buffer organization using CPU_WRITE
777 instruction. Support for older chipsets (color
778 treatment and different CPU_WRITE opcode).
779 @@ -115,35 +108,50 @@
780 #include "extensions/xf86dgastr.h"
787 +#if !defined(MONOVGA) && !defined(XF86VGA16)
793 pciTagRec CyrixPciTag;
794 extern vgaHWCursorRec vgaHWCursor;
796 -#define NUM_STD_CRTC_REGS 25
797 -#define NUM_EXT_CRTC_REGS 16
800 vgaHWRec std; /* IBM VGA */
803 - /* override of miscellaneous output register value */
805 - unsigned char miscOutput;
807 - /* override of standard CRTC register values */
809 - unsigned char stdCRTCregs[NUM_STD_CRTC_REGS];
811 - /* extended CRTC register values (specific to MediaGX) */
813 - unsigned char extCRTCregs[NUM_EXT_CRTC_REGS];
814 + { /* extended SoftVGA registers */
815 + unsigned char VerticalTimingExtension;
816 + unsigned char ExtendedAddressControl;
817 + unsigned char ExtendedOffset;
818 + unsigned char ExtendedColorControl;
819 + unsigned char DisplayCompression;
820 + unsigned char DriverControl;
821 + unsigned char DACControl;
822 + unsigned char ClockControl;
823 + unsigned char CrtClockFrequency;
824 + unsigned char CrtClockFrequencyFraction;
825 + unsigned char RefreshRate;
827 + /* display controller hardware registers */
828 + CARD32 DcGeneralCfg;
829 + CARD32 DcCursStOffset;
830 + CARD32 DcCbStOffset;
831 + CARD32 DcLineDelta;
835 + CARD32 DcCursorColor;
837 /* graphics pipeline registers */
841 + /* save area for cursor image */
842 + char cursorPattern[256];
844 } vgaCYRIXRec, *vgaCYRIXPtr;
847 static void CYRIXRestore();
848 static void CYRIXAdjust();
851 static void CYRIXFbInit();
852 static Bool CYRIXScreenInit();
853 static Bool CYRIXPitchAdjust();
857 void CYRIXSetWrite();
861 (void (*)())NoopDDA, /* CYRIXGetMode */
865 + (void (*)())NoopDDA, /* CYRIXFbInit */
871 VGA_NO_DIVIDE_VERT, /* ChipInterlaceType */
872 {0,}, /* ChipOptionFlags */
873 8, /* ChipRounding */
874 - TRUE, /* ChipUseLinearAddressing */
875 - 0x40800000, /* ChipLinearBase */
876 - 0x001FFFFF, /* ChipLinearSize */
877 + FALSE, /* ChipUseLinearAddressing */
878 + 0, /* ChipLinearBase */
879 + 0, /* ChipLinearSize */
880 TRUE, /* ChipHas16bpp */
881 FALSE, /* ChipHas24bpp */
882 FALSE, /* ChipHas32bpp */
887 -int CYRIXvsaversion; /* VSA version */
888 -#define CYRIX_VSA1 1
889 -#define CYRIX_VSA2 2
891 int CYRIXcbufferAddress; /* relative to video base */
892 int CYRIXoffscreenAddress;
893 int CYRIXcursorAddress;
896 #define newstate ((vgaCYRIXPtr)vgaNewVideoState)
902 - unsigned char miscOutput;
903 - unsigned char stdCRTCregs[NUM_STD_CRTC_REGS];
904 - unsigned char extCRTCregs[NUM_EXT_CRTC_REGS];
907 -vgaCYRIXmode CYRIXmodes[] =
909 -/*------------------------------------------------------------------------------*/
910 - { 640, 480, /* 640x480 */
911 - 25, /* 25 MHz clock = 60 Hz refresh rate */
912 - 0xE3, /* miscOutput register */
913 - { 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, /* standard CRTC */
914 - 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
915 - 0xEA, 0x0C, 0xDF, 0x50, 0x00, 0xE7, 0x04, 0xE3, 0xFF },
916 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
917 - 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } },
918 -/*------------------------------------------------------------------------------*/
919 - { 800, 600, /* 800x600 */
920 - 40, /* 40 MHz clock = 60 Hz refresh rate */
921 - 0x23, /* miscOutput register */
922 - { 0x7F, 0x63, 0x64, 0x82, 0x6B, 0x1B, 0x72, 0xF0, /* standard CRTC */
923 - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
924 - 0x59, 0x0D, 0x57, 0x64, 0x00, 0x57, 0x73, 0xE3, 0xFF },
925 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
926 - 0x00, 0x00, 0x01, 0x03, 0xA0, 0x50, 0x00, 0x00 } },
927 -/*------------------------------------------------------------------------------*/
928 - { 1024, 768, /* 1024x768 */
929 - 65, /* 65 MHz clock = 60 Hz refresh rate */
930 - 0xE3, /* miscOutput register */
931 - { 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xF5, /* standard CRTC */
932 - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
933 - 0x04, 0x0A, 0xFF, 0x80, 0x00, 0xFF, 0x25, 0xE3, 0xFF },
934 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
935 - 0x00, 0x00, 0x01, 0x03, 0x80, 0x41, 0x00, 0x00 } },
936 -/*------------------------------------------------------------------------------*/
937 - { 1280, 1024, /* 1280x1024 */
938 - 108, /* 108 MHz clock = 60 Hz refresh rate */
939 - 0x23, /* miscOutput register */
940 - { 0xCF, 0x9F, 0xA0, 0x92, 0xAA, 0x19, 0x28, 0x52, /* standard CRTC */
941 - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
942 - 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF },
943 - { 0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
944 - 0x00, 0x00, 0x01, 0x03, 0x80, 0x6C, 0x00, 0x00 } },
945 -/*------------------------------------------------------------------------------*/
946 - { 640, 480, /* 640x480 */
947 - 31, /* 31.5 MHz clock = 75 Hz refresh rate */
948 - 0xE3, /* miscOutput register */
949 - { 0x64, 0x4F, 0x4F, 0x88, 0x54, 0x9B, 0xF2, 0x1F, /* standard CRTC */
950 - 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
951 - 0xE1, 0x04, 0xDF, 0x50, 0x00, 0xDF, 0xF3, 0xE3, 0xFF },
952 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
953 - 0x00, 0x00, 0x01, 0x03, 0xA0, 0x3F, 0x00, 0x00 } },
954 -/*------------------------------------------------------------------------------*/
955 - { 800, 600, /* 800x600 */
956 - 99, /* 99 MHz clock = 75 Hz refresh rate */
957 - 0x23, /* miscOutput register */
958 - { 0x7F, 0x63, 0x63, 0x83, 0x68, 0x11, 0x6F, 0xF0, /* standard CRTC */
959 - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
960 - 0x59, 0x1C, 0x57, 0x64, 0x00, 0x57, 0x70, 0xE3, 0xFF },
961 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
962 - 0x00, 0x00, 0x01, 0x03, 0xA0, 0x63, 0x00, 0x00 } },
963 -/*------------------------------------------------------------------------------*/
964 - { 1024, 768, /* 1024x768 */
965 - 79, /* 79 MHz clock = 75 Hz refresh rate */
966 - 0xE3, /* miscOutput register */
967 - { 0x9F, 0x7F, 0x7F, 0x83, 0x84, 0x8F, 0x1E, 0xF5, /* standard CRTC */
968 - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
969 - 0x01, 0x04, 0xFF, 0x80, 0x00, 0xFF, 0x1F, 0xE3, 0xFF },
970 - { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
971 - 0x00, 0x00, 0x01, 0x03, 0x80, 0x4F, 0x00, 0x00 } },
972 -/*------------------------------------------------------------------------------*/
973 - { 1280, 1024, /* 1280x1024 */
974 - 135, /* 135 MHz clock = 75 Hz refresh rate */
975 - 0x23, /* miscOutput register */
976 - { 0xCE, 0x9F, 0x9F, 0x92, 0xA4, 0x15, 0x28, 0x52, /* standard CRTC */
977 - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
978 - 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF },
979 - { 0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */
980 - 0x00, 0x00, 0x01, 0x03, 0x80, 0x87, 0x00, 0x00 } },
981 -/*------------------------------------------------------------------------------*/
984 -#define NUM_CYRIX_MODES sizeof(CYRIXmodes)/sizeof(vgaCYRIXmode)
990 vga256InfoRec.bankedMono = TRUE;
991 OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &vga256InfoRec.clockOptions);
994 /* define option set valid for the driver */
995 OFLG_SET(OPTION_SW_CURSOR, &CYRIX.ChipOptionFlags);
996 OFLG_SET(OPTION_HW_CURSOR, &CYRIX.ChipOptionFlags);
997 @@ -496,12 +419,13 @@
998 CYRIX.ChipLinearSize = (1024 * vga256InfoRec.videoRam);
1000 CYRIX.ChipUseLinearAddressing = TRUE;
1003 /* map the entire area from GX_BASE (scratchpad area)
1004 up to the end of the control registers */
1005 GXregisters = (char*)xf86MapVidMem(vga256InfoRec.scrnIndex,
1007 - (void*)physbase, 0x20000);
1008 + (void*)physbase, 0x9000);
1011 { ErrorF("%s %s: Cannot map hardware registers\n",
1012 @@ -509,80 +433,27 @@
1016 - /* check VSA version */
1017 - /* VSA2 contains a "CX" signature at registers 0x35 and 0x36. */
1018 - /* The SoftVGA interface changed slightly for VSA2. Originally, */
1019 - /* VSA2 was intended for MXi only, but it may someday be */
1020 - /* provided for MediaGX systems as well. */
1022 - CYRIXvsaversion = CYRIX_VSA2;
1023 - outb(vgaIOBase + 4, 0x35);
1024 - if (inb(vgaIOBase + 5) != 'C') CYRIXvsaversion = CYRIX_VSA1;
1025 - outb(vgaIOBase + 4, 0x36);
1026 - if (inb(vgaIOBase + 5) != 'X') CYRIXvsaversion = CYRIX_VSA1;
1027 - if (CYRIXvsaversion == CYRIX_VSA1)
1029 - ErrorF("%s %s: VSA1 detected\n",
1030 - XCONFIG_PROBED, vga256InfoRec.name);
1034 - ErrorF("%s %s: VSA2 detected\n",
1035 - XCONFIG_PROBED, vga256InfoRec.name);
1040 -/*------------------------------------------------------------------------*\
1043 -** From README file: "The FbInit() function is required for drivers with
1044 -** accelerated graphics support. It is used to replace default cfb.banked
1045 -** functions with accelerated chip-specific versions.
1047 -** For the Cyrix driver, this routine is also used to allocate video
1048 -** memory. This is more complicated than it needs to be...
1050 -** For VSA1, SoftVGA manages all of graphics memory, including the
1051 -** compression buffer, cursor buffer, and offscreen memory. The driver
1052 -** should not allocate memory itself. For offscreen memory it reads
1053 -** registers 0x3C and 0x3D. For the cursor buffer it reads the hardware
1054 -** register after validating a mode. For compression, it just sets bit 0
1055 -** of register 0x49 if it wants to use compression, and SoftVGA will
1056 -** enable it if memory has been allocated.
1058 -** This model, however, breaks down for this driver. There is a bug in
1059 -** SoftVGA that keeps the 0x3C register from working properly. This bug
1060 -** also prevents compression from being enabled when using a virtual
1061 -** desktop. This driver also cannot use the memory past 2 Meg, which
1062 -** effects the memory calculation.
1064 -** Therefore, this driver does what it is not supposed to and allocates
1065 -** video memory itself. But, this is required due to bugs in SoftVGA and,
1066 -** as it turns out, works out fine (with limiting compression use).
1068 -** For VSA2, the driver is supposed to do this allocation itself.
1069 -\*------------------------------------------------------------------------*/
1074 { int lineDelta = vga256InfoRec.displayWidth * (vgaBitsPerPixel / 8);
1075 int virtualDelta = vga256InfoRec.virtualX * (vgaBitsPerPixel / 8);
1078 vgaSetScreenInitHook(CYRIXScreenInit);
1080 - /* always put the cursor at the end of video memory. */
1082 - CYRIXcursorAddress = CYRIX.ChipLinearSize - 256;
1084 /* offscreen memory is, normally, right after the frame buffer;
1085 + always put the cursor at the end of video memory.
1087 (It would be nice to use the ignored 64KB block at the end of
1088 the video memory (2112 - 2048) for the hardware cursor, but
1089 it is not mapped. This will not be a problem in Xfree 3.9 */
1091 CYRIXoffscreenAddress = (lineDelta * vga256InfoRec.virtualY);
1092 - CYRIXoffscreenSize = CYRIXcursorAddress - CYRIXoffscreenAddress;
1093 + CYRIXcursorAddress = CYRIX.ChipLinearSize - 256;
1094 + CYRIXoffscreenSize = CYRIXcursorAddress - CYRIXoffscreenAddress;
1096 /* if there is enough room between lines, put the compression
1099 CYRIXcbLineDelta = (lineDelta >> 2);
1100 if (xf86Verbose > 1)
1101 ErrorF("%s %s: Interleaving frame buffer and compression buffer\n",
1102 - XCONFIG_PROBED, vga256InfoRec.name);
1103 + XCONFIG_PROBED, vga256InfoRec.name);
1105 /* otherwise, put it directly after the virtual frame */
1108 if (cbuffer_size > CYRIXoffscreenSize)
1109 { CYRIXcbLineDelta = 0;
1110 ErrorF("%s %s: No room for the compression buffer\n",
1111 - XCONFIG_PROBED, vga256InfoRec.name);
1112 + XCONFIG_PROBED, vga256InfoRec.name);
1115 { CYRIXcbufferAddress = CYRIXoffscreenAddress;
1116 @@ -609,43 +480,25 @@
1117 CYRIXoffscreenSize -= cbuffer_size;
1120 - /* print results of offscreen memory configuration */
1122 - if (CYRIXoffscreenSize <= 0)
1124 - ErrorF("%s %s: No offscreen memory available.\n",
1125 - XCONFIG_PROBED, vga256InfoRec.name);
1129 - ErrorF("%s %s: Offscreen memory from 0x%8.8X-0x%8.8X\n",
1130 - XCONFIG_PROBED, vga256InfoRec.name,
1131 - CYRIXoffscreenAddress,
1132 - CYRIXoffscreenAddress+CYRIXoffscreenSize-1);
1135 - /* call CYRIXAccelInit to setup the XAA accelerated functions */
1137 + /* call CYRIXAccelInit to setup the XAA accelerated functions */
1138 if (!OFLG_ISSET(OPTION_NOACCEL, &vga256InfoRec.options))
1141 /* install hardware cursor routines */
1143 if (OFLG_ISSET(OPTION_HW_CURSOR, &vga256InfoRec.options))
1144 - { if (CYRIXoffscreenSize > 0)
1145 + { if (CYRIXoffscreenSize >= 0)
1146 { vgaHWCursor.Initialized = TRUE;
1147 vgaHWCursor.Init = CYRIXCursorInit;
1148 vgaHWCursor.Restore = CYRIXRestoreCursor;
1149 vgaHWCursor.Warp = CYRIXWarpCursor;
1150 vgaHWCursor.QueryBestSize = CYRIXQueryBestSize;
1151 - ErrorF("%s %s: Using hardware cursor at %8.8X\n",
1152 - XCONFIG_PROBED, vga256InfoRec.name, CYRIXcursorAddress);
1154 + ErrorF("%s %s: Using hardware cursor\n",
1155 + XCONFIG_PROBED, vga256InfoRec.name);
1159 ErrorF("%s %s: No room for hardware cursor\n",
1160 - XCONFIG_PROBED, vga256InfoRec.name);
1162 + XCONFIG_PROBED, vga256InfoRec.name);
1170 +#endif /* not MONOVGA */
1174 @@ -747,121 +601,210 @@
1180 +{ unsigned char temp;
1181 + /* switch off compression and cursor the hard way */
1182 + GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
1183 + GX_REG(DC_GENERAL_CFG) &= ~(DC_GCFG_CMPE | DC_GCFG_DECE | DC_GCFG_FDTY | DC_GCFG_CURE);
1184 + GX_REG(DC_UNLOCK) = 0;
1185 + CYRIXmarkLinesDirty();
1187 /* reset SoftVGA extensions to standard VGA behaviour */
1189 - for (i = 0; i < NUM_EXT_CRTC_REGS; i++)
1191 - outb(vgaIOBase + 4, 0x40 + i);
1192 - outb(vgaIOBase + 5, 0x00);
1194 + outb(vgaIOBase + 4, CrtcExtendedAddressControl);
1195 + temp = inb(vgaIOBase + 5);
1196 + outb(vgaIOBase + 5, temp & 0xf8);
1197 + outb(vgaIOBase + 4, CrtcExtendedStartAddress);
1198 + outb(vgaIOBase + 5, 0x00);
1199 + outb(vgaIOBase + 4, CrtcWriteMemoryAperture);
1200 + temp = inb(vgaIOBase + 5);
1201 + outb(vgaIOBase + 5, temp & 0xe0);
1202 + outb(vgaIOBase + 4, CrtcReadMemoryAperture);
1203 + temp = inb(vgaIOBase + 5);
1204 + outb(vgaIOBase + 5, temp & 0xe0);
1205 + outb(vgaIOBase + 4, CrtcDriverControl);
1206 + temp = inb(vgaIOBase + 5);
1207 + outb(vgaIOBase + 5, temp & 0xfe);
1208 + outb(vgaIOBase + 4, CrtcDisplayCompression);
1209 + temp = inb(vgaIOBase + 5);
1210 + outb(vgaIOBase + 5, temp & 0xf0);
1214 CYRIXRestore(restore)
1215 vgaCYRIXPtr restore;
1216 -{ unsigned char i, temp, temp2;
1217 - unsigned long value;
1219 - /* unlock extended CRTC registers */
1221 - outb(vgaIOBase + 4, 0x30);
1222 - outb(vgaIOBase + 5, 0x57);
1223 - outb(vgaIOBase + 5, 0x4C);
1224 +{ unsigned char temp;
1225 + vgaProtect(TRUE); /* Blank the screen */
1227 - /* SIGNAL THE BEGINNING OF THE MODE SWITCH
1228 - SoftVGA will hold off validating the back end hardware. */
1230 - outb(vgaIOBase + 4, CrtcModeSwitchControl);
1231 - outb(vgaIOBase + 5, 0x01);
1232 + /* it would be ideal to be able to use the ModeSwitchControl
1233 + register to protect SoftVGA from reading the configuration
1234 + before all registers have been written. But that bit must be
1235 + set somewhere in the middle of vgaHWRestore (after restoring
1236 + the font). Luckily things seem to work without it. */
1238 /* restore standard VGA portion */
1241 vgaHWRestore((vgaHWPtr)restore);
1242 + CYRIXmarkLinesDirty();
1244 - /* override restored miscellaneous output regiter value */
1246 - outb(0x3C2, restore->ext.miscOutput);
1248 - /* override restored standard CRTC register values */
1250 - outb(vgaIOBase + 4, 0x11);
1251 - outb(vgaIOBase + 5, 0x00);
1252 - for (i = 0; i < NUM_STD_CRTC_REGS; i++)
1254 - outb(vgaIOBase + 4, i);
1255 - outb(vgaIOBase + 5, restore->ext.stdCRTCregs[i]);
1258 /* restore SoftVGA extended registers */
1259 + outb(vgaIOBase + 4, CrtcDriverControl);
1260 + temp = inb(vgaIOBase + 5);
1261 + outb(vgaIOBase + 5, (restore->ext.DriverControl & 0x01)
1264 + outb(vgaIOBase + 4, CrtcVerticalTimingExtension);
1265 + temp = inb(vgaIOBase + 5);
1266 + outb(vgaIOBase + 5, (restore->ext.VerticalTimingExtension & 0x55)
1269 + outb(vgaIOBase + 4, CrtcExtendedAddressControl);
1270 + temp = inb(vgaIOBase + 5);
1271 + outb(vgaIOBase + 5, (restore->ext.ExtendedAddressControl & 0x07)
1274 + outb(vgaIOBase + 4, CrtcExtendedOffset);
1275 + temp = inb(vgaIOBase + 5);
1276 + outb(vgaIOBase + 5, (restore->ext.ExtendedOffset & 0x03)
1279 + outb(vgaIOBase + 4, CrtcExtendedColorControl);
1280 + temp = inb(vgaIOBase + 5);
1281 + outb(vgaIOBase + 5, (restore->ext.ExtendedColorControl & 0x07)
1284 + outb(vgaIOBase + 4, CrtcDisplayCompression);
1285 + temp = inb(vgaIOBase + 5);
1286 + outb(vgaIOBase + 5, (restore->ext.DisplayCompression & 0x0f)
1289 + outb(vgaIOBase + 4, CrtcDACControl);
1290 + temp = inb(vgaIOBase + 5);
1291 + outb(vgaIOBase + 5, (restore->ext.DACControl & 0x0e)
1294 + if (restore->std.NoClock >= 0)
1295 + { outb(vgaIOBase + 4, CrtcClockControl);
1296 + temp = inb(vgaIOBase + 5);
1297 + outb(vgaIOBase + 5, (restore->ext.ClockControl & 0xb0)
1300 + outb(vgaIOBase + 4, CrtcClockFrequency);
1301 + outb(vgaIOBase + 5, restore->ext.CrtClockFrequency);
1303 + outb(vgaIOBase + 4, CrtcClockFrequencyFraction);
1304 + outb(vgaIOBase + 5, restore->ext.CrtClockFrequencyFraction);
1306 + outb(vgaIOBase + 4, CrtcRefreshRate);
1307 + outb(vgaIOBase + 5, restore->ext.RefreshRate);
1310 + /* let SoftVGA programming settle before we access DC registers,
1311 + but don't wait too long */
1313 + CYRIXmarkLinesDirty();
1315 + /* restore display controller hardware registers */
1317 +#define DCFG_MASK (DC_GCFG_FDTY | DC_GCFG_DECE | DC_GCFG_CMPE)
1318 +#define GPBS_MASK (BC_16BPP | BC_FB_WIDTH_2048)
1320 - for (i = 0; i < NUM_EXT_CRTC_REGS; i++)
1322 - outb(vgaIOBase + 4, 0x40+i);
1323 - outb(vgaIOBase + 5, restore->ext.extCRTCregs[i]);
1325 + GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
1327 - /* signal the end of the mode switch */
1328 + GX_REG(DC_CURS_ST_OFFSET) = restore->ext.DcCursStOffset;
1329 + GX_REG(DC_CB_ST_OFFSET) = restore->ext.DcCbStOffset;
1330 + GX_REG(DC_LINE_DELTA) = (GX_REG(DC_LINE_DELTA) & 0xFFC00FFF)
1331 + | (restore->ext.DcLineDelta & 0x003FF000);
1332 + GX_REG(DC_BUF_SIZE) = (GX_REG(DC_BUF_SIZE) & 0xFFFF01FF)
1333 + | (restore->ext.DcBufSize & 0x0000FE00);
1334 + GX_REG(DC_CURSOR_X) = restore->ext.DcCursorX;
1335 + GX_REG(DC_CURSOR_Y) = restore->ext.DcCursorY;
1336 + GX_REG(DC_CURSOR_COLOR) = restore->ext.DcCursorColor;
1338 - outb(vgaIOBase + 4, CrtcModeSwitchControl);
1339 - outb(vgaIOBase + 5, 0x00);
1340 + GX_REG(DC_GENERAL_CFG) = (GX_REG(DC_GENERAL_CFG) & (~DCFG_MASK))
1341 + | (restore->ext.DcGeneralCfg & DCFG_MASK);
1343 - /* wait until SoftVGA has validated the mode.
1344 - This is for VSA1 only, where SoftVGA waits until the next
1345 - vertical blank to recalculate the hardware state. For VSA2
1346 - the hardware us updated immediately, so this is not needed.
1347 - THIS MUST BE DONE FOR VSA1 before loading the GP_BLT_STATUS
1348 - register, otherwise SoftVGA will override the value. */
1349 + GX_REG(DC_UNLOCK) = 0;
1351 - if (CYRIXvsaversion == CYRIX_VSA1)
1353 - outb(vgaIOBase + 4, 0x33);
1354 - while(inb(vgaIOBase + 5) & 0x80);
1356 + GX_REG(GP_BLIT_STATUS) = (GX_REG(GP_BLIT_STATUS) & (~GPBS_MASK))
1357 + | (restore->ext.GpBlitStatus & GPBS_MASK);
1359 - /* overrite what SoftVGA may have stored into GP_BLIT_STATUS */
1360 + /* restore cursor pattern */
1361 + if (restore->ext.DcCursStOffset < 1024 * vga256InfoRec.videoRam)
1362 + memcpy((char*)vgaLinearBase + restore->ext.DcCursStOffset,
1363 + restore->ext.cursorPattern, 256);
1366 - GX_REG(GP_BLIT_STATUS) = restore->ext.GpBlitStatus;
1367 + vgaProtect(FALSE); /* Turn on screen */
1374 - struct vgaCYRIXext ext;
1375 +{ struct vgaCYRIXext ext;
1377 - /* save miscellaneous output register */
1379 + /* save graphics pipeline registers */
1380 + ext.GpBlitStatus = GX_REG(GP_BLIT_STATUS);
1382 - ext.miscOutput = inb(0x3CC);
1383 + /* save display controller hardware registers */
1384 + GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
1385 + ext.DcGeneralCfg = GX_REG(DC_GENERAL_CFG);
1386 + ext.DcCursStOffset = GX_REG(DC_CURS_ST_OFFSET);
1387 + ext.DcCbStOffset = GX_REG(DC_CB_ST_OFFSET);
1388 + ext.DcLineDelta = GX_REG(DC_LINE_DELTA);
1389 + ext.DcBufSize = GX_REG(DC_BUF_SIZE);
1390 + ext.DcCursorX = GX_REG(DC_CURSOR_X);
1391 + ext.DcCursorY = GX_REG(DC_CURSOR_Y);
1392 + ext.DcCursorColor = GX_REG(DC_CURSOR_COLOR);
1393 + GX_REG(DC_UNLOCK) = 0;
1395 + /* save cursor pattern.
1396 + In the 3.3.1 solution, we don't need to do this
1397 + if it is in the extra 64KB block of frame buffer memory
1398 + that we ignore (and is not mapped anyway) */
1399 + if (ext.DcCursStOffset < 1024 * vga256InfoRec.videoRam)
1400 + memcpy(ext.cursorPattern,
1401 + (char*)vgaLinearBase + ext.DcCursStOffset, 256);
1404 - /* save standard CRTC registers */
1405 + /* save SoftVGA extended registers */
1406 + outb(vgaIOBase + 4, CrtcVerticalTimingExtension);
1407 + ext.VerticalTimingExtension = inb(vgaIOBase + 5);
1409 - for (i = 0; i < NUM_STD_CRTC_REGS; i++)
1411 - outb(vgaIOBase + 4, i);
1412 - ext.stdCRTCregs[i] = inb(vgaIOBase + 5);
1414 + outb(vgaIOBase + 4, CrtcExtendedAddressControl);
1415 + ext.ExtendedAddressControl = inb(vgaIOBase + 5);
1417 - /* save extended CRTC registers */
1418 + outb(vgaIOBase + 4, CrtcExtendedOffset);
1419 + ext.ExtendedOffset = inb(vgaIOBase + 5);
1421 - for (i = 0; i < NUM_EXT_CRTC_REGS; i++)
1423 - outb(vgaIOBase + 4, 0x40+i);
1424 - ext.extCRTCregs[i] = inb(vgaIOBase + 5);
1426 + outb(vgaIOBase + 4, CrtcExtendedColorControl);
1427 + ext.ExtendedColorControl = inb(vgaIOBase + 5);
1429 - /* save graphics pipeline registers */
1430 + outb(vgaIOBase + 4, CrtcDisplayCompression);
1431 + ext.DisplayCompression = inb(vgaIOBase + 5);
1433 - ext.GpBlitStatus = GX_REG(GP_BLIT_STATUS);
1434 + outb(vgaIOBase + 4, CrtcDriverControl);
1435 + ext.DriverControl = inb(vgaIOBase + 5);
1437 - /* save standard VGA portion */
1438 + outb(vgaIOBase + 4, CrtcDACControl);
1439 + ext.DACControl = inb(vgaIOBase + 5);
1441 + outb(vgaIOBase + 4, CrtcClockControl);
1442 + ext.ClockControl = inb(vgaIOBase + 5);
1444 + outb(vgaIOBase + 4, CrtcClockFrequency);
1445 + ext.CrtClockFrequency = inb(vgaIOBase + 5);
1447 + outb(vgaIOBase + 4, CrtcClockFrequencyFraction);
1448 + ext.CrtClockFrequencyFraction = inb(vgaIOBase + 5);
1450 + outb(vgaIOBase + 4, CrtcRefreshRate);
1451 + ext.RefreshRate = inb(vgaIOBase + 5);
1453 + /* save standard VGA portion */
1455 save = (vgaCYRIXPtr)vgaHWSave((vgaHWPtr)save, sizeof(vgaCYRIXRec));
1458 return ((void *) save);
1461 @@ -869,108 +812,101 @@
1464 DisplayModePtr mode;
1465 -{ int i, mode_index;
1466 - int clock = vga256InfoRec.clock[mode->Clock] / 1000;
1468 - int offset_shift = (vgaBitsPerPixel == 16) ? 2 :
1469 +{ int offset_shift = (vgaBitsPerPixel == 16) ? 2 :
1470 (vgaBitsPerPixel == 8) ? 3 : 4;
1471 int line_offset = vga256InfoRec.displayWidth >> offset_shift;
1473 /* initialize standard VGA portion */
1475 if (!vgaHWInit(mode,sizeof(vgaCYRIXRec)))
1478 - /* search for specified mode in the table */
1479 - /* Need to find the entry with the closest dot clock value */
1480 - /* Assume within at least 200 MHz and then maintain closest natch. */
1484 - for (i = 0; i < NUM_CYRIX_MODES; i++)
1486 - diff = clock - CYRIXmodes[i].clock;
1487 - if (diff < 0) diff = -diff;
1488 - if ((mode->CrtcHDisplay == CYRIXmodes[i].xsize) &&
1489 - (mode->CrtcVDisplay == CYRIXmodes[i].ysize) &&
1497 - /* override standard miscOutput register value */
1499 - newstate->ext.miscOutput = CYRIXmodes[mode_index].miscOutput;
1500 + newstate->std.CRTC[19] = line_offset;
1502 - /* override standard CRTC register values */
1503 + /* initialize SoftVGA extended registers */
1504 + newstate->ext.VerticalTimingExtension =
1505 + ((mode->CrtcVSyncStart & 0x400) >> 4) |
1506 + (((mode->CrtcVDisplay - 1) & 0x400) >> 8) |
1507 + (((mode->CrtcVTotal - 2) & 0x400) >> 10) |
1508 + ((mode->CrtcVSyncStart & 0x400) >> 6);
1510 - for (i = 0; i < NUM_STD_CRTC_REGS; i++)
1512 - newstate->ext.stdCRTCregs[i] =
1513 - CYRIXmodes[mode_index].stdCRTCregs[i];
1516 - /* set extended CRTC registers */
1518 - for (i = 0; i < NUM_EXT_CRTC_REGS; i++)
1520 - newstate->ext.extCRTCregs[i] =
1521 - CYRIXmodes[mode_index].extCRTCregs[i];
1524 - /* override pitch from the mode tables */
1525 - /* (same tables are used for 8BPP and 16BPP) */
1526 + if (vgaBitsPerPixel < 8)
1527 + newstate->ext.ExtendedAddressControl = EAC_DIRECT_FRAME_BUFFER;
1529 + newstate->ext.ExtendedAddressControl = EAC_DIRECT_FRAME_BUFFER |
1530 + EAC_PACKED_CHAIN4;
1532 - newstate->ext.stdCRTCregs[19] = line_offset;
1533 - newstate->ext.extCRTCregs[5] = ((line_offset >> 8) & 0x03);
1534 + newstate->ext.ExtendedOffset = ((line_offset >> 8) & 0x03);
1536 - /* override color control from the mode tables */
1537 - /* (same tables are used for 8BPP and 16BPP) */
1538 + newstate->ext.ExtendedColorControl = (vgaBitsPerPixel == 16)
1539 + ? ECC_16BPP | ECC_565_FORMAT
1542 + /* display compression is set using the DC registers */
1543 + newstate->ext.DisplayCompression = 0x00;
1545 + /* we drive the palette through the display controller (in new
1546 + chipsets only) in 8bpp and 16bpp (that is, whenever the
1547 + hardware cursor is used). */
1548 + if (vgaBitsPerPixel < 8)
1549 + newstate->ext.DriverControl = 0x00;
1551 + newstate->ext.DriverControl = DRVCT_DISPLAY_DRIVER_ACTIVE;
1553 - newstate->ext.extCRTCregs[6] = (vgaBitsPerPixel == 16)
1554 - ? ECC_16BPP | ECC_565_FORMAT : ECC_8BPP;
1555 + /* set `16 bit bus' or else compression will hang the
1556 + system in 16bpp mode */
1557 + if (vgaBitsPerPixel == 16)
1558 + newstate->ext.DACControl = DACCT_ENABLE_16BIT_BUS;
1560 + newstate->ext.DACControl = 0;
1562 - /* enable display compression when appropriate */
1564 - if (CYRIXvsaversion == CYRIX_VSA1)
1566 - /* For VSA1, SoftVGA manages the compression buffer. */
1567 - /* Enabling compression directly causes unpredictable results. */
1568 - /* Only enable if not panning (there is a bug in SoftVGA that */
1569 - /* will put the compression buffer in the wrong place when */
1570 - /* using a virtual desktop. */
1571 - /* By setting bit 0 of register 0x49, SoftVGA will enable */
1572 - /* compression whenever possible, based on memory available */
1573 - /* and starting address of memory. */
1575 - if ((mode->CrtcVDisplay == vga256InfoRec.virtualY) &&
1576 - (mode->CrtcHDisplay == vga256InfoRec.virtualX))
1578 - newstate->ext.extCRTCregs[9] = 0x01;
1579 - ErrorF("%s %s: Display compression enabled.\n",
1580 - XCONFIG_PROBED, vga256InfoRec.name);
1584 - ErrorF("%s %s: Display compression disabled.\n",
1585 - XCONFIG_PROBED, vga256InfoRec.name);
1587 + if (newstate->std.NoClock >= 0)
1588 + { int entier_clock = (vga256InfoRec.clock[mode->Clock] / 1000);
1589 + int clock_fraction = (vga256InfoRec.clock[mode->Clock] / 100)
1590 + - (entier_clock * 10);
1592 + newstate->ext.ClockControl = CLKCT_EXT_CLOCK_MODE;
1593 + newstate->ext.CrtClockFrequency = entier_clock;
1594 + newstate->ext.CrtClockFrequencyFraction = clock_fraction;
1595 + newstate->ext.RefreshRate = 0 /* relevant to VGA BIOS only */;
1599 + /* initialize masked contents of display controller
1600 + hardware registers. */
1601 + newstate->ext.DcCursStOffset = CYRIXcursorAddress;
1602 + newstate->ext.DcCbStOffset = CYRIXcbufferAddress;
1603 + newstate->ext.DcLineDelta = CYRIXcbLineDelta << 12;
1604 + newstate->ext.DcBufSize = 0x41 << 9;
1605 + newstate->ext.DcCursorX = 0;
1606 + newstate->ext.DcCursorY = 0;
1607 + newstate->ext.DcCursorColor = 0;
1609 + /* Compression is enabled only when a buffer was allocated by
1610 + FbInit and provided that the displayed screen is the virtual
1611 + screen. If the line delta is not 1024 or 2048, entire frames
1612 + will be flagged dirty as opposed to lines. Problems with 16bpp
1613 + and line-dirty flagging seem to have been solved now. */
1614 + if (CYRIXcbLineDelta != 0 &&
1615 + mode->CrtcVDisplay == vga256InfoRec.virtualY &&
1616 + mode->CrtcHDisplay == vga256InfoRec.virtualX)
1617 + { newstate->ext.DcGeneralCfg = DC_GCFG_DECE
1619 + if (/* vgaBitsPerPixel != 8 || -- this is OK now */
1620 + (vga256InfoRec.displayWidth * (vgaBitsPerPixel / 8)) & 0x03FF)
1621 + newstate->ext.DcGeneralCfg |= DC_GCFG_FDTY;
1625 - /* ### TO DO ### */
1626 - /* Enable display compression directly for VSA2. */
1627 - /* For VSA2, the display driver manages all graphics memory. */
1629 + newstate->ext.DcGeneralCfg = 0;
1631 - /* initialize the graphics pipeline registers */
1633 + /* initialize the graphics pipeline registers */
1634 newstate->ext.GpBlitStatus = ((vga256InfoRec.displayWidth == 2048) ?
1635 BC_FB_WIDTH_2048 : BC_FB_WIDTH_1024) |
1636 ((vgaBitsPerPixel == 16) ?
1637 BC_16BPP : BC_8BPP);
1643 @@ -978,68 +914,31 @@
1646 { int Base = (y * vga256InfoRec.displayWidth + x);
1647 - unsigned long active, sync, count1, count2;
1649 if (vgaBitsPerPixel > 8) Base *= (vgaBitsPerPixel / 8);
1650 if (vgaBitsPerPixel < 8) Base /= 2;
1652 - /* wait until out of active display area */
1654 - active = GX_REG(DC_V_TIMING_1) & 0x07FF;
1655 - sync = GX_REG(DC_V_TIMING_3) & 0x07FF;
1659 - /* read twice to avoid transition values */
1661 - count1 = GX_REG(DC_V_LINE_CNT) & 0x07FF;
1662 - count2 = GX_REG(DC_V_LINE_CNT) & 0x07FF;
1663 - } while ((count1 != count2) || (count1 < active) || (count1 >= sync));
1665 - /* load the start address directly */
1667 + /* doing this using the SoftVGA registers does not work reliably */
1668 GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
1669 GX_REG(DC_FB_ST_OFFSET) = Base;
1670 GX_REG(DC_UNLOCK) = 0;
1673 -/*------------------------------------------------------------------------*\
1676 -** From README file: "The ValidMode() function is required. It is used to
1677 -** check for any chipset dependent reasons why a graphics mode might not be
1678 -** valid. It gets called by higher levels of the code after the Probe()
1679 -** stage. In many cases no special checking will be required and this
1680 -** function will simply return TRUE always."
1682 -** For the Cyrix driver, this routine loops through modes provided in a
1683 -** table at the beginning of this file and returns OK if it finds a match.
1684 -** These tables were required to make the standard VESA 60 Hz and 75 Hz
1685 -** modes work correctly. Doing this, however, takes away the flexibility
1686 -** of adding different resolutions or different refresh rates to the
1687 -** XF86Config file.
1688 -\*------------------------------------------------------------------------*/
1691 CYRIXValidMode(mode, verbose, flag)
1692 DisplayModePtr mode;
1698 - /* loop through table of modes */
1700 - for (i = 0; i < NUM_CYRIX_MODES; i++)
1702 - if ((mode->CrtcHDisplay == CYRIXmodes[i].xsize) &&
1703 - (mode->CrtcVDisplay == CYRIXmodes[i].ysize))
1707 +{ /* note (avg): there seems to be a lot more to this if you look
1708 + at the GGI code (adjustment). */
1709 + if (mode->CrtcHSyncStart - mode->CrtcHDisplay >= 24 ||
1710 + mode->CrtcHSyncStart - mode->CrtcHDisplay <= 8)
1712 + ErrorF("%s %s: mode %s: horizontal sync out of range (sync - display should be between 8 and 24)\n",
1713 + XCONFIG_PROBED, vga256InfoRec.name, mode->name
1715 + return MODE_HSYNC;
1723 diff -ruN XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/gxrender.c XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/gxrender.c
1724 --- XFree86-3.3.5/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/gxrender.c Thu Jun 24 01:59:41 1999
1725 +++ XFree86-3.3.3.1/xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/gxrender.c Wed Dec 31 19:00:00 1969
1727 -/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cyrix/gxrender.c,v 1.1.2.1 1999/06/24 05:59:41 hohndel Exp $ */
1729 -//---------------------------------------------------------------------------
1732 -// This file gives examples of using the MediaGX graphics unit to provide
1733 -// acceleration for 2D display drivers. It is intended to provide an
1734 -// absraction layer for new display driver development. This code handles
1735 -// the quirks of the MediaGX graphics unit to allow faster developemt times
1736 -// for new drivers.
1737 -//---------------------------------------------------------------------------
1740 -/* GRAPHICS PIPELINE REGISTER DEFINITIONS */
1742 -#define GP_DST_XCOOR 0x8100 /* x destination origin */
1743 -#define GP_DST_YCOOR 0x8102 /* y destination origin */
1744 -#define GP_WIDTH 0x8104 /* pixel width */
1745 -#define GP_HEIGHT 0x8106 /* pixel height */
1746 -#define GP_SRC_XCOOR 0x8108 /* x source origin */
1747 -#define GP_SRC_YCOOR 0x810A /* y source origin */
1749 -#define GP_VECTOR_LENGTH 0x8104 /* vector length */
1750 -#define GP_INIT_ERROR 0x8106 /* vector initial error */
1751 -#define GP_AXIAL_ERROR 0x8108 /* axial error increment */
1752 -#define GP_DIAG_ERROR 0x810A /* diagonal error increment */
1754 -#define GP_SRC_COLOR_0 0x810C /* source color 0 */
1755 -#define GP_SRC_COLOR_1 0x810E /* source color 1 */
1756 -#define GP_PAT_COLOR_0 0x8110 /* pattern color 0 */
1757 -#define GP_PAT_COLOR_1 0x8112 /* pattern color 1 */
1758 -#define GP_PAT_COLOR_2 0x8114 /* pattern color 2 */
1759 -#define GP_PAT_COLOR_3 0x8116 /* pattern color 3 */
1760 -#define GP_PAT_DATA_0 0x8120 /* bits 31:0 of pattern */
1761 -#define GP_PAT_DATA_1 0x8124 /* bits 63:32 of pattern */
1762 -#define GP_PAT_DATA_2 0x8128 /* bits 95:64 of pattern */
1763 -#define GP_PAT_DATA_3 0x812C /* bits 127:96 of pattern */
1765 -#define GP_RASTER_MODE 0x8200 /* raster operation */
1766 -#define GP_VECTOR_MODE 0x8204 /* vector mode register */
1767 -#define GP_BLIT_MODE 0x8208 /* blit mode register */
1768 -#define GP_BLIT_STATUS 0x820C /* blit status register */
1770 -/* "GP_VECTOR_MODE" BIT DEFINITIONS */
1772 -#define VM_X_MAJOR 0x0000 /* X major vector */
1773 -#define VM_Y_MAJOR 0x0001 /* Y major vector */
1774 -#define VM_MAJOR_INC 0x0002 /* positive major axis step */
1775 -#define VM_MINOR_INC 0x0004 /* positive minor axis step */
1776 -#define VM_READ_DST_FB 0x0008 /* read destination data */
1778 -/* "GP_RASTER_MODE" BIT DEFINITIONS */
1780 -#define RM_PAT_DISABLE 0x0000 /* pattern is disabled */
1781 -#define RM_PAT_MONO 0x0100 /* 1BPP pattern expansion */
1782 -#define RM_PAT_DITHER 0x0200 /* 2BPP pattern expansion */
1783 -#define RM_PAT_COLOR 0x0300 /* 8BPP or 16BPP pattern */
1784 -#define RM_PAT_MASK 0x0300 /* mask for pattern mode */
1785 -#define RM_PAT_TRANSPARENT 0x0400 /* transparent 1BPP pattern */
1786 -#define RM_SRC_TRANSPARENT 0x0800 /* transparent 1BPP source */
1788 -/* "GP_BLIT_STATUS" BIT DEFINITIONS */
1790 -#define BS_BLIT_BUSY 0x0001 /* blit engine is busy */
1791 -#define BS_PIPELINE_BUSY 0x0002 /* graphics pipeline is bus */
1792 -#define BS_BLIT_PENDING 0x0004 /* blit pending */
1793 -#define BC_8BPP 0x0000 /* 8BPP mode */
1794 -#define BC_16BPP 0x0100 /* 16BPP mode */
1795 -#define BC_FB_WIDTH_1024 0x0000 /* framebuffer width = 1024 */
1796 -#define BC_FB_WIDTH_2048 0x0200 /* framebuffer width = 2048 */
1798 -/* "GP_BLIT_MODE" BIT DEFINITIONS */
1800 -#define BM_READ_SRC_NONE 0x0000 /* source foreground color */
1801 -#define BM_READ_SRC_FB 0x0001 /* read source from FB */
1802 -#define BM_READ_SRC_BB0 0x0002 /* read source from BB0 */
1803 -#define BM_READ_SRC_BB1 0x0003 /* read source from BB1 */
1804 -#define BM_READ_SRC_MASK 0x0003 /* read source mask */
1806 -#define BM_READ_DST_NONE 0x0000 /* no destination data */
1807 -#define BM_READ_DST_BB0 0x0008 /* destination from BB0 */
1808 -#define BM_READ_DST_BB1 0x000C /* destination from BB1 */
1809 -#define BM_READ_DST_FB0 0x0010 /* dest from FB (store BB0) */
1810 -#define BM_READ_DST_FB1 0x0014 /* dest from FB (store BB1)*/
1811 -#define BM_READ_DST_MASK 0x001C /* read destination mask */
1813 -#define BM_WRITE_FB 0x0000 /* write to framebuffer */
1814 -#define BM_WRITE_MEM 0x0020 /* write to memory */
1815 -#define BM_WRITE_MASK 0x0020 /* write mask */
1817 -#define BM_SOURCE_COLOR 0x0000 /* source is 8BPP or 16BPP */
1818 -#define BM_SOURCE_EXPAND 0x0040 /* source is 1BPP */
1819 -#define BM_SOURCE_TEXT 0x00C0 /* source is 1BPP text */
1820 -#define BM_SOURCE_MASK 0x00C0 /* source mask */
1822 -#define BM_REVERSE_Y 0x0100 /* reverse Y direction */
1824 -/* THE DRIVER NEEDS TO MAINTAIN THE SIZE AND LOCATION OF THE BLT BUFFERS
1825 -// These constants will work with 2K or 3K config, 8 or 16 BPP. The driver
1826 -// should set them, however, to optimize for the current config. Otherwise
1827 -// screen to screen BLTs, for example, may be visibly split into two vertical
1828 -// sections when they do not need to be.
1831 -/* STATIC VARIABLES FOR GXRENDER.C FILE */
1833 -unsigned char *GXRregptr;
1834 -unsigned short GXRbpp;
1835 -unsigned short GXRbb0Base;
1836 -unsigned short GXRbb1Base;
1837 -unsigned short GXRbufferWidthPixels;
1839 -unsigned short GXRpatternFlags;
1840 -unsigned short GXRsourceFlags;
1841 -unsigned short GXRsavedColor;
1842 -unsigned short GXRsavedRop;
1843 -unsigned short GXRusesDstData;
1845 -/* MACROS FOR REGISTER ACCESS
1846 -// These macros asssume that a pointer was specified during initialization.
1847 -// They also assume 32-bit access is possible (16-bit access such as for
1848 -// Windows 98 display drivers would require different macros).
1851 -#define WRITE_REG8(offset, value) \
1852 - (*(volatile unsigned char *)(GXRregptr + (offset))) = (value)
1854 -#define WRITE_REG16(offset, value) \
1855 - (*(volatile unsigned short *)(GXRregptr + (offset))) = (value)
1857 -#define WRITE_REG32(offset, value) \
1858 - (*(volatile unsigned long *)(GXRregptr + (offset))) = (value)
1860 -#define READ_REG16(offset) \
1861 - (*(volatile unsigned short *)(GXRregptr + (offset)))
1863 -#define READ_REG32(offset) \
1864 - (*(volatile unsigned long *)(GXRregptr + (offset)))
1867 -//---------------------------------------------------------------------------
1870 -// This routine initializes the parameters for the current configuration.
1872 -// REGPTR pointer to GX memory mapped registers
1873 -// BPP bits per pixel (8 pr 16)
1875 -//---------------------------------------------------------------------------
1878 -void gxr_initialize(unsigned char *regptr, unsigned short bpp,
1879 - unsigned short BB0base, unsigned short BB1base,
1880 - unsigned short BBwidthPixels)
1882 - GXRregptr = regptr;
1884 - GXRbb0Base = BB0base;
1885 - GXRbb1Base = BB1base;
1886 - GXRbufferWidthPixels = BBwidthPixels;
1890 -//---------------------------------------------------------------------------
1891 -// GXR_WAIT_UNTIL_IDLE
1893 -// This routine waits until the graphics engine is idle.
1894 -//---------------------------------------------------------------------------
1897 -void gxr_wait_until_idle(void)
1899 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_BUSY);
1903 -//---------------------------------------------------------------------------
1904 -// GXR_LOAD_SOLID_SOURCE
1906 -// This routine is used to specify a solid source color. For the Xfree96
1907 -// display driver, the source color is used to specify a planemask and the
1908 -// ROP is adjusted accordingly.
1909 -//---------------------------------------------------------------------------
1912 -void gxr_load_solid_source(unsigned short color)
1914 - /* CLEAR TRANSPARENCY FLAG */
1916 - GXRsourceFlags = 0;
1918 - /* FORMAT 8 BPP COLOR */
1919 - /* GX requires 8BPP color data be duplicated into bits [15:8]. */
1921 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
1924 - color |= (color << 8);
1927 - /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */
1929 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
1930 - WRITE_REG16(GP_SRC_COLOR_0, color);
1934 -//---------------------------------------------------------------------------
1935 -// GXR_LOAD_MONO_SOURCE
1937 -// This routine is used to specify the monochrome source colors.
1938 -//---------------------------------------------------------------------------
1941 -void gxr_load_mono_source(unsigned short bgcolor, unsigned short fgcolor,
1942 - unsigned short transparent)
1944 - /* SET TRANSPARENCY FLAG */
1946 - GXRsourceFlags = transparent ? RM_SRC_TRANSPARENT : 0;
1948 - /* FORMAT 8 BPP COLOR */
1949 - /* GX requires 8BPP color data be duplicated into bits [15:8]. */
1951 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
1953 - bgcolor &= 0x00FF;
1954 - bgcolor |= (bgcolor << 8);
1955 - fgcolor &= 0x00FF;
1956 - fgcolor |= (fgcolor << 8);
1959 - /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */
1961 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
1962 - WRITE_REG16(GP_SRC_COLOR_0, bgcolor);
1963 - WRITE_REG16(GP_SRC_COLOR_1, fgcolor);
1967 -//---------------------------------------------------------------------------
1968 -// GXR_LOAD_SOLID_PATTERN
1970 -// This routine is used to specify a solid pattern color. It is called
1971 -// before performing solid rectangle fills or more complicated BLTs that
1972 -// use a solid pattern color.
1974 -// The driver should always call "gxr_load_raster_operation" after a call
1975 -// to this routine to make sure that the pattern flags are set appropriately.
1976 -//---------------------------------------------------------------------------
1979 -void gxr_load_solid_pattern(unsigned short color)
1981 - /* SET PATTERN FLAGS */
1983 - GXRpatternFlags = 0;
1985 - /* FORMAT 8 BPP COLOR */
1986 - /* GX requires 8BPP color data be duplicated into bits [15:8]. */
1988 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
1991 - color |= (color << 8);
1994 - /* SAVE THE REFORMATTED COLOR FOR LATER */
1995 - /* Used to call the "gxr_solid_fill" routine for special cases. */
1997 - GXRsavedColor = color;
1999 - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
2001 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2002 - WRITE_REG16(GP_PAT_COLOR_0, color);
2006 -//---------------------------------------------------------------------------
2007 -// GXR_LOAD_MONO_PATTERN
2009 -// This routine is used to specify a monochrome pattern.
2010 -//---------------------------------------------------------------------------
2013 -void gxr_load_mono_pattern(unsigned short bgcolor, unsigned short fgcolor,
2014 - unsigned long data0, unsigned long data1, unsigned char transparent)
2016 - /* SET PATTERN FLAGS */
2018 - GXRpatternFlags = transparent ? RM_PAT_MONO | RM_PAT_TRANSPARENT :
2021 - /* FORMAT 8 BPP COLOR */
2022 - /* GX requires 8BPP color data be duplicated into bits [15:8]. */
2024 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
2026 - bgcolor &= 0x00FF;
2027 - bgcolor |= (bgcolor << 8);
2028 - fgcolor &= 0x00FF;
2029 - fgcolor |= (fgcolor << 8);
2032 - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */
2034 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2035 - WRITE_REG16(GP_PAT_COLOR_0, bgcolor);
2036 - WRITE_REG16(GP_PAT_COLOR_1, fgcolor);
2037 - WRITE_REG32(GP_PAT_DATA_0, data0);
2038 - WRITE_REG32(GP_PAT_DATA_1, data1);
2042 -//---------------------------------------------------------------------------
2043 -// GXR_LOAD_RASTER_OPERATION
2045 -// This routine loads the specified raster operation. It sets the pattern
2046 -// flags appropriately.
2047 -//---------------------------------------------------------------------------
2050 -void gxr_load_raster_operation(unsigned char rop)
2052 - unsigned short rop16;
2054 - /* GENERATE 16-BIT VERSION OF ROP WITH PATTERN FLAGS */
2056 - rop16 = (unsigned short) rop | GXRpatternFlags;
2057 - if ((rop & 0x33) ^ ((rop >> 2) & 0x33))
2058 - rop16 |= GXRsourceFlags;
2060 - /* SAVE ROP FOR LATER COMPARISONS */
2061 - /* Need to have the pattern flags included */
2063 - GXRsavedRop = rop16;
2065 - /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */
2066 - /* True if even bits (0:2:4:6) do not equal the correspinding */
2067 - /* even bits (1:3:5:7). */
2069 - GXRusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55));
2071 - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */
2072 - /* Only one operation can be pending at a time. */
2074 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2075 - WRITE_REG16(GP_RASTER_MODE, rop16);
2079 -//---------------------------------------------------------------------------
2082 -// This routine MUST be used when performing a solid rectangle fill with
2083 -// the ROPs of PATCOPY (0xF0), BLACKNESS (0x00), WHITENESS (0xFF), or
2084 -// PATINVERT (0x0F). There is a bug in GXm for these cases that requires a
2087 -// For BLACKNESS (ROP = 0x00), set the color to 0x0000.
2088 -// For WHITENESS (ROP = 0xFF), set the color to 0xFFFF.
2089 -// For PATINVERT (ROP = 0x0F), invert the desired color.
2091 -// X screen X position (left)
2092 -// Y screen Y position (top)
2093 -// WIDTH width of rectangle, in pixels
2094 -// HEIGHT height of rectangle, in scanlines
2095 -// COLOR fill color
2097 -// THIS ROUTINE SHOULD NOT BE DIRECTLY CALLED FROM THE DRIVER. The driver
2098 -// should always use gxr_pattern_fill and let that routine call this one
2099 -// when approipriate. This is to hide quirks specific to MediaGX hardware.
2100 -//---------------------------------------------------------------------------
2103 -void gxr_solid_fill(unsigned short x, unsigned short y,
2104 - unsigned short width, unsigned short height, unsigned short color)
2106 - unsigned short section;
2108 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2109 - /* Only one operation can be pending at a time. */
2111 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2113 - /* SET REGISTERS TO DRAW RECTANGLE */
2115 - WRITE_REG16(GP_DST_XCOOR, x);
2116 - WRITE_REG16(GP_DST_YCOOR, y);
2117 - WRITE_REG16(GP_HEIGHT, height);
2118 - WRITE_REG16(GP_RASTER_MODE, 0x00F0); /* PATCOPY */
2119 - WRITE_REG16(GP_PAT_COLOR_0, color);
2121 - /* CHECK WIDTH FOR GX BUG WORKAROUND */
2125 - /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */
2127 - WRITE_REG16(GP_WIDTH, width);
2128 - WRITE_REG16(GP_BLIT_MODE, 0);
2132 - /* DRAW FIRST PART OF RECTANGLE */
2133 - /* Get to a 16 pixel boundary. */
2135 - section = 0x10 - (x & 0x0F);
2136 - WRITE_REG16(GP_WIDTH, section);
2137 - WRITE_REG16(GP_BLIT_MODE, 0);
2139 - /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */
2141 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2142 - WRITE_REG16(GP_DST_XCOOR, x + section);
2143 - WRITE_REG16(GP_DST_YCOOR, y);
2144 - WRITE_REG16(GP_WIDTH, width - section);
2145 - WRITE_REG16(GP_BLIT_MODE, 0);
2150 -//----------------------------------------------------------------------------
2151 -// GXR_PATTERN_FILL
2153 -// This routine is used to fill a rectangular region. The pattern must
2154 -// be previously loaded using one of gxr_load_*_pattern routines. Also, the
2155 -// raster operation must be previously specified using the
2156 -// "gxr_load_raster_operation" routine.
2158 -// X screen X position (left)
2159 -// Y screen Y position (top)
2160 -// WIDTH width of rectangle, in pixels
2161 -// HEIGHT height of rectangle, in scanlines
2162 -//----------------------------------------------------------------------------
2165 -void gxr_pattern_fill(unsigned short x, unsigned short y,
2166 - unsigned short width, unsigned short height)
2168 - unsigned short section, buffer_width, blit_mode;
2170 - /* CHECK IF OPTIMIZED SOLID CASES */
2171 - /* Check all 16 bits of the ROP to include solid pattern flags. */
2173 - switch(GXRsavedRop)
2175 - /* CHECK FOR SPECIAL CASES WITHOUT DESTINATION DATA */
2176 - /* Need hardware workaround for fast "burst write" cases. */
2179 - gxr_solid_fill(x, y, width, height, GXRsavedColor);
2182 - gxr_solid_fill(x, y, width, height, ~GXRsavedColor);
2185 - gxr_solid_fill(x, y, width, height, 0x0000);
2188 - gxr_solid_fill(x, y, width, height, 0xFFFF);
2191 - /* REMAINING CASES REQUIRE DESTINATION DATA OR NOT SOLID COLOR */
2195 - /* DETERMINE BLT MODE VALUE */
2196 - /* Still here for non-solid patterns without destination data. */
2198 - blit_mode = GXRusesDstData ? BM_READ_DST_FB0 : 0;
2200 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2201 - /* Write the registers that do not change for each section. */
2203 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2204 - WRITE_REG16(GP_HEIGHT, height);
2206 - /* SINCE ONLY DESTINATION DATA, WE CAN USE BOTH BB0 AND BB1. */
2207 - /* Therefore, width available = BLT buffer width * 2. */
2209 - buffer_width = GXRbufferWidthPixels << 1;
2211 - /* REPEAT UNTIL FINISHED WITH RECTANGLE */
2212 - /* Perform BLT in vertical sections, as wide as the BLT buffer */
2213 - /* allows. Hardware does not split the operations, so */
2214 - /* software must do it to avoid large scanlines that would */
2215 - /* overflow the BLT buffers. */
2219 - /* DETERMINE WIDTH OF SECTION */
2221 - if (width > buffer_width) section = buffer_width;
2222 - else section = width;
2224 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2226 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2227 - WRITE_REG16(GP_DST_XCOOR, x);
2228 - WRITE_REG16(GP_DST_YCOOR, y);
2229 - WRITE_REG16(GP_WIDTH, section);
2230 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2232 - /* ADJUST PARAMETERS FOR NEXT SECTION */
2242 -//----------------------------------------------------------------------------
2243 -// SCREEN TO SCREEN BLT
2245 -// This routine should be used to perform a screen to screen BLT when the
2246 -// ROP does not require destination data.
2248 -// SRCX screen X position to copy from
2249 -// SRCY screen Y position to copy from
2250 -// DSTX screen X position to copy to
2251 -// DSTY screen Y position to copy to
2252 -// WIDTH width of rectangle, in pixels
2253 -// HEIGHT height of rectangle, in scanlines
2254 -//----------------------------------------------------------------------------
2257 -void gxr_screen_to_screen_blt(unsigned short srcx, unsigned short srcy,
2258 - unsigned short dstx, unsigned short dsty, unsigned short width,
2259 - unsigned short height)
2261 - unsigned short section, buffer_width;
2262 - unsigned short blit_mode;
2264 - /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */
2266 - blit_mode = GXRusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB :
2269 - /* CHECK Y DIRECTION */
2270 - /* Hardware has support for negative Y direction. */
2274 - blit_mode |= BM_REVERSE_Y;
2275 - srcy += height - 1;
2276 - dsty += height - 1;
2279 - /* CHECK X DIRECTION */
2280 - /* Hardware does not support negative X direction since at the time */
2281 - /* of development all supported resolutions could fit a scanline of */
2282 - /* data at once into the BLT buffers (using both BB0 and BB1). This */
2283 - /* code is more generic to allow for any size BLT buffer. */
2291 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2292 - /* Write the registers that do not change for each section. */
2294 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2295 - WRITE_REG16(GP_HEIGHT, height);
2297 - /* CHECK AVAILABLE BLT BUFFER SIZE */
2298 - /* Can use both BLT buffers if no destination data is required. */
2300 - buffer_width = GXRusesDstData ? GXRbufferWidthPixels :
2301 - GXRbufferWidthPixels << 1;
2303 - /* REPEAT UNTIL FINISHED WITH RECTANGLE */
2304 - /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */
2305 - /* Hardware does not split the operations, so software must do it to */
2306 - /* avoid large scanlines that would overflow the BLT buffers. */
2310 - /* CHECK WIDTH OF CURRENT SECTION */
2312 - if (width > buffer_width) section = buffer_width;
2313 - else section = width;
2315 - /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */
2317 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2318 - WRITE_REG16(GP_SRC_YCOOR, srcy);
2319 - WRITE_REG16(GP_DST_YCOOR, dsty);
2320 - WRITE_REG16(GP_WIDTH, section);
2322 - /* CHECK X DIRECTION */
2326 - /* NEGATIVE X DIRECTION */
2327 - /* Still positive X direction within the section. */
2331 - WRITE_REG16(GP_SRC_XCOOR, srcx);
2332 - WRITE_REG16(GP_DST_XCOOR, dstx);
2333 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2337 - /* POSITIVE X DIRECTION */
2339 - WRITE_REG16(GP_SRC_XCOOR, srcx);
2340 - WRITE_REG16(GP_DST_XCOOR, dstx);
2341 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2350 -//----------------------------------------------------------------------------
2351 -// SCREEN TO SCREEN TRANSPARENT BLT
2353 -// This routine should be used to perform a screen to screen BLT when a
2354 -// specified color should by transparent. The only supported ROP is SRCCOPY.
2356 -// SRCX screen X position to copy from
2357 -// SRCY screen Y position to copy from
2358 -// DSTX screen X position to copy to
2359 -// DSTY screen Y position to copy to
2360 -// WIDTH width of rectangle, in pixels
2361 -// HEIGHT height of rectangle, in scanlines
2362 -// COLOR transparent color
2363 -//----------------------------------------------------------------------------
2366 -void gxr_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy,
2367 - unsigned short dstx, unsigned short dsty, unsigned short width,
2368 - unsigned short height, unsigned short color)
2370 - unsigned short section, buffer_width;
2371 - unsigned short blit_mode = BM_READ_SRC_FB;
2374 - /* CHECK Y DIRECTION */
2375 - /* Hardware has support for negative Y direction. */
2379 - blit_mode |= BM_REVERSE_Y;
2380 - srcy += height - 1;
2381 - dsty += height - 1;
2384 - /* CHECK X DIRECTION */
2385 - /* Hardware does not support negative X direction since at the time */
2386 - /* of development all supported resolutions could fit a scanline of */
2387 - /* data at once into the BLT buffers (using both BB0 and BB1). This */
2388 - /* code is more generic to allow for any size BLT buffer. */
2396 - /* CALCULATE BLT BUFFER SIZE */
2397 - /* Need to use BB1 to store the BLT buffer data. */
2399 - buffer_width = GXRbufferWidthPixels;
2401 - /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */
2403 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
2406 - color |= (color << 8);
2409 - /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */
2410 - /* Need to make sure any previous BLT using BB1 is complete. */
2412 - while(READ_REG16(GP_BLIT_STATUS) & BS_PIPELINE_BUSY);
2413 - for (i = 0; i < 16; i+=2)
2415 - WRITE_REG16(GXRbb1Base+i, color);
2418 - /* DO BOGUS BLT TO LATCH DATA FROM BB1 */
2419 - /* Already know graphics pipeline is idle. */
2421 - WRITE_REG32(GP_DST_XCOOR, 0);
2422 - WRITE_REG32(GP_SRC_XCOOR, 0);
2423 - WRITE_REG16(GP_WIDTH, 16);
2424 - WRITE_REG16(GP_HEIGHT, 1);
2425 - WRITE_REG16(GP_RASTER_MODE, 0x00CC);
2426 - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1);
2428 - /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */
2430 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2431 - WRITE_REG16(GP_HEIGHT, height);
2432 - WRITE_REG16(GP_RASTER_MODE, 0x10C6);
2433 - WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF);
2435 - /* REPEAT UNTIL FINISHED WITH RECTANGLE */
2436 - /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */
2437 - /* Hardware does not split the operations, so software must do it to */
2438 - /* avoid large scanlines that would overflow the BLT buffers. */
2442 - /* CHECK WIDTH OF CURRENT SECTION */
2444 - if (width > buffer_width) section = buffer_width;
2445 - else section = width;
2447 - /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */
2449 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2450 - WRITE_REG16(GP_SRC_YCOOR, srcy);
2451 - WRITE_REG16(GP_DST_YCOOR, dsty);
2452 - WRITE_REG16(GP_WIDTH, section);
2454 - /* CHECK X DIRECTION */
2455 - /* Again, this must be done in software, and can be removed if the */
2456 - /* display driver knows that the BLT buffers will always be large */
2457 - /* enough to contain an entire scanline of a screen to screen BLT. */
2461 - /* NEGATIVE X DIRECTION */
2462 - /* Still positive X direction within the section. */
2466 - WRITE_REG16(GP_SRC_XCOOR, srcx);
2467 - WRITE_REG16(GP_DST_XCOOR, dstx);
2468 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2472 - /* POSITIVE X DIRECTION */
2474 - WRITE_REG16(GP_SRC_XCOOR, srcx);
2475 - WRITE_REG16(GP_DST_XCOOR, dstx);
2476 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2485 -//----------------------------------------------------------------------------
2486 -// COLOR BITMAP TO SCREEN BLT
2488 -// This routine transfers color bitmap data to the screen. For most cases,
2489 -// when the ROP is SRCCOPY, it may be faster to write a separate routine that
2490 -// copies the data to the frame buffer directly. This routine should be
2491 -// used when the ROP requires destination data.
2493 -// Transparency is handled by another routine.
2495 -// SRCX X offset within source bitmap
2496 -// SRCY Y offset within source bitmap
2497 -// DSTX screen X position to render data
2498 -// DSTY screen Y position to render data
2499 -// WIDTH width of rectangle, in pixels
2500 -// HEIGHT height of rectangle, in scanlines
2501 -// *DATA pointer to bitmap data
2502 -// PITCH pitch of bitmap data (bytes between scanlines)
2503 -// ROP ternary raster operation (0x00-0xFF).
2504 -//----------------------------------------------------------------------------
2507 -void gxr_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy,
2508 - unsigned short dstx, unsigned short dsty, unsigned short width,
2509 - unsigned short height, unsigned char *data, unsigned short pitch,
2510 - unsigned char rop)
2512 - unsigned short section, buffer_width;
2513 - unsigned short blit_mode = BM_READ_SRC_BB0;
2514 - unsigned short line_srcx, line_dstx, line_width;
2515 - unsigned short offset, i;
2517 - /* CHECK IF ROP REQUIRES DESTINATION DATA */
2518 - /* Even bits (0:2:4:6) do not equal corresponding odd bits (1:3:5:7). */
2520 - if ((rop & 0x55) ^ ((rop >> 1) & 0x55))
2521 - blit_mode |= BM_READ_DST_FB1;
2523 - /* CHECK SIZE OF BLT BUFFER */
2525 - buffer_width = GXRbufferWidthPixels;
2527 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2528 - /* Write the registers that do not change for each section. */
2530 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2531 - WRITE_REG16(GP_HEIGHT, 1);
2532 - WRITE_REG16(GP_RASTER_MODE, (unsigned short) rop & 0x00FF);
2534 - /* REPEAT FOR EACH SCANLINE */
2536 - offset = srcy * pitch;
2540 - line_width = width;
2544 - while(line_width > 0)
2546 - /* CHECK WIDTH OF CURRENT SECTION */
2548 - if (line_width > buffer_width) section = buffer_width;
2549 - else section = line_width;
2551 - /* TRANSFER SCANLINE OF BITMAP DATA TO BLT BUFFER 0 */
2552 - /* Need to wait for BS_PIPELINE_BUSY to make sure that the */
2553 - /* data in BB0 for the previous scanline is no longer used. */
2554 - /* This can be heavily optimized to not do a byte at a time. */
2556 - while(READ_REG16(GP_BLIT_STATUS) & BS_PIPELINE_BUSY);
2557 - if (READ_REG16(GP_BLIT_STATUS) & BC_16BPP)
2559 - for (i = 0; i < section; i++)
2561 - WRITE_REG16(GXRbb0Base+i, data[offset+((line_srcx+i)<<1)]);
2566 - for (i = 0; i < section; i++)
2568 - WRITE_REG8(GXRbb0Base+i, data[line_srcx+offset+i]);
2572 - /* RENDER FROM BB0 TO FRAME BUFFER */
2574 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2575 - WRITE_REG16(GP_DST_XCOOR, line_dstx);
2576 - WRITE_REG16(GP_DST_YCOOR, dsty);
2577 - WRITE_REG16(GP_WIDTH, section);
2578 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2580 - line_width -= section;
2581 - line_dstx += section;
2582 - line_srcx += section;
2591 -//----------------------------------------------------------------------------
2592 -// COLOR BITMAP TO SCREEN TRANSPARENT BLT
2594 -// This routine transfers color bitmap data to the screen with transparency.
2595 -// The transparent color is specified. The only supported ROP is SRCCOPY,
2596 -// meaning that transparency cannot be applied if the ROP requires
2597 -// destination data (this is a hardware restriction).
2599 -// SRCX X offset within source bitmap
2600 -// SRCY Y offset within source bitmap
2601 -// DSTX screen X position to render data
2602 -// DSTY screen Y position to render data
2603 -// WIDTH width of rectangle, in pixels
2604 -// HEIGHT height of rectangle, in scanlines
2605 -// *DATA pointer to bitmap data
2606 -// PITCH pitch of bitmap data (bytes between scanlines)
2607 -// COLOR transparent color
2608 -//----------------------------------------------------------------------------
2611 -void gxr_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy,
2612 - unsigned short dstx, unsigned short dsty, unsigned short width,
2613 - unsigned short height, unsigned char *data, unsigned short pitch,
2614 - unsigned short color)
2616 - unsigned short section, buffer_width;
2617 - unsigned short blit_mode = BM_READ_SRC_BB0;
2618 - unsigned short line_srcx, line_dstx, line_width;
2619 - unsigned short offset, i, first_blt = 1;
2621 - /* CHECK SIZE OF BLT BUFFER */
2623 - buffer_width = GXRbufferWidthPixels;
2625 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2626 - /* Write the registers that do not change for each section. */
2628 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2629 - WRITE_REG16(GP_HEIGHT, 1);
2630 - WRITE_REG16(GP_RASTER_MODE, 0x10C6);
2631 - WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF);
2633 - /* CALCULATE OFFSET INTO BITMAP DATA */
2635 - offset = srcy * pitch;
2637 - /* REPEAT FOR EACH SCANLINE */
2641 - line_width = width;
2645 - while(line_width > 0)
2647 - /* CHECK WIDTH OF CURRENT SECTION */
2649 - if (line_width > buffer_width) section = buffer_width;
2650 - else section = line_width;
2652 - /* TRANSFER SCANLINE OF BITMAP DATA TO BLT BUFFER 0 */
2653 - /* Need to wait for BS_PIPELINE_BUSY to make sure that the */
2654 - /* data in BB0 for the previous scanline is no longer used. */
2655 - /* This can be heavily optimized to not do a byte at a time. */
2657 - while(READ_REG16(GP_BLIT_STATUS) & BS_PIPELINE_BUSY);
2658 - if (READ_REG16(GP_BLIT_STATUS) & BC_16BPP)
2660 - for (i = 0; i < section; i++)
2662 - WRITE_REG16(GXRbb0Base+i, data[offset+((line_srcx+i)<<1)]);
2667 - for (i = 0; i < section; i++)
2669 - WRITE_REG8(GXRbb0Base+i, data[line_srcx+offset+i]);
2673 - /* RENDER FROM BB0 TO FRAME BUFFER */
2675 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2676 - WRITE_REG16(GP_DST_XCOOR, line_dstx);
2677 - WRITE_REG16(GP_DST_YCOOR, dsty);
2678 - WRITE_REG16(GP_WIDTH, section);
2680 - /* NEED TO DO EXTRA WORK FOR THE FIRST BLT */
2684 - /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */
2685 - /* This can be heavily optimized to not do 16-bits at a time. */
2687 - if (READ_REG16(GP_BLIT_STATUS) & BC_16BPP)
2689 - for (i = 0; i < section; i++)
2691 - WRITE_REG16(GXRbb1Base+i*2, color);
2696 - for (i = 0; i < section; i++)
2698 - WRITE_REG8(GXRbb1Base+i, (unsigned char) color);
2701 - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0 | BM_READ_DST_BB1);
2706 - /* AFTER FIRST BLT, THE TRANSPARENCY DATA IS LATCHED */
2707 - /* Save time by not reading data from BB1. */
2709 - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0);
2711 - line_width -= section;
2712 - line_dstx += section;
2713 - line_srcx += section;
2722 -//----------------------------------------------------------------------------
2723 -// MONOCHROME BITMAP TO SCREEN BLT
2725 -// This routine transfers monochrome bitmap data to the screen.
2727 -// SRCX X offset within source bitmap
2728 -// SRCY Y offset within source bitmap
2729 -// DSTX screen X position to render data
2730 -// DSTY screen Y position to render data
2731 -// WIDTH width of rectangle, in pixels
2732 -// HEIGHT height of rectangle, in scanlines
2733 -// *DATA pointer to bitmap data
2734 -// PITCH pitch of bitmap data (bytes between scanlines)
2735 -// FGCOLOR color for bits = 1
2736 -// BGCOLOR color for bits = 0
2737 -// ROP ternary raster operation (0x00-0xFF).
2738 -// TRANSPARENT zero for opaque, otherwise transparent
2739 -//----------------------------------------------------------------------------
2742 -void gxr_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy,
2743 - unsigned short dstx, unsigned short dsty, unsigned short width,
2744 - unsigned short height, unsigned char *data, unsigned short pitch,
2745 - unsigned short fgcolor, unsigned short bgcolor, unsigned char rop,
2746 - unsigned char transparent)
2748 - unsigned short section, buffer_width;
2749 - unsigned short blit_mode = BM_READ_SRC_BB0 | BM_SOURCE_EXPAND;
2750 - unsigned short line_srcx, line_dstx, line_width;
2751 - unsigned short offset, i, bytes, raster_mode;
2753 - /* FORMAT 8BPP COLOR */
2754 - /* GX requires that 8BPP color data be duplicated into bits [15:8]. */
2756 - if (!(READ_REG16(GP_BLIT_STATUS) & BC_16BPP))
2758 - fgcolor &= 0x00FF;
2759 - fgcolor |= (fgcolor << 8);
2760 - bgcolor &= 0x00FF;
2761 - bgcolor |= (bgcolor << 8);
2764 - /* CHECK IF ROP REQUIRES DESTINATION DATA */
2765 - /* Even bits (0:2:4:6) do not equal corresponding odd bits (1:3:5:7). */
2767 - if ((rop & 0x55) ^ ((rop >> 1) & 0x55))
2768 - blit_mode |= BM_READ_DST_FB1;
2770 - /* CALCULATE RASTER MODE */
2771 - /* Set mono flag. Transparency set based on input parameter. */
2773 - raster_mode = ((unsigned short) rop & 0x00FF);
2774 - if (transparent) raster_mode |= RM_SRC_TRANSPARENT;
2776 - /* CHECK SIZE OF BLT BUFFER */
2778 - buffer_width = GXRbufferWidthPixels;
2780 - /* CALCULATE OFFSET INTO BITMAP DATA */
2782 - offset = srcy * pitch;
2784 - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
2785 - /* Write the registers that do not change for each section. */
2787 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2788 - WRITE_REG16(GP_HEIGHT, 1);
2789 - WRITE_REG16(GP_RASTER_MODE, raster_mode);
2790 - WRITE_REG16(GP_SRC_COLOR_0, bgcolor);
2791 - WRITE_REG16(GP_SRC_COLOR_1, fgcolor);
2793 - /* REPEAT FOR EACH SCANLINE */
2797 - line_width = width;
2801 - while(line_width > 0)
2803 - /* CHECK WIDTH OF CURRENT SECTION */
2804 - /* Only divide into sections if reading destination data. */
2805 - /* Since the source data is monochrome, it will always fit. */
2807 - section = line_width;
2808 - if ((line_width > buffer_width) && (blit_mode & BM_READ_DST_FB1))
2809 - section = buffer_width;
2811 - /* BYTES TO TRANSFER */
2812 - /* Add two bytes to handle truncating and alignment. */
2814 - bytes = (section >> 3) + 2;
2816 - /* TRANSFER SCANLINE OF BITMAP DATA TO BLT BUFFER 0 */
2817 - /* Need to wait for BS_PIPELINE_BUSY to make sure that the */
2818 - /* data in BB0 for the previous scanline is no longer used. */
2819 - /* This can be heavily optimized to not do a byte at a time. */
2821 - while(READ_REG16(GP_BLIT_STATUS) & BS_PIPELINE_BUSY);
2822 - for (i = 0; i < bytes; i++)
2824 - WRITE_REG8(GXRbb0Base+i, data[(line_srcx >> 3)+offset+i]);
2827 - /* RENDER FROM BB0 TO FRAME BUFFER */
2829 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2830 - WRITE_REG16(GP_DST_XCOOR, line_dstx);
2831 - WRITE_REG16(GP_DST_YCOOR, dsty);
2832 - WRITE_REG16(GP_SRC_XCOOR, line_srcx & 7);
2833 - WRITE_REG16(GP_WIDTH, section);
2834 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2836 - line_width -= section;
2837 - line_dstx += section;
2838 - line_srcx += section;
2847 -//----------------------------------------------------------------------------
2850 -// This routine draws a single character of text. It can only be used for
2851 -// characters that are less than or equal to 64x64 in size, since it
2852 -// transfers the entire data into the BLT buffers at once. Larger characters
2853 -// should use the monochrome bitmap to screen routine. The only supported
2854 -// ROP is SRCCOPY, again since the BLT buffer size is limited.
2856 -// SRCX X offset within source bitmap
2857 -// SRCY Y offset within source bitmap
2858 -// DSTX screen X position to render data
2859 -// DSTY screen Y position to render data
2860 -// WIDTH width of rectangle, in pixels
2861 -// HEIGHT height of rectangle, in scanlines
2862 -// *DATA pointer to bitmap data (NULL if already loaded)
2863 -// PITCH pitch of bitmap data (bytes between scanlines)
2865 -// For the Xfree86 display driver, the OS is given a pointer to BB0.
2866 -// Therefore, the data is already loaded when the driver is called, so the
2867 -// driver simply passes a NULL pointer to this routine.
2869 -// This same type of routine could be developed for "icons", or small
2870 -// color bitmaps that can fit entirely in the BLT buffer.
2871 -//----------------------------------------------------------------------------
2874 -void gxr_text_glyph(unsigned short srcx, unsigned short srcy,
2875 - unsigned short dstx, unsigned short dsty, unsigned short width,
2876 - unsigned short height, unsigned char *data, unsigned short pitch)
2878 - unsigned short offset, i, j, buffer_offset, bytes, blit_mode;
2880 - blit_mode = BM_READ_SRC_BB0 | BM_SOURCE_EXPAND;
2881 - if (GXRusesDstData) blit_mode |= BM_READ_DST_FB1;
2883 - /* CHECK IF DATA NEEDS TO BE TRANSFERRED */
2887 - /* TRANSFER ENTIRE BITMAP DATA TO BLT BUFFER 0 */
2888 - /* Need to wait for BS_PIPELINE_BUSY to make sure that the */
2889 - /* data in BB0 for any previous BLT is no longer used. */
2890 - /* This data transfer has lots of room for performance optimization. */
2892 - buffer_offset = 0;
2893 - offset = srcy * pitch + (srcx >> 3);
2894 - bytes = ((width + (srcx & 7) + 7) >> 3);
2895 - while(READ_REG16(GP_BLIT_STATUS) & BS_PIPELINE_BUSY);
2896 - for (j = 0; j < height; j++)
2898 - for (i = 0; i < bytes; i++)
2900 - WRITE_REG8(GXRbb0Base+buffer_offset, data[offset+i]);
2907 - /* RENDER FROM BB0 TO FRAME BUFFER */
2908 - /* Already know that the pipeline is idle from loading data. */
2910 - WRITE_REG16(GP_DST_XCOOR, dstx);
2911 - WRITE_REG16(GP_DST_YCOOR, dsty);
2912 - WRITE_REG16(GP_SRC_XCOOR, srcx & 7);
2913 - WRITE_REG16(GP_WIDTH, width);
2914 - WRITE_REG16(GP_HEIGHT, height);
2915 - WRITE_REG16(GP_BLIT_MODE, blit_mode);
2919 -//----------------------------------------------------------------------------
2922 -// This routine draws a vector using the specified Bresenham parameters.
2923 -// Currently this file does not support a routine that accepts the two
2924 -// endpoints of a vector and calculates the Bresenham parameters. If it
2925 -// ever does, this routine is still required for vectors that have been
2928 -// X screen X position to start vector
2929 -// Y screen Y position to start vector
2930 -// LENGTH length of the vector, in pixels
2931 -// INITERR Bresenham initial error term
2932 -// AXIALERR Bresenham axial error term
2933 -// DIAGERR Bresenham diagonal error term
2934 -// FLAGS VM_YMAJOR, VM_MAJOR_INC, VM_MINOR_INC
2935 -//----------------------------------------------------------------------------
2938 -void gxr_bresenham_line(unsigned short x, unsigned short y,
2939 - unsigned short length, unsigned short initerr,
2940 - unsigned short axialerr, unsigned short diagerr,
2941 - unsigned short flags)
2943 - unsigned short vector_mode = flags;
2944 - if (GXRusesDstData) vector_mode |= VM_READ_DST_FB;
2946 - /* CHECK NULL LENGTH */
2948 - if (!length) return;
2950 - /* LOAD THE REGISTERS FOR THE VECTOR */
2952 - while(READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING);
2953 - WRITE_REG16(GP_DST_XCOOR, x);
2954 - WRITE_REG16(GP_DST_YCOOR, y);
2955 - WRITE_REG16(GP_VECTOR_LENGTH, length);
2956 - WRITE_REG16(GP_INIT_ERROR, initerr);
2957 - WRITE_REG16(GP_AXIAL_ERROR, axialerr);
2958 - WRITE_REG16(GP_DIAG_ERROR, diagerr);
2959 - WRITE_REG16(GP_VECTOR_MODE, vector_mode);