From 079a0913be0ed3d66c6ca2820bfdc65b80da479c Mon Sep 17 00:00:00 2001 From: Xavier Bachelot Date: Wed, 10 Oct 2007 10:14:07 +0000 Subject: sync with experimental branch (changeset 401-403,405-407) --- src/via_bios.h | 2 + src/via_driver.c | 139 +++++++++++++++++++++++++++++++++---------------------- src/via_id.c | 4 +- src/via_mode.c | 57 +++++++++++++++-------- src/via_swov.c | 14 ++++-- src/via_vbe.c | 30 +++++------- 6 files changed, 149 insertions(+), 97 deletions(-) (limited to 'src') diff --git a/src/via_bios.h b/src/via_bios.h index ba735ed8ea44..0b3f8f35836d 100644 --- a/src/via_bios.h +++ b/src/via_bios.h @@ -158,6 +158,8 @@ CARD32 ViaGetMemoryBandwidth(ScrnInfoPtr pScrn); ModeStatus ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); void ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode); void ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode); +void ViaModeSecondaryVGAOffset(ScrnInfoPtr pScrn); +void ViaModeSecondaryVGAFetchCount(ScrnInfoPtr pScrn, int width); void ViaLCDPower(ScrnInfoPtr pScrn, Bool On); void ViaTVPower(ScrnInfoPtr pScrn, Bool On); void ViaTVSave(ScrnInfoPtr pScrn); diff --git a/src/via_driver.c b/src/via_driver.c index af67b4f326cf..e688b13ea9d7 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -721,7 +721,9 @@ static Bool VIASetupDefaultOptions(ScrnInfoPtr pScrn) switch (pVia->Chipset) { case VIA_KM400: - pVia->DRIIrqEnable = FALSE; + /* IRQ is not broken on KM400A */ + if (pVia->ChipRev < 0x80) + pVia->DRIIrqEnable = FALSE; break; case VIA_K8M800: pVia->DRIIrqEnable = FALSE; @@ -980,7 +982,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) pScrn->videoRam = pEnt->device->videoRam; else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Video Memory Size in Option is %d KB, Detect is %d KB!", + "Video Memory Size in Option is %d KB, Detect is %d KB!\n", pScrn->videoRam, pEnt->device->videoRam); } } @@ -1431,28 +1433,36 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) } } - /* Detect amount of installed RAM */ - if (pScrn->videoRam < 16384 || pScrn->videoRam > 65536) { - if(pVia->Chipset == VIA_CLE266) { - bMemSize = hwp->readSeq(hwp, 0x34); - if (!bMemSize) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "CR34 says nothing; trying CR39.\n"); - bMemSize = hwp->readSeq(hwp, 0x39); - } - } else - bMemSize = hwp->readSeq(hwp, 0x39); - - if (bMemSize > 16 && bMemSize <= 128) - pScrn->videoRam = (bMemSize + 1) << 9; - else if (bMemSize > 0 && bMemSize < 31) - pScrn->videoRam = bMemSize << 12; - else { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Memory size detection failed: using 16MB.\n"); - pScrn->videoRam = 16 << 10; /* Assume the basic 16MB */ - } - } + switch (pVia->Chipset) { + case VIA_CLE266: + case VIA_KM400: + pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 0), 0xE1) & 0x70 ) >> 4 ) ) << 10 ; + break; + case VIA_PM800: + case VIA_VM800: + case VIA_K8M800: + pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 3), 0xA1) & 0x70 ) >> 4 ) ) << 10 ; + break; + case VIA_K8M890: + case VIA_P4M900: + case VIA_CX700: + pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 3), 0xA1) & 0x70 ) >> 4 ) ) << 12 ; + break; + default: + /* Detect amount of installed RAM */ + if (pScrn->videoRam < 16384 || pScrn->videoRam > 65536) { + bMemSize = hwp->readSeq(hwp, 0x39); + if (bMemSize > 16 && bMemSize <= 128) + pScrn->videoRam = (bMemSize + 1) << 9; + else if (bMemSize > 0 && bMemSize < 31) + pScrn->videoRam = bMemSize << 12; + else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Memory size detection failed: using 16MB.\n"); + pScrn->videoRam = 16 << 10; /* Assume the basic 16MB */ + } + } + } /* Split FB for SAMM */ /* FIXME: For now, split FB into two equal sections. This should @@ -2622,15 +2632,40 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) pVia->OverlaySupported = FALSE; - if (!vgaHWInit(pScrn, mode)) - return FALSE; - pScrn->vtSema = TRUE; - if (!pVia->IsSecondary) - ViaModePrimary(pScrn, mode); - else - ViaModeSecondary(pScrn, mode); + if (!pVia->pVbe) { + + if (!vgaHWInit(pScrn, mode)) + return FALSE; + + if (!pVia->IsSecondary) + ViaModePrimary(pScrn, mode); + else + ViaModeSecondary(pScrn, mode); + + } else { + + if (!ViaVbeSetMode(pScrn, mode)) + return FALSE; + /* + * FIXME: pVia->IsSecondary is not working here. + * We should be able to detect when the display + * is using the secondary head. + * TODO: This should be enabled for others + * chipsets as well + */ + if (pVia->Chipset == VIA_P4M900 && + pVia->pBIOSInfo->PanelActive) { + /* + * Since we are using virtual, we need to adjust + * the offset to match the framebuffer alignment + */ + if (pScrn->displayWidth != mode->HDisplay) + ViaModeSecondaryVGAOffset(pScrn); + // ViaModeSecondaryVGAFixAlignment(pScrn, mode); + } + } /* Enable the graphics engine. */ if (!pVia->NoAccel) { @@ -2743,34 +2778,31 @@ VIAAdjustFrame(int scrnIndex, int x, int y, int flags) if (pVia->pVbe) { ViaVbeAdjustFrame(scrnIndex, x, y, flags); - VIAVidAdjustFrame(pScrn, x, y); - return; - } - - Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8); + } else { - /* now program the start address registers */ - if (pVia->IsSecondary) { - Base = (Base + pScrn->fbOffset) >> 3; - ViaCrtcMask(hwp, 0x62, (Base & 0x7F) << 1 , 0xFE); - hwp->writeCrtc(hwp, 0x63, (Base & 0x7F80) >> 7); - hwp->writeCrtc(hwp, 0x64, (Base & 0x7F8000) >> 15); - } - else { - Base = Base >> 1; - hwp->writeCrtc(hwp, 0x0C, (Base & 0xFF00) >> 8); - hwp->writeCrtc(hwp, 0x0D, Base & 0xFF); - hwp->writeCrtc(hwp, 0x34, (Base & 0xFF0000) >> 16); + Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8); + + /* now program the start address registers */ + if (pVia->IsSecondary) { + Base = (Base + pScrn->fbOffset) >> 3; + ViaCrtcMask(hwp, 0x62, (Base & 0x7F) << 1 , 0xFE); + hwp->writeCrtc(hwp, 0x63, (Base & 0x7F80) >> 7); + hwp->writeCrtc(hwp, 0x64, (Base & 0x7F8000) >> 15); + } else { + Base = Base >> 1; + hwp->writeCrtc(hwp, 0x0C, (Base & 0xFF00) >> 8); + hwp->writeCrtc(hwp, 0x0D, Base & 0xFF); + hwp->writeCrtc(hwp, 0x34, (Base & 0xFF0000) >> 16); #if 0 /* The CLE266A doesn't have this implemented, it seems. -- Luc */ ViaCrtcMask(hwp, 0x48, Base >> 24, 0x03); #endif + } } VIAVidAdjustFrame(pScrn, x, y); } - static Bool VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { @@ -2794,11 +2826,8 @@ VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags) if (pVia->VQEnable) viaDisableVQ(pScrn); - - if (pVia->pVbe) - ret = ViaVbeSetMode(pScrn, mode); - else - ret = VIAWriteMode(pScrn, mode); + + ret = VIAWriteMode(pScrn, mode); #ifdef XF86DRI if (pVia->directRenderingEnabled) { @@ -2806,7 +2835,7 @@ VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags) VIADRIRingBufferInit(pScrn); DRIUnlock(screenInfo.screens[scrnIndex]); } -#endif +#endif return ret; } diff --git a/src/via_id.c b/src/via_id.c index da5dc039879a..a2bda6a8d532 100644 --- a/src/via_id.c +++ b/src/via_id.c @@ -177,7 +177,7 @@ static struct ViaCardIdStruct ViaCardId[] = { {"VIA VT3344 (VM800) - EPIA EN", VIA_VM800, 0x1106, 0x3344, VIA_DEVICE_CRT | VIA_DEVICE_TV}, {"Gigabyte GA-8VM800M-775", VIA_VM800, 0x1458, 0xD000, VIA_DEVICE_CRT}, {"MSI PM8M-V", VIA_VM800, 0x1462, 0x7104, VIA_DEVICE_CRT}, - {"MSI Fuzzy CN700T", VIA_VM800, 0x1462, 0x7199, VIA_DEVICE_CRT | VIA_DEVICE_TV}, + {"MSI Fuzzy CN700/CN700T/CN700G", VIA_VM800, 0x1462, 0x7199, VIA_DEVICE_CRT | VIA_DEVICE_TV}, {"MSI PM8M3-V", VIA_VM800, 0x1462, 0x7211, VIA_DEVICE_CRT}, {"MSI PM8PM", VIA_VM800, 0x1462, 0x7222, VIA_DEVICE_CRT}, {"RoverBook Partner W500", VIA_VM800, 0x1509, 0x4330, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, @@ -195,12 +195,14 @@ static struct ViaCardIdStruct ViaCardId[] = { {"Shuttle FX22V1", VIA_K8M890, 0x1297, 0x3080, VIA_DEVICE_CRT}, {"MSI K9VGM-V", VIA_K8M890, 0x1462, 0x7253, VIA_DEVICE_CRT}, {"Averatec 226x", VIA_K8M890, 0x14FF, 0xA002, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, + {"Fujitsu/Siemens Amilo La 1703", VIA_K8M890, 0x1734, 0x10D9, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, /* P4M900 */ {"Asustek P5VD2-VM", VIA_P4M900, 0x1043, 0x81CE, VIA_DEVICE_CRT}, {"VIA VT3364 (P4M900)", VIA_P4M900, 0x1106, 0x3371, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Gigabyte GA-VM900M", VIA_P4M900, 0x1458, 0xD000, VIA_DEVICE_CRT}, {"Everex NC1501/NC1503", VIA_P4M900, 0x1509, 0x1E30, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Clevo M660SE", VIA_P4M900, 0x1558, 0x0664, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, + {"Neo Endura 540SLe", VIA_P4M900, 0x1558, 0x5408, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Fujitsu/Siemens Amilo Pro V3515", VIA_P4M900, 0x1734, 0x10CB, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Fujitsu/Siemens Amilo Li1705", VIA_P4M900, 0x1734, 0x10F7, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, /* CX700 */ diff --git a/src/via_mode.c b/src/via_mode.c index c1839570ff8e..3d234937180c 100644 --- a/src/via_mode.c +++ b/src/via_mode.c @@ -1774,6 +1774,42 @@ ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode) hwp->disablePalette(hwp); } +void +ViaModeSecondaryVGAFetchCount(ScrnInfoPtr pScrn, int width) { + + vgaHWPtr hwp = VGAHWPTR(pScrn); + CARD16 temp; + + /* fetch count */ + temp = (width * (pScrn->bitsPerPixel >> 3)) >> 3; + /* Make sure that this is 32byte aligned */ + if (temp & 0x03) { + temp += 0x03; + temp &= ~0x03; + } + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fetch Count: 0x%03X\n", temp)); + hwp->writeCrtc(hwp, 0x65, (temp >> 1) & 0xFF); + ViaCrtcMask(hwp, 0x67, temp >> 7, 0x0C); +} + +void +ViaModeSecondaryVGAOffset(ScrnInfoPtr pScrn) { + + vgaHWPtr hwp = VGAHWPTR(pScrn); + CARD16 temp; + + /* offset */ + temp = (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) >> 3; + if (temp & 0x03) { /* Make sure that this is 32byte aligned */ + temp += 0x03; + temp &= ~0x03; + } + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Offset: 0x%03X\n", temp)); + hwp->writeCrtc(hwp, 0x66, temp & 0xFF); + ViaCrtcMask(hwp, 0x67, temp >> 8, 0x03); + +} + /* * */ @@ -1901,26 +1937,9 @@ ViaModeSecondaryVGA(ScrnInfoPtr pScrn, DisplayModePtr mode) temp = mode->CrtcVSyncEnd; ViaCrtcMask(hwp, 0x5F, temp, 0x1F); - /* offset */ - temp = (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) >> 3; - if (temp & 0x03) { /* Make sure that this is 32byte aligned */ - temp += 0x03; - temp &= ~0x03; - } - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Offset: 0x%03X\n", temp)); - hwp->writeCrtc(hwp, 0x66, temp & 0xFF); - ViaCrtcMask(hwp, 0x67, temp >> 8, 0x03); + ViaModeSecondaryVGAOffset(pScrn); + ViaModeSecondaryVGAFetchCount(pScrn, mode->CrtcHDisplay); - /* fetch count */ - temp = (mode->CrtcHDisplay * (pScrn->bitsPerPixel >> 3)) >> 3; - /* Make sure that this is 32byte aligned */ - if (temp & 0x03) { - temp += 0x03; - temp &= ~0x03; - } - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fetch Count: 0x%03X\n", temp)); - hwp->writeCrtc(hwp, 0x65, (temp >> 1) & 0xFF); - ViaCrtcMask(hwp, 0x67, temp >> 7, 0x0C); } /* diff --git a/src/via_swov.c b/src/via_swov.c index 2a4d3018b07a..4dc04483fe51 100644 --- a/src/via_swov.c +++ b/src/via_swov.c @@ -1718,9 +1718,17 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag, DBG_DD(ErrorF("NEEDV1PREFETCH\n")); vidCtl |= V1_PREFETCH_ON_3336; } - - if (pVia->pBIOSInfo->PanelActive) { - vidCtl |= 0x80000000; + + /* + * FIXME: + * Enable video on secondary + */ + if (pVia->Chipset == VIA_P4M900 && + pVia->pBIOSInfo->PanelActive) { + /* V1_ON_SND_DISPLAY */ + vidCtl |= 0x80000000; + /* SECOND_DISPLAY_COLOR_KEY_ENABLE */ + compose |= 0x00010000 | 0x1 ; } viaOverlayGetV1V3Format(pVia, (videoFlag & VIDEO_1_INUSE) ? 1 : 3, diff --git a/src/via_vbe.c b/src/via_vbe.c index e7ce88c74deb..4122558bdeed 100644 --- a/src/via_vbe.c +++ b/src/via_vbe.c @@ -133,20 +133,20 @@ static Bool ViaVbeSetActiveDevices( ScrnInfoPtr pScrn, int mode, int refresh ) { } /* - * Sets the panel expansion mode + * Sets the panel mode (expand or center) */ -static Bool ViaVbeSetPanelExpansion(ScrnInfoPtr pScrn, Bool expanded) { +static Bool ViaVbeSetPanelMode(ScrnInfoPtr pScrn, Bool expand) { VIAPtr pVia = VIAPTR(pScrn); VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo; vbeInfoPtr pVbe = pVia->pVbe; - DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSetPanelExpansion\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSetPanelMode\n")); ViaVbeInitInt10(pVbe); pVbe->pInt10->ax = 0x4F14; pVbe->pInt10->bx = 0x0306; - pVbe->pInt10->cx = 0x80 | expanded; + pVbe->pInt10->cx = 0x80 | expand; xf86ExecX86int10(pVbe->pInt10); @@ -241,9 +241,14 @@ ViaVbeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) } } } else { + if (pBIOSInfo->PanelActive && !pVia->useLegacyVBE) { - if (!ViaVbeSetPanelExpansion(pScrn, !pBIOSInfo->Center)) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to set the panel expansion.\n"); + /* + * FIXME: should we always set the panel expansion? + * does it depend on the resolution? + */ + if (!ViaVbeSetPanelMode(pScrn, !pBIOSInfo->Center)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to set the panel mode.\n"); } } @@ -264,19 +269,6 @@ ViaVbeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) pScrn->vtSema = TRUE; -/* - pVia->Bpp = data->data->BitsPerPixel >> 3; - pVia->Bpl = data->data->XResolution * pVia->Bpp; -*/ - - if (!pVia->NoAccel) { -#ifdef XF86DRI || defined(VIA_HAVE_EXA) - VIAInitialize3DEngine(pScrn); -#endif - viaInitialize2DEngine(pScrn); - } - ViaVbeAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - return (TRUE); } -- cgit v1.2.3