xf86-video-vesa 2.0.0, plus one fix to keep it working with xserver 1.4.

This commit is contained in:
matthieu
2008-10-12 13:55:49 +00:00
parent 1756bd319c
commit 1d58f414b6
4 changed files with 353 additions and 271 deletions

View File

@@ -1,12 +1,24 @@
This is a stub file. This package has not yet had its complete licensing
information compiled. Please see the individual source files for details on
your rights to use and modify this software.
Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
Please submit updated COPYING files to the Xorg bugzilla:
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, sublicense,
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:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
The above copyright notice and this permission notice 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
CONECTIVA LINUX 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.
All licensing questions regarding this software should be directed at the
Xorg mailing list:
http://lists.freedesktop.org/mailman/listinfo/xorg
Except as contained in this notice, the name of Conectiva Linux shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from
Conectiva Linux.

View File

@@ -22,7 +22,7 @@
AC_PREREQ(2.57)
AC_INIT([xf86-video-vesa],
1.3.0,
2.0.0,
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-video-vesa)
@@ -56,6 +56,18 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
PKG_CHECK_MODULES(XORG, xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES)
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
save_CFLAGS="$CFLAGS"
CFLAGS="$XORG_CFLAGS"
AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
[XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
[#include "xorg-server.h"])
CFLAGS="$save_CFLAGS"
if test "x$XSERVER_LIBPCIACCESS" = xyes; then
PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
fi
AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src'
INCLUDES="$XORG_INCS -I${sdkdir} "'-I$(top_srcdir)/src -I$(prefix)/include'
AC_SUBST([CFLAGS])

View File

@@ -1,6 +1,7 @@
#define DEBUG_VERB 2
/*
* Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
* Copyright 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,8 +28,7 @@
*
* Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
* David Dawes <dawes@xfree86.org>
*
* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c,v 1.40 2003/11/03 05:11:45 tsi Exp $
* Adam Jackson <ajax@redhat.com>
*/
#ifdef HAVE_CONFIG_H
@@ -48,6 +48,7 @@
/* Colormap handling */
#include "micmap.h"
#include "xf86cmap.h"
#include "xf86Modes.h"
/* DPMS */
#define DPMS_SERVER
@@ -57,6 +58,10 @@
static const OptionInfoRec * VESAAvailableOptions(int chipid, int busid);
static void VESAIdentify(int flags);
static Bool VESAProbe(DriverPtr drv, int flags);
#ifdef XSERVER_LIBPCIACCESS
static Bool VESAPciProbe(DriverPtr drv, int entity_num,
struct pci_device *dev, intptr_t match_data);
#endif
static Bool VESAPreInit(ScrnInfoPtr pScrn, int flags);
static Bool VESAScreenInit(int Index, ScreenPtr pScreen, int argc,
char **argv);
@@ -70,6 +75,7 @@ static Bool VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode);
static void VESAAdjustFrame(int scrnIndex, int x, int y, int flags);
static void VESAFreeScreen(int scrnIndex, int flags);
static void VESAFreeRec(ScrnInfoPtr pScrn);
static VESAPtr VESAGetRec(ScrnInfoPtr pScrn);
static void
VESADisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
@@ -96,28 +102,22 @@ static void *VESAWindowWindowed(ScreenPtr pScrn, CARD32 row, CARD32 offset,
static Bool VESADGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen);
/*
* This contains the functions needed by the server after loading the
* driver module. It must be supplied, and gets added the driver list by
* the Module Setup funtion in the dynamic case. In the static case a
* reference to this is compiled in, and this requires that the name of
* this DriverRec be an upper-case version of the driver name.
*/
_X_EXPORT DriverRec VESA = {
VESA_VERSION,
VESA_DRIVER_NAME,
VESAIdentify,
VESAProbe,
VESAAvailableOptions,
NULL,
0
};
enum GenericTypes
{
CHIP_VESA_GENERIC
};
#ifdef XSERVER_LIBPCIACCESS
static const struct pci_id_match vesa_device_match[] = {
{
PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
0x00030000, 0x00ffffff, CHIP_VESA_GENERIC
},
{ 0, 0, 0 },
};
#endif
/* Supported chipsets */
static SymTabRec VESAChipsets[] =
{
@@ -135,6 +135,31 @@ static IsaChipsets VESAISAchipsets[] = {
{-1, 0 }
};
/*
* This contains the functions needed by the server after loading the
* driver module. It must be supplied, and gets added the driver list by
* the Module Setup funtion in the dynamic case. In the static case a
* reference to this is compiled in, and this requires that the name of
* this DriverRec be an upper-case version of the driver name.
*/
_X_EXPORT DriverRec VESA = {
VESA_VERSION,
VESA_DRIVER_NAME,
VESAIdentify,
VESAProbe,
VESAAvailableOptions,
NULL,
0,
NULL,
#ifdef XSERVER_LIBPCIACCESS
vesa_device_match,
VESAPciProbe
#endif
};
typedef enum {
OPTION_SHADOW_FB,
OPTION_DFLT_REFRESH,
@@ -149,69 +174,7 @@ static const OptionInfoRec VESAOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
/*
* List of symbols from other modules that this module references. This
* list is used to tell the loader that it is OK for symbols here to be
* unresolved providing that it hasn't been told that they haven't been
* told that they are essential via a call to xf86LoaderReqSymbols() or
* xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
* unresolved symbols that are not required.
*/
#ifdef XFree86LOADER
static const char *miscfbSymbols[] = {
"xf1bppScreenInit",
"xf4bppScreenInit",
#ifdef USE_AFB
"afbScreenInit",
#endif
"mfbScreenInit",
NULL
};
#endif
static const char *fbSymbols[] = {
"fbPictureInit",
"fbScreenInit",
NULL
};
static const char *shadowSymbols[] = {
"shadowInit",
"shadowUpdatePackedWeak",
"shadowUpdatePlanar4Weak",
"shadowUpdatePlanar4x8Weak",
NULL
};
static const char *vbeSymbols[] = {
"VBEBankSwitch",
"VBEExtendedInit",
"VBEFindSupportedDepths",
"VBEGetModeInfo",
"VBEGetVBEInfo",
"VBEGetVBEMode",
"VBEPrintModes",
"VBESaveRestore",
"VBESetDisplayStart",
"VBESetGetDACPaletteFormat",
"VBESetGetLogicalScanlineLength",
"VBESetGetPaletteData",
"VBESetModeNames",
"VBESetModeParameters",
"VBESetVBEMode",
"VBEValidateModes",
"vbeDoEDID",
"vbeFree",
NULL
};
#ifdef XFree86LOADER
static const char *ddcSymbols[] = {
"xf86PrintEDID",
"xf86SetDDCproperties",
NULL
};
/* Module loader interface */
static MODULESETUPPROTO(vesaSetup);
@@ -244,13 +207,7 @@ vesaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
if (!Initialised)
{
Initialised = TRUE;
xf86AddDriver(&VESA, Module, 0);
LoaderRefSymLists(miscfbSymbols,
fbSymbols,
shadowSymbols,
vbeSymbols,
ddcSymbols,
NULL);
xf86AddDriver(&VESA, Module, 1);
return (pointer)TRUE;
}
@@ -273,11 +230,172 @@ VESAIdentify(int flags)
xf86PrintChipsets(VESA_NAME, "driver for VESA chipsets", VESAChipsets);
}
static VESAPtr
VESAGetRec(ScrnInfoPtr pScrn)
{
if (!pScrn->driverPrivate)
pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1);
return ((VESAPtr)pScrn->driverPrivate);
}
/* Only a little like VBESetModeParameters */
static void
VESASetModeParameters(vbeInfoPtr pVbe, DisplayModePtr vbemode,
DisplayModePtr ddcmode)
{
VbeModeInfoData *data;
int clock;
data = (VbeModeInfoData *)vbemode->Private;
data->block = xcalloc(sizeof(VbeCRTCInfoBlock), 1);
data->block->HorizontalTotal = ddcmode->HTotal;
data->block->HorizontalSyncStart = ddcmode->HSyncStart;
data->block->HorizontalSyncEnd = ddcmode->HSyncEnd;
data->block->VerticalTotal = ddcmode->VTotal;
data->block->VerticalSyncStart = ddcmode->VSyncStart;
data->block->VerticalSyncEnd = ddcmode->VSyncEnd;
data->block->Flags = ((ddcmode->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) |
((ddcmode->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0);
data->block->PixelClock = ddcmode->Clock * 1000;
/* ask the BIOS to figure out the real clock */
clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock);
if (clock)
data->block->PixelClock = clock;
data->mode |= (1 << 11);
data->block->RefreshRate = 100 * ((double)(data->block->PixelClock) /
(double)(ddcmode->HTotal * ddcmode->VTotal));
}
static ModeStatus
VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
{
static int warned = 0;
int found = 0;
ScrnInfoPtr pScrn = xf86Screens[scrn];
VESAPtr pVesa = VESAGetRec(pScrn);
MonPtr mon = pScrn->monitor;
ModeStatus ret;
DisplayModePtr mode;
float v;
pVesa = VESAGetRec(pScrn);
if (pass != MODECHECK_FINAL) {
if (!warned) {
xf86DrvMsg(scrn, X_WARNING, "VESAValidMode called unexpectedly\n");
warned = 1;
}
return MODE_OK;
}
/*
* This is suboptimal. We pass in just the barest description of a mode
* we can get away with to VBEValidateModes, so it can't really throw
* out anything we give it. But we need to filter the list so that we
* don't populate the mode list with things the monitor can't do.
*
* So first off, if this isn't a mode we handed to the server (ie,
* M_T_BUILTIN), then we know we can't do it.
*/
if (!(p->type & M_T_BUILTIN))
return MODE_NOMODE;
if (pVesa->strict_validation) {
/*
* If it's our first pass at mode validation, we'll try for a strict
* intersection between the VBE and DDC mode lists.
*/
if (pScrn->monitor->DDC) {
for (mode = pScrn->monitor->Modes; mode; mode = mode->next) {
if (mode->type & M_T_DRIVER &&
mode->HDisplay == p->HDisplay &&
mode->VDisplay == p->VDisplay) {
if (xf86CheckModeForMonitor(mode, mon) == MODE_OK) {
found = 1;
break;
}
}
if (mode == pScrn->monitor->Last)
break;
}
if (!found)
return MODE_NOMODE;
/* having found a matching mode, stash the CRTC values aside */
VESASetModeParameters(pVesa->pVbe, p, mode);
return MODE_OK;
}
/* No DDC and no modes make Homer something something... */
return MODE_NOMODE;
}
#if (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,4,99,0,0))
/*
* Finally, walk through the vsync rates 1Hz at a time looking for a mode
* that will fit. This is assuredly a terrible way to do this, but
* there's no obvious method for computing a mode of a given size that
* will pass xf86CheckModeForMonitor. XXX this path is terrible, but
* then, by this point, you're well into despair territory.
*/
for (v = mon->vrefresh[0].lo; v <= mon->vrefresh[0].hi; v++) {
mode = xf86GTFMode(p->HDisplay, p->VDisplay, v, 0, 0);
ret = xf86CheckModeForMonitor(mode, mon);
xfree(mode);
if (ret == MODE_OK)
break;
}
#endif
return ret;
}
static void
VESAInitScrn(ScrnInfoPtr pScrn)
{
pScrn->driverVersion = VESA_VERSION;
pScrn->driverName = VESA_DRIVER_NAME;
pScrn->name = VESA_NAME;
pScrn->Probe = VESAProbe;
pScrn->PreInit = VESAPreInit;
pScrn->ScreenInit = VESAScreenInit;
pScrn->SwitchMode = VESASwitchMode;
pScrn->ValidMode = VESAValidMode;
pScrn->AdjustFrame = VESAAdjustFrame;
pScrn->EnterVT = VESAEnterVT;
pScrn->LeaveVT = VESALeaveVT;
pScrn->FreeScreen = VESAFreeScreen;
}
/*
* This function is called once, at the start of the first server generation to
* do a minimal probe for supported hardware.
*/
#ifdef XSERVER_LIBPCIACCESS
static Bool
VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
intptr_t match_data)
{
ScrnInfoPtr pScrn;
pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL,
NULL, NULL, NULL, NULL, NULL);
if (pScrn != NULL) {
VESAPtr pVesa = VESAGetRec(pScrn);
VESAInitScrn(pScrn);
pVesa->pciInfo = dev;
}
return (pScrn != NULL);
}
#endif
static Bool
VESAProbe(DriverPtr drv, int flags)
{
@@ -295,6 +413,7 @@ VESAProbe(DriverPtr drv, int flags)
&devSections)) <= 0)
return (FALSE);
#ifndef XSERVER_LIBPCIACCESS
/* PCI BUS */
if (xf86GetPciVideoInfo()) {
numUsed = xf86MatchPciInstances(VESA_NAME, PCI_VENDOR_GENERIC,
@@ -311,17 +430,7 @@ VESAProbe(DriverPtr drv, int flags)
if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
VESAPCIchipsets,NULL,
NULL,NULL,NULL,NULL))) {
pScrn->driverVersion = VESA_VERSION;
pScrn->driverName = VESA_DRIVER_NAME;
pScrn->name = VESA_NAME;
pScrn->Probe = VESAProbe;
pScrn->PreInit = VESAPreInit;
pScrn->ScreenInit = VESAScreenInit;
pScrn->SwitchMode = VESASwitchMode;
pScrn->AdjustFrame = VESAAdjustFrame;
pScrn->EnterVT = VESAEnterVT;
pScrn->LeaveVT = VESALeaveVT;
pScrn->FreeScreen = VESAFreeScreen;
VESAInitScrn(pScrn);
foundScreen = TRUE;
}
}
@@ -329,6 +438,7 @@ VESAProbe(DriverPtr drv, int flags)
xfree(usedChips);
}
}
#endif
/* Isa Bus */
numUsed = xf86MatchIsaInstances(VESA_NAME,VESAChipsets,
@@ -343,18 +453,7 @@ VESAProbe(DriverPtr drv, int flags)
if ((pScrn = xf86ConfigIsaEntity(pScrn, 0,usedChips[i],
VESAISAchipsets, NULL,
NULL, NULL, NULL, NULL))) {
pScrn->driverVersion = VESA_VERSION;
pScrn->driverName = VESA_DRIVER_NAME;
pScrn->name = VESA_NAME;
pScrn->Probe = VESAProbe;
pScrn->PreInit = VESAPreInit;
pScrn->ScreenInit = VESAScreenInit;
pScrn->SwitchMode = VESASwitchMode;
pScrn->AdjustFrame = VESAAdjustFrame;
pScrn->EnterVT = VESAEnterVT;
pScrn->LeaveVT = VESALeaveVT;
pScrn->FreeScreen = VESAFreeScreen;
VESAInitScrn(pScrn);
foundScreen = TRUE;
}
}
@@ -391,15 +490,6 @@ VESAFindIsaDevice(GDevPtr dev)
return (int)CHIP_VESA_GENERIC;
}
static VESAPtr
VESAGetRec(ScrnInfoPtr pScrn)
{
if (!pScrn->driverPrivate)
pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1);
return ((VESAPtr)pScrn->driverPrivate);
}
static void
VESAFreeRec(ScrnInfoPtr pScrn)
{
@@ -445,14 +535,13 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
VbeInfoBlock *vbe;
DisplayModePtr pMode;
VbeModeInfoBlock *mode;
char *mod = NULL;
const char *reqSym = NULL;
Gamma gzeros = {0.0, 0.0, 0.0};
rgb rzeros = {0, 0, 0};
pointer pDDCModule;
int i;
int flags24 = 0;
int defaultDepth = 0;
int defaultBpp = 0;
int depths = 0;
if (flags & PROBE_DETECT)
@@ -460,36 +549,23 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
pVesa = VESAGetRec(pScrn);
pVesa->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
pVesa->device = xf86GetDevFromEntity(pScrn->entityList[0],
pScrn->entityInstanceList[0]);
#if 0
/* Load vgahw module */
if (!xf86LoadSubModule(pScrn, "vgahw"))
return (FALSE);
xf86LoaderReqSymLists(vgahwSymbols, NULL);
#endif
/* Load vbe module */
if (!xf86LoadSubModule(pScrn, "vbe"))
return (FALSE);
xf86LoaderReqSymLists(vbeSymbols, NULL);
if ((pVesa->pVbe = VBEExtendedInit(NULL, pVesa->pEnt->index,
SET_BIOS_SCRATCH
| RESTORE_BIOS_SCRATCH)) == NULL)
return (FALSE);
#ifndef XSERVER_LIBPCIACCESS
if (pVesa->pEnt->location.type == BUS_PCI) {
pVesa->pciInfo = xf86GetPciInfoForEntity(pVesa->pEnt->index);
pVesa->pciTag = pciTag(pVesa->pciInfo->bus, pVesa->pciInfo->device,
pVesa->pciInfo->func);
pVesa->primary = xf86IsPrimaryPci(pVesa->pciInfo);
}
else
pVesa->primary = TRUE;
#endif
pScrn->chipset = "vesa";
pScrn->monitor = pScrn->confScreen->monitor;
@@ -510,31 +586,29 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
V_MODETYPE_VBE);
/* Preferred order for default depth selection. */
if (depths & V_DEPTH_16)
if (depths & V_DEPTH_24)
defaultDepth = 24;
else if (depths & V_DEPTH_16)
defaultDepth = 16;
else if (depths & V_DEPTH_15)
defaultDepth = 15;
else if (depths & V_DEPTH_8)
defaultDepth = 8;
else if (depths & V_DEPTH_24)
defaultDepth = 24;
else if (depths & V_DEPTH_4)
defaultDepth = 4;
else if (depths & V_DEPTH_1)
defaultDepth = 1;
/*
* Setting this avoids a "Driver can't support depth 24" message,
* which could be misleading.
*/
if (!flags24)
flags24 = Support24bppFb;
if (defaultDepth == 24 && !(flags24 & Support32bppFb))
defaultBpp = 24;
/* Prefer 24bpp for fb since it potentially allows larger modes. */
/* Prefer 32bpp because 1999 called and wants its packed pixels back */
if (flags24 & Support32bppFb)
flags24 |= SupportConvert24to32 | PreferConvert24to32;
if (flags24 & Support24bppFb)
flags24 |= SupportConvert32to24 | PreferConvert32to24;
flags24 |= SupportConvert32to24;
if (!xf86SetDepthBpp(pScrn, defaultDepth, 0, 0, flags24)) {
if (!xf86SetDepthBpp(pScrn, defaultDepth, 0, defaultBpp, flags24)) {
vbeFree(pVesa->pVbe);
return (FALSE);
}
@@ -595,12 +669,27 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
VBESetModeNames(pScrn->modePool);
pVesa->strict_validation = TRUE;
i = VBEValidateModes(pScrn, NULL, pScrn->display->modes,
NULL, NULL, 0, 2048, 1, 0, 2048,
pScrn->display->virtualX,
pScrn->display->virtualY,
pVesa->mapSize, LOOKUP_BEST_REFRESH);
if (i <= 0) {
DisplayModePtr mode;
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"No valid modes left. Trying less strict filter...\n");
for (mode = pScrn->monitor->Modes; mode; mode = mode->next)
mode->status = MODE_OK;
pVesa->strict_validation = FALSE;
i = VBEValidateModes(pScrn, NULL, pScrn->display->modes,
NULL, NULL, 0, 2048, 1, 0, 2048,
pScrn->display->virtualX,
pScrn->display->virtualY,
pVesa->mapSize, LOOKUP_BEST_REFRESH);
}
if (i <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes\n");
vbeFree(pVesa->pVbe);
@@ -648,55 +737,18 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
if (xf86ReturnOptValBool(pVesa->Options, OPTION_DFLT_REFRESH, FALSE))
pVesa->defaultRefresh = TRUE;
pVesa->ModeSetClearScreen = FALSE;
if (xf86ReturnOptValBool(pVesa->Options, OPTION_MODESET_CLEAR_SCREEN,
TRUE))
FALSE))
pVesa->ModeSetClearScreen = TRUE;
if (!pVesa->defaultRefresh)
if (!pVesa->defaultRefresh && !pVesa->strict_validation)
VBESetModeParameters(pScrn, pVesa->pVbe);
mode = ((VbeModeInfoData*)pScrn->modes->Private)->data;
switch (mode->MemoryModel) {
case 0x0: /* Text mode */
case 0x1: /* CGA graphics */
case 0x2: /* Hercules graphics */
case 0x5: /* Non-chain 4, 256 color */
case 0x7: /* YUV */
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unsupported Memory Model: %d", mode->MemoryModel);
break;
case 0x3: /* Planar */
if (pVesa->shadowFB) {
mod = "fb";
pScrn->bitmapBitOrder = BITMAP_BIT_ORDER;
xf86LoaderReqSymbols("fbPictureInit", NULL);
}
else {
switch (pScrn->bitsPerPixel) {
case 1:
mod = "xf1bpp";
reqSym = "xf1bppScreenInit";
break;
case 4:
mod = "xf4bpp";
reqSym = "xf4bppScreenInit";
break;
default:
#ifdef USE_AFB
mod = "afb";
reqSym = "afbScreenInit";
break;
#else
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unsupported bpp: %d", pScrn->bitsPerPixel);
#endif
}
}
break;
case 0x4: /* Packed pixel */
case 0x6: /* Direct Color */
mod = "fb";
case 0x6: /* Direct Color */
pScrn->bitmapBitOrder = BITMAP_BIT_ORDER;
switch (pScrn->bitsPerPixel) {
@@ -712,35 +764,26 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
break;
default:
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unsupported Memory Model: %d", mode->MemoryModel);
return FALSE;
}
if (pVesa->shadowFB) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using \"Shadow Framebuffer\"\n");
if (pScrn->depth == 1) {
mod = "mfb";
reqSym = "mfbScreenInit";
}
if (!xf86LoadSubModule(pScrn, "shadow")) {
vbeFree(pVesa->pVbe);
return (FALSE);
}
xf86LoaderReqSymLists(shadowSymbols, NULL);
}
if (mod && xf86LoadSubModule(pScrn, mod) == NULL) {
if (xf86LoadSubModule(pScrn, "fb") == NULL) {
VESAFreeRec(pScrn);
vbeFree(pVesa->pVbe);
return (FALSE);
}
if (mod) {
if (reqSym) {
xf86LoaderReqSymbols(reqSym, NULL);
} else {
xf86LoaderReqSymLists(fbSymbols, NULL);
}
}
vbeFree(pVesa->pVbe);
return (TRUE);
@@ -763,6 +806,16 @@ vesaCreateScreenResources(ScreenPtr pScreen)
return ret;
}
static void
vesaEnableDisableFBAccess(int scrnIndex, Bool enable)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
VESAPtr pVesa = VESAGetRec(pScrn);
pVesa->accessEnabled = enable;
pVesa->EnableDisableFBAccess(scrnIndex, enable);
}
static Bool
VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
{
@@ -850,42 +903,8 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
mode = ((VbeModeInfoData*)pScrn->modes->Private)->data;
switch (mode->MemoryModel) {
case 0x0: /* Text mode */
case 0x1: /* CGA graphics */
case 0x2: /* Hercules graphics */
case 0x5: /* Non-chain 4, 256 color */
case 0x7: /* YUV */
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unsupported Memory Model: %d", mode->MemoryModel);
return (FALSE);
case 0x3: /* Planar */
switch (pScrn->bitsPerPixel) {
case 1:
if (!xf1bppScreenInit(pScreen, pVesa->base,
pScrn->virtualX, pScrn->virtualY,
pScrn->xDpi, pScrn->yDpi,
pScrn->displayWidth))
return (FALSE);
break;
case 4:
if (!xf4bppScreenInit(pScreen, pVesa->base,
pScrn->virtualX, pScrn->virtualY,
pScrn->xDpi, pScrn->yDpi,
pScrn->displayWidth))
return (FALSE);
break;
default:
#ifdef USE_AFB
if (!afbScreenInit(pScreen, pVesa->base,
pScrn->virtualX, pScrn->virtualY,
pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth))
#endif
return (FALSE);
break;
}
break;
case 0x4: /* Packed pixel */
case 0x6: /* Direct Color */
case 0x6: /* Direct Color */
switch (pScrn->bitsPerPixel) {
case 8:
case 16:
@@ -905,6 +924,10 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return (FALSE);
}
break;
default:
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unsupported Memory Model: %d", mode->MemoryModel);
return (FALSE);
}
@@ -928,14 +951,7 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
fbPictureInit(pScreen, 0, 0);
if (pVesa->shadowFB) {
if (mode->MemoryModel == 3) { /* Planar */
if (pScrn->bitsPerPixel == 8)
pVesa->update = shadowUpdatePlanar4x8Weak();
else
pVesa->update = shadowUpdatePlanar4Weak();
pVesa->window = VESAWindowPlanar;
}
else if (pVesa->mapPhys == 0xa0000) { /* Windowed */
if (pVesa->mapPhys == 0xa0000) { /* Windowed */
pVesa->update = shadowUpdatePackedWeak();
pVesa->window = VESAWindowWindowed;
}
@@ -949,7 +965,7 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pVesa->CreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = vesaCreateScreenResources;
}
else if (pVesa->mapPhys == 0xa0000 && mode->MemoryModel != 0x3) {
else if (pVesa->mapPhys == 0xa0000) {
unsigned int bankShift = 0;
while ((unsigned)(64 >> bankShift) != mode->WinGranularity)
bankShift++;
@@ -988,6 +1004,10 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
VESALoadPalette, NULL, flags))
return (FALSE);
pVesa->accessEnabled = TRUE;
pVesa->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = vesaEnableDisableFBAccess;
pVesa->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = VESACloseScreen;
pScreen->SaveScreen = VESASaveScreen;
@@ -1040,6 +1060,7 @@ VESACloseScreen(int scrnIndex, ScreenPtr pScreen)
}
pScrn->vtSema = FALSE;
pScrn->EnableDisableFBAccess = pVesa->EnableDisableFBAccess;
pScreen->CreateScreenResources = pVesa->CreateScreenResources;
pScreen->CloseScreen = pVesa->CloseScreen;
return pScreen->CloseScreen(scrnIndex, pScreen);
@@ -1050,12 +1071,12 @@ VESASwitchMode(int scrnIndex, DisplayModePtr pMode, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
VESAPtr pVesa = VESAGetRec(pScrn);
Bool ret;
Bool ret, disableAccess = pVesa->ModeSetClearScreen && pVesa->accessEnabled;
if (pVesa->ModeSetClearScreen)
if (disableAccess)
pScrn->EnableDisableFBAccess(scrnIndex,FALSE);
ret = VESASetMode(xf86Screens[scrnIndex], pMode);
if (pVesa->ModeSetClearScreen)
if (disableAccess)
pScrn->EnableDisableFBAccess(scrnIndex,TRUE);
return ret;
}
@@ -1071,7 +1092,9 @@ VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
pVesa = VESAGetRec(pScrn);
data = (VbeModeInfoData*)pMode->Private;
mode = data->mode | ( pVesa->ModeSetClearScreen ? (1U << 15) : 0);
/* careful, setting the bit means don't clear the screen */
mode = data->mode | (pVesa->ModeSetClearScreen ? 0 : (1U << 15));
/* enable linear addressing */
if (pVesa->mapPhys != 0xa0000)
@@ -1103,7 +1126,7 @@ VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
VBESetLogicalScanline(pVesa->pVbe, pScrn->displayWidth);
if (pScrn->bitsPerPixel == 8 && pVesa->vbeInfo->Capabilities[0] & 0x01 &&
!(data->data->MemoryModel & 0x6 || data->data->MemoryModel & 0x7))
!(data->data->MemoryModel == 0x6 || data->data->MemoryModel == 0x7))
VBESetGetDACPaletteFormat(pVesa->pVbe, 8);
pScrn->vtSema = TRUE;
@@ -1136,6 +1159,28 @@ VESAMapVidMem(ScrnInfoPtr pScrn)
pScrn->memPhysBase = pVesa->mapPhys;
pScrn->fbOffset = pVesa->mapOff;
#ifdef XSERVER_LIBPCIACCESS
if ((pVesa->mapPhys != 0xa0000) && (pVesa->pciInfo != NULL)) {
(void) pci_device_map_range(pVesa->pciInfo, pScrn->memPhysBase,
pVesa->mapSize,
(PCI_DEV_MAP_FLAG_WRITABLE
| PCI_DEV_MAP_FLAG_WRITE_COMBINE),
& pVesa->base);
}
else
pVesa->base = xf86MapDomainMemory(pScrn->scrnIndex, 0, pVesa->pciInfo,
pScrn->memPhysBase, pVesa->mapSize);
if (pVesa->base) {
if (pVesa->mapPhys != 0xa0000)
pVesa->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0,
pVesa->pciInfo,
0xa0000, 0x10000);
else
pVesa->VGAbase = pVesa->base;
}
#else
if (pVesa->mapPhys != 0xa0000 && pVesa->pEnt->location.type == BUS_PCI)
pVesa->base = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
pVesa->pciTag, pScrn->memPhysBase,
@@ -1152,6 +1197,7 @@ VESAMapVidMem(ScrnInfoPtr pScrn)
else
pVesa->VGAbase = pVesa->base;
}
#endif
pVesa->ioBase = pScrn->domainIOBase;
@@ -1171,9 +1217,20 @@ VESAUnmapVidMem(ScrnInfoPtr pScrn)
if (pVesa->base == NULL)
return;
#ifdef XSERVER_LIBPCIACCESS
if (pVesa->mapPhys != 0xa0000) {
(void) pci_device_unmap_range(pVesa->pciInfo, pVesa->base,
pVesa->mapSize);
xf86UnMapVidMem(pScrn->scrnIndex, pVesa->VGAbase, 0x10000);
}
else {
xf86UnMapVidMem(pScrn->scrnIndex, pVesa->base, pVesa->mapSize);
}
#else
xf86UnMapVidMem(pScrn->scrnIndex, pVesa->base, pVesa->mapSize);
if (pVesa->mapPhys != 0xa0000)
xf86UnMapVidMem(pScrn->scrnIndex, pVesa->VGAbase, 0x10000);
#endif
pVesa->base = NULL;
}

View File

@@ -69,16 +69,12 @@
#include "xf86Resources.h"
#include "xf86RAC.h"
#include "xf1bpp.h"
#include "xf4bpp.h"
#include "fb.h"
#ifdef USE_AFB
#include "afb.h"
#ifdef XSERVER_LIBPCIACCESS
#include <pciaccess.h>
#endif
#include "mfb.h"
#define VESA_VERSION 4000
#define VESA_NAME "VESA"
#define VESA_DRIVER_NAME "vesa"
@@ -94,9 +90,12 @@ typedef struct _VESARec
EntityInfoPtr pEnt;
CARD16 major, minor;
VbeInfoBlock *vbeInfo;
GDevPtr device;
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *pciInfo;
#else
pciVideoPtr pciInfo;
PCITAG pciTag;
#endif
miBankInfoRec bank;
int curBank, bankSwitchWindowB;
CARD16 maxBytesPerScanline;
@@ -108,7 +107,7 @@ typedef struct _VESARec
CARD32 *pal, *savedPal;
CARD8 *fonts;
xf86MonPtr monitor;
Bool shadowFB, primary;
Bool shadowFB, strict_validation;
CARD32 windowAoffset;
/* Don't override the default refresh rate. */
Bool defaultRefresh;
@@ -117,6 +116,8 @@ typedef struct _VESARec
int nDGAMode;
CloseScreenProcPtr CloseScreen;
CreateScreenResourcesProcPtr CreateScreenResources;
xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
Bool accessEnabled;
OptionInfoPtr Options;
IOADDRESS ioBase;
Bool ModeSetClearScreen;