diff options
author | dawes <dawes> | 2001-03-19 21:38:52 +0000 |
---|---|---|
committer | dawes <dawes> | 2001-03-19 21:38:52 +0000 |
commit | c9a3e2ae446907ec2fd7470f0a51cf2105bc0319 (patch) | |
tree | 3f034e523fa1b41f57c7b2b364073a31fd0d8a75 /xc/programs/Xserver/hw/xfree86/drivers/glint | |
parent | 326ae10581288b55caed7c82f687000ae3693eec (diff) |
Initial XFree86 4.0.99.1 merge.
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/glint')
17 files changed, 2112 insertions, 3741 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile index d4978cc14..9583be466 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.29 2000/09/20 00:09:21 keithp Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.31 2001/01/31 16:14:51 alanh Exp $ XCOMM XCOMM This is an Imakefile for the GLINT driver. XCOMM @@ -14,12 +14,12 @@ DRIINCLUDES=-I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri SRCS = glint_driver.c pm2_dac.c pm2ramdac.c pm2_accel.c pm_dac.c IBMramdac.c \ pm_accel.c tx_dac.c tx_accel.c pm2v_dac.c pm2vramdac.c pm2_video.c \ - pm3_dac.c pm3_accel.c TIramdac.c dualmx_dac.c dualmx_accel.c \ - glint_shadow.c $(DRISRC) sx_accel.c TIdualramdac.c glint_dga.c + pm3_dac.c pm3_accel.c TIramdac.c \ + glint_shadow.c $(DRISRC) sx_accel.c glint_dga.c OBJS = glint_driver.o pm2_dac.o pm2ramdac.o pm2_accel.o pm_dac.o IBMramdac.o \ pm_accel.o tx_dac.o tx_accel.o pm2v_dac.o pm2vramdac.o pm2_video.o \ - pm3_dac.o pm3_accel.o TIramdac.o dualmx_dac.o dualmx_accel.o \ - glint_shadow.o $(DRIOBJ) sx_accel.o TIdualramdac.o glint_dga.o + pm3_dac.o pm3_accel.o TIramdac.o \ + glint_shadow.o $(DRIOBJ) sx_accel.o glint_dga.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -52,7 +52,6 @@ ObjectModuleTarget(glint,$(OBJS)) InstallObjectModule(glint,$(MODULEDIR),drivers) #if !defined(XF86DriverSDK) -CppManTarget(glint,) InstallModuleManPage(glint) #endif @@ -61,9 +60,6 @@ DependTarget() InstallDriverSDKNonExecFile(IBMramdac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(TIramdac.c,$(DRIVERSDKDIR)/drivers/glint) -InstallDriverSDKNonExecFile(TIdualramdac.c,$(DRIVERSDKDIR)/drivers/glint) -InstallDriverSDKNonExecFile(dualmx_accel.c,$(DRIVERSDKDIR)/drivers/glint) -InstallDriverSDKNonExecFile(dualmx_dac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(glint.h,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(glint_dri.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(glint_dri.h,$(DRIVERSDKDIR)/drivers/glint) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 b/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 index caa5961ee..5a79d688e 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 @@ -1,14 +1,12 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.6 2000/12/12 17:02:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.7 2000/12/20 11:13:01 alanh Exp $ */ STATUS as of Mon, 16 Oct 2000 21:24:51 +0200 Working : * Unaccelerated : Depth 8, 15, 16 and 24 are ok. I tested them upto 1280x1024 only as my monitor don't support higher modes. - * Untested on big endian systems, i had some reports of endianess problems - with a Permedia4 though, so i suppose things are broken for Permedia3 - also. If you encounter problems, please contact me or try with - acceleration disabled. + * Endianess clean, thanks to Romain Dolbeau <dolbeaur@club-internet.fr> for + helping me debug this. * HW cursor. * ShadowFb works. * Full 2D Accels. @@ -65,7 +63,7 @@ Video Overlay [NOTHING DONE YET] : * I have not done anything yet here. -DRI/3D Accels [NOTHING DONE YET] : +DRI/3D Accels [WORK IS PLANED] : * First approach would be to use the gamma for one head only (most probably the first head, it could be configurable though). @@ -103,3 +101,4 @@ DRI/3D Accels [NOTHING DONE YET] : sync the gamma also when doing syncs. Not sure where the right place for this is though. Maybe when switching between 2D and 3D ? +Sven Luther <luther@dpt-info.u-strasbg.fr> diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c deleted file mode 100644 index 92efb5f13..000000000 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 1998 by Alan Hourihane, Wigan, England. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * - * Modified from IBMramdac.c to support TI RAMDAC routines - * by Jens Owen, <jens@precisioninsight.com>. - * - * glintOutTIIndReg() and glintInTIIndReg() are used to access - * the indirect TI RAMDAC registers only. - */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c,v 1.1 2000/03/21 21:46:27 alanh Exp $ */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86_ansic.h" - -#include "xf86PciInfo.h" -#include "xf86Pci.h" - -#include "TI.h" -#include "glint_regs.h" -#include "glint.h" - -#define TI_WRITE_ADDR 0x4000 -#define TI_RAMDAC_DATA 0x4008 -#define TI_PIXEL_MASK 0x4010 -#define TI_READ_ADDR 0x4018 -#define TI_CURS_COLOR_WRITE_ADDR 0x4020 -#define TI_CURS_COLOR_DATA 0x4028 -#define TI_CURS_COLOR_READ_ADDR 0x4038 -#define TI_DIRECT_CURS_CTRL 0x4048 -#define TI_INDEX_DATA 0x4050 -#define TI_CURS_RAM_DATA 0x4058 -#define TI_CURS_X_LOW 0x4060 -#define TI_CURS_X_HIGH 0x4068 -#define TI_CURS_Y_LOW 0x4070 -#define TI_CURS_Y_HIGH 0x4078 - -void -DUALglintOutTIIndReg(ScrnInfoPtr pScrn, - CARD32 reg, unsigned char mask, unsigned char data) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned char tmp = 0x00; - int offset; - - if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */ - offset = TI_WRITE_ADDR + ((reg & 0xf) << 3); - if (mask != 0x00) - tmp = GLINT_SECONDARY_READ_REG(offset) & mask; - - GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, offset); - } - else { /* normal indirect access */ - GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR); - - if (mask != 0x00) - tmp = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA) & mask; - - GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, TI_INDEX_DATA); - } -} - -unsigned char -DUALglintInTIIndReg (ScrnInfoPtr pScrn, CARD32 reg) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned char ret; - int offset; - - if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */ - offset = TI_WRITE_ADDR + ((reg & 0xf) << 3); - ret = GLINT_SECONDARY_READ_REG(offset); - } - else { /* normal indirect access */ - GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR); - ret = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA); - } - - return (ret); -} - -void -DUALglintTIWriteAddress (ScrnInfoPtr pScrn, CARD32 index) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_WRITE_ADDR); -} - -void -DUALglintTIWriteData (ScrnInfoPtr pScrn, unsigned char data) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_SECONDARY_SLOW_WRITE_REG(data, TI_RAMDAC_DATA); -} - -void -DUALglintTIReadAddress (ScrnInfoPtr pScrn, CARD32 index) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_SECONDARY_SLOW_WRITE_REG(0xFF, TI_PIXEL_MASK); - GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_READ_ADDR); -} - -unsigned char -DUALglintTIReadData (ScrnInfoPtr pScrn) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - return(GLINT_SECONDARY_READ_REG(TI_RAMDAC_DATA)); -} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c deleted file mode 100644 index fa93a2905..000000000 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * Dirk Hohndel, <hohndel@suse.de> - * Stefan Dirsch, <sndirsch@suse.de> - * - * Dual MX accelerated options. - * - * Modified version of tx_accel.c to support dual MX chips by - * Jens Owen, <jens@precisioninsight.com> - */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c,v 1.9 2000/06/21 13:35:51 alanh Exp $ */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86_ansic.h" - -#include "xf86PciInfo.h" -#include "xf86Pci.h" - -#include "fb.h" - -#include "miline.h" - -#include "glint_regs.h" -#include "glint.h" - -#include "xaalocal.h" /* For replacements */ - -static void DualMXSync(ScrnInfoPtr pScrn); -static void DualMXSetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, - unsigned int planemask); -static void DualMXSubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, - int w, int h); -static void DualMXSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, - int patterny, - int fg, int bg, int rop, - unsigned int planemask); -static void DualMXSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx, - int patterny, int x, int y, - int w, int h); -static void DualMXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, - int rop, unsigned int planemask, - int transparency_color); -static void DualMXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, - int x2, int y2, int w, int h); -static void DualMXWriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, - int skipleft, int fg, int bg, int rop, - unsigned int planemask); -static void DualMXSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, - int x2,int y2); -static void DualMXDisableClipping(ScrnInfoPtr pScrn); -static void DualMXWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, int rop, - unsigned int planemask, int trans, - int bpp, int depth); -static void DualMXSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, - int bg, int rop, unsigned int planemask); -static void DualMXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, - int y, int w, int h, int skipleft); -static void DualMXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, - int bg, int rop, unsigned int planemask); -static void DualMXSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, - int y, int w, int h, int skipleft); -static void DualMXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); -static void DualMXLoadCoord(ScrnInfoPtr pScrn, int x, int y, int w, int h, - int a, int d); -static void DualMXSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, - unsigned int planemask); -static void DualMXSubsequentHorVertLine(ScrnInfoPtr pScrn, int x1, int y1, - int len, int dir); -static void DualMXSubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, - int x, int y, int dmaj, int dmin, int e, - int len, int octant); -static void DualMXPolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, - int mode, int npt, DDXPointPtr pPts); -static void DualMXPolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, - int nseg, xSegment *pSeg); - -#define MAX_FIFO_ENTRIES 15 - -void -DualMXInitializeEngine(ScrnInfoPtr pScrn) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - pGlint->rasterizerMode = RMMultiGLINT; - - /* Initialize the Accelerator Engine to defaults */ - - /* Only write the following registerto the first MX */ - GLINT_SLOW_WRITE_REG(1, BroadcastMask); - GLINT_SLOW_WRITE_REG(0x00000001, ScanLineOwnership); - - /* Only write the following register to the second MX */ - GLINT_SLOW_WRITE_REG(2, BroadcastMask); - GLINT_SLOW_WRITE_REG(0x00000005, ScanLineOwnership); - - /* Make sure the rest of the register writes go to both MX's */ - GLINT_SLOW_WRITE_REG(3, BroadcastMask); - - GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); - GLINT_SLOW_WRITE_REG(pGlint->pprod | LBRM_ScanlineInt2, LBReadMode); - pGlint->pprod |= FBRM_ScanlineInt2; - GLINT_SLOW_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_SLOW_WRITE_REG(0, dXSub); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWriteMode); - GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureColorMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureReadMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTWindow); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LineStippleMode); - GLINT_SLOW_WRITE_REG(0, UpdateLineStippleCounters); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); - GLINT_SLOW_WRITE_REG(0x400, FilterMode); - GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); - GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBSourceOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, WindowOrigin); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBWindowBase); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PatternRamMode); - - switch (pScrn->bitsPerPixel) { - case 8: - GLINT_SLOW_WRITE_REG(0x2, PixelSize); - break; - case 16: - GLINT_SLOW_WRITE_REG(0x1, PixelSize); - break; - case 32: - GLINT_SLOW_WRITE_REG(0x0, PixelSize); - break; - } - - pGlint->ROP = 0xFF; - pGlint->ClippingOn = FALSE; - pGlint->startxsub = 0; - pGlint->startxdom = 0; - pGlint->starty = 0; - pGlint->count = 0; - pGlint->dxdom = 0; - pGlint->dy = 1; - pGlint->planemask = 0; - GLINT_SLOW_WRITE_REG(0, StartXSub); - GLINT_SLOW_WRITE_REG(0, StartXDom); - GLINT_SLOW_WRITE_REG(0, StartY); - GLINT_SLOW_WRITE_REG(0, GLINTCount); - GLINT_SLOW_WRITE_REG(0, dXDom); - GLINT_SLOW_WRITE_REG(1<<16, dY); -} - -Bool -DualMXAccelInit(ScreenPtr pScreen) -{ - XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GLINTPtr pGlint = GLINTPTR(pScrn); - long memory = pGlint->FbMapSize; - BoxRec AvailFBArea; - - pGlint->AccelInfoRec = infoPtr = XAACreateInfoRec(); - if (!infoPtr) return FALSE; - - DualMXInitializeEngine(pScrn); - - infoPtr->Flags = PIXMAP_CACHE | - LINEAR_FRAMEBUFFER | - OFFSCREEN_PIXMAPS; - - infoPtr->Sync = DualMXSync; - - infoPtr->SetClippingRectangle = DualMXSetClippingRectangle; - infoPtr->DisableClipping = DualMXDisableClipping; - infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL | -#if 0 - HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | -#endif - HARDWARE_CLIP_SOLID_FILL; - - infoPtr->SolidFillFlags = 0; - infoPtr->SetupForSolidFill = DualMXSetupForFillRectSolid; - infoPtr->SubsequentSolidFillRect = DualMXSubsequentFillRectSolid; - - infoPtr->SolidLineFlags = 0; - infoPtr->PolySegmentThinSolidFlags = 0; - infoPtr->PolylinesThinSolidFlags = 0; - infoPtr->SetupForSolidLine = DualMXSetupForSolidLine; - infoPtr->SubsequentSolidHorVertLine = DualMXSubsequentHorVertLine; - if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)) - { - infoPtr->SubsequentSolidBresenhamLine = - DualMXSubsequentSolidBresenhamLine; - } - infoPtr->PolySegmentThinSolid = DualMXPolySegmentThinSolidWrapper; - infoPtr->PolylinesThinSolid = DualMXPolylinesThinSolidWrapper; - -#if 0 - infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | - ONLY_LEFT_TO_RIGHT_BITBLT; - infoPtr->SetupForScreenToScreenCopy = DualMXSetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = DualMXSubsequentScreenToScreenCopy; -#endif - - infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_ORIGIN | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS; - infoPtr->SetupForMono8x8PatternFill = DualMXSetupForMono8x8PatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = - DualMXSubsequentMono8x8PatternFillRect; - -#if 0 - if (!pGlint->UsePCIRetry) { - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - TRANSPARENCY_ONLY | -#if 0 - LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | -#endif - BIT_ORDER_IN_BYTE_LSBFIRST; - - pGlint->XAAScanlineColorExpandBuffers[0] = - xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8)); - pGlint->XAAScanlineColorExpandBuffers[1] = - xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8)); - - infoPtr->NumScanlineColorExpandBuffers = 2; - infoPtr->ScanlineColorExpandBuffers = - pGlint->XAAScanlineColorExpandBuffers; - - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = - DualMXSetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = - DualMXSubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = - DualMXSubsequentColorExpandScanline; - } else { - infoPtr->CPUToScreenColorExpandFillFlags = TRANSPARENCY_ONLY | - SYNC_AFTER_COLOR_EXPAND | - CPU_TRANSFER_PAD_DWORD | -#if 0 - LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | -#endif - BIT_ORDER_IN_BYTE_LSBFIRST; - infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4; - infoPtr->SetupForCPUToScreenColorExpandFill = - DualMXSetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - DualMXSubsequentCPUToScreenColorExpandFill; - } -#endif - - infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; - - infoPtr->WriteBitmap = DualMXWriteBitmap; - infoPtr->WritePixmap = DualMXWritePixmap; - - AvailFBArea.x1 = 0; - AvailFBArea.y1 = 0; - AvailFBArea.x2 = pScrn->displayWidth; - if (memory > (16383*1024)) memory = 16383*1024; - AvailFBArea.y2 = memory / (pScrn->displayWidth * - pScrn->bitsPerPixel / 8); - - xf86InitFBManager(pScreen, &AvailFBArea); - - return (XAAInit(pScreen, infoPtr)); -} - -static void DualMXLoadCoord( - ScrnInfoPtr pScrn, - int x, int y, - int w, int h, - int a, int d -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WRITE_REG(w<<16, StartXSub); - GLINT_WRITE_REG(x<<16,StartXDom); - GLINT_WRITE_REG(y<<16,StartY); - GLINT_WRITE_REG(h,GLINTCount); - GLINT_WRITE_REG(a<<16,dXDom); - GLINT_WRITE_REG(d<<16,dY); -} - -static void MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords ) -{ - while(dwords & ~0x03) { - *dest = *src; - *(dest + 1) = *(src + 1); - *(dest + 2) = *(src + 2); - *(dest + 3) = *(src + 3); - src += 4; - dest += 4; - dwords -= 4; - } - if (!dwords) return; - *dest = *src; - if (dwords == 1) return; - *(dest + 1) = *(src + 1); - if (dwords == 2) return; - *(dest + 2) = *(src + 2); -} - -#define Sync_tag 0x188 - -static void -DualMXSync( - ScrnInfoPtr pScrn -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned long readValue; - - CHECKCLIPPING; - - while (GLINT_READ_REG(DMACount) != 0); - GLINT_WAIT(3); - GLINT_WRITE_REG(3, BroadcastMask); /* hack! this shouldn't need to be reloaded */ - GLINT_WRITE_REG(1<<10, FilterMode); - GLINT_WRITE_REG(0, GlintSync); - - /* Read 1st MX until Sync Tag shows */ - do { - while(GLINT_READ_REG(OutFIFOWords) == 0); - readValue = GLINT_READ_REG(OutputFIFO); -#ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "1st MX: OutputFIFO %x\n",readValue); -#endif - } while (readValue != Sync_tag); - - /* Read 2nd MX until Sync Tag shows */ - do { - while(GLINT_SECONDARY_READ_REG(OutFIFOWords) == 0); - readValue = GLINT_SECONDARY_READ_REG(OutputFIFO); -#ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "2nd MX: OutputFIFO %x\n",readValue); -#endif - } while (readValue != Sync_tag); - -#ifdef DEBUG - if (GLINT_READ_REG(OutFIFOWords)||GLINT_SECONDARY_READ_REG(OutFIFOWords)) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Unread data in output FIFO after sync\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "1st MX: OutFifoWords %d\n",GLINT_READ_REG(OutFIFOWords)); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "2nd MX: OutFifoWords %d\n",GLINT_SECONDARY_READ_REG(OutFIFOWords)); - } -#endif -} - -static void -DualMXSetupForFillRectSolid( - ScrnInfoPtr pScrn, - int color, int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - pGlint->ForeGroundColor = color; - - GLINT_WAIT(5); - REPLICATE(color); - DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - GLINT_WRITE_REG(color, FBBlockColor); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - GLINT_WRITE_REG(color, PatternRamData0); - pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation; - } - LOADROP(rop); -} - -static void -DualMXSubsequentFillRectSolid( - ScrnInfoPtr pScrn, - int x, int y, - int w, int h -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(8); - DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode,Render); -} - -static void -DualMXSetClippingRectangle( - ScrnInfoPtr pScrn, - int x1, int y1, - int x2, int y2 -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(3); - GLINT_WRITE_REG((y1&0xFFFF)<<16|(x1&0xFFFF), ScissorMinXY); - GLINT_WRITE_REG((y2&0xFFFF)<<16|(x2&0xFFFF), ScissorMaxXY); - GLINT_WRITE_REG(1, ScissorMode); /* Enable Scissor Mode */ - pGlint->ClippingOn = TRUE; -} - -static void -DualMXDisableClipping( - ScrnInfoPtr pScrn -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - CHECKCLIPPING; -} - -static void -DualMXSetupForScreenToScreenCopy( - ScrnInfoPtr pScrn, - int xdir, int ydir, - int rop, - unsigned int planemask, - int transparency_color -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - pGlint->BltScanDirection = ydir; - - GLINT_WAIT(5); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod | FBRM_SrcEnable, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_SrcEnable | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); -} - -static void -DualMXSubsequentScreenToScreenCopy( - ScrnInfoPtr pScrn, - int x1, int y1, - int x2, int y2, - int w, int h -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int srcaddr, dstaddr; - - GLINT_WAIT(10); - if (pGlint->BltScanDirection != 1) { - y1 += h - 1; - y2 += h - 1; - DualMXLoadCoord(pScrn, x2, y2, x2+w, h, 0, -1); - } else { - DualMXLoadCoord(pScrn, x2, y2, x2+w, h, 0, 1); - } - - srcaddr = y1 * pScrn->displayWidth + x1; - dstaddr = y2 * pScrn->displayWidth + x2; - - GLINT_WRITE_REG(srcaddr - dstaddr, FBSourceOffset); - GLINT_WRITE_REG(PrimitiveTrapezoid| FastFillEnable | SpanOperation, Render); -} - -static void -DualMXSetupForScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - REPLICATE(fg); - REPLICATE(bg); - GLINT_WAIT(6); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - pGlint->FrameBufferReadMode = FastFillEnable; - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation; - GLINT_WRITE_REG(fg, PatternRamData0); - } - LOADROP(rop); -} - -static void -DualMXSubsequentScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */ - -#if 0 - DualMXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h); -#endif - - pGlint->cpucount = y; - pGlint->cpuheight = h; - GLINT_WAIT(6); - DualMXLoadCoord(pScrn, x, pGlint->cpucount, x+w, 1, 0, 1); -} - -static void -DualMXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - CARD32 *src; - int dwords = pGlint->dwords; - - GLINT_WAIT(7); - DualMXLoadCoord(pScrn, pGlint->startxdom, pGlint->cpucount, pGlint->startxsub, 1, 0, 1); - - GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode | SyncOnBitMask, - Render); - - src = (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno]; - while (dwords >= infoRec->ColorExpandRange) { - GLINT_WAIT(infoRec->ColorExpandRange); - GLINT_WRITE_REG((infoRec->ColorExpandRange - 2)<<16 | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src, - infoRec->ColorExpandRange - 1); - dwords -= (infoRec->ColorExpandRange - 1); - src += (infoRec->ColorExpandRange - 1); - } - if (dwords) { - GLINT_WAIT(dwords); - GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,dwords); - } - pGlint->cpucount += 1; -#if 0 - if (pGlint->cpucount == (pGlint->cpuheight + 1)) - CHECKCLIPPING; -#endif -} - -static void -DualMXSetupForCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - REPLICATE(fg); - - DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - GLINT_WRITE_REG(fg, FBBlockColor); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - GLINT_WRITE_REG(fg, PatternRamData0); - pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation; - } - LOADROP(rop); -} - -static void -DualMXSubsequentCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dwords = ((w + 31) >> 5) * h; - -#if 0 - DualMXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h); -#endif - - DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode | - SyncOnBitMask, Render); - GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); -} - -void DualMXSetupForMono8x8PatternFill( - ScrnInfoPtr pScrn, - int patternx, int patterny, - int fg, int bg, int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - if (bg == -1) pGlint->FrameBufferReadMode = -1; - else pGlint->FrameBufferReadMode = 0; - pGlint->ForeGroundColor = fg; - pGlint->BackGroundColor = bg; - REPLICATE(pGlint->ForeGroundColor); - REPLICATE(pGlint->BackGroundColor); - - GLINT_WAIT(13); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG((patternx & 0x000000FF), AreaStipplePattern0); - GLINT_WRITE_REG((patternx & 0x0000FF00) >> 8, AreaStipplePattern1); - GLINT_WRITE_REG((patternx & 0x00FF0000) >> 16, AreaStipplePattern2); - GLINT_WRITE_REG((patternx & 0xFF000000) >> 24, AreaStipplePattern3); - GLINT_WRITE_REG((patterny & 0x000000FF), AreaStipplePattern4); - GLINT_WRITE_REG((patterny & 0x0000FF00) >> 8, AreaStipplePattern5); - GLINT_WRITE_REG((patterny & 0x00FF0000) >> 16, AreaStipplePattern6); - GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7); - - if (rop == GXcopy) { - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); -} - -static void -DualMXSubsequentMono8x8PatternFillRect( - ScrnInfoPtr pScrn, - int patternx, int patterny, - int x, int y, - int w, int h -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int span = 0; - - GLINT_WAIT(12); - DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - - if (pGlint->FrameBufferReadMode != -1) { - if (pGlint->ROP == GXcopy) { - GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor); - span = 0; - } else { - GLINT_WRITE_REG(pGlint->BackGroundColor, PatternRamData0); - span = SpanOperation; - } - GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern | - UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | span | FastFillEnable | - PrimitiveTrapezoid, Render); - } - - if (pGlint->ROP == GXcopy) { - GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor); - span = 0; - } else { - GLINT_WRITE_REG(pGlint->ForeGroundColor, PatternRamData0); - span = SpanOperation; - } - GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12| - UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | span | FastFillEnable | - PrimitiveTrapezoid, Render); -} - -static void -DualMXWriteBitmap(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int skipleft, - int fg, int bg, - int rop, - unsigned int planemask -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned char *srcpntr; - int dwords, height, mode; - Bool SecondPass = FALSE; - register int count; - register CARD32* pattern; - - w += skipleft; - x -= skipleft; - dwords = (w + 31) >> 5; - - DualMXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h); - - GLINT_WAIT(11); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); - LOADROP(rop); - if (rop == GXcopy) { - mode = 0; - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - mode = SpanOperation; - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - - if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ - REPLICATE(fg); - GLINT_WAIT(3); - if (rop == GXcopy) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, PatternRamData0); - } - } else if(rop == GXcopy) { - REPLICATE(bg); - GLINT_WAIT(5); - if (rop == GXcopy) { - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(bg, PatternRamData0); - } - GLINT_WRITE_REG(PrimitiveTrapezoid |mode|FastFillEnable,Render); - REPLICATE(fg); - if (rop == GXcopy) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, PatternRamData0); - } - } else { - SecondPass = TRUE; - REPLICATE(fg); - GLINT_WAIT(3); - if (rop == GXcopy) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, PatternRamData0); - } - } - -SECOND_PASS: - GLINT_WRITE_REG(PrimitiveTrapezoid | FastFillEnable | mode | SyncOnBitMask, Render); - - height = h; - srcpntr = src; - while(height--) { - count = dwords >> 3; - pattern = (CARD32*)srcpntr; - while(count--) { - GLINT_WAIT(8); - GLINT_WRITE_REG(*(pattern), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+1), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+2), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+3), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+4), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+5), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+6), BitMaskPattern); - GLINT_WRITE_REG(*(pattern+7), BitMaskPattern); - pattern+=8; - } - count = dwords & 0x07; - GLINT_WAIT(count); - while (count--) - GLINT_WRITE_REG(*(pattern++), BitMaskPattern); - srcpntr += srcwidth; - } - - if(SecondPass) { - SecondPass = FALSE; - REPLICATE(bg); - GLINT_WAIT(4); - GLINT_WRITE_REG((pGlint->rasterizerMode|InvertBitMask), RasterizerMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(bg, PatternRamData0); - } - goto SECOND_PASS; - } - - GLINT_WAIT(2); - GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); - CHECKCLIPPING; - SET_SYNC_FLAG(infoRec); -} - -static void -DualMXWritePixmap( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, /* bytes */ - int rop, - unsigned int planemask, - int trans, - int bpp, int depth -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - CARD32 *srcp; - int count,dwords, skipleft, Bpp = bpp >> 3; - - if((skipleft = (long)src & 0x03L)) { - skipleft /= Bpp; - - x -= skipleft; - w += skipleft; - - src = (unsigned char*)((long)src & ~0x03L); - } - - switch(Bpp) { - case 1: dwords = (w + 3) >> 2; - break; - case 2: dwords = (w + 1) >> 1; - break; - case 4: dwords = w; - break; - default: return; - } - - DualMXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h); - - GLINT_WAIT(12); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(0, PatternRamMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); - DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - GLINT_WRITE_REG(PrimitiveTrapezoid | FastFillEnable | SpanOperation | - SyncOnHostData, Render); - - while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= infoRec->ColorExpandRange) { - GLINT_WAIT(infoRec->ColorExpandRange); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((infoRec->ColorExpandRange - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, infoRec->ColorExpandRange - 1); - count -= infoRec->ColorExpandRange - 1; - srcp += infoRec->ColorExpandRange - 1; - } - if(count) { - GLINT_WAIT(count); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - } - CHECKCLIPPING; - SET_SYNC_FLAG(infoRec); -} - -static void -DualMXPolylinesThinSolidWrapper( - DrawablePtr pDraw, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr pPts -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - GLINTPtr pGlint = GLINTPTR(infoRec->pScrn); - pGlint->CurrentGC = pGC; - pGlint->CurrentDrawable = pDraw; - if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn); - XAAPolyLines(pDraw, pGC, mode, npt, pPts); -} - -static void -DualMXPolySegmentThinSolidWrapper( - DrawablePtr pDraw, - GCPtr pGC, - int nseg, - xSegment *pSeg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - GLINTPtr pGlint = GLINTPTR(infoRec->pScrn); - pGlint->CurrentGC = pGC; - pGlint->CurrentDrawable = pDraw; - if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn); - XAAPolySegment(pDraw, pGC, nseg, pSeg); -} - -static void -DualMXSetupForSolidLine(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(5); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(color, GLINTColor); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); -} - -static void -DualMXSubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(7); - if (dir == DEGREES_0) { - DualMXLoadCoord(pScrn, x, y, 0, len, 1, 0); - } else { - DualMXLoadCoord(pScrn, x, y, 0, len, 0, 1); - } - - GLINT_WRITE_REG(PrimitiveLine, Render); -} - -static void -DualMXSubsequentSolidBresenhamLine( ScrnInfoPtr pScrn, - int x, int y, int dmaj, int dmin, int e, int len, int octant) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dxdom, dy; - - if(dmaj == dmin) { - GLINT_WAIT(7); - if(octant & YDECREASING) { - dy = -1; - } else { - dy = 1; - } - - if(octant & XDECREASING) { - dxdom = -1; - } else { - dxdom = 1; - } - - DualMXLoadCoord(pScrn, x, y, 0, len, dxdom, dy); - GLINT_WRITE_REG(PrimitiveLine, Render); - return; - } - - fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0, - (octant & XDECREASING) ? -1 : 1, - (octant & YDECREASING) ? -1 : 1, - (octant & YMAJOR) ? Y_AXIS : X_AXIS, - x, y, dmin + e, dmin, -dmaj, len); -} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c deleted file mode 100644 index d042bfa47..000000000 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c +++ /dev/null @@ -1,807 +0,0 @@ -/* - * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Original Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * Dirk Hohndel, <hohndel@suse.de> - * Stefan Dirsch, <sndirsch@suse.de> - * Helmut Fahrion, <hf@suse.de> - * - * Modified version of tx_dac.c to support Dual MX rasterizers by - * Jens Owen <jens@precisioninsight.com> - */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c,v 1.4 2000/05/10 18:55:28 alanh Exp $ */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86_ansic.h" - -#include "xf86PciInfo.h" -#include "xf86Pci.h" - -#include "IBM.h" -#include "TI.h" -#include "glint_regs.h" -#include "glint.h" - -#define DEBUG -#ifdef DEBUG -#define DUMP(name,field) do { \ - value = GLINT_READ_REG(field); \ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\t\t%s(primary): 0x%lX\n", name, value); \ - value = GLINT_SECONDARY_READ_REG(field); \ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\t\t%s(secondary): 0x%lX\n", name, value); \ -} while (0) - -#define TIDUMP(name,field) do { \ - value = glintInTIIndReg(pScrn,field); \ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\t\t%s: 0x%lX\n", name, value); \ -} while (0) - -void -GLINTDumpRegs(ScrnInfoPtr pScrn) { - GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned long value; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tGAMMA/MX regs:\n"); - DUMP("ResetStatus",ResetStatus); - DUMP("IntEnable",IntEnable); - DUMP("IntFlags",IntFlags); - DUMP("InFIFOSpace",InFIFOSpace); - DUMP("OutFIFOWords",OutFIFOWords); - DUMP("DMAAddress",DMAAddress); - DUMP("DMACount",DMACount); - DUMP("ErrorFlags",ErrorFlags); - DUMP("VClkCtl",VClkCtl); - DUMP("TestRegister",TestRegister); - DUMP("Aperture0",Aperture0); - DUMP("Aperture1",Aperture1); - DUMP("DMAControl",DMAControl); - DUMP("FIFODis",FIFODis); - DUMP("LBMemoryCtl",LBMemoryCtl); - DUMP("LBMemoryEDO",LBMemoryEDO); - DUMP("FBMemoryCtl",FBMemoryCtl); - DUMP("FBModeSel",FBModeSel); - DUMP("FBGCWrMask",FBGCWrMask); - DUMP("FBGCColorLower",FBGCColorLower); - DUMP("FBTXMemCtl",FBTXMemCtl); - DUMP("FBWrMaskk",FBWrMaskk); - DUMP("FBGCColorUpper",FBGCColorUpper); - DUMP("OutputFIFO",OutputFIFO); - DUMP("VTGHLimit",VTGHLimit); - DUMP("VTGHSyncStart",VTGHSyncStart); - DUMP("VTGHSyncEnd",VTGHSyncEnd); - DUMP("VTGHBlankEnd",VTGHBlankEnd); - DUMP("VTGVLimit",VTGVLimit); - DUMP("VTGVSyncStart",VTGVSyncStart); - DUMP("VTGVSyncEnd",VTGVSyncEnd); - DUMP("VTGVBlankEnd",VTGVBlankEnd); - DUMP("VTGHGateStart",VTGHGateStart); - DUMP("VTGHGateEnd",VTGHGateEnd); - DUMP("VTGVGateStart",VTGVGateStart); - DUMP("VTGVGateEnd",VTGVGateEnd); - DUMP("VTGPolarity",VTGPolarity); - DUMP("VTGFrameRowAddr",VTGFrameRowAddr); - DUMP("VTGVLineNumber",VTGVLineNumber); - DUMP("VTGSerialClk",VTGSerialClk); - DUMP("VTGModeCtl",VTGModeCtl); - DUMP("GInFIFOSpace",GInFIFOSpace); - DUMP("GDMAAddress",GDMAAddress); - DUMP("GDMAControl",GDMAControl); - DUMP("GOutDMA",GOutDMA); - DUMP("GOutDMACount",GOutDMACount); - DUMP("GResetStatus",GResetStatus); - DUMP("GIntEnable",GIntEnable); - DUMP("GIntFlags",GIntFlags); - DUMP("GErrorFlags",GErrorFlags); - DUMP("GTestRegister",GTestRegister); - DUMP("GFIFODis",GFIFODis); - DUMP("GChipConfig",GChipConfig); - DUMP("GCSRAperture",GCSRAperture); - DUMP("GPageTableAddr",GPageTableAddr); - DUMP("GPageTableLength",GPageTableLength); - DUMP("GDelayTimer",GDelayTimer); - DUMP("GCommandMode",GCommandMode); - DUMP("GCommandIntEnable",GCommandIntEnable); - DUMP("GCommandIntFlags",GCommandIntFlags); - DUMP("GCommandErrorFlags",GCommandErrorFlags); - DUMP("GCommandStatus",GCommandStatus); - DUMP("GCommandFaultingAddr",GCommandFaultingAddr); - DUMP("GVertexFaultingAddr",GVertexFaultingAddr); - DUMP("GWriteFaultingAddr",GWriteFaultingAddr); - DUMP("GFeedbackSelectCount",GFeedbackSelectCount); - DUMP("GGammaProcessorMode",GGammaProcessorMode); - DUMP("GVGAShadow",GVGAShadow); - DUMP("GMultGLINTAperture",GMultGLINTAperture); - DUMP("GMultGLINT1",GMultGLINT1); - DUMP("GMultGLINT2",GMultGLINT2); - DUMP("StartXDom",StartXDom); - DUMP("dXDom",dXDom); - DUMP("StartXSub",StartXSub); - DUMP("dXSub",dXSub); - DUMP("StartY",StartY); - DUMP("dY",dY); - DUMP("GLINTCount",GLINTCount); - DUMP("Render",Render); - DUMP("ContinueNewLine",ContinueNewLine); - DUMP("ContinueNewDom",ContinueNewDom); - DUMP("ContinueNewSub",ContinueNewSub); - DUMP("Continue",Continue); - DUMP("FlushSpan",FlushSpan); - DUMP("BitMaskPattern",BitMaskPattern); - DUMP("PointTable0",PointTable0); - DUMP("PointTable1",PointTable1); - DUMP("PointTable2",PointTable2); - DUMP("PointTable3",PointTable3); - DUMP("RasterizerMode",RasterizerMode); - DUMP("YLimits",YLimits); - DUMP("ScanLineOwnership",ScanLineOwnership); - DUMP("WaitForCompletion",WaitForCompletion); - DUMP("PixelSize",PixelSize); - DUMP("XLimits",XLimits); - DUMP("RectangleOrigin",RectangleOrigin); - DUMP("RectangleSize",RectangleSize); - DUMP("PackedDataLimits",PackedDataLimits); - DUMP("ScissorMode",ScissorMode); - DUMP("ScissorMinXY",ScissorMinXY); - DUMP("ScissorMaxXY",ScissorMaxXY); - DUMP("ScreenSize",ScreenSize); - DUMP("AreaStippleMode",AreaStippleMode); - DUMP("LineStippleMode",LineStippleMode); - DUMP("LoadLineStippleCounters",LoadLineStippleCounters); - DUMP("UpdateLineStippleCounters",UpdateLineStippleCounters); - DUMP("SaveLineStippleState",SaveLineStippleState); - DUMP("WindowOrigin",WindowOrigin); - DUMP("AreaStipplePattern0",AreaStipplePattern0); - DUMP("AreaStipplePattern1",AreaStipplePattern1); - DUMP("AreaStipplePattern2",AreaStipplePattern2); - DUMP("AreaStipplePattern3",AreaStipplePattern3); - DUMP("AreaStipplePattern4",AreaStipplePattern4); - DUMP("AreaStipplePattern5",AreaStipplePattern5); - DUMP("AreaStipplePattern6",AreaStipplePattern6); - DUMP("AreaStipplePattern7",AreaStipplePattern7); - DUMP("TextureAddressMode",TextureAddressMode); - DUMP("TextureReadMode",TextureReadMode); - DUMP("TextureFormat",TextureFormat); - DUMP("TextureCacheControl",TextureCacheControl); - DUMP("GLINTBorderColor",GLINTBorderColor); - DUMP("TexelLUTIndex",TexelLUTIndex); - DUMP("TexelLUTData",TexelLUTData); - DUMP("Texel0",Texel0); - DUMP("Texel1",Texel1); - DUMP("Texel2",Texel2); - DUMP("Texel3",Texel3); - DUMP("Texel4",Texel4); - DUMP("Texel5",Texel5); - DUMP("Texel6",Texel6); - DUMP("Texel7",Texel7); - DUMP("Interp0",Interp0); - DUMP("Interp1",Interp1); - DUMP("Interp2",Interp2); - DUMP("Interp3",Interp3); - DUMP("Interp4",Interp4); - DUMP("TextureFilter",TextureFilter); - DUMP("TexelLUTMode",TexelLUTMode); - DUMP("TextureColorMode",TextureColorMode); - DUMP("TextureEnvColor",TextureEnvColor); - DUMP("FogMode",FogMode); - DUMP("FogColor",FogColor); - DUMP("FStart",FStart); - DUMP("dFdx",dFdx); - DUMP("dFdyDom",dFdyDom); - DUMP("KsStart",KsStart); - DUMP("dKsdx",dKsdx); - DUMP("dKsdyDom",dKsdyDom); - DUMP("KdStart", KdStart ); - DUMP("dKdStart", dKdStart); - DUMP("dKddyDom", dKddyDom); - DUMP("RStart", RStart ); - DUMP("dRdx", dRdx); - DUMP("dRdyDom", dRdyDom ); - DUMP("GStart", GStart ); - DUMP("dGdx", dGdx ); - DUMP("dGdyDom", dGdyDom ); - DUMP("BStart", BStart ); - DUMP("dBdx", dBdx ); - DUMP("dBdyDom", dBdyDom ); - DUMP("AStart", AStart ); - DUMP("dAdx", dAdx ); - DUMP("dAdyDom", dAdyDom ); - DUMP("ColorDDAMode", ColorDDAMode ); - DUMP("ConstantColor", ConstantColor ); - DUMP("GLINTColor", GLINTColor); - DUMP("AlphaTestMode", AlphaTestMode ); - DUMP("AntialiasMode", AntialiasMode); - DUMP("AlphaBlendMode", AlphaBlendMode); - DUMP("DitherMode", DitherMode ); - DUMP("FBSoftwareWriteMask", FBSoftwareWriteMask); - DUMP("LogicalOpMode", LogicalOpMode ); - DUMP("FBWriteData", FBWriteData); - DUMP("RouterMode", RouterMode); - DUMP("LBReadMode", LBReadMode); - DUMP("LBReadFormat", LBReadFormat); - DUMP("LBSourceOffset", LBSourceOffset); - DUMP("LBStencil", LBStencil); - DUMP("LBDepth", LBDepth ); - DUMP("LBWindowBase", LBWindowBase); - DUMP("LBWriteMode", LBWriteMode); - DUMP("LBWriteFormat", LBWriteFormat); - DUMP("TextureData", TextureData ); - DUMP("TextureDownloadOffset", TextureDownloadOffset); - DUMP("GLINTWindow", GLINTWindow ); - DUMP("StencilMode", StencilMode); - DUMP("StencilData", StencilData); - DUMP("GLINTStencil", GLINTStencil ); - DUMP("DepthMode", DepthMode); - DUMP("GLINTDepth", GLINTDepth ); - DUMP("ZStartU", ZStartU ); - DUMP("ZStartL", ZStartL ); - DUMP("dZdxU", dZdxU); - DUMP("dZdxL", dZdxL); - DUMP("dZdyDomU",dZdyDomU ); - DUMP("dZdyDomL", dZdyDomL); - DUMP("FastClearDepth", FastClearDepth); - DUMP("FBReadMode", FBReadMode); - DUMP("FBSourceOffset", FBSourceOffset ); - DUMP("FBPixelOffset", FBPixelOffset); - DUMP("FBColor", FBColor ); - DUMP("FBData", FBData); - DUMP("FBSourceData", FBSourceData ); - DUMP("FBWindowBase", FBWindowBase ); - DUMP("FBWriteMode", FBWriteMode ); - DUMP("FBHardwareWriteMask", FBHardwareWriteMask ); - DUMP("FBBlockColor", FBBlockColor ); - DUMP("FBReadPixel", FBReadPixel); - DUMP("PatternRamMode", PatternRamMode ); - DUMP("PatternRamData0", PatternRamData0 ); - DUMP("PatternRamData1", PatternRamData1); - DUMP("PatternRamData2", PatternRamData2 ); - DUMP("PatternRamData3", PatternRamData3 ); - DUMP("PatternRamData4", PatternRamData4); - DUMP("PatternRamData5", PatternRamData5 ); - DUMP("PatternRamData6", PatternRamData6 ); - DUMP("PatternRamData7", PatternRamData7 ); - DUMP("FilterMode", FilterMode ); - DUMP("StatisticMode", StatisticMode); - DUMP("MinRegion", MinRegion ); - DUMP("MaxRegion", MaxRegion ); - DUMP("ResetPickResult", ResetPickResult ); - DUMP("MitHitRegion", MitHitRegion ); - DUMP("MaxHitRegion", MaxHitRegion ); - DUMP("PickResult", PickResult ); - DUMP("GlintSync", GlintSync); - DUMP("FBBlockColorU", FBBlockColorU ); - DUMP("FBBlockColorL", FBBlockColorL ); - DUMP("SuspendUntilFrameBlank", SuspendUntilFrameBlank ); - DUMP("FBSourceBase", FBSourceBase ); - DUMP("FBSourceDelta", FBSourceDelta); - DUMP("Config", Config ); - DUMP("YUVMode", YUVMode ); - DUMP("DrawTriangle", DrawTriangle); - DUMP("RepeatTriangle", RepeatTriangle); - DUMP("DrawLine01", DrawLine01); - DUMP("DrawLine10", DrawLine10 ); - DUMP("RepeatLine", RepeatLine ); - DUMP("BroadcastMask", BroadcastMask ); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tTI3030 direct regs:\n"); -#define TI_WRITE_ADDR 0x4000 -#define TI_RAMDAC_DATA 0x4008 -#define TI_PIXEL_MASK 0x4010 -#define TI_READ_ADDR 0x4018 -#define TI_CURS_COLOR_WRITE_ADDR 0x4020 -#define TI_CURS_COLOR_DATA 0x4028 -#define TI_CURS_COLOR_READ_ADDR 0x4038 -#define TI_DIRECT_CURS_CTRL 0x4048 -#define TI_INDEX_DATA 0x4050 -#define TI_CURS_RAM_DATA 0x4058 -#define TI_CURS_X_LOW 0x4060 -#define TI_CURS_X_HIGH 0x4068 -#define TI_CURS_Y_LOW 0x4070 -#define TI_CURS_Y_HIGH 0x4078 - DUMP("TI_WRITE_ADDR", TI_WRITE_ADDR); - DUMP("TI_RAMDAC_DATA", TI_RAMDAC_DATA); - DUMP("TI_PIXEL_MASK", TI_PIXEL_MASK); - DUMP("TI_READ_ADDR", TI_READ_ADDR); - DUMP("TI_CURS_COLOR_WRITE_ADDR", TI_CURS_COLOR_WRITE_ADDR); - DUMP("TI_CURS_COLOR_DATA", TI_CURS_COLOR_DATA); - DUMP("TI_CURS_COLOR_READ_ADDR", TI_CURS_COLOR_READ_ADDR); - DUMP("TI_DIRECT_CURS_CTRL", TI_DIRECT_CURS_CTRL); - DUMP("TI_INDEX_DATA", TI_INDEX_DATA); - DUMP("TI_CURS_RAM_DATA", TI_CURS_RAM_DATA); - DUMP("TI_CURS_X_LOW", TI_CURS_X_LOW); - DUMP("TI_CURS_X_HIGH", TI_CURS_X_HIGH); - DUMP("TI_CURS_Y_LOW", TI_CURS_Y_LOW); - DUMP("TI_CURS_Y_HIGH", TI_CURS_Y_HIGH); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tTI3030 indirect regs:\n"); - TIDUMP("TIDAC_rev",TIDAC_rev); - TIDUMP("TIDAC_ind_curs_ctrl",TIDAC_ind_curs_ctrl); - TIDUMP("TIDAC_byte_router_ctrl",TIDAC_byte_router_ctrl); - TIDUMP("TIDAC_latch_ctrl",TIDAC_latch_ctrl); - TIDUMP("TIDAC_true_color_ctrl",TIDAC_true_color_ctrl); - TIDUMP("TIDAC_multiplex_ctrl",TIDAC_multiplex_ctrl); - TIDUMP("TIDAC_clock_select",TIDAC_clock_select); - TIDUMP("TIDAC_palette_page",TIDAC_palette_page); - TIDUMP("TIDAC_general_ctrl",TIDAC_general_ctrl); - TIDUMP("TIDAC_misc_ctrl",TIDAC_misc_ctrl); - TIDUMP("TIDAC_pll_addr",TIDAC_pll_addr); - TIDUMP("TIDAC_pll_pixel_data",TIDAC_pll_pixel_data); - TIDUMP("TIDAC_pll_memory_data",TIDAC_pll_memory_data); - TIDUMP("TIDAC_pll_loop_data",TIDAC_pll_loop_data); - TIDUMP("TIDAC_key_over_low",TIDAC_key_over_low); - TIDUMP("TIDAC_key_over_high",TIDAC_key_over_high); - TIDUMP("TIDAC_key_red_low",TIDAC_key_red_low); - TIDUMP("TIDAC_key_red_high",TIDAC_key_red_high); - TIDUMP("TIDAC_key_green_low",TIDAC_key_green_low); - TIDUMP("TIDAC_key_green_high",TIDAC_key_green_high); - TIDUMP("TIDAC_key_blue_low",TIDAC_key_blue_low); - TIDUMP("TIDAC_key_blue_high",TIDAC_key_blue_high); - TIDUMP("TIDAC_key_ctrl",TIDAC_key_ctrl); - TIDUMP("TIDAC_clock_ctrl",TIDAC_clock_ctrl); - TIDUMP("TIDAC_sense_test",TIDAC_sense_test); - TIDUMP("TIDAC_test_mode_data",TIDAC_test_mode_data); - TIDUMP("TIDAC_crc_remain_lsb",TIDAC_crc_remain_lsb); - TIDUMP("TIDAC_crc_remain_msb",TIDAC_crc_remain_msb); - TIDUMP("TIDAC_crc_bit_select",TIDAC_crc_bit_select); - TIDUMP("TIDAC_id",TIDAC_id); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tTI3030 PLL regs:\n"); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x00); - TIDUMP("Pixel N",TIDAC_pll_pixel_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x01); - TIDUMP("Pixel M",TIDAC_pll_pixel_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x02); - TIDUMP("Pixel P",TIDAC_pll_pixel_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x00); - TIDUMP("Memory N",TIDAC_pll_memory_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x04); - TIDUMP("Memory M",TIDAC_pll_memory_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x08); - TIDUMP("Memory P",TIDAC_pll_memory_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x00); - TIDUMP("Loop N",TIDAC_pll_loop_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x10); - TIDUMP("Loop M",TIDAC_pll_loop_data); - glintOutTIIndReg(pScrn, TIDAC_pll_addr, 0, 0x20); - TIDUMP("Loop P",TIDAC_pll_loop_data); -} -#endif - -static int -Shiftbpp(ScrnInfoPtr pScrn, int value) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - int logbytesperaccess; - - if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) || - (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ) - logbytesperaccess = 4; - else - logbytesperaccess = 3; - - switch (pScrn->bitsPerPixel) { - case 8: - value >>= logbytesperaccess; - pGlint->BppShift = logbytesperaccess; - break; - case 16: - if (pGlint->DoubleBuffer) { - value >>= (logbytesperaccess-2); - pGlint->BppShift = logbytesperaccess-2; - } else { - value >>= (logbytesperaccess-1); - pGlint->BppShift = logbytesperaccess-1; - } - break; - case 24: - value *= 3; - value >>= logbytesperaccess; - pGlint->BppShift = logbytesperaccess; - break; - case 32: - value >>= (logbytesperaccess-2); - pGlint->BppShift = logbytesperaccess-2; - break; - } - return (value); -} - -Bool -DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - GLINTRegPtr pReg = &pGlint->ModeReg; - RamDacHWRecPtr pTI = RAMDACHWPTR(pScrn); - RamDacRegRecPtr ramdacReg = &pTI->ModeReg; - CARD32 temp1, temp2, temp3, temp4; - - pReg->glintRegs[Aperture0 >> 3] = 0; - pReg->glintRegs[Aperture1 >> 3] = 0; - - if (pGlint->UsePCIRetry) { - pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) | 0x01; - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) - pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01; - else - pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x03; - } else { - pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) & 0xFFFFFFFE; - pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01; - } - - temp1 = mode->CrtcHSyncStart - mode->CrtcHDisplay; - temp2 = mode->CrtcVSyncStart - mode->CrtcVDisplay; - temp3 = mode->CrtcHSyncEnd - mode->CrtcHSyncStart; - temp4 = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; - - pReg->glintRegs[VTGHLimit >> 3] = Shiftbpp(pScrn,mode->CrtcHTotal); - pReg->glintRegs[VTGHSyncEnd >> 3] = Shiftbpp(pScrn, temp1 + temp3); - pReg->glintRegs[VTGHSyncStart >> 3] = Shiftbpp(pScrn, temp1); - pReg->glintRegs[VTGHBlankEnd >> 3] = Shiftbpp(pScrn, mode->CrtcHTotal - - mode->CrtcHDisplay); - - pReg->glintRegs[VTGVLimit >> 3] = mode->CrtcVTotal; - pReg->glintRegs[VTGVSyncEnd >> 3] = temp2 + temp4; - pReg->glintRegs[VTGVSyncStart >> 3] = temp2; - pReg->glintRegs[VTGVBlankEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay; - -#if 1 /* We force them high */ - pReg->glintRegs[VTGPolarity >> 3] = 0xBA; -#else - pReg->glintRegs[VTGPolarity >> 3] = (((mode->Flags & V_PHSYNC) ? 0:2)<<2) | - ((mode->Flags & V_PVSYNC) ? 0 : 2) | (0xb0); -#endif - - pReg->glintRegs[VClkCtl >> 3] = 0; - pReg->glintRegs[VTGVGateStart >> 3] = pReg->glintRegs[VTGVBlankEnd>>3] - 1; - pReg->glintRegs[VTGVGateEnd >> 3] = pReg->glintRegs[VTGVBlankEnd>>3]; - /* - * tell DAC to use the ICD chip clock 0 as ref clock - * and set up some more video timing generator registers - */ - pReg->glintRegs[VTGHGateStart >> 3] = pReg->glintRegs[VTGHBlankEnd>>3] - 1; - pReg->glintRegs[VTGHGateEnd >> 3] = pReg->glintRegs[VTGHLimit>>3] - 1; - pReg->glintRegs[VTGSerialClk >> 3] = 0x0002; - pReg->glintRegs[FBModeSel >> 3] = 0x907; - pReg->glintRegs[VTGModeCtl >> 3] = 0x04; - - /* - * Setup memory control registers for FB and LB - */ - pReg->glintRegs[FBMemoryCtl >> 3] = 0x00000800; - pReg->glintRegs[LBMemoryEDO >> 3] = GLINT_READ_REG(LBMemoryEDO); - pReg->glintRegs[LBMemoryEDO >> 3] &= ~(LBEDOMask | - LBEDOBankSizeMask | - LBTwoPageDetectorMask); - pReg->glintRegs[LBMemoryEDO >> 3] |= (LBEDOEnabled | - LBEDOBankSize4M | - LBTwoPageDetector); - pReg->glintRegs[LBMemoryCtl >> 3] = GLINT_READ_REG(LBMemoryCtl); - pReg->glintRegs[LBMemoryCtl >> 3] &= ~(LBNumBanksMask | - LBPageSizeMask | - LBRASCASLowMask | - LBRASPrechargeMask | - LBCASLowMask | - LBPageModeMask | - LBRefreshCountMask); - pReg->glintRegs[LBMemoryCtl >> 3] |= (LBNumBanks2 | - LBPageSize1024 | - LBRASCASLow2 | - LBRASPrecharge2 | - LBCASLow1 | - LBPageModeEnabled | - (0x20 << LBRefreshCountShift)); - pReg->glintRegs[GCSRAperture >> 3] = GCSRSecondaryGLINTMapEn; - - /* - * Setup HW - * - * Note: The order of discovery for the MX devices is dependent - * on which way the resource allocation code decides to scan the - * bus. This setup assumes the first MX found owns the even - * scanlines. Should the implementation change an scan the bus - * in the opposite direction, then simple invert the indices for - * MXPciInfo below. If this is setup wrong, the bug will appear - * as incorrect scanline interleaving when software rendering. - */ - pReg->glintRegs[GMultGLINTAperture >> 3] = pGlint->realMXWidth; - pReg->glintRegs[GMultGLINT1 >> 3] = - pGlint->MXPciInfo[0]->memBase[2] & 0xFF800000; - pReg->glintRegs[GMultGLINT2 >> 3] = - pGlint->MXPciInfo[1]->memBase[2] & 0xFF800000; - - /* Copy info to secondary regs */ - pReg->glintSecondRegs[Aperture0>>3] = pReg->glintRegs[Aperture0>>3]; - pReg->glintSecondRegs[Aperture1>>3] = pReg->glintRegs[Aperture1>>3]; - - pReg->glintSecondRegs[DFIFODis>>3] = pReg->glintRegs[DFIFODis>>3]; - pReg->glintSecondRegs[FIFODis>>3] = pReg->glintRegs[FIFODis>>3]; - pReg->glintSecondRegs[VTGHLimit>>3] = pReg->glintRegs[VTGHLimit>>3]; - pReg->glintSecondRegs[VTGHSyncEnd>>3] = pReg->glintRegs[VTGHSyncEnd>>3]; - pReg->glintSecondRegs[VTGHSyncStart>>3] = pReg->glintRegs[VTGHSyncStart>>3]; - pReg->glintSecondRegs[VTGHBlankEnd>>3] = pReg->glintRegs[VTGHBlankEnd>>3]; - pReg->glintSecondRegs[VTGVLimit>>3] = pReg->glintRegs[VTGVLimit>>3]; - pReg->glintSecondRegs[VTGVSyncEnd>>3] = pReg->glintRegs[VTGVSyncEnd>>3]; - pReg->glintSecondRegs[VTGVSyncStart>>3] = pReg->glintRegs[VTGVSyncStart>>3]; - pReg->glintSecondRegs[VTGVBlankEnd>>3] = pReg->glintRegs[VTGVBlankEnd>>3]; - pReg->glintSecondRegs[VTGPolarity>>3] = pReg->glintRegs[VTGPolarity>>3]; - pReg->glintSecondRegs[VClkCtl>>3] = pReg->glintRegs[VClkCtl>>3]; - pReg->glintSecondRegs[VTGVGateStart>>3] = pReg->glintRegs[VTGVGateStart>>3]; - pReg->glintSecondRegs[VTGVGateEnd>>3] = pReg->glintRegs[VTGVGateEnd>>3]; - pReg->glintSecondRegs[VTGSerialClk>>3] = pReg->glintRegs[VTGSerialClk>>3]; - pReg->glintSecondRegs[VTGHGateStart>>3] = pReg->glintRegs[VTGHGateStart>>3]; - pReg->glintSecondRegs[VTGHGateEnd>>3] = pReg->glintRegs[VTGHGateEnd>>3]; - pReg->glintSecondRegs[FBModeSel>>3] = pReg->glintRegs[FBModeSel>>3]; - pReg->glintSecondRegs[VTGModeCtl>>3] = pReg->glintRegs[VTGModeCtl>>3]; - pReg->glintSecondRegs[FBMemoryCtl>>3] = pReg->glintRegs[FBMemoryCtl>>3]; - pReg->glintSecondRegs[LBMemoryEDO>>3] = pReg->glintRegs[LBMemoryEDO>>3]; - pReg->glintSecondRegs[LBMemoryCtl>>3] = pReg->glintRegs[LBMemoryCtl>>3]; - pReg->glintSecondRegs[GCSRAperture>>3] = pReg->glintRegs[GCSRAperture>>3]; - pReg->glintSecondRegs[GMultGLINTAperture>>3] = - pReg->glintRegs[GMultGLINTAperture>>3]; - pReg->glintSecondRegs[GMultGLINT1>>3] = pReg->glintRegs[GMultGLINT1>>3]; - pReg->glintSecondRegs[GMultGLINT2>>3] = pReg->glintRegs[GMultGLINT2>>3]; - - switch (pGlint->RamDac->RamDacType) { - case TI3030_RAMDAC: - case TI3026_RAMDAC: - { - /* Get the programmable clock values */ - unsigned long m=0,n=0,p=0; - unsigned long clock; - int count; - unsigned long q, status, VCO; - - clock = TIramdacCalculateMNPForClock(pGlint->RefClock, - mode->Clock, 1, pGlint->MinClock, pGlint->MaxClock, &m, &n, &p); - - ramdacReg->DacRegs[TIDAC_PIXEL_N] = ((n & 0x3f) | 0xc0); - ramdacReg->DacRegs[TIDAC_PIXEL_M] = (m & 0x3f) ; - ramdacReg->DacRegs[TIDAC_PIXEL_P] = ((p & 0x03) | 0xb0); - ramdacReg->DacRegs[TIDAC_PIXEL_VALID] = TRUE; - - if (pGlint->RamDac->RamDacType == (TI3026_RAMDAC)) - n = 65 - ((64 << 2) / pScrn->bitsPerPixel); - else - n = 65 - ((128 << 2) / pScrn->bitsPerPixel); - m = 61; - p = 0; - for (q = 0; q < 8; q++) { - if (q > 0) p = 3; - for ( ; p < 4; p++) { - VCO = ((clock * (q + 1) * (65 - m)) / (65 - n)) << (p + 1); - if (VCO >= 110000) { break; } - } - if (VCO >= 110000) { break; } - } - ramdacReg->DacRegs[TIDAC_clock_ctrl] = (q | 0x38); - - ramdacReg->DacRegs[TIDAC_LOOP_N] = ((n & 0x3f) | 0xc0); - ramdacReg->DacRegs[TIDAC_LOOP_M] = (m & 0x3f) ; - ramdacReg->DacRegs[TIDAC_LOOP_P] = ((p & 0x03) | 0xf0); - ramdacReg->DacRegs[TIDAC_LOOP_VALID] = TRUE; - } - break; - } - - /* Now use helper routines to setup bpp for this driver */ - (*pGlint->RamDac->SetBpp)(pScrn, ramdacReg); - - return(TRUE); -} - -void -DualMXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - glintReg->glintRegs[Aperture0 >> 3] = GLINT_READ_REG(Aperture0); - glintReg->glintRegs[Aperture1 >> 3] = GLINT_READ_REG(Aperture1); - - glintReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis); - glintReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis); - - glintReg->glintRegs[VClkCtl >> 3] = GLINT_READ_REG(VClkCtl); - glintReg->glintRegs[VTGPolarity >> 3] = GLINT_READ_REG(VTGPolarity); - glintReg->glintRegs[VTGHLimit >> 3] = GLINT_READ_REG(VTGHLimit); - glintReg->glintRegs[VTGHBlankEnd >> 3] = GLINT_READ_REG(VTGHBlankEnd); - glintReg->glintRegs[VTGHSyncStart >> 3] = GLINT_READ_REG(VTGHSyncStart); - glintReg->glintRegs[VTGHSyncEnd >> 3] = GLINT_READ_REG(VTGHSyncEnd); - glintReg->glintRegs[VTGVLimit >> 3] = GLINT_READ_REG(VTGVLimit); - glintReg->glintRegs[VTGVBlankEnd >> 3] = GLINT_READ_REG(VTGVBlankEnd); - glintReg->glintRegs[VTGVSyncStart >> 3] = GLINT_READ_REG(VTGVSyncStart); - glintReg->glintRegs[VTGVSyncEnd >> 3] = GLINT_READ_REG(VTGVSyncEnd); - glintReg->glintRegs[VTGVGateStart >> 3] = GLINT_READ_REG(VTGVGateStart); - glintReg->glintRegs[VTGVGateEnd >> 3] = GLINT_READ_REG(VTGVGateEnd); - glintReg->glintRegs[VTGSerialClk >> 3] = GLINT_READ_REG(VTGSerialClk); - glintReg->glintRegs[FBModeSel >> 3] = GLINT_READ_REG(FBModeSel); - glintReg->glintRegs[VTGModeCtl >> 3] = GLINT_READ_REG(VTGModeCtl); - glintReg->glintRegs[VTGHGateStart >> 3] = GLINT_READ_REG(VTGHGateStart); - glintReg->glintRegs[VTGHGateEnd >> 3] = GLINT_READ_REG(VTGHGateEnd); - glintReg->glintRegs[FBMemoryCtl >> 3] = GLINT_READ_REG(FBMemoryCtl); - glintReg->glintRegs[LBMemoryEDO >> 3] = GLINT_READ_REG(LBMemoryEDO); - glintReg->glintRegs[LBMemoryCtl >> 3] = GLINT_READ_REG(LBMemoryCtl); - glintReg->glintRegs[GCSRAperture >> 3] = GLINT_READ_REG(GCSRAperture); - glintReg->glintRegs[GMultGLINTAperture>>3] = - GLINT_READ_REG(GMultGLINTAperture); - glintReg->glintRegs[GMultGLINT1>>3] = GLINT_READ_REG(GMultGLINT1); - glintReg->glintRegs[GMultGLINT2>>3] = GLINT_READ_REG(GMultGLINT2); - - glintReg->glintSecondRegs[Aperture0 >> 3] = - GLINT_SECONDARY_READ_REG(Aperture0); - glintReg->glintSecondRegs[Aperture1 >> 3] = - GLINT_SECONDARY_READ_REG(Aperture1); - - glintReg->glintSecondRegs[DFIFODis >> 3] = - GLINT_SECONDARY_READ_REG(DFIFODis); - glintReg->glintSecondRegs[FIFODis >> 3] = - GLINT_SECONDARY_READ_REG(FIFODis); - - glintReg->glintSecondRegs[VClkCtl >> 3] = - GLINT_SECONDARY_READ_REG(VClkCtl); - glintReg->glintSecondRegs[VTGPolarity >> 3] = - GLINT_SECONDARY_READ_REG(VTGPolarity); - glintReg->glintSecondRegs[VTGHLimit >> 3] = - GLINT_SECONDARY_READ_REG(VTGHLimit); - glintReg->glintSecondRegs[VTGHBlankEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGHBlankEnd); - glintReg->glintSecondRegs[VTGHSyncStart >> 3] = - GLINT_SECONDARY_READ_REG(VTGHSyncStart); - glintReg->glintSecondRegs[VTGHSyncEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGHSyncEnd); - glintReg->glintSecondRegs[VTGVLimit >> 3] = - GLINT_SECONDARY_READ_REG(VTGVLimit); - glintReg->glintSecondRegs[VTGVBlankEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGVBlankEnd); - glintReg->glintSecondRegs[VTGVSyncStart >> 3] = - GLINT_SECONDARY_READ_REG(VTGVSyncStart); - glintReg->glintSecondRegs[VTGVSyncEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGVSyncEnd); - glintReg->glintSecondRegs[VTGVGateStart >> 3] = - GLINT_SECONDARY_READ_REG(VTGVGateStart); - glintReg->glintSecondRegs[VTGVGateEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGVGateEnd); - glintReg->glintSecondRegs[VTGSerialClk >> 3] = - GLINT_SECONDARY_READ_REG(VTGSerialClk); - glintReg->glintSecondRegs[FBModeSel >> 3] = - GLINT_SECONDARY_READ_REG(FBModeSel); - glintReg->glintSecondRegs[VTGModeCtl >> 3] = - GLINT_SECONDARY_READ_REG(VTGModeCtl); - glintReg->glintSecondRegs[VTGHGateStart >> 3] = - GLINT_SECONDARY_READ_REG(VTGHGateStart); - glintReg->glintSecondRegs[VTGHGateEnd >> 3] = - GLINT_SECONDARY_READ_REG(VTGHGateEnd); - glintReg->glintSecondRegs[FBMemoryCtl >> 3] = - GLINT_SECONDARY_READ_REG(FBMemoryCtl); - glintReg->glintSecondRegs[LBMemoryEDO >> 3] = - GLINT_SECONDARY_READ_REG(LBMemoryEDO); - glintReg->glintSecondRegs[LBMemoryCtl >> 3] = - GLINT_SECONDARY_READ_REG(LBMemoryCtl); - glintReg->glintSecondRegs[GCSRAperture >> 3] = - GLINT_SECONDARY_READ_REG(GCSRAperture); - glintReg->glintSecondRegs[GMultGLINTAperture>>3] = - GLINT_SECONDARY_READ_REG(GMultGLINTAperture); - glintReg->glintSecondRegs[GMultGLINT1>>3] = - GLINT_SECONDARY_READ_REG(GMultGLINT1); - glintReg->glintSecondRegs[GMultGLINT2>>3] = - GLINT_SECONDARY_READ_REG(GMultGLINT2); -} - -void -DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - -#if 0 - GLINT_SLOW_WRITE_REG(0, ResetStatus); - while(GLINT_READ_REG(ResetStatus) != 0) { - xf86MsgVerb(X_INFO, 2, "Resetting Engine - Please Wait.\n"); - }; -#endif - - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture0 >> 3], Aperture0); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture1 >> 3], Aperture1); - - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[DFIFODis >> 3], DFIFODis); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FIFODis >> 3], FIFODis); - - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGPolarity >> 3], VTGPolarity); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGSerialClk >> 3], VTGSerialClk); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGModeCtl >> 3], VTGModeCtl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHLimit >> 3], VTGHLimit); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHSyncStart >> 3],VTGHSyncStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHSyncEnd >> 3], VTGHSyncEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHBlankEnd >> 3], VTGHBlankEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVLimit >> 3], VTGVLimit); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVSyncStart >> 3],VTGVSyncStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVSyncEnd >> 3], VTGVSyncEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVBlankEnd >> 3], VTGVBlankEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVGateStart >> 3],VTGVGateStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGVGateEnd >> 3], VTGVGateEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FBModeSel >> 3], FBModeSel); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHGateStart >> 3],VTGHGateStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHGateEnd >> 3], VTGHGateEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FBMemoryCtl >> 3], FBMemoryCtl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[LBMemoryEDO >> 3], LBMemoryEDO); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[LBMemoryCtl >> 3], LBMemoryCtl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GCSRAperture >> 3], GCSRAperture); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINTAperture >> 3], - GMultGLINTAperture); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINT1 >> 3], GMultGLINT1); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINT2 >> 3], GMultGLINT2); - - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[Aperture0 >> 3], Aperture0); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[Aperture1 >> 3], Aperture1); - - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[DFIFODis >> 3], DFIFODis); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[FIFODis >> 3], FIFODis); - - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGPolarity >> 3], VTGPolarity); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGSerialClk >> 3], VTGSerialClk); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGModeCtl >> 3], VTGModeCtl); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHLimit >> 3], VTGHLimit); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHSyncStart >> 3],VTGHSyncStart); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHSyncEnd >> 3], VTGHSyncEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHBlankEnd >> 3], VTGHBlankEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVLimit >> 3], VTGVLimit); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVSyncStart >> 3],VTGVSyncStart); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVSyncEnd >> 3], VTGVSyncEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVBlankEnd >> 3], VTGVBlankEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVGateStart >> 3],VTGVGateStart); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGVGateEnd >> 3], VTGVGateEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[FBModeSel >> 3], FBModeSel); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHGateStart >> 3],VTGHGateStart); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[VTGHGateEnd >> 3], VTGHGateEnd); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[FBMemoryCtl >> 3], FBMemoryCtl); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[LBMemoryEDO >> 3], LBMemoryEDO); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[LBMemoryCtl >> 3], LBMemoryCtl); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[GCSRAperture >> 3], GCSRAperture); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[GMultGLINTAperture >>3], GMultGLINTAperture); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[GMultGLINT1 >> 3], GMultGLINT1); - GLINT_SECONDARY_SLOW_WRITE_REG( - glintReg->glintSecondRegs[GMultGLINT2 >> 3], GMultGLINT2); -} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp deleted file mode 100644 index 00ba3b542..000000000 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp +++ /dev/null @@ -1,114 +0,0 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp,v 1.10 2000/12/11 20:18:13 dawes Exp $ -.\" shorthand for double quote that works everywhere. -.ds q \N'34' -.TH GLINT __drivermansuffix__ "Version 4.0.2" "XFree86" -.SH NAME -glint \- GLINT/Permedia video driver -.SH SYNOPSIS -.nf -.B "Section \*qDevice\*q" -.BI " Identifier \*q" devname \*q -.B " Driver \*qglint\*q" -\ \ ... -.B EndSection -.fi -.SH DESCRIPTION -.B glint -is an XFree86 driver for 3Dlabs & Texas Instruments GLINT/Permedia based video -cards. The driver is rather fully accelerated, and provides support for the -following framebuffer depths: 8, 15 (may give bad results with FBDev support), -16, 24 (32 bpp recommended, 24 bpp has problems), 30, and an 8+24 overlay mode. -.SH SUPPORTED HARDWARE -The -.B glint -driver supports 3Dlabs (GLINT MX, GLINT 500TX, GLINT GAMMA, Permedia, -Permedia 2, Permedia 2v, Permedia 3) and Texas Instruments (Permedia, -Permedia 2) chips. -.SH CONFIGURATION DETAILS -Please refer to XF86Config(__filemansuffix__) for general configuration -details. This section only covers configuration details specific to this -driver. -.PP -The driver auto-detects the chipset type, but the following -.B ChipSet -names may optionally be specified in the config file -.B \*qDevice\*q -section, and will override the auto-detection: -.PP -.RS 4 -"ti_pm2", "ti_pm", "pm3", "pm2v", "pm2", "pm", "500tx", "mx", "gamma". -.RE -.PP -The driver will try to auto-detect the amount of video memory present for all -chips. If it's not detected correctly, the actual amount of video memory should -be specified with a -.B VideoRam -entry in the config file -.B \*qDevice\*q -section. -.PP -Additionally, you may need to specify the bus ID of your card with a -.B BusID -entry in the config file -.B \*qDevice\*q -section, especially with FBDev support. -.PP -The following driver -.B Options -are supported: -.TP -.BI "Option \*qHWCursor\*q \*q" boolean \*q -Enable or disable the HW cursor. Default: on. -.TP -.BI "Option \*qSWCursor\*q \*q" boolean \*q -Enable or disable the SW cursor. Default: off. -This option disables the -.B HWCursor -option and vice versa. -.TP -.BI "Option \*qNoAccel\*q \*q" boolean \*q -Disable or enable acceleration. Default: acceleration is enabled. -.TP -.BI "Option \*qOverlay\*q" -Enable 8+24 overlay mode. Only appropriate for depth 24, 32 bpp. -.RB ( Note: -This hasn't been tested with FBDev support and probably won't work.) -Recognized values are: "8,24", "24,8". Default: off. -.TP -.BI "Option \*qPciRetry\*q \*q" boolean \*q -Enable or disable PCI retries. -.RB ( Note: -This doesn't work with Permedia2 based cards for Amigas.) Default: off. -.TP -.BI "Option \*qShadowFB\*q \*q" boolean \*q -Enable or disable use of the shadow framebuffer layer. See -shadowfb(__drivermansuffix__) for further information. -.RB ( Note: -This disables hardware acceleration.) Default: off. -.TP -.BI "Option \*qUseFBDev\*q \*q" boolean \*q -Enable or disable use of an OS-specific fb interface (which is not supported -on all OSs). See fbdevhw(__drivermansuffix__) for further information. -Default: off. -.ig -.TP -.BI "Option \*qRGBbits\*q \*q" integer \*q -Each gun of the RGB triple can have either 8 or 10 bits. Default: 8 -.. -.TP -.BI "Option \*qBlockWrite\*q \*q" boolean \*q -Enable or disable block writes for the various Permedia 2 chips. This improves -acceleration in general, but disables it for some special cases. Default: off. -.TP -.BI "Option \*qFireGL3000\*q \*q" boolean \*q -If you have a card of the same name, turn this on. Default: off. -.TP -.BI "Option \*qSetMClk\*q \*q" freq \*q -The driver will try to auto-detect the memory clock for all chips. If it's not -detected correctly, the actual value (in MHz) should be specified with this -option. -.SH "SEE ALSO" -XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) -.SH AUTHORS -Authors include: Alan Hourihane, Dirk Hohndel, Stefan Dirsch, Michel Dänzer, -Sven Luther diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h index d7467a00d..52cc1f883 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h @@ -1,6 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.37 2000/11/14 17:32:59 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.44 2001/02/07 13:26:18 alanh Exp $ */ /* - * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk> + * Copyright 1997-2001 by Alan Hourihane <alanh@fairlite.demon.co.uk> * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -45,7 +45,7 @@ #include "glint_dripriv.h" #endif -#define GLINT_MAX_MX_DEVICES 2 +#define GLINT_MAX_MULTI_DEVICES 2 #define GLINT_VGA_MMIO_OFF 0x6000 #define VERSION 4000 @@ -57,21 +57,27 @@ typedef struct { CARD32 glintRegs[0x2000]; - CARD32 glintSecondRegs[0x2000]; - CARD32 DacRegs[0x100]; /* used by internal DACs */ + CARD32 DacRegs[0x100]; CARD8 cmap[0x300]; } GLINTRegRec, *GLINTRegPtr; #define GLINTPTR(p) ((GLINTPtr)((p)->driverPrivate)) typedef struct { + int lastInstance; + int refCount; +} GLINTEntRec, *GLINTEntPtr; + +typedef struct { pciVideoPtr PciInfo; - pciVideoPtr MXPciInfo[GLINT_MAX_MX_DEVICES]; - int numMXDevices; + pciVideoPtr MultiPciInfo[GLINT_MAX_MULTI_DEVICES]; + int numMultiDevices; + int MultiChip; + Bool MultiAperture; PCITAG PciTag; EntityInfoPtr pEnt; + GLINTEntPtr entityPrivate; RamDacHelperRecPtr RamDac; - int MemClock; int Chipset; int ChipRev; int HwBpp; @@ -94,7 +100,7 @@ typedef struct { int cpuheight; int cpucount; int planemask; - int realMXWidth; + int realWidth; CARD32 IOAddress; unsigned long FbAddress; int irq; @@ -102,6 +108,7 @@ typedef struct { unsigned char * IOBaseVGA; unsigned char * FbBase; long FbMapSize; + long IOOffset; DGAModePtr DGAModes; int numDGAModes; Bool DGAactive; @@ -110,47 +117,52 @@ typedef struct { Bool NoAccel; Bool FBDev; Bool ShadowFB; - Bool WriteBitmap; unsigned char * ShadowPtr; int ShadowPitch; Bool Dac6Bit; Bool HWCursor; Bool ClippingOn; - Bool UsePCIRetry; Bool UseBlockWrite; Bool UseFireGL3000; + CARD8 VGAdata[65536]; Bool VGAcore; + Bool STATE; + Bool ScanlineDirect; int MXFbSize; CARD32 rasterizerMode; int MinClock; int MaxClock; int RefClock; - GLINTRegRec SavedReg; - GLINTRegRec ModeReg; + GLINTRegRec SavedReg[GLINT_MAX_MULTI_DEVICES]; + GLINTRegRec ModeReg[GLINT_MAX_MULTI_DEVICES]; CARD32 AccelFlags; CARD32 ROP; CARD32 FrameBufferReadMode; CARD32 BltScanDirection; CARD32 TexMapFormat; CARD32 PixelWidth; + CARD32 FIFOSize; RamDacRecPtr RamDacRec; xf86CursorInfoPtr CursorInfoRec; XAAInfoRecPtr AccelInfoRec; CloseScreenProcPtr CloseScreen; + ScreenBlockHandlerProcPtr BlockHandler; GCPtr CurrentGC; DrawablePtr CurrentDrawable; I2CBusPtr DDCBus, VSBus; + CARD32 FGCursor; + CARD32 BGCursor; + CARD8 HardwareCursorPattern[1024]; CARD8* XAAScanlineColorExpandBuffers[2]; + CARD8* ScratchBuffer; CARD32 RasterizerSwap; + void (*LoadCursorCallback)(ScrnInfoPtr); + void (*CursorColorCallback)(ScrnInfoPtr); + CARD32 PM3_PixelSize; int PM3_Config2D; int PM3_Render2D; int PM3_AreaStippleMode; int PM3_VideoControl; - Bool PM3_UseGamma; - pciVideoPtr PM3_GammaPciInfo; - PCITAG PM3_GammaPciTag; - CARD32 PM3_GammaIOAddress; - unsigned char * PM3_GammaIOBase; #ifdef XF86DRI Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -212,28 +224,24 @@ void PermediaInitializeEngine(ScrnInfoPtr pScrn); void Permedia2VRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void Permedia2VSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool Permedia2VInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void Permedia2VPreInit(ScrnInfoPtr pScrn); Bool Permedia2vHWCursorInit(ScreenPtr pScreen); -/* pm3_dac.c */ void Permedia3PreInit(ScrnInfoPtr pScrn); int Permedia3MemorySizeDetect(ScrnInfoPtr pScrn); void Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); -Bool Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode); -/* pm3_accel.c */ -/* Not needed, ... is it ever called outside of pm3_accel.c ? -void Permedia3Sync(ScrnInfoPtr pScrn); -*/ +Bool Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode, GLINTRegPtr pReg); Bool Permedia3AccelInit(ScreenPtr pScreen); void Permedia3InitializeEngine(ScrnInfoPtr pScrn); -/* End of pm3 stuff */ void TXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void TXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); -Bool TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +Bool TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode, GLINTRegPtr glintReg); Bool TXAccelInit(ScreenPtr pScreen); void TXInitializeEngine(ScrnInfoPtr pScrn); +void SXInitializeEngine(ScrnInfoPtr pScrn); Bool SXAccelInit(ScreenPtr pScreen); void DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); @@ -256,17 +264,17 @@ Bool glintIBM640HWCursorInit(ScreenPtr pScreen); void glintOutTIIndReg(ScrnInfoPtr pScrn, CARD32 reg, unsigned char mask, unsigned char data); unsigned char glintInTIIndReg(ScrnInfoPtr pScrn, CARD32 reg); -void DUALglintOutTIIndReg(ScrnInfoPtr pScrn, +void GMX2000OutIndReg(ScrnInfoPtr pScrn, CARD32 reg, unsigned char mask, unsigned char data); -unsigned char DUALglintInTIIndReg(ScrnInfoPtr pScrn, CARD32 reg); +unsigned char GMX2000InIndReg(ScrnInfoPtr pScrn, CARD32 reg); void glintTIWriteAddress(ScrnInfoPtr pScrn, CARD32 index); void glintTIReadAddress(ScrnInfoPtr pScrn, CARD32 index); void glintTIWriteData(ScrnInfoPtr pScrn, unsigned char data); unsigned char glintTIReadData(ScrnInfoPtr pScrn); -void DUALglintTIWriteAddress(ScrnInfoPtr pScrn, CARD32 index); -void DUALglintTIReadAddress(ScrnInfoPtr pScrn, CARD32 index); -void DUALglintTIWriteData(ScrnInfoPtr pScrn, unsigned char data); -unsigned char DUALglintTIReadData(ScrnInfoPtr pScrn); +void GMX2000WriteAddress(ScrnInfoPtr pScrn, CARD32 index); +void GMX2000ReadAddress(ScrnInfoPtr pScrn, CARD32 index); +void GMX2000WriteData(ScrnInfoPtr pScrn, unsigned char data); +unsigned char GMX2000ReadData(ScrnInfoPtr pScrn); Bool glintTIHWCursorInit(ScreenPtr pScreen); void Permedia2OutIndReg(ScrnInfoPtr pScrn, @@ -282,6 +290,10 @@ void Permedia2LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual); void Permedia2LoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual); +void Permedia3LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); +void Permedia3LoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); void Permedia2I2CUDelay(I2CBusPtr b, int usec); void Permedia2I2CPutBits(I2CBusPtr b, int scl, int sda); void Permedia2I2CGetBits(I2CBusPtr b, int *scl, int *sda); @@ -300,6 +312,8 @@ void GLINTAdjustFrame(int scrnIndex, int x, int y, int flags); extern int partprodPermedia[]; +Bool GLINTDGAInit(ScreenPtr pScreen); + Bool GLINTDRIScreenInit(ScreenPtr pScreen); Bool GLINTDRIFinishScreenInit(ScreenPtr pScreen); void GLINTDRICloseScreen(ScreenPtr pScreen); @@ -314,4 +328,10 @@ void GLINT_VERB_WRITE_REG(GLINTPtr, CARD32 v, int r, char *file, int line); CARD32 GLINT_VERB_READ_REG(GLINTPtr, CARD32 r, char *file, int line); void GLINTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); + +void GLINT_MoveBYTE(CARD32* dest, unsigned char* src, int dwords); +void GLINT_MoveWORDS(CARD32* dest, unsigned short* src, int dwords); +void GLINT_MoveDWORDS(CARD32* dest, CARD32* src, int dwords); + +int Shiftbpp(ScrnInfoPtr pScrn, int value); #endif /* _GLINT_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c index 2c6ed447f..a82d7da8a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c @@ -1,5 +1,5 @@ /* - * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK. + * Copyright 2000-2001 by Alan Hourihane, Sychdyn, North Wales, UK. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c,v 1.1 2000/05/10 18:55:29 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c,v 1.2 2001/01/31 16:14:54 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -54,9 +54,8 @@ DGAFunctionRec GLINTDGAFuncs = { GLINT_GetViewport, GLINT_Sync, GLINT_FillRect, - NULL, -#if 0 GLINT_BlitRect, +#if 0 GLINT_BlitTransRect #else NULL diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c index 6cf4650f2..2da9bb004 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.18 2000/06/23 23:43:43 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.21 2001/02/07 13:26:18 alanh Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -305,8 +305,9 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) LBRF_FrameCountPos24 | LBRF_GIDWidth4 | LBRF_GIDPos32 ), LBWriteFormat); - if (pGlint->numMXDevices == 2) { - GLINT_SECONDARY_SLOW_WRITE_REG( + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + GLINT_SLOW_WRITE_REG( (LBRF_DepthWidth16 | LBRF_StencilWidth8 | LBRF_StencilPos16 | @@ -314,7 +315,7 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) LBRF_FrameCountPos24 | LBRF_GIDWidth4 | LBRF_GIDPos32 ), LBReadFormat); - GLINT_SECONDARY_SLOW_WRITE_REG( + GLINT_SLOW_WRITE_REG( (LBRF_DepthWidth16 | LBRF_StencilWidth8 | LBRF_StencilPos16 | @@ -322,6 +323,7 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) LBRF_FrameCountPos24 | LBRF_GIDWidth4 | LBRF_GIDPos32 ), LBWriteFormat); + ACCESSCHIP1(); } return TRUE; @@ -361,7 +363,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen) if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_GAMMA) return FALSE; - if (pGlint->numMXDevices > 2) return FALSE; + if (pGlint->numMultiDevices > 2) return FALSE; pDRIInfo = DRICreateInfoRec(); if(pDRIInfo == NULL) @@ -455,7 +457,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen) } /* Tell the client driver how many MX's we have */ - pGlintDRI->numMXDevices = pGlint->numMXDevices; + pGlintDRI->numMultiDevices = pGlint->numMultiDevices; /* Tell the client about our screen size setup */ pGlintDRI->pprod = pGlint->pprod; @@ -831,68 +833,70 @@ GLINTDRISwapContext( pRC->MX1.CFilterMode = GLINT_READ_REG(FilterMode); pRC->MX1.CStatisticMode = GLINT_READ_REG(StatisticMode); - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { pRC->MX1.CBroadcastMask = GLINT_READ_REG(BroadcastMask); - pRC->MX2.CStartXDom = GLINT_SECONDARY_READ_REG(StartXDom); - pRC->MX2.CdXDom = GLINT_SECONDARY_READ_REG(dXDom); - pRC->MX2.CStartXSub = GLINT_SECONDARY_READ_REG(StartXSub); - pRC->MX2.CdXSub = GLINT_SECONDARY_READ_REG(dXSub); - pRC->MX2.CStartY = GLINT_SECONDARY_READ_REG(StartY); - pRC->MX2.CdY = GLINT_SECONDARY_READ_REG(dY); - pRC->MX2.CGLINTCount = GLINT_SECONDARY_READ_REG(GLINTCount); - pRC->MX2.CPointTable0 = GLINT_SECONDARY_READ_REG(PointTable0); - pRC->MX2.CPointTable1 = GLINT_SECONDARY_READ_REG(PointTable1); - pRC->MX2.CPointTable2 = GLINT_SECONDARY_READ_REG(PointTable2); - pRC->MX2.CPointTable3 = GLINT_SECONDARY_READ_REG(PointTable3); - pRC->MX2.CRasterizerMode = GLINT_SECONDARY_READ_REG(RasterizerMode); - pRC->MX2.CYLimits = GLINT_SECONDARY_READ_REG(YLimits); - pRC->MX2.CScanLineOwnership = GLINT_SECONDARY_READ_REG(ScanLineOwnership); - pRC->MX2.CPixelSize = GLINT_SECONDARY_READ_REG(PixelSize); - pRC->MX2.CScissorMode = GLINT_SECONDARY_READ_REG(ScissorMode); - pRC->MX2.CScissorMinXY = GLINT_SECONDARY_READ_REG(ScissorMinXY); - pRC->MX2.CScissorMaxXY = GLINT_SECONDARY_READ_REG(ScissorMaxXY); - pRC->MX2.CScreenSize = GLINT_SECONDARY_READ_REG(ScreenSize); - pRC->MX2.CAreaStippleMode = GLINT_SECONDARY_READ_REG(AreaStippleMode); - pRC->MX2.CLineStippleMode = GLINT_SECONDARY_READ_REG(LineStippleMode); - pRC->MX2.CLoadLineStippleCounters = GLINT_SECONDARY_READ_REG(LoadLineStippleCounters); - pRC->MX2.CWindowOrigin = GLINT_SECONDARY_READ_REG(WindowOrigin); - pRC->MX2.CRouterMode = GLINT_SECONDARY_READ_REG(RouterMode); - pRC->MX2.CTextureAddressMode = GLINT_SECONDARY_READ_REG(TextureAddressMode); - pRC->MX2.CTextureReadMode = GLINT_SECONDARY_READ_REG(TextureReadMode); - pRC->MX2.CTextureColorMode = GLINT_SECONDARY_READ_REG(TextureColorMode); - pRC->MX2.CFogMode = GLINT_SECONDARY_READ_REG(FogMode); - pRC->MX2.CColorDDAMode = GLINT_SECONDARY_READ_REG(ColorDDAMode); - pRC->MX2.CGLINTColor = GLINT_SECONDARY_READ_REG(GLINTColor); - pRC->MX2.CAlphaTestMode = GLINT_SECONDARY_READ_REG(AlphaTestMode); - pRC->MX2.CAntialiasMode = GLINT_SECONDARY_READ_REG(AntialiasMode); - pRC->MX2.CAlphaBlendMode = GLINT_SECONDARY_READ_REG(AlphaBlendMode); - pRC->MX2.CDitherMode = GLINT_SECONDARY_READ_REG(DitherMode); - pRC->MX2.CFBSoftwareWriteMask = GLINT_SECONDARY_READ_REG(FBSoftwareWriteMask); - pRC->MX2.CLogicalOpMode = GLINT_SECONDARY_READ_REG(LogicalOpMode); - pRC->MX2.CFBWriteData = GLINT_SECONDARY_READ_REG(FBWriteData); - pRC->MX2.CLBReadMode = GLINT_SECONDARY_READ_REG(LBReadMode); - pRC->MX2.CLBSourceOffset = GLINT_SECONDARY_READ_REG(LBSourceOffset); - pRC->MX2.CLBWindowBase = GLINT_SECONDARY_READ_REG(LBWindowBase); - pRC->MX2.CLBWriteMode = GLINT_SECONDARY_READ_REG(LBWriteMode); - pRC->MX2.CTextureDownloadOffset = GLINT_SECONDARY_READ_REG(TextureDownloadOffset); - pRC->MX2.CLBWindowOffset = GLINT_SECONDARY_READ_REG(LBWindowOffset); - pRC->MX2.CGLINTWindow = GLINT_SECONDARY_READ_REG(GLINTWindow); - pRC->MX2.CStencilMode = GLINT_SECONDARY_READ_REG(StencilMode); - pRC->MX2.CDepthMode = GLINT_SECONDARY_READ_REG(DepthMode); - pRC->MX2.CGLINTDepth = GLINT_SECONDARY_READ_REG(GLINTDepth); - pRC->MX2.CFBReadMode = GLINT_SECONDARY_READ_REG(FBReadMode); - pRC->MX2.CFBSourceOffset = GLINT_SECONDARY_READ_REG(FBSourceOffset); - pRC->MX2.CFBPixelOffset = GLINT_SECONDARY_READ_REG(FBPixelOffset); - pRC->MX2.CFBWindowBase = GLINT_SECONDARY_READ_REG(FBWindowBase); - pRC->MX2.CFBWriteMode = GLINT_SECONDARY_READ_REG(FBWriteMode); - pRC->MX2.CFBHardwareWriteMask = GLINT_SECONDARY_READ_REG(FBHardwareWriteMask); - pRC->MX2.CFBBlockColor = GLINT_SECONDARY_READ_REG(FBBlockColor); - pRC->MX2.CPatternRamMode = GLINT_SECONDARY_READ_REG(PatternRamMode); - pRC->MX2.CFBBlockColorU = GLINT_SECONDARY_READ_REG(FBBlockColorU); - pRC->MX2.CFBBlockColorL = GLINT_SECONDARY_READ_REG(FBBlockColorL); - pRC->MX2.CFilterMode = GLINT_SECONDARY_READ_REG(FilterMode); - pRC->MX2.CStatisticMode = GLINT_SECONDARY_READ_REG(StatisticMode); + ACCESSCHIP2(); + pRC->MX2.CStartXDom = GLINT_READ_REG(StartXDom); + pRC->MX2.CdXDom = GLINT_READ_REG(dXDom); + pRC->MX2.CStartXSub = GLINT_READ_REG(StartXSub); + pRC->MX2.CdXSub = GLINT_READ_REG(dXSub); + pRC->MX2.CStartY = GLINT_READ_REG(StartY); + pRC->MX2.CdY = GLINT_READ_REG(dY); + pRC->MX2.CGLINTCount = GLINT_READ_REG(GLINTCount); + pRC->MX2.CPointTable0 = GLINT_READ_REG(PointTable0); + pRC->MX2.CPointTable1 = GLINT_READ_REG(PointTable1); + pRC->MX2.CPointTable2 = GLINT_READ_REG(PointTable2); + pRC->MX2.CPointTable3 = GLINT_READ_REG(PointTable3); + pRC->MX2.CRasterizerMode = GLINT_READ_REG(RasterizerMode); + pRC->MX2.CYLimits = GLINT_READ_REG(YLimits); + pRC->MX2.CScanLineOwnership = GLINT_READ_REG(ScanLineOwnership); + pRC->MX2.CPixelSize = GLINT_READ_REG(PixelSize); + pRC->MX2.CScissorMode = GLINT_READ_REG(ScissorMode); + pRC->MX2.CScissorMinXY = GLINT_READ_REG(ScissorMinXY); + pRC->MX2.CScissorMaxXY = GLINT_READ_REG(ScissorMaxXY); + pRC->MX2.CScreenSize = GLINT_READ_REG(ScreenSize); + pRC->MX2.CAreaStippleMode = GLINT_READ_REG(AreaStippleMode); + pRC->MX2.CLineStippleMode = GLINT_READ_REG(LineStippleMode); + pRC->MX2.CLoadLineStippleCounters = GLINT_READ_REG(LoadLineStippleCounters); + pRC->MX2.CWindowOrigin = GLINT_READ_REG(WindowOrigin); + pRC->MX2.CRouterMode = GLINT_READ_REG(RouterMode); + pRC->MX2.CTextureAddressMode = GLINT_READ_REG(TextureAddressMode); + pRC->MX2.CTextureReadMode = GLINT_READ_REG(TextureReadMode); + pRC->MX2.CTextureColorMode = GLINT_READ_REG(TextureColorMode); + pRC->MX2.CFogMode = GLINT_READ_REG(FogMode); + pRC->MX2.CColorDDAMode = GLINT_READ_REG(ColorDDAMode); + pRC->MX2.CGLINTColor = GLINT_READ_REG(GLINTColor); + pRC->MX2.CAlphaTestMode = GLINT_READ_REG(AlphaTestMode); + pRC->MX2.CAntialiasMode = GLINT_READ_REG(AntialiasMode); + pRC->MX2.CAlphaBlendMode = GLINT_READ_REG(AlphaBlendMode); + pRC->MX2.CDitherMode = GLINT_READ_REG(DitherMode); + pRC->MX2.CFBSoftwareWriteMask = GLINT_READ_REG(FBSoftwareWriteMask); + pRC->MX2.CLogicalOpMode = GLINT_READ_REG(LogicalOpMode); + pRC->MX2.CFBWriteData = GLINT_READ_REG(FBWriteData); + pRC->MX2.CLBReadMode = GLINT_READ_REG(LBReadMode); + pRC->MX2.CLBSourceOffset = GLINT_READ_REG(LBSourceOffset); + pRC->MX2.CLBWindowBase = GLINT_READ_REG(LBWindowBase); + pRC->MX2.CLBWriteMode = GLINT_READ_REG(LBWriteMode); + pRC->MX2.CTextureDownloadOffset = GLINT_READ_REG(TextureDownloadOffset); + pRC->MX2.CLBWindowOffset = GLINT_READ_REG(LBWindowOffset); + pRC->MX2.CGLINTWindow = GLINT_READ_REG(GLINTWindow); + pRC->MX2.CStencilMode = GLINT_READ_REG(StencilMode); + pRC->MX2.CDepthMode = GLINT_READ_REG(DepthMode); + pRC->MX2.CGLINTDepth = GLINT_READ_REG(GLINTDepth); + pRC->MX2.CFBReadMode = GLINT_READ_REG(FBReadMode); + pRC->MX2.CFBSourceOffset = GLINT_READ_REG(FBSourceOffset); + pRC->MX2.CFBPixelOffset = GLINT_READ_REG(FBPixelOffset); + pRC->MX2.CFBWindowBase = GLINT_READ_REG(FBWindowBase); + pRC->MX2.CFBWriteMode = GLINT_READ_REG(FBWriteMode); + pRC->MX2.CFBHardwareWriteMask = GLINT_READ_REG(FBHardwareWriteMask); + pRC->MX2.CFBBlockColor = GLINT_READ_REG(FBBlockColor); + pRC->MX2.CPatternRamMode = GLINT_READ_REG(PatternRamMode); + pRC->MX2.CFBBlockColorU = GLINT_READ_REG(FBBlockColorU); + pRC->MX2.CFBBlockColorL = GLINT_READ_REG(FBBlockColorL); + pRC->MX2.CFilterMode = GLINT_READ_REG(FilterMode); + pRC->MX2.CStatisticMode = GLINT_READ_REG(StatisticMode); + ACCESSCHIP1(); } if (readContextType == DRI_3D_CONTEXT) { @@ -1020,133 +1024,135 @@ GLINTDRISwapContext( pRC->MX1.CKdBStart = GLINT_READ_REG(KdBStart); pRC->MX1.CdKdBdx = GLINT_READ_REG(dKdBdx); pRC->MX1.CdKdBdyDom = GLINT_READ_REG(dKdBdyDom); - if (pGlint->numMXDevices == 2) { - pRC->MX2.CSStart = GLINT_SECONDARY_READ_REG(SStart); - pRC->MX2.CdSdx = GLINT_SECONDARY_READ_REG(dSdx); - pRC->MX2.CdSdyDom = GLINT_SECONDARY_READ_REG(dSdyDom); - pRC->MX2.CTStart = GLINT_SECONDARY_READ_REG(TStart); - pRC->MX2.CdTdx = GLINT_SECONDARY_READ_REG(dTdx); - pRC->MX2.CdTdyDom = GLINT_SECONDARY_READ_REG(dTdyDom); - pRC->MX2.CQStart = GLINT_SECONDARY_READ_REG(QStart); - pRC->MX2.CdQdx = GLINT_SECONDARY_READ_REG(dQdx); - pRC->MX2.CdQdyDom = GLINT_SECONDARY_READ_REG(dQdyDom); - pRC->MX2.CLOD = GLINT_SECONDARY_READ_REG(LOD); - pRC->MX2.CdSdy = GLINT_SECONDARY_READ_REG(dSdy); - pRC->MX2.CdTdy = GLINT_SECONDARY_READ_REG(dTdy); - pRC->MX2.CdQdy = GLINT_SECONDARY_READ_REG(dQdy); - pRC->MX2.CTextureFormat = GLINT_SECONDARY_READ_REG(TextureFormat); - pRC->MX2.CTextureCacheControl = GLINT_SECONDARY_READ_REG(TextureCacheControl); - pRC->MX2.CGLINTBorderColor = GLINT_SECONDARY_READ_REG(GLINTBorderColor); - pRC->MX2.CTexelLUTIndex = GLINT_SECONDARY_READ_REG(TexelLUTIndex); - pRC->MX2.CTexelLUTData = GLINT_SECONDARY_READ_REG(TexelLUTData); - pRC->MX2.CTexelLUTAddress = GLINT_SECONDARY_READ_REG(TexelLUTAddress); - pRC->MX2.CTexelLUTTransfer = GLINT_SECONDARY_READ_REG(TexelLUTTransfer); - pRC->MX2.CTextureFilterMode = GLINT_SECONDARY_READ_REG(TextureFilterMode); - pRC->MX2.CTextureChromaUpper = GLINT_SECONDARY_READ_REG(TextureChromaUpper); - pRC->MX2.CTextureChromaLower = GLINT_SECONDARY_READ_REG(TextureChromaLower); - pRC->MX2.CTxBaseAddr0 = GLINT_SECONDARY_READ_REG(TxBaseAddr0); - pRC->MX2.CTxBaseAddr1 = GLINT_SECONDARY_READ_REG(TxBaseAddr1); - pRC->MX2.CTxBaseAddr2 = GLINT_SECONDARY_READ_REG(TxBaseAddr2); - pRC->MX2.CTxBaseAddr3 = GLINT_SECONDARY_READ_REG(TxBaseAddr3); - pRC->MX2.CTxBaseAddr4 = GLINT_SECONDARY_READ_REG(TxBaseAddr4); - pRC->MX2.CTxBaseAddr5 = GLINT_SECONDARY_READ_REG(TxBaseAddr5); - pRC->MX2.CTxBaseAddr6 = GLINT_SECONDARY_READ_REG(TxBaseAddr6); - pRC->MX2.CTxBaseAddr7 = GLINT_SECONDARY_READ_REG(TxBaseAddr7); - pRC->MX2.CTxBaseAddr8 = GLINT_SECONDARY_READ_REG(TxBaseAddr8); - pRC->MX2.CTxBaseAddr9 = GLINT_SECONDARY_READ_REG(TxBaseAddr9); - pRC->MX2.CTxBaseAddr10 = GLINT_SECONDARY_READ_REG(TxBaseAddr10); - pRC->MX2.CTxBaseAddr11 = GLINT_SECONDARY_READ_REG(TxBaseAddr11); - pRC->MX2.CTexelLUT0 = GLINT_SECONDARY_READ_REG(TexelLUT0); - pRC->MX2.CTexelLUT1 = GLINT_SECONDARY_READ_REG(TexelLUT1); - pRC->MX2.CTexelLUT2 = GLINT_SECONDARY_READ_REG(TexelLUT2); - pRC->MX2.CTexelLUT3 = GLINT_SECONDARY_READ_REG(TexelLUT3); - pRC->MX2.CTexelLUT4 = GLINT_SECONDARY_READ_REG(TexelLUT4); - pRC->MX2.CTexelLUT5 = GLINT_SECONDARY_READ_REG(TexelLUT5); - pRC->MX2.CTexelLUT6 = GLINT_SECONDARY_READ_REG(TexelLUT6); - pRC->MX2.CTexelLUT7 = GLINT_SECONDARY_READ_REG(TexelLUT7); - pRC->MX2.CTexelLUT8 = GLINT_SECONDARY_READ_REG(TexelLUT8); - pRC->MX2.CTexelLUT9 = GLINT_SECONDARY_READ_REG(TexelLUT9); - pRC->MX2.CTexelLUT10 = GLINT_SECONDARY_READ_REG(TexelLUT10); - pRC->MX2.CTexelLUT11 = GLINT_SECONDARY_READ_REG(TexelLUT11); - pRC->MX2.CTexelLUT12 = GLINT_SECONDARY_READ_REG(TexelLUT12); - pRC->MX2.CTexelLUT13 = GLINT_SECONDARY_READ_REG(TexelLUT13); - pRC->MX2.CTexelLUT14 = GLINT_SECONDARY_READ_REG(TexelLUT14); - pRC->MX2.CTexelLUT15 = GLINT_SECONDARY_READ_REG(TexelLUT15); - pRC->MX2.CTexel0 = GLINT_SECONDARY_READ_REG(Texel0); - pRC->MX2.CTexel1 = GLINT_SECONDARY_READ_REG(Texel1); - pRC->MX2.CTexel2 = GLINT_SECONDARY_READ_REG(Texel2); - pRC->MX2.CTexel3 = GLINT_SECONDARY_READ_REG(Texel3); - pRC->MX2.CTexel4 = GLINT_SECONDARY_READ_REG(Texel4); - pRC->MX2.CTexel5 = GLINT_SECONDARY_READ_REG(Texel5); - pRC->MX2.CTexel6 = GLINT_SECONDARY_READ_REG(Texel6); - pRC->MX2.CTexel7 = GLINT_SECONDARY_READ_REG(Texel7); - pRC->MX2.CInterp0 = GLINT_SECONDARY_READ_REG(Interp0); - pRC->MX2.CInterp1 = GLINT_SECONDARY_READ_REG(Interp1); - pRC->MX2.CInterp2 = GLINT_SECONDARY_READ_REG(Interp2); - pRC->MX2.CInterp3 = GLINT_SECONDARY_READ_REG(Interp3); - pRC->MX2.CInterp4 = GLINT_SECONDARY_READ_REG(Interp4); - pRC->MX2.CTextureFilter = GLINT_SECONDARY_READ_REG(TextureFilter); - pRC->MX2.CTextureEnvColor = GLINT_SECONDARY_READ_REG(TextureEnvColor); - pRC->MX2.CFogColor = GLINT_SECONDARY_READ_REG(FogColor); - pRC->MX2.CFStart = GLINT_SECONDARY_READ_REG(FStart); - pRC->MX2.CdFdx = GLINT_SECONDARY_READ_REG(dFdx); - pRC->MX2.CdFdyDom = GLINT_SECONDARY_READ_REG(dFdyDom); - pRC->MX2.CKsStart = GLINT_SECONDARY_READ_REG(KsStart); - pRC->MX2.CdKsdx = GLINT_SECONDARY_READ_REG(dKsdx); - pRC->MX2.CdKsdyDom = GLINT_SECONDARY_READ_REG(dKsdyDom); - pRC->MX2.CKdStart = GLINT_SECONDARY_READ_REG(KdStart); - pRC->MX2.CdKdStart = GLINT_SECONDARY_READ_REG(dKdStart); - pRC->MX2.CdKddyDom = GLINT_SECONDARY_READ_REG(dKddyDom); - pRC->MX2.CRStart = GLINT_SECONDARY_READ_REG(RStart); - pRC->MX2.CdRdx = GLINT_SECONDARY_READ_REG(dRdx); - pRC->MX2.CdRdyDom = GLINT_SECONDARY_READ_REG(dRdyDom); - pRC->MX2.CGStart = GLINT_SECONDARY_READ_REG(GStart); - pRC->MX2.CdGdx = GLINT_SECONDARY_READ_REG(dGdx); - pRC->MX2.CdGdyDom = GLINT_SECONDARY_READ_REG(dGdyDom); - pRC->MX2.CBStart = GLINT_SECONDARY_READ_REG(BStart); - pRC->MX2.CdBdx = GLINT_SECONDARY_READ_REG(dBdx); - pRC->MX2.CdBdyDom = GLINT_SECONDARY_READ_REG(dBdyDom); - pRC->MX2.CAStart = GLINT_SECONDARY_READ_REG(AStart); - pRC->MX2.CdAdx = GLINT_SECONDARY_READ_REG(dAdx); - pRC->MX2.CdAdyDom = GLINT_SECONDARY_READ_REG(dAdyDom); - pRC->MX2.CConstantColor = GLINT_SECONDARY_READ_REG(ConstantColor); - pRC->MX2.CChromaUpper = GLINT_SECONDARY_READ_REG(ChromaUpper); - pRC->MX2.CChromaLower = GLINT_SECONDARY_READ_REG(ChromaLower); - pRC->MX2.CChromaTestMode = GLINT_SECONDARY_READ_REG(ChromaTestMode); - pRC->MX2.CStencilData = GLINT_SECONDARY_READ_REG(StencilData); - pRC->MX2.CGLINTStencil = GLINT_SECONDARY_READ_REG(GLINTStencil); - pRC->MX2.CZStartU = GLINT_SECONDARY_READ_REG(ZStartU); - pRC->MX2.CZStartL = GLINT_SECONDARY_READ_REG(ZStartL); - pRC->MX2.CdZdxU = GLINT_SECONDARY_READ_REG(dZdxU); - pRC->MX2.CdZdxL = GLINT_SECONDARY_READ_REG(dZdxL); - pRC->MX2.CdZdyDomU = GLINT_SECONDARY_READ_REG(dZdyDomU); - pRC->MX2.CdZdyDomL = GLINT_SECONDARY_READ_REG(dZdyDomL); - pRC->MX2.CFastClearDepth = GLINT_SECONDARY_READ_REG(FastClearDepth); - pRC->MX2.CMinRegion = GLINT_SECONDARY_READ_REG(MinRegion); - pRC->MX2.CMaxRegion = GLINT_SECONDARY_READ_REG(MaxRegion); - pRC->MX2.CKsRStart = GLINT_SECONDARY_READ_REG(KsRStart); - pRC->MX2.CdKsRdx = GLINT_SECONDARY_READ_REG(dKsRdx); - pRC->MX2.CdKsRdyDom = GLINT_SECONDARY_READ_REG(dKsRdyDom); - pRC->MX2.CKsGStart = GLINT_SECONDARY_READ_REG(KsGStart); - pRC->MX2.CdKsGdx = GLINT_SECONDARY_READ_REG(dKsGdx); - pRC->MX2.CdKsGdyDom = GLINT_SECONDARY_READ_REG(dKsGdyDom); - pRC->MX2.CKsBStart = GLINT_SECONDARY_READ_REG(KsBStart); - pRC->MX2.CdKsBdx = GLINT_SECONDARY_READ_REG(dKsBdx); - pRC->MX2.CdKsBdyDom = GLINT_SECONDARY_READ_REG(dKsBdyDom); - pRC->MX2.CKdRStart = GLINT_SECONDARY_READ_REG(KdRStart); - pRC->MX2.CdKdRdx = GLINT_SECONDARY_READ_REG(dKdRdx); - pRC->MX2.CdKdRdyDom = GLINT_SECONDARY_READ_REG(dKdRdyDom); - pRC->MX2.CKdGStart = GLINT_SECONDARY_READ_REG(KdGStart); - pRC->MX2.CdKdGdx = GLINT_SECONDARY_READ_REG(dKdGdx); - pRC->MX2.CdKdGdyDom = GLINT_SECONDARY_READ_REG(dKdGdyDom); - pRC->MX2.CKdBStart = GLINT_SECONDARY_READ_REG(KdBStart); - pRC->MX2.CdKdBdx = GLINT_SECONDARY_READ_REG(dKdBdx); - pRC->MX2.CdKdBdyDom = GLINT_SECONDARY_READ_REG(dKdBdyDom); + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + pRC->MX2.CSStart = GLINT_READ_REG(SStart); + pRC->MX2.CdSdx = GLINT_READ_REG(dSdx); + pRC->MX2.CdSdyDom = GLINT_READ_REG(dSdyDom); + pRC->MX2.CTStart = GLINT_READ_REG(TStart); + pRC->MX2.CdTdx = GLINT_READ_REG(dTdx); + pRC->MX2.CdTdyDom = GLINT_READ_REG(dTdyDom); + pRC->MX2.CQStart = GLINT_READ_REG(QStart); + pRC->MX2.CdQdx = GLINT_READ_REG(dQdx); + pRC->MX2.CdQdyDom = GLINT_READ_REG(dQdyDom); + pRC->MX2.CLOD = GLINT_READ_REG(LOD); + pRC->MX2.CdSdy = GLINT_READ_REG(dSdy); + pRC->MX2.CdTdy = GLINT_READ_REG(dTdy); + pRC->MX2.CdQdy = GLINT_READ_REG(dQdy); + pRC->MX2.CTextureFormat = GLINT_READ_REG(TextureFormat); + pRC->MX2.CTextureCacheControl = GLINT_READ_REG(TextureCacheControl); + pRC->MX2.CGLINTBorderColor = GLINT_READ_REG(GLINTBorderColor); + pRC->MX2.CTexelLUTIndex = GLINT_READ_REG(TexelLUTIndex); + pRC->MX2.CTexelLUTData = GLINT_READ_REG(TexelLUTData); + pRC->MX2.CTexelLUTAddress = GLINT_READ_REG(TexelLUTAddress); + pRC->MX2.CTexelLUTTransfer = GLINT_READ_REG(TexelLUTTransfer); + pRC->MX2.CTextureFilterMode = GLINT_READ_REG(TextureFilterMode); + pRC->MX2.CTextureChromaUpper = GLINT_READ_REG(TextureChromaUpper); + pRC->MX2.CTextureChromaLower = GLINT_READ_REG(TextureChromaLower); + pRC->MX2.CTxBaseAddr0 = GLINT_READ_REG(TxBaseAddr0); + pRC->MX2.CTxBaseAddr1 = GLINT_READ_REG(TxBaseAddr1); + pRC->MX2.CTxBaseAddr2 = GLINT_READ_REG(TxBaseAddr2); + pRC->MX2.CTxBaseAddr3 = GLINT_READ_REG(TxBaseAddr3); + pRC->MX2.CTxBaseAddr4 = GLINT_READ_REG(TxBaseAddr4); + pRC->MX2.CTxBaseAddr5 = GLINT_READ_REG(TxBaseAddr5); + pRC->MX2.CTxBaseAddr6 = GLINT_READ_REG(TxBaseAddr6); + pRC->MX2.CTxBaseAddr7 = GLINT_READ_REG(TxBaseAddr7); + pRC->MX2.CTxBaseAddr8 = GLINT_READ_REG(TxBaseAddr8); + pRC->MX2.CTxBaseAddr9 = GLINT_READ_REG(TxBaseAddr9); + pRC->MX2.CTxBaseAddr10 = GLINT_READ_REG(TxBaseAddr10); + pRC->MX2.CTxBaseAddr11 = GLINT_READ_REG(TxBaseAddr11); + pRC->MX2.CTexelLUT0 = GLINT_READ_REG(TexelLUT0); + pRC->MX2.CTexelLUT1 = GLINT_READ_REG(TexelLUT1); + pRC->MX2.CTexelLUT2 = GLINT_READ_REG(TexelLUT2); + pRC->MX2.CTexelLUT3 = GLINT_READ_REG(TexelLUT3); + pRC->MX2.CTexelLUT4 = GLINT_READ_REG(TexelLUT4); + pRC->MX2.CTexelLUT5 = GLINT_READ_REG(TexelLUT5); + pRC->MX2.CTexelLUT6 = GLINT_READ_REG(TexelLUT6); + pRC->MX2.CTexelLUT7 = GLINT_READ_REG(TexelLUT7); + pRC->MX2.CTexelLUT8 = GLINT_READ_REG(TexelLUT8); + pRC->MX2.CTexelLUT9 = GLINT_READ_REG(TexelLUT9); + pRC->MX2.CTexelLUT10 = GLINT_READ_REG(TexelLUT10); + pRC->MX2.CTexelLUT11 = GLINT_READ_REG(TexelLUT11); + pRC->MX2.CTexelLUT12 = GLINT_READ_REG(TexelLUT12); + pRC->MX2.CTexelLUT13 = GLINT_READ_REG(TexelLUT13); + pRC->MX2.CTexelLUT14 = GLINT_READ_REG(TexelLUT14); + pRC->MX2.CTexelLUT15 = GLINT_READ_REG(TexelLUT15); + pRC->MX2.CTexel0 = GLINT_READ_REG(Texel0); + pRC->MX2.CTexel1 = GLINT_READ_REG(Texel1); + pRC->MX2.CTexel2 = GLINT_READ_REG(Texel2); + pRC->MX2.CTexel3 = GLINT_READ_REG(Texel3); + pRC->MX2.CTexel4 = GLINT_READ_REG(Texel4); + pRC->MX2.CTexel5 = GLINT_READ_REG(Texel5); + pRC->MX2.CTexel6 = GLINT_READ_REG(Texel6); + pRC->MX2.CTexel7 = GLINT_READ_REG(Texel7); + pRC->MX2.CInterp0 = GLINT_READ_REG(Interp0); + pRC->MX2.CInterp1 = GLINT_READ_REG(Interp1); + pRC->MX2.CInterp2 = GLINT_READ_REG(Interp2); + pRC->MX2.CInterp3 = GLINT_READ_REG(Interp3); + pRC->MX2.CInterp4 = GLINT_READ_REG(Interp4); + pRC->MX2.CTextureFilter = GLINT_READ_REG(TextureFilter); + pRC->MX2.CTextureEnvColor = GLINT_READ_REG(TextureEnvColor); + pRC->MX2.CFogColor = GLINT_READ_REG(FogColor); + pRC->MX2.CFStart = GLINT_READ_REG(FStart); + pRC->MX2.CdFdx = GLINT_READ_REG(dFdx); + pRC->MX2.CdFdyDom = GLINT_READ_REG(dFdyDom); + pRC->MX2.CKsStart = GLINT_READ_REG(KsStart); + pRC->MX2.CdKsdx = GLINT_READ_REG(dKsdx); + pRC->MX2.CdKsdyDom = GLINT_READ_REG(dKsdyDom); + pRC->MX2.CKdStart = GLINT_READ_REG(KdStart); + pRC->MX2.CdKdStart = GLINT_READ_REG(dKdStart); + pRC->MX2.CdKddyDom = GLINT_READ_REG(dKddyDom); + pRC->MX2.CRStart = GLINT_READ_REG(RStart); + pRC->MX2.CdRdx = GLINT_READ_REG(dRdx); + pRC->MX2.CdRdyDom = GLINT_READ_REG(dRdyDom); + pRC->MX2.CGStart = GLINT_READ_REG(GStart); + pRC->MX2.CdGdx = GLINT_READ_REG(dGdx); + pRC->MX2.CdGdyDom = GLINT_READ_REG(dGdyDom); + pRC->MX2.CBStart = GLINT_READ_REG(BStart); + pRC->MX2.CdBdx = GLINT_READ_REG(dBdx); + pRC->MX2.CdBdyDom = GLINT_READ_REG(dBdyDom); + pRC->MX2.CAStart = GLINT_READ_REG(AStart); + pRC->MX2.CdAdx = GLINT_READ_REG(dAdx); + pRC->MX2.CdAdyDom = GLINT_READ_REG(dAdyDom); + pRC->MX2.CConstantColor = GLINT_READ_REG(ConstantColor); + pRC->MX2.CChromaUpper = GLINT_READ_REG(ChromaUpper); + pRC->MX2.CChromaLower = GLINT_READ_REG(ChromaLower); + pRC->MX2.CChromaTestMode = GLINT_READ_REG(ChromaTestMode); + pRC->MX2.CStencilData = GLINT_READ_REG(StencilData); + pRC->MX2.CGLINTStencil = GLINT_READ_REG(GLINTStencil); + pRC->MX2.CZStartU = GLINT_READ_REG(ZStartU); + pRC->MX2.CZStartL = GLINT_READ_REG(ZStartL); + pRC->MX2.CdZdxU = GLINT_READ_REG(dZdxU); + pRC->MX2.CdZdxL = GLINT_READ_REG(dZdxL); + pRC->MX2.CdZdyDomU = GLINT_READ_REG(dZdyDomU); + pRC->MX2.CdZdyDomL = GLINT_READ_REG(dZdyDomL); + pRC->MX2.CFastClearDepth = GLINT_READ_REG(FastClearDepth); + pRC->MX2.CMinRegion = GLINT_READ_REG(MinRegion); + pRC->MX2.CMaxRegion = GLINT_READ_REG(MaxRegion); + pRC->MX2.CKsRStart = GLINT_READ_REG(KsRStart); + pRC->MX2.CdKsRdx = GLINT_READ_REG(dKsRdx); + pRC->MX2.CdKsRdyDom = GLINT_READ_REG(dKsRdyDom); + pRC->MX2.CKsGStart = GLINT_READ_REG(KsGStart); + pRC->MX2.CdKsGdx = GLINT_READ_REG(dKsGdx); + pRC->MX2.CdKsGdyDom = GLINT_READ_REG(dKsGdyDom); + pRC->MX2.CKsBStart = GLINT_READ_REG(KsBStart); + pRC->MX2.CdKsBdx = GLINT_READ_REG(dKsBdx); + pRC->MX2.CdKsBdyDom = GLINT_READ_REG(dKsBdyDom); + pRC->MX2.CKdRStart = GLINT_READ_REG(KdRStart); + pRC->MX2.CdKdRdx = GLINT_READ_REG(dKdRdx); + pRC->MX2.CdKdRdyDom = GLINT_READ_REG(dKdRdyDom); + pRC->MX2.CKdGStart = GLINT_READ_REG(KdGStart); + pRC->MX2.CdKdGdx = GLINT_READ_REG(dKdGdx); + pRC->MX2.CdKdGdyDom = GLINT_READ_REG(dKdGdyDom); + pRC->MX2.CKdBStart = GLINT_READ_REG(KdBStart); + pRC->MX2.CdKdBdx = GLINT_READ_REG(dKdBdx); + pRC->MX2.CdKdBdyDom = GLINT_READ_REG(dKdBdyDom); + ACCESSCHIP1(); } /* send gamma the context dump command */ GLINT_WAIT(3); - if (pGlint->numMXDevices == 2) + if (pGlint->numMultiDevices == 2) GLINT_WRITE_REG(1, BroadcastMask); GLINT_WRITE_REG(3<<14, FilterMode); /* context bits on gamma */ GLINT_WRITE_REG(GLINT_GAMMA_CONTEXT_MASK, ContextDump); @@ -1179,7 +1185,7 @@ dumpIndex,readValue); readValue = GLINT_READ_REG(OutputFIFO); GLINT_SLOW_WRITE_REG(1<<10, FilterMode); - if (pGlint->numMXDevices == 2) + if (pGlint->numMultiDevices == 2) GLINT_SLOW_WRITE_REG(3,BroadcastMask); } } @@ -1191,7 +1197,7 @@ dumpIndex,readValue); /* send context restore command */ GLINT_WAIT(1); - if (pGlint->numMXDevices == 2) + if (pGlint->numMultiDevices == 2) GLINT_WRITE_REG(1, BroadcastMask); GLINT_WAIT(3); @@ -1220,7 +1226,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); pGlint->AccelInfoRec->NeedToSync = TRUE; /* finally the MX portions */ - if (pGlint->numMXDevices == 2) + if (pGlint->numMultiDevices == 2) GLINT_SLOW_WRITE_REG(1, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX1.CSStart, SStart); GLINT_SLOW_WRITE_REG(pWC->MX1.CdSdx, dSdx); @@ -1344,7 +1350,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); GLINT_SLOW_WRITE_REG(pWC->MX1.CdKdBdx, dKdBdx); GLINT_SLOW_WRITE_REG(pWC->MX1.CdKdBdyDom, dKdBdyDom); - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { GLINT_SLOW_WRITE_REG(2, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX2.CSStart, SStart); GLINT_SLOW_WRITE_REG(pWC->MX2.CdSdx, dSdx); @@ -1473,7 +1479,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); /* restore the 2D portion of the new context */ /* Restore MX1's registers */ - if (pGlint->numMXDevices == 2) + if (pGlint->numMultiDevices == 2) GLINT_SLOW_WRITE_REG(1, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX1.CStartXDom, StartXDom); GLINT_SLOW_WRITE_REG(pWC->MX1.CdXDom, dXDom); @@ -1536,7 +1542,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); GLINT_SLOW_WRITE_REG(pWC->MX1.CStatisticMode, StatisticMode); /* Restore MX2's registers */ - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { GLINT_SLOW_WRITE_REG(2, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX2.CStartXDom, StartXDom); GLINT_SLOW_WRITE_REG(pWC->MX2.CdXDom, dXDom); @@ -1629,7 +1635,7 @@ GLINTDRIInitBuffers( GLINT_WRITE_REG(0, FBWriteMode); GLINT_WRITE_REG(0, LBWindowBase); GLINT_WRITE_REG(1, LBWriteMode); - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { GLINT_WRITE_REG( pGlint->pprod | LBRM_ScanlineInt2 , LBReadMode); } else { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h index 9fe9f02de..08dc5e3b1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.4 2000/05/10 18:55:29 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.5 2001/01/31 16:14:55 alanh Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -50,7 +50,7 @@ typedef struct { drmMapFlags flagsControlRegs1; drmMapFlags flagsControlRegs2; drmMapFlags flagsControlRegs3; - int numMXDevices; + int numMultiDevices; int pprod; } GLINTDRIRec, *GLINTDRIPtr; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c index 344381c19..638c2298c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c @@ -1,5 +1,5 @@ /* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. + * Copyright 1997-2001 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -28,7 +28,7 @@ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen, * Siemens Nixdorf Informationssysteme and Appian Graphics. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.103 2000/12/08 13:42:35 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.117 2001/02/15 11:03:56 alanh Exp $ */ #include "fb.h" #include "cfb8_32.h" @@ -53,21 +53,18 @@ #include "mibstore.h" +#include "pm3_regs.h" #include "glint_regs.h" #include "IBM.h" #include "TI.h" #include "glint.h" -#ifdef XFreeXDGA #define _XF86DGA_SERVER_ #include "extensions/xf86dgastr.h" -#endif -#ifdef DPMSExtension #include "globals.h" #define DPMS_SERVER #include "extensions/dpms.h" -#endif #define DEBUG 0 @@ -103,12 +100,13 @@ static Bool GLINTUnmapMem(ScrnInfoPtr pScrn); static void GLINTSave(ScrnInfoPtr pScrn); static void GLINTRestore(ScrnInfoPtr pScrn); static Bool GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void GLINTBlockHandler(int, pointer, pointer, pointer); /* * This is intentionally screen-independent. It indicates the binding * choice made in the first PreInit. */ -static int pix24bpp = 0; +static int GLINTEntityIndex = -1; static Bool FBDevProbed = FALSE; /* @@ -122,9 +120,6 @@ static Bool FBDevProbed = FALSE; DriverRec GLINT = { VERSION, GLINT_DRIVER_NAME, -#if 0 - "accelerated driver for 3dlabs and derived chipsets", -#endif GLINTIdentify, GLINTProbe, GLINTAvailableOptions, @@ -132,6 +127,25 @@ DriverRec GLINT = { 0 }; +static SymTabRec GLINTVGAChipsets[] = { + { PCI_VENDOR_TI_CHIP_PERMEDIA2, "ti_pm2" }, + { PCI_VENDOR_TI_CHIP_PERMEDIA, "ti_pm" }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, "pm3" }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, "pm2v" }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, "pm2" }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA, "pm" }, +}; + +static PciChipsets GLINTVGAPciChipsets[] = { + { PCI_VENDOR_TI_CHIP_PERMEDIA2, PCI_VENDOR_TI_CHIP_PERMEDIA2, RES_SHARED_VGA }, + { PCI_VENDOR_TI_CHIP_PERMEDIA, PCI_VENDOR_TI_CHIP_PERMEDIA, NULL }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, RES_SHARED_VGA }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, RES_SHARED_VGA }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, RES_SHARED_VGA }, + { PCI_VENDOR_3DLABS_CHIP_PERMEDIA, PCI_VENDOR_3DLABS_CHIP_PERMEDIA, NULL }, + { -1, -1, RES_UNDEFINED } +}; + static SymTabRec GLINTChipsets[] = { { PCI_VENDOR_3DLABS_CHIP_GAMMA, "gamma" }, { PCI_VENDOR_TI_CHIP_PERMEDIA2, "ti_pm2" }, @@ -166,33 +180,23 @@ static PciChipsets GLINTPciChipsets[] = { { -1, -1, RES_UNDEFINED } }; - typedef enum { OPTION_SW_CURSOR, - OPTION_HW_CURSOR, - OPTION_PCI_RETRY, OPTION_RGB_BITS, OPTION_NOACCEL, OPTION_BLOCK_WRITE, OPTION_FIREGL3000, - OPTION_MEM_CLK, OPTION_OVERLAY, OPTION_SHADOW_FB, - OPTION_FBDEV, - OPTION_NOWRITEBITMAP, - OPTION_PM3_USE_GAMMA + OPTION_FBDEV } GLINTOpts; static OptionInfoRec GLINTOptions[] = { - { OPTION_PM3_USE_GAMMA, "UseGamma", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_RGB_BITS, "RGBbits", OPTV_INTEGER, {0}, FALSE }, { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_BLOCK_WRITE, "BlockWrite", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FIREGL3000, "FireGL3000", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_MEM_CLK, "SetMClk", OPTV_FREQ, {0}, FALSE }, { OPTION_OVERLAY, "Overlay", OPTV_ANYSTR, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, @@ -212,7 +216,6 @@ static RamDacSupportedInfoRec TIRamdacs[] = { { -1 } }; - static const char *vgahwSymbols[] = { "vgaHWGetIndex", "vgaHWSave", @@ -251,9 +254,7 @@ static const char *xaaSymbols[] = { static const char *fbSymbols[] = { "cfb8_32ScreenInit", -#ifdef RENDER "fbPictureInit", -#endif "fbScreenInit", "fbBres", NULL @@ -479,7 +480,6 @@ int partprodPermedia[] = { -1, -1, -1, -1, 0}; -#ifdef DPMSExtension static void GLINTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) @@ -490,7 +490,8 @@ GLINTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) { + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_MX)) ) { vtgpolarity = GLINT_READ_REG(VTGPolarity) & 0xFFFFFFF0; } else { videocontrol = GLINT_READ_REG(PMVideoControl) & 0xFFFFFFD6; @@ -524,13 +525,13 @@ GLINTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) { + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_MX)) ) { GLINT_SLOW_WRITE_REG(vtgpolarity, VTGPolarity); } else { GLINT_SLOW_WRITE_REG(videocontrol, PMVideoControl); } } -#endif static Bool GLINTGetRec(ScrnInfoPtr pScrn) @@ -686,9 +687,20 @@ GLINTProbe(DriverPtr drv, int flags) } else if (checkusedPci) { - numUsed = xf86MatchPciInstances(GLINT_NAME, 0, - GLINTChipsets, GLINTPciChipsets, devSections, - numDevSections, drv, &usedChips); + if (flags & PROBE_DETECT) { + /* HACK, Currently when -configuring, we only return VGA + * based chips. Manual configuring is necessary to poke + * at the other chips */ + numUsed = xf86MatchPciInstances(GLINT_NAME, 0, + GLINTVGAChipsets, GLINTVGAPciChipsets, + devSections, + numDevSections, drv, &usedChips); + } else { + numUsed = xf86MatchPciInstances(GLINT_NAME, 0, + GLINTChipsets, GLINTPciChipsets, devSections, + numDevSections, drv, &usedChips); + } + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -697,51 +709,111 @@ GLINTProbe(DriverPtr drv, int flags) if (!(flags & PROBE_DETECT)) for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn = NULL; + GLINTEntPtr pGlintEnt = NULL; + DevUnion *pPriv; + pPci = xf86GetPciInfoForEntity(usedChips[i]); /* Allocate a ScrnInfoRec and claim the slot */ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], GLINTPciChipsets, NULL, NULL, NULL, NULL, NULL))) { - pPci = xf86GetPciInfoForEntity(usedChips[i]); - /* Only claim other chips when GAMMA is used */ - if (pPci->chipType == PCI_CHIP_GAMMA) { - while (*checkusedPci != NULL) { - int eIndex; + /* Claim specifics, when we KNOW ! the board */ + + /* Appian Jeronimo J2000 */ + if ((pPci->subsysVendor == 0x1097) && + (pPci->subsysCard == 0x3d32)) { + int eIndex; + if (!xf86IsEntityShared(usedChips[i])) { + eIndex = xf86ClaimPciSlot(pPci->bus, + pPci->device, + 1, + drv, -1 /* XXX */, + NULL, FALSE); + xf86AddEntityToScreen(pScrn,eIndex); + } else { + eIndex = xf86ClaimPciSlot(pPci->bus, + pPci->device, + 2, + drv, -1 /* XXX */, + NULL, FALSE); + xf86AddEntityToScreen(pScrn,eIndex); + } + } else + /* Only claim other chips when GAMMA is used */ + if (pPci->chipType == PCI_CHIP_GAMMA) { + while (*checkusedPci != NULL) { + int eIndex; /* make sure we claim all but our source device */ - if ((pPci->bus == (*checkusedPci)->bus && - pPci->device == (*checkusedPci)->device) && + if ((pPci->bus == (*checkusedPci)->bus && + pPci->device == (*checkusedPci)->device) && pPci->func != (*checkusedPci)->func) { - - /* Claim other entities on the same card */ - eIndex = xf86ClaimPciSlot((*checkusedPci)->bus, + + /* Claim other entities on the same card */ + eIndex = xf86ClaimPciSlot((*checkusedPci)->bus, (*checkusedPci)->device, (*checkusedPci)->func, drv, -1 /* XXX */, NULL, FALSE); - if (eIndex == -1) { - /* This can't happen */ - FatalError("someone claimed the free slot!\n"); - } - xf86AddEntityToScreen(pScrn,eIndex); - } - checkusedPci++; - } - } - /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = VERSION; - pScrn->driverName = GLINT_DRIVER_NAME; - pScrn->name = GLINT_NAME; - pScrn->Probe = GLINTProbe; - pScrn->PreInit = GLINTPreInit; - pScrn->ScreenInit = GLINTScreenInit; - pScrn->SwitchMode = GLINTSwitchMode; - pScrn->FreeScreen = GLINTFreeScreen; - pScrn->EnterVT = GLINTEnterVT; + if (eIndex != -1) { + xf86AddEntityToScreen(pScrn,eIndex); + } else { + ErrorF("BusID %d:%d:%d already claimed\n", + (*checkusedPci)->bus, + (*checkusedPci)->device, + (*checkusedPci)->func); + xfree(usedChips); + return FALSE; + } + } + checkusedPci++; + } } - } + + /* Fill in what we can of the ScrnInfoRec */ + pScrn->driverVersion = VERSION; + pScrn->driverName = GLINT_DRIVER_NAME; + pScrn->name = GLINT_NAME; + pScrn->Probe = GLINTProbe; + pScrn->PreInit = GLINTPreInit; + pScrn->ScreenInit = GLINTScreenInit; + pScrn->SwitchMode = GLINTSwitchMode; + pScrn->FreeScreen = GLINTFreeScreen; + pScrn->EnterVT = GLINTEnterVT; + } + + /* Allow sharing if Appian J2000 detected */ + /* (later Diamond FireGL3000 support too) */ + + if ((pPci->subsysVendor == 0x1097) && + (pPci->subsysCard == 0x3d32)) { + xf86SetEntitySharable(usedChips[i]); + /* Allocate an entity private if necessary */ + if (GLINTEntityIndex < 0) + GLINTEntityIndex = xf86AllocateEntityPrivateIndex(); + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], + GLINTEntityIndex); + if (!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(GLINTEntRec), 1); + pGlintEnt = pPriv->ptr; + pGlintEnt->lastInstance = -1; + } else { + pGlintEnt = pPriv->ptr; + } + + /* + * Set the entity instance for this instance of the driver. + * For dual head per card, instance 0 is the "master" + * instance, driving the primary head, and instance 1 is + * the "slave". + */ + pGlintEnt->lastInstance++; + xf86SetEntityInstanceForScreen(pScrn, + pScrn->entityList[0], pGlintEnt->lastInstance); + } + } } xfree(usedChips); @@ -767,7 +839,6 @@ GetAccelPitchValues(ScrnInfoPtr pScrn) switch (pGlint->Chipset) { case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_TI_CHIP_PERMEDIA: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: @@ -776,9 +847,18 @@ GetAccelPitchValues(ScrnInfoPtr pScrn) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: - case PCI_VENDOR_3DLABS_CHIP_GAMMA: linep = &partprod500TX[0]; break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + /* When GAMMA in use, we always have MultiChip defined, even if + * only one chip is connected to GAMMA as the entites > 1 + */ + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + linep = &partprod500TX[0]; + break; + } + break; } for (i = 0; linep[i] != 0; i++) { @@ -806,21 +886,12 @@ GLINTProbeTIramdac(ScrnInfoPtr pScrn) pGlint = GLINTPTR(pScrn); pGlint->RamDacRec = RamDacCreateInfoRec(); - if (pGlint->numMXDevices == 2) { - pGlint->RamDacRec->ReadDAC = DUALglintInTIIndReg; - pGlint->RamDacRec->WriteDAC = DUALglintOutTIIndReg; - pGlint->RamDacRec->ReadAddress = DUALglintTIReadAddress; - pGlint->RamDacRec->WriteAddress = DUALglintTIWriteAddress; - pGlint->RamDacRec->ReadData = DUALglintTIReadData; - pGlint->RamDacRec->WriteData = DUALglintTIWriteData; - } else { - pGlint->RamDacRec->ReadDAC = glintInTIIndReg; - pGlint->RamDacRec->WriteDAC = glintOutTIIndReg; - pGlint->RamDacRec->ReadAddress = glintTIReadAddress; - pGlint->RamDacRec->WriteAddress = glintTIWriteAddress; - pGlint->RamDacRec->ReadData = glintTIReadData; - pGlint->RamDacRec->WriteData = glintTIWriteData; - } + pGlint->RamDacRec->ReadDAC = glintInTIIndReg; + pGlint->RamDacRec->WriteDAC = glintOutTIIndReg; + pGlint->RamDacRec->ReadAddress = glintTIReadAddress; + pGlint->RamDacRec->WriteAddress = glintTIWriteAddress; + pGlint->RamDacRec->ReadData = glintTIReadData; + pGlint->RamDacRec->WriteData = glintTIWriteData; pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette; if(!RamDacInit(pScrn, pGlint->RamDacRec)) { @@ -828,12 +899,12 @@ GLINTProbeTIramdac(ScrnInfoPtr pScrn) return; } GLINTMapMem(pScrn); - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { temp = GLINT_READ_REG(GCSRAperture); GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture); } pGlint->RamDac = TIramdacProbe(pScrn, TIRamdacs); - if (pGlint->numMXDevices == 2) { + if (pGlint->numMultiDevices == 2) { GLINT_SLOW_WRITE_REG(temp, GCSRAperture); } GLINTUnmapMem(pScrn); @@ -866,10 +937,9 @@ static Bool GLINTPreInit(ScrnInfoPtr pScrn, int flags) { GLINTPtr pGlint; + GLINTEntPtr pGlintEnt = NULL; MessageType from; int i; - int LinearFramebuffer = 0; - double real; Bool Overlay = FALSE; int maxwidth = 0, maxheight = 0; ClockRangePtr clockRanges; @@ -904,28 +974,23 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) /* Get the entities, and make sure they are PCI. */ pGlint->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); - if (flags & PROBE_DETECT) { - GLINTProbeDDC(pScrn, pGlint->pEnt->index); - return TRUE; + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + pGlintEnt = xf86GetEntityPrivate(pScrn->entityList[0], + GLINTEntityIndex)->ptr; + pGlint->entityPrivate = pGlintEnt; } if (pGlint->pEnt->location.type == BUS_PCI) { - /* Initialize the card through int10 interface if needed */ - if ( xf86LoadSubModule(pScrn, "int10")){ - xf86Int10InfoPtr pInt; - - xf86LoaderReqSymLists(int10Symbols, NULL); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); - pInt = xf86InitInt10(pGlint->pEnt->index); - xf86FreeInt10(pInt); - } - pGlint->PciInfo = xf86GetPciInfoForEntity(pGlint->pEnt->index); pGlint->PciTag = pciTag(pGlint->PciInfo->bus, pGlint->PciInfo->device, pGlint->PciInfo->func); } + pGlint->numMultiDevices = 0; + pGlint->IOOffset = 0; /* Set IO Offset for Gamma */ + if (pScrn->numEntities > 1) { pciVideoPtr pPci; EntityInfoPtr pEnt; @@ -933,29 +998,41 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) for (i = 1; i < pScrn->numEntities; i++) { pEnt = xf86GetEntityInfo(pScrn->entityList[i]); pPci = xf86GetPciInfoForEntity(pEnt->index); - if (pPci->chipType == PCI_CHIP_MX) { - if (pGlint->numMXDevices >= GLINT_MAX_MX_DEVICES) { + if ( (pPci->chipType == PCI_CHIP_MX) || + (pPci->chipType == PCI_CHIP_PERMEDIA3) ) { + pGlint->MultiChip = pPci->chipType; + if (pGlint->numMultiDevices >= GLINT_MAX_MULTI_DEVICES) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "%d MX chips unsupported, aborting. (Max - 2)\n", - pGlint->numMXDevices); + "%d multiple chips unsupported, aborting. (Max - 2)\n", + pGlint->numMultiDevices); return FALSE; } else { - LinearFramebuffer = pPci->memBase[2]; - pGlint->MXPciInfo[pGlint->numMXDevices] = pPci; - pGlint->numMXDevices++; + pGlint->MultiPciInfo[pGlint->numMultiDevices] = pPci; + pGlint->numMultiDevices++; } } } } - /* - * VGA isn't used, so mark it so. XXX Should check if any VGA resources - * are decoded or not, and if not, change them from Unused to Disabled. - * Mem resources seem to be disabled. This is importand to avoid conflicts - * with DGA - */ + { + EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + pciVideoPtr pPci = xf86GetPciInfoForEntity(pEnt->index); + + if ( (pPci->chipType == PCI_CHIP_GAMMA) && + (pGlint->numMultiDevices == 0) ) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Gamma with ZERO connected chips, aborting\n"); + return FALSE; + } + } + + if (flags & PROBE_DETECT) { + GLINTProbeDDC(pScrn, pGlint->pEnt->index); + return TRUE; + } + xf86SetOperatingState(resVgaMemShared, pGlint->pEnt->index, ResDisableOpr); - xf86SetOperatingState(resVgaIoShared, pGlint->pEnt->index, ResUnusedOpr); + xf86SetOperatingState(resVgaIoShared, pGlint->pEnt->index, ResDisableOpr); /* Operations for which memory access is required. */ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; @@ -1002,10 +1079,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) xf86PrintDepthBpp(pScrn); - /* Get the depth24 pixmap format */ - if (pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); - /* * This must happen after pScrn->display has been set because * xf86SetWeight references it. @@ -1058,22 +1131,14 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) /* Default to 8bits per RGB */ if (pScrn->depth == 30) pScrn->rgbBits = 10; - else pScrn->rgbBits = 8; + else pScrn->rgbBits = 8; if (xf86GetOptValInteger(GLINTOptions, OPTION_RGB_BITS, &pScrn->rgbBits)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Bits per RGB set to %d\n", pScrn->rgbBits); } - if (xf86GetOptValFreq(GLINTOptions, OPTION_MEM_CLK, OPTUNITS_MHZ, &real)) { - pGlint->MemClock = (int)real; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Memory Clock override enabled, set to %dMHz\n", - pGlint->MemClock); - } from = X_DEFAULT; pGlint->HWCursor = TRUE; /* ON by default */ - if (xf86GetOptValBool(GLINTOptions, OPTION_HW_CURSOR, &pGlint->HWCursor)) - from = X_CONFIG; if (xf86ReturnOptValBool(GLINTOptions, OPTION_SW_CURSOR, FALSE)) { from = X_CONFIG; pGlint->HWCursor = FALSE; @@ -1127,12 +1192,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, from, "%s Linux framebuffer device\n", pGlint->FBDev ? "Using" : "Not using"); - pGlint->UsePCIRetry = FALSE; - from = X_DEFAULT; - if (xf86GetOptValBool(GLINTOptions, OPTION_PCI_RETRY, &pGlint->UsePCIRetry)) - from = X_CONFIG; - if (pGlint->UsePCIRetry) - xf86DrvMsg(pScrn->scrnIndex, from, "PCI retry enabled\n"); pScrn->overlayFlags = 0; from = X_DEFAULT; if ((s = xf86GetOptValString(GLINTOptions, OPTION_OVERLAY))) { @@ -1154,6 +1213,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->VGAcore = FALSE; pGlint->DoubleBuffer = FALSE; pGlint->RamDac = NULL; + pGlint->STATE = FALSE; /* * Set the Chipset and ChipRev, allowing config file entries to * override. @@ -1208,59 +1268,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); - /* SVEN : Claim a Gamma chip if available. */ - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) { - int eIndex = -1; - from = X_DEFAULT; - pGlint->PM3_UseGamma = FALSE; - if (xf86ReturnOptValBool(GLINTOptions, OPTION_PM3_USE_GAMMA, FALSE)) { - from = X_CONFIG; - pGlint->PM3_UseGamma = TRUE; - } - xf86DrvMsg(pScrn->scrnIndex, from, "%s to use Gamma with Permedia 3.\n", - (pGlint->PM3_UseGamma ? "Trying" : "Not trying")); - if (pGlint->PM3_UseGamma) { - pciVideoPtr *checkusedPci; - checkusedPci = xf86GetPciVideoInfo(); - while (*checkusedPci != NULL) { - /* Is there a free gamma on the same device ? */ - if (((*checkusedPci)->chipType == PCI_CHIP_GAMMA) && - (((*checkusedPci)->bus == pGlint->PciInfo->bus)) && - (((*checkusedPci)->device == pGlint->PciInfo->device))) - if ((eIndex = xf86ClaimPciSlot((*checkusedPci)->bus, - (*checkusedPci)->device, - (*checkusedPci)->func, - pScrn->drv, -1, - NULL, FALSE)) != -1) break; - } - checkusedPci++; - } - if (eIndex == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "No free Gamma chip was found.\n"); - pGlint->PM3_UseGamma = FALSE; - } else { - unsigned int r; - /* Add the Gamma to the screen info structure. */ - xf86AddEntityToScreen(pScrn,eIndex); - pGlint->PM3_GammaPciInfo = - xf86GetPciInfoForEntity(eIndex); - pGlint->PM3_GammaPciTag = pciTag( - pGlint->PM3_GammaPciInfo->bus, - pGlint->PM3_GammaPciInfo->device, - pGlint->PM3_GammaPciInfo->func); - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Gamma Claimed at BusID PCI:%d:%d:%d.\n", - pGlint->PM3_GammaPciInfo->bus, - pGlint->PM3_GammaPciInfo->device, - pGlint->PM3_GammaPciInfo->func); - /* Let's dump the Gamma registers, at least some of them ... */ - pGlint->PM3_GammaIOAddress = - pGlint->PM3_GammaPciInfo->memBase[0] & 0xFFFFC000; - } - } if ((pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2)) { if (xf86ReturnOptValBool(GLINTOptions, OPTION_BLOCK_WRITE, FALSE)) { @@ -1290,17 +1298,18 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->FbAddress = pGlint->PciInfo->memBase[2] & 0xFF800000; } - xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", + if (pGlint->FbAddress) + xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", (unsigned long)pGlint->FbAddress); /* Trap GAMMA & DELTA specification, with no linear address */ - /* Find the first SX/TX/MX chip and use that address */ + /* Find the first GLINT chip and use that address */ if (pGlint->FbAddress == 0) { - if (LinearFramebuffer) { - pGlint->FbAddress = LinearFramebuffer; + if (pGlint->MultiPciInfo[0]->memBase[2]) { + pGlint->FbAddress = pGlint->MultiPciInfo[0]->memBase[2]; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "FrameBuffer used from first SX/TX/MX chip at 0x%x\n", - LinearFramebuffer); + "FrameBuffer used from first rasterizer chip at 0x%x\n", + pGlint->MultiPciInfo[0]->memBase[2]); } else { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No FrameBuffer memory - aborting\n"); @@ -1315,11 +1324,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) */ pGlint->IOAddress = pGlint->pEnt->device->IOBase; from = X_CONFIG; -#if 0 /* This freezes the box, why ? */ - } else if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) && - pGlint->PM3_UseGamma) { - pGlint->IOAddress = pGlint->PM3_GammaPciInfo->memBase[0] & 0xFFFFC000; -#endif } else { pGlint->IOAddress = pGlint->PciInfo->memBase[0] & 0xFFFFC000; } @@ -1327,6 +1331,21 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->IOAddress += 0x10000; #endif + if ((IS_J2000) && (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) { + /* Fix up for dual head mode, offset gamma registers at 0x10000 */ + if ((xf86IsEntityShared(pScrn->entityList[0])) && + (xf86IsPrimInitDone(pScrn->entityList[0]))) { +#if 0 /* When we need gamma & acceleration, this should be used instead */ + pGlint->IOAddress += 0x10000; +#endif + } else { + xf86SetPrimInitDone(pScrn->entityList[0]); + } +#if 1 /* And then remove this */ + pGlint->IOAddress = pGlint->MultiPciInfo[0]->memBase[0] & 0xFFFFC000; +#endif + } + xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n", (unsigned long)pGlint->IOAddress); @@ -1344,6 +1363,31 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } } + pGlint->FbMapSize = 0; + + { + /* We have to boot some multiple head type boards here */ + GLINTMapMem(pScrn); + switch (pGlint->Chipset) { + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + Permedia3PreInit(pScrn); + break; + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + Permedia2VPreInit(pScrn); + break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + switch (pGlint->MultiChip) { + case PCI_CHIP_PERMEDIA3: + Permedia3PreInit(pScrn); + break; + } + break; + default: + break; + } + GLINTUnmapMem(pScrn); + } + /* HW bpp matches reported bpp */ pGlint->HwBpp = pScrn->bitsPerPixel; @@ -1352,32 +1396,47 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if (pGlint->pEnt->device->videoRam != 0) { pScrn->videoRam = pGlint->pEnt->device->videoRam; from = X_CONFIG; - } else if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) { - /* Need to initialize the memory timings of the second head - * of the Appian Jeronimo 2000 board here. - * Check this routine in pm3_dac.c if you have another board - * than a J2000, as memory timings will surely change. - */ - GLINTMapMem(pScrn); - Permedia3PreInit(pScrn); - GLINTUnmapMem(pScrn); - pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); - } else if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) { - /* The PM2v has the same problem detecting memory as the PM3 */ - pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); } else { - pGlint->FbMapSize = 0; /* Need to set FbMapSize for MMIO access */ /* Need to access MMIO to determine videoRam */ GLINTMapMem(pScrn); - if( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) ) - pScrn->videoRam = 1024 * (1 << ((GLINT_READ_REG(FBMemoryCtl) & - 0xE0000000)>>29)); - else - pScrn->videoRam = 2048 * (((GLINT_READ_REG(PMMemConfig) >> 29) & - 0x03) + 1); + switch (pGlint->Chipset) { + case PCI_VENDOR_3DLABS_CHIP_500TX: + case PCI_VENDOR_3DLABS_CHIP_300SX: + case PCI_VENDOR_3DLABS_CHIP_MX: + pScrn->videoRam = (1 << ((GLINT_READ_REG(FBMemoryCtl) & + 0xE0000000)>>29)) * 1024; + break; + case PCI_VENDOR_TI_CHIP_PERMEDIA2: + case PCI_VENDOR_TI_CHIP_PERMEDIA: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + pScrn->videoRam = (((GLINT_READ_REG(PMMemConfig) >> 29) & + 0x03) + 1) * 2048; + break; + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); + break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached Rasterizer is GLINT MX\n"); + pScrn->videoRam = + (1 << ((GLINT_READ_REG(FBMemoryCtl) & + 0xE0000000)>>29)) * 1024; + break; + case PCI_CHIP_PERMEDIA3: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached Rasterizer is Permedia3\n"); + pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); + break; + } + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Number of Rasterizers attached is %d\n", + pGlint->numMultiDevices); + break; + } GLINTUnmapMem(pScrn); } } else { @@ -1386,61 +1445,19 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->FbMapSize = pScrn->videoRam * 1024; - /* We should move this out somewhere ! */ + /* OVERRIDE videoRam/FbMapSize, for Multiply connected chips to GAMMA */ + pGlint->MultiAperture = FALSE; if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { + (pGlint->numMultiDevices == 2) ) { CARD32 chipconfig; + CARD32 size = 0; CARD32 temp; GLINTMapMem(pScrn); -#if 0 - /* We shouldn't really do this yet, we haven't saved the - * state of the chip. - * Best of all put a timer in to reset the engine if it - * doesn't respond - but later */ - /* - * This is needed before the first GLINT_SLOW_WRITE_REG -- - * otherwise the server will hang if it was left in a bad state. - */ - GLINT_WRITE_REG(0, ResetStatus); - while (GLINT_READ_REG(ResetStatus) & 0x80000000) { - xf86DrvMsg(pScrn->scrnIndex, from, "Resetting Core\n"); - } -#endif - temp = GLINT_READ_REG(GCSRAperture); GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture); -#if 0 - xf86DrvMsg(pScrn->scrnIndex, from, - "InFIFOSpace = %d, %d (after reset)\n", - GLINT_READ_REG(InFIFOSpace), - GLINT_SECONDARY_READ_REG(InFIFOSpace)); - xf86DrvMsg(pScrn->scrnIndex, from, - "OutFIFOSWords = %d, %d (after reset)\n", - GLINT_READ_REG(OutFIFOWords), - GLINT_SECONDARY_READ_REG(OutFIFOWords)); - - /* Reset doesn't appear to drain the Output - FIFO. Argh. */ - while (GLINT_READ_REG(OutFIFOWords)) { - GLINT_READ_REG(OutputFIFO); - } - while (GLINT_SECONDARY_READ_REG(OutFIFOWords)) { - GLINT_SECONDARY_READ_REG(OutputFIFO); - } - - xf86DrvMsg(pScrn->scrnIndex, from, - "InFIFOSpace = %d, %d (after drain)\n", - GLINT_READ_REG(InFIFOSpace), - GLINT_SECONDARY_READ_REG(InFIFOSpace)); - xf86DrvMsg(pScrn->scrnIndex, from, - "OutFIFOSWords = %d, %d (after drain)\n", - GLINT_READ_REG(OutFIFOWords), - GLINT_SECONDARY_READ_REG(OutFIFOWords)); -#endif - chipconfig = GLINT_READ_REG(GChipConfig); GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture); @@ -1449,18 +1466,26 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) switch (chipconfig & GChipMultiGLINTApMask) { case GChipMultiGLINTAp_0M: - pGlint->FbMapSize = 0; + size = 0; break; case GChipMultiGLINTAp_16M: - pGlint->FbMapSize = 16 * 1024 * 1024; + size = 16 * 1024 * 1024; break; case GChipMultiGLINTAp_32M: - pGlint->FbMapSize = 32 * 1024 * 1024; + size = 32 * 1024 * 1024; break; case GChipMultiGLINTAp_64M: - pGlint->FbMapSize = 64 * 1024 * 1024; + size = 64 * 1024 * 1024; break; } + + if (size == 0) { + xf86DrvMsg(pScrn->scrnIndex, from, "MultiAperture: disabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, from, "MultiAperture: enabled\n"); + pGlint->FbMapSize = size; + pGlint->MultiAperture = TRUE; + } } xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", @@ -1474,6 +1499,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) switch (pGlint->Chipset) { case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: + pGlint->FIFOSize = 256; maxheight = 2048; maxwidth = 2048; pGlint->RefClock = 14318; @@ -1491,6 +1517,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } break; case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + pGlint->FIFOSize = 256; maxheight = 2048; maxwidth = 2048; pGlint->RefClock = 14318; @@ -1508,6 +1535,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } break; case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + pGlint->FIFOSize = 120; maxheight = 4096; maxwidth = 4096; pGlint->RefClock = 14318; @@ -1539,13 +1567,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: - case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - pGlint->UsePCIRetry) { - xf86DrvMsg(pScrn->scrnIndex, from, - "GAMMA in use - PCI retries disabled\n"); - pGlint->UsePCIRetry = FALSE; - } + pGlint->FIFOSize = 16; if (pScrn->bitsPerPixel == 24) { xf86DrvMsg(pScrn->scrnIndex, from, "-depth 24 -pixmap24 not supported by this chip.\n"); @@ -1571,22 +1593,119 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if (pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC) || pGlint->RamDac->RamDacType == (IBM526_RAMDAC)) pGlint->RefClock = 40000; - else { - xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, - "Undefined RefClock\n"); - return FALSE; - } } } if (!pGlint->RamDac) return FALSE; break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + pGlint->FIFOSize = 32; + if (pScrn->bitsPerPixel == 24) { + xf86DrvMsg(pScrn->scrnIndex, from, + "-depth 24 -pixmap24 not supported by this chip.\n"); + return FALSE; + } + maxheight = 4096; + maxwidth = 4096; + /* Let's do board specific stuff first */ + if (IS_J2000) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Appian Jeronimo 2000 board detected\n"); + pGlint->RefClock = 14318; + pGlint->RamDacRec = RamDacCreateInfoRec(); + pGlint->RamDacRec->ReadDAC = Permedia2vInIndReg; + pGlint->RamDacRec->WriteDAC = Permedia2vOutIndReg; + pGlint->RamDacRec->ReadAddress = Permedia2ReadAddress; + pGlint->RamDacRec->WriteAddress = Permedia2WriteAddress; + pGlint->RamDacRec->ReadData = Permedia2ReadData; + pGlint->RamDacRec->WriteData = Permedia2WriteData; + if(!RamDacInit(pScrn, pGlint->RamDacRec)) { + RamDacDestroyInfoRec(pGlint->RamDacRec); + return FALSE; + } +#if 1 /* REMOVE LATER - see other IS_J2000 fixup code */ + /* As we push the acceleration through the pm3 (for now) we can + * safely set the FIFOSize to 120 again */ + pGlint->FIFOSize = 120; +#endif + break; + } + if (IS_GMX2000) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "3DLabs GMX2000 board detected\n"); + /* We need to wrap these after detection as the second MX + * is the only chip that can write to the TI3030 dac */ + ACCESSCHIP2(); + GLINTProbeTIramdac(pScrn); + ACCESSCHIP1(); + pGlint->RamDacRec->ReadDAC = GMX2000InIndReg; + pGlint->RamDacRec->WriteDAC = GMX2000OutIndReg; + pGlint->RamDacRec->ReadAddress = GMX2000ReadAddress; + pGlint->RamDacRec->WriteAddress = GMX2000WriteAddress; + pGlint->RamDacRec->ReadData = GMX2000ReadData; + pGlint->RamDacRec->WriteData = GMX2000WriteData; + pGlint->RefClock = 14318; + break; + } + /* Test for an TI ramdac */ + if (!pGlint->RamDac) { + GLINTProbeTIramdac(pScrn); + if (pGlint->RamDac) + if ( (pGlint->RamDac->RamDacType == (TI3026_RAMDAC)) || + (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ) + pGlint->RefClock = 14318; + } + /* Test for an IBM ramdac */ + if (!pGlint->RamDac) { + GLINTProbeIBMramdac(pScrn); + if (pGlint->RamDac) { + if (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) + pGlint->RefClock = 28322; + else + if (pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC) || + pGlint->RamDac->RamDacType == (IBM526_RAMDAC)) + pGlint->RefClock = 40000; + } + } + if (!pGlint->RamDac) { + if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) { + pGlint->RefClock = 14318; + pGlint->RamDacRec = RamDacCreateInfoRec(); + pGlint->RamDacRec->ReadDAC = Permedia2vInIndReg; + pGlint->RamDacRec->WriteDAC = Permedia2vOutIndReg; + pGlint->RamDacRec->ReadAddress = Permedia2ReadAddress; + pGlint->RamDacRec->WriteAddress = Permedia2WriteAddress; + pGlint->RamDacRec->ReadData = Permedia2ReadData; + pGlint->RamDacRec->WriteData = Permedia2WriteData; + } + if(!RamDacInit(pScrn, pGlint->RamDacRec)) { + RamDacDestroyInfoRec(pGlint->RamDacRec); + return FALSE; + } + } else + if (!pGlint->RamDac) + return FALSE; + break; } + if (pGlint->FIFOSize) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "FIFO Size is %d DWORDS\n", + pGlint->FIFOSize); + if (pGlint->FBDev || FBDevProbed) pGlint->VGAcore = FALSE; if (pGlint->VGAcore) { + /* Initialize the card through int10 interface if needed */ + if ( xf86LoadSubModule(pScrn, "int10")){ + xf86Int10InfoPtr pInt; + + xf86LoaderReqSymLists(int10Symbols, NULL); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); + pInt = xf86InitInt10(pGlint->pEnt->index); + xf86FreeInt10(pInt); + } + /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; @@ -1634,7 +1753,8 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX)|| (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) ) + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_MX)) ) pGlint->MaxClock = 220000; if ( (pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA) ) { @@ -1671,7 +1791,9 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) break; } } - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) + if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_PERMEDIA3)) ) pGlint->MaxClock = 300000; } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", @@ -1698,7 +1820,9 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) /* Select valid modes from those available */ if ((pGlint->NoAccel) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3)) { + (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_PERMEDIA3)) ) { /* * XXX Assuming min pitch 256, max <maxwidth> * XXX Assuming min height 128, max <maxheight> @@ -1784,9 +1908,10 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) { + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_MX)) ) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "GLINT SX/TX/MX chipsets only support one modeline, using first\n"); + "This GLINT chip only supports one modeline, using first\n"); pScrn->modes->next = NULL; pScrn->virtualX = pScrn->modes->HDisplay; pScrn->virtualY = pScrn->modes->VDisplay; @@ -1813,24 +1938,31 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_MX: case PCI_VENDOR_3DLABS_CHIP_300SX: - case PCI_VENDOR_3DLABS_CHIP_GAMMA: pGlint->pprod = partprod500TX[pScrn->displayWidth >> 5]; pGlint->bppalign = 0; break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + pGlint->pprod = partprod500TX[pScrn->displayWidth >> 5]; + pGlint->bppalign = 0; + break; + } + break; } if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - int bytesPerPixel, realMXWidthBytes, inputXSpanBytes; + (pGlint->numMultiDevices == 2) ) { + int bytesPerPixel, realWidthBytes, inputXSpanBytes; CARD32 postMultiply, productEnable, use16xProduct, inputXSpan; CARD32 binaryEval, glintApSize; /* setup multi glint framebuffer aperture */ bytesPerPixel = (pScrn->bitsPerPixel >> 3); - realMXWidthBytes = pScrn->displayWidth * bytesPerPixel; + realWidthBytes = pScrn->displayWidth * bytesPerPixel; /* compute Input X Span field */ - binaryEval = ((realMXWidthBytes << 1) - 1); + binaryEval = ((realWidthBytes << 1) - 1); if (binaryEval & (8 << 10)) { /* 8K */ inputXSpan = 3; inputXSpanBytes = 8 * 1024; @@ -1849,7 +1981,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } /* compute post multiply */ - binaryEval = realMXWidthBytes >> 3; + binaryEval = realWidthBytes >> 3; postMultiply = 0; while ((postMultiply < 5) && !(binaryEval & 1)) { postMultiply++; @@ -1894,7 +2026,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) glintApSize = 0 << 10; } - pGlint->realMXWidth = ( glintApSize | + pGlint->realWidth = ( glintApSize | postMultiply | productEnable | use16xProduct | @@ -2107,14 +2239,17 @@ GLINTSave(ScrnInfoPtr pScrn) { GLINTPtr pGlint; GLINTRegPtr glintReg; + GLINTRegPtr glintReg2; RamDacHWRecPtr pRAMDAC; RamDacRegRecPtr RAMDACreg; pGlint = GLINTPTR(pScrn); pRAMDAC = RAMDACHWPTR(pScrn); - glintReg = &pGlint->SavedReg; + glintReg = &pGlint->SavedReg[0]; + glintReg2 = &pGlint->SavedReg[1]; RAMDACreg = &pRAMDAC->SavedReg; TRACE_ENTER("GLINTSave"); + if (pGlint->VGAcore) { vgaRegPtr vgaReg; vgaReg = &VGAHWPTR(pScrn)->SavedReg; @@ -2145,15 +2280,32 @@ GLINTSave(ScrnInfoPtr pScrn) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXSave(pScrn, glintReg); + (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - DualMXSave(pScrn, glintReg); - } - else { + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2() + TXSave(pScrn, glintReg2); +#if 0 + (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg2); +#endif + ACCESSCHIP1(); + } TXSave(pScrn, glintReg); + (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; + case PCI_CHIP_PERMEDIA3: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + Permedia3Save(pScrn, glintReg2); + ACCESSCHIP1(); + } + Permedia3Save(pScrn, glintReg); + break; } - (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); break; } TRACE_EXIT("GLINTSave"); @@ -2171,9 +2323,10 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { int ret = -1; GLINTPtr pGlint = GLINTPTR(pScrn); - GLINTRegPtr glintReg; RamDacHWRecPtr pRAMDAC = RAMDACHWPTR(pScrn); RamDacRegRecPtr RAMDACreg; + GLINTRegPtr glintReg = &pGlint->ModeReg[0]; + GLINTRegPtr glintReg2 = &pGlint->ModeReg[1]; if (pGlint->VGAcore) { vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -2195,7 +2348,7 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) ret = Permedia2VInit(pScrn, mode); break; case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: - ret = Permedia3Init(pScrn, mode); + ret = Permedia3Init(pScrn, mode, glintReg); break; case PCI_VENDOR_TI_CHIP_PERMEDIA: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: @@ -2204,13 +2357,26 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + ret = TXInit(pScrn, mode, glintReg); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - ret = DualMXInit(pScrn, mode); - } - else { - ret = TXInit(pScrn, mode); + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + ret = TXInit(pScrn, mode, glintReg2); + ACCESSCHIP1(); + } + ret = TXInit(pScrn, mode, glintReg); + break; + case PCI_CHIP_PERMEDIA3: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + ret = Permedia3Init(pScrn, mode, glintReg2); + ACCESSCHIP1(); + } + ret = Permedia3Init(pScrn, mode, glintReg); + break; } break; } @@ -2226,9 +2392,12 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); } - glintReg = &pGlint->ModeReg; + glintReg = &pGlint->ModeReg[0]; + glintReg2 = &pGlint->ModeReg[1]; RAMDACreg = &pRAMDAC->ModeReg; + pGlint->STATE = FALSE; + switch (pGlint->Chipset) { case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: @@ -2248,15 +2417,32 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - DualMXRestore(pScrn, glintReg); - } - else { + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + TXRestore(pScrn, glintReg2); +#if 0 + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec,RAMDACreg2); +#endif + ACCESSCHIP1(); + } TXRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; + case PCI_CHIP_PERMEDIA3: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + Permedia3Restore(pScrn, glintReg2); + ACCESSCHIP1(); + } + Permedia3Restore(pScrn, glintReg); + break; } - (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; } @@ -2278,12 +2464,14 @@ GLINTRestore(ScrnInfoPtr pScrn) { GLINTPtr pGlint; GLINTRegPtr glintReg; + GLINTRegPtr glintReg2; RamDacHWRecPtr pRAMDAC; RamDacRegRecPtr RAMDACreg; pGlint = GLINTPTR(pScrn); pRAMDAC = RAMDACHWPTR(pScrn); - glintReg = &pGlint->SavedReg; + glintReg = &pGlint->SavedReg[0]; + glintReg2 = &pGlint->SavedReg[1]; RAMDACreg = &pRAMDAC->SavedReg; TRACE_ENTER("GLINTRestore"); @@ -2312,15 +2500,32 @@ GLINTRestore(ScrnInfoPtr pScrn) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - DualMXRestore(pScrn, glintReg); - } - else { + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + TXRestore(pScrn, glintReg2); +#if 0 + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec,RAMDACreg2); +#endif + ACCESSCHIP1(); + } TXRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; + case PCI_CHIP_PERMEDIA3: + if (pGlint->numMultiDevices == 2) { + ACCESSCHIP2(); + Permedia3Restore(pScrn, glintReg2); + ACCESSCHIP1(); + } + Permedia3Restore(pScrn, glintReg); + break; } - (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; } @@ -2334,6 +2539,7 @@ GLINTRestore(ScrnInfoPtr pScrn) } vgaHWProtect(pScrn, FALSE); } + TRACE_EXIT("GLINTRestore"); } @@ -2366,19 +2572,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } - /* Timing problem with PM3 & PM2V chips dont like being blasted */ - /* This solves the dual head problem but trahses the console font. */ - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) { - /* Graphics Index VGA register don't work in mmio mode - * for the Permedia3 chip, it thrashes the console font. - * Let's keep the IO functions for this instead ... */ - vgaHWWriteIndexProcPtr writeGr = hwp->writeGr; - vgaHWReadIndexProcPtr readGr = hwp->readGr; - vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); - hwp->writeGr = writeGr; - hwp->readGr = readGr; - } else if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) - vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); + vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); vgaHWGetIOBase(hwp); } @@ -2405,6 +2599,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon)); } + /* Initialise the first mode */ if ( (!pGlint->FBDev) && !(GLINTModeInit(pScrn, pScrn->currentMode))) { xf86DrvMsg(scrnIndex, X_ERROR, @@ -2494,10 +2689,8 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); -#ifdef RENDER if (ret) fbPictureInit(pScreen, 0, 0); -#endif break; case 32: if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) @@ -2510,10 +2703,8 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); -#ifdef RENDER if (ret) fbPictureInit(pScreen, 0, 0); -#endif } break; default: @@ -2528,6 +2719,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); + pGlint->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = GLINTBlockHandler; + if (!pGlint->ShadowFB) GLINTDGAInit(pScreen); @@ -2563,13 +2757,16 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) break; case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXAccelInit(pScreen); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - DualMXAccelInit(pScreen); - } - else { + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: TXAccelInit(pScreen); + break; + case PCI_CHIP_PERMEDIA3: + Permedia3AccelInit(pScreen); + break; } break; case PCI_VENDOR_3DLABS_CHIP_300SX: @@ -2592,7 +2789,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) Permedia2HWCursorInit(pScreen); else if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3)) + (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_PERMEDIA3)) ) Permedia2vHWCursorInit(pScreen); else /* If we get here pGlint->Ramdac should have been set */ @@ -2610,8 +2809,19 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (!miCreateDefColormap(pScreen)) return FALSE; + if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && + (pGlint->MultiChip == PCI_CHIP_PERMEDIA3)) ) { + if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, + (pGlint->FBDev) ? fbdevHWLoadPalette : + ((pScrn->depth == 16) ? Permedia3LoadPalette16:Permedia3LoadPalette), + NULL, + CMAP_RELOAD_ON_MODE_SWITCH | + ((pScrn->overlayFlags & OVERLAY_8_32_PLANAR) + ? 0 : CMAP_PALETTED_TRUECOLOR))) + return FALSE; + } else if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || - (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) || (pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2)) { if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, @@ -2645,9 +2855,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if(pGlint->ShadowFB) ShadowFBInit(pScreen, GLINTRefreshArea); -#ifdef DPMSExtension xf86DPMSInit(pScreen, (DPMSSetProcPtr)GLINTDisplayPowerManagementSet, 0); -#endif #ifdef XF86DRI if (pGlint->directRenderingEnabled) { @@ -2720,14 +2928,20 @@ GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) PermediaInitializeEngine(pScrn); break; case PCI_VENDOR_3DLABS_CHIP_500TX: - case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXInitializeEngine(pScrn); + break; + case PCI_VENDOR_3DLABS_CHIP_300SX: + SXInitializeEngine(pScrn); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2)) { - DualMXInitializeEngine(pScrn); - } else { - TXInitializeEngine(pScrn); + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + TXInitializeEngine(pScrn); + break; + case PCI_CHIP_PERMEDIA3: + Permedia3InitializeEngine(pScrn); + break; } break; } @@ -2774,9 +2988,18 @@ GLINTAdjustFrame(int scrnIndex, int x, int y, int flags) case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + GLINT_SLOW_WRITE_REG(base, PMScreenBase); + break; case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + base = (y * pScrn->displayWidth + x) >> pGlint->BppShift; GLINT_SLOW_WRITE_REG(base, PMScreenBase); break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) { + base = (y * pScrn->displayWidth + x) >> pGlint->BppShift; + GLINT_SLOW_WRITE_REG(base, PMScreenBase); + } + break; } TRACE_EXIT("GLINTAdjustFrame (normal)"); } @@ -2827,14 +3050,20 @@ GLINTEnterVT(int scrnIndex, int flags) PermediaInitializeEngine(pScrn); break; case PCI_VENDOR_3DLABS_CHIP_500TX: - case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: + TXInitializeEngine(pScrn); + break; + case PCI_VENDOR_3DLABS_CHIP_300SX: + SXInitializeEngine(pScrn); + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && - (pGlint->numMXDevices == 2) ) { - DualMXInitializeEngine(pScrn); - } else { - TXInitializeEngine(pScrn); + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + TXInitializeEngine(pScrn); + break; + case PCI_CHIP_PERMEDIA3: + Permedia3InitializeEngine(pScrn); + break; } break; } @@ -2860,6 +3089,7 @@ GLINTLeaveVT(int scrnIndex, int flags) GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("GLINTLeaveVT"); + pGlint->STATE = TRUE; GLINTRestore(pScrn); if (pGlint->VGAcore) vgaHWLock(VGAHWPTR(pScrn)); @@ -2903,6 +3133,7 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen) if (pGlint->FBDev) fbdevHWRestore(pScrn); else { + pGlint->STATE = TRUE; GLINTRestore(pScrn); if (pGlint->VGAcore) vgaHWLock(VGAHWPTR(pScrn)); @@ -2917,11 +3148,16 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen) xfree(pGlint->ShadowPtr); if (pGlint->DGAModes) xfree(pGlint->DGAModes); + if (pGlint->ScratchBuffer) + xfree(pGlint->ScratchBuffer); pScrn->vtSema = FALSE; if (xf86IsPc98()) outb(0xfac, 0x00); + if(pGlint->BlockHandler) + pScreen->BlockHandler = pGlint->BlockHandler; + pScreen->CloseScreen = pGlint->CloseScreen; TRACE_EXIT("GLINTCloseScreen"); return (*pScreen->CloseScreen)(scrnIndex, pScreen); @@ -2934,15 +3170,12 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen) static void GLINTFreeScreen(int scrnIndex, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("GLINTFreeScreen"); - if ((pGlint->FBDev || FBDevProbed) && xf86LoaderCheckSymbol("fbdevHWFreeRec")) + if (xf86LoaderCheckSymbol("fbdevHWFreeRec")) fbdevHWFreeRec(xf86Screens[scrnIndex]); - if (pGlint->VGAcore && xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) vgaHWFreeHWRec(xf86Screens[scrnIndex]); - if (pGlint->RamDacRec && xf86LoaderCheckSymbol("RamDacFreeRec")) + if (xf86LoaderCheckSymbol("RamDacFreeRec")) RamDacFreeRec(xf86Screens[scrnIndex]); GLINTFreeRec(xf86Screens[scrnIndex]); TRACE_EXIT("GLINTFreeScreen"); @@ -3038,6 +3271,14 @@ GLINTSaveScreen(ScreenPtr pScreen, int mode) case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) { + temp = GLINT_READ_REG(PMVideoControl); + if (unblank) temp |= 1; + else temp &= 0xFFFFFFFE; + GLINT_SLOW_WRITE_REG(temp, PMVideoControl); + } + break; } } @@ -3045,22 +3286,174 @@ GLINTSaveScreen(ScreenPtr pScreen, int mode) return TRUE; } +static void +GLINTBlockHandler ( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask +){ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + GLINTPtr pGlint = GLINTPTR(pScrn); + + if(pGlint->CursorColorCallback) + (*pGlint->CursorColorCallback)(pScrn); + + if(pGlint->LoadCursorCallback) + (*pGlint->LoadCursorCallback)(pScrn); + + pScreen->BlockHandler = pGlint->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = GLINTBlockHandler; +} + #ifdef DEBUG void GLINT_VERB_WRITE_REG(GLINTPtr pGlint, CARD32 v, int r, char *file, int line) { if (xf86GetVerbosity() > 2) ErrorF("[0x%04x] <- 0x%08x (%s, %d)\n", r, v, file, line); - *(volatile CARD32 *)((char *) pGlint->IOBase + r) = v; + *(volatile CARD32 *)((char *) pGlint->IOBase + pGlint->IOOffset + r) = v; } CARD32 GLINT_VERB_READ_REG(GLINTPtr pGlint, CARD32 r, char *file, int line) { - CARD32 v = *(volatile CARD32 *)((char *) pGlint->IOBase + r); + CARD32 v = + *(volatile CARD32 *)((char *) pGlint->IOBase + pGlint->IOOffset + r); if (xf86GetVerbosity() > 2) ErrorF("[0x%04x] -> 0x%08x (%s, %d)\n", r, v, file, line); return v; } #endif + +void GLINT_MoveBYTE( + register CARD32* dest, + register unsigned char* src, + register int dwords) +{ +#ifdef __alpha__ + write_mem_barrier(); +#endif + while(dwords) { + *dest = *src; + src += 1; + dest += 1; + dwords -= 1; + } +} + +void GLINT_MoveWORDS( + register CARD32* dest, + register unsigned short* src, + register int dwords) +{ +#ifdef __alpha__ + write_mem_barrier(); +#endif + while(dwords & ~0x01) { + *dest = *src; + *(dest + 1) = *(src + 1); + src += 2; + dest += 2; + dwords -= 2; + } + if (dwords) + *dest = *src; +} + +void GLINT_MoveDWORDS( + register CARD32* dest, + register CARD32* src, + register int dwords) +{ +#ifdef __alpha__ + write_mem_barrier(); +#endif + while(dwords & ~0x03) { + *dest = *src; + *(dest + 1) = *(src + 1); + *(dest + 2) = *(src + 2); + *(dest + 3) = *(src + 3); + src += 4; + dest += 4; + dwords -= 4; + } + + while(dwords) { + *dest = *src; + src++; + dest++; + dwords--; + } +} + +int +Shiftbpp(ScrnInfoPtr pScrn, int value) +{ + GLINTPtr pGlint = GLINTPTR(pScrn); + int logbytesperaccess = 2; /* default */ + + switch (pGlint->Chipset) { + case PCI_VENDOR_TI_CHIP_PERMEDIA: + case PCI_VENDOR_TI_CHIP_PERMEDIA2: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + logbytesperaccess = 2; + break; + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + logbytesperaccess = 4; + break; + case PCI_VENDOR_3DLABS_CHIP_300SX: + case PCI_VENDOR_3DLABS_CHIP_500TX: + case PCI_VENDOR_3DLABS_CHIP_MX: + if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) || + (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ) + logbytesperaccess = 4; + else + logbytesperaccess = 3; + break; + case PCI_VENDOR_3DLABS_CHIP_GAMMA: + switch (pGlint->MultiChip) { + case PCI_CHIP_MX: + if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) || + (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ) + logbytesperaccess = 4; + else + logbytesperaccess = 3; + break; + case PCI_CHIP_PERMEDIA3: + logbytesperaccess = 4; + break; + } + } + + switch (pScrn->bitsPerPixel) { + case 8: + value >>= logbytesperaccess; + pGlint->BppShift = logbytesperaccess; + break; + case 16: + if (pGlint->DoubleBuffer) { + value >>= (logbytesperaccess-2); + pGlint->BppShift = logbytesperaccess-2; + } else { + value >>= (logbytesperaccess-1); + pGlint->BppShift = logbytesperaccess-1; + } + break; + case 24: + value *= 3; + value >>= logbytesperaccess; + pGlint->BppShift = logbytesperaccess; + break; + case 32: + value >>= (logbytesperaccess-2); + pGlint->BppShift = logbytesperaccess-2; + break; + } + return (value); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h index 8e319152b..06e1cb265 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.21 2000/09/19 14:12:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.25 2001/02/15 11:03:57 alanh Exp $ */ /* * glint register file @@ -19,16 +19,7 @@ #include "compiler.h" -/********************************************** -* GLINT 500TX Configuration Region Registers * -***********************************************/ - -/* Device Identification */ -#define CFGVendorId 0x0000 -#define PCI_VENDOR_3DLABS 0x3D3D -#define PCI_VENDOR_TI 0x104C -#define CFGDeviceId 0x0002 - +/* The chips we know */ #define PCI_CHIP_3DLABS_300SX 0x01 #define PCI_CHIP_3DLABS_500TX 0x02 #define PCI_CHIP_3DLABS_DELTA 0x03 @@ -40,6 +31,26 @@ #define PCI_CHIP_3DLABS_PERMEDIA3 0x0A #define PCI_CHIP_TI_PERMEDIA 0x3d04 +/* The boards we know */ +#define IS_GMX2000 ((pGlint->PciInfo->subsysVendor == 0x3d3d) && \ + (pGlint->PciInfo->subsysCard == 0x0106)) + +#define IS_J2000 ((pGlint->PciInfo->subsysVendor == 0x1097) && \ + (pGlint->PciInfo->subsysCard == 0x3d32)) + +#define IS_JPRO ((pGlint->PciInfo->subsysVendor == 0x1097) && \ + (pGlint->PciInfo->subsysCard == 0x3db3)) + +/********************************************** +* GLINT 500TX Configuration Region Registers * +***********************************************/ + +/* Device Identification */ +#define CFGVendorId 0x0000 +#define PCI_VENDOR_3DLABS 0x3D3D +#define PCI_VENDOR_TI 0x104C +#define CFGDeviceId 0x0002 + #define CFGRevisionId 0x08 #define CFGClassCode 0x09 #define CFGHeaderType 0x0E @@ -323,6 +334,10 @@ #define PM2VDACRDDClk1PreScale 0x204 #define PM2VDACRDDClk1FeedbackScale 0x205 #define PM2VDACRDDClk1PostScale 0x206 +#define PM2VDACRDMClkControl 0x20D +#define PM2VDACRDMClkPreScale 0x20E +#define PM2VDACRDMClkFeedbackScale 0x20F +#define PM2VDACRDMClkPostScale 0x210 #define PM2VDACRDCursorPalette 0x303 #define PM2VDACRDCursorPattern 0x400 #define PM2VDACIndexRegLow 0x4020 @@ -981,6 +996,8 @@ #define FM_PassStatisticTag 0x1000 #define FM_PassStatisticData 0x2000 +#define Sync_tag 0x0188 + #define StatisticMode GLINT_TAG_ADDR(0x18,0x01) #define MinRegion GLINT_TAG_ADDR(0x18,0x02) #define MaxRegion GLINT_TAG_ADDR(0x18,0x03) @@ -1173,44 +1190,40 @@ GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__) #else -#define GLINT_WRITE_REG(v,r) MMIO_OUT32(pGlint->IOBase,(unsigned long)r, v) -#define GLINT_READ_REG(r) MMIO_IN32(pGlint->IOBase,(unsigned long)r) -#define GLINT_SECONDARY_WRITE_REG(v,r) \ - MMIO_OUT32(pGlint->IOBase,(unsigned long)r+0x10000, v) -#define GLINT_SECONDARY_READ_REG(r) \ - MMIO_IN32(pGlint->IOBase,(unsigned long)r+0x10000) +#define GLINT_WRITE_REG(v,r) \ + MMIO_OUT32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r), (v)) +#define GLINT_READ_REG(r) \ + MMIO_IN32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r)) #endif /* DEBUG */ #define GLINT_WAIT(n) \ do{ \ - if(!pGlint->UsePCIRetry) \ - while(GLINT_READ_REG(InFIFOSpace)<(n)){ \ - mem_barrier(); \ - } \ + while(GLINT_READ_REG(InFIFOSpace)<(n)); \ }while(0) -#define GLINT_MASK_WRITE_REG(v,m,r) \ - GLINT_WRITE_REG((GLINT_READ_REG(r)&(m))|(v),r) - #define GLINTDACDelay(x) do { \ int delay = x; \ unsigned char tmp; \ while(delay--){tmp = GLINT_READ_REG(InFIFOSpace);}; \ } while(0) +#define GLINT_MASK_WRITE_REG(v,m,r) \ + GLINT_WRITE_REG((GLINT_READ_REG(r)&(m))|(v),r) + #define GLINT_SLOW_WRITE_REG(v,r) \ do{ \ - GLINTDACDelay(5); \ + mem_barrier(); \ + GLINT_WAIT(1); \ + mem_barrier(); \ GLINT_WRITE_REG(v,r); \ - GLINTDACDelay(5); \ }while(0) -#define GLINT_SECONDARY_SLOW_WRITE_REG(v,r) \ -do{ \ - while(GLINT_READ_REG(InFIFOSpace)<1); \ - GLINT_SECONDARY_WRITE_REG(v,r); \ -}while(0) +#define GLINT_SET_INDEX(index) \ +do{ \ + GLINT_SLOW_WRITE_REG(((index)>>8)&0xff,PM2VDACIndexRegHigh); \ + GLINT_SLOW_WRITE_REG((index)&0xff,PM2VDACIndexRegLow); \ +} while(0) #define REPLICATE(r) \ { \ @@ -1266,4 +1279,38 @@ do{ \ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\ } #endif + +/* Permedia Save/Restore functions */ + +#define STOREREG(address,value) \ + pReg->glintRegs[address >> 3] = value; + +#define SAVEREG(address) \ + pReg->glintRegs[address >> 3] = GLINT_READ_REG(address); + +#define RESTOREREG(address) \ + GLINT_SLOW_WRITE_REG(pReg->glintRegs[address >> 3], address); + +#define STOREDAC(address,value) \ + pReg->DacRegs[address] = value; + +#define P2VOUT(address) \ + Permedia2vOutIndReg(pScrn, address, 0x00, pReg->DacRegs[address]); + +#define P2VIN(address) \ + pReg->DacRegs[address] = Permedia2vInIndReg(pScrn, address); + +/* RamDac Save/Restore functions, used by external DAC's */ + +#define STORERAMDAC(address,value) \ + ramdacReg->DacRegs[address] = value; + +/* Multi Chip access */ + +#define ACCESSCHIP1() \ + pGlint->IOOffset = 0; + +#define ACCESSCHIP2() \ + pGlint->IOOffset = 0x10000; + #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c index 65b7d0b36..ef3a1b1bb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c @@ -1,5 +1,5 @@ /* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. + * Copyright 1997-2001 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -30,7 +30,7 @@ * * Permedia 2 accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.24 2000/03/31 22:55:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.28 2001/02/15 11:03:57 alanh Exp $ */ #include "Xarch.h" #include "xf86.h" @@ -115,18 +115,10 @@ static void Permedia2WritePixmap16bpp(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int transparency_color, int bpp, int depth); -static void Permedia2WritePixmap24bpp(ScrnInfoPtr pScrn, int x, int y, int w, - int h, unsigned char *src, int srcwidth, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); static void Permedia2WritePixmap32bpp(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int transparency_color, int bpp, int depth); -static void Permedia2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop,unsigned int planemask); -static void Permedia2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft); static void Permedia2SetupForScanlineCPUToScreenColorExpandFill( ScrnInfoPtr pScrn, int fg, int bg, int rop, @@ -141,8 +133,6 @@ static void Permedia2PolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, static void Permedia2PolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment *pSeg); -#define MAX_FIFO_ENTRIES 256 - #if X_BYTE_ORDER == X_BIG_ENDIAN # define STIPPLE_SWAP 1<<18 /* Mirror stipple pattern horizontally */ #else @@ -182,7 +172,7 @@ Permedia2InitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); - GLINT_SLOW_WRITE_REG(0xc00, FilterMode); + GLINT_SLOW_WRITE_REG(0x400, FilterMode); GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode); @@ -328,35 +318,21 @@ Permedia2AccelInit(ScreenPtr pScreen) Permedia2SubsequentMono8x8PatternFillRect; } - if (pGlint->UsePCIRetry) { - infoPtr->CPUToScreenColorExpandFillFlags = SYNC_AFTER_COLOR_EXPAND | - BIT_ORDER_IN_BYTE_LSBFIRST | - CPU_TRANSFER_PAD_DWORD; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + BIT_ORDER_IN_BYTE_LSBFIRST; - infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4; - infoPtr->SetupForCPUToScreenColorExpandFill = - Permedia2SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Permedia2SubsequentCPUToScreenColorExpandFill; - } else { - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_LSBFIRST; - - infoPtr->NumScanlineColorExpandBuffers = 1; - infoPtr->ScanlineColorExpandBuffers = + infoPtr->NumScanlineColorExpandBuffers = 1; + infoPtr->ScanlineColorExpandBuffers = pGlint->XAAScanlineColorExpandBuffers; - pGlint->XAAScanlineColorExpandBuffers[0] = + pGlint->XAAScanlineColorExpandBuffers[0] = pGlint->IOBase + OutputFIFO + 4; - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = Permedia2SetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = Permedia2SubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = + infoPtr->SubsequentColorExpandScanline = Permedia2SubsequentColorExpandScanline; - } - - infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; infoPtr->WriteBitmap = Permedia2WriteBitmap; @@ -366,13 +342,6 @@ Permedia2AccelInit(ScreenPtr pScreen) if (pScrn->bitsPerPixel == 16) infoPtr->WritePixmap = Permedia2WritePixmap16bpp; else -#if 0 - if (pScrn->bitsPerPixel == 24) { - infoPtr->WritePixmap = Permedia2WritePixmap24bpp; - infoPtr->WritePixmapFlags |= NO_PLANEMASK; - } - else -#endif if (pScrn->bitsPerPixel == 32) infoPtr->WritePixmap = Permedia2WritePixmap32bpp; @@ -381,7 +350,6 @@ Permedia2AccelInit(ScreenPtr pScreen) infoPtr->SolidFillFlags |= NO_PLANEMASK; infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK; infoPtr->WriteBitmapFlags |= NO_PLANEMASK; - infoPtr->CPUToScreenColorExpandFillFlags |= NO_PLANEMASK; infoPtr->ScanlineCPUToScreenColorExpandFillFlags |= NO_PLANEMASK; infoPtr->Mono8x8PatternFillFlags |= NO_PLANEMASK; } @@ -427,11 +395,11 @@ Permedia2Sync(ScrnInfoPtr pScrn) CHECKCLIPPING; while (GLINT_READ_REG(DMACount) != 0); - GLINT_WAIT(1); + GLINT_WAIT(2); + GLINT_WRITE_REG(0x400, FilterMode); GLINT_WRITE_REG(0, GlintSync); do { while(GLINT_READ_REG(OutFIFOWords) == 0); -#define Sync_tag 0x188 } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); } @@ -733,63 +701,6 @@ Permedia2SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h) TRACE_EXIT("Permedia2SubsequentFillRectSolid"); } -static void MoveBYTE( - register CARD32* dest, - register unsigned char* src, - register int dwords -) -{ - while(dwords) { - *dest = *src; - src += 1; - dest += 1; - dwords -= 1; - } -} - -static void MoveWORDS( - register CARD32* dest, - register unsigned short* src, - register int dwords -) -{ - while(dwords & ~0x01) { - *dest = *src; - *(dest + 1) = *(src + 1); - src += 2; - dest += 2; - dwords -= 2; - } - switch(dwords) { - case 0: return; - case 1: *dest = *src; - return; - } -} - -static void MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords ) -{ - while(dwords & ~0x03) { - *dest = *src; - *(dest + 1) = *(src + 1); - *(dest + 2) = *(src + 2); - *(dest + 3) = *(src + 3); - src += 4; - dest += 4; - dwords -= 4; - } - if (!dwords) return; - *dest = *src; - if (dwords == 1) return; - *(dest + 1) = *(src + 1); - if (dwords == 2) return; - *(dest + 2) = *(src + 2); -} - - static void Permedia2SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn, int patternx, int patterny, @@ -939,82 +850,6 @@ Permedia2SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, } static void -Permedia2SetupForCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dobackground = 0; - - TRACE_ENTER("Permedia2SetupForCPUToScreenColorExpandFill"); - if (bg != -1) dobackground |= ForceBackgroundColor; - - GLINT_WAIT(7); - DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - pGlint->ForeGroundColor = fg; - pGlint->BackGroundColor = bg; - REPLICATE(fg); - REPLICATE(bg); - - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (dobackground) { - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, FBBlockColor); - } - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground| - pGlint->RasterizerSwap,RasterizerMode); - GLINT_WRITE_REG(fg, ConstantColor); - if (dobackground) { - pGlint->FrameBufferReadMode = TextureEnable; - GLINT_WRITE_REG(bg, Texel0); - } else - pGlint->FrameBufferReadMode = 0; - } - LOADROP(rop); - TRACE_EXIT("Permedia2SetupForCPUToScreenColorExpandFill"); -} - -static void -Permedia2SubsequentCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dwords = ((w + 31) >> 5) * h; - - TRACE_ENTER("Permedia2SubsequentCPUToScreenColorExpandFill"); - GLINT_WAIT(8); - Permedia2LoadCoord(pScrn, x, y, w, h); - - if ((pGlint->ROP == GXcopy) && (pGlint->BackGroundColor != -1)) { - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | FastFillEnable, Render); - REPLICATE(pGlint->ForeGroundColor) - GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor); - } - - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | SyncOnBitMask | - pGlint->FrameBufferReadMode, Render); - GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); - GLINT_WAIT(dwords); - TRACE_EXIT("Permedia2SubsequentCPUToScreenColorExpandFill"); -} - -static void Permedia2SetupForScanlineCPUToScreenColorExpandFill( ScrnInfoPtr pScrn, int fg, int bg, @@ -1141,44 +976,28 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, } if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { + if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(fg, FBBlockColor); } else { GLINT_WRITE_REG(fg, ConstantColor); } - } else if(rop == GXcopy) { - /* >>>>> set bg <<<<<<< */ - /* >>>>> draw rect (x,y,w,h) */ + } else if((rop == GXcopy) && (pScrn->bitsPerPixel != 24)) { REPLICATE(bg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(bg, ConstantColor); - } - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |mode,Render); - /* >>>>>> set fg <<<<<< */ + GLINT_WRITE_REG(bg, FBBlockColor); + GLINT_WRITE_REG(PrimitiveRectangle | XPositive |YPositive |mode,Render); REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, ConstantColor); - } + GLINT_WRITE_REG(fg, FBBlockColor); } else { SecondPass = TRUE; - /* >>>>> set fg <<<<<<< */ REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { + if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(fg, FBBlockColor); } else { GLINT_WRITE_REG(fg, ConstantColor); } } - /* >>>>>>>>> initiate transfer (x,y,w,h). Skipleft pixels on the - left edge will be clipped <<<<<< */ - SECOND_PASS: GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | mode | SyncOnBitMask, Render); @@ -1188,17 +1007,16 @@ SECOND_PASS: GLINT_WAIT(dwords); /* 0x0D is the TAG value for BitMaskPattern */ GLINT_WRITE_REG(((dwords - 1) << 16) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32 *)srcpntr, dwords); srcpntr += srcwidth; } if(SecondPass) { SecondPass = FALSE; - /* >>>>>> invert bitmask and set bg <<<<<<<< */ REPLICATE(bg); GLINT_WAIT(3); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { + if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(InvertBitMask|pGlint->RasterizerSwap,RasterizerMode); GLINT_WRITE_REG(bg, FBBlockColor); } else { @@ -1276,24 +1094,27 @@ Permedia2WritePixmap8bpp( count = dwords; address = ((y * pScrn->displayWidth) + x) >> 2; srcp = (CARD32*)src; + GLINT_WAIT(1); /*??*/ GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + address += pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; @@ -1305,6 +1126,7 @@ Permedia2WritePixmap8bpp( char align = (x & pGlint->bppalign); + GLINT_WAIT(1); /*??*/ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); if (rop == GXcopy) { GLINT_WAIT(6); @@ -1324,22 +1146,24 @@ Permedia2WritePixmap8bpp( while(h--) { count = dwords; srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; @@ -1348,22 +1172,24 @@ Permedia2WritePixmap8bpp( while(h--) { count = w; srcpbyte = (unsigned char *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpbyte += MAX_FIFO_ENTRIES - 1; + GLINT_MoveBYTE( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (unsigned char *)srcpbyte, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcpbyte += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveBYTE( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (unsigned char *)srcpbyte, count); } src += srcwidth; @@ -1435,24 +1261,27 @@ Permedia2WritePixmap16bpp( count = dwords; address = ((y * pScrn->displayWidth) + x) >> 1; srcp = (CARD32*)src; + GLINT_WAIT(1); /*??*/ GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + address += pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; @@ -1483,22 +1312,24 @@ Permedia2WritePixmap16bpp( while(h--) { count = dwords; srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; @@ -1507,22 +1338,24 @@ Permedia2WritePixmap16bpp( while(h--) { count = w; srcpword = (unsigned short *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned short *)srcpword, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpword += MAX_FIFO_ENTRIES - 1; + GLINT_MoveWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (unsigned short *)srcpword, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcpword += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (unsigned short *)srcpword, count); } src += srcwidth; @@ -1536,107 +1369,6 @@ Permedia2WritePixmap16bpp( } static void -Permedia2WritePixmap24bpp( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int rop, - unsigned int planemask, - int transparency_color, - int bpp, int depth -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - int skipleft = 0, dwords, count; - unsigned char* srcpbyte; - CARD32* srcp; - - GLINT_WAIT(3); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - dwords = ((w+1)*3)>>2; - if((skipleft = (long)src & 0x03L)) { - skipleft = 4 - skipleft; - - x -= skipleft; - w += skipleft; - - src = (unsigned char*)(src - (3*skipleft)); - } - - { - Permedia2SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - - GLINT_WAIT(4); - Permedia2LoadCoord(pScrn, x&0xFFFF, y, w, h); - LOADROP(rop); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | - SyncOnHostData, Render); - -#if 1 - while(h--) { - count = w; - srcpbyte = (unsigned char *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpbyte += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, count); - } - src += srcwidth; -#else - while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; -#endif - } - } - - Permedia2DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); -} - - -static void Permedia2WritePixmap32bpp( ScrnInfoPtr pScrn, int x, int y, int w, int h, @@ -1689,24 +1421,27 @@ Permedia2WritePixmap32bpp( count = dwords; address = (y * pScrn->displayWidth) + x; srcp = (CARD32*)src; + GLINT_WAIT(1); /*??*/ GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + address += pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x11 << 4) | 0x0D is the TAG for TextureData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; @@ -1727,22 +1462,24 @@ Permedia2WritePixmap32bpp( while(h--) { count = dwords; srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } if(count) { GLINT_WAIT(count + 1); /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c index 45f605dd5..604ed1533 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c @@ -1,5 +1,5 @@ /* - * Copyright 2000 by Sven Luther <luther@dpt-info.u-strasbg.fr>. + * Copyright 2000-2001 by Sven Luther <luther@dpt-info.u-strasbg.fr>. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -26,7 +26,7 @@ * * Permedia 3 accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c,v 1.7 2000/11/28 16:10:39 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c,v 1.22 2001/02/05 15:10:43 alanh Exp $ */ #include "Xarch.h" #include "xf86.h" @@ -47,7 +47,6 @@ #include "xaalocal.h" /* For replacements */ #define DEBUG 0 -#define USE_DIRECT_FIFO_WRITES 1 #if DEBUG # define TRACE_ENTER(str) ErrorF("pm3_accel: " str " %d\n",pScrn->scrnIndex) @@ -61,6 +60,7 @@ /* Sync */ void Permedia3Sync(ScrnInfoPtr pScrn); +void DualPermedia3Sync(ScrnInfoPtr pScrn); /* Clipping */ static void Permedia3SetClippingRectangle(ScrnInfoPtr pScrn, int x, int y, int w, int h); @@ -78,6 +78,8 @@ static void Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask); static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h); +static void Permedia3SubsequentFillRectSolid32bpp(ScrnInfoPtr pScrn, int x, + int y, int w, int h); /* 8x8 Mono Pattern Fills */ static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, int fg, int bg, @@ -85,26 +87,28 @@ static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, static void Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int x_offset, int y_offset, int x, int y, int w, int h); -/* Color Expansion Fills */ -static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop,unsigned int planemask); -static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft); -/* Direct Fifo Bitmap Writes */ -static void Permedia3WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, int skipleft, - int fg, int bg, int rop,unsigned int planemask); -/* Images Writes */ -static void Permedia3SetupForImageWrite(ScrnInfoPtr pScrn, int rop, +static void Permedia3SetupForScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask); +static void Permedia3SubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int x, + int y, int w, int h, int skipleft); +static void Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); +static void Permedia3SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int trans_color, int bpp, int depth); -static void Permedia3SubsequentImageWriteRect(ScrnInfoPtr pScrn, +static void Permedia3SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); -/* Direct Fifo Pixmap Writes */ +static void Permedia3SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno); +static void Permedia3RestoreAccelState(ScrnInfoPtr pScrn); static void Permedia3WritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int transparency_color, int bpp, int depth); +static void Permedia3WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int skipleft, + int fg, int bg, int rop,unsigned int planemask); void Permedia3InitializeEngine(ScrnInfoPtr pScrn) @@ -115,14 +119,23 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) /* Initialize the Accelerator Engine to defaults */ TRACE_ENTER("Permedia3InitializeEngine"); + if (pGlint->MultiAperture) { + /* Only write the following register to the first PM3 */ + GLINT_SLOW_WRITE_REG(1, BroadcastMask); + GLINT_SLOW_WRITE_REG(0x00000001, ScanLineOwnership); + + /* Only write the following register to the second PM3 */ + GLINT_SLOW_WRITE_REG(2, BroadcastMask); + GLINT_SLOW_WRITE_REG(0x00000005, ScanLineOwnership); + + /* Make sure the rest of the register writes go to both PM3's */ + GLINT_SLOW_WRITE_REG(3, BroadcastMask); + } + /* Host out PreInit */ /* Set filter mode to enable sync tag & data output */ - GLINT_SLOW_WRITE_REG(0xc00, FilterMode); + GLINT_SLOW_WRITE_REG(0x400, FilterMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); - Permedia3Sync(pScrn); - - TRACE("Permedia3InitializeEngine : first sync"); - /* Disable most units by default */ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3DeltaMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); @@ -171,7 +184,6 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(0, PM3DeltaControl); GLINT_SLOW_WRITE_REG(0xffffffff, BitMaskPattern); - Permedia3Sync(pScrn); /* ScissorStippleUnit Initialization (is it needed ?) */ pGlint->ClippingOn = FALSE; @@ -184,14 +196,12 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) (0&0xffff)|((0&0xffff)<<16), WindowOrigin); */ - Permedia3Sync(pScrn); /* StencilDepthUnit Initialization */ GLINT_SLOW_WRITE_REG(0, PM3Window); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode); GLINT_SLOW_WRITE_REG(0, StencilData); - Permedia3Sync(pScrn); /* FBReadUnit Initialization */ TRACE("Permedia3InitializeEngine : only syncs upto now"); @@ -242,30 +252,29 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) TRACE("Permedia3InitializeEngine : SourceRead"); switch (pScrn->bitsPerPixel) { case 8: - GLINT_SLOW_WRITE_REG(0x2, PixelSize); + pGlint->PM3_PixelSize = 2; #if X_BYTE_ORDER == X_BIG_ENDIAN pGlint->RasterizerSwap = 3<<15; /* Swap host data */ #endif break; case 16: - GLINT_SLOW_WRITE_REG(0x1, PixelSize); + pGlint->PM3_PixelSize = 1; #if X_BYTE_ORDER == X_BIG_ENDIAN pGlint->RasterizerSwap = 2<<15; /* Swap host data */ #endif break; case 32: - GLINT_SLOW_WRITE_REG(0x0, PixelSize); + pGlint->PM3_PixelSize = 0; break; } + GLINT_SLOW_WRITE_REG(pGlint->PM3_PixelSize, PixelSize); #if X_BYTE_ORDER == X_BIG_ENDIAN GLINT_SLOW_WRITE_REG(1 | pGlint->RasterizerSwap, RasterizerMode); #endif TRACE("Permedia3InitializeEngine : PixelSize"); - Permedia3Sync(pScrn); /* LogicalOpUnit Initialization */ GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); - Permedia3Sync(pScrn); /* FBWriteUnit Initialization */ GLINT_SLOW_WRITE_REG( @@ -278,7 +287,6 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG( PM3FBWriteBufferWidth_Width(pScrn->displayWidth), PM3FBWriteBufferWidth0); - Permedia3Sync(pScrn); /* GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferAddr1); GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferOffset1); @@ -305,7 +313,6 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) (pScrn->bitsPerPixel * pScrn->displayWidth)), PM3SizeOfFramebuffer); GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); - Permedia3Sync(pScrn); TRACE("Permedia3InitializeEngine : FBHardwareWriteMask & SizeOfFramebuffer"); /* Color Format */ switch (pScrn->depth) { @@ -346,6 +353,8 @@ Permedia3InitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(0, StartXSub); GLINT_SLOW_WRITE_REG(0, StartY); GLINT_SLOW_WRITE_REG(0, GLINTCount); + if (*pGlint->AccelInfoRec->Sync) + (*pGlint->AccelInfoRec->Sync)(pScrn); TRACE_EXIT("Permedia3InitializeEngine"); } @@ -360,36 +369,30 @@ Permedia3AccelInit(ScreenPtr pScreen) pGlint->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; - Permedia3InitializeEngine(pScrn); - /* Generic accel engine flags */ - infoPtr->Flags = - PIXMAP_CACHE | - OFFSCREEN_PIXMAPS | - LINEAR_FRAMEBUFFER; + infoPtr->Flags = PIXMAP_CACHE | + OFFSCREEN_PIXMAPS | + LINEAR_FRAMEBUFFER; /* Synchronization of the accel engine */ - infoPtr->Sync = Permedia3Sync; + if (pGlint->MultiAperture) + infoPtr->Sync = DualPermedia3Sync; + else + infoPtr->Sync = Permedia3Sync; + + Permedia3InitializeEngine(pScrn); /* Clipping Setup */ infoPtr->ClippingFlags = 0; - /* This does not work correctly, i don't know why, but i guess it is - * because the clipping stuff is not ok ... - * Let's disable it for now (also in the respective functions, we - * clear the UserScissorEnable bit in Render2D. - HARDWARE_CLIP_MONO_8x8_FILL | - HARDWARE_CLIP_SOLID_FILL; - */ infoPtr->SetClippingRectangle = Permedia3SetClippingRectangle; infoPtr->DisableClipping = Permedia3DisableClipping; /* ScreenToScreenCopy */ - infoPtr->ScreenToScreenCopyFlags = - NO_TRANSPARENCY; + infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; infoPtr->SetupForScreenToScreenCopy = - Permedia3SetupForScreenToScreenCopy; + Permedia3SetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = - Permedia3SubsequentScreenToScreenCopy; + Permedia3SubsequentScreenToScreenCopy; /* SolidFill */ infoPtr->SolidFillFlags = 0; @@ -397,80 +400,84 @@ Permedia3AccelInit(ScreenPtr pScreen) infoPtr->SubsequentSolidFillRect = Permedia3SubsequentFillRectSolid; /* 8x8 Mono Pattern Fills */ - infoPtr->Mono8x8PatternFillFlags = - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_SCREEN_ORIGIN | - BIT_ORDER_IN_BYTE_LSBFIRST; + infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_PROGRAMMED_ORIGIN | + HARDWARE_PATTERN_SCREEN_ORIGIN | + BIT_ORDER_IN_BYTE_LSBFIRST; infoPtr->SetupForMono8x8PatternFill = - Permedia3SetupForMono8x8PatternFill; + Permedia3SetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = - Permedia3SubsequentMono8x8PatternFillRect; + Permedia3SubsequentMono8x8PatternFillRect; + + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + LEFT_EDGE_CLIPPING | + LEFT_EDGE_CLIPPING_NEGATIVE_X | + BIT_ORDER_IN_BYTE_LSBFIRST | + CPU_TRANSFER_PAD_DWORD; + + infoPtr->NumScanlineColorExpandBuffers = 1; + pGlint->ScratchBuffer = xalloc(((pScrn->virtualX+62)/32*4) + + (pScrn->virtualX + * pScrn->bitsPerPixel / 8)); + infoPtr->ScanlineColorExpandBuffers = + pGlint->XAAScanlineColorExpandBuffers; + pGlint->XAAScanlineColorExpandBuffers[0] = + pGlint->IOBase + OutputFIFO + 4; + + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + Permedia3SetupForScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + Permedia3SubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = + Permedia3SubsequentColorExpandScanline; + + infoPtr->ScanlineImageWriteFlags = NO_GXCOPY | + LEFT_EDGE_CLIPPING | + LEFT_EDGE_CLIPPING_NEGATIVE_X | + BIT_ORDER_IN_BYTE_LSBFIRST | + CPU_TRANSFER_PAD_DWORD; + infoPtr->NumScanlineImageWriteBuffers = 1; + infoPtr->ScanlineImageWriteBuffers = + pGlint->XAAScanlineColorExpandBuffers; + infoPtr->SetupForScanlineImageWrite = + Permedia3SetupForScanlineImageWrite; + infoPtr->SubsequentScanlineImageWriteRect = + Permedia3SubsequentScanlineImageWriteRect; + infoPtr->SubsequentImageWriteScanline = + Permedia3SubsequentImageWriteScanline; -#if USE_DIRECT_FIFO_WRITES - /* Direct Fifo Bitmap Writes */ - infoPtr->WriteBitmapFlags = 0; infoPtr->WriteBitmap = Permedia3WriteBitmap; -#endif + infoPtr->WriteBitmapFlags = 0; - /* Color Expand Fills */ - infoPtr->CPUToScreenColorExpandFillFlags = - /* - SYNC_AFTER_COLOR_EXPAND | - */ - LEFT_EDGE_CLIPPING | - BIT_ORDER_IN_BYTE_LSBFIRST | - CPU_TRANSFER_BASE_FIXED | - CPU_TRANSFER_PAD_DWORD; - infoPtr->ColorExpandBase = pGlint->IOBase + BitMaskPattern; - infoPtr->ColorExpandRange = 4; - infoPtr->SetupForCPUToScreenColorExpandFill = - Permedia3SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Permedia3SubsequentCPUToScreenColorExpandFill; - -#if USE_DIRECT_FIFO_WRITES - /* Direct Fifo Images Writes */ - infoPtr->WritePixmapFlags = 0; infoPtr->WritePixmap = Permedia3WritePixmap; -#else - /* Images Writes */ - infoPtr->ImageWriteFlags = - NO_GXCOPY | - /* - SYNC_AFTER_IMAGE_WRITE | - */ - LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | - BIT_ORDER_IN_BYTE_LSBFIRST | - CPU_TRANSFER_BASE_FIXED | - CPU_TRANSFER_PAD_DWORD; - infoPtr->ImageWriteBase = pGlint->IOBase + PM3FBSourceData; - infoPtr->ImageWriteRange = 4; - infoPtr->SetupForImageWrite = - Permedia3SetupForImageWrite; - infoPtr->SubsequentImageWriteRect = - Permedia3SubsequentImageWriteRect; -#endif + infoPtr->WritePixmapFlags = 0; /* Available Framebuffer Area for XAA. */ AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = pGlint->FbMapSize / (pScrn->displayWidth * - pScrn->bitsPerPixel / 8); - /* Alan does this ??? + /* X coords are short's so we have to do this to make sure we dont wrap*/ AvailFBArea.y2 = ((pGlint->FbMapSize > 16384*1024) ? 16384*1024 : - pGlint->FbMapSize) / (pScrn->displayWidth + pGlint->FbMapSize) / (pScrn->displayWidth * pScrn->bitsPerPixel / 8); - */ /* Permedia3 has a maximum 4096x4096 framebuffer */ if (AvailFBArea.y2 > 4095) AvailFBArea.y2 = 4095; + { + Bool shared_accel = FALSE; + int i; + + for(i = 0; i < pScrn->numEntities; i++) { + if(xf86IsEntityShared(pScrn->entityList[i])) + shared_accel = TRUE; + } + if(shared_accel == TRUE) + infoPtr->RestoreAccelState = Permedia3RestoreAccelState; + } + xf86InitFBManager(pScreen, &AvailFBArea); - Permedia3Sync(pScrn); return(XAAInit(pScreen, infoPtr)); } @@ -491,11 +498,41 @@ Permedia3Sync(ScrnInfoPtr pScrn) CHECKCLIPPING; while (GLINT_READ_REG(DMACount) != 0); - GLINT_WAIT(1); + GLINT_WAIT(2); + GLINT_WRITE_REG(0x400, FilterMode); GLINT_WRITE_REG(0, GlintSync); do { while(GLINT_READ_REG(OutFIFOWords) == 0); - } while (GLINT_READ_REG(OutputFIFO) != PM3SyncTag); + } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); +} + +void +DualPermedia3Sync( + ScrnInfoPtr pScrn +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + CHECKCLIPPING; + + while (GLINT_READ_REG(DMACount) != 0); + GLINT_WAIT(3); + GLINT_WRITE_REG(3, BroadcastMask); /* hack! this shouldn't need to be reloaded */ + GLINT_WRITE_REG(0x400, FilterMode); + GLINT_WRITE_REG(0, GlintSync); + + /* Read 1st PM3 until Sync Tag shows */ + ACCESSCHIP1(); + do { + while(GLINT_READ_REG(OutFIFOWords) == 0); + } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); + + ACCESSCHIP2(); + /* Read 2nd PM3 until Sync Tag shows */ + do { + while(GLINT_READ_REG(OutFIFOWords) == 0); + } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); + + ACCESSCHIP1(); } static void @@ -523,26 +560,34 @@ Permedia3SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SetupForScreenToScreenCopy"); + pGlint->PM3_Render2D = PM3Render2D_SpanOperation | PM3Render2D_Operation_Normal; + pGlint->ClippingOn = TRUE; + pGlint->PM3_Config2D = PM3Config2D_UserScissorEnable | PM3Config2D_ForegroundROPEnable | PM3Config2D_ForegroundROP(rop) | PM3Config2D_FBWriteEnable; + if (xdir == 1) pGlint->PM3_Render2D |= PM3Render2D_XPositive; if (ydir == 1) pGlint->PM3_Render2D |= PM3Render2D_YPositive; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXnoop)&&(rop!=GXinvert)) { pGlint->PM3_Render2D |= PM3Render2D_FBSourceReadEnable; pGlint->PM3_Config2D |= PM3Config2D_Blocking; } + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + GLINT_WAIT(2); DO_PLANEMASK(planemask); GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); + TRACE_EXIT("Permedia3SetupForScreenToScreenCopy"); } static void @@ -578,10 +623,8 @@ Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SetupForFillRectSolid"); - REPLICATE(color); - /* Prepapre Common Render2D & Config2D data */ + /* Prepare Common Render2D & Config2D data */ pGlint->PM3_Render2D = - PM3Render2D_SpanOperation | PM3Render2D_XPositive | PM3Render2D_YPositive | PM3Render2D_Operation_Normal; @@ -590,28 +633,42 @@ Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, PM3Config2D_ForegroundROPEnable | PM3Config2D_ForegroundROP(rop) | PM3Config2D_FBWriteEnable; - if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) - pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; - /* Clipping is not working ok yet, let's disable it. - if (pGlint->ClippingOn) - pGlint->PM3_Config2D |= PM3Config2D_UserScissorEnable; - */ GLINT_WAIT(3); - /* Using FBClockColor (have to disable SpanOperation) will fill only the - * first 32 pixels of the 64 pixels of a span. Lets use ForegroundColor - * instead (from the LogicOps unit) - GLINT_WRITE_REG(color, PM3FBBlockColor); + REPLICATE(color); + /* We can't do block fills properly at 32bpp, so we can stick the chip + * into 16bpp and double the width and xcoord, but it seems that at + * extremely high resolutions (above 1600) it doesn't fill. + * so, we fall back to the slower span filling method. */ - GLINT_WRITE_REG(color, PM3ForegroundColor); + if ((rop == GXcopy) && (pScrn->bitsPerPixel == 32) && + (pScrn->displayWidth <= 1600)) { + pGlint->AccelInfoRec->SubsequentSolidFillRect = + Permedia3SubsequentFillRectSolid32bpp; + GLINT_WRITE_REG(color, PM3FBBlockColor); + } else { + pGlint->AccelInfoRec->SubsequentSolidFillRect = + Permedia3SubsequentFillRectSolid; + /* Can't do block fills at 8bpp either */ + if ((rop == GXcopy) && (pScrn->bitsPerPixel == 16)) { + GLINT_WRITE_REG(color, PM3FBBlockColor); + } else { + pGlint->PM3_Render2D |= PM3Render2D_SpanOperation; + GLINT_WRITE_REG(color, PM3ForegroundColor); + } + } + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; DO_PLANEMASK(planemask); GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); TRACE_EXIT("Permedia3SetupForFillRectSolid"); } + static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h) { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SubsequentFillRectSolid"); + GLINT_WAIT(2); GLINT_WRITE_REG( PM3RectanglePosition_XOffset(x) | @@ -620,8 +677,42 @@ Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h) GLINT_WRITE_REG(pGlint->PM3_Render2D | PM3Render2D_Width(w) | PM3Render2D_Height(h), PM3Render2D); + TRACE_EXIT("Permedia3SubsequentFillRectSolid"); } + +static void +Permedia3SubsequentFillRectSolid32bpp(ScrnInfoPtr pScrn, int x, int y, int w, int h) +{ + GLINTPtr pGlint = GLINTPTR(pScrn); + TRACE_ENTER("Permedia3SubsequentFillRectSolid32bpp"); + + GLINT_WAIT(6); + + /* Put the chip into 16bpp mode */ + GLINT_WRITE_REG(1, PixelSize); + /* Now double the displayWidth */ + GLINT_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth<<1), + PM3FBWriteBufferWidth0); + + /* and double the x,w coords */ + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x<<1) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w<<1) | PM3Render2D_Height(h), + PM3Render2D); + + /* Now fixup */ + GLINT_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth), + PM3FBWriteBufferWidth0); + GLINT_WRITE_REG(0, PixelSize); + TRACE_EXIT("Permedia3SubsequentFillRectSolid32bpp"); +} + /* 8x8 Mono Pattern Fills */ static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, @@ -645,10 +736,6 @@ Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, PM3Config2D_FBWriteEnable; if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; - /* Clipping is not working correctly yet ... - if (pGlint->ClippingOn) - pGlint->PM3_Config2D |= PM3Config2D_UserScissorEnable; - */ pGlint->PM3_AreaStippleMode = 1; /* Mirror stipple pattern horizontally */ #if X_BYTE_ORDER == X_BIG_ENDIAN @@ -699,12 +786,15 @@ Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, TRACE_EXIT("Permedia3SubsequentMono8x8PatternFillRect"); } -/* Color Expansion Fills */ -static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop,unsigned int planemask) -{ +static void +Permedia3SetupForScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask +){ GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("Permedia3SetupForCPUToScreenColorExpandFill"); + REPLICATE(fg); pGlint->PM3_Render2D = PM3Render2D_SpanOperation | @@ -729,14 +819,23 @@ static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, GLINT_WRITE_REG(fg, PM3ForegroundColor); DO_PLANEMASK(planemask); GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); - TRACE_EXIT("Permedia3SetupForCPUToScreenColorExpandFill"); } -static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft) -{ + +static void +Permedia3SubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft +){ GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("Permedia3SubsequentCPUToScreenColorExpandFill"); - GLINT_WAIT(4); + + TRACE_ENTER("Permedia2SubsequentScanlineCPUToScreenColorExpandFill"); + + pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */ + + pGlint->cpucount = h; + + GLINT_WAIT(5); GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); GLINT_WRITE_REG( @@ -746,16 +845,55 @@ static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, GLINT_WRITE_REG(pGlint->PM3_Render2D | PM3Render2D_Width(w) | PM3Render2D_Height(h), PM3Render2D); - TRACE_EXIT("Permedia3SubsequentCPUToScreenColorExpandFill"); + + if ((pGlint->dwords*h) < pGlint->FIFOSize) { + /* Turn on direct for less than 120 dword colour expansion */ + pGlint->XAAScanlineColorExpandBuffers[0] = pGlint->IOBase+OutputFIFO+4; + pGlint->ScanlineDirect = 1; + GLINT_WRITE_REG(((pGlint->dwords*h)-1)<<16 | 0x0D, OutputFIFO); + GLINT_WAIT(pGlint->dwords*h); + } else { + /* Use indirect for anything else */ + pGlint->XAAScanlineColorExpandBuffers[0] = pGlint->ScratchBuffer; + pGlint->ScanlineDirect = 0; + } + + pGlint->cpucount--; } +static void +Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + GLINTPtr pGlint = GLINTPTR(pScrn); + CARD32 *srcp = (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno]; + int dwords = pGlint->dwords; + + if (!pGlint->ScanlineDirect) { + while(dwords >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | 0x0D, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + dwords -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; + } + if(dwords) { + GLINT_WAIT(dwords + 1); + GLINT_WRITE_REG(((dwords - 1) << 16) | 0x0D, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, dwords); + } + } +} /* Images Writes */ -static void Permedia3SetupForImageWrite(ScrnInfoPtr pScrn, int rop, +static void Permedia3SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int trans_color, int bpp, int depth) { GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("Permedia3SetupForImageWrite"); + TRACE_ENTER("Permedia3SetupForScanlineImageWrite"); pGlint->PM3_Render2D = PM3Render2D_SpanOperation | PM3Render2D_XPositive | @@ -771,14 +909,18 @@ static void Permedia3SetupForImageWrite(ScrnInfoPtr pScrn, int rop, GLINT_WAIT(2); DO_PLANEMASK(planemask); GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); - TRACE_EXIT("Permedia3SetupForImageWrite"); + TRACE_EXIT("Permedia3SetupForScanlineImageWrite"); } -static void Permedia3SubsequentImageWriteRect(ScrnInfoPtr pScrn, + +static void Permedia3SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) { GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("Permedia3SubsequentImageWrite"); - GLINT_WAIT(4); + TRACE_ENTER("Permedia3SubsequentScanlineImageWrite"); + pGlint->dwords = (((w * pScrn->bitsPerPixel) + 3) >> 2); /* per scanline */ + + pGlint->cpucount = h; + GLINT_WAIT(5); GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); GLINT_WRITE_REG( @@ -788,81 +930,62 @@ static void Permedia3SubsequentImageWriteRect(ScrnInfoPtr pScrn, GLINT_WRITE_REG(pGlint->PM3_Render2D | PM3Render2D_Width(w) | PM3Render2D_Height(h), PM3Render2D); - TRACE_EXIT("Permedia3SubsequentImageWrite"); -} + if (pGlint->dwords < pGlint->FIFOSize) { + /* Turn on direct for less than 120 dword colour expansion */ + pGlint->XAAScanlineColorExpandBuffers[0] = pGlint->IOBase+OutputFIFO+4; + pGlint->ScanlineDirect = 1; + GLINT_WRITE_REG(((pGlint->dwords*h)-1)<<16 | (0x15<<4) | 0x05, + OutputFIFO); + GLINT_WAIT(pGlint->dwords); + } else { + /* Use indirect for anything else */ + pGlint->XAAScanlineColorExpandBuffers[0] = pGlint->ScratchBuffer; + pGlint->ScanlineDirect = 0; + } -/* Defines for Direct Fifo access */ - -#define WriteRange 120 -#define PciRetryWriteRange 1023 -#define WriteBase_Fixed ((CARD32 *)(pGlint->IOBase + PM3FBSourceData)) -#define WriteBase ((CARD32 *)(pGlint->IOBase + OutputFIFO + 4)) - -/* Direct Fifo Bitmap Writes */ + pGlint->cpucount--; + TRACE_EXIT("Permedia3SubsequentScanlineImageWrite"); +} static void -Permedia3WriteBitmap(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, int skipleft, - int fg, int bg, int rop, - unsigned int planemask -) +Permedia3SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) { - int dwords; - int ApertureRange; GLINTPtr pGlint = GLINTPTR(pScrn); - TRACE_ENTER("Permedia3WriteBitmap"); + int dwords = pGlint->dwords; - w += skipleft; - x -= skipleft; - dwords = (w + 31) >>5; - if (pGlint->UsePCIRetry) ApertureRange = PciRetryWriteRange; - else ApertureRange = WriteRange; - - /* width of the stuff to copy in 32 bit words */ - Permedia3SetupForCPUToScreenColorExpandFill(pScrn, fg, bg, rop, planemask); - Permedia3SubsequentCPUToScreenColorExpandFill(pScrn, x, y, w, h, skipleft); - - if (dwords > ApertureRange) { - while(h--) { - XAAMoveDWORDS_FixedBase(WriteBase_Fixed, (CARD32*)src, dwords); - src += srcwidth; - } + if (pGlint->ScanlineDirect) { + if (pGlint->cpucount--) + GLINT_WAIT(dwords); + return; } else { - /* the src is exatcly as wide as the target rectangle. We copy all - * of it, so no need to separate stuff by scanline */ - if(srcwidth == (dwords << 5)) { - /* decrement contains the number of lines that can be - * put in the fifo */ - int decrement = ApertureRange/dwords; - - while(h > decrement) { - GLINT_WAIT(dwords * decrement); - GLINT_WRITE_REG((((dwords * decrement)-1) << 16) | 0xd, - OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * decrement); - src += (srcwidth * decrement); - h -= decrement; - } - if(h) { - GLINT_WAIT(dwords * h); - GLINT_WRITE_REG((((dwords * h)-1) << 16) | 0xd, OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * h); - } - } else { - while(h--) { - GLINT_WAIT(dwords); - GLINT_WRITE_REG(((dwords-1) << 16) | 0xd, OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords); - src += srcwidth; - } + while(dwords >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno], + pGlint->FIFOSize - 1); + dwords -= pGlint->FIFOSize - 1; + } + if(dwords) { + GLINT_WAIT(dwords + 1); + GLINT_WRITE_REG(((dwords - 1) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno], + dwords); } } - TRACE_EXIT("Permedia3WriteBitmap"); } -/* Direct Fifo Images Writes */ + +static void +Permedia3RestoreAccelState(ScrnInfoPtr pScrn) +{ + Permedia3Sync(pScrn); +} static void Permedia3WritePixmap( @@ -877,9 +1000,10 @@ Permedia3WritePixmap( ) { int dwords; + int count; int skipleft = (long)src & 0x03L; int Bpp = bpp >> 3; - int ApertureRange; + CARD32 *srcp; GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3WritePixmap"); @@ -893,51 +1017,143 @@ Permedia3WritePixmap( x -= skipleft; w += skipleft; - + src = (unsigned char*)((long)src & ~0x03L); } - Permedia3SetupForImageWrite(pScrn, rop, planemask, trans, bpp, depth); - Permedia3SubsequentImageWriteRect(pScrn, x, y, w, h, skipleft); + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_SyncOnHostData; + pGlint->PM3_Config2D = + PM3Config2D_UserScissorEnable | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + GLINT_WAIT(6); + DO_PLANEMASK(planemask); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); + GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); + GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); /* width of the stuff to copy in 32 bit words */ dwords = ((w * Bpp) + 3) >> 2; - if (pGlint->UsePCIRetry) ApertureRange = PciRetryWriteRange; - else ApertureRange = WriteRange; - if (dwords > ApertureRange) { - while(h--) { - XAAMoveDWORDS_FixedBase(WriteBase_Fixed, (CARD32*)src, dwords); - src += srcwidth; + while(h--) { + count = dwords; + srcp = (CARD32*)src; + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); + /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; } - } else { - /* the src is exatcly as wide as the target rectangle. We copy all - * of it, so no need to separate stuff by scanline */ - if(srcwidth == (dwords << 2)) { - /* decrement contains the number of lines that can be - * put in the fifo */ - int decrement = ApertureRange/dwords; - - while(h > decrement) { - GLINT_WAIT(dwords * decrement); - GLINT_WRITE_REG((((dwords * decrement)-1) << 16) | 0x155, - OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * decrement); - src += (srcwidth * decrement); - h -= decrement; - } - if(h) { - GLINT_WAIT(dwords * h); - GLINT_WRITE_REG((((dwords * h)-1) << 16) | 0x155, OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * h); - } - } else { - while(h--) { - GLINT_WAIT(dwords); - GLINT_WRITE_REG(((dwords-1) << 16) | 0x155, OutputFIFO); - XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords); - src += srcwidth; - } + if(count) { + GLINT_WAIT(count + 1); + /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ + GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, count); } + src += srcwidth; + } + + Permedia3DisableClipping(pScrn); + Permedia3Sync(pScrn); +} + +static void +Permedia3WriteBitmap(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, int skipleft, + int fg, int bg, int rop, + unsigned int planemask +) +{ + int dwords; + GLINTPtr pGlint = GLINTPTR(pScrn); + int count; + CARD32 *srcp; + TRACE_ENTER("Permedia3WriteBitmap"); + + w += skipleft; + x -= skipleft; + dwords = (w + 31) >>5; + + REPLICATE(fg); + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_SyncOnBitMask; + pGlint->PM3_Config2D = + PM3Config2D_UserScissorEnable | + PM3Config2D_UseConstantSource | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + if (bg != -1) { + REPLICATE(bg); + pGlint->PM3_Config2D |= PM3Config2D_OpaqueSpan; + GLINT_WAIT(8); + GLINT_WRITE_REG(bg, BackgroundColor); } - TRACE_EXIT("Permedia3WritePixmap"); + else GLINT_WAIT(7); + GLINT_WRITE_REG(fg, PM3ForegroundColor); + DO_PLANEMASK(planemask); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); + GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); + GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); + + while(h--) { + count = dwords; + srcp = (CARD32*)src; + while(count >= pGlint->FIFOSize) { + GLINT_WAIT(pGlint->FIFOSize); + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | + 0x0D, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, pGlint->FIFOSize - 1); + count -= pGlint->FIFOSize - 1; + srcp += pGlint->FIFOSize - 1; + } + if(count) { + GLINT_WAIT(count + 1); + GLINT_WRITE_REG(((count - 1) << 16) | 0x0D, OutputFIFO); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + (CARD32*)srcp, count); + } + src += srcwidth; + } + + Permedia3DisableClipping(pScrn); + Permedia3Sync(pScrn); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c index 467d9674f..2cdcbbea4 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c @@ -1,5 +1,5 @@ /* - * Copyright 2000 by Sven Luther <luther@dpt-info.u-strasbg.fr>. + * Copyright 2000,2001 by Sven Luther <luther@dpt-info.u-strasbg.fr>. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,11 +21,12 @@ * * Authors: Sven Luther, <luther@dpt-info.u-strasbg.fr> * Thomas Witzel, <twitzel@nmr.mgh.harvard.edu> + * Alan Hourihane, <alanh@fairlite.demon.co.uk> * * this work is sponsored by Appian Graphics. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.8 2000/10/26 13:41:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.18 2001/02/05 10:44:58 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -50,104 +51,78 @@ # define TRACE(str) #endif -int PM3QuickFillMemory(ScrnInfoPtr pScrn,int size); - int -PM3QuickFillMemory(ScrnInfoPtr pScrn,int size) +Permedia3MemorySizeDetect(ScrnInfoPtr pScrn) { GLINTPtr pGlint = GLINTPTR (pScrn); - unsigned int * p; - unsigned int p_content; - unsigned int i, j; - long savemapsize; - - savemapsize = pGlint->FbMapSize; - pGlint->FbMapSize = size*1024*1024; - - pGlint->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - pGlint->PciTag, pGlint->FbAddress, pGlint->FbMapSize); - if (pGlint->FbBase == NULL) { - pGlint->FbMapSize = savemapsize; - return FALSE; - } + CARD32 size = 0, temp, temp1, temp2, i; - /* Set pointer to Aperture1 */ - p = (unsigned int *) pGlint->FbBase; - /* Fill in megs number of megabytes */ - for(i=0;i<size;i++) - for(j=0;j<1024*256;j+=1024) - p[j+(i*1024*256)] = j + (i * 1024*256); + /* We can map 64MB, as that's the size of the Permedia3 aperture + * regardless of memory configuration */ + pGlint->FbMapSize = 64*1024*1024; - /* Set pointer to Aperture1 */ - p = (unsigned int *) pGlint->FbBase; + /* Mark as VIDMEM_MMIO to avoid write-combining while detecting memory */ + pGlint->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, + pGlint->PciTag, pGlint->FbAddress, pGlint->FbMapSize); - /* If original ptr is 0x0 then no rollover occured */ - p_content = p[0]; - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase, - pGlint->FbMapSize); - pGlint->FbBase = NULL; - pGlint->FbMapSize = savemapsize; - if (p_content == 0x0) - return TRUE; - else return FALSE; -} -int -Permedia3MemorySizeDetect(ScrnInfoPtr pScrn) -{ - GLINTPtr pGlint; - int size = 1; - pGlint = GLINTPTR (pScrn); - /* Fill memory until get a rollover of dram to 0 - * fill in powers of 2, 1,2,4,8,16,32 + if (pGlint->FbBase == NULL) + return 0; + + temp = GLINT_READ_REG(PM3MemBypassWriteMask); + GLINT_SLOW_WRITE_REG(0xffffffff, PM3MemBypassWriteMask); + + /* The Permedia3 splits up memory, and even replicates it. Grrr. + * So that each 32MB appears at offset 0, and offset 32, unless + * there's really 64MB attached to the chip. + * So, 16MB appears at offset 0, nothing between 16-32, then it re-appears + * at offset 32. + * This below is to detect the cases of memory combinations + * It may also need closer examination for boards other than 16 or 32MB */ - while(PM3QuickFillMemory(pScrn,size)) - { - size = size*2; - if(size == 64) break; + + /* Test first 32MB */ + for(i=0;i<32;i++) { + /* write test pattern */ + MMIO_OUT32(pGlint->FbBase, i*1024*1024, i*0x00345678); + mem_barrier(); + temp1 = MMIO_IN32(pGlint->FbBase, i*1024*1024); + /* Let's check for wrapover, write will fail at 16MB boundary */ + if (temp1 == (i*0x00345678)) + size = i; + else + break; } - /* Correct memory amount since fail */ - if (size != 1) - size = size / 2; - else - return 1*1024; - /* Just to make sure */ - if (PM3QuickFillMemory(pScrn,size)) - return size*1024; - return 16*1024; -} -static int -Shiftbpp(ScrnInfoPtr pScrn, int value) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - /* shift horizontal timings for 128bit SGRAMs or SDRAMs */ - int logbytesperaccess = 4; - - switch (pScrn->bitsPerPixel) { - case 8: - value >>= logbytesperaccess; - pGlint->BppShift = logbytesperaccess; - break; - case 16: - if (pGlint->DoubleBuffer) { - value >>= (logbytesperaccess-2); - pGlint->BppShift = logbytesperaccess-2; - } else { - value >>= (logbytesperaccess-1); - pGlint->BppShift = logbytesperaccess-1; + /* Ok, we're satisfied we've got 32MB, let's test the second lot */ + if (size == i) { + for(i=0;i<32;i++) { + /* Clear first 32MB */ + MMIO_OUT32(pGlint->FbBase, i*1024*1024, 0); + mem_barrier(); + } + for(i=32;i<64;i++) { + /* write test pattern */ + MMIO_OUT32(pGlint->FbBase, i*1024*1024, i*0x00345678); + mem_barrier(); + temp1 = MMIO_IN32(pGlint->FbBase, i*1024*1024); + temp2 = MMIO_IN32(pGlint->FbBase, (i-32)*1024*1024); + /* Let's check for wrapover */ + if ( (temp1 == (i*0x00345678)) && (temp2 == 0) ) + size = i; + else + break; } - break; - case 24: - value *= 3; - value >>= logbytesperaccess; - pGlint->BppShift = logbytesperaccess; - break; - case 32: - value >>= (logbytesperaccess-2); - pGlint->BppShift = logbytesperaccess-2; - break; } - return (value); + + GLINT_SLOW_WRITE_REG(temp, PM3MemBypassWriteMask); + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase, + pGlint->FbMapSize); + + pGlint->FbBase = NULL; + pGlint->FbMapSize = 0; + + return ( (size+1) * 1024 ); } static unsigned long @@ -188,18 +163,17 @@ void Permedia3PreInit(ScrnInfoPtr pScrn) { GLINTPtr pGlint = GLINTPTR(pScrn); + TRACE_ENTER("Permedia3PreInit"); - if ((pGlint->PciInfo->subsysVendor == 0x1097) && - (pGlint->PciInfo->subsysCard == 0x3d32)) { + if (IS_J2000) { unsigned char m,n,p; unsigned long clockused; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Appian Jeronimo 2000 board detected and initialized.\n\t" - "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n", - pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); + + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) + GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture); /* Memory timings for the Appian J2000 board. - * This is needed for the second head which is left unitilialized + * This is needed for the second head which is left un-initialized * by the bios, thus freezing the machine. */ GLINT_SLOW_WRITE_REG(0x02e311B8, PM3LocalMemCaps); GLINT_SLOW_WRITE_REG(0x07424905, PM3LocalMemTimings); @@ -231,98 +205,91 @@ Permedia3PreInit(ScrnInfoPtr pScrn) PM3RD_SClkControl_SOURCE_PCLK | PM3RD_SClkControl_ENABLE); } - else xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unknown Glint Permedia3 board detected.\n\t" - "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n\t" - "Let's hope that it is correctly initialized by the bios.\n", - pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); + TRACE_EXIT("Permedia3PreInit"); } Bool -Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode) +Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode, GLINTRegPtr pReg) { GLINTPtr pGlint = GLINTPTR(pScrn); - GLINTRegPtr pReg = &pGlint->ModeReg; CARD32 temp1, temp2, temp3, temp4; - pReg->glintRegs[PM3MemBypassWriteMask >> 3] = 0xffffffff; - pReg->glintRegs[PM3ByAperture1Mode >> 3] = 0x00000000; - pReg->glintRegs[PM3ByAperture2Mode >> 3] = 0x00000000; - - pReg->glintRegs[Aperture0 >> 3] = 0; - pReg->glintRegs[Aperture1 >> 3] = 0; + if ((pGlint->numMultiDevices == 2) || (IS_J2000)) { + STOREREG(GCSRAperture, GCSRSecondaryGLINTMapEn); + } - if (pGlint->UsePCIRetry) { - pReg->glintRegs[DFIFODis >> 3] = 1; - pReg->glintRegs[FIFODis >> 3] = 3; - } else { - pReg->glintRegs[DFIFODis >> 3] = 0; - pReg->glintRegs[FIFODis >> 3] = 1; + if (pGlint->MultiAperture) { + STOREREG(GMultGLINTAperture, pGlint->realWidth); + STOREREG(GMultGLINT1, + pGlint->MultiPciInfo[0]->memBase[2] & 0xFF800000); + STOREREG(GMultGLINT2, + pGlint->MultiPciInfo[1]->memBase[2] & 0xFF800000); } + STOREREG(PM3MemBypassWriteMask, 0xffffffff); + STOREREG(Aperture0, 0x00000000); + STOREREG(Aperture1, 0x00000000); + + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) + STOREREG(DFIFODis, 0x00000001); + + STOREREG(FIFODis, 0x00000007); + temp1 = mode->CrtcHSyncStart - mode->CrtcHDisplay; temp2 = mode->CrtcVSyncStart - mode->CrtcVDisplay; temp3 = mode->CrtcHSyncEnd - mode->CrtcHSyncStart; temp4 = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; - pReg->glintRegs[PMHTotal >> 3] = Shiftbpp(pScrn,mode->CrtcHTotal); - pReg->glintRegs[PMHsEnd >> 3] = Shiftbpp(pScrn, temp1 + temp3); - pReg->glintRegs[PMHsStart >> 3] = Shiftbpp(pScrn, temp1); - pReg->glintRegs[PMHbEnd >> 3] = - Shiftbpp(pScrn,mode->CrtcHTotal-mode->CrtcHDisplay); - pReg->glintRegs[PMHgEnd >> 3] = pReg->glintRegs[PMHbEnd >> 3]; - pReg->glintRegs[PMScreenStride >> 3] = - Shiftbpp(pScrn,pScrn->displayWidth); - - pReg->glintRegs[PMVTotal >> 3] = mode->CrtcVTotal; - pReg->glintRegs[PMVsEnd >> 3] = temp2 + temp4; - pReg->glintRegs[PMVsStart >> 3] = temp2; - pReg->glintRegs[PMVbEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay; - - pReg->glintRegs[PMHTotal >> 3] -= 1; - pReg->glintRegs[PMVTotal >> 3] -= 1; - pReg->glintRegs[PMVsStart >> 3] -= 1; - pReg->glintRegs[PMVsEnd >> 3] -= 1; - - /* The hw cursor needs /VSYNC to recognize vert retrace. We'll stick - both sync lines to active high here and if needed invert them - using the RAMDAC's RDSyncControl below. */ - /* We need to set the pixelsize (bit 19 & 20) also ... */ + STOREREG(PMHTotal, Shiftbpp(pScrn, mode->CrtcHTotal - 1)); + STOREREG(PMHsEnd, Shiftbpp(pScrn, temp1 + temp3)); + STOREREG(PMHsStart, Shiftbpp(pScrn, temp1)); + STOREREG(PMHbEnd, Shiftbpp(pScrn, mode->CrtcHTotal - mode->CrtcHDisplay)); + STOREREG(PMHgEnd, Shiftbpp(pScrn, mode->CrtcHTotal - mode->CrtcHDisplay)); + STOREREG(PMScreenStride, Shiftbpp(pScrn, pScrn->displayWidth)); + + STOREREG(PMVTotal, mode->CrtcVTotal - 1); + STOREREG(PMVsEnd, temp2 + temp4 - 1); + STOREREG(PMVsStart, temp2 - 1); + STOREREG(PMVbEnd, mode->CrtcVTotal - mode->CrtcVDisplay); + switch (pScrn->bitsPerPixel) { case 8: - pReg->glintRegs[PM3ByAperture1Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_8BIT; - pReg->glintRegs[PM3ByAperture2Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_8BIT; - pReg->glintRegs[PMVideoControl >> 3] = - 1 | (1 << 3) | (1 << 5) | (0 << 19); + STOREREG(PM3ByAperture1Mode, PM3ByApertureMode_PIXELSIZE_8BIT); + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_8BIT); + STOREREG(PMVideoControl, 1 | (1 << 3) | (1 << 5) | (0 << 19)); break; case 16: - pReg->glintRegs[PM3ByAperture1Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_16BIT; - pReg->glintRegs[PM3ByAperture2Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_16BIT; - pReg->glintRegs[PMVideoControl >> 3] = - 1 | (1 << 3) | (1 << 5) | (1 << 19); +#if X_BYTE_ORDER != X_BIG_ENDIAN + STOREREG(PM3ByAperture1Mode, PM3ByApertureMode_PIXELSIZE_16BIT); + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_16BIT); +#else + STOREREG(PM3ByAperture1Mode, PM3ByApertureMode_PIXELSIZE_16BIT | + PM3ByApertureMode_BYTESWAP_BADC); + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_16BIT | + PM3ByApertureMode_BYTESWAP_BADC); +#endif + STOREREG(PMVideoControl, 1 | (1 << 3) | (1 << 5) | (1 << 19)); break; case 32: - pReg->glintRegs[PM3ByAperture1Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_32BIT; - pReg->glintRegs[PM3ByAperture2Mode >> 3] = - PM3ByApertureMode_PIXELSIZE_32BIT; - pReg->glintRegs[PMVideoControl >> 3] = - 1 | (1 << 3) | (1 << 5) | (2 << 19); +#if X_BYTE_ORDER != X_BIG_ENDIAN + STOREREG(PM3ByAperture1Mode, PM3ByApertureMode_PIXELSIZE_32BIT); + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_32BIT); +#else + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_32BIT | + PM3ByApertureMode_BYTESWAP_DCBA); + STOREREG(PM3ByAperture2Mode, PM3ByApertureMode_PIXELSIZE_32BIT | + PM3ByApertureMode_BYTESWAP_DCBA); +#endif + STOREREG(PMVideoControl, 1 | (1 << 3) | (1 << 5) | (2 << 19)); break; } - pReg->glintRegs[VClkCtl >> 3] = (GLINT_READ_REG(VClkCtl) & 0xFFFFFFFC); - pReg->glintRegs[PMScreenBase >> 3] = 0; + STOREREG(VClkCtl, GLINT_READ_REG(VClkCtl) & 0xFFFFFFFC); + STOREREG(PMScreenBase, 0x00000000); + STOREREG(ChipConfig, GLINT_READ_REG(ChipConfig) & 0xFFFFFFFD); - pReg->glintRegs[ChipConfig >> 3] = GLINT_READ_REG(ChipConfig) & 0xFFFFFFDD; - pReg->DacRegs[PM2VDACRDDACControl] = 0x00; - { /* Get the programmable clock values */ unsigned char m,n,p; @@ -331,197 +298,274 @@ Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Let's program the dot clock */ clockused = PM3DAC_CalculateClock(mode->Clock, pGlint->RefClock, &m,&n,&p); - pReg->DacRegs[PM3RD_DClk0PreScale] = m; - pReg->DacRegs[PM3RD_DClk0FeedbackScale] = n; - pReg->DacRegs[PM3RD_DClk0PostScale] = p; + STOREDAC(PM3RD_DClk0PreScale, m); + STOREDAC(PM3RD_DClk0FeedbackScale, n); + STOREDAC(PM3RD_DClk0PostScale, p); } - pReg->DacRegs[PM2VDACRDIndexControl] = 0x00; - - if (pScrn->rgbBits == 8) - pReg->DacRegs[PM2VDACRDMiscControl] = 0x01; /* 8bit DAC */ - else - pReg->DacRegs[PM2VDACRDMiscControl] = 0x00; /* 6bit DAC */ - - pReg->DacRegs[PM2VDACRDSyncControl] = 0x00; - if (!(mode->Flags & V_PHSYNC)) - pReg->DacRegs[PM2VDACRDSyncControl] |= 0x01; /* invert hsync */ - if (!(mode->Flags & V_PVSYNC)) - pReg->DacRegs[PM2VDACRDSyncControl] |= 0x08; /* invert vsync */ - + temp1 = 0; + temp2 = 0; #if 0 /* Currently commented out while testing Flat Panel support */ - pReg->DacRegs[PM2VDACRDDACControl] = 0x01; - pReg->DacRegs[PM2VDACRDSyncControl] |= 0x40; - pReg->glintRegs[VSConfiguration >> 3] = (GLINT_READ_REG(VSConfiguration) & 0xFFFFFFF8) | 0x06; - pReg->glintRegs[VSBBase >> 3] = 1<<14; + temp1 |= 0x40; + temp2 |= 0x01; + STOREREG(VSConfiguration, + (GLINT_READ_REG(VSConfiguration) & 0xFFFFFFF8) | 0x06)); + STOREREG(VSBBase, 1<<14); #endif + if (mode->Flags & V_PHSYNC) temp1 |= 0x01; /* invert hsync */ + if (mode->Flags & V_PVSYNC) temp1 |= 0x08; /* invert vsync */ + + STOREDAC(PM2VDACRDIndexControl, 0x00); + STOREDAC(PM2VDACRDSyncControl, temp1); + STOREDAC(PM2VDACRDDACControl, 0x00); + + temp3 = 0; + if (pScrn->rgbBits == 8) + temp3 |= 0x01; /* 8bit DAC */ switch (pScrn->bitsPerPixel) { case 8: - pReg->DacRegs[PM2VDACRDPixelSize] = 0x00; - pReg->DacRegs[PM2VDACRDColorFormat] = 0x2E; + STOREDAC(PM2VDACRDPixelSize, 0x00); + STOREDAC(PM2VDACRDColorFormat, 0x2E); break; case 16: - pReg->DacRegs[PM2VDACRDPixelSize] = 0x01; - if (pScrn->depth == 15) - pReg->DacRegs[PM2VDACRDColorFormat] = 0x61; - else - pReg->DacRegs[PM2VDACRDColorFormat] = 0x70; + STOREDAC(PM2VDACRDPixelSize, 0x01); + if (pScrn->depth == 15) { + STOREDAC(PM2VDACRDColorFormat, 0x61); + } else { + STOREDAC(PM2VDACRDColorFormat, 0x70); + } break; case 24: - pReg->DacRegs[PM2VDACRDPixelSize] = 0x04; - pReg->DacRegs[PM2VDACRDColorFormat] = 0x60; + STOREDAC(PM2VDACRDPixelSize, 0x04); + STOREDAC(PM2VDACRDColorFormat, 0x60); break; case 32: - pReg->DacRegs[PM2VDACRDPixelSize] = 0x02; - pReg->DacRegs[PM2VDACRDColorFormat] = 0x20; if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x10; - pReg->DacRegs[PM2VDACRDOverlayKey] = pScrn->colorKey; + temp3 |= 0x18; + STOREDAC(PM2VDACRDOverlayKey, pScrn->colorKey); } + STOREDAC(PM2VDACRDPixelSize, 0x02); + STOREDAC(PM2VDACRDColorFormat, 0x20); break; } + STOREDAC(PM2VDACRDMiscControl, temp3); return(TRUE); } void -Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr glintReg) +Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr pReg) { GLINTPtr pGlint = GLINTPTR(pScrn); int i; + /* We can't rely on the vgahw layer copying the font information + * back properly, due to problems with MMIO access to VGA space + * so we memcpy the information */ + memcpy((CARD8*)pGlint->VGAdata,(CARD8*)pGlint->FbBase, 65536); + + if ((pGlint->numMultiDevices == 2) || (IS_J2000)) { + SAVEREG(GCSRAperture); + } + + if (pGlint->MultiAperture) { + SAVEREG(GMultGLINTAperture); + SAVEREG(GMultGLINT1); + SAVEREG(GMultGLINT2); + } + /* Permedia 3 memory Timings */ - glintReg->glintRegs[PM3MemBypassWriteMask >> 3] = - GLINT_READ_REG(PM3MemBypassWriteMask); - glintReg->glintRegs[PM3ByAperture1Mode >> 3] = - GLINT_READ_REG(PM3ByAperture1Mode); - glintReg->glintRegs[PM3ByAperture2Mode >> 3] = - GLINT_READ_REG(PM3ByAperture2Mode); - - glintReg->glintRegs[ChipConfig >> 3] = GLINT_READ_REG(ChipConfig); - glintReg->glintRegs[Aperture0 >> 3] = GLINT_READ_REG(Aperture0); - glintReg->glintRegs[Aperture1 >> 3] = GLINT_READ_REG(Aperture1); - - glintReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis); - glintReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis); - glintReg->glintRegs[PMHTotal >> 3] = GLINT_READ_REG(PMHTotal); - glintReg->glintRegs[PMHbEnd >> 3] = GLINT_READ_REG(PMHbEnd); - glintReg->glintRegs[PMHbEnd >> 3] = GLINT_READ_REG(PMHgEnd); - glintReg->glintRegs[PMScreenStride >> 3] = GLINT_READ_REG(PMScreenStride); - glintReg->glintRegs[PMHsStart >> 3] = GLINT_READ_REG(PMHsStart); - glintReg->glintRegs[PMHsEnd >> 3] = GLINT_READ_REG(PMHsEnd); - glintReg->glintRegs[PMVTotal >> 3] = GLINT_READ_REG(PMVTotal); - glintReg->glintRegs[PMVbEnd >> 3] = GLINT_READ_REG(PMVbEnd); - glintReg->glintRegs[PMVsStart >> 3] = GLINT_READ_REG(PMVsStart); - glintReg->glintRegs[PMVsEnd >> 3] = GLINT_READ_REG(PMVsEnd); - glintReg->glintRegs[PMScreenBase >> 3] = GLINT_READ_REG(PMScreenBase); - glintReg->glintRegs[PMVideoControl >> 3] = GLINT_READ_REG(PMVideoControl); - glintReg->glintRegs[VClkCtl >> 3] = GLINT_READ_REG(VClkCtl); + SAVEREG(PM3MemBypassWriteMask); + SAVEREG(PM3ByAperture1Mode); + SAVEREG(PM3ByAperture2Mode); + SAVEREG(ChipConfig); + SAVEREG(Aperture0); + SAVEREG(Aperture1); + + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) + SAVEREG(DFIFODis); + SAVEREG(FIFODis); + SAVEREG(PMHTotal); + SAVEREG(PMHbEnd); + SAVEREG(PMHgEnd); + SAVEREG(PMScreenStride); + SAVEREG(PMHsStart); + SAVEREG(PMHsEnd); + SAVEREG(PMVTotal); + SAVEREG(PMVbEnd); + SAVEREG(PMVsStart); + SAVEREG(PMVsEnd); + SAVEREG(PMScreenBase); + SAVEREG(PMVideoControl); + SAVEREG(VClkCtl); #if 0 /* Currently commented out while testing Flat Panel support */ - glintReg->glintRegs[VSConfiguration >> 3] = GLINT_READ_REG(VSConfiguration); - glintReg->glintRegs[VSBBase >> 3] = GLINT_READ_REG(VSBBase); + SAVEREG(VSConfiguration); + SAVEREG(VSBBase); #endif for (i=0;i<768;i++) { Permedia2ReadAddress(pScrn, i); - glintReg->cmap[i] = Permedia2ReadData(pScrn); + pReg->cmap[i] = Permedia2ReadData(pScrn); } - glintReg->DacRegs[PM2VDACRDIndexControl] = - Permedia2vInIndReg(pScrn, PM2VDACRDIndexControl); - glintReg->DacRegs[PM2VDACRDOverlayKey] = - Permedia2vInIndReg(pScrn, PM2VDACRDOverlayKey); - glintReg->DacRegs[PM2VDACRDSyncControl] = - Permedia2vInIndReg(pScrn, PM2VDACRDSyncControl); - glintReg->DacRegs[PM2VDACRDMiscControl] = - Permedia2vInIndReg(pScrn, PM2VDACRDMiscControl); - glintReg->DacRegs[PM2VDACRDDACControl] = - Permedia2vInIndReg(pScrn, PM2VDACRDDACControl); - glintReg->DacRegs[PM2VDACRDPixelSize] = - Permedia2vInIndReg(pScrn, PM2VDACRDPixelSize); - glintReg->DacRegs[PM2VDACRDColorFormat] = - Permedia2vInIndReg(pScrn, PM2VDACRDColorFormat); - - glintReg->DacRegs[PM2VDACRDDClk0PreScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0PreScale); - glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0FeedbackScale); - glintReg->DacRegs[PM2VDACRDDClk0PostScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0PostScale); + P2VIN(PM2VDACRDIndexControl); + P2VIN(PM2VDACRDOverlayKey); + P2VIN(PM2VDACRDSyncControl); + P2VIN(PM2VDACRDMiscControl); + P2VIN(PM2VDACRDDACControl); + P2VIN(PM2VDACRDPixelSize); + P2VIN(PM2VDACRDColorFormat); + P2VIN(PM2VDACRDDClk0PreScale); + P2VIN(PM2VDACRDDClk0FeedbackScale); + P2VIN(PM2VDACRDDClk0PostScale); } void -Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg) +Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr pReg) { GLINTPtr pGlint = GLINTPTR(pScrn); CARD32 temp; int i; -#if 0 - GLINT_SLOW_WRITE_REG(0, ResetStatus); - while(GLINT_READ_REG(ResetStatus) != 0) { - xf86MsgVerb(X_INFO, 2, "Resetting Engine - Please Wait.\n"); - }; -#endif + /* We can't rely on the vgahw layer copying the font information + * back properly, due to problems with MMIO access to VGA space + * so we memcpy the information */ + if (pGlint->STATE) + memcpy((CARD8*)pGlint->FbBase,(CARD8*)pGlint->VGAdata, 65536); + + if ((pGlint->numMultiDevices == 2) || (IS_J2000)) { + RESTOREREG(GCSRAperture); + } + + if (pGlint->MultiAperture) { + RESTOREREG(GMultGLINTAperture); + RESTOREREG(GMultGLINT1); + RESTOREREG(GMultGLINT2); + } /* Permedia 3 memory Timings */ - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3MemBypassWriteMask >> 3], - PM3MemBypassWriteMask); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture1Mode >> 3], - PM3ByAperture1Mode); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture2Mode >> 3], - PM3ByAperture2Mode); - - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[ChipConfig >> 3], ChipConfig); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture0 >> 3], Aperture0); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture1 >> 3], Aperture1); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[DFIFODis >> 3], DFIFODis); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FIFODis >> 3], FIFODis); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVideoControl >> 3], - PMVideoControl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHbEnd >> 3], PMHgEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMScreenBase >> 3], PMScreenBase); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VClkCtl >> 3], VClkCtl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMScreenStride >> 3], - PMScreenStride); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHTotal >> 3], PMHTotal); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHbEnd >> 3], PMHbEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHsStart >> 3], PMHsStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHsEnd >> 3], PMHsEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVTotal >> 3], PMVTotal); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVbEnd >> 3], PMVbEnd); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsStart >> 3], PMVsStart); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsEnd >> 3], PMVsEnd); + RESTOREREG(PM3MemBypassWriteMask); + RESTOREREG(PM3ByAperture1Mode); + RESTOREREG(PM3ByAperture2Mode); + RESTOREREG(ChipConfig); + RESTOREREG(Aperture0); + RESTOREREG(Aperture1); + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) + RESTOREREG(DFIFODis); + RESTOREREG(FIFODis); + RESTOREREG(PMVideoControl); + RESTOREREG(PMHbEnd); + RESTOREREG(PMHgEnd); + RESTOREREG(PMScreenBase); + RESTOREREG(VClkCtl); + RESTOREREG(PMScreenStride); + RESTOREREG(PMHTotal); + RESTOREREG(PMHsStart); + RESTOREREG(PMHsEnd); + RESTOREREG(PMVTotal); + RESTOREREG(PMVbEnd); + RESTOREREG(PMVsStart); + RESTOREREG(PMVsEnd); + #if 0 /* Currently commented out while testing Flat Panel support */ - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VSConfiguration >> 3], VSConfiguration); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VSBBase >> 3], VSBBase); + RESTOREREG(VSConfiguration); + RESTOREREG(VSBBase); #endif - Permedia2vOutIndReg(pScrn, PM2VDACRDIndexControl, 0x00, - glintReg->DacRegs[PM2VDACRDIndexControl]); - Permedia2vOutIndReg(pScrn, PM2VDACRDOverlayKey, 0x00, - glintReg->DacRegs[PM2VDACRDOverlayKey]); - Permedia2vOutIndReg(pScrn, PM2VDACRDSyncControl, 0x00, - glintReg->DacRegs[PM2VDACRDSyncControl]); - Permedia2vOutIndReg(pScrn, PM2VDACRDMiscControl, 0x00, - glintReg->DacRegs[PM2VDACRDMiscControl]); - Permedia2vOutIndReg(pScrn, PM2VDACRDDACControl, 0x00, - glintReg->DacRegs[PM2VDACRDDACControl]); - Permedia2vOutIndReg(pScrn, PM2VDACRDPixelSize, 0x00, - glintReg->DacRegs[PM2VDACRDPixelSize]); - Permedia2vOutIndReg(pScrn, PM2VDACRDColorFormat, 0x00, - glintReg->DacRegs[PM2VDACRDColorFormat]); + P2VOUT(PM2VDACRDIndexControl); + P2VOUT(PM2VDACRDOverlayKey); + P2VOUT(PM2VDACRDSyncControl); + P2VOUT(PM2VDACRDMiscControl); + P2VOUT(PM2VDACRDDACControl); + P2VOUT(PM2VDACRDPixelSize); + P2VOUT(PM2VDACRDColorFormat); for (i=0;i<768;i++) { Permedia2WriteAddress(pScrn, i); - Permedia2WriteData(pScrn, glintReg->cmap[i]); + Permedia2WriteData(pScrn, pReg->cmap[i]); } temp = Permedia2vInIndReg(pScrn, PM2VDACIndexClockControl) & 0xFC; - Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PreScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0PreScale]); - Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0FeedbackScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale]); - Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PostScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0PostScale]); + P2VOUT(PM2VDACRDDClk0PreScale); + P2VOUT(PM2VDACRDDClk0FeedbackScale); + P2VOUT(PM2VDACRDDClk0PostScale); Permedia2vOutIndReg(pScrn, PM2VDACIndexClockControl, 0x00, temp|0x03); } + +void Permedia3LoadPalette( + ScrnInfoPtr pScrn, + int numColors, + int *indices, + LOCO *colors, + VisualPtr pVisual +){ +#if 0 /* NOT YET */ + GLINTPtr pGlint = GLINTPTR(pScrn); +#endif + int i, index, shift = 0, j, repeat = 1; + + if (pScrn->depth == 15) { + repeat = 8; + shift = 3; + } + + for(i = 0; i < numColors; i++) { + index = indices[i]; + for (j = 0; j < repeat; j++) { + Permedia2WriteAddress(pScrn, (index << shift)+j); + Permedia2WriteData(pScrn, colors[index].red); + Permedia2WriteData(pScrn, colors[index].green); + Permedia2WriteData(pScrn, colors[index].blue); + } + /* for video i/o */ +#if 0 /* NOT YET */ + GLINT_SLOW_WRITE_REG(index, PM3LUTIndex); + GLINT_SLOW_WRITE_REG((colors[index].red & 0xFF) | + ((colors[index].green & 0xFF) << 8) | + ((colors[index].blue & 0xFF) << 16), + PM3LUTData); +#endif + } +} + +/* special one for 565 mode */ +void Permedia3LoadPalette16( + ScrnInfoPtr pScrn, + int numColors, + int *indices, + LOCO *colors, + VisualPtr pVisual +){ +#if 0 /* NOT YET */ + GLINTPtr pGlint = GLINTPTR(pScrn); +#endif + int i, index, j; + + for(i = 0; i < numColors; i++) { + index = indices[i]; + for (j = 0; j < 4; j++) { + Permedia2WriteAddress(pScrn, (index << 2)+j); + Permedia2WriteData(pScrn, colors[index >> 1].red); + Permedia2WriteData(pScrn, colors[index].green); + Permedia2WriteData(pScrn, colors[index >> 1].blue); + } +#if 0 /* NOT YET */ + GLINT_SLOW_WRITE_REG(index, PM3LUTIndex); + GLINT_SLOW_WRITE_REG((colors[index].red & 0xFF) | + ((colors[index].green & 0xFF) << 8) | + ((colors[index].blue & 0xFF) << 16), + PM3LUTData); +#endif + + if(index <= 31) { + for (j = 0; j < 4; j++) { + Permedia2WriteAddress(pScrn, (index << 3)+j); + Permedia2WriteData(pScrn, colors[index].red); + Permedia2WriteData(pScrn, colors[(index << 1) + 1].green); + Permedia2WriteData(pScrn, colors[index].blue); + } + } + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h index ed455edd9..42946b213 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h,v 1.3 2000/10/17 09:07:05 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h,v 1.4 2001/01/31 16:15:02 alanh Exp $ */ /* * glint register file @@ -698,7 +698,7 @@ #define PM3LUT 0x8e80 #define PM3LUTAddress 0x84d0 #define PM3LUTData 0x84c8 -#define PM3LUTIndex 0x64c0 +#define PM3LUTIndex 0x84c0 #define PM3LUTMode 0xb378 #define PM3LUTModeAnd 0xad70 #define PM3LUTModeOr 0xad78 @@ -955,11 +955,6 @@ #define PM3FillRectanglePosition_XOffset(x) ((x)&0xffff) #define PM3FillRectanglePosition_YOffset(y) (((y)&0xffff)<<16) -/********************************************** -* GLINT Permedia3 Tags and other stuff * -***********************************************/ -#define PM3SyncTag 0x0188 - #if 0 /********************************************** @@ -986,16 +981,6 @@ WRITE_REG(base,offset,temp&(~(val))); \ } -#if 0 /* Old Xfree code ... */ -#define WAIT(n) \ -do{ \ - if(!pGlint->UsePCIRetry) \ - while(READ_REG(InFIFOSpace)<(n)){ \ - mem_barrier(); \ - } \ -}while(0) -#endif - #define RAMDAC_DELAY(b,x) do { \ int delay = x; \ unsigned char tmp; \ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c index 2f08ac36d..1909ffada 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c @@ -1,5 +1,5 @@ /* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. + * Copyright 1997-2001 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -28,7 +28,7 @@ * * GLINT 500TX / MX accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.22 2000/05/10 20:01:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.25 2001/02/07 13:26:21 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -47,6 +47,7 @@ #include "xaalocal.h" /* For replacements */ static void TXSync(ScrnInfoPtr pScrn); +static void DualTXSync(ScrnInfoPtr pScrn); static void TXSetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask); static void TXSubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, @@ -74,10 +75,6 @@ static void TXWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int trans, int bpp, int depth); -static void TXSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, - int bg, int rop, unsigned int planemask); -static void TXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, - int y, int w, int h, int skipleft); static void TXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); static void TXSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, @@ -104,9 +101,30 @@ TXInitializeEngine(ScrnInfoPtr pScrn) { GLINTPtr pGlint = GLINTPTR(pScrn); /* Initialize the Accelerator Engine to defaults */ + pGlint->rasterizerMode = UNIT_DISABLE; + + if (pGlint->MultiAperture) { + pGlint->rasterizerMode = RMMultiGLINT; + + /* Only write the following register to the first chip */ + GLINT_SLOW_WRITE_REG(1, BroadcastMask); + GLINT_SLOW_WRITE_REG(0x00000001, ScanLineOwnership); + + /* Only write the following register to the second chip */ + GLINT_SLOW_WRITE_REG(2, BroadcastMask); + GLINT_SLOW_WRITE_REG(0x00000005, ScanLineOwnership); + + /* Make sure the rest of the register writes go to both chip's */ + GLINT_SLOW_WRITE_REG(3, BroadcastMask); + GLINT_SLOW_WRITE_REG(pGlint->pprod | LBRM_ScanlineInt2, LBReadMode); + pGlint->pprod |= FBRM_ScanlineInt2; + } else { + GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode); + } + + GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); - GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode); GLINT_SLOW_WRITE_REG(pGlint->pprod, FBReadMode); GLINT_SLOW_WRITE_REG(0, dXSub); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWriteMode); @@ -134,7 +152,6 @@ TXInitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(0x400, FilterMode); GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset); @@ -192,7 +209,10 @@ TXAccelInit(ScreenPtr pScreen) LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; - infoPtr->Sync = TXSync; + if (pGlint->MultiAperture) + infoPtr->Sync = DualTXSync; + else + infoPtr->Sync = TXSync; infoPtr->SetClippingRectangle = TXSetClippingRectangle; infoPtr->DisableClipping = TXDisableClipping; @@ -217,10 +237,12 @@ TXAccelInit(ScreenPtr pScreen) infoPtr->PolySegmentThinSolid = TXPolySegmentThinSolidWrapper; infoPtr->PolylinesThinSolid = TXPolylinesThinSolidWrapper; - infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | - ONLY_LEFT_TO_RIGHT_BITBLT; - infoPtr->SetupForScreenToScreenCopy = TXSetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = TXSubsequentScreenToScreenCopy; + if (!pGlint->MultiAperture) { + infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | + ONLY_LEFT_TO_RIGHT_BITBLT; + infoPtr->SetupForScreenToScreenCopy = TXSetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = TXSubsequentScreenToScreenCopy; + } infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_ORIGIN | HARDWARE_PATTERN_SCREEN_ORIGIN | @@ -228,37 +250,25 @@ TXAccelInit(ScreenPtr pScreen) infoPtr->SetupForMono8x8PatternFill = TXSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = TXSubsequentMono8x8PatternFillRect; - if (!pGlint->UsePCIRetry) { - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = TRANSPARENCY_ONLY | BIT_ORDER_IN_BYTE_LSBFIRST; - pGlint->XAAScanlineColorExpandBuffers[0] = + pGlint->XAAScanlineColorExpandBuffers[0] = xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8)); - pGlint->XAAScanlineColorExpandBuffers[1] = + pGlint->XAAScanlineColorExpandBuffers[1] = xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8)); - infoPtr->NumScanlineColorExpandBuffers = 2; - infoPtr->ScanlineColorExpandBuffers = + infoPtr->NumScanlineColorExpandBuffers = 2; + infoPtr->ScanlineColorExpandBuffers = pGlint->XAAScanlineColorExpandBuffers; - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = TXSetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = TXSubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = + infoPtr->SubsequentColorExpandScanline = TXSubsequentColorExpandScanline; - } else { - infoPtr->CPUToScreenColorExpandFillFlags = TRANSPARENCY_ONLY | - SYNC_AFTER_COLOR_EXPAND | - CPU_TRANSFER_PAD_DWORD | - BIT_ORDER_IN_BYTE_LSBFIRST; - infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4; - infoPtr->SetupForCPUToScreenColorExpandFill = - TXSetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - TXSubsequentCPUToScreenColorExpandFill; - } infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; @@ -312,42 +322,20 @@ static void TXLoadCoord( } #else GLINT_WRITE_REG(w<<16, StartXSub); - pGlint->startxsub = w; GLINT_WRITE_REG(x<<16,StartXDom); - pGlint->startxdom = x; GLINT_WRITE_REG(y<<16,StartY); - pGlint->starty = y; GLINT_WRITE_REG(h,GLINTCount); - pGlint->count = h; GLINT_WRITE_REG(a<<16,dXDom); - pGlint->dxdom = a; GLINT_WRITE_REG(d<<16,dY); + pGlint->startxsub = w; + pGlint->startxdom = x; + pGlint->starty = y; + pGlint->count = h; + pGlint->dxdom = a; pGlint->dy = d; #endif } -static void MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords ) -{ - while(dwords & ~0x03) { - *dest = *src; - *(dest + 1) = *(src + 1); - *(dest + 2) = *(src + 2); - *(dest + 3) = *(src + 3); - src += 4; - dest += 4; - dwords -= 4; - } - if (!dwords) return; - *dest = *src; - if (dwords == 1) return; - *(dest + 1) = *(src + 1); - if (dwords == 2) return; - *(dest + 2) = *(src + 2); -} - static void TXSync( ScrnInfoPtr pScrn @@ -363,12 +351,46 @@ TXSync( GLINT_WRITE_REG(0, GlintSync); do { while(GLINT_READ_REG(OutFIFOWords) == 0); -#define Sync_tag 0x188 readValue = GLINT_READ_REG(OutputFIFO); } while (readValue != Sync_tag); } static void +DualTXSync( + ScrnInfoPtr pScrn +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + unsigned long readValue; + + CHECKCLIPPING; + + while (GLINT_READ_REG(DMACount) != 0); + GLINT_WAIT(3); + + /* hack! this shouldn't need to be reloaded */ + GLINT_WRITE_REG(3, BroadcastMask); + GLINT_WRITE_REG(0x400, FilterMode); + GLINT_WRITE_REG(0, GlintSync); + + /* Read 1st MX until Sync Tag shows */ + ACCESSCHIP1(); + do { + while(GLINT_READ_REG(OutFIFOWords) == 0); + readValue = GLINT_READ_REG(OutputFIFO); + } while (readValue != Sync_tag); + + ACCESSCHIP2(); + /* Read 2nd MX until Sync Tag shows */ + do { + while(GLINT_READ_REG(OutFIFOWords) == 0); + readValue = GLINT_READ_REG(OutputFIFO); + } while (readValue != Sync_tag); + + ACCESSCHIP1(); +} + + +static void TXSetupForFillRectSolid( ScrnInfoPtr pScrn, int color, int rop, @@ -492,7 +514,7 @@ TXSetupForScanlineCPUToScreenColorExpandFill( REPLICATE(bg); GLINT_WAIT(6); DO_PLANEMASK(planemask); - GLINT_WRITE_REG(0, RasterizerMode); + GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); if (rop == GXcopy) { GLINT_WRITE_REG(pGlint->pprod, FBReadMode); GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); @@ -541,7 +563,8 @@ TXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) while (dwords >= infoRec->ColorExpandRange) { GLINT_WAIT(infoRec->ColorExpandRange); GLINT_WRITE_REG((infoRec->ColorExpandRange - 2)<<16 | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src, + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src, infoRec->ColorExpandRange - 1); dwords -= (infoRec->ColorExpandRange - 1); src += (infoRec->ColorExpandRange - 1); @@ -549,51 +572,12 @@ TXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) if (dwords) { GLINT_WAIT(dwords); GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,dwords); + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,dwords); } pGlint->cpucount += 1; } -static void -TXSetupForCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - REPLICATE(fg); - - DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode); - GLINT_WRITE_REG(fg, FBBlockColor); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode); - GLINT_WRITE_REG(fg, PatternRamData0); - pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation; - } - LOADROP(rop); -} - -static void -TXSubsequentCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dwords = ((w + 31) >> 5) * h; - - TXLoadCoord(pScrn, x, y, x+w, h, 0, 1); - GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode | - SyncOnBitMask, Render); - GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); -} - void TXSetupForMono8x8PatternFill( ScrnInfoPtr pScrn, int patternx, int patterny, @@ -696,7 +680,7 @@ TXWriteBitmap(ScrnInfoPtr pScrn, GLINT_WAIT(11); DO_PLANEMASK(planemask); - GLINT_WRITE_REG(0, RasterizerMode); + GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); LOADROP(rop); if (rop == GXcopy) { mode = 0; @@ -775,7 +759,7 @@ SECOND_PASS: SecondPass = FALSE; REPLICATE(bg); GLINT_WAIT(4); - GLINT_WRITE_REG(InvertBitMask, RasterizerMode); + GLINT_WRITE_REG(InvertBitMask | pGlint->rasterizerMode, RasterizerMode); if (rop == GXcopy) { GLINT_WRITE_REG(bg, FBBlockColor); } else { @@ -785,7 +769,7 @@ SECOND_PASS: } GLINT_WAIT(2); - GLINT_WRITE_REG(0, RasterizerMode); + GLINT_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); CHECKCLIPPING; SET_SYNC_FLAG(infoRec); } @@ -848,7 +832,8 @@ TXWritePixmap( /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((infoRec->ColorExpandRange - 2) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, infoRec->ColorExpandRange - 1); count -= infoRec->ColorExpandRange - 1; srcp += infoRec->ColorExpandRange - 1; @@ -858,7 +843,8 @@ TXWritePixmap( /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), + GLINT_MoveDWORDS( + (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), (CARD32*)srcp, count); } src += srcwidth; |