From f0d53110b3f344aec68e32a170aa038c5a85aeaf Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Thu, 31 Jan 2008 02:12:53 -0200 Subject: [PATCH] Add libpciaccess support to generic vga driver. --- configure.ac | 10 +++++ src/generic.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index 39e2a3d..c24796d 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,16 @@ 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) +AC_CHECK_DECL(XSERVER_LIBPCIACCESS, + [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no], + [#include "xorg-server.h"]) + +if test "x$XSERVER_LIBPCIACCESS" = xyes; then + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) + XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" +fi +AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes) + # Checks for libraries. # Checks for header files. diff --git a/src/generic.c b/src/generic.c index 4be7c39..684552b 100644 --- a/src/generic.c +++ b/src/generic.c @@ -62,6 +62,10 @@ #include "xf86Resources.h" #include "xf86int10.h" +#ifdef XSERVER_LIBPCIACCESS +#include +#endif + /* Some systems #define VGA for their own purposes */ #undef VGA @@ -79,10 +83,31 @@ #define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ #endif +/* + * This structure is used to wrap the screen's CloseScreen vector. + */ +typedef struct _GenericRec +{ + Bool ShadowFB; + Bool KGAUniversal; + CARD8 * ShadowPtr; + CARD32 ShadowPitch; + CloseScreenProcPtr CloseScreen; + OptionInfoPtr Options; +#ifdef XSERVER_LIBPCIACCESS + struct pci_device *pciInfo; +#endif +} GenericRec, *GenericPtr; + + /* Forward definitions */ static const OptionInfoRec *GenericAvailableOptions(int chipid, int busid); static void GenericIdentify(int); static Bool GenericProbe(DriverPtr, int); +#ifdef XSERVER_LIBPCIACCESS +static Bool GenericPciProbe(DriverPtr drv, int entity_num, + struct pci_device *dev, intptr_t match_data); +#endif static Bool GenericPreInit(ScrnInfoPtr, int); static Bool GenericScreenInit(int, ScreenPtr, int, char **); static Bool GenericSwitchMode(int, DisplayModePtr, int); @@ -97,6 +122,24 @@ static Bool GenericMapMem(ScrnInfoPtr scrp); static ModeStatus GenericValidMode(int, DisplayModePtr, Bool, int); +static GenericPtr GenericGetRec(ScrnInfoPtr pScreenInfo); + +enum GenericTypes +{ + CHIP_VGA_GENERIC +}; + +#ifdef XSERVER_LIBPCIACCESS +static const struct pci_id_match generic_device_match[] = { + { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + 0x00030000, 0x00ffffff, CHIP_VGA_GENERIC + }, + + { 0, 0, 0 }, +}; +#endif + /* The root of all evil... */ _X_EXPORT DriverRec VGA = { @@ -106,7 +149,13 @@ _X_EXPORT DriverRec VGA = GenericProbe, GenericAvailableOptions, NULL, - 0 + 0, + NULL, + +#ifdef XSERVER_LIBPCIACCESS + generic_device_match, + GenericPciProbe +#endif }; typedef enum @@ -210,7 +259,13 @@ GenericSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) if (!Initialised) { Initialised = TRUE; - xf86AddDriver(&VGA, Module, 0); + xf86AddDriver(&VGA, Module, +#ifdef XSERVER_LIBPCIACCESS + HaveDriverFuncs +#else + 0 +#endif + ); LoaderRefSymLists(vgahwSymbols, miscfbSymbols, fbSymbols, shadowfbSymbols, int10Symbols, NULL); return (pointer)TRUE; @@ -224,11 +279,6 @@ GenericSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) #endif -enum GenericTypes -{ - CHIP_VGA_GENERIC -}; - /* Supported chipsets */ static SymTabRec GenericChipsets[] = { @@ -267,6 +317,37 @@ GenericAvailableOptions(int chipid, int busid) * do a minimal probe for supported hardware. */ +#ifdef XSERVER_LIBPCIACCESS +static Bool +GenericPciProbe(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) { + GenericPtr pGeneric = GenericGetRec(pScrn); + + pScrn->driverVersion = VGA_VERSION_CURRENT; + pScrn->driverName = VGA_DRIVER_NAME; + pScrn->name = VGA_NAME; + pScrn->Probe = GenericProbe; + pScrn->PreInit = GenericPreInit; + pScrn->ScreenInit = GenericScreenInit; + pScrn->SwitchMode = GenericSwitchMode; + pScrn->AdjustFrame = GenericAdjustFrame; + pScrn->EnterVT = GenericEnterVT; + pScrn->LeaveVT = GenericLeaveVT; + pScrn->FreeScreen = GenericFreeScreen; + + pGeneric->pciInfo = dev; + } + + return (pScrn != NULL); +} +#endif + static Bool GenericProbe(DriverPtr drv, int flags) { @@ -283,6 +364,7 @@ GenericProbe(DriverPtr drv, int flags) if ((numDevSections = xf86MatchDevice(VGA_NAME, &devSections)) <= 0) return FALSE; +#ifndef XSERVER_LIBPCIACCESS /* PCI BUS */ if (xf86GetPciVideoInfo()) { @@ -324,6 +406,7 @@ GenericProbe(DriverPtr drv, int flags) xfree(usedChips); } } +#endif /* Isa Bus */ numUsed = xf86MatchIsaInstances(VGA_NAME, GenericChipsets, @@ -391,20 +474,6 @@ VGAFindIsaDevice(GDevPtr dev) return (int)CHIP_VGA_GENERIC; } -/* - * This structure is used to wrap the screen's CloseScreen vector. - */ -typedef struct _GenericRec -{ - Bool ShadowFB; - Bool KGAUniversal; - CARD8 * ShadowPtr; - CARD32 ShadowPitch; - CloseScreenProcPtr CloseScreen; - OptionInfoPtr Options; -} GenericRec, *GenericPtr; - - static GenericPtr GenericGetRec(ScrnInfoPtr pScreenInfo) { -- 1.5.3.2