[Openchrome-devel] xf86-video-openchrome: src/Makefile.am src/via_display.c src/via_driver.c src/via_driver.h src/via_lvds.c src/via_ums.h src/via_vbe.c
Kevin Brace
kevinbrace at kemper.freedesktop.org
Fri Mar 18 13:46:22 UTC 2016
src/Makefile.am | 1
src/via_display.c | 181 +++++++----------------
src/via_driver.c | 24 ---
src/via_driver.h | 17 --
src/via_lvds.c | 94 +++---------
src/via_ums.h | 11 -
src/via_vbe.c | 419 ------------------------------------------------------
7 files changed, 87 insertions(+), 660 deletions(-)
New commits:
commit d6a65df0e31657495fbdd488c06780b8b33fdccc
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Fri Mar 18 06:11:00 2016 -0700
Removal of VESA BIOS Extension (VBE) support
VBE support should have been discontinued long time ago, but
remained in the code for some reason. It adds nothing but
unnecessary code maintenance burden on the developers. The support
for VBE is now discontinued.
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index c3c38cc..629f89e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,7 +65,6 @@ openchrome_drv_la_SOURCES = \
via_xv_overlay.c \
via_xv_overlay.h \
via_ums.c \
- via_vbe.c \
via_vgahw.c \
via_vgahw.h \
via_xv.c \
diff --git a/src/via_display.c b/src/via_display.c
index 7ccb3ff..fa48728 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -827,29 +827,26 @@ iga1_crtc_dpms(xf86CrtcPtr crtc, int mode)
VIAPtr pVia = VIAPTR(pScrn);
VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
- if (pVia->pVbe) {
- ViaVbeDPMS(pScrn, mode);
- } else {
- switch (mode) {
- case DPMSModeOn:
- if (pBIOSInfo->SimultaneousEnabled)
- ViaDisplayEnableSimultaneous(pScrn);
- break;
+ switch (mode) {
+ case DPMSModeOn:
+ if (pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayEnableSimultaneous(pScrn);
+ break;
- case DPMSModeStandby:
- case DPMSModeSuspend:
- case DPMSModeOff:
- if (pBIOSInfo->SimultaneousEnabled)
- ViaDisplayDisableSimultaneous(pScrn);
- break;
+ case DPMSModeStandby:
+ case DPMSModeSuspend:
+ case DPMSModeOff:
+ if (pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayDisableSimultaneous(pScrn);
+ break;
- default:
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n",
- mode);
- break;
- }
- //vgaHWSaveScreen(pScrn->pScreen, mode);
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n",
+ mode);
+ break;
}
+ //vgaHWSaveScreen(pScrn->pScreen, mode);
+
}
static void
@@ -859,12 +856,7 @@ iga1_crtc_save(xf86CrtcPtr crtc)
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe && pVia->vbeSR) {
- ViaVbeSaveRestore(pScrn, MODE_SAVE);
- } else {
- VIASave(pScrn);
- }
-
+ VIASave(pScrn);
vgaHWUnlock(hwp);
}
@@ -875,10 +867,7 @@ iga1_crtc_restore(xf86CrtcPtr crtc)
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe && pVia->vbeSR)
- ViaVbeSaveRestore(pScrn, MODE_RESTORE);
- else
- VIARestore(pScrn);
+ VIARestore(pScrn);
/* A soft reset helps to avoid a 3D hang on VT switch. */
switch (pVia->Chipset) {
@@ -916,9 +905,6 @@ iga1_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
CARD32 temp;
ModeStatus modestatus;
- if (pVia->pVbe)
- return TRUE;
-
if ((mode->Clock < pScrn->clockRanges->minClock) ||
(mode->Clock > pScrn->clockRanges->maxClock)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -957,11 +943,7 @@ iga1_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
ScrnInfoPtr pScrn = crtc->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe) {
- ViaVbeAdjustFrame(pScrn, x, y);
- } else {
- ViaFirstCRTCSetStartingAddress(crtc, x, y);
- }
+ ViaFirstCRTCSetStartingAddress(crtc, x, y);
VIAVidAdjustFrame(pScrn, x, y);
}
@@ -973,22 +955,17 @@ iga1_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
ScrnInfoPtr pScrn = crtc->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- if (!pVia->pVbe) {
- if (!vgaHWInit(pScrn, adjusted_mode))
- return;
+ if (!vgaHWInit(pScrn, adjusted_mode))
+ return;
- ViaCRTCInit(pScrn);
- ViaModeFirstCRTC(pScrn, adjusted_mode);
+ ViaCRTCInit(pScrn);
+ ViaModeFirstCRTC(pScrn, adjusted_mode);
- if (pVia->pBIOSInfo->SimultaneousEnabled)
- ViaDisplayEnableSimultaneous(pScrn);
- else
- ViaDisplayDisableSimultaneous(pScrn);
+ if (pVia->pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayEnableSimultaneous(pScrn);
+ else
+ ViaDisplayDisableSimultaneous(pScrn);
- } else {
- if (!ViaVbeSetMode(pScrn, adjusted_mode))
- return;
- }
iga1_crtc_set_origin(crtc, crtc->x, crtc->y);
}
@@ -1251,29 +1228,25 @@ iga2_crtc_dpms(xf86CrtcPtr crtc, int mode)
VIAPtr pVia = VIAPTR(pScrn);
VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
- if (pVia->pVbe) {
- ViaVbeDPMS(pScrn, mode);
- } else {
- switch (mode) {
- case DPMSModeOn:
- if (pBIOSInfo->SimultaneousEnabled)
- ViaDisplayEnableSimultaneous(pScrn);
- break;
+ switch (mode) {
+ case DPMSModeOn:
+ if (pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayEnableSimultaneous(pScrn);
+ break;
- case DPMSModeStandby:
- case DPMSModeSuspend:
- case DPMSModeOff:
- if (pBIOSInfo->SimultaneousEnabled)
- ViaDisplayDisableSimultaneous(pScrn);
- break;
+ case DPMSModeStandby:
+ case DPMSModeSuspend:
+ case DPMSModeOff:
+ if (pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayDisableSimultaneous(pScrn);
+ break;
- default:
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n",
- mode);
- break;
- }
- //vgaHWSaveScreen(pScrn->pScreen, mode);
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n",
+ mode);
+ break;
}
+ //vgaHWSaveScreen(pScrn->pScreen, mode);
}
static void
@@ -1283,11 +1256,8 @@ iga2_crtc_save(xf86CrtcPtr crtc)
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe && pVia->vbeSR)
- ViaVbeSaveRestore(pScrn, MODE_SAVE);
- else
- VIASave(pScrn);
- vgaHWUnlock(hwp);
+ VIASave(pScrn);
+ vgaHWUnlock(hwp);
}
static void
@@ -1297,10 +1267,7 @@ iga2_crtc_restore(xf86CrtcPtr crtc)
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe && pVia->vbeSR)
- ViaVbeSaveRestore(pScrn, MODE_RESTORE);
- else
- VIARestore(pScrn);
+ VIARestore(pScrn);
vgaHWLock(hwp);
}
@@ -1324,9 +1291,6 @@ iga2_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
CARD32 temp;
ModeStatus modestatus;
- if (pVia->pVbe)
- return TRUE;
-
if ((mode->Clock < pScrn->clockRanges->minClock) ||
(mode->Clock > pScrn->clockRanges->maxClock)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -1365,11 +1329,7 @@ iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
ScrnInfoPtr pScrn = crtc->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe) {
- ViaVbeAdjustFrame(pScrn, x, y);
- } else {
- ViaSecondCRTCSetStartingAddress(crtc, x, y);
- }
+ ViaSecondCRTCSetStartingAddress(crtc, x, y);
VIAVidAdjustFrame(pScrn, x, y);
}
@@ -1380,22 +1340,18 @@ iga2_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
ScrnInfoPtr pScrn = crtc->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe) {
- if (!ViaVbeSetMode(pScrn, adjusted_mode))
- return;
- } else {
- if (!vgaHWInit(pScrn, adjusted_mode))
- return;
+ if (!vgaHWInit(pScrn, adjusted_mode))
+ return;
- ViaCRTCInit(pScrn);
- ViaModeSecondCRTC(pScrn, adjusted_mode);
- ViaSecondDisplayChannelEnable(pScrn);
+ ViaCRTCInit(pScrn);
+ ViaModeSecondCRTC(pScrn, adjusted_mode);
+ ViaSecondDisplayChannelEnable(pScrn);
+
+ if (pVia->pBIOSInfo->SimultaneousEnabled)
+ ViaDisplayEnableSimultaneous(pScrn);
+ else
+ ViaDisplayDisableSimultaneous(pScrn);
- if (pVia->pBIOSInfo->SimultaneousEnabled)
- ViaDisplayEnableSimultaneous(pScrn);
- else
- ViaDisplayDisableSimultaneous(pScrn);
- }
iga2_crtc_set_origin(crtc, crtc->x, crtc->y);
}
@@ -1710,23 +1666,6 @@ UMSCrtcInit(ScrnInfoPtr pScrn)
if (!xf86LoadSubModule(pScrn, "ddc"))
return FALSE;
- pVia->pVbe = NULL;
- if (pVia->useVBEModes) {
- /* VBE doesn't properly initialise int10 itself. */
- if (xf86LoadSubModule(pScrn, "int10") &&
- xf86LoadSubModule(pScrn, "vbe")) {
- pVia->pVbe = VBEExtendedInit(NULL, pVia->EntityIndex,
- SET_BIOS_SCRATCH |
- RESTORE_BIOS_SCRATCH);
- }
-
- if (!pVia->pVbe)
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "VBE initialisation failed."
- " Using builtin code to set modes.\n");
- else
- ConfiguredMonitor = vbeDoEDID(pVia->pVbe, NULL);
- }
-
/*
* Set up ClockRanges, which describe what clock ranges are
* available, and what sort of modes they can be used for.
@@ -1853,9 +1792,5 @@ UMSCrtcInit(ScrnInfoPtr pScrn)
ViaOutputsDetect(pScrn);
- if (pVia->pVbe) {
- if (!ViaVbeModePreInit(pScrn))
- return FALSE;
- }
return TRUE;
}
diff --git a/src/via_driver.c b/src/via_driver.c
index 14c363b..671fe21 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -166,7 +166,6 @@ typedef enum
OPTION_PRINTTVREGS,
OPTION_I2CSCAN,
#endif
- OPTION_VBEMODES,
OPTION_NOACCEL,
OPTION_ACCELMETHOD,
OPTION_EXA_NOCOMPOSITE,
@@ -191,7 +190,6 @@ typedef enum
OPTION_AGP_DMA,
OPTION_2D_DMA,
OPTION_XV_DMA,
- OPTION_VBE_SAVERESTORE,
OPTION_MAX_DRIMEM,
OPTION_AGPMEM,
OPTION_DISABLE_XV_BW_CHECK
@@ -203,7 +201,6 @@ static OptionInfoRec VIAOptions[] = {
{OPTION_PRINTTVREGS, "PrintTVRegs", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_I2CSCAN, "I2CScan", OPTV_BOOLEAN, {0}, FALSE},
#endif
- {OPTION_VBEMODES, "VBEModes", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE},
{OPTION_EXA_NOCOMPOSITE, "ExaNoComposite", OPTV_BOOLEAN, {0}, FALSE},
@@ -224,7 +221,6 @@ static OptionInfoRec VIAOptions[] = {
{OPTION_AGP_DMA, "EnableAGPDMA", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_2D_DMA, "NoAGPFor2D", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_XV_DMA, "NoXVDMA", OPTV_BOOLEAN, {0}, FALSE},
- {OPTION_VBE_SAVERESTORE, "VbeSaveRestore", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_DISABLE_XV_BW_CHECK, "DisableXvBWCheck", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_MAX_DRIMEM, "MaxDRIMem", OPTV_INTEGER, {0}, FALSE},
{OPTION_AGPMEM, "AGPMem", OPTV_INTEGER, {0}, FALSE},
@@ -427,9 +423,6 @@ VIAFreeRec(ScrnInfoPtr pScrn)
free(pBIOSInfo);
}
- if (VIAPTR(pScrn)->pVbe)
- vbeFree(VIAPTR(pScrn)->pVbe);
-
if (pVia->VideoRegs)
free(pVia->VideoRegs);
@@ -659,8 +652,6 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
pVia->agpEnable = TRUE;
pVia->dma2d = TRUE;
pVia->dmaXV = TRUE;
- pVia->useVBEModes = FALSE;
- pVia->vbeSR = FALSE;
#ifdef HAVE_DEBUG
pVia->disableXvBWCheck = FALSE;
#endif
@@ -677,7 +668,6 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
/* line buffer (limited to 800) is too small to do interpolation. */
pVia->swov.maxWInterp = 800;
pVia->swov.maxHInterp = 600;
- pVia->useLegacyVBE = TRUE;
pBIOSInfo->TVDIPort = VIA_DI_PORT_DVP1;
@@ -716,7 +706,6 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
case VIA_P4M900:
pVia->VideoEngine = VIDEO_ENGINE_CME;
pVia->agpEnable = FALSE;
- pVia->useLegacyVBE = FALSE;
/* FIXME: this needs to be tested */
pVia->dmaXV = FALSE;
pBIOSInfo->TVDIPort = VIA_DI_PORT_DVP0;
@@ -1337,19 +1326,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
"image transfer if DRI is enabled.\n",
(pVia->dmaXV) ? "" : "not ");
- //pVia->useVBEModes = FALSE;
- from = xf86GetOptValBool(VIAOptions, OPTION_VBEMODES, &pVia->useVBEModes)
- ? X_CONFIG : X_DEFAULT;
- xf86DrvMsg(pScrn->scrnIndex, from, "Will %senable VBE modes.\n",
- (pVia->useVBEModes) ? "" : "not ");
-
- //pVia->vbeSR = FALSE;
- from = xf86GetOptValBool(VIAOptions, OPTION_VBE_SAVERESTORE, &pVia->vbeSR)
- ? X_CONFIG : X_DEFAULT;
- xf86DrvMsg(pScrn->scrnIndex, from, "VBE VGA register save & restore "
- "will %sbe used\n\tif VBE modes are enabled.\n",
- (pVia->vbeSR) ? "" : "not ");
-
#ifdef HAVE_DEBUG
//pVia->disableXvBWCheck = FALSE;
from = xf86GetOptValBool(VIAOptions, OPTION_DISABLE_XV_BW_CHECK,
diff --git a/src/via_driver.h b/src/via_driver.h
index 4c17257..98bfb90 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -54,7 +54,6 @@
#include "xf86Crtc.h"
#include "xf86RandR12.h"
#include "xf86cmap.h"
-#include "vbe.h"
#ifdef HAVE_DRI
#define _XF86DRI_SERVER_
@@ -214,15 +213,6 @@ typedef struct _twodContext {
int clipY2;
} ViaTwodContext;
-typedef struct{
- /* textMode */
- CARD8 *state, *pstate; /* SVGA state */
- int statePage, stateSize, stateMode;
-
- /* vbe version */
- int major, minor;
-} ViaVbeModeInfo;
-
typedef struct _VIA {
VIARegRec SavedReg;
int Bpp, Bpl;
@@ -255,7 +245,6 @@ typedef struct _VIA {
Bool NoAccel;
Bool shadowFB;
Rotation rotate;
- Bool vbeSR;
int agpMem;
CreateScreenResourcesProcPtr CreateScreenResources;
@@ -271,12 +260,6 @@ typedef struct _VIA {
int ChipRev;
int EntityIndex;
- /* vbe */
- vbeInfoPtr pVbe;
- ViaVbeModeInfo vbeMode;
- Bool useVBEModes;
- Bool useLegacyVBE;
-
/* Support for shadowFB and rotation */
unsigned char* ShadowPtr;
diff --git a/src/via_lvds.c b/src/via_lvds.c
index ae7fc38..44ddb6b 100644
--- a/src/via_lvds.c
+++ b/src/via_lvds.c
@@ -379,38 +379,34 @@ via_lvds_dpms(xf86OutputPtr output, int mode)
ScrnInfoPtr pScrn = output->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- if (pVia->pVbe) {
- ViaVbePanelPower(pVia->pVbe, (mode == DPMSModeOn));
- } else {
- switch (mode) {
- case DPMSModeOn:
- switch (pVia->Chipset) {
- case VIA_P4M900:
- case VIA_CX700:
- case VIA_VX800:
- case VIA_VX855:
- case VIA_VX900:
- ViaLVDSPower(pScrn, TRUE);
- break;
- }
- ViaLCDPower(output, TRUE);
+ switch (mode) {
+ case DPMSModeOn:
+ switch (pVia->Chipset) {
+ case VIA_P4M900:
+ case VIA_CX700:
+ case VIA_VX800:
+ case VIA_VX855:
+ case VIA_VX900:
+ ViaLVDSPower(pScrn, TRUE);
break;
+ }
+ ViaLCDPower(output, TRUE);
+ break;
- case DPMSModeStandby:
- case DPMSModeSuspend:
- case DPMSModeOff:
- switch (pVia->Chipset) {
- case VIA_P4M900:
- case VIA_CX700:
- case VIA_VX800:
- case VIA_VX855:
- case VIA_VX900:
- ViaLVDSPower(pScrn, FALSE);
- break;
- }
- ViaLCDPower(output, FALSE);
+ case DPMSModeStandby:
+ case DPMSModeSuspend:
+ case DPMSModeOff:
+ switch (pVia->Chipset) {
+ case VIA_P4M900:
+ case VIA_CX700:
+ case VIA_VX800:
+ case VIA_VX855:
+ case VIA_VX900:
+ ViaLVDSPower(pScrn, FALSE);
break;
}
+ ViaLCDPower(output, FALSE);
+ break;
}
}
@@ -809,44 +805,12 @@ via_lvds_mode_set(xf86OutputPtr output, DisplayModePtr mode,
ScrnInfoPtr pScrn = output->scrn;
VIAPtr pVia = VIAPTR(pScrn);
- /*
- * 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 other chipsets as well.
- */
- if (pVia->pVbe) {
- if (!pVia->useLegacyVBE) {
- /*
- * FIXME: Should we always set the panel expansion?
- * Does it depend on the resolution?
- */
- if (!ViaVbeSetPanelMode(pScrn, !Panel->Center)) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Unable to set the panel mode.\n");
- }
- }
-
- switch (pVia->Chipset) {
- case VIA_P4M900:
- case VIA_VX800:
- case VIA_VX855:
- case VIA_VX900:
- /*
- * Since we are using virtual, we need to adjust
- * the offset to match the framebuffer alignment.
- */
- if (pScrn->displayWidth != adjusted_mode->CrtcHDisplay)
- ViaSecondCRTCHorizontalOffset(pScrn);
- break;
- }
+ if (Panel->Scale) {
+ ViaPanelScale(pScrn, mode->HDisplay, mode->VDisplay,
+ Panel->NativeWidth,
+ Panel->NativeHeight);
} else {
- if (Panel->Scale) {
- ViaPanelScale(pScrn, mode->HDisplay, mode->VDisplay,
- Panel->NativeWidth,
- Panel->NativeHeight);
- } else {
- ViaPanelScaleDisable(pScrn);
- }
+ ViaPanelScaleDisable(pScrn);
}
}
diff --git a/src/via_ums.h b/src/via_ums.h
index dee43fa..8b274a1 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -182,17 +182,6 @@ typedef struct _VIABIOSINFO {
} VIABIOSInfoRec, *VIABIOSInfoPtr;
-/* Function prototypes */
-/* via_vbe.c */
-void ViaVbeAdjustFrame(ScrnInfoPtr pScrn, int x, int y);
-Bool ViaVbeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode);
-Bool ViaVbeSaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function);
-Bool ViaVbeModePreInit(ScrnInfoPtr pScrn);
-void ViaVbeDPMS(ScrnInfoPtr pScrn, int mode);
-void ViaVbeDoDPMS(ScrnInfoPtr pScrn, int mode);
-int ViaVbePanelPower(vbeInfoPtr pVbe, int mode);
-Bool ViaVbeSetPanelMode(ScrnInfoPtr pScrn, Bool expand);
-
/* via_ums.c */
Bool VIAMapMem(ScrnInfoPtr pScrn);
void VIAUnmapMem(ScrnInfoPtr pScrn);
diff --git a/src/via_vbe.c b/src/via_vbe.c
deleted file mode 100644
index 776ed2f..0000000
--- a/src/via_vbe.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright 2004 The Unichrome Project [unichrome.sf.net]
- * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * VBE Mode setting.
- *
- * The functions were more or less taken from the vesa driver.
- * They were added to support BIOS modes directly.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "via_driver.h"
-#include "vbe.h"
-#include "vbeModes.h"
-
-#define R16(v) ((v) & 0xffff)
-#define VBE_DEFAULT_REFRESH 6000
-
-void
-ViaVbeAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
-{
- VIAPtr pVia = VIAPTR(pScrn);
-
- VBESetDisplayStart(pVia->pVbe, x, y, TRUE);
-}
-
-/*
- * Default values for pInt10.
- */
-static void
-ViaVbeInitInt10(vbeInfoPtr pVbe)
-{
- pVbe->pInt10->ax = 0x4F14;
- pVbe->pInt10->cx = 0;
- pVbe->pInt10->dx = 0;
- pVbe->pInt10->di = 0;
- pVbe->pInt10->num = 0x10;
-}
-
-static int
-ViaVbeGetRefreshRateIndex(int maxRefresh)
-{
- int rri = 0;
-
- if (maxRefresh >= 120) {
- rri = 10;
- } else if (maxRefresh >= 100) {
- rri = 9;
- } else if (maxRefresh >= 85) {
- rri = 7;
- } else if (maxRefresh >= 75) {
- rri = 5;
- } else {
- rri = 0;
- }
-
- return rri;
-}
-
-static int
-ViaVbeGetActiveDevices(ScrnInfoPtr pScrn)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int activeDevices = 0, i;
-
- /* TODO: Add others devices. */
- for (i = 0; i < xf86_config->num_output; i++) {
- xf86OutputPtr output = xf86_config->output[i];
-
- if (output->status == XF86OutputStatusConnected) {
- if (!strncmp(output->name, "VGA", 3))
- activeDevices = 0x01;
- else if (!strncmp(output->name, "LVDS", 4))
- activeDevices |= 0x02;
- else if (!strncmp(output->name, "TV", 2))
- activeDevices |= 0x04;
- }
- }
- return activeDevices;
-}
-
-/*
- * Sets the requested mode, refresh rate and active devices.
- */
-static Bool
-ViaVbeSetActiveDevices(ScrnInfoPtr pScrn, int mode, int refresh)
-{
- VIAPtr pVia = VIAPTR(pScrn);
- vbeInfoPtr pVbe = pVia->pVbe;
-
- ViaVbeInitInt10(pVbe);
- pVbe->pInt10->bx = 0x8003;
- pVbe->pInt10->cx = ViaVbeGetActiveDevices(pScrn);
- pVbe->pInt10->dx = mode & 0x1FF;
- pVbe->pInt10->di = ViaVbeGetRefreshRateIndex(refresh);
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSetActiveDevices "
- "mode: %x, refresh: %d active devices: 0x%2x\n",
- mode, refresh, pVbe->pInt10->cx));
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if (pVbe->pInt10->ax != 0x4F)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * Sets the panel mode (expand or center).
- */
-Bool
-ViaVbeSetPanelMode(ScrnInfoPtr pScrn, Bool expand)
-{
- VIAPtr pVia = VIAPTR(pScrn);
- vbeInfoPtr pVbe = pVia->pVbe;
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSetPanelMode\n"));
-
- ViaVbeInitInt10(pVbe);
- pVbe->pInt10->ax = 0x4F14;
- pVbe->pInt10->bx = 0x0306;
- pVbe->pInt10->cx = 0x80 | expand;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if (pVbe->pInt10->ax != 0x4F)
- return FALSE;
-
- return TRUE;
-}
-
-static Bool
-ViaVbeSetRefresh(ScrnInfoPtr pScrn, int maxRefresh)
-{
- VIAPtr pVia = VIAPTR(pScrn);
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSetRefresh\n"));
- vbeInfoPtr pVbe = pVia->pVbe;
-
- ViaVbeInitInt10(pVbe);
- pVbe->pInt10->bx = 0x0001;
- pVbe->pInt10->cx = ViaVbeGetActiveDevices(pScrn);
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Active Device: %d\n",
- pVbe->pInt10->cx));
-
- pVbe->pInt10->di = ViaVbeGetRefreshRateIndex(maxRefresh);
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Refresh Rate Index: %d\n",
- pVbe->pInt10->di));
-
- /* Real execution */
- xf86ExecX86int10(pVbe->pInt10);
-
- if (pVbe->pInt10->ax != 0x4F)
- return FALSE;
-
- return TRUE;
-}
-
-Bool
-ViaVbeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
-{
- VIAPtr pVia;
- VbeModeInfoData *data;
-
- pVia = VIAPTR(pScrn);
- int mode;
- int refreshRate;
-
- data = (VbeModeInfoData *) pMode->Private;
-
- mode = data->mode | (1 << 15);
-
- /* Enable linear addressing. */
- mode |= 1 << 14;
-
- if (data->block) {
- refreshRate = data->block->RefreshRate;
- } else {
- refreshRate = VBE_DEFAULT_REFRESH;
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Unable to determine the refresh rate, using %.2f. "
- "Please check your configuration.\n", refreshRate / 100.);
- }
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Trying VBE Mode %dx%d (0x%x) Refresh %.2f:\n",
- (int)data->data->XResolution, (int)data->data->YResolution,
- mode & ~(1 << 11), (float)refreshRate / 100.);
-
- if (pVia->useLegacyVBE) {
-
- ViaVbeSetRefresh(pScrn, refreshRate / 100);
-
- if (VBESetVBEMode(pVia->pVbe, mode, data->block) == FALSE) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBESetVBEMode failed");
- if ((data->block || (data->mode & (1 << 11))) &&
- VBESetVBEMode(pVia->pVbe, (mode & ~(1 << 11)), NULL) == TRUE) {
- /* Some cards do not like setting the clock. */
- xf86ErrorF("...but worked OK without customized "
- "refresh and dotclock.\n");
- free(data->block);
- data->block = NULL;
- data->mode &= ~(1 << 11);
- } else {
- ErrorF("\n");
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Set VBE Mode failed!\n");
- return (FALSE);
- }
- }
- } else {
- data->mode &= ~(1 << 11);
- if (VBESetVBEMode(pVia->pVbe, data->mode, NULL) == FALSE) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Set VBE Mode failed.\n");
- return (FALSE);
- }
-
- if (!ViaVbeSetActiveDevices(pScrn, data->mode, refreshRate / 100)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Unable to set the active devices.\n");
- return (FALSE);
- }
- }
-
- if (data->data->XResolution != pScrn->displayWidth)
- VBESetLogicalScanline(pVia->pVbe, pScrn->displayWidth);
-
- return (TRUE);
-}
-
-Bool
-ViaVbeSaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function)
-{
- VIAPtr pVia = VIAPTR(pScrn);
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaVbeSaveRestore\n"));
-
- if ((MODE_QUERY < 0) || (function > MODE_RESTORE))
- return (FALSE);
-
- if (function == MODE_SAVE)
- pVia->SavedReg.SR1A = hwp->readSeq(hwp, 0x1A);
-
- /* Query amount of memory to save state. */
- if ((function == MODE_QUERY) ||
- ((function == MODE_SAVE) && (pVia->vbeMode.state == NULL))) {
-
- /* Make sure we save at least this information in case of failure. */
- (void)VBEGetVBEMode(pVia->pVbe, &(pVia->vbeMode.stateMode));
-
- if (pVia->vbeMode.major > 1) {
- if (!VBESaveRestore(pVia->pVbe, function,
- (pointer) & (pVia->vbeMode.state),
- &(pVia->vbeMode.stateSize),
- &(pVia->vbeMode.statePage))) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "VBESaveRestore failed\n");
- return FALSE;
- }
- }
- }
-
- /* Save/Restore Super VGA state. */
- if (function != MODE_QUERY) {
- Bool retval = TRUE;
-
- if (pVia->vbeMode.major > 1) {
- if (function == MODE_RESTORE)
- memcpy(pVia->vbeMode.state, pVia->vbeMode.pstate,
- pVia->vbeMode.stateSize);
-
- if ((retval = VBESaveRestore(pVia->pVbe, function,
- (pointer) & (pVia->vbeMode.state),
- &(pVia->vbeMode.stateSize),
- &(pVia->vbeMode.statePage)))
- && (function == MODE_SAVE)) {
- /* Do not rely on the memory not being touched. */
- if (pVia->vbeMode.pstate == NULL)
- pVia->vbeMode.pstate = malloc(pVia->vbeMode.stateSize);
- memcpy(pVia->vbeMode.pstate, pVia->vbeMode.state,
- pVia->vbeMode.stateSize);
- }
- }
-
- if (function == MODE_RESTORE) {
- if (!VBESetVBEMode(pVia->pVbe, pVia->vbeMode.stateMode, NULL)) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "VBESetVBEMode failed\n");
- }
- }
-
- if (!retval)
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-
-Bool
-ViaVbeModePreInit(ScrnInfoPtr pScrn)
-{
- VIAPtr pVia = VIAPTR(pScrn);
- VbeInfoBlock *vbe;
-
- int i;
-
- memset(&(pVia->vbeMode), 0, sizeof(ViaVbeModeInfo));
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Searching for matching VESA mode(s):\n");
-
- if ((vbe = VBEGetVBEInfo(pVia->pVbe)) == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBEGetVBEInfo failed\n");
- return FALSE;
- }
-
- pVia->vbeMode.major = (unsigned)(vbe->VESAVersion >> 8);
- pVia->vbeMode.minor = vbe->VESAVersion & 0xff;
-
- pScrn->modePool = VBEGetModePool(pScrn, pVia->pVbe, vbe, V_MODETYPE_VBE);
- if (pScrn->modePool == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No matching modes\n");
- return FALSE;
- }
-
- VBESetModeNames(pScrn->modePool);
-
- i = VBEValidateModes(pScrn, NULL, pScrn->display->modes,
- NULL, NULL, 0, 2048, 1, 0, 2048,
- pScrn->display->virtualX,
- pScrn->display->virtualY,
- pScrn->videoRam, LOOKUP_BEST_REFRESH);
-
- if (i <= 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
- return (FALSE);
- }
-
- VBESetModeParameters(pScrn, pVia->pVbe);
-
- xf86PruneDriverModes(pScrn);
-#if 0
- pMode = pScrn->modes;
- do {
- vbeMode = ((VbeModeInfoData *) pMode->Private)->data;
- pMode = pMode->next;
- } while (pMode != NULL && pMode != pScrn->modes);
-#endif
- return TRUE;
-}
-
-int
-ViaVbePanelPower(vbeInfoPtr pVbe, int mode)
-{
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x5F54;
- pVbe->pInt10->bx = (mode) ? 0x00 : 0x01;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- return (R16(pVbe->pInt10->ax) == 0x015f);
-}
-
-#if 0
-/*
- * FIXME: This might be useful in the future. Otherwise feel free to remove.
- * If mode=1, it sets the panel in a low-power, low-performance state;
- * if mode=0, then high performance.
- */
-static int
-ViaVbePanelLowPower(vbeInfoPtr pVbe, int mode)
-{
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x5F60;
- pVbe->pInt10->bx = (mode) ? 0x01 : 0x00;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- return (R16(pVbe->pInt10->ax) == 0x015f);
-}
-#endif
-
-void
-ViaVbeDPMS(ScrnInfoPtr pScrn, int mode)
-{
- VIAPtr pVia = VIAPTR(pScrn);
-
- if (!pScrn->vtSema)
- return;
- VBEDPMSSet(pVia->pVbe, mode);
-}
More information about the Openchrome-devel
mailing list