diff options
author | dawes <dawes> | 2001-06-14 22:23:38 +0000 |
---|---|---|
committer | dawes <dawes> | 2001-06-14 22:23:38 +0000 |
commit | a9af1066d2bdb2fdeba01fa0e632c8a84252c890 (patch) | |
tree | 7ff6948a75cb86262da535d5640dbedb02620a37 /xc/programs/Xserver/hw/xfree86/drivers/glint | |
parent | 5132c952e46848a277c5465ccc5db366fa2876f5 (diff) |
First pass of 4.1.0 merge.
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/glint')
11 files changed, 1146 insertions, 694 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile index 9d0d04db1..a23fb7820 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.32 2001/02/24 14:29:16 alanh Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.34.2.1 2001/05/25 11:19:31 alanh Exp $ XCOMM XCOMM This is an Imakefile for the GLINT driver. XCOMM @@ -39,7 +39,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/render #endif -DEFINES = $(GLX_DEFINES) -DPPC_MMIO_IS_BE +DEFINES = $(GLX_DEFINES) -DPPC_MMIO_IS_BE -DSPARC_MMIO_IS_BE #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -76,6 +76,8 @@ InstallDriverSDKNonExecFile(pm2v_dac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(pm2vramdac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(pm3_dac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(pm3_accel.c,$(DRIVERSDKDIR)/drivers/glint) +InstallDriverSDKNonExecFile(pm3_video.c,$(DRIVERSDKDIR)/drivers/glint) +InstallDriverSDKNonExecFile(pm3_regs.h,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(pm_accel.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(pm_dac.c,$(DRIVERSDKDIR)/drivers/glint) InstallDriverSDKNonExecFile(tx_accel.c,$(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 c8950a4bc..c4db56f6b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 @@ -1,6 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.9 2001/04/18 09:24:47 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.11 2001/05/08 19:31:22 alanh Exp $ */ -STATUS as of Fri, 13 Apr 2001 21:43:39 +0200 +STATUS as of Tue, 8 May 2001 19:01:39 +0200 Working : * Unaccelerated : Depth 8, 15, 16 and 24 are ok. I tested them upto @@ -24,13 +24,25 @@ Working : - Pixmap Writes using direct FIFO writes with or without FIFO Disconnect. * Appian J2000 second head initialization. * Dual head : The console fonts will get trashed, but dual head works. - * Xv : Hardware video scaler with the following attributes : - - FILTER : None, Partial (X only) or Full filtering. - - OVERLAY_MODE : Opaque, Blended or Color keyed Video Overlay. - - MIRROR : X and/or Y Axis mirroring. + * Xv : Hardware video scaler : + - Needs checking on a big endian machine. + - Needs acceleration to work. + - Clipping supported trough the alpha channel in depth 15 and 24 + and with an overlay key color in depth 8 and 16. + - Support both dual head and single head, trough gamma or permedia3. + - Attributes are : + - FILTER : None, Partial (X only) or Full filtering. + - MIRROR : X and/or Y Axis mirroring. + - ALPHA : + - 0 -> FB Only + - 1 -> 25% Video, 75% FB + - 2 -> 75% Video, 25% FB + - 3 -> Video Only + - [TODO] VIDEOKEY : Overlay Key Color for clipping in depth 8 and 16. * DRI : Work is underway. Not Working : + * [NOT POSSIBLE] 2D Accel : - Solid & Dashed Lines are not possible on glint hardware. - 8x8 Color Pattern Fill is almost never used. @@ -40,19 +52,20 @@ Not Working : - CPUToScreenTexture. - CPUToScreenAlphaTexture. * [NEED FIX] Xv has still some minor problems : - - Currently it needs accel to work. - => we could enable the offscreen memory manager, but this will crash the - server. I guess this is because of bad timing. - - Crashes when used with the gamma chip. - - Clipping is not supported. - => we could use framebuffer alpha blending or alpha channel keyed video - overlay to simulate it, but this would need to set the framebuffer alpha - channel as a mask, and would be very inefficient. Maybe we could use a - second framebuffer to do this, and use it as a mask ? + - depth 8 does not work, but then it may be the app i am using. + - when using 2D accels there is some unstability in the video display. I + guess this is because there is then not enough bandwith to do the + copying of the data in time. After a time of the above, the images + becomes black. It will come back once stopvideo is called. + [FIX] i will disable VideoOverlay each 25 frames, this causes a flicker, + but at least it will bing the image back. * [WORK IS UNDERWAY] DRI/OpenGL (only together with a gamma chip) : - DRI support should be ok, but accelerated openGL is not yet supported. - The accelerated OpenGL library supposes we are using a gamma together with a MX rasterizer, not a Permedia3 one. + +Known problems : + * Console gets broken when using dual headed mode. The culprit seems to be the vga graphics index & port (GraphicsIndexReg : 0x63ce, GraphicsPort : 0x3cf). I had to use IO acces for both these two, because if not, console @@ -67,6 +80,8 @@ Not Working : Well, this is partly fixed, but still appears under very heavy load. * [FIXED] When moving a window around a lot quickly, the video outputs dies. Well, this is partly fixed, but still appears under very heavy load. + => [NOTE] If this two still happens, try disabling the Hardware cursor, with + the "SWCursor" option to your device XF86Config section. * Sometimes there are blue transparent garbage in the form of small horizontal bands, few pixels high, and more pixels width, maybe 64pixels ? This may be a hardware bug. diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h index 2baed5658..3db30c12d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.47 2001/04/18 09:24:47 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.48.2.1 2001/05/24 20:12:47 alanh Exp $ */ /* * Copyright 1997-2001 by Alan Hourihane <alanh@fairlite.demon.co.uk> * @@ -46,7 +46,6 @@ #endif #define GLINT_MAX_MULTI_DEVICES 2 -#define GLINT_VGA_MMIO_OFF 0x6000 #define VERSION 4000 #define GLINT_NAME "GLINT" @@ -83,29 +82,28 @@ typedef struct { int HwBpp; int BppShift; int pprod; - int ForeGroundColor; - int BackGroundColor; + CARD32 ForeGroundColor; + CARD32 BackGroundColor; int bppalign; - int startxdom; - int startxsub; - int starty; - int count; - int dy; - int x; - int y; - int w; - int h; - int dxdom; + CARD32 startxdom; + CARD32 startxsub; + CARD32 starty; + CARD32 count; + CARD32 dy; + CARD32 x; + CARD32 y; + CARD32 w; + CARD32 h; + CARD32 dxdom; int dwords; int cpuheight; int cpucount; - int planemask; + CARD32 planemask; int realWidth; CARD32 IOAddress; unsigned long FbAddress; int irq; unsigned char * IOBase; - unsigned char * IOBaseVGA; unsigned char * FbBase; long FbMapSize; long IOOffset; @@ -126,7 +124,6 @@ typedef struct { Bool UseFlatPanel; Bool UseFireGL3000; CARD8 VGAdata[65536]; - Bool VGAcore; Bool STATE; Bool ScanlineDirect; int MXFbSize; @@ -160,10 +157,11 @@ typedef struct { void (*LoadCursorCallback)(ScrnInfoPtr); void (*CursorColorCallback)(ScrnInfoPtr); CARD32 PM3_PixelSize; - int PM3_Config2D; - int PM3_Render2D; - int PM3_AreaStippleMode; - int PM3_VideoControl; + CARD32 PM3_Config2D; + CARD32 PM3_Render2D; + CARD32 PM3_AreaStippleMode; + CARD32 PM3_VideoControl; + int InFifoSpace; #ifdef XF86DRI Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -174,6 +172,7 @@ typedef struct { GLINTConfigPrivPtr pVisualConfigsPriv; GLINTRegRec DRContextRegs; #endif + OptionInfoPtr Options; } GLINTRec, *GLINTPtr; /* Defines for PCI data */ 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 0625bd4c6..2e2759283 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.26 2001/04/10 16:08:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.27 2001/05/02 15:06:09 dawes Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 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 fe03f47b1..76f0b0620 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c @@ -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.122 2001/04/19 09:28:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.125.2.4 2001/05/29 11:32:22 alanh Exp $ */ #include "fb.h" #include "cfb8_32.h" @@ -42,7 +42,6 @@ #include "xf86cmap.h" #include "shadowfb.h" #include "fbdevhw.h" -#include "vgaHW.h" #include "xf86RAC.h" #include "xf86Resources.h" #include "xf86int10.h" @@ -79,7 +78,7 @@ # define TRACE(str) #endif -static OptionInfoPtr GLINTAvailableOptions(int chipid, int busid); +static const OptionInfoRec * GLINTAvailableOptions(int chipid, int busid); static void GLINTIdentify(int flags); static Bool GLINTProbe(DriverPtr drv, int flags); static Bool GLINTPreInit(ScrnInfoPtr pScrn, int flags); @@ -158,9 +157,7 @@ static SymTabRec GLINTChipsets[] = { { PCI_VENDOR_3DLABS_CHIP_300SX, "300sx" }, { PCI_VENDOR_3DLABS_CHIP_500TX, "500tx" }, { PCI_VENDOR_3DLABS_CHIP_MX, "mx" }, -/* { PCI_VENDOR_3DLABS_CHIP_DELTA, "delta" }, -*/ { -1, NULL } }; @@ -175,9 +172,7 @@ static PciChipsets GLINTPciChipsets[] = { { PCI_VENDOR_3DLABS_CHIP_300SX, PCI_VENDOR_3DLABS_CHIP_300SX, NULL }, { PCI_VENDOR_3DLABS_CHIP_500TX, PCI_VENDOR_3DLABS_CHIP_500TX, NULL }, { PCI_VENDOR_3DLABS_CHIP_MX, PCI_VENDOR_3DLABS_CHIP_MX, NULL }, -/* { PCI_VENDOR_3DLABS_CHIP_DELTA, PCI_VENDOR_3DLABS_CHIP_DELTA, NULL }, -*/ { -1, -1, RES_UNDEFINED } }; @@ -193,7 +188,7 @@ typedef enum { OPTION_FLATPANEL } GLINTOpts; -static OptionInfoRec GLINTOptions[] = { +static const OptionInfoRec GLINTOptions[] = { { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_RGB_BITS, "RGBbits", OPTV_INTEGER, {0}, FALSE }, { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, @@ -219,24 +214,6 @@ static RamDacSupportedInfoRec TIRamdacs[] = { { -1 } }; -static const char *vgahwSymbols[] = { - "vgaHWGetIndex", - "vgaHWSave", - "vgaHWRestore", - "vgaHWGetHWRec", - "vgaHWUnlock", - "vgaHWInit", - "vgaHWProtect", - "vgaHWSetMmioFuncs", - "vgaHWGetIOBase", - "vgaHWMapMem", - "vgaHWLock", - "vgaHWFreeHWRec", - "vgaHWSaveScreen", - "vgaHWddc1SetSpeed", - NULL -}; - static const char *xf8_32bppSymbols[] = { "xf86Overlay8Plus32Init", NULL @@ -252,6 +229,7 @@ static const char *xaaSymbols[] = { "XAAScreenIndex", "XAAPolyLines", "XAAPolySegment", + "XAAFillSolidRects", NULL }; @@ -289,6 +267,7 @@ static const char *shadowSymbols[] = { static const char *vbeSymbols[] = { "VBEInit", "vbeDoEDID", + "vbeFree", NULL }; @@ -387,7 +366,7 @@ glintSetup(pointer module, pointer opts, int *errmaj, int *errmin) if (!setupDone) { setupDone = TRUE; xf86AddDriver(&GLINT, module, 0); - LoaderRefSymLists(vgahwSymbols, fbSymbols, ddcSymbols, i2cSymbols, + LoaderRefSymLists(fbSymbols, ddcSymbols, i2cSymbols, xaaSymbols, xf8_32bppSymbols, shadowSymbols, fbdevHWSymbols, int10Symbols, vbeSymbols, @@ -493,6 +472,12 @@ 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_DELTA) && + (pGlint->MultiChip == PCI_CHIP_300SX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_500TX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_MX)) || ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && (pGlint->MultiChip == PCI_CHIP_MX)) ) { vtgpolarity = GLINT_READ_REG(VTGPolarity) & 0xFFFFFFF0; @@ -528,6 +513,12 @@ 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_DELTA) && + (pGlint->MultiChip == PCI_CHIP_300SX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_500TX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_MX)) || ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && (pGlint->MultiChip == PCI_CHIP_MX)) ) { GLINT_SLOW_WRITE_REG(vtgpolarity, VTGPolarity); @@ -574,7 +565,7 @@ GLINTIdentify(int flags) xf86PrintChipsets(GLINT_NAME, "driver for 3Dlabs chipsets", GLINTChipsets); } -static OptionInfoPtr +static const OptionInfoRec * GLINTAvailableOptions(int chipid, int busid) { return GLINTOptions; @@ -590,6 +581,7 @@ GLINTProbeDDC(ScrnInfoPtr pScrn, int index) { pVbe = VBEInit(NULL,index); vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); } } @@ -744,7 +736,8 @@ GLINTProbe(DriverPtr drv, int flags) } } else /* Only claim other chips when GAMMA is used */ - if (pPci->chipType == PCI_CHIP_GAMMA) { + if ((pPci->chipType == PCI_CHIP_GAMMA) || + (pPci->chipType == PCI_CHIP_DELTA)) { while (*checkusedPci != NULL) { int eIndex; /* make sure we claim all but our source device */ @@ -852,13 +845,19 @@ GetAccelPitchValues(ScrnInfoPtr pScrn) 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 + case PCI_VENDOR_3DLABS_CHIP_DELTA: + /* When GAMMA/DELTA in use, we always have MultiChip defined, even if + * only one chip is connected to GAMMA/DELTA as the entities > 1 */ switch (pGlint->MultiChip) { case PCI_CHIP_MX: + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: linep = &partprod500TX[0]; break; + case PCI_CHIP_PERMEDIA: + linep = &partprodPermedia[0]; + break; } break; } @@ -990,6 +989,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->PciInfo->func); } + pGlint->InFifoSpace = 0; /* Force a Read of FIFO space on first run */ pGlint->numMultiDevices = 0; pGlint->IOOffset = 0; /* Set IO Offset for Gamma */ @@ -1001,6 +1001,9 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pEnt = xf86GetEntityInfo(pScrn->entityList[i]); pPci = xf86GetPciInfoForEntity(pEnt->index); if ( (pPci->chipType == PCI_CHIP_MX) || + (pPci->chipType == PCI_CHIP_PERMEDIA) || + (pPci->chipType == PCI_CHIP_500TX) || + (pPci->chipType == PCI_CHIP_300SX) || (pPci->chipType == PCI_CHIP_PERMEDIA3) ) { pGlint->MultiChip = pPci->chipType; if (pGlint->numMultiDevices >= GLINT_MAX_MULTI_DEVICES) { @@ -1020,10 +1023,11 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]); pciVideoPtr pPci = xf86GetPciInfoForEntity(pEnt->index); - if ( (pPci->chipType == PCI_CHIP_GAMMA) && + if ( ((pPci->chipType == PCI_CHIP_GAMMA) || + (pPci->chipType == PCI_CHIP_DELTA)) && (pGlint->numMultiDevices == 0) ) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Gamma with ZERO connected chips, aborting\n"); + "Gamma/Delta with ZERO connected chips, aborting\n"); return FALSE; } } @@ -1032,7 +1036,8 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]); pciVideoPtr pPci = xf86GetPciInfoForEntity(pEnt->index); - if (!(pPci->chipType == PCI_CHIP_GAMMA)) { + if ((pPci->chipType != PCI_CHIP_GAMMA) && + (pPci->chipType != PCI_CHIP_DELTA)) { GLINTProbeDDC(pScrn, pGlint->pEnt->index); return TRUE; } else @@ -1135,33 +1140,36 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) xf86CollectOptions(pScrn, NULL); /* Process the options */ - xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, GLINTOptions); + if (!(pGlint->Options = xalloc(sizeof(GLINTOptions)))) + return FALSE; + memcpy(pGlint->Options, GLINTOptions, sizeof(GLINTOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pGlint->Options); /* Default to 8bits per RGB */ if (pScrn->depth == 30) pScrn->rgbBits = 10; else pScrn->rgbBits = 8; - if (xf86GetOptValInteger(GLINTOptions, OPTION_RGB_BITS, &pScrn->rgbBits)) { + if (xf86GetOptValInteger(pGlint->Options, OPTION_RGB_BITS, &pScrn->rgbBits)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Bits per RGB set to %d\n", pScrn->rgbBits); } from = X_DEFAULT; pGlint->HWCursor = TRUE; /* ON by default */ - if (xf86ReturnOptValBool(GLINTOptions, OPTION_SW_CURSOR, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_SW_CURSOR, FALSE)) { from = X_CONFIG; pGlint->HWCursor = FALSE; } xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", pGlint->HWCursor ? "HW" : "SW"); - if (xf86ReturnOptValBool(GLINTOptions, OPTION_FLATPANEL, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_FLATPANEL, FALSE)) { pGlint->UseFlatPanel = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Flat Panel Interface\n"); } - if (xf86ReturnOptValBool(GLINTOptions, OPTION_NOACCEL, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_NOACCEL, FALSE)) { pGlint->NoAccel = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); } - if (xf86ReturnOptValBool(GLINTOptions, OPTION_SHADOW_FB, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_SHADOW_FB, FALSE)) { pGlint->ShadowFB = TRUE; pGlint->NoAccel = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, @@ -1169,7 +1177,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } /* Check whether to use the FBDev stuff and fill in the rest of pScrn */ - if (xf86ReturnOptValBool(GLINTOptions, OPTION_FBDEV, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_FBDEV, FALSE)) { if (!FBDevProbed && !xf86LoadSubModule(pScrn, "fbdevhw")) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "couldn't load fbdevHW module!\n"); @@ -1206,7 +1214,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pScrn->overlayFlags = 0; from = X_DEFAULT; - if ((s = xf86GetOptValString(GLINTOptions, OPTION_OVERLAY))) { + if ((s = xf86GetOptValString(pGlint->Options, OPTION_OVERLAY))) { if (!*s || !xf86NameCmp(s, "8,24") || !xf86NameCmp(s, "24,8")) { Overlay = TRUE; } else { @@ -1222,7 +1230,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } } - pGlint->VGAcore = FALSE; pGlint->DoubleBuffer = FALSE; pGlint->RamDac = NULL; pGlint->STATE = FALSE; @@ -1283,19 +1290,17 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if ((pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2)) { - if (xf86ReturnOptValBool(GLINTOptions, OPTION_BLOCK_WRITE, FALSE)) { + if (xf86ReturnOptValBool(pGlint->Options, OPTION_BLOCK_WRITE, FALSE)) { pGlint->UseBlockWrite = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Block Writes enabled\n"); } } - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) { - if (xf86ReturnOptValBool(GLINTOptions, OPTION_FIREGL3000, FALSE)) { - /* Can't we detect a Fire GL 3000 ????? and remove this ? */ - pGlint->UseFireGL3000 = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + if (xf86ReturnOptValBool(pGlint->Options, OPTION_FIREGL3000, FALSE)) { + /* Can't we detect a Fire GL 3000 ????? and remove this ? */ + pGlint->UseFireGL3000 = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Diamond FireGL3000 mode enabled\n"); - } } if (!FBDevProbed) { @@ -1394,6 +1399,65 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) break; } break; + case PCI_VENDOR_3DLABS_CHIP_DELTA: + /* Delta has a bug, we need to fix it here */ + { + int basecopro = + pGlint->MultiPciInfo[0]->memBase[0] & 0xFFFFC000; + int basedelta = pGlint->PciInfo->memBase[0] & 0xFFFFC000; + int glintdelta = pGlint->PciTag; + int glintcopro = pciTag(pGlint->MultiPciInfo[0]->bus, + pGlint->MultiPciInfo[0]->device, + pGlint->MultiPciInfo[0]->func); + int temp, base3copro, offset; + + if( (basedelta & 0x20000) ^ (basecopro & 0x20000) ) { + if (pGlint->MultiChip == PCI_CHIP_PERMEDIA) { + offset = 0x20; /* base4 */ + } else { + offset = 0x1c; /* base3 */ + } + base3copro = pciReadLong(glintcopro, offset); + if( (basecopro & 0x20000) ^ (base3copro & 0x20000) ) { + /* + * oops, still different; we know that base3 + * is at least 16 MB, so we just take 128k + * offset into it. + */ + base3copro += 0x20000; + } + /* + * and now for the magic. + * read old value + * write fffffffff + * read value + * write new value + */ + temp = pciReadLong(glintdelta, 0x10); + pciWriteLong(glintdelta, 0x10, 0xffffffff); + temp = pciReadLong(glintdelta, 0x10); + pciWriteLong(glintdelta, 0x10, base3copro); + + /* + * additionally,sometimes we see the baserom which might + * confuse the chip, so let's make sure that is disabled + */ + temp = pciReadLong(glintcopro, 0x30); + pciWriteLong(glintcopro, 0x30, 0xffffffff); + temp = pciReadLong(glintcopro, 0x30); + pciWriteLong(glintcopro, 0x30, 0); + + /* + * now update our internal structure accordingly + */ + pGlint->IOAddress = + pGlint->PciInfo->memBase[0] = base3copro; + xf86DrvMsg(pScrn->scrnIndex, from, + "Delta Bug - Changing MMIO registers to 0x%lX\n", + (unsigned long)pGlint->IOAddress); + } + } + break; default: break; } @@ -1429,8 +1493,27 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); break; + case PCI_VENDOR_3DLABS_CHIP_DELTA: case PCI_VENDOR_3DLABS_CHIP_GAMMA: switch (pGlint->MultiChip) { + case PCI_CHIP_PERMEDIA: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached Rasterizer is GLINT Permedia\n"); + pScrn->videoRam = (((GLINT_READ_REG(PMMemConfig)>>29) & + 0x03) + 1) * 2048; + break; + case PCI_CHIP_300SX: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached Rasterizer is GLINT 300SX\n"); + pScrn->videoRam = (1 << ((GLINT_READ_REG(FBMemoryCtl) & + 0xE0000000)>>29)) * 1024; + break; + case PCI_CHIP_500TX: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached Rasterizer is GLINT 500TX\n"); + pScrn->videoRam = (1 << ((GLINT_READ_REG(FBMemoryCtl) & + 0xE0000000)>>29)) * 1024; + break; case PCI_CHIP_MX: xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Attached Rasterizer is GLINT MX\n"); @@ -1515,7 +1598,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) maxheight = 2048; maxwidth = 2048; pGlint->RefClock = 14318; - pGlint->VGAcore = TRUE; /* chip has a vga core */ pGlint->RamDacRec = RamDacCreateInfoRec(); pGlint->RamDacRec->ReadDAC = Permedia2InIndReg; pGlint->RamDacRec->WriteDAC = Permedia2OutIndReg; @@ -1533,7 +1615,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) maxheight = 2048; maxwidth = 2048; pGlint->RefClock = 14318; - pGlint->VGAcore = TRUE; /* chip has a vga core */ pGlint->RamDacRec = RamDacCreateInfoRec(); pGlint->RamDacRec->ReadDAC = Permedia2vInIndReg; pGlint->RamDacRec->WriteDAC = Permedia2vOutIndReg; @@ -1551,7 +1632,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) maxheight = 4096; maxwidth = 4096; pGlint->RefClock = 14318; - pGlint->VGAcore = TRUE; pGlint->RamDacRec = RamDacCreateInfoRec(); pGlint->RamDacRec->ReadDAC = Permedia2vInIndReg; pGlint->RamDacRec->WriteDAC = Permedia2vOutIndReg; @@ -1566,9 +1646,9 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) break; case PCI_VENDOR_TI_CHIP_PERMEDIA: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: + pGlint->FIFOSize = 31; maxheight = 1024; maxwidth = 1536; - pGlint->VGAcore = TRUE; /* chip has a vga core */ GLINTProbeIBMramdac(pScrn); if (pGlint->RamDac == NULL) return FALSE; if (pGlint->RamDac->RamDacType != (IBM526DB_RAMDAC) && @@ -1579,7 +1659,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) case PCI_VENDOR_3DLABS_CHIP_500TX: case PCI_VENDOR_3DLABS_CHIP_300SX: case PCI_VENDOR_3DLABS_CHIP_MX: - pGlint->FIFOSize = 16; + pGlint->FIFOSize = 15; if (pScrn->bitsPerPixel == 24) { xf86DrvMsg(pScrn->scrnIndex, from, "-depth 24 -pixmap24 not supported by this chip.\n"); @@ -1610,6 +1690,50 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) if (!pGlint->RamDac) return FALSE; break; + case PCI_VENDOR_3DLABS_CHIP_DELTA: + pGlint->FIFOSize = 15; + switch (pGlint->MultiChip) { + case PCI_CHIP_PERMEDIA: + maxheight = 1024; + maxwidth = 1536; + GLINTProbeIBMramdac(pScrn); + if (pGlint->RamDac == NULL) return FALSE; + if (pGlint->RamDac->RamDacType != (IBM526DB_RAMDAC) && + pGlint->RamDac->RamDacType != (IBM526_RAMDAC)) + return FALSE; + pGlint->RefClock = 14318; + break; + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: + case PCI_CHIP_MX: + if (pScrn->bitsPerPixel == 24) { + xf86DrvMsg(pScrn->scrnIndex, from, + "-depth 24 -pixmap24 not supported by this chip.\n"); + return FALSE; + } + maxheight = 4096; + maxwidth = 4096; + /* 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->RamDac->RamDacType == (IBM526DB_RAMDAC) || + pGlint->RamDac->RamDacType == (IBM526_RAMDAC)) + pGlint->RefClock = 40000; + } + } + break; + } + break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: pGlint->FIFOSize = 32; if (pScrn->bitsPerPixel == 24) { @@ -1704,30 +1828,18 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) 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 */ + /* Initialize the card through int10 interface if needed */ + if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_GAMMA && + pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_DELTA && + !xf86IsPrimaryPci(pGlint->PciInfo)) { if ( xf86LoadSubModule(pScrn, "int10")){ - xf86Int10InfoPtr pInt; - - xf86LoaderReqSymLists(int10Symbols, NULL); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); - pInt = xf86InitInt10(pGlint->pEnt->index); - xf86FreeInt10(pInt); - } + xf86Int10InfoPtr pInt; - /* The vgahw module should be loaded here when needed */ - if (!xf86LoadSubModule(pScrn, "vgahw")) - return FALSE; - - xf86LoaderReqSymLists(vgahwSymbols, NULL); - /* - * Allocate a vgaHWRec - */ - if (!vgaHWGetHWRec(pScrn)) - return FALSE; + xf86LoaderReqSymLists(int10Symbols, NULL); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); + pInt = xf86InitInt10(pGlint->pEnt->index); + xf86FreeInt10(pInt); + } } /* Set the min pixel clock */ @@ -1765,11 +1877,19 @@ 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_DELTA) && + (pGlint->MultiChip == PCI_CHIP_300SX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_500TX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_MX)) || ((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) ) { + (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_PERMEDIA)) ) { switch (pScrn->bitsPerPixel) { case 8: pGlint->MaxClock = 200000; @@ -1920,6 +2040,12 @@ 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_DELTA) && + (pGlint->MultiChip == PCI_CHIP_300SX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_500TX)) || + ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) && + (pGlint->MultiChip == PCI_CHIP_MX)) || ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) && (pGlint->MultiChip == PCI_CHIP_MX)) ) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, @@ -1937,6 +2063,20 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) } } + /* Check Virtual resolution */ + if (pScrn->virtualX > maxwidth) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "GLINTModeInit: virtual width (%d) too big for hardware\n", + pScrn->virtualX); + return FALSE; + } + if (pScrn->virtualY > maxheight) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "GLINTModeInit: virtual height (%d) too big for hardware\n", + pScrn->virtualY); + return FALSE; + } + switch (pGlint->Chipset) { /* Now we know displaywidth, so set linepitch data */ case PCI_VENDOR_TI_CHIP_PERMEDIA2: @@ -1954,11 +2094,18 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags) pGlint->bppalign = 0; break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { case PCI_CHIP_MX: + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: pGlint->pprod = partprod500TX[pScrn->displayWidth >> 5]; pGlint->bppalign = 0; break; + case PCI_CHIP_PERMEDIA: + pGlint->pprod = partprodPermedia[pScrn->displayWidth >> 5]; + pGlint->bppalign = bppand[(pScrn->bitsPerPixel>>3)-1]; + break; } break; } @@ -2166,12 +2313,6 @@ GLINTMapMem(ScrnInfoPtr pScrn) pGlint->IOBase = fbdevHWMapMMIO(pScrn); if (pGlint->IOBase == NULL) return FALSE; - /* - * This does not work on Alphas ! They need VGA MMIO space - * mapped in a special way as they cannot access it byte - * or wordwise. - */ - pGlint->IOBaseVGA = pGlint->IOBase + GLINT_VGA_MMIO_OFF; TRACE_EXIT("GLINTMapMem"); return TRUE; @@ -2183,8 +2324,6 @@ GLINTMapMem(ScrnInfoPtr pScrn) */ pGlint->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pGlint->PciTag, pGlint->IOAddress, 0x20000); - pGlint->IOBaseVGA = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, - pGlint->PciTag, pGlint->IOAddress + GLINT_VGA_MMIO_OFF, 0x2000); if (pGlint->IOBase == NULL) return FALSE; @@ -2231,10 +2370,6 @@ GLINTUnmapMem(ScrnInfoPtr pScrn) xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->IOBase, 0x20000); pGlint->IOBase = NULL; - if (pGlint->IOBaseVGA != NULL) - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->IOBaseVGA, 0x2000); - pGlint->IOBaseVGA = NULL; - if (pGlint->FbBase != NULL) xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase, pGlint->FbMapSize); pGlint->FbBase = NULL; @@ -2262,16 +2397,6 @@ GLINTSave(ScrnInfoPtr pScrn) RAMDACreg = &pRAMDAC->SavedReg; TRACE_ENTER("GLINTSave"); - if (pGlint->VGAcore) { - vgaRegPtr vgaReg; - vgaReg = &VGAHWPTR(pScrn)->SavedReg; - if (xf86IsPrimaryPci(pGlint->PciInfo)) { - vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_FONTS); - } else { - vgaHWSave(pScrn, vgaReg, VGA_SR_MODE); - } - } - switch (pGlint->Chipset) { case PCI_VENDOR_TI_CHIP_PERMEDIA2: @@ -2296,7 +2421,10 @@ GLINTSave(ScrnInfoPtr pScrn) (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: case PCI_CHIP_MX: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2() @@ -2309,6 +2437,10 @@ GLINTSave(ScrnInfoPtr pScrn) TXSave(pScrn, glintReg); (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); break; + case PCI_CHIP_PERMEDIA: + PermediaSave(pScrn, glintReg); + (*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_CHIP_PERMEDIA3: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); @@ -2340,15 +2472,6 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) GLINTRegPtr glintReg = &pGlint->ModeReg[0]; GLINTRegPtr glintReg2 = &pGlint->ModeReg[1]; - if (pGlint->VGAcore) { - vgaHWPtr hwp = VGAHWPTR(pScrn); - vgaHWUnlock(hwp); - - /* Initialise the ModeReg values */ - if (!vgaHWInit(pScrn, mode)) - return FALSE; - } - pScrn->vtSema = TRUE; switch (pGlint->Chipset) { @@ -2372,8 +2495,11 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) ret = TXInit(pScrn, mode, glintReg); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { case PCI_CHIP_MX: + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); ret = TXInit(pScrn, mode, glintReg2); @@ -2381,6 +2507,9 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) } ret = TXInit(pScrn, mode, glintReg); break; + case PCI_CHIP_PERMEDIA: + ret = PermediaInit(pScrn, mode); + break; case PCI_CHIP_PERMEDIA3: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); @@ -2396,14 +2525,6 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) if (!ret) return FALSE; - /* Program the registers */ - if (pGlint->VGAcore) { - vgaHWPtr hwp = VGAHWPTR(pScrn); - vgaRegPtr vgaReg = &hwp->ModeReg; - vgaHWProtect(pScrn, TRUE); - vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); - } - glintReg = &pGlint->ModeReg[0]; glintReg2 = &pGlint->ModeReg[1]; RAMDACreg = &pRAMDAC->ModeReg; @@ -2433,7 +2554,10 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: case PCI_CHIP_MX: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); @@ -2446,6 +2570,10 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) TXRestore(pScrn, glintReg); (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; + case PCI_CHIP_PERMEDIA: + PermediaRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_CHIP_PERMEDIA3: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); @@ -2458,10 +2586,6 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) break; } - if (pGlint->VGAcore) { - vgaHWProtect(pScrn, FALSE); - } - if (xf86IsPc98()) outb(0xfac, 0x01); @@ -2487,9 +2611,6 @@ GLINTRestore(ScrnInfoPtr pScrn) RAMDACreg = &pRAMDAC->SavedReg; TRACE_ENTER("GLINTRestore"); - if (pGlint->VGAcore) { - vgaHWProtect(pScrn, TRUE); - } switch (pGlint->Chipset) { case PCI_VENDOR_TI_CHIP_PERMEDIA2: @@ -2520,8 +2641,11 @@ GLINTRestore(ScrnInfoPtr pScrn) (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { case PCI_CHIP_MX: + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: if (pGlint->numMultiDevices == 2) { ACCESSCHIP2(); TXRestore(pScrn, glintReg2); @@ -2533,6 +2657,10 @@ GLINTRestore(ScrnInfoPtr pScrn) TXRestore(pScrn, glintReg); (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); break; + case PCI_CHIP_PERMEDIA: + PermediaRestore(pScrn, glintReg); + (*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg); + break; case PCI_CHIP_PERMEDIA3: #ifdef PM3Video TRACE("PM3Video : VideoLeaveVT"); @@ -2549,17 +2677,6 @@ GLINTRestore(ScrnInfoPtr pScrn) break; } - if (pGlint->VGAcore) { - vgaHWPtr hwp = VGAHWPTR(pScrn); - vgaRegPtr vgaReg = &hwp->SavedReg; - if (xf86IsPrimaryPci(pGlint->PciInfo)) { - vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_FONTS); - } else { - vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); - } - vgaHWProtect(pScrn, FALSE); - } - TRACE_EXIT("GLINTRestore"); } @@ -2582,20 +2699,6 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (!GLINTMapMem(pScrn)) return FALSE; - /* Initialize the MMIO vgahw functions */ - if (pGlint->VGAcore) { - vgaHWPtr hwp; - hwp = VGAHWPTR(pScrn); - if (xf86IsPrimaryPci(pGlint->PciInfo)) { - hwp->MapSize = 0x10000; /* Standard 64k VGA window */ - if (!vgaHWMapMem(pScrn)) - return FALSE; - } - - vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); - vgaHWGetIOBase(hwp); - } - if (pGlint->FBDev) { fbdevHWSave(pScrn); if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) { @@ -2742,8 +2845,10 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pGlint->BlockHandler = pScreen->BlockHandler; pScreen->BlockHandler = GLINTBlockHandler; +#if !defined(__sparc__) if (!pGlint->ShadowFB) GLINTDGAInit(pScreen); +#endif if (pScrn->bitsPerPixel > 8) { /* Fixup RGB ordering */ @@ -2780,10 +2885,18 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) TXAccelInit(pScreen); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: case PCI_CHIP_MX: TXAccelInit(pScreen); break; + case PCI_CHIP_300SX: + SXAccelInit(pScreen); + break; + case PCI_CHIP_PERMEDIA: + PermediaAccelInit(pScreen); + break; case PCI_CHIP_PERMEDIA3: Permedia3AccelInit(pScreen); break; @@ -2968,10 +3081,18 @@ GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) SXInitializeEngine(pScrn); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: case PCI_CHIP_MX: TXInitializeEngine(pScrn); break; + case PCI_CHIP_300SX: + SXInitializeEngine(pScrn); + break; + case PCI_CHIP_PERMEDIA: + PermediaInitializeEngine(pScrn); + break; case PCI_CHIP_PERMEDIA3: Permedia3InitializeEngine(pScrn); break; @@ -3028,9 +3149,15 @@ GLINTAdjustFrame(int scrnIndex, int x, int y, int flags) GLINT_SLOW_WRITE_REG(base, PMScreenBase); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) { + case PCI_VENDOR_3DLABS_CHIP_DELTA: + switch (pGlint->MultiChip) { + case PCI_CHIP_PERMEDIA3: base = (y * pScrn->displayWidth + x) >> pGlint->BppShift; GLINT_SLOW_WRITE_REG(base, PMScreenBase); + break; + case PCI_CHIP_PERMEDIA: + GLINT_SLOW_WRITE_REG(base, PMScreenBase); + break; } break; } @@ -3103,10 +3230,18 @@ GLINTEnterVT(int scrnIndex, int flags) SXInitializeEngine(pScrn); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: case PCI_CHIP_MX: TXInitializeEngine(pScrn); break; + case PCI_CHIP_300SX: + SXInitializeEngine(pScrn); + break; + case PCI_CHIP_PERMEDIA: + PermediaInitializeEngine(pScrn); + break; case PCI_CHIP_PERMEDIA3: Permedia3InitializeEngine(pScrn); break; @@ -3137,8 +3272,6 @@ GLINTLeaveVT(int scrnIndex, int flags) TRACE_ENTER("GLINTLeaveVT"); pGlint->STATE = TRUE; GLINTRestore(pScrn); - if (pGlint->VGAcore) - vgaHWLock(VGAHWPTR(pScrn)); if (xf86IsPc98()) outb(0xfac, 0x00); @@ -3193,8 +3326,6 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen) else { pGlint->STATE = TRUE; GLINTRestore(pScrn); - if (pGlint->VGAcore) - vgaHWLock(VGAHWPTR(pScrn)); } GLINTUnmapMem(pScrn); } @@ -3234,8 +3365,6 @@ GLINTFreeScreen(int scrnIndex, int flags) TRACE_ENTER("GLINTFreeScreen"); if (xf86LoaderCheckSymbol("fbdevHWFreeRec")) fbdevHWFreeRec(xf86Screens[scrnIndex]); - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); if (xf86LoaderCheckSymbol("RamDacFreeRec")) RamDacFreeRec(xf86Screens[scrnIndex]); GLINTFreeRec(xf86Screens[scrnIndex]); @@ -3333,11 +3462,15 @@ GLINTSaveScreen(ScreenPtr pScreen, int mode) 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); + case PCI_VENDOR_3DLABS_CHIP_DELTA: + switch (pGlint->MultiChip) { + case PCI_CHIP_PERMEDIA3: + case PCI_CHIP_PERMEDIA: + temp = GLINT_READ_REG(PMVideoControl); + if (unblank) temp |= 1; + else temp &= 0xFFFFFFFE; + GLINT_SLOW_WRITE_REG(temp, PMVideoControl); + break; } break; } @@ -3433,22 +3566,74 @@ void GLINT_MoveDWORDS( #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--; - } + if ((unsigned long)src & 0x3UL) { + unsigned char *pchar; + while (dwords & ~0x03) { + pchar = (unsigned char *)(src + 0); + *(dest + 0) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + pchar = (unsigned char *)(src + 1); + *(dest + 1) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + pchar = (unsigned char *)(src + 2); + *(dest + 2) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + pchar = (unsigned char *)(src + 3); + *(dest + 3) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + src += 4; + dest += 4; + dwords -= 4; + } + if (!dwords) + return; + pchar = (unsigned char *)(src + 0); + *(dest + 0) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + if (dwords == 1) + return; + pchar = (unsigned char *)(src + 1); + *(dest + 1) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + if (dwords == 2) + return; + pchar = (unsigned char *)(src + 2); + *(dest + 2) = (((CARD32)pchar[0] << 24) | + ((CARD32)pchar[1] << 16) | + ((CARD32)pchar[2] << 8) | + ((CARD32)pchar[3] << 0)); + } else { + 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); + } } int @@ -3478,7 +3663,10 @@ Shiftbpp(ScrnInfoPtr pScrn, int value) logbytesperaccess = 3; break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: + case PCI_VENDOR_3DLABS_CHIP_DELTA: switch (pGlint->MultiChip) { + case PCI_CHIP_500TX: + case PCI_CHIP_300SX: case PCI_CHIP_MX: if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) || (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ) @@ -3486,6 +3674,9 @@ Shiftbpp(ScrnInfoPtr pScrn, int value) else logbytesperaccess = 3; break; + case PCI_CHIP_PERMEDIA: + logbytesperaccess = 2; + break; case PCI_CHIP_PERMEDIA3: logbytesperaccess = 4; break; 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 a684b81b6..4690035ea 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.26 2001/04/19 09:28:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.26.2.1 2001/05/24 20:12:47 alanh Exp $ */ /* * glint register file @@ -1202,7 +1202,16 @@ #define GLINT_WAIT(n) \ do{ \ - while(GLINT_READ_REG(InFIFOSpace)<(n)); \ + if (pGlint->InFifoSpace>=(n)) \ + pGlint->InFifoSpace -= (n); \ + else { \ + int tmp; \ + while((tmp=GLINT_READ_REG(InFIFOSpace))<(n)); \ + /* Clamp value due to bugs in PM3 */ \ + if (tmp > pGlint->FIFOSize) \ + tmp = pGlint->FIFOSize; \ + pGlint->InFifoSpace = tmp - (n); \ + } \ }while(0) #define GLINTDACDelay(x) do { \ @@ -1217,7 +1226,7 @@ do{ \ #define GLINT_SLOW_WRITE_REG(v,r) \ do{ \ mem_barrier(); \ - GLINT_WAIT(1); \ + GLINT_WAIT(pGlint->FIFOSize); \ mem_barrier(); \ GLINT_WRITE_REG(v,r); \ }while(0) 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 532c56178..67c7c2b18 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c @@ -30,7 +30,7 @@ * * Permedia 2 accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.29 2001/02/27 23:04:59 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.29.2.1 2001/05/30 11:42:22 alanh Exp $ */ #include "Xarch.h" #include "xf86.h" @@ -336,12 +336,14 @@ Permedia2AccelInit(ScreenPtr pScreen) infoPtr->WriteBitmap = Permedia2WriteBitmap; - if (pScrn->bitsPerPixel == 8) + if (pScrn->bitsPerPixel == 8) { infoPtr->WritePixmap = Permedia2WritePixmap8bpp; - else - if (pScrn->bitsPerPixel == 16) + infoPtr->WritePixmapFlags = NO_GXCOPY; + } else + if (pScrn->bitsPerPixel == 16) { infoPtr->WritePixmap = Permedia2WritePixmap16bpp; - else + infoPtr->WritePixmapFlags = NO_GXCOPY; + } else if (pScrn->bitsPerPixel == 32) infoPtr->WritePixmap = Permedia2WritePixmap32bpp; 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 29b0a7715..9e330e190 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c @@ -26,7 +26,7 @@ * this work is sponsored by Appian Graphics. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.22 2001/03/20 19:08:58 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.24 2001/05/16 07:56:07 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -331,6 +331,7 @@ Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode, GLINTRegPtr pReg) STOREDAC(PM2VDACRDColorFormat, 0x2E); break; case 16: + temp3 |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE; STOREDAC(PM2VDACRDPixelSize, 0x01); if (pScrn->depth == 15) { STOREDAC(PM2VDACRDColorFormat, 0x61); @@ -339,10 +340,12 @@ Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode, GLINTRegPtr pReg) } break; case 24: + temp3 |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE; STOREDAC(PM2VDACRDPixelSize, 0x04); STOREDAC(PM2VDACRDColorFormat, 0x60); break; case 32: + temp3 |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE; if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { temp3 |= 0x18; STOREDAC(PM2VDACRDOverlayKey, pScrn->colorKey); @@ -366,8 +369,8 @@ Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr pReg) /* 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); + * so we memcpy the information using the slow routines */ + xf86SlowBcopy((CARD8*)pGlint->FbBase, (CARD8*)pGlint->VGAdata, 65536); if ((pGlint->numMultiDevices == 2) || (IS_J2000)) { SAVEREG(GCSRAperture); @@ -435,9 +438,9 @@ Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr pReg) /* 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 */ + * so we memcpy the information using the slow routines */ if (pGlint->STATE) - memcpy((CARD8*)pGlint->FbBase,(CARD8*)pGlint->VGAdata, 65536); + xf86SlowBcopy((CARD8*)pGlint->VGAdata, (CARD8*)pGlint->FbBase, 65536); if ((pGlint->numMultiDevices == 2) || (IS_J2000)) { RESTOREREG(GCSRAperture); 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 a09ca3508..d707bee94 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.6 2001/04/18 09:24:48 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h,v 1.7 2001/05/08 19:31:22 alanh Exp $ */ /* * glint register file @@ -400,8 +400,8 @@ #define PM3RD_VideoOverlayBlend 0x02c #define PM3RD_VideoOverlayBlend_FACTOR_0_PERCENT (0<<6) #define PM3RD_VideoOverlayBlend_FACTOR_25_PERCENT (1<<6) - #define PM3RD_VideoOverlayBlend_FACTOR_59_PERCENT (2<<6) - #define PM3RD_VideoOverlayBlend_FACTOR_75_PERCENT (3<<6) + #define PM3RD_VideoOverlayBlend_FACTOR_75_PERCENT (2<<6) + #define PM3RD_VideoOverlayBlend_FACTOR_100_PERCENT (3<<6) #define PM3RD_DClkSetup1 0x1f0 #define PM3RD_DClkSetup2 0x1f1 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c index 78c0fcad6..589eb8d5c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c @@ -23,7 +23,7 @@ * Based on work of Michael H. Schimek <m.schimek@netway.at> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c,v 1.3 2001/04/18 09:24:49 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_video.c,v 1.6 2001/05/08 19:31:22 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -34,12 +34,18 @@ #include "xf86fbman.h" #include "xf86xv.h" #include "Xv.h" +#include "regionstr.h" +#include "xaa.h" +#include "xaalocal.h" #include "glint_regs.h" #include "pm3_regs.h" #include "glint.h" #define DEBUG(x) +#define USE_HARDWARE_COPY 1 +#define SUPPORT_CLIPPING 1 +#define BLACKNESS_WORKAROUND 1 #ifndef XvExtension @@ -60,8 +66,6 @@ void Permedia3VideoLeaveVT(ScrnInfoPtr pScrn) {} #define CLAMP(v, min, max) (((v) < (min)) ? (min) : MIN(v, max)) #define ENTRIES(array) (sizeof(array) / sizeof((array)[0])) -#define MAX_BUFFERS 3 - enum { OVERLAY_DATA_NONE, OVERLAY_DATA_COLORKEY, @@ -69,22 +73,39 @@ enum { OVERLAY_DATA_ALPHABLEND } ; +#define MAX_BUFFERS 3 + typedef struct _PortPrivRec { struct _AdaptorPrivRec * pAdaptor; + /* Sync function */ + void (*Sync) (ScrnInfoPtr pScrn); + /* Attributes */ - char OverlayData; + INT32 ColorKey; + INT32 OverlayAlpha; INT32 OverlayMode; - INT32 OverlayControl; INT32 Attribute[3]; + /* Clipping */ + RegionRec clip; + +#if 0 /* Adding this cause the server to crash if we minimize the video */ + /* Frame counter */ + char Frames; +#endif + + /* Ramdac save values, ... */ + INT32 ramdac_x, ramdac_w; + INT32 ramdac_y, ramdac_h; + Bool ramdac_on; + /* Buffers */ - int Id, Bpp; - int Format, Bpp_shift; + int Id, Format; + int FB_Shift, Video_Shift; short display, copy; - FBLinearPtr Buffer[MAX_BUFFERS]; - CARD32 BufferStride; /* bytes */ - int OverlayStride; /* pixels */ + FBAreaPtr Buffer[MAX_BUFFERS]; + CARD32 BufferBase[MAX_BUFFERS]; /* Buffer and Drawable size and position */ INT32 vx, vy, vw, vh; /* 12.10 fp */ @@ -103,8 +124,7 @@ typedef struct _AdaptorPrivRec { PortPrivPtr pPort; } AdaptorPrivRec, *AdaptorPrivPtr; -static AdaptorPrivPtr AdaptorPriv; - +static AdaptorPrivPtr AdaptorPrivList = NULL; /* * Proprietary Attributes @@ -114,42 +134,35 @@ static AdaptorPrivPtr AdaptorPriv; /* We support 3 sorts of filters : * 0 : None. * 1 : Partial (only in the X directrion). - * 2 : Full. + * 2 : Full (incompatible with X mirroring). */ #define XV_MIRROR "XV_MIRROR" /* We also support mirroring of the image : - * bit 0 : if set, will mirror in the X direction. + * bit 0 : if set, will mirror in the X direction + * (incompatible with full filtering). * bit 1 : if set, will mirror in the Y direction. */ -#define XV_OVERLAY_MODE "XV_OVERLAY_MODE" -/* We support these different overlay modes (bit 0-2) : - * 0 : Opaque video overlay (default). - * 1 : Color keyed overlay, framebuffer color key. - * Data : bit 3-27 : color key in RGB 888 format. - * 2 : Color keyed overlay, framebuffer alpha key. - * Data : bit 3-11 : 8 bit alpha key. - * 3 : Color keyed overlay, overlay color key. - * Data : bit 3-27 : color key in RGB 888 format. - * 4 : Per pixel alpha blending. - * 5 : Constant alpha blending. - * Data : bit 3-11 : 8 bit alpha blend factor. - * 6-7 : Reserved. +#define XV_ALPHA "XV_ALPHA" +/* We support the following alpha blend factors : + * 0 -> 0% Video, 100% Framebuffer + * 1 -> 25% Video, 75% Framebuffer + * 2 -> 75% Video, 25% Framebuffer + * 3 -> 100% Video, 0% Framebuffer */ - static XF86AttributeRec ScalerAttributes[] = { { XvSettable | XvGettable, 0, 2, XV_FILTER }, { XvSettable | XvGettable, 0, 3, XV_MIRROR }, - { XvSettable | XvGettable, 0, (2<<27)-1, XV_OVERLAY_MODE }, + { XvSettable | XvGettable, 0, 3, XV_ALPHA }, }; #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) -static Atom xvFilter, xvMirror, xvOverlayMode; +static Atom xvFilter, xvMirror, xvAlpha; /* Scaler */ @@ -261,7 +274,7 @@ ScalerImages[] = */ static void -RemoveAreaCallback(FBLinearPtr Buffer) +RemoveBufferCallback(FBAreaPtr Buffer) { PortPrivPtr pPPriv = (PortPrivPtr) Buffer->devPrivate.ptr; int i = -1; @@ -287,9 +300,11 @@ FreeBuffers(PortPrivPtr pPPriv, Bool from_timer) } } + pPPriv->display = -1; + pPPriv->copy = -1; for (i=0; i < MAX_BUFFERS; i++) if (pPPriv->Buffer[i]) { - xf86FreeOffscreenLinear (pPPriv->Buffer[i]); + xf86FreeOffscreenArea (pPPriv->Buffer[i]); pPPriv->Buffer[i] = NULL; } } @@ -313,13 +328,14 @@ TimerCallback(OsTimerPtr pTim, CARD32 now, pointer p) } static int -AllocateBuffers(PortPrivPtr pPPriv, - int w_bpp, int h) +AllocateBuffers(PortPrivPtr pPPriv, int w_bpp, int h) { AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; ScrnInfoPtr pScrn = pAPriv->pScrn; int i = -1; + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "We try to allocate a %dx%d buffer.\n", w_bpp, h)); /* we start a timer to free the buffers if they are nto used within * 5 seconds (pPPriv->Delay * pPPriv->Instant) */ pPPriv->StopDelay = pPPriv->Delay; @@ -328,73 +344,194 @@ AllocateBuffers(PortPrivPtr pPPriv, TimerSet(pPPriv->Timer, 0, 80, TimerCallback, pAPriv); } - for (i=0; i < MAX_BUFFERS && (i == pPPriv->display || i == pPPriv->copy); i++); + for (i=0; i < MAX_BUFFERS + && (i == pPPriv->display || i == pPPriv->copy); i++); if (pPPriv->Buffer[i]) { - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Buffer %d exists.\n", i)); - if (pPPriv->Buffer[i]->size == w_bpp * h) { - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + if ((pPPriv->Buffer[i]->box.x2 - pPPriv->Buffer[i]->box.x1) == w_bpp && + (pPPriv->Buffer[i]->box.y2 - pPPriv->Buffer[i]->box.y1) == h) { + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Buffer %d is of the good size, let's use it.\n", i)); return (pPPriv->copy = i); } - else if (xf86ResizeOffscreenLinear (pPPriv->Buffer[i], w_bpp * h)) { - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + else if (xf86ResizeOffscreenArea (pPPriv->Buffer[i], w_bpp, h)) { + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "I was able to resize buffer %d, let's use it.\n", i)); + pPPriv->BufferBase[i] = + ((pPPriv->Buffer[i]->box.y1 * pScrn->displayWidth) + + pPPriv->Buffer[i]->box.x1)<<pPPriv->FB_Shift; return (pPPriv->copy = i); } else { - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "I was not able to resize buffer %d.\n", i)); - xf86FreeOffscreenLinear (pPPriv->Buffer[i]); + xf86FreeOffscreenArea (pPPriv->Buffer[i]); pPPriv->Buffer[i] = NULL; } } - if ((pPPriv->Buffer[i] = xf86AllocateOffscreenLinear (pScrn->pScreen, - w_bpp * h, 0, NULL, NULL, (pointer) pPPriv))) { - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + if ((pPPriv->Buffer[i] = xf86AllocateOffscreenArea (pScrn->pScreen, + w_bpp, h, 4 >> pPPriv->FB_Shift, NULL, NULL, (pointer) pPPriv))) { + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Sucessfully allocated buffer %d, let's use it.\n", i)); + pPPriv->BufferBase[i] = + ((pPPriv->Buffer[i]->box.y1 * pScrn->displayWidth) + + pPPriv->Buffer[i]->box.x1)<<pPPriv->FB_Shift; return (pPPriv->copy = i); } - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Unable to allocate a buffer.\n")); return -1; } -#define GET_OFFSET(pScrn, offset) \ - (offset + (pScrn->virtualY*pScrn->displayWidth*pScrn->bitsPerPixel/8)) - /* * Xv interface */ +#if USE_HARDWARE_COPY static void -CopyYV12LE(CARD8 *Y, CARD32 *dst, int width, int height, int pitch) +HWCopySetup(PortPrivPtr pPPriv, int x, int y, int w, int h) { - int Y_size = width * height; + AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; + ScrnInfoPtr pScrn = pAPriv->pScrn; + GLINTPtr pGlint = GLINTPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "x = %d, y = %d, w = %d, h = %d.\n", x, y, w, h)); + + GLINT_WAIT(4); + GLINT_WRITE_REG(0xffffffff, FBHardwareWriteMask); + GLINT_WRITE_REG( + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(GXcopy) | + PM3Config2D_FBWriteEnable, + PM3Config2D); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG( + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_SyncOnHostData | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); +} +static void +HWCopyYV12(PortPrivPtr pPPriv, CARD8 *Y, int w, int h) +{ + AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; + ScrnInfoPtr pScrn = pAPriv->pScrn; + GLINTPtr pGlint = GLINTPTR(pScrn); + int Y_size = w * h; CARD8 *V = Y + Y_size; CARD8 *U = V + (Y_size >> 2); - int pad = (pitch >> 2) - (width >> 1); - int x; - - width >>= 1; - - for (height >>= 1; height > 0; height--) { - for (x = 0; x < width; Y += 2, x++) - *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24); - dst += pad; - for (x = 0; x < width; Y += 2, x++) - *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24); - dst += pad; - U += width; - V += width; + CARD32 *dst; + int dwords, i, x; + + dwords = Y_size >> 1; + + x = 0; + while (dwords >= pGlint->FIFOSize) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(pGlint->FIFOSize); + /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = pGlint->FIFOSize - 1; i; i--, Y += 2, U++, V++, dst++, x++) { + /* mmm, i don't know if this is really needed, as we perform + * endianess inversion as usual, let's check it before removing */ +#if X_BYTE_ORDER == X_BIG_ENDIAN + *dst = V[0] + (Y[1] << 8) + (U[0] << 16) + (Y[0] << 24); +#else + *dst = Y[0] + (U[0] << 8) + (Y[1] << 16) + (V[0] << 24); +#endif + if (x == w>>1) { U -= w>>1; V -= w>>1; } + if (x == w) x = 0; + } + dwords -= pGlint->FIFOSize - 1; } -} - + if (dwords) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(dwords + 1); + /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ + GLINT_WRITE_REG(((dwords - 1) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = dwords; i; i--, Y += 2, U++, V++, dst++, x++) { + /* mmm, i don't know if this is really needed, as we perform + * endianess inversion as usual, let's check it before removing */ #if X_BYTE_ORDER == X_BIG_ENDIAN + *dst = V[0] + (Y[1] << 8) + (U[0] << 16) + (Y[0] << 24); +#else + *dst = Y[0] + (U[0] << 8) + (Y[1] << 16) + (V[0] << 24); +#endif + if (x == w>>1) { U -= w>>1; V -= w>>1; } + if (x == w) x = 0; + } + } +} +static void +HWCopyFlat(PortPrivPtr pPPriv, CARD8 *src, int w, int h) +{ + AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; + ScrnInfoPtr pScrn = pAPriv->pScrn; + GLINTPtr pGlint = GLINTPTR(pScrn); + int size = w * h; + int pitch = pScrn->displayWidth<<pPPriv->FB_Shift; + CARD32 *dst; + CARD8 *tmp_src; + int dwords, i; + if (w == pitch) { + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "HWCopyFlat : src = %08x, w = pitch = %d, h = %d.\n", + src, w, h)); + dwords = size >> pPPriv->Video_Shift; + while (dwords >= pGlint->FIFOSize) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(pGlint->FIFOSize); + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = pGlint->FIFOSize - 1; i; i--, dst++, src++) *dst = *src; + dwords -= pGlint->FIFOSize - 1; + } + if (dwords) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(dwords + 1); + GLINT_WRITE_REG(((dwords - 1) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = dwords; i; i--, dst++, src++) *dst = *src; + } + } else { + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "HWCopyFlat : src = %08x, w = %d, pitch = %d, h = %d.\n", + src, w, pitch, h)); + while (h) { + tmp_src = src; + dwords = w >> pPPriv->Video_Shift; + while (dwords >= pGlint->FIFOSize) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(pGlint->FIFOSize); + GLINT_WRITE_REG(((pGlint->FIFOSize - 2) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = pGlint->FIFOSize - 1; i; i--, dst++, src++) *dst = *src; + dwords -= pGlint->FIFOSize - 1; + } + if (dwords) { + dst = (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4); + GLINT_WAIT(dwords + 1); + GLINT_WRITE_REG(((dwords - 1) << 16) | (0x15 << 4) | + 0x05, OutputFIFO); + for (i = dwords; i; i--, dst++, src++) *dst = *src; + } + src = tmp_src + pitch; + } + } +} +#else static void -CopyYV12BE(CARD8 *Y, CARD32 *dst, int width, int height, int pitch) +CopyYV12(CARD8 *Y, CARD32 *dst, int width, int height, int pitch) { int Y_size = width * height; CARD8 *V = Y + Y_size; @@ -406,18 +543,24 @@ CopyYV12BE(CARD8 *Y, CARD32 *dst, int width, int height, int pitch) for (height >>= 1; height > 0; height--) { for (x = 0; x < width; Y += 2, x++) +#if X_BYTE_ORDER == X_BIG_ENDIAN *dst++ = V[x] + (Y[1] << 8) + (U[x] << 16) + (Y[0] << 24); +#else + *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24); +#endif dst += pad; for (x = 0; x < width; Y += 2, x++) +#if X_BYTE_ORDER == X_BIG_ENDIAN *dst++ = V[x] + (Y[1] << 8) + (U[x] << 16) + (Y[0] << 24); +#else + *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24); +#endif dst += pad; U += width; V += width; } } -#endif /* X_BYTE_ORDER == X_BIG_ENDIAN */ - static void CopyFlat(CARD8 *src, CARD8 *dst, int width, int height, int pitch) { @@ -433,6 +576,7 @@ CopyFlat(CARD8 *src, CARD8 *dst, int width, int height, int pitch) height--; } } +#endif #define FORMAT_RGB8888 PM3VideoOverlayMode_COLORFORMAT_RGB8888 #define FORMAT_RGB4444 PM3VideoOverlayMode_COLORFORMAT_RGB4444 @@ -463,6 +607,9 @@ do{ \ mem_barrier(); \ }while(0) +#define RAMDAC_WRITE_OLD(data,index) \ + Permedia2vOutIndReg(pScrn, index, 0x00, data) + /* Notice, have to check that we dont overflow the deltas here ... */ static void compute_scale_factor( @@ -487,33 +634,8 @@ compute_scale_factor( } } -/* Some thougth about clipping : - * - * To support clipping, we will need to : - * - We need to convert the clipregion to a bounding box - * and a bitmap that is the mask associated with the clipregion. - * - Load this bitmap to offscreen memory. - * - Copy/expand this bitmap to the needed area, masking only the alpha - * channel of the framebuffer. - * - Use either the alpha blended or framebuffer alpha keyed overlay mode to - * mask the clipped away region. - * - If the clip region gets changed, we have to upload a new clip mask, - * clear the old alpha mask in the framebuffer and copy the new clip mask - * to the framebuffer again. - * - If the position of the region get's changed (but not the clip mask) we - * need to clear the old frambuffer clip mask in the alpha channel and - * upload the new one. - * - * All this will only work if : - * - * 1) we are using an framebuffer format with an alpha channel, that is - * RGBA 8888 (depth 24) and RGBA 5551 (depth 15). - * 2) nobody else uses the alpha channel. - * - */ - static void -BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) +BeginOverlay(PortPrivPtr pPPriv, int display) { AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; ScrnInfoPtr pScrn = pAPriv->pScrn; @@ -523,10 +645,13 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) unsigned int src_w = pPPriv->vw, dst_w = pPPriv->dw; unsigned int src_h = pPPriv->vh, dst_h = pPPriv->dh; unsigned int shrink_delta, zoom_delta; +#if BLACKNESS_WORKAROUND + static int Frames = 50; +#endif + unsigned int stride = + (pScrn->displayWidth << pPPriv->FB_Shift) >> pPPriv->Video_Shift; - /* Let's overlay only to visible parts of the screen - * Note : this has no place here, and will not work if - * clipping is not supported, since Xv will not show this. */ + /* Let's overlay only to visible parts of the screen */ if (pPPriv->dx < pScrn->frameX0) { dst_w = dst_w - pScrn->frameX0 + dst_x; dst_x = 0; @@ -554,7 +679,13 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) * the Permedia3 overlay unit requirement, and compute the X deltas. */ compute_scale_factor(&src_w, &dst_w, &shrink_delta, &zoom_delta); - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "BeginOverlay\n")); +#if BLACKNESS_WORKAROUND + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "BeginOverlay %d (buffer %d)\n", Frames, display)); +#else + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "BeginOverlay (buffer %d)\n", display)); +#endif if (src_w != pPPriv->vw) DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "BeginOverlay : Padding video width to 4 pixels %d->%d.\n", @@ -562,17 +693,45 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) if (dst_w != pPPriv->dw) DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "BeginOverlay : Scaling destination width from %d to %d.\n" - "\tThe scaling factor is to high, and may cause problems.", + "\tThe scaling factor is to high, and may cause problems.\n", pPPriv->dw, dst_w)); if (display != -1) pPPriv->display = display; - GLINT_WAIT(12); + +#if BLACKNESS_WORKAROUND + if (++Frames>25) { + Frames = 0; + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Registers (1) : %08x, %08x, %08x, %08x, %08x.\n", + GLINT_READ_REG(PM3VideoOverlayFifoControl), + GLINT_READ_REG(PM3VideoOverlayMode), + GLINT_READ_REG(PM3VideoOverlayBase0), + GLINT_READ_REG(PM3VideoOverlayBase1), + GLINT_READ_REG(PM3VideoOverlayBase2))); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Registers (2) : %08x, %08x, %08x, %08x.\n", + GLINT_READ_REG(PM3VideoOverlayStride), + GLINT_READ_REG(PM3VideoOverlayWidth), + GLINT_READ_REG(PM3VideoOverlayHeight), + GLINT_READ_REG(PM3VideoOverlayOrigin))); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Registers (3) : %08x, %08x, %08x, %08x.\n", + GLINT_READ_REG(PM3VideoOverlayYDelta), + GLINT_READ_REG(PM3VideoOverlayShrinkXDelta), + GLINT_READ_REG(PM3VideoOverlayZoomXDelta), + GLINT_READ_REG(PM3VideoOverlayIndex))); + GLINT_WAIT(8); + GLINT_WRITE_REG(PM3VideoOverlayMode_DISABLE, + PM3VideoOverlayMode); + } else GLINT_WAIT(7); +#else + GLINT_WAIT(7); +#endif GLINT_WRITE_REG(3|(12<<16), PM3VideoOverlayFifoControl); /* Updating the Video Overlay Source Image Parameters */ GLINT_WRITE_REG( - GET_OFFSET(pScrn, pPPriv->Buffer[pPPriv->display]->offset)>>bpp_shift, + pPPriv->BufferBase[pPPriv->display]>>pPPriv->Video_Shift, PM3VideoOverlayBase+(pPPriv->display*8)); - GLINT_WRITE_REG(pPPriv->display, PM3VideoOverlayIndex); GLINT_WRITE_REG(pPPriv->Format | PM3VideoOverlayMode_BUFFERSYNC_MANUAL | PM3VideoOverlayMode_FLIP_VIDEO | @@ -581,7 +740,7 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) PM3VideoOverlayMode_ENABLE, PM3VideoOverlayMode); /* Let's set the source stride. */ - GLINT_WRITE_REG(PM3VideoOverlayStride_STRIDE(pPPriv->OverlayStride), + GLINT_WRITE_REG(PM3VideoOverlayStride_STRIDE(stride), PM3VideoOverlayStride); /* Let's set the position and size of the visible part of the source. */ GLINT_WRITE_REG(PM3VideoOverlayWidth_WIDTH(src_w), @@ -592,6 +751,8 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) PM3VideoOverlayOrigin_XORIGIN(src_x) | PM3VideoOverlayOrigin_YORIGIN(src_y), PM3VideoOverlayOrigin); + + GLINT_WAIT(5); /* Scale the source to the destinationsize */ if (src_h == dst_h) { GLINT_WRITE_REG( @@ -604,50 +765,150 @@ BeginOverlay(PortPrivPtr pPPriv, int display, int bpp_shift, BoxPtr extent) } GLINT_WRITE_REG(shrink_delta, PM3VideoOverlayShrinkXDelta); GLINT_WRITE_REG(zoom_delta, PM3VideoOverlayZoomXDelta); - /* Launch the true update at the next FrameBlank */ + GLINT_WRITE_REG(pPPriv->display, PM3VideoOverlayIndex); GLINT_WRITE_REG(PM3VideoOverlayUpdate_ENABLE, PM3VideoOverlayUpdate); - /* Setting the ramdac video overlay rgion */ - /* Begining of overlay region */ - RAMDAC_WRITE((dst_x&0xff), PM3RD_VideoOverlayXStartLow); - RAMDAC_WRITE((dst_x&0xf00)>>8, PM3RD_VideoOverlayXStartHigh); - RAMDAC_WRITE((dst_y&0xff), PM3RD_VideoOverlayYStartLow); - RAMDAC_WRITE((dst_y&0xf00)>>8, PM3RD_VideoOverlayYStartHigh); - /* End of overlay regions (+1) */ - RAMDAC_WRITE(((dst_x+dst_w)&0xff), PM3RD_VideoOverlayXEndLow); - RAMDAC_WRITE(((dst_x+dst_w)&0xf00)>>8,PM3RD_VideoOverlayXEndHigh); - RAMDAC_WRITE(((dst_y+dst_h)&0xff), PM3RD_VideoOverlayYEndLow); - RAMDAC_WRITE(((dst_y+dst_h)&0xf00)>>8,PM3RD_VideoOverlayYEndHigh); + + + /* Now set the ramdac video overlay region and mode */ + if ((pPPriv->ramdac_x != dst_x) || (pPPriv->ramdac_w != dst_w)) { + RAMDAC_WRITE((dst_x&0xff), PM3RD_VideoOverlayXStartLow); + RAMDAC_WRITE((dst_x&0xf00)>>8, PM3RD_VideoOverlayXStartHigh); + RAMDAC_WRITE(((dst_x+dst_w)&0xff), PM3RD_VideoOverlayXEndLow); + RAMDAC_WRITE(((dst_x+dst_w)&0xf00)>>8,PM3RD_VideoOverlayXEndHigh); + pPPriv->ramdac_x = dst_x; + pPPriv->ramdac_w = dst_w; + } + if ((pPPriv->ramdac_y != dst_y) || (pPPriv->ramdac_h != dst_h)) { + RAMDAC_WRITE((dst_y&0xff), PM3RD_VideoOverlayYStartLow); + RAMDAC_WRITE((dst_y&0xf00)>>8, PM3RD_VideoOverlayYStartHigh); + RAMDAC_WRITE(((dst_y+dst_h)&0xff), PM3RD_VideoOverlayYEndLow); + RAMDAC_WRITE(((dst_y+dst_h)&0xf00)>>8,PM3RD_VideoOverlayYEndHigh); + pPPriv->ramdac_y = dst_y; + pPPriv->ramdac_h = dst_h; + } - switch (pPPriv->OverlayData) { - case OVERLAY_DATA_COLORKEY : - RAMDAC_WRITE(((pPPriv->OverlayControl>>8)&0xff), - PM3RD_VideoOverlayKeyR); - RAMDAC_WRITE(((pPPriv->OverlayControl>>16)&0xff), - PM3RD_VideoOverlayKeyG); - RAMDAC_WRITE(((pPPriv->OverlayControl>>24)&0xff), - PM3RD_VideoOverlayKeyB); - break; - case OVERLAY_DATA_ALPHAKEY : - RAMDAC_WRITE(((pPPriv->OverlayControl>>8)&0xff), - PM3RD_VideoOverlayKeyR); - break; - case OVERLAY_DATA_ALPHABLEND : - RAMDAC_WRITE(((pPPriv->OverlayControl>>8)&0xff), - PM3RD_VideoOverlayBlend); - break; + if (!pPPriv->ramdac_on) { + if (pPPriv->OverlayAlpha<(3<<6)) { + RAMDAC_WRITE(pPPriv->OverlayAlpha, PM3RD_VideoOverlayBlend); + RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | + PM3RD_VideoOverlayControl_MODE_BLEND | + PM3RD_VideoOverlayControl_BLENDSRC_REGISTER, + PM3RD_VideoOverlayControl); + } else { +#if SUPPORT_CLIPPING + switch (pScrn->depth) { + case 8: + case 16: + RAMDAC_WRITE((pPPriv->ColorKey&0xff0000)>>16, + PM3RD_VideoOverlayKeyR); + RAMDAC_WRITE((pPPriv->ColorKey&0x00ff00)>>8, + PM3RD_VideoOverlayKeyG); + RAMDAC_WRITE(pPPriv->ColorKey&0x0000ff, + PM3RD_VideoOverlayKeyB); + RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | + PM3RD_VideoOverlayControl_MODE_MAINKEY | + PM3RD_VideoOverlayControl_KEY_COLOR, + PM3RD_VideoOverlayControl); + break; + case 15: + RAMDAC_WRITE(0x1, PM3RD_VideoOverlayKeyR); + RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | + PM3RD_VideoOverlayControl_MODE_MAINKEY | + PM3RD_VideoOverlayControl_KEY_ALPHA, + PM3RD_VideoOverlayControl); + break; + case 24: + RAMDAC_WRITE(0xff, PM3RD_VideoOverlayKeyR); + RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | + PM3RD_VideoOverlayControl_MODE_MAINKEY | + PM3RD_VideoOverlayControl_KEY_ALPHA, + PM3RD_VideoOverlayControl); + break; + } +#else + RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | + PM3RD_VideoOverlayControl_MODE_ALWAYS, + PM3RD_VideoOverlayControl); +#endif + } + pPPriv->ramdac_on = TRUE; } - /* And now enable Video Overlay in the RAMDAC */ - RAMDAC_WRITE(PM3RD_VideoOverlayControl_ENABLE | - /* OverlayMode attribute */ - (pPPriv->OverlayControl&0xff), - PM3RD_VideoOverlayControl); - - pPPriv->Buffer[pPPriv->display]->RemoveLinearCallback = - RemoveAreaCallback; + + pPPriv->Buffer[pPPriv->display]->RemoveAreaCallback = + RemoveBufferCallback; if (display != -1) pPPriv->copy = -1; } +#if SUPPORT_CLIPPING + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} +static void Clip (PortPrivPtr pPPriv, RegionPtr clipBoxes) +{ + AdaptorPrivPtr pAPriv = pPPriv->pAdaptor; + ScrnInfoPtr pScrn = pAPriv->pScrn; + + /* Let's handle the clipping here. */ + if(!RegionsEqual(&pPPriv->clip, clipBoxes)) { + REGION_COPY(pScrn->pScreen, &pPPriv->clip, clipBoxes); + if (pPPriv->OverlayAlpha<(3<<6)) { + XAAFillSolidRects(pScrn, pPPriv->OverlayAlpha<<24, GXcopy, + 0xff000000, REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } else { + switch (pScrn->depth) { + case 8: /* CI8 */ + XAAFillSolidRects(pScrn, pPPriv->ColorKey, + GXcopy, 0xffffffff, REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + break; + case 15: /* RGB5551 */ + XAAFillSolidRects(pScrn, 0xffffffff, GXcopy, 0x80008000, + REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); + break; + case 16: /* RGB565 */ + XAAFillSolidRects(pScrn, pPPriv->ColorKey, GXcopy, + 0xffffffff, REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + break; + case 24: /* RGB8888 */ + XAAFillSolidRects(pScrn, 0xffffffff, GXcopy, + 0xff000000, REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + break; + } + } + } +} +#endif + static void StopOverlay(PortPrivPtr pPPriv, int cleanup) { @@ -657,38 +918,42 @@ StopOverlay(PortPrivPtr pPPriv, int cleanup) DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "StopOverlay.\n")); /* Stop the Video Overlay in the RAMDAC */ - RAMDAC_WRITE(PM3RD_VideoOverlayControl_DISABLE, - PM3RD_VideoOverlayControl); + if (pPPriv->ramdac_on) { + RAMDAC_WRITE(PM3RD_VideoOverlayControl_DISABLE, + PM3RD_VideoOverlayControl); + pPPriv->ramdac_on = FALSE; + } /* Stop the Video Overlay in the Video Overlay Unit */ GLINT_WAIT(1); GLINT_WRITE_REG(PM3VideoOverlayMode_DISABLE, PM3VideoOverlayMode); } -/* ReputImage may be used if only the position of the destination changes, - * maybe while moving the window around or something such. - */ +/* ReputImage is used if only the destination position or + * the clipboxes change. */ static int Permedia3ReputImage(ScrnInfoPtr pScrn, short drw_x, short drw_y, RegionPtr clipBoxes, pointer data) { PortPrivPtr pPPriv = (PortPrivPtr) data; - GLINTPtr pGlint = GLINTPTR(pScrn); - BoxPtr extent; DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "ReputImage %d,%d.\n", drw_x, drw_y)); - /* If the buffer was freed, we cannot overlay it. */ - if (pPPriv->display == -1) { + +#if !SUPPORT_CLIPPING + /* If the clip region is not a rectangle */ + if (REGION_SIZE(clipBoxes) != 0) { StopOverlay (pPPriv, FALSE); return Success; } - if (REGION_SIZE(clipBoxes) != 0) { - /* We need to transform the clipBoxes into a bitmap, - * and upload it to offscreen memory. */ +#endif + + /* If the buffer was freed, we cannot overlay it. */ + if (pPPriv->display == -1) { StopOverlay (pPPriv, FALSE); return Success; } + /* Check that the dst area is some part of the visible screen. */ if ((drw_x + pPPriv->dw) < pScrn->frameX0 || (drw_y + pPPriv->dh) < pScrn->frameY0 || @@ -699,16 +964,13 @@ Permedia3ReputImage(ScrnInfoPtr pScrn, pPPriv->dx = drw_x; pPPriv->dy = drw_y; - /* We sync the chip. */ - if (pGlint->MultiAperture) DualPermedia3Sync(pScrn); - else Permedia3Sync(pScrn); - - extent = REGION_EXTENTS(pScrn, clipBoxes); - BeginOverlay(pPPriv, -1, pPPriv->Bpp_shift, extent); +#if SUPPORT_CLIPPING + /* Clipping */ + Clip (pPPriv, clipBoxes); +#endif - /* We sync the chip. */ - if (pGlint->MultiAperture) DualPermedia3Sync(pScrn); - else Permedia3Sync(pScrn); + /* Restart the overlay */ + BeginOverlay(pPPriv, -1); return Success; } @@ -721,10 +983,12 @@ Permedia3PutImage(ScrnInfoPtr pScrn, Bool sync, RegionPtr clipBoxes, pointer data) { PortPrivPtr pPPriv = (PortPrivPtr) data; +#if !USE_HARDWARE_COPY GLINTPtr pGlint = GLINTPTR(pScrn); +#endif int copy = -1; - BoxPtr extent; - BoxRec ext; + Bool copy_flat = TRUE; + int w_bpp; DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "PutImage %d,%d,%d,%d -> %d,%d,%d,%d " @@ -732,20 +996,27 @@ Permedia3PutImage(ScrnInfoPtr pScrn, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, id, buf, width, height, sync)); - extent = REGION_EXTENTS(pScrn, clipBoxes); - ext = *extent; - if (REGION_SIZE(clipBoxes) != 0) return Success; +#if !SUPPORT_CLIPPING + /* If the clip region is not a rectangle */ + if (REGION_SIZE(clipBoxes) != 0) { + StopOverlay (pPPriv, FALSE); + return Success; + } +#endif /* Check that the src area to put is included in the buffer. */ if ((src_x + src_w) > width || (src_y + src_h) > height || - src_x < 0 || src_y < 0) + src_x < 0 || src_y < 0) { + StopOverlay(pPPriv, FALSE); return BadValue; + } /* Check that the dst area is some part of the visible screen. */ if ((drw_x + drw_w) < pScrn->frameX0 || (drw_y + drw_h) < pScrn->frameY0 || drw_x > pScrn->frameX1 || drw_y > pScrn->frameY1) { + StopOverlay(pPPriv, FALSE); return Success; } @@ -771,176 +1042,119 @@ Permedia3PutImage(ScrnInfoPtr pScrn, if (i >= ENTRIES(ScalerImages)) return XvBadAlloc; pPPriv->Id = id; - pPPriv->Bpp = ScalerImages[i].bits_per_pixel; } - /* We sync the chip. I don't know if it is really - * needed but X crashed when i didn't do it. */ - if (pGlint->MultiAperture) DualPermedia3Sync(pScrn); - else Permedia3Sync(pScrn); - - /* Let's define the different strides values */ - pPPriv->OverlayStride = width; - pPPriv->BufferStride = ((pPPriv->Bpp+7)>>3) * width; + /* Let's find the image format and Video_Shift values */ + switch (id) { + case LE4CC('Y','V','1','2'): + pPPriv->Format = FORMAT_YUV422; + pPPriv->Video_Shift = 1; + copy_flat = FALSE; + break; + case LE4CC('Y','U','Y','2'): + pPPriv->Format = FORMAT_YUV422; + pPPriv->Video_Shift = 1; + break; + case LE4CC('U','Y','V','Y'): + pPPriv->Format = FORMAT_VUY422; + pPPriv->Video_Shift = 1; + break; + case LE4CC('Y','U','V','A'): + pPPriv->Format = FORMAT_YUV444; + pPPriv->Video_Shift = 2; + break; + case LE4CC('V','U','Y','A'): + pPPriv->Format = FORMAT_VUY444; + pPPriv->Video_Shift = 2; + break; + case 0x41: /* RGBA 8:8:8:8 */ + pPPriv->Format = FORMAT_RGB8888; + pPPriv->Video_Shift = 2; + break; + case 0x42: /* RGB 5:6:5 */ + pPPriv->Format = FORMAT_RGB565; + pPPriv->Video_Shift = 1; + break; + case 0x43: /* RGB 1:5:5:5 */ + pPPriv->Format = FORMAT_RGB5551; + pPPriv->Video_Shift = 1; + break; + case 0x44: /* RGB 4:4:4:4 */ + pPPriv->Format = FORMAT_RGB4444; + pPPriv->Video_Shift = 1; + break; + case 0x46: /* RGB 2:3:3 */ + pPPriv->Format = FORMAT_RGB332; + pPPriv->Video_Shift = 0; + break; + case 0x47: /* BGRA 8:8:8:8 */ + pPPriv->Format = FORMAT_BGR8888; + pPPriv->Video_Shift = 2; + break; + case 0x48: /* BGR 5:6:5 */ + pPPriv->Format = FORMAT_BGR565; + pPPriv->Video_Shift = 1; + break; + case 0x49: /* BGR 1:5:5:5 */ + pPPriv->Format = FORMAT_BGR5551; + pPPriv->Video_Shift = 1; + break; + case 0x4A: /* BGR 4:4:4:4 */ + pPPriv->Format = FORMAT_BGR4444; + pPPriv->Video_Shift = 1; + break; + case 0x4C: /* BGR 2:3:3 */ + pPPriv->Format = FORMAT_BGR332; + pPPriv->Video_Shift = 0; + break; + default: + return XvBadAlloc; + } /* Now we allocate a buffer, if it is needed */ - if ((copy = AllocateBuffers(pPPriv, pPPriv->BufferStride, height)) == -1) + w_bpp = (width << pPPriv->Video_Shift) >> pPPriv->FB_Shift; + if ((copy = AllocateBuffers(pPPriv, w_bpp, height)) == -1) return XvBadAlloc; - /* Now, we can copy the image to the buffer */ - switch (id) { - case LE4CC('Y','V','1','2'): -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - CopyYV12LE(buf, - (CARD32 *)((CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset)), - width, height, pPPriv->BufferStride); + /* Let's copy the image to the framebuffer */ +#if USE_HARDWARE_COPY + /* Erm, ... removing this log message will make the server crash. */ + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Hardware image upload.\n")); + HWCopySetup(pPPriv, pPPriv->Buffer[copy]->box.x1, + pPPriv->Buffer[copy]->box.y1, w_bpp, height); + if (copy_flat) HWCopyFlat(pPPriv, buf, width, height); + else HWCopyYV12(pPPriv, buf, width, height); #else - if (pGlint->FBDev) - CopyYV12LE(buf, - (CARD32 *)((CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset)), - width, height, pPPriv->BufferStride); - else - CopyYV12BE(buf, - (CARD32 *)((CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset)), - width, height, pPPriv->BufferStride); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Software image upload (1).\n")); + pPPriv->Sync(pScrn); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Software image upload (2).\n")); + if (copy_flat) CopyFlat(buf, + (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[copy], + width << pPPriv->FB_Shift, height, + pScrn->displayWidth << pPPriv->FB_Shift); + else CopyYV12(buf, + (CARD32 *)((CARD8 *) pGlint->FbBase + pPPriv->BufferBase[copy]), + width, height, pScrn->displayWidth << pPPriv->FB_Shift); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Software image upload (3).\n")); + pPPriv->Sync(pScrn); + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Software image upload (4).\n")); #endif - pPPriv->Format = FORMAT_YUV422; - pPPriv->Bpp_shift = 1; - break; - case LE4CC('Y','U','Y','2'): - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_YUV422; - pPPriv->Bpp_shift = 1; - break; - - case LE4CC('U','Y','V','Y'): - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_VUY422; - pPPriv->Bpp_shift = 1; - break; - - case LE4CC('Y','U','V','A'): - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 2, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_YUV444; - pPPriv->Bpp_shift = 2; - break; - - case LE4CC('V','U','Y','A'): - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 2, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_VUY444; - pPPriv->Bpp_shift = 2; - break; - - case 0x41: /* RGBA 8:8:8:8 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 2, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_RGB8888; - pPPriv->Bpp_shift = 2; - break; - - case 0x42: /* RGB 5:6:5 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_RGB565; - pPPriv->Bpp_shift = 1; - break; - - case 0x43: /* RGB 1:5:5:5 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_RGB5551; - pPPriv->Bpp_shift = 1; - break; - - case 0x44: /* RGB 4:4:4:4 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_RGB4444; - pPPriv->Bpp_shift = 1; - break; - - case 0x46: /* RGB 2:3:3 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_RGB332; - pPPriv->Bpp_shift = 0; - break; - - case 0x47: /* BGRA 8:8:8:8 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 2, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_BGR8888; - pPPriv->Bpp_shift = 2; - break; - - case 0x48: /* BGR 5:6:5 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_BGR565; - pPPriv->Bpp_shift = 1; - break; - - case 0x49: /* BGR 1:5:5:5 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_BGR5551; - pPPriv->Bpp_shift = 1; - break; - - case 0x4A: /* BGR 4:4:4:4 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 1, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_BGR4444; - pPPriv->Bpp_shift = 1; - break; - - case 0x4C: /* BGR 2:3:3 */ - CopyFlat(buf, (CARD8 *) pGlint->FbBase + - GET_OFFSET(pScrn, pPPriv->Buffer[copy]->offset), - width << 0, height, pPPriv->BufferStride); - pPPriv->Format = FORMAT_BGR332; - pPPriv->Bpp_shift = 0; - break; - default: - return XvBadAlloc; - } - /* We sync the chip. */ - if (pGlint->MultiAperture) DualPermedia3Sync(pScrn); - else Permedia3Sync(pScrn); - /* Don't know why we need this, - * but the server will crash if i remove it. */ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Starting the overlay.\n"); +#if SUPPORT_CLIPPING + /* Clipping*/ + Clip (pPPriv, clipBoxes); +#endif /* We start the overlay */ - BeginOverlay(pPPriv, copy, pPPriv->Bpp_shift, extent); + BeginOverlay(pPPriv, copy); - /* We sync the chip again. */ - if (sync) { - if (pGlint->MultiAperture) DualPermedia3Sync(pScrn); - else Permedia3Sync(pScrn); - } + /* We sync the chip again (if needed). */ + if (sync) pPPriv->Sync(pScrn); return Success; } @@ -953,6 +1167,7 @@ Permedia3StopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "StopVideo : exit=%d\n", cleanup)); + REGION_EMPTY(pScrn->pScreen, &pPPriv->clip); StopOverlay(pPPriv, cleanup); if (cleanup) { @@ -966,7 +1181,6 @@ Permedia3SetPortAttribute(ScrnInfoPtr pScrn, { PortPrivPtr pPPriv = (PortPrivPtr) data; - /* Note, we could decode and store attributes directly here */ if (attribute == xvFilter) { switch (value) { case 0: /* No Filtering */ @@ -975,17 +1189,20 @@ Permedia3SetPortAttribute(ScrnInfoPtr pScrn, ~PM3VideoOverlayMode_FILTER_MASK) | PM3VideoOverlayMode_FILTER_OFF; break; - case 1: /* No Filtering */ + case 1: /* Partial Filtering (X axis only) */ pPPriv->OverlayMode = (pPPriv->OverlayMode & ~PM3VideoOverlayMode_FILTER_MASK) | PM3VideoOverlayMode_FILTER_PARTIAL; break; - case 2: /* No Filtering */ + case 2: /* Full Bilinear Filtering */ + /* We have to disable X mirroring also */ pPPriv->OverlayMode = (pPPriv->OverlayMode & - ~PM3VideoOverlayMode_FILTER_MASK) | + ~(PM3VideoOverlayMode_FILTER_MASK | + PM3VideoOverlayMode_MIRRORX_ON)) | PM3VideoOverlayMode_FILTER_FULL; + pPPriv->Attribute[1] &= 2; break; default: return BadValue; @@ -1002,11 +1219,23 @@ Permedia3SetPortAttribute(ScrnInfoPtr pScrn, PM3VideoOverlayMode_MIRRORY_OFF; break; case 1: /* X Axis Mirroring */ - pPPriv->OverlayMode = - (pPPriv->OverlayMode & - ~PM3VideoOverlayMode_MIRROR_MASK) | - PM3VideoOverlayMode_MIRRORX_ON | - PM3VideoOverlayMode_MIRRORY_OFF; + /* If full filtering was enabled, rever to partial. */ + if (pPPriv->Attribute[0] == 2) { + pPPriv->OverlayMode = + (pPPriv->OverlayMode & + ~(PM3VideoOverlayMode_MIRROR_MASK | + PM3VideoOverlayMode_FILTER_MASK)) | + PM3VideoOverlayMode_MIRRORX_ON | + PM3VideoOverlayMode_MIRRORY_OFF | + PM3VideoOverlayMode_FILTER_PARTIAL; + pPPriv->Attribute[0] = 1; + } else { + pPPriv->OverlayMode = + (pPPriv->OverlayMode & + ~PM3VideoOverlayMode_MIRROR_MASK) | + PM3VideoOverlayMode_MIRRORX_ON | + PM3VideoOverlayMode_MIRRORY_OFF; + } break; case 2: /* Y Axis Mirroring */ pPPriv->OverlayMode = @@ -1016,73 +1245,33 @@ Permedia3SetPortAttribute(ScrnInfoPtr pScrn, PM3VideoOverlayMode_MIRRORY_ON; break; case 3: /* X and Y Axis Mirroring */ - pPPriv->OverlayMode = - (pPPriv->OverlayMode & - ~PM3VideoOverlayMode_MIRROR_MASK) | - PM3VideoOverlayMode_MIRRORX_ON | - PM3VideoOverlayMode_MIRRORY_ON; + /* If full filtering was enabled, rever to partial. */ + if (pPPriv->Attribute[0] == 2) { + pPPriv->OverlayMode = + (pPPriv->OverlayMode & + ~(PM3VideoOverlayMode_MIRROR_MASK | + PM3VideoOverlayMode_FILTER_MASK)) | + PM3VideoOverlayMode_MIRRORX_ON | + PM3VideoOverlayMode_MIRRORY_ON | + PM3VideoOverlayMode_FILTER_PARTIAL; + pPPriv->Attribute[0] = 1; + } else { + pPPriv->OverlayMode = + (pPPriv->OverlayMode & + ~PM3VideoOverlayMode_MIRROR_MASK) | + PM3VideoOverlayMode_MIRRORX_ON | + PM3VideoOverlayMode_MIRRORY_ON; + } break; default: return BadValue; } pPPriv->Attribute[1] = value; } - else if (attribute == xvOverlayMode) { - pPPriv->OverlayControl = - PM3RD_VideoOverlayControl_ENABLE; - switch (value&&0xff) { - case 0: /* Opaque video overlay */ - pPPriv->OverlayData = - OVERLAY_DATA_NONE; - pPPriv->OverlayControl = - PM3RD_VideoOverlayControl_MODE_ALWAYS; - break; - case 1: /* Color keyed overlay, framebuffer color key */ - pPPriv->OverlayData = - OVERLAY_DATA_COLORKEY; - pPPriv->OverlayControl = - /* color key in RGB 888 mode */ - ((value<<5)&0xffffff00) | - PM3RD_VideoOverlayControl_MODE_MAINKEY | - PM3RD_VideoOverlayControl_KEY_COLOR; - break; - case 2: /* Color keyed overlay, framebuffer alpha key */ - pPPriv->OverlayData = - OVERLAY_DATA_ALPHAKEY; - pPPriv->OverlayControl = - /* 8 bit alpha key */ - ((value<<5)&0xff00) | - PM3RD_VideoOverlayControl_MODE_MAINKEY | - PM3RD_VideoOverlayControl_KEY_ALPHA; - break; - case 3: /* Color keyed overlay, overlay color key */ - pPPriv->OverlayData = - OVERLAY_DATA_COLORKEY; - pPPriv->OverlayControl = - /* color key in RGB 888 mode */ - ((value<<5)&0xffffff00) | - PM3RD_VideoOverlayControl_MODE_OVERLAYKEY; - break; - case 4: /* Per pixel alpha blending */ - pPPriv->OverlayData = - OVERLAY_DATA_NONE; - pPPriv->OverlayControl = - PM3RD_VideoOverlayControl_MODE_BLEND | - PM3RD_VideoOverlayControl_BLENDSRC_MAIN; - break; - case 5: /* Constant alpha blending */ - pPPriv->OverlayData = - OVERLAY_DATA_ALPHABLEND; - pPPriv->OverlayControl = - /* 8 bit alpha blend factor - * (only the 2 top bits are used) */ - ((value<<5)&0xff00) | - PM3RD_VideoOverlayControl_MODE_BLEND | - PM3RD_VideoOverlayControl_BLENDSRC_REGISTER; - break; - default: - return BadValue; - } + else if (attribute == xvAlpha) { + if (value >= 0 && value <= 3) { + pPPriv->OverlayAlpha = value << 6; + } else return BadValue; pPPriv->Attribute[2] = value; } else return BadMatch; @@ -1104,7 +1293,7 @@ Permedia3GetPortAttribute(ScrnInfoPtr pScrn, *value = pPPriv->Attribute[0]; else if (attribute == xvMirror) *value = pPPriv->Attribute[1]; - else if (attribute == xvOverlayMode) + else if (attribute == xvAlpha) *value = pPPriv->Attribute[2]; else return BadMatch; @@ -1204,6 +1393,7 @@ NewAdaptorPriv(ScrnInfoPtr pScrn) { AdaptorPrivPtr pAPriv = (AdaptorPrivPtr) xcalloc(1, sizeof(AdaptorPrivRec)); PortPrivPtr pPPriv = (PortPrivPtr) xcalloc(1, sizeof(PortPrivRec)); + GLINTPtr pGlint = GLINTPTR(pScrn); int i; if (!pAPriv) return NULL; @@ -1218,23 +1408,41 @@ NewAdaptorPriv(ScrnInfoPtr pScrn) return NULL; } - /* Attributes */ pPPriv->pAdaptor = pAPriv; - pPPriv->Attribute[0] = 0; /* Full filtering enabled */ + /* Sync */ + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, + "Sync is using : %sPermedia3Sync.\n", + pGlint->MultiAperture?"Dual":"")); + if (pGlint->MultiAperture) pPPriv->Sync = DualPermedia3Sync; + else pPPriv->Sync = Permedia3Sync; + + /* Framebuffer bpp shift */ + pPPriv->FB_Shift = pScrn->bitsPerPixel >> 4; + + /* Attributes */ + pPPriv->Attribute[0] = 2; /* Full filtering enabled */ pPPriv->Attribute[1] = 0; /* No mirroring */ - pPPriv->Attribute[2] = 0; /* Opaque overlay mode */ - pPPriv->OverlayData = 0; + pPPriv->Attribute[2] = 3; /* Opaque overlay mode */ + pPPriv->ColorKey = 0; + pPPriv->OverlayAlpha = + PM3RD_VideoOverlayBlend_FACTOR_100_PERCENT; pPPriv->OverlayMode = PM3VideoOverlayMode_FILTER_FULL | PM3VideoOverlayMode_MIRRORX_OFF | PM3VideoOverlayMode_MIRRORY_OFF; - pPPriv->OverlayControl = - PM3RD_VideoOverlayControl_ENABLE | - PM3RD_VideoOverlayControl_MODE_ALWAYS; + + /* Clipping */ + REGION_EMPTY(pScrn->pScreen, &pPPriv->clip); + + /* RAMDAC saved values */ + pPPriv->ramdac_x = 0; + pPPriv->ramdac_w = 0; + pPPriv->ramdac_y = 0; + pPPriv->ramdac_h = 0; + pPPriv->ramdac_on = FALSE; /* Buffers */ pPPriv->Id = ScalerImages[0].id; - pPPriv->Bpp = ScalerImages[0].bits_per_pixel; pPPriv->copy = -1; pPPriv->display = -1; for (i = 0; i < MAX_BUFFERS; i++) @@ -1267,10 +1475,15 @@ Permedia3VideoLeaveVT(ScrnInfoPtr pScrn) void Permedia3VideoUninit(ScrnInfoPtr pScrn) { - if (AdaptorPriv->pScrn == pScrn) { - DeleteAdaptorPriv(AdaptorPriv); - AdaptorPriv = NULL; - } + AdaptorPrivPtr pAPriv, *ppAPriv; + + for (ppAPriv = &AdaptorPrivList; (pAPriv = *ppAPriv); ppAPriv = &(pAPriv->Next)) + if (pAPriv->pScrn == pScrn) { + *ppAPriv = pAPriv->Next; + DeleteAdaptorPriv(pAPriv); + break; + } + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv cleanup\n")); } @@ -1286,9 +1499,15 @@ Permedia3VideoInit(ScreenPtr pScreen) switch (pGlint->Chipset) { case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, + "Using the Permedia3 chipset.\n"); break; case PCI_VENDOR_3DLABS_CHIP_GAMMA: - if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) break; + if (pGlint->MultiChip == PCI_CHIP_PERMEDIA3) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, + "Using the Gamma chipset.\n"); + break; + } default: xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 1, "No Xv support for chipset %d.\n", pGlint->Chipset); @@ -1299,14 +1518,9 @@ Permedia3VideoInit(ScreenPtr pScreen) "Initializing Permedia3 Xv driver rev. 1\n"); if (pGlint->NoAccel) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 1, - "Xv : Sorry, Xv is not supported without accelerations"); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Xv initialization failed : XAA is needed\n"); return; -#if 0 /* This works, but crashes the X server after a time. */ - xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 1, - "Xv : Acceleration disabled, starting offscreen memory manager\n."); - Permedia3EnableOffscreen (pScreen); -#endif } if (!(pAPriv = NewAdaptorPriv(pScrn))) { @@ -1321,7 +1535,7 @@ Permedia3VideoInit(ScreenPtr pScreen) VARPtrs = &VAR; VAR.type = XvInputMask | XvWindowMask | XvImageMask; - VAR.flags = VIDEO_OVERLAID_IMAGES; + VAR.flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; VAR.name = "Permedia 3 Frontend Scaler"; VAR.nEncodings = ENTRIES(ScalerEncodings); VAR.pEncodings = ScalerEncodings; @@ -1349,12 +1563,15 @@ Permedia3VideoInit(ScreenPtr pScreen) if (xf86XVScreenInit(pScreen, &VARPtrs, 1)) { xvFilter = MAKE_ATOM(XV_FILTER); xvMirror = MAKE_ATOM(XV_MIRROR); - xvOverlayMode = MAKE_ATOM(XV_OVERLAY_MODE); + xvAlpha = MAKE_ATOM(XV_ALPHA); - /* Add it to the AdaptatorList */ - AdaptorPriv = pAPriv; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv frontend scaler enabled\n"); +#if USE_HARDWARE_COPY + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Xv frontend scaler enabled (HW)\n"); +#else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Xv frontend scaler enabled (SW)\n"); +#endif } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv initialization failed\n"); DeleteAdaptorPriv(pAPriv); 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 95db91fa7..271754097 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c @@ -28,7 +28,7 @@ * * GLINT 500TX / MX accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.26 2001/04/19 09:28:32 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.26.2.2 2001/05/30 10:08:19 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -94,8 +94,6 @@ static void TXPolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, static void TXPolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment *pSeg); -#define MAX_FIFO_ENTRIES 15 - void TXInitializeEngine(ScrnInfoPtr pScrn) { @@ -252,14 +250,14 @@ TXAccelInit(ScreenPtr pScreen) TRANSPARENCY_ONLY | 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->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 = TXSetupForScanlineCPUToScreenColorExpandFill; @@ -268,7 +266,7 @@ TXAccelInit(ScreenPtr pScreen) infoPtr->SubsequentColorExpandScanline = TXSubsequentColorExpandScanline; - infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; + infoPtr->ColorExpandRange = pGlint->FIFOSize; infoPtr->WriteBitmap = TXWriteBitmap; infoPtr->WritePixmap = TXWritePixmap; @@ -280,6 +278,8 @@ TXAccelInit(ScreenPtr pScreen) AvailFBArea.y2 = memory / (pScrn->displayWidth * pScrn->bitsPerPixel / 8); + if (AvailFBArea.y2 > 4095) AvailFBArea.y2 = 4095; + xf86InitFBManager(pScreen, &AvailFBArea); return (XAAInit(pScreen, infoPtr)); @@ -537,43 +537,57 @@ TXSubsequentScanlineCPUToScreenColorExpandFill( pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */ - pGlint->cpucount = y; - pGlint->cpuheight = h; - GLINT_WAIT(6); - TXLoadCoord(pScrn, x, pGlint->cpucount, x+w, 1, 0, 1); + pGlint->cpucount = h; + + GLINT_WAIT(8); + TXLoadCoord(pScrn, x, y, (x+w), h, 0, 1); + GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode | SyncOnBitMask, + Render); +#if defined(__alpha__) + if (0) /* force Alpha to use indirect always */ +#else + if ((pGlint->dwords*h) < pGlint->FIFOSize) +#endif + { + /* Turn on direct for less than FIFOSize 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 TXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); GLINTPtr pGlint = GLINTPTR(pScrn); - CARD32 *src; + CARD32 *srcp = (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno]; int dwords = pGlint->dwords; - GLINT_WAIT(7); - TXLoadCoord(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); - GLINT_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); - GLINT_MoveDWORDS( - (CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,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); + } } - pGlint->cpucount += 1; } void TXSetupForMono8x8PatternFill( |