diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mga.h | 12 | ||||
-rw-r--r-- | src/mga_dac3026.c | 4 | ||||
-rw-r--r-- | src/mga_dacG.c | 185 | ||||
-rw-r--r-- | src/mga_dri.c | 28 | ||||
-rw-r--r-- | src/mga_dri.h | 1 | ||||
-rw-r--r-- | src/mga_driver.c | 205 | ||||
-rw-r--r-- | src/mga_halmod.c | 2 | ||||
-rw-r--r-- | src/mga_maven.h | 80 | ||||
-rw-r--r-- | src/mga_sarea.h | 4 | ||||
-rw-r--r-- | src/mga_storm.c | 10 |
10 files changed, 420 insertions, 111 deletions
@@ -374,7 +374,13 @@ typedef struct { unsigned int (*ddc1Read)(ScrnInfoPtr); void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed); Bool (*i2cInit)(ScrnInfoPtr); - I2CBusPtr I2C; + I2CBusPtr DDC_Bus1; + I2CBusPtr DDC_Bus2; + I2CBusPtr Maven_Bus; + I2CDevPtr Maven; + char Maven_Version; + Bool UseMaven; + Bool UseMavenPM; Bool FBDev; int colorKey; int videoKey; @@ -414,8 +420,10 @@ typedef struct { #endif XF86VideoAdaptorPtr adaptor; Bool DualHeadEnabled; + Bool Crtc2IsTV; Bool SecondCrtc; Bool SecondOutput; + GDevPtr device; /* The hardware's real SrcOrg */ int realSrcOrg; @@ -575,6 +583,8 @@ Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); #endif +Bool MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val); + void MGACRTC2Set(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo); void MGAEnableSecondOutPut(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo); void MGACRTC2SetPitch(ScrnInfoPtr pSrcn, xMODEINFO *pModeInfo); diff --git a/src/mga_dac3026.c b/src/mga_dac3026.c index 7cbec19..ecd0605 100644 --- a/src/mga_dac3026.c +++ b/src/mga_dac3026.c @@ -1033,7 +1033,7 @@ MGA3026_i2cInit(ScrnInfoPtr pScrn) I2CPtr = xf86CreateI2CBusRec(); if(!I2CPtr) return FALSE; - pMga->I2C = I2CPtr; + pMga->DDC_Bus1 = I2CPtr; I2CPtr->BusName = "DDC"; I2CPtr->scrnIndex = pScrn->scrnIndex; @@ -1282,6 +1282,6 @@ void MGA2064SetupFuncs(ScrnInfoPtr pScrn) pMga->ModeInit = MGA3026Init; pMga->ddc1Read = MGA3026_ddc1Read; /* vgaHWddc1SetSpeed will only work if the card is in VGA mode */ - pMga->DDC1SetSpeed = vgaHWddc1SetSpeed; + pMga->DDC1SetSpeed = vgaHWddc1SetSpeedWeak(); pMga->i2cInit = MGA3026_i2cInit; } diff --git a/src/mga_dacG.c b/src/mga_dacG.c index 0a3a7e2..4dc93e4 100644 --- a/src/mga_dacG.c +++ b/src/mga_dacG.c @@ -26,6 +26,7 @@ #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" +#include "mga_maven.h" #include "xf86DDC.h" @@ -1020,10 +1021,19 @@ MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) * which VGA line is connected to each DDC pin, so I've had to guess. * * DDC1 support only requires DDC_SDA_MASK, - * DDC2 support reuqiers DDC_SDA_MASK and DDC_SCL_MASK + * DDC2 support requires DDC_SDA_MASK and DDC_SCL_MASK + * + * If we want DDC on second head (P2) then we must use DDC2 protocol (I2C) + * + * Be careful, DDC1 and DDC2 refer to protocols, DDC_P1 and DDC_P2 refer to + * DDC data coming in on which videoport on the card */ -static const int DDC_SDA_MASK = 1 << 1; -static const int DDC_SCL_MASK = 1 << 3; +static const int DDC_P1_SDA_MASK = (1 << 1); +static const int DDC_P1_SCL_MASK = (1 << 3); +static const int DDC_P2_SDA_MASK = (1 << 0); +static const int DDC_P2_SCL_MASK = (1 << 2); +static const int MAVEN_SDA_MASK = (1 << 4); +static const int MAVEN_SCL_MASK = (1 << 5); static unsigned int MGAG_ddc1Read(ScrnInfoPtr pScrn) @@ -1032,19 +1042,19 @@ MGAG_ddc1Read(ScrnInfoPtr pScrn) unsigned char val; /* Define the SDA as an input */ - outMGAdacmsk(MGA1064_GEN_IO_CTL, ~(DDC_SCL_MASK | DDC_SDA_MASK), 0); + outMGAdacmsk(MGA1064_GEN_IO_CTL, ~(DDC_P1_SCL_MASK | DDC_P1_SDA_MASK), 0); /* wait for Vsync */ while( INREG( MGAREG_Status ) & 0x08 ); while( ! (INREG( MGAREG_Status ) & 0x08) ); /* Get the result */ - val = (inMGAdac(MGA1064_GEN_IO_DATA) & DDC_SDA_MASK); + val = (inMGAdac(MGA1064_GEN_IO_DATA) & DDC_P1_SDA_MASK); return val; } static void -MGAG_I2CGetBits(I2CBusPtr b, int *clock, int *data) +MGAG_I2CGetBits(I2CBusPtr b, int *clock, int *data, int my_scl_mask, int my_sda_mask) { ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex]; MGAPtr pMga = MGAPTR(pScrn); @@ -1053,8 +1063,8 @@ MGAG_I2CGetBits(I2CBusPtr b, int *clock, int *data) /* Get the result. */ val = inMGAdac(MGA1064_GEN_IO_DATA); - *clock = (val & DDC_SCL_MASK) != 0; - *data = (val & DDC_SDA_MASK) != 0; + *clock = (val & my_scl_mask) != 0; + *data = (val & my_sda_mask) != 0; #ifdef DEBUG ErrorF("MGAG_I2CGetBits(%p,...) val=0x%x, returns clock %d, data %d\n", b, val, *clock, *data); #endif @@ -1063,26 +1073,59 @@ MGAG_I2CGetBits(I2CBusPtr b, int *clock, int *data) /* * ATTENTION! - the DATA and CLOCK lines need to be tri-stated when * high. Therefore turn off output driver for the line to set line - * to high. High signal is maintained by a 15k Ohm pll-up resistor. + * to high. High signal is maintained by a 15k Ohm pull-up resistor. */ static void -MGAG_I2CPutBits(I2CBusPtr b, int clock, int data) +MGAG_I2CPutBits(I2CBusPtr b, int clock, int data, int my_scl_mask, int my_sda_mask) { ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex]; MGAPtr pMga = MGAPTR(pScrn); unsigned char drv, val; - val = (clock ? DDC_SCL_MASK : 0) | (data ? DDC_SDA_MASK : 0); - drv = ((!clock) ? DDC_SCL_MASK : 0) | ((!data) ? DDC_SDA_MASK : 0); + val = (clock ? my_scl_mask : 0) | (data ? my_sda_mask : 0); + drv = ((!clock) ? my_scl_mask : 0) | ((!data) ? my_sda_mask : 0); /* Write the values */ - outMGAdacmsk(MGA1064_GEN_IO_CTL, ~(DDC_SCL_MASK | DDC_SDA_MASK) , drv); - outMGAdacmsk(MGA1064_GEN_IO_DATA, ~(DDC_SCL_MASK | DDC_SDA_MASK) , val); + outMGAdacmsk(MGA1064_GEN_IO_CTL, ~(my_scl_mask | my_sda_mask) , drv); + outMGAdacmsk(MGA1064_GEN_IO_DATA, ~(my_scl_mask | my_sda_mask) , val); #ifdef DEBUG ErrorF("MGAG_I2CPutBits(%p, %d, %d) val=0x%x\n", b, clock, data, val); #endif } +/* FIXME, can we use some neater way besides these silly stubs? */ + +static void +MGAG_DDC_P1_I2CPutBits(I2CBusPtr b, int clock, int data) +{ + MGAG_I2CPutBits(b, clock, data, DDC_P1_SCL_MASK, DDC_P1_SDA_MASK); +} +static void +MGAG_DDC_P2_I2CPutBits(I2CBusPtr b, int clock, int data) +{ + MGAG_I2CPutBits(b, clock, data, DDC_P2_SCL_MASK, DDC_P2_SDA_MASK); +} +static void +MGAG_MAVEN_I2CPutBits(I2CBusPtr b, int clock, int data) +{ + MGAG_I2CPutBits(b, clock, data, MAVEN_SCL_MASK, MAVEN_SDA_MASK); +} + +static void +MGAG_DDC_P1_I2CGetBits(I2CBusPtr b, int *clock, int *data) +{ + MGAG_I2CGetBits(b, clock, data, DDC_P1_SCL_MASK, DDC_P1_SDA_MASK); +} +static void +MGAG_DDC_P2_I2CGetBits(I2CBusPtr b, int *clock, int *data) +{ + MGAG_I2CGetBits(b, clock, data, DDC_P2_SCL_MASK, DDC_P2_SDA_MASK); +} +static void +MGAG_MAVEN_I2CGetBits(I2CBusPtr b, int *clock, int *data) +{ + MGAG_I2CGetBits(b, clock, data, MAVEN_SCL_MASK, MAVEN_SDA_MASK); +} Bool MGAG_i2cInit(ScrnInfoPtr pScrn) @@ -1090,20 +1133,112 @@ MGAG_i2cInit(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); I2CBusPtr I2CPtr; - I2CPtr = xf86CreateI2CBusRec(); - if(!I2CPtr) return FALSE; + if (pMga->SecondCrtc == FALSE) { + I2CPtr = xf86CreateI2CBusRec(); + if(!I2CPtr) return FALSE; - pMga->I2C = I2CPtr; + pMga->DDC_Bus1 = I2CPtr; - I2CPtr->BusName = "DDC"; - I2CPtr->scrnIndex = pScrn->scrnIndex; - I2CPtr->I2CPutBits = MGAG_I2CPutBits; - I2CPtr->I2CGetBits = MGAG_I2CGetBits; - I2CPtr->AcknTimeout = 5; + I2CPtr->BusName = "DDC P1"; + I2CPtr->scrnIndex = pScrn->scrnIndex; + I2CPtr->I2CPutBits = MGAG_DDC_P1_I2CPutBits; + I2CPtr->I2CGetBits = MGAG_DDC_P1_I2CGetBits; + I2CPtr->AcknTimeout = 5; - if (!xf86I2CBusInit(I2CPtr)) { - return FALSE; + if (!xf86I2CBusInit(I2CPtr)) { + xf86DestroyI2CBusRec(pMga->DDC_Bus1, TRUE, TRUE); + pMga->DDC_Bus1 = NULL; + return FALSE; + } } + else { + /* We have a dual head setup on G-series, set up DDC #2. */ + I2CPtr = xf86CreateI2CBusRec(); + if(!I2CPtr) return FALSE; + + pMga->DDC_Bus2 = I2CPtr; + + I2CPtr->BusName = "DDC P2"; + I2CPtr->scrnIndex = pScrn->scrnIndex; + I2CPtr->I2CPutBits = MGAG_DDC_P2_I2CPutBits; + I2CPtr->I2CGetBits = MGAG_DDC_P2_I2CGetBits; + I2CPtr->AcknTimeout = 5; + + if (!xf86I2CBusInit(I2CPtr)) { + xf86DestroyI2CBusRec(pMga->DDC_Bus2, TRUE, TRUE); + pMga->DDC_Bus2 = NULL; + } + else { + if (!xf86I2CProbeAddress(pMga->DDC_Bus2, 0xA0)) { /* 0xA0 is DDC EEPROM address */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC #2 unavailable -> TV cable connected or no monitor connected!\n"); + pMga->Crtc2IsTV = TRUE; /* assume for now. We need to fix HAL interactions. */ + } + } + + /* Then try to set up MAVEN bus. */ + + I2CPtr = xf86CreateI2CBusRec(); + if(!I2CPtr) return FALSE; + pMga->Maven_Bus = I2CPtr; + + I2CPtr->BusName = "MAVEN"; + I2CPtr->scrnIndex = pScrn->scrnIndex; + I2CPtr->I2CPutBits = MGAG_MAVEN_I2CPutBits; + I2CPtr->I2CGetBits = MGAG_MAVEN_I2CGetBits; + I2CPtr->StartTimeout = 5; + + if (!xf86I2CBusInit(I2CPtr)) { + xf86DestroyI2CBusRec(pMga->Maven_Bus, TRUE, TRUE); + pMga->Maven_Bus = NULL; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to register MAVEN I2C bus!\n"); + } + else { + Bool failed = FALSE; + /* Try to detect the MAVEN. */ + if (xf86I2CProbeAddress(pMga->Maven_Bus, MAVEN_READ) == TRUE) { + I2CDevPtr dp = xf86CreateI2CDevRec(); + if (dp) { + I2CByte maven_ver; + + pMga->Maven = dp; + dp->DevName = "MGA-TVO"; + dp->SlaveAddr = MAVEN_WRITE; + dp->pI2CBus = pMga->Maven_Bus; + if (!xf86I2CDevInit(dp)) { + xf86DestroyI2CDevRec(dp, TRUE); + pMga->Maven = NULL; + failed = TRUE; + } + if (MGAMavenRead(pScrn, 0xB2, &maven_ver)) { + if (maven_ver < 0x14) { /* heuristic stolen from matroxfb */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MAVEN revision MGA-TVO-B detected (0x%x)\n", maven_ver); + pMga->Maven_Version = 'B'; + } + else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MAVEN revision MGA-TVO-C detected (0x%x)\n", maven_ver); + pMga->Maven_Version = 'C'; + } + } + else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to determine MAVEN hardware version!\n"); + } + } + else { + failed = TRUE; + } + } + else { + failed = TRUE; + } + + if (failed) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to register MGA-TVO I2C device!\n"); + pMga->Maven = NULL; + pMga->Maven_Version = 0; + } + } + } + return TRUE; } @@ -1196,7 +1331,7 @@ void MGAGSetupFuncs(ScrnInfoPtr pScrn) pMga->ModeInit = MGAGInit; pMga->ddc1Read = MGAG_ddc1Read; /* vgaHWddc1SetSpeed will only work if the card is in VGA mode */ - pMga->DDC1SetSpeed = vgaHWddc1SetSpeed; + pMga->DDC1SetSpeed = vgaHWddc1SetSpeedWeak(); pMga->i2cInit = MGAG_i2cInit; } diff --git a/src/mga_dri.c b/src/mga_dri.c index 755c0db..098b24b 100644 --- a/src/mga_dri.c +++ b/src/mga_dri.c @@ -52,6 +52,7 @@ #include "mga_macros.h" #include "mga_dri.h" #include "mga_sarea.h" +#include "mga_common.h" #define _XF86DRI_SERVER_ #include "GL/glxtokens.h" @@ -321,14 +322,14 @@ static Bool MGAInitVisualConfigs( ScreenPtr pScreen ) } static Bool MGACreateContext( ScreenPtr pScreen, VisualPtr visual, - drmContext hwContext, void *pVisualConfigPriv, + drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore ) { /* Nothing yet */ return TRUE; } -static void MGADestroyContext( ScreenPtr pScreen, drmContext hwContext, +static void MGADestroyContext( ScreenPtr pScreen, drm_context_t hwContext, DRIContextType contextStore ) { /* Nothing yet */ @@ -514,8 +515,10 @@ static void MGAWakeupHandler( int screenNum, pointer wakeupData, { ScreenPtr pScreen = screenInfo.screens[screenNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); - if ( xf86IsEntityShared( pScrn->entityList[0] ) ) { + if ( xf86IsEntityShared( pScrn->entityList[0] ) + && pMga->DualHeadEnabled) { MGASwapContextShared( pScreen ); } else { MGASwapContext( pScreen ); @@ -809,7 +812,7 @@ static Bool MGADRIMapInit( ScreenPtr pScreen ) pMGADRIServer->registers.size = MGAIOMAPSIZE; if ( drmAddMap( pMga->drmFD, - (drmHandle)pMga->IOAddress, + (drm_handle_t)pMga->IOAddress, pMGADRIServer->registers.size, DRM_REGISTERS, DRM_READ_ONLY, &pMGADRIServer->registers.handle ) < 0 ) { @@ -1040,11 +1043,15 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) pDRIInfo->drmDriverName = MGAKernelDriverName; pDRIInfo->clientDriverName = MGAClientDriverName; - pDRIInfo->busIdString = xalloc(64); - sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d", - ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum ); + if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) { + pDRIInfo->busIdString = DRICreatePCIBusID(pMga->PciInfo); + } else { + pDRIInfo->busIdString = xalloc(64); + sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d", + ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum, + ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum, + ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum ); + } pDRIInfo->ddxDriverMajorVersion = MGA_MAJOR_VERSION; pDRIInfo->ddxDriverMinorVersion = MGA_MINOR_VERSION; pDRIInfo->ddxDriverPatchVersion = MGA_PATCHLEVEL; @@ -1110,7 +1117,8 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) pDRIInfo->CreateContext = MGACreateContext; pDRIInfo->DestroyContext = MGADestroyContext; - if ( xf86IsEntityShared( pScrn->entityList[0] ) ) { + if ( xf86IsEntityShared( pScrn->entityList[0] ) + && pMga->DualHeadEnabled) { pDRIInfo->SwapContext = MGADRISwapContextShared; } else { pDRIInfo->SwapContext = MGADRISwapContext; diff --git a/src/mga_dri.h b/src/mga_dri.h index fdd1272..6d2addc 100644 --- a/src/mga_dri.h +++ b/src/mga_dri.h @@ -32,7 +32,6 @@ #define __MGA_DRI_H__ #include "xf86drm.h" -#include "mga_common.h" #define MGA_DEFAULT_AGP_MODE 1 #define MGA_MAX_AGP_MODE 4 diff --git a/src/mga_driver.c b/src/mga_driver.c index 7e45fc4..c2c3724 100644 --- a/src/mga_driver.c +++ b/src/mga_driver.c @@ -47,11 +47,6 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.244tsi Exp $ */ -/* - * This is a first cut at a non-accelerated version to work with the - * new server design (DHD). - */ - /* All drivers should typically include these */ #include "xf86.h" @@ -88,6 +83,7 @@ #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" +#include "mga_maven.h" #include "xaa.h" #include "xf86cmap.h" @@ -251,7 +247,7 @@ static const char *vgahwSymbols[] = { "vgaHWSetMmioFuncs", "vgaHWUnlock", "vgaHWUnmapMem", - "vgaHWddc1SetSpeed", + "vgaHWddc1SetSpeedWeak", NULL }; @@ -271,7 +267,7 @@ static const char *xaaSymbols[] = { "XAACachePlanarMonoStipple", "XAACreateInfoRec", "XAADestroyInfoRec", - "XAAFallbackOps", + "XAAGetFallbackOps", "XAAInit", "XAAMoveDWORDS", "XAA_888_plus_PICT_a8_to_8888", @@ -325,6 +321,7 @@ static const char *driSymbols[] = { "DRIScreenInit", "DRIUnlock", "GlxSetVisualConfigs", + "DRICreatePCIBusID", NULL }; #endif @@ -368,22 +365,22 @@ static const char *int10Symbols[] = { }; static const char *fbdevHWSymbols[] = { - "fbdevHWAdjustFrame", + "fbdevHWAdjustFrameWeak", "fbdevHWEnterVT", "fbdevHWGetVidmem", "fbdevHWInit", - "fbdevHWLeaveVT", - "fbdevHWLoadPalette", + "fbdevHWLeaveVTWeak", + "fbdevHWLoadPaletteWeak", "fbdevHWMapMMIO", "fbdevHWMapVidmem", "fbdevHWModeInit", "fbdevHWRestore", "fbdevHWSave", - "fbdevHWSwitchMode", + "fbdevHWSwitchModeWeak", "fbdevHWUnmapMMIO", "fbdevHWUnmapVidmem", "fbdevHWUseBuildinMode", - "fbdevHWValidMode", + "fbdevHWValidModeWeak", NULL }; @@ -413,7 +410,7 @@ static XF86ModuleVersionInfo mgaVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, MGA_MAJOR_VERSION, MGA_MINOR_VERSION, MGA_PATCHLEVEL, ABI_CLASS_VIDEODRV, /* This is a video driver */ ABI_VIDEODRV_VERSION, @@ -711,10 +708,6 @@ MGAReadBios(ScrnInfoPtr pScrn) pBios = &pMga->Bios; pBios2 = &pMga->Bios2; - /* Get the output mode set by the BIOS */ - xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress + 0x7ff1u, - sizeof(CARD8), &pMga->BiosOutputMode); - /* * If the BIOS address was probed, it was found from the PCI config * space. If it was given in the config file, try to guess when it @@ -738,6 +731,9 @@ MGAReadBios(ScrnInfoPtr pScrn) return; } + /* Get the output mode set by the BIOS */ + pMga->BiosOutputMode = BIOS[0x7ff1]; + /* Get the video BIOS info block */ if (strncmp((char *)(&BIOS[45]), "MATROX", 6)) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, @@ -995,9 +991,8 @@ MGAdoDDC(ScrnInfoPtr pScrn) } else { /* ddc module not found, we can do without it */ pMga->ddc1Read = NULL; - - /* Without DDC, we have no use for the I2C bus */ - pMga->i2cInit = NULL; + pMga->DDC_Bus1 = NULL; + pMga->DDC_Bus2 = NULL; return NULL; } } else @@ -1012,7 +1007,8 @@ MGAdoDDC(ScrnInfoPtr pScrn) } else { /* i2c module not found, we can do without it */ pMga->i2cInit = NULL; - pMga->I2C = NULL; + pMga->DDC_Bus1 = NULL; + pMga->DDC_Bus2 = NULL; } } #endif /* MGAuseI2C */ @@ -1032,7 +1028,7 @@ MGAdoDDC(ScrnInfoPtr pScrn) return NULL; } else { /* XXX Need to write an MGA mode ddc1SetSpeed */ - if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeed) { + if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) { pMga->DDC1SetSpeed = NULL; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "DDC1 disabled - chip not in VGA mode\n"); @@ -1045,47 +1041,58 @@ MGAdoDDC(ScrnInfoPtr pScrn) /* It is now safe to talk to the card */ #if MGAuseI2C - /* Initialize I2C bus - used by DDC if available */ + /* Initialize I2C buses - used by DDC if available */ if (pMga->i2cInit) { pMga->i2cInit(pScrn); } - /* Read and output monitor info using DDC2 over I2C bus */ - if (pMga->I2C) { - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->I2C); + + /* DDC for second head... */ + if (pMga->SecondCrtc && pMga->DDC_Bus2) { + MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus2); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", (void *)MonInfo); xf86PrintEDID(MonInfo); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n"); + xf86SetDDCproperties(pScrn, MonInfo); + return MonInfo; } - if (!MonInfo) -#endif /* MGAuseI2C */ - /* Read and output monitor info using DDC1 */ - if (pMga->ddc1Read && pMga->DDC1SetSpeed) { - MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, - pMga->DDC1SetSpeed, - pMga->ddc1Read ) ; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", - (void *)MonInfo); - xf86PrintEDID( MonInfo ); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n"); - } - if (!MonInfo){ - vbeInfoPtr pVbe; - if (xf86LoadSubModule(pScrn, "vbe")) { - pVbe = VBEInit(NULL,pMga->pEnt->index); - MonInfo = vbeDoEDID(pVbe, NULL); - vbeFree(pVbe); - - if (MonInfo){ - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBE DDC Monitor info: %p\n", - (void *)MonInfo); - xf86PrintEDID( MonInfo ); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n"); - } - } - } - + else { + /* Its the first head... */ + if (pMga->DDC_Bus1) { + MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus1); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", MonInfo); + xf86PrintEDID(MonInfo); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n"); + } + if (!MonInfo) +#endif /* MGAuseI2C */ + /* Read and output monitor info using DDC1 */ + if (pMga->ddc1Read && pMga->DDC1SetSpeed) { + MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, + pMga->DDC1SetSpeed, + pMga->ddc1Read ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", MonInfo); + xf86PrintEDID( MonInfo ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n"); + } + if (!MonInfo){ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,pMga->pEnt->index); + MonInfo = vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); + + if (MonInfo){ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBE DDC Monitor info: %p\n", MonInfo); + xf86PrintEDID( MonInfo ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n"); + } + } + } +#if MGAuseI2C + } +#endif /* Restore previous state and unmap MGA memory and MMIO areas */ MGARestore(pScrn); MGAUnmapMem(pScrn); @@ -1169,6 +1176,30 @@ MGAProbeDDC(ScrnInfoPtr pScrn, int index) } } +Bool +MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if (!pMga->Maven) return FALSE; + + /* FIXME: Using private interfaces for the moment until a more + * flexible xf86I2CWriteRead() variant shows up for us + * + * MAVEN does _not_ like a start bit in the middle of its transaction + * MAVEN does _not_ like ACK at the end of the transaction + */ + + if (!pMga->Maven_Bus->I2CStart(pMga->Maven_Bus, pMga->Maven->ByteTimeout)) return FALSE; + if (!pMga->Maven_Bus->I2CPutByte(pMga->Maven, MAVEN_READ)) return FALSE; + if (!pMga->Maven_Bus->I2CPutByte(pMga->Maven, reg)) return FALSE; + pMga->Maven_Bus->I2CStop(pMga->Maven); + if (!pMga->Maven_Bus->I2CGetByte(pMga->Maven, val, 0)) return FALSE; + pMga->Maven_Bus->I2CStop(pMga->Maven); + + return TRUE; +} + /* Mandatory */ static Bool MGAPreInit(ScrnInfoPtr pScrn, int flags) @@ -1660,11 +1691,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(fbdevHWSymbols, NULL); if (!fbdevHWInit(pScrn, pMga->PciInfo, NULL)) return FALSE; - pScrn->SwitchMode = fbdevHWSwitchMode; - pScrn->AdjustFrame = fbdevHWAdjustFrame; + pScrn->SwitchMode = fbdevHWSwitchModeWeak(); + pScrn->AdjustFrame = fbdevHWAdjustFrameWeak(); pScrn->EnterVT = MGAEnterVTFBDev; - pScrn->LeaveVT = fbdevHWLeaveVT; - pScrn->ValidMode = fbdevHWValidMode; + pScrn->LeaveVT = fbdevHWLeaveVTWeak(); + pScrn->ValidMode = fbdevHWValidModeWeak(); } pMga->Rotate = 0; if ((s = xf86GetOptValString(pMga->Options, OPTION_ROTATE))) { @@ -3396,7 +3427,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) else f = CMAP_RELOAD_ON_MODE_SWITCH; if(!xf86HandleColormaps(pScreen, 256, 8, - (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f)) + pMga->FBDev ? fbdevHWLoadPaletteWeak() : MGAdac->LoadPalette, + NULL, f)) return FALSE; if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */ @@ -3973,6 +4005,8 @@ MGASaveScreen(ScreenPtr pScreen, int mode) * MGADisplayPowerManagementSet -- * * Sets VESA Display Power Management Signaling (DPMS) Mode. + * + * XXX This needs fixing for sync-on-green! */ void MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, @@ -4019,12 +4053,55 @@ MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) { MGAPtr pMga = MGAPTR(pScrn); - CARD32 crtc2 = 0; + CARD32 val = INREG(MGAREG_C2CTL); + + if (PowerManagementMode==DPMSModeOn) { + /* Enable CRTC2 */ + val |= 0x1; + val &= ~(0x8); + OUTREG(MGAREG_C2CTL, val); + /* Restore normal MAVEN values */ + if (pMga->Maven) { + /* if TV MODE -- for later implementation + MAVW(MONEN, 0xb3); + MAVW(MONSET, 0x20); + MAVW(OUTMODE, 0x08); output: SVideo/Composite + MAVW(STABLE, 0x02); makes picture stable? + fixme? linux uses 0x14... + MAVW(TEST, (MAVR(TEST) & 0x10)); + + */ + /* else monitor mode */ + + xf86I2CWriteByte(pMga->Maven, MGAMAV_MONEN, 0xb2); + /* must be set to this in monitor mode */ + xf86I2CWriteByte(pMga->Maven, MGAMAV_MONSET, 0x20); + /* output: monitor mode */ + xf86I2CWriteByte(pMga->Maven, MGAMAV_OUTMODE, 0x03); + /* makes picture stable? */ + xf86I2CWriteByte(pMga->Maven, MGAMAV_STABLE, 0x22); + /* turn off test signal */ + xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x00); + } + } + else { + /* Disable CRTC2 video */ + val |= 0x8; + val &= ~(0x1); + OUTREG(MGAREG_C2CTL, val); + + /* Disable MAVEN display */ + if (pMga->Maven) { + /* In order to blank the 2nd display, we must set some MAVEN registers. + * It seems that not always the same values work on different hardware so + * we try a few different (possibly redundant) ones. */ + /* xf86I2CWriteByte(pMga->Maven, MGAMAV_STABLE, 0x6a); */ + /* xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x03); */ + /* xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x10); */ + xf86I2CWriteByte(pMga->Maven, MGAMAV_OUTMODE, 0x80); + } - if (PowerManagementMode != DPMSModeOn) - crtc2 = 0x8; /* c2pixclkdis */ - crtc2 |= INREG(MGAREG_C2CTL) & ~0x8; - OUTREG(MGAREG_C2CTL, crtc2); + } } diff --git a/src/mga_halmod.c b/src/mga_halmod.c index a5bb425..61ef298 100644 --- a/src/mga_halmod.c +++ b/src/mga_halmod.c @@ -15,7 +15,7 @@ static XF86ModuleVersionInfo halVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, HAL_MAJOR_VERSION, HAL_MINOR_VERSION, HAL_PATCHLEVEL, ABI_CLASS_VIDEODRV, /* This is a video driver */ ABI_VIDEODRV_VERSION, diff --git a/src/mga_maven.h b/src/mga_maven.h new file mode 100644 index 0000000..219d91e --- /dev/null +++ b/src/mga_maven.h @@ -0,0 +1,80 @@ +#define MODULE_BIT 0x00004000 + +/* Maven bus address */ +#define MAVEN_WRITE (0x1B<<1) +#define MAVEN_READ ((0x1B<<1)|1) + +#define I2C_CLOCK 0x20 +#define I2C_DATA 0x10 + +/* MGA-TVO-C I2C (G200), Maven (G400) */ +#define I2C_CLOCK 0x20 +#define I2C_DATA 0x10 +/* primary head DDC for Mystique(?), G100, G200, G400 */ +#define DDC1_CLK 0x08 +#define DDC1_DATA 0x02 +/* primary head DDC for Millennium, Millennium II */ +#define DDC1B_CLK 0x10 +#define DDC1B_DATA 0x04 +/* secondary head DDC for G400, G450 and G550 */ +#define DDC2_CLK 0x04 +#define DDC2_DATA 0x01 + +/*MAVEN registers (<= G400) */ +#define MGAMAV_PGM 0x3E +#define MGAMAV_PIXPLLM 0x80 +#define MGAMAV_PIXPLLN 0x81 +#define MGAMAV_PIXPLLP 0x82 +#define MGAMAV_GAMMA1 0x83 +#define MGAMAV_GAMMA2 0x84 +#define MGAMAV_GAMMA3 0x85 +#define MGAMAV_GAMMA4 0x86 +#define MGAMAV_GAMMA5 0x87 +#define MGAMAV_GAMMA6 0x88 +#define MGAMAV_GAMMA7 0x89 +#define MGAMAV_GAMMA8 0x8A +#define MGAMAV_GAMMA9 0x8B +#define MGAMAV_MONSET 0x8C +#define MGAMAV_TEST 0x8D +#define MGAMAV_WREG_0X8E_L 0x8E +#define MGAMAV_WREG_0X8E_H 0x8F +#define MGAMAV_HSCALETV 0x90 +#define MGAMAV_TSCALETVL 0x91 +#define MGAMAV_TSCALETVH 0x92 +#define MGAMAV_FFILTER 0x93 +#define MGAMAV_MONEN 0x94 +#define MGAMAV_RESYNC 0x95 +#define MGAMAV_LASTLINEL 0x96 +#define MGAMAV_LASTLINEH 0x97 +#define MGAMAV_WREG_0X98_L 0x98 +#define MGAMAV_WREG_0X98_H 0x99 +#define MGAMAV_HSYNCLENL 0x9A +#define MGAMAV_HSYNCLENH 0x9B +#define MGAMAV_HSYNCSTRL 0x9C +#define MGAMAV_HSYNCSTRH 0x9D +#define MGAMAV_HDISPLAYL 0x9E +#define MGAMAV_HDISPLAYH 0x9F +#define MGAMAV_HTOTALL 0xA0 +#define MGAMAV_HTOTALH 0xA1 +#define MGAMAV_VSYNCLENL 0xA2 +#define MGAMAV_VSYNCLENH 0xA3 +#define MGAMAV_VSYNCSTRL 0xA4 +#define MGAMAV_VSYNCSTRH 0xA5 +#define MGAMAV_VDISPLAYL 0xA6 +#define MGAMAV_VDISPLAYH 0xA7 +#define MGAMAV_VTOTALL 0xA8 +#define MGAMAV_VTOTALH 0xA9 +#define MGAMAV_HVIDRSTL 0xAA +#define MGAMAV_HVIDRSTH 0xAB +#define MGAMAV_VVIDRSTL 0xAC +#define MGAMAV_VVIDRSTH 0xAD +#define MGAMAV_VSOMETHINGL 0xAE +#define MGAMAV_VSOMETHINGH 0xAF +#define MGAMAV_OUTMODE 0xB0 +#define MGAMAV_LOCK 0xB3 +#define MGAMAV_LUMA 0xB9 +#define MGAMAV_VDISPLAYTV 0xBE +#define MGAMAV_STABLE 0xBF +#define MGAMAV_HDISPLAYTV 0xC2 +#define MGAMAV_BREG_0XC6 0xC6 + diff --git a/src/mga_sarea.h b/src/mga_sarea.h index cb1c3e9..c5ffbbc 100644 --- a/src/mga_sarea.h +++ b/src/mga_sarea.h @@ -176,7 +176,7 @@ typedef struct { /* The current cliprects, or a subset thereof. */ - XF86DRIClipRectRec boxes[MGA_NR_SAREA_CLIPRECTS]; + drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS]; unsigned int nbox; /* Information about the most recently used 3d drawable. The @@ -197,7 +197,7 @@ typedef struct { unsigned int exported_nback; int exported_back_x, exported_front_x, exported_w; int exported_back_y, exported_front_y, exported_h; - XF86DRIClipRectRec exported_boxes[MGA_NR_SAREA_CLIPRECTS]; + drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS]; /* Counters for aging textures and for client-side throttling. */ diff --git a/src/mga_storm.c b/src/mga_storm.c index aa14f6f..7661596 100644 --- a/src/mga_storm.c +++ b/src/mga_storm.c @@ -745,7 +745,7 @@ MGANAME(AccelInit)(ScreenPtr pScreen) infoPtr->SubsequentScreenToScreenColorExpandFill = MGANAME(SubsequentPlanarScreenToScreenColorExpandFill); infoPtr->CacheColorExpandDensity = PSZ; - infoPtr->CacheMonoStipple = XAACachePlanarMonoStipple; + infoPtr->CacheMonoStipple = XAAGetCachePlanarMonoStipple(); /* It's faster to blit the stipples if you have fastbilt */ if(pMga->HasFBitBlt) infoPtr->ScreenToScreenColorExpandFillFlags = TRANSPARENCY_ONLY; @@ -1076,8 +1076,8 @@ MGAStormSync(ScrnInfoPtr pScrn) CHECK_DMA_QUIESCENT(pMga, pScrn); - /* This reportedly causes a freeze for the Mystique. */ - if (pMga->Chipset != PCI_CHIP_MGA1064) + /* MGAISBUSY() reportedly causes a freeze for Mystique revision 2 and older */ + if (!(pMga->Chipset == PCI_CHIP_MGA1064 && (pMga->ChipRev >= 0 && pMga->ChipRev <= 2))) while(MGAISBUSY()); /* flush cache before a read (mga-1064g 5.1.6) */ OUTREG8(MGAREG_CRTC_INDEX, 0); @@ -2366,7 +2366,7 @@ MGAPolyPoint ( if(!numRects) return; if(numRects != 1) { - XAAFallbackOps.PolyPoint(pDraw, pGC, mode, npt, ppt); + XAAGetFallbackOps()->PolyPoint(pDraw, pGC, mode, npt, ppt); return; } @@ -2419,7 +2419,7 @@ MGAValidatePolyPoint( MGAPtr pMga = MGAPTR(pScrn); Bool fullPlanemask = TRUE; - pGC->ops->PolyPoint = XAAFallbackOps.PolyPoint; + pGC->ops->PolyPoint = XAAGetFallbackOps()->PolyPoint; if((pGC->planemask & pMga->AccelInfoRec->FullPlanemask) != pMga->AccelInfoRec->FullPlanemask) |