summaryrefslogtreecommitdiff
path: root/xserver/hw/xfree86/common
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
commitdbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch)
treef8963ef73903a7b4374adc2354dffbaa905112ac /xserver/hw/xfree86/common
parent33b2029f322f3c238b7ba528083195ad8dde33e1 (diff)
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/hw/xfree86/common')
-rw-r--r--xserver/hw/xfree86/common/Makefile.am28
-rw-r--r--xserver/hw/xfree86/common/Makefile.in113
-rw-r--r--xserver/hw/xfree86/common/compiler.h2
-rw-r--r--xserver/hw/xfree86/common/extramodes6
-rw-r--r--xserver/hw/xfree86/common/modeline2c.awk96
-rw-r--r--xserver/hw/xfree86/common/modeline2c.pl110
-rw-r--r--xserver/hw/xfree86/common/xf86.h76
-rw-r--r--xserver/hw/xfree86/common/xf86AutoConfig.c292
-rw-r--r--xserver/hw/xfree86/common/xf86Bus.c312
-rw-r--r--xserver/hw/xfree86/common/xf86Bus.h9
-rw-r--r--xserver/hw/xfree86/common/xf86Config.c306
-rw-r--r--xserver/hw/xfree86/common/xf86Config.h14
-rw-r--r--xserver/hw/xfree86/common/xf86Configure.c93
-rw-r--r--xserver/hw/xfree86/common/xf86Cursor.c29
-rw-r--r--xserver/hw/xfree86/common/xf86DGA.c219
-rw-r--r--xserver/hw/xfree86/common/xf86DPMS.c53
-rw-r--r--xserver/hw/xfree86/common/xf86DefModes.c160
-rw-r--r--xserver/hw/xfree86/common/xf86DoProbe.c4
-rw-r--r--xserver/hw/xfree86/common/xf86DoScanPci.c116
-rw-r--r--xserver/hw/xfree86/common/xf86Events.c10
-rw-r--r--xserver/hw/xfree86/common/xf86Globals.c58
-rw-r--r--xserver/hw/xfree86/common/xf86Helper.c376
-rw-r--r--xserver/hw/xfree86/common/xf86Init.c447
-rw-r--r--xserver/hw/xfree86/common/xf86Mode.c221
-rw-r--r--xserver/hw/xfree86/common/xf86Module.h15
-rw-r--r--xserver/hw/xfree86/common/xf86PM.c6
-rw-r--r--xserver/hw/xfree86/common/xf86PciInfo.h9
-rw-r--r--xserver/hw/xfree86/common/xf86Priv.h19
-rw-r--r--xserver/hw/xfree86/common/xf86Privstr.h69
-rw-r--r--xserver/hw/xfree86/common/xf86RandR.c41
-rw-r--r--xserver/hw/xfree86/common/xf86Resources.h2
-rw-r--r--xserver/hw/xfree86/common/xf86VidMode.c83
-rw-r--r--xserver/hw/xfree86/common/xf86Xinput.c43
-rw-r--r--xserver/hw/xfree86/common/xf86cmap.c122
-rw-r--r--xserver/hw/xfree86/common/xf86cvt.c292
-rw-r--r--xserver/hw/xfree86/common/xf86fbman.c208
-rw-r--r--xserver/hw/xfree86/common/xf86pciBus.c3109
-rw-r--r--xserver/hw/xfree86/common/xf86pciBus.h25
-rw-r--r--xserver/hw/xfree86/common/xf86sbusBus.c17
-rw-r--r--xserver/hw/xfree86/common/xf86str.h66
-rw-r--r--xserver/hw/xfree86/common/xf86xv.c139
-rw-r--r--xserver/hw/xfree86/common/xf86xvmc.c20
-rw-r--r--xserver/hw/xfree86/common/xf86xvpriv.h4
43 files changed, 2169 insertions, 5270 deletions
diff --git a/xserver/hw/xfree86/common/Makefile.am b/xserver/hw/xfree86/common/Makefile.am
index d983ee9cc..0f44075ba 100644
--- a/xserver/hw/xfree86/common/Makefile.am
+++ b/xserver/hw/xfree86/common/Makefile.am
@@ -21,33 +21,30 @@ RANDRSOURCES = xf86RandR.c
BUSSOURCES = xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
-KBDSOURCES = xf86Kbd@XORG_OS_KBD@.c
-
MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
-xf86DefModeSet.c: $(srcdir)/modeline2c.pl $(MODEDEFSOURCES)
- cat $(MODEDEFSOURCES) | $(PERL) $(srcdir)/modeline2c.pl > $@
+xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
+ cat $(MODEDEFSOURCES) | $(AWK) -f $(srcdir)/modeline2c.awk > $@
BUILT_SOURCES = xf86DefModeSet.c
AM_LDFLAGS = -r
libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
- xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c \
- xf86DoProbe.c xf86DoScanPci.c xf86Events.c \
- xf86Globals.c xf86Io.c xf86AutoConfig.c \
+ xf86Cursor.c xf86DGA.c xf86DPMS.c \
+ xf86DoProbe.c xf86Events.c \
+ xf86Globals.c xf86AutoConfig.c \
xf86MiscExt.c xf86Option.c \
xf86VidMode.c xf86fbman.c xf86cmap.c \
xf86Helper.c xf86PM.c \
xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c \
$(XVSOURCES) $(BUSSOURCES) $(XKBSOURCES) \
- $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES) \
- $(KBDSOURCES)
+ $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES)
nodist_libcommon_la_SOURCES = xf86DefModeSet.c
libinit_a_SOURCES = xf86Build.h xf86Init.c
INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
-I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \
- -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
+ -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
-I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod
sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
@@ -59,11 +56,6 @@ sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
DISTCLEANFILES = xf86Build.h
CLEANFILES = $(BUILT_SOURCES)
-# this is a hack for now. as above we don't have rules to build all of these
-# yet, but we want to make sure they all get into the distball. this should
-# eventually go away.
-DISTKBDSOURCES = xf86Kbd.c xf86KbdBSD.c xf86KbdLnx.c xf86KbdMach.c
-
EXTRA_DIST = \
atKeynames.h \
compiler.h \
@@ -74,7 +66,6 @@ EXTRA_DIST = \
xf86Bus.h \
xf86Config.h \
xf86InPriv.h \
- xf86Keymap.h \
xf86Module.h \
xf86Opt.h \
xf86PciInfo.h \
@@ -94,13 +85,12 @@ EXTRA_DIST = \
xf86Version.h \
xorgVersion.h \
xf86Date.h \
- xf86DefModes.c \
$(MODEDEFSOURCES) \
- modeline2c.pl \
+ modeline2c.awk \
$(DISTKBDSOURCES)
if LNXACPI
XORG_CFLAGS += -DHAVE_ACPI
endif
-AM_CFLAGS = $(XORG_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/xserver/hw/xfree86/common/Makefile.in b/xserver/hw/xfree86/common/Makefile.in
index 5dabb92bb..155bb0083 100644
--- a/xserver/hw/xfree86/common/Makefile.in
+++ b/xserver/hw/xfree86/common/Makefile.in
@@ -66,13 +66,13 @@ libinit_a_OBJECTS = $(am_libinit_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcommon_la_LIBADD =
am__libcommon_la_SOURCES_DIST = xf86Configure.c xf86Bus.c xf86Config.c \
- xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c xf86DoProbe.c \
- xf86DoScanPci.c xf86Events.c xf86Globals.c xf86AutoConfig.c \
- xf86MiscExt.c xf86Option.c xf86VidMode.c xf86fbman.c \
- xf86cmap.c xf86Helper.c xf86PM.c xf86Mode.c xf86Build.h \
- xorgHelper.c xf86Versions.c xf86xv.c xf86xvmc.c xf86isaBus.c \
- xf86pciBus.c xf86fbBus.c xf86noBus.c xf86sbusBus.c xf86XKB.c \
- xf86Debug.c xf86Xinput.c xisb.c xf86RandR.c
+ xf86Cursor.c xf86DGA.c xf86DPMS.c xf86DoProbe.c xf86Events.c \
+ xf86Globals.c xf86AutoConfig.c xf86MiscExt.c xf86Option.c \
+ xf86VidMode.c xf86fbman.c xf86cmap.c xf86Helper.c xf86PM.c \
+ xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c xf86xv.c \
+ xf86xvmc.c xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c \
+ xf86sbusBus.c xf86XKB.c xf86Debug.c xf86Xinput.c xisb.c \
+ xf86RandR.c
@XV_TRUE@am__objects_1 = xf86xv.lo xf86xvmc.lo
@XORG_BUS_SPARC_TRUE@am__objects_2 = xf86sbusBus.lo
am__objects_3 = xf86isaBus.lo xf86pciBus.lo xf86fbBus.lo xf86noBus.lo \
@@ -82,13 +82,13 @@ am__objects_4 = xf86XKB.lo
am__objects_6 = xf86Xinput.lo xisb.lo
am__objects_7 = xf86RandR.lo
am_libcommon_la_OBJECTS = xf86Configure.lo xf86Bus.lo xf86Config.lo \
- xf86Cursor.lo xf86cvt.lo xf86DGA.lo xf86DPMS.lo xf86DoProbe.lo \
- xf86DoScanPci.lo xf86Events.lo xf86Globals.lo \
- xf86AutoConfig.lo xf86MiscExt.lo xf86Option.lo xf86VidMode.lo \
- xf86fbman.lo xf86cmap.lo xf86Helper.lo xf86PM.lo xf86Mode.lo \
- xorgHelper.lo xf86Versions.lo $(am__objects_1) \
- $(am__objects_3) $(am__objects_4) $(am__objects_5) \
- $(am__objects_6) $(am__objects_7)
+ xf86Cursor.lo xf86DGA.lo xf86DPMS.lo xf86DoProbe.lo \
+ xf86Events.lo xf86Globals.lo xf86AutoConfig.lo xf86MiscExt.lo \
+ xf86Option.lo xf86VidMode.lo xf86fbman.lo xf86cmap.lo \
+ xf86Helper.lo xf86PM.lo xf86Mode.lo xorgHelper.lo \
+ xf86Versions.lo $(am__objects_1) $(am__objects_3) \
+ $(am__objects_4) $(am__objects_5) $(am__objects_6) \
+ $(am__objects_7)
nodist_libcommon_la_OBJECTS = xf86DefModeSet.lo
libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) \
$(nodist_libcommon_la_OBJECTS)
@@ -161,8 +161,6 @@ BSD_KQUEUE_APM_FALSE = @BSD_KQUEUE_APM_FALSE@
BSD_KQUEUE_APM_TRUE = @BSD_KQUEUE_APM_TRUE@
BUILDDOCS_FALSE = @BUILDDOCS_FALSE@
BUILDDOCS_TRUE = @BUILDDOCS_TRUE@
-BUILD_DARWIN_FALSE = @BUILD_DARWIN_FALSE@
-BUILD_DARWIN_TRUE = @BUILD_DARWIN_TRUE@
BUILD_DATE = @BUILD_DATE@
BUILD_IOPORT_FALSE = @BUILD_IOPORT_FALSE@
BUILD_IOPORT_TRUE = @BUILD_IOPORT_TRUE@
@@ -234,6 +232,10 @@ DMX_FALSE = @DMX_FALSE@
DMX_TRUE = @DMX_TRUE@
DPMSExtension_FALSE = @DPMSExtension_FALSE@
DPMSExtension_TRUE = @DPMSExtension_TRUE@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRI2_FALSE = @DRI2_FALSE@
+DRI2_TRUE = @DRI2_TRUE@
DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
DRIPROTO_LIBS = @DRIPROTO_LIBS@
DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
@@ -263,7 +265,7 @@ FREEBSD_KLDLOAD_FALSE = @FREEBSD_KLDLOAD_FALSE@
FREEBSD_KLDLOAD_TRUE = @FREEBSD_KLDLOAD_TRUE@
FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
FREETYPE_LIBS = @FREETYPE_LIBS@
-FREETYPE_REQUIRES = @FREETYPE_REQUIRES@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
GLX_FALSE = @GLX_FALSE@
GLX_TRUE = @GLX_TRUE@
@@ -277,8 +279,8 @@ HAVE_AGL_FRAMEWORK_FALSE = @HAVE_AGL_FRAMEWORK_FALSE@
HAVE_AGL_FRAMEWORK_TRUE = @HAVE_AGL_FRAMEWORK_TRUE@
HAVE_DBUS_FALSE = @HAVE_DBUS_FALSE@
HAVE_DBUS_TRUE = @HAVE_DBUS_TRUE@
-HAVE_X_PLUGIN_FALSE = @HAVE_X_PLUGIN_FALSE@
-HAVE_X_PLUGIN_TRUE = @HAVE_X_PLUGIN_TRUE@
+HAVE_XPLUGIN_FALSE = @HAVE_XPLUGIN_FALSE@
+HAVE_XPLUGIN_TRUE = @HAVE_XPLUGIN_TRUE@
HP300_VIDEO_FALSE = @HP300_VIDEO_FALSE@
HP300_VIDEO_TRUE = @HP300_VIDEO_TRUE@
HPPA_VIDEO_FALSE = @HPPA_VIDEO_FALSE@
@@ -319,6 +321,9 @@ KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
KDRIVE_TRUE = @KDRIVE_TRUE@
+LAUNCHD = @LAUNCHD@
+LAUNCHD_FALSE = @LAUNCHD_FALSE@
+LAUNCHD_TRUE = @LAUNCHD_TRUE@
LDFLAGS = @LDFLAGS@
LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
LEX = @LEX@
@@ -373,6 +378,8 @@ OBJCFLAGS = @OBJCFLAGS@
OBJCLINK = @OBJCLINK@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@@ -380,12 +387,11 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
PERL = @PERL@
-PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
-PIXMAN_LIBS = @PIXMAN_LIBS@
PKG_CONFIG = @PKG_CONFIG@
-PLIST_VENDOR_WEB = @PLIST_VENDOR_WEB@
-PLIST_VERSION_STRING = @PLIST_VERSION_STRING@
PPC_VIDEO_FALSE = @PPC_VIDEO_FALSE@
PPC_VIDEO_TRUE = @PPC_VIDEO_TRUE@
PROJECTROOT = @PROJECTROOT@
@@ -397,13 +403,12 @@ RECORD_FALSE = @RECORD_FALSE@
RECORD_TRUE = @RECORD_TRUE@
RES_FALSE = @RES_FALSE@
RES_TRUE = @RES_TRUE@
-RGB_DB = @RGB_DB@
SCREENSAVER_FALSE = @SCREENSAVER_FALSE@
SCREENSAVER_TRUE = @SCREENSAVER_TRUE@
SECURE_RPC_FALSE = @SECURE_RPC_FALSE@
SECURE_RPC_TRUE = @SECURE_RPC_TRUE@
SED = @SED@
-SERVERCONFIGdir = @SERVERCONFIGdir@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SGI_VIDEO_FALSE = @SGI_VIDEO_FALSE@
SGI_VIDEO_TRUE = @SGI_VIDEO_TRUE@
@@ -419,20 +424,21 @@ SPARC64_VIDEO_TRUE = @SPARC64_VIDEO_TRUE@
STRIP = @STRIP@
SUN_KBD_MODE_FALSE = @SUN_KBD_MODE_FALSE@
SUN_KBD_MODE_TRUE = @SUN_KBD_MODE_TRUE@
-SYS_LIBS = @SYS_LIBS@
TSLIB_CFLAGS = @TSLIB_CFLAGS@
TSLIB_FALSE = @TSLIB_FALSE@
TSLIB_LIBS = @TSLIB_LIBS@
TSLIB_TRUE = @TSLIB_TRUE@
USE_CURSES_FALSE = @USE_CURSES_FALSE@
USE_CURSES_TRUE = @USE_CURSES_TRUE@
-USE_RGB_BUILTIN_FALSE = @USE_RGB_BUILTIN_FALSE@
-USE_RGB_BUILTIN_TRUE = @USE_RGB_BUILTIN_TRUE@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
VENDOR_NAME = @VENDOR_NAME@
VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
VENDOR_RELEASE = @VENDOR_RELEASE@
VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11APP_FALSE = @X11APP_FALSE@
+X11APP_TRUE = @X11APP_TRUE@
X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
XACE_FALSE = @XACE_FALSE@
@@ -449,18 +455,22 @@ XDMCP_LIBS = @XDMCP_LIBS@
XDMCP_TRUE = @XDMCP_TRUE@
XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
-XEGLMODULES_LIBS = @XEGLMODULES_LIBS@
XEGL_FALSE = @XEGL_FALSE@
XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
XEGL_TRUE = @XEGL_TRUE@
XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
XEPHYR_FALSE = @XEPHYR_FALSE@
+XEPHYR_HAS_DRI_FALSE = @XEPHYR_HAS_DRI_FALSE@
+XEPHYR_HAS_DRI_TRUE = @XEPHYR_HAS_DRI_TRUE@
XEPHYR_INCS = @XEPHYR_INCS@
XEPHYR_LIBS = @XEPHYR_LIBS@
XEPHYR_TRUE = @XEPHYR_TRUE@
-XERRORDB_PATH = @XERRORDB_PATH@
XEVIE_FALSE = @XEVIE_FALSE@
XEVIE_TRUE = @XEVIE_TRUE@
XF86BIGFONT_FALSE = @XF86BIGFONT_FALSE@
@@ -484,10 +494,12 @@ XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
XGLX_FALSE = @XGLX_FALSE@
XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
XGLX_TRUE = @XGLX_TRUE@
XGL_FALSE = @XGL_FALSE@
XGL_LIBS = @XGL_LIBS@
XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
XGL_TRUE = @XGL_TRUE@
XINERAMA_FALSE = @XINERAMA_FALSE@
XINERAMA_TRUE = @XINERAMA_TRUE@
@@ -501,19 +513,18 @@ XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
XNEST_FALSE = @XNEST_FALSE@
XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
XNEST_TRUE = @XNEST_TRUE@
XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
-XORG_BUS_FREEBSDPCI_FALSE = @XORG_BUS_FREEBSDPCI_FALSE@
-XORG_BUS_FREEBSDPCI_TRUE = @XORG_BUS_FREEBSDPCI_TRUE@
+XORG_BUS_BSDPCI_FALSE = @XORG_BUS_BSDPCI_FALSE@
+XORG_BUS_BSDPCI_TRUE = @XORG_BUS_BSDPCI_TRUE@
XORG_BUS_IX86PCI_FALSE = @XORG_BUS_IX86PCI_FALSE@
XORG_BUS_IX86PCI_TRUE = @XORG_BUS_IX86PCI_TRUE@
XORG_BUS_LINUXPCI_FALSE = @XORG_BUS_LINUXPCI_FALSE@
XORG_BUS_LINUXPCI_TRUE = @XORG_BUS_LINUXPCI_TRUE@
-XORG_BUS_NETBSDPCI_FALSE = @XORG_BUS_NETBSDPCI_FALSE@
-XORG_BUS_NETBSDPCI_TRUE = @XORG_BUS_NETBSDPCI_TRUE@
XORG_BUS_PPCPCI_FALSE = @XORG_BUS_PPCPCI_FALSE@
XORG_BUS_PPCPCI_TRUE = @XORG_BUS_PPCPCI_TRUE@
XORG_BUS_SPARCPCI_FALSE = @XORG_BUS_SPARCPCI_FALSE@
@@ -521,7 +532,6 @@ XORG_BUS_SPARCPCI_TRUE = @XORG_BUS_SPARCPCI_TRUE@
XORG_BUS_SPARC_FALSE = @XORG_BUS_SPARC_FALSE@
XORG_BUS_SPARC_TRUE = @XORG_BUS_SPARC_TRUE@
XORG_CFLAGS = @XORG_CFLAGS@ $(am__append_1)
-XORG_CORE_LIBS = @XORG_CORE_LIBS@
XORG_FALSE = @XORG_FALSE@
XORG_INCS = @XORG_INCS@
XORG_LIBS = @XORG_LIBS@
@@ -531,23 +541,31 @@ XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
XORG_OS = @XORG_OS@
XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
XORG_TRUE = @XORG_TRUE@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
XPRINT_CFLAGS = @XPRINT_CFLAGS@
XPRINT_FALSE = @XPRINT_FALSE@
XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
XPRINT_TRUE = @XPRINT_TRUE@
XP_USE_FREETYPE_FALSE = @XP_USE_FREETYPE_FALSE@
XP_USE_FREETYPE_TRUE = @XP_USE_FREETYPE_TRUE@
XQUARTZ_FALSE = @XQUARTZ_FALSE@
XQUARTZ_TRUE = @XQUARTZ_TRUE@
+XREGISTRY_FALSE = @XREGISTRY_FALSE@
+XREGISTRY_TRUE = @XREGISTRY_TRUE@
XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
XSDLSERVER_FALSE = @XSDLSERVER_FALSE@
XSDLSERVER_TRUE = @XSDLSERVER_TRUE@
XSDL_INCS = @XSDL_INCS@
XSDL_LIBS = @XSDL_LIBS@
+XSELINUX_FALSE = @XSELINUX_FALSE@
+XSELINUX_TRUE = @XSELINUX_TRUE@
XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
@@ -555,12 +573,14 @@ XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
XSERVER_DTRACE_FALSE = @XSERVER_DTRACE_FALSE@
XSERVER_DTRACE_TRUE = @XSERVER_DTRACE_TRUE@
XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
XTRAP_FALSE = @XTRAP_FALSE@
XTRAP_TRUE = @XTRAP_TRUE@
XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
XVFB_FALSE = @XVFB_FALSE@
XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
XVFB_TRUE = @XVFB_TRUE@
XVMC_FALSE = @XVMC_FALSE@
XVMC_TRUE = @XVMC_TRUE@
@@ -585,7 +605,7 @@ XWIN_PRIMARYFB_TRUE = @XWIN_PRIMARYFB_TRUE@
XWIN_RANDR_FALSE = @XWIN_RANDR_FALSE@
XWIN_RANDR_TRUE = @XWIN_RANDR_TRUE@
XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
-XWIN_SYSTEM_LIBS = @XWIN_SYSTEM_LIBS@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
XWIN_TRUE = @XWIN_TRUE@
XWIN_XV_FALSE = @XWIN_XV_FALSE@
XWIN_XV_TRUE = @XWIN_XV_TRUE@
@@ -593,6 +613,11 @@ X_PRIVSEP_FALSE = @X_PRIVSEP_FALSE@
X_PRIVSEP_TRUE = @X_PRIVSEP_TRUE@
YACC = @YACC@
__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
@@ -635,6 +660,7 @@ host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
@@ -667,8 +693,8 @@ MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
BUILT_SOURCES = xf86DefModeSet.c
AM_LDFLAGS = -r
libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
- xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c \
- xf86DoProbe.c xf86DoScanPci.c xf86Events.c \
+ xf86Cursor.c xf86DGA.c xf86DPMS.c \
+ xf86DoProbe.c xf86Events.c \
xf86Globals.c xf86AutoConfig.c \
xf86MiscExt.c xf86Option.c \
xf86VidMode.c xf86fbman.c xf86cmap.c \
@@ -681,7 +707,7 @@ nodist_libcommon_la_SOURCES = xf86DefModeSet.c
libinit_a_SOURCES = xf86Build.h xf86Init.c
INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
-I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \
- -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
+ -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
-I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod
sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
@@ -721,9 +747,8 @@ EXTRA_DIST = \
xf86Version.h \
xorgVersion.h \
xf86Date.h \
- xf86DefModes.c \
$(MODEDEFSOURCES) \
- modeline2c.pl \
+ modeline2c.awk \
$(DISTKBDSOURCES)
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
@@ -798,7 +823,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Debug.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DefModeSet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DoProbe.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DoScanPci.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Events.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Globals.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Helper.Plo@am__quote@
@@ -813,7 +837,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86XKB.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Xinput.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86cmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86cvt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86fbBus.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86fbman.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86isaBus.Plo@am__quote@
@@ -1050,8 +1073,8 @@ uninstall-am: uninstall-info-am uninstall-sdkHEADERS
uninstall-sdkHEADERS
-xf86DefModeSet.c: $(srcdir)/modeline2c.pl $(MODEDEFSOURCES)
- cat $(MODEDEFSOURCES) | $(PERL) $(srcdir)/modeline2c.pl > $@
+xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
+ cat $(MODEDEFSOURCES) | $(AWK) -f $(srcdir)/modeline2c.awk > $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/xserver/hw/xfree86/common/compiler.h b/xserver/hw/xfree86/common/compiler.h
index 536a886c2..ce4ad8edc 100644
--- a/xserver/hw/xfree86/common/compiler.h
+++ b/xserver/hw/xfree86/common/compiler.h
@@ -503,7 +503,7 @@ extern unsigned int inb(unsigned long port);
extern unsigned int inw(unsigned long port);
extern unsigned int inl(unsigned long port);
-# elif defined(linux) && defined(__amd64__)
+# elif defined(linux) && (defined(__amd64__) || defined(__x86_64__))
# include <inttypes.h>
diff --git a/xserver/hw/xfree86/common/extramodes b/xserver/hw/xfree86/common/extramodes
index 1d72861e4..450502670 100644
--- a/xserver/hw/xfree86/common/extramodes
+++ b/xserver/hw/xfree86/common/extramodes
@@ -7,18 +7,12 @@
# 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz
ModeLine "832x624" 57.284 832 864 928 1152 624 625 628 667 -Hsync -Vsync
-# 1152x768 @ 54.8Hz (Titanium PowerBook) hsync: 44.2kHz
-ModeLine "1152x768" 64.995 1152 1178 1314 1472 768 771 777 806 +hsync +vsync
-
# 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz
ModeLine "1400x1050" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +hsync +vsync
# 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz
ModeLine "1400x1050" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +hsync +vsync
-# 1600x1024 @ 60Hz (SGI 1600SW) hsync: 64.0kHz
-Modeline "1600x1024" 106.910 1600 1620 1640 1670 1024 1027 1030 1067 -hsync -vsync
-
# 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz
Modeline "1920x1440" 341.35 1920 2072 2288 2656 1440 1441 1444 1512 -hsync +vsync
diff --git a/xserver/hw/xfree86/common/modeline2c.awk b/xserver/hw/xfree86/common/modeline2c.awk
new file mode 100644
index 000000000..71a956e05
--- /dev/null
+++ b/xserver/hw/xfree86/common/modeline2c.awk
@@ -0,0 +1,96 @@
+#!/usr/bin/awk -f
+#
+# Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
+# All rights reserved.
+#
+# Based on Perl script by Dirk Hohndel.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# Usage: modeline2c.awk < modefile > xf86DefModeSet.c
+#
+
+BEGIN {
+ flagsdict[""] = "0"
+
+ flagsdict["+hsync +vsync"] = "V_PHSYNC | V_PVSYNC"
+ flagsdict["+hsync -vsync"] = "V_PHSYNC | V_NVSYNC"
+ flagsdict["-hsync +vsync"] = "V_NHSYNC | V_PVSYNC"
+ flagsdict["-hsync -vsync"] = "V_NHSYNC | V_NVSYNC"
+ flagsdict["+hsync +vsync interlace"] = "V_PHSYNC | V_PVSYNC | V_INTERLACE"
+ flagsdict["+hsync -vsync interlace"] = "V_PHSYNC | V_NVSYNC | V_INTERLACE"
+ flagsdict["-hsync +vsync interlace"] = "V_NHSYNC | V_PVSYNC | V_INTERLACE"
+ flagsdict["-hsync -vsync interlace"] = "V_NHSYNC | V_NVSYNC | V_INTERLACE"
+
+ print "/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at"
+ print " * modeline2c.awk */"
+ print ""
+ print "/*"
+ print " * Author: Joerg Sonnenberger <joerg@NetBSD.org>"
+ print " * Based on Perl script from Dirk Hohndel <hohndel@XFree86.Org>"
+ print " */"
+ print ""
+ print "#ifdef HAVE_XORG_CONFIG_H"
+ print "#include <xorg-config.h>"
+ print "#endif"
+ print ""
+ print "#ifdef __UNIXOS2__"
+ print "#define I_NEED_OS2_H"
+ print "#endif"
+ print "#include \"xf86.h\""
+ print "#include \"xf86Config.h\""
+ print "#include \"xf86Priv.h\""
+ print "#include \"xf86_OSlib.h\""
+ print ""
+ print "#include \"globals.h\""
+ print ""
+ print "#define MODEPREFIX NULL, NULL, NULL, MODE_OK, M_T_DEFAULT"
+ print "#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0"
+ print ""
+ print "const DisplayModeRec xf86DefaultModes [] = {"
+
+ modeline = "\t{MODEPREFIX,%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n"
+ modeline_data = "^[a-zA-Z]+[ \t]+[^ \t]+[ \t0-9.]+"
+}
+
+/^[mM][oO][dD][eE][lL][iI][nN][eE]/ {
+ flags = $0
+ gsub(modeline_data, "", flags)
+ flags = tolower(flags)
+ printf(modeline, $3 * 1000, $4, $5, $6, $7,
+ $8, $9, $10, $11, flagsdict[flags])
+ # Half-width double scanned modes
+ printf(modeline, $3 * 500, $4/2, $5/2, $6/2, $7/2,
+ $8/2, $9/2, $10/2, $11/2, flagsdict[flags] " | V_DBLSCAN")
+}
+
+/^#/ {
+ print "/*" substr($0, 2) " */"
+}
+
+END {
+ print "};"
+ printf "const int xf86NumDefaultModes = sizeof(xf86DefaultModes) / sizeof(DisplayModeRec);"
+}
diff --git a/xserver/hw/xfree86/common/modeline2c.pl b/xserver/hw/xfree86/common/modeline2c.pl
deleted file mode 100644
index cc6c6925e..000000000
--- a/xserver/hw/xfree86/common/modeline2c.pl
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/usr/bin/perl
-
-# automatically generate the xf86DefModeSet.c file from a normal
-# XF86Config style file of Modelines
-#
-# run as
-#
-# perl /modeline2c.pl < [modesfile] > xf86DefModes.c
-#
-# hackish perl - author Dirk Hohndel
-#
-# Copyright 1999-2003 by The XFree86 Project, Inc.
-#
-# 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:
-#
-# 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
-# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
-#
-# Except as contained in this notice, the name of the copyright holder(s)
-# and author(s) shall not be used in advertising or otherwise to promote
-# the sale, use or other dealings in this Software without prior written
-# authorization from the copyright holder(s) and author(s).
-#
-# $XFree86: xc/programs/Xserver/hw/xfree86/common/modeline2c.pl,v 1.10tsi Exp $
-
-#my %flagshash;
-$flagshash{""} = "0";
-# $flagshash{"Interlace"} = "V_INTERLACE";
-# $flagshash{"+hsync"} = "V_PHSYNC";
-# $flagshash{"-hsync"} = "V_NHSYNC";
-# $flagshash{"+vsync"} = "V_PVSYNC";
-# $flagshash{"-vsync"} = "V_NVSYNC";
-# XXX I'm definitely not a perl guru... -- tsi
-$flagshash{"+hsync +vsync"} = "V_PHSYNC | V_PVSYNC";
-$flagshash{"+hsync -vsync"} = "V_PHSYNC | V_NVSYNC";
-$flagshash{"-hsync +vsync"} = "V_NHSYNC | V_PVSYNC";
-$flagshash{"-hsync -vsync"} = "V_NHSYNC | V_NVSYNC";
-$flagshash{"+hsync +vsync interlace"} = "V_PHSYNC | V_PVSYNC | V_INTERLACE";
-$flagshash{"+hsync -vsync interlace"} = "V_PHSYNC | V_NVSYNC | V_INTERLACE";
-$flagshash{"-hsync +vsync interlace"} = "V_NHSYNC | V_PVSYNC | V_INTERLACE";
-$flagshash{"-hsync -vsync interlace"} = "V_NHSYNC | V_NVSYNC | V_INTERLACE";
-
-# stop CVS from expanding the XFree86 Id here...
-
-$proj = "XFree86";
-printf("/* \$$proj\$ */
-
-/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at
- * modeline2c.pl */
-
-/*
- * Copyright 1999-2003 by The XFree86 Project, Inc.
- *
- * Author: Dirk Hohndel <hohndel\@XFree86.Org>
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifdef __UNIXOS2__
-#define I_NEED_OS2_H
-#endif
-#include \"xf86.h\"
-#include \"xf86Config.h\"
-#include \"xf86Priv.h\"
-#include \"xf86_OSlib.h\"
-
-#include \"globals.h\"
-
-#define MODEPREFIX(name) NULL, NULL, name, MODE_OK, M_T_DEFAULT
-#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-DisplayModeRec xf86DefaultModes [] = {
-");
-while (<>) {
- if (/^\#/) {
- s/^\#//;
- chop;
- print "/*" . $_ . " */\n";
- }
- if (/^ModeLine\s+(\S+)\s+([\d.\s]+)(.*)/i) {
- $name = $1;
- $values = $2;
- $flags = $3;
- $flags =~ y/A-Z/a-z/;
- $values =~ /([\d.]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
- printf("\t{MODEPREFIX(%s),%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n",
- $name,$1*1000,$2,$3,$4,$5,$6,$7,$8,$9,$flagshash{$flags});
-# Also generate half-width doublescanned modes
- printf("\t{MODEPREFIX(\"%dx%d\"),%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s | V_DBLSCAN, MODESUFFIX},\n",
- $2/2,$6/2,$1*500,$2/2,$3/2,$4/2,$5/2,$6/2,$7/2,$8/2,$9/2,$flagshash{$flags});
- }
-
-
-}
-printf("\t{MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}\n};\n");
diff --git a/xserver/hw/xfree86/common/xf86.h b/xserver/hw/xfree86/common/xf86.h
index 51125304e..065102fb5 100644
--- a/xserver/hw/xfree86/common/xf86.h
+++ b/xserver/hw/xfree86/common/xf86.h
@@ -42,6 +42,8 @@
#include <dix-config.h>
#endif
+#include <pciaccess.h>
+
#include "xf86str.h"
#include "xf86Opt.h"
#include <X11/Xfuncproto.h>
@@ -55,23 +57,24 @@
/* General parameters */
extern int xf86DoConfigure;
extern Bool xf86DoConfigurePass1;
-extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
-extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
-extern int xf86PixmapIndex;
+extern DevPrivateKey xf86ScreenKey;
+extern DevPrivateKey xf86CreateRootWindowKey;
+extern DevPrivateKey xf86PixmapKey;
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern const unsigned char byte_reversed[256];
extern ScrnInfoPtr xf86CurrentScreen;
extern Bool pciSlotClaimed;
extern Bool isaSlotClaimed;
extern Bool fbSlotClaimed;
-#ifdef __sparc__
+#if defined(__sparc__) || defined(__sparc)
extern Bool sbusSlotClaimed;
#endif
extern confDRIRec xf86ConfigDRI;
extern Bool xf86inSuspend;
+extern Bool xf86DRI2Enabled(void);
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
-
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
+ xf86ScreenKey))
#define XF86FLIP_PIXELS() \
do { \
if (xf86GetFlipPixels()) { \
@@ -85,29 +88,18 @@ extern Bool xf86inSuspend;
#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
(((p) == Pix24Use32) ? 32 : 0))
-/* variables for debugging */
-#ifdef BUILDDEBUG
-extern char* xf86p8bit[];
-extern CARD32 xf86DummyVar1;
-extern CARD32 xf86DummyVar2;
-extern CARD32 xf86DummyVar3;
-#endif
-
/* Function Prototypes */
#ifndef _NO_XF86_PROTOTYPES
/* xf86Bus.c */
-Bool xf86CheckPciSlot(int bus, int device, int func);
-int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+Bool xf86CheckPciSlot( const struct pci_device * );
+int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp,
int chipset, GDevPtr dev, Bool active);
Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
int *func);
Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
void xf86FormatPciBusNumber(int busnum, char *buffer);
-pciVideoPtr *xf86GetPciVideoInfo(void);
-pciConfigPtr *xf86GetPciConfigInfo(void);
-void xf86SetPciVideo(pciVideoPtr, resType);
void xf86PrintResList(int verb, resPtr list);
resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
@@ -118,7 +110,7 @@ int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
void xf86EnableAccess(ScrnInfoPtr pScrn);
void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
-Bool xf86IsPrimaryPci(pciVideoPtr pPci);
+Bool xf86IsPrimaryPci(struct pci_device * pPci);
Bool xf86IsPrimaryIsa(void);
/* new RAC */
resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex);
@@ -134,40 +126,23 @@ int xf86GetNumEntityInstances(int entityIndex);
GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
-int xf86GetPciEntity(int bus, int dev, int func);
+struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
EntityProc enter, EntityProc leave, pointer);
void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
resPtr xf86RegisterResources(int entityIndex, resList list,
unsigned long Access);
-Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base);
void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
xf86SetAccessFuncPtr oldFuncs);
Bool xf86IsEntityPrimary(int entityIndex);
-Bool xf86FixPciResource(int entityIndex, int prt, memType alignment,
- unsigned long type);
resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
void xf86EnterServerState(xf86State state);
-resRange xf86GetBlock(unsigned long type, memType size,
- memType window_start, memType window_end,
- memType align_mask, resPtr avoid);
-resRange xf86GetSparse(unsigned long type, memType fixed_bits,
- memType decode_mask, memType address_mask,
- resPtr avoid);
memType xf86ChkConflict(resRange *rgp, int entityIndex);
-Bool xf86IsPciDevPresent(int bus, int dev, int func);
ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
Bool xf86NoSharedResources(int screenIndex, resType res);
resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
-pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
- char n, pciVideoPtr pvp_exclude);
-pciVideoPtr xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
- char n, pciVideoPtr pvp_exclude);
-#ifdef INCLUDE_DEPRECATED
-void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable);
-#endif
void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
@@ -186,8 +161,8 @@ DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
/* xf86Configure.c */
GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
void *busData, int chipset);
-GDevPtr xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo,
- int chipset);
+GDevPtr xf86AddDeviceToConfigure( const char *driver,
+ struct pci_device * pVideo, int chipset );
/* xf86Cursor.c */
@@ -363,14 +338,12 @@ int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
pointer value);
Bool xf86IsUnblank(int mode);
-void xf86AddModuleInfo(ModuleInfoPtr info, pointer module);
-void xf86DeleteModuleInfo(int idx);
+_X_DEPRECATED void xf86AddModuleInfo(pointer info, pointer module);
+_X_DEPRECATED void xf86DeleteModuleInfo(int idx);
+void xf86getsecs(long *, long *);
/* xf86Debug.c */
#ifdef BUILDDEBUG
- void xf86Break1(void);
-void xf86Break2(void);
-void xf86Break3(void);
CARD8 xf86PeekFb8(CARD8 *p);
CARD16 xf86PeekFb16(CARD16 *p);
CARD32 xf86PeekFb32(CARD32 *p);
@@ -383,8 +356,6 @@ CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset);
void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v);
void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v);
void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v);
-extern void xf86SPTimestamp(xf86TsPtr* timestamp, char* string);
-extern void xf86STimestamp(xf86TsPtr* timestamp);
#endif
/* xf86Init.c */
@@ -418,6 +389,15 @@ void xf86PruneDriverModes(ScrnInfoPtr scrp);
void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
void xf86PrintModes(ScrnInfoPtr scrp);
void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+double xf86ModeHSync(DisplayModePtr mode);
+double xf86ModeVRefresh(DisplayModePtr mode);
+void xf86SetModeDefaultName(DisplayModePtr mode);
+void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
+DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode);
+DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2);
+void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
+DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
/* xf86Option.c */
diff --git a/xserver/hw/xfree86/common/xf86AutoConfig.c b/xserver/hw/xfree86/common/xf86AutoConfig.c
index 541fb2781..7e5fab412 100644
--- a/xserver/hw/xfree86/common/xf86AutoConfig.c
+++ b/xserver/hw/xfree86/common/xf86AutoConfig.c
@@ -39,20 +39,10 @@
#include "xf86Config.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "dirent.h"
/* Sections for the default built-in configuration. */
-#define BUILTIN_MODULE_SECTION \
- "Section \"Module\"\n" \
- "\tLoad\t\"extmod\"\n" \
- "\tLoad\t\"dbe\"\n" \
- "\tLoad\t\"glx\"\n" \
- "\tLoad\t\"freetype\"\n" \
- "\tLoad\t\"type1\"\n" \
- "\tLoad\t\"record\"\n" \
- "\tLoad\t\"dri\"\n" \
- "EndSection\n\n"
-
#define BUILTIN_DEVICE_NAME \
"\"Builtin Default %s Device %d\""
@@ -68,14 +58,6 @@
BUILTIN_DEVICE_SECTION_PRE \
BUILTIN_DEVICE_SECTION_POST
-#define BUILTIN_MONITOR_NAME \
- "\"Builtin Default Monitor\""
-
-#define BUILTIN_MONITOR_SECTION \
- "Section \"Monitor\"\n" \
- "\tIdentifier\t" BUILTIN_MONITOR_NAME "\n" \
- "EndSection\n\n"
-
#define BUILTIN_SCREEN_NAME \
"\"Builtin Default %s Screen %d\""
@@ -83,7 +65,6 @@
"Section \"Screen\"\n" \
"\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
"\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
- "\tMonitor\t" BUILTIN_MONITOR_NAME "\n" \
"EndSection\n\n"
#define BUILTIN_LAYOUT_SECTION_PRE \
@@ -101,7 +82,6 @@ static int builtinLines = 0;
static const char *deviceList[] = {
"fbdev",
"vesa",
- "vga",
NULL
};
@@ -156,7 +136,7 @@ AppendToConfig(const char *s)
}
static const char *
-videoPtrToDriverName(pciVideoPtr info)
+videoPtrToDriverName(struct pci_device *dev)
{
/*
* things not handled yet:
@@ -164,10 +144,10 @@ videoPtrToDriverName(pciVideoPtr info)
* xgi.
*/
- switch (info->vendor)
+ switch (dev->vendor_id)
{
case 0x1022:
- if (info->chipType == 0x2081)
+ if (dev->device_id == 0x2081)
return "geode";
else
return NULL;
@@ -178,24 +158,16 @@ videoPtrToDriverName(pciVideoPtr info)
case 0x102c: return "chips";
case 0x1013: return "cirrus";
case 0x8086:
- switch (info->chipType)
- {
- case 0x00d1: case 0x7800:
- return "i740";
- case 0x1132: case 0x2562: case 0x2572: case 0x3577:
- case 0x3582: case 0x358e: case 0x7121: case 0x7123:
- case 0x7125:
- return "i810";
- default:
- return "intel";
- }
+ if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800))
+ return "i740";
+ else return "intel";
case 0x102b: return "mga";
case 0x10c8: return "neomagic";
case 0x105d: return "i128";
case 0x10de: case 0x12d2: return "nv";
case 0x1163: return "rendition";
case 0x5333:
- switch (info->chipType)
+ switch (dev->device_id)
{
case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
case 0x8812: case 0x8814: case 0x8901:
@@ -209,7 +181,7 @@ videoPtrToDriverName(pciVideoPtr info)
case 0x1039: return "sis";
case 0x126f: return "siliconmotion";
case 0x121a:
- if (info->chipType < 0x0003)
+ if (dev->device_id < 0x0003)
return "voodoo";
else
return "tdfx";
@@ -228,29 +200,10 @@ xf86AutoConfig(void)
{
const char **p;
char buf[1024];
- pciVideoPtr *pciptr, info = NULL;
- char *driver = NULL;
+ const char *driver = NULL;
ConfigStatus ret;
- /* Find the primary device, and get some information about it. */
- if (xf86PciVideoInfo) {
- for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) {
- if (xf86IsPrimaryPci(info)) {
- break;
- }
- }
- if (!info) {
- ErrorF("Primary device is not PCI\n");
- }
- } else {
- ErrorF("xf86PciVideoInfo is not set\n");
- }
-
- if (info)
- driver = videoPtrToDriverName(info);
-
- AppendToConfig(BUILTIN_MODULE_SECTION);
- AppendToConfig(BUILTIN_MONITOR_SECTION);
+ driver = chooseVideoDriver();
if (driver) {
snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE,
@@ -300,3 +253,226 @@ xf86AutoConfig(void)
return (ret == CONFIG_OK);
}
+
+int
+xchomp(char *line)
+{
+ size_t len = 0;
+
+ if (!line) {
+ return 1;
+ }
+
+ len = strlen(line);
+ if (line[len - 1] == '\n' && len > 0) {
+ line[len - 1] = '\0';
+ }
+ return 0;
+}
+
+GDevPtr
+autoConfigDevice(GDevPtr preconf_device)
+{
+ GDevPtr ptr = NULL;
+
+ if (!xf86configptr) {
+ return NULL;
+ }
+
+ /* If there's a configured section with no driver chosen, use it */
+ if (preconf_device) {
+ ptr = preconf_device;
+ } else {
+ ptr = (GDevPtr)xalloc(sizeof(GDevRec));
+ if (!ptr) {
+ return NULL;
+ }
+ memset((GDevPtr)ptr, 0, sizeof(GDevRec));
+ ptr->chipID = -1;
+ ptr->chipRev = -1;
+ ptr->irq = -1;
+
+ ptr->active = TRUE;
+ ptr->claimed = FALSE;
+ ptr->identifier = "Autoconfigured Video Device";
+ ptr->driver = NULL;
+ }
+ if (!ptr->driver) {
+ ptr->driver = chooseVideoDriver();
+ }
+
+ /* TODO Handle multiple screen sections */
+ if (xf86ConfigLayout.screens && !xf86ConfigLayout.screens->screen->device) {
+ xf86ConfigLayout.screens->screen->device = ptr;
+ ptr->myScreenSection = xf86ConfigLayout.screens->screen;
+ }
+ xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n");
+
+ return ptr;
+}
+
+#ifdef __linux__
+/* This function is used to provide a workaround for binary drivers that
+ * don't export their PCI ID's properly. If distros don't end up using this
+ * feature it can and should be removed because the symbol-based resolution
+ * scheme should be the primary one */
+static void
+matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
+{
+ DIR *idsdir;
+ FILE *fp;
+ struct dirent *direntry;
+ char *line = NULL;
+ size_t len;
+ ssize_t read;
+ char path_name[256], vendor_str[5], chip_str[5];
+ uint16_t vendor, chip;
+ int i, j;
+
+ idsdir = opendir(PCI_TXT_IDS_PATH);
+ if (!idsdir)
+ return;
+
+ xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
+ direntry = readdir(idsdir);
+ /* Read the directory */
+ while (direntry) {
+ if (direntry->d_name[0] == '.') {
+ direntry = readdir(idsdir);
+ continue;
+ }
+ len = strlen(direntry->d_name);
+ /* A tiny bit of sanity checking. We should probably do better */
+ if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
+ /* We need the full path name to open the file */
+ strncpy(path_name, PCI_TXT_IDS_PATH, 256);
+ strncat(path_name, "/", 1);
+ strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
+ fp = fopen(path_name, "r");
+ if (fp == NULL) {
+ xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
+ goto end;
+ }
+ /* Read the file */
+#ifdef __GLIBC__
+ while ((read = getline(&line, &len, fp)) != -1) {
+#else
+ while ((line = fgetln(fp, &len)) != (char *)NULL) {
+#endif /* __GLIBC __ */
+ xchomp(line);
+ if (isdigit(line[0])) {
+ strncpy(vendor_str, line, 4);
+ vendor_str[4] = '\0';
+ vendor = (int)strtol(vendor_str, NULL, 16);
+ if ((strlen(&line[4])) == 0) {
+ chip_str[0] = '\0';
+ chip = -1;
+ } else {
+ /* Handle trailing whitespace */
+ if (isspace(line[4])) {
+ chip_str[0] = '\0';
+ chip = -1;
+ } else {
+ /* Ok, it's a real ID */
+ strncpy(chip_str, &line[4], 4);
+ chip_str[4] = '\0';
+ chip = (int)strtol(chip_str, NULL, 16);
+ }
+ }
+ if (vendor == match_vendor && chip == match_chip ) {
+ i = 0;
+ while (matches[i]) {
+ i++;
+ }
+ matches[i] = (char*)xalloc(sizeof(char) * strlen(direntry->d_name) - 3);
+ if (!matches[i]) {
+ xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
+ goto end;
+ }
+ /* hack off the .ids suffix. This should guard
+ * against other problems, but it will end up
+ * taking off anything after the first '.' */
+ for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
+ if (direntry->d_name[j] == '.') {
+ matches[i][j] = '\0';
+ break;
+ } else {
+ matches[i][j] = direntry->d_name[j];
+ }
+ }
+ xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
+ }
+ } else {
+ /* TODO Handle driver overrides here */
+ }
+ }
+ fclose(fp);
+ }
+ direntry = readdir(idsdir);
+ }
+ end:
+ xfree(line);
+ closedir(idsdir);
+}
+#endif /* __linux__ */
+
+char*
+chooseVideoDriver(void)
+{
+ struct pci_device * info = NULL;
+ struct pci_device_iterator *iter;
+ char *chosen_driver = NULL;
+ int i;
+ char *matches[20]; /* If we have more than 20 drivers we're in trouble */
+
+ for (i=0 ; i<20 ; i++)
+ matches[i] = NULL;
+
+ /* Find the primary device, and get some information about it. */
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((info = pci_device_next(iter)) != NULL) {
+ if (xf86IsPrimaryPci(info)) {
+ break;
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+ if (!info) {
+ ErrorF("Primary device is not PCI\n");
+ }
+#ifdef __linux__
+ else {
+ matchDriverFromFiles(matches, info->vendor_id, info->device_id);
+ }
+#endif /* __linux__ */
+
+ /* TODO Handle multiple drivers claiming to support the same PCI ID */
+ if (matches[0]) {
+ chosen_driver = matches[0];
+ } else {
+ if (info != NULL)
+ chosen_driver = videoPtrToDriverName(info);
+ if (chosen_driver == NULL) {
+#if defined __i386__ || defined __amd64__ || defined __x86_64__ || defined __hurd__
+ chosen_driver = "vesa";
+#elif defined __sparc__
+ chosen_driver = "sunffb";
+#else
+ chosen_driver = "fbdev";
+#endif
+ }
+ }
+
+ xf86Msg(X_DEFAULT, "Matched %s for the autoconfigured driver\n", chosen_driver);
+
+ i = 0;
+ while (matches[i]) {
+ if (matches[i] != chosen_driver) {
+ xfree(matches[i]);
+ }
+ i++;
+ }
+
+ return chosen_driver;
+}
diff --git a/xserver/hw/xfree86/common/xf86Bus.c b/xserver/hw/xfree86/common/xf86Bus.c
index 1ca93ca8d..5722667b2 100644
--- a/xserver/hw/xfree86/common/xf86Bus.c
+++ b/xserver/hw/xfree86/common/xf86Bus.c
@@ -52,6 +52,7 @@
#include "xf86_OSproc.h"
#include "xf86RAC.h"
+#include "Pci.h"
/* Entity data */
EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
@@ -74,10 +75,6 @@ static resPtr AccReducers = NULL;
/* resource lists */
resPtr Acc = NULL;
-resPtr osRes = NULL;
-
-/* allocatable ranges */
-resPtr ResRange = NULL;
/* predefined special resources */
_X_EXPORT resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
@@ -113,7 +110,7 @@ void
xf86BusProbe(void)
{
xf86PciProbe();
-#if defined(__sparc__) || defined(__sparc)
+#if (defined(__sparc__) || defined(__sparc))
xf86SbusProbe();
#endif
}
@@ -253,9 +250,7 @@ xf86IsEntityPrimary(int entityIndex)
switch (pEnt->busType) {
case BUS_PCI:
- return (pEnt->pciBusId.bus == primaryBus.id.pci.bus &&
- pEnt->pciBusId.device == primaryBus.id.pci.device &&
- pEnt->pciBusId.func == primaryBus.id.pci.func);
+ return (pEnt->bus.id.pci == primaryBus.id.pci);
case BUS_ISA:
return TRUE;
case BUS_SBUS:
@@ -295,8 +290,10 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
if (entityIndex == -1)
return;
if (xf86Entities[entityIndex]->inUse &&
- !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL))
- FatalError("Requested Entity already in use!\n");
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
+ ErrorF("Requested Entity already in use!\n");
+ return;
+ }
pScrn->numEntities++;
pScrn->entityList = xnfrealloc(pScrn->entityList,
@@ -1361,27 +1358,12 @@ xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
void
xf86ResourceBrokerInit(void)
{
- resPtr resPci;
-
- osRes = NULL;
-
- /* Get the addressable ranges */
- ResRange = xf86BusAccWindowsFromOS();
- xf86MsgVerb(X_INFO, 3, "Addressable bus resource ranges are\n");
- xf86PrintResList(3, ResRange);
+ Acc = NULL;
/* Get the ranges used exclusively by the system */
- osRes = xf86AccResFromOS(osRes);
- xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
- xf86PrintResList(3, osRes);
-
- /* Bus dep initialization */
- resPci = ResourceBrokerInitPci(&osRes);
- Acc = xf86JoinResLists(xf86DupResList(osRes), resPci);
-
- xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n");
+ Acc = xf86AccResFromOS(Acc);
+ xf86MsgVerb(X_INFO, 3, "System resource ranges:\n");
xf86PrintResList(3, Acc);
-
}
#define MEM_ALIGN (1024 * 1024)
@@ -1544,213 +1526,6 @@ RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, Bool useEstimated
#endif
/*
- * Resource request code
- */
-
-#define ALIGN(x,a) ((x) + a) &~(a)
-
-_X_EXPORT resRange
-xf86GetBlock(unsigned long type, memType size,
- memType window_start, memType window_end,
- memType align_mask, resPtr avoid)
-{
- memType min, max, tmp;
- resRange r = {ResEnd,0,0};
- resPtr res_range = ResRange;
-
- if (!size) return r;
- if (window_end < window_start || (window_end - window_start) < (size - 1)) {
- ErrorF("Requesting insufficient memory window!:"
- " start: 0x%lx end: 0x%lx size 0x%lx\n",
- window_start,window_end,size);
- return r;
- }
- type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResBlock;
-
- while (res_range) {
- if ((type & ResTypeMask) == (res_range->res_type & ResTypeMask)) {
- if (res_range->block_begin > window_start)
- min = res_range->block_begin;
- else
- min = window_start;
- if (res_range->block_end < window_end)
- max = res_range->block_end;
- else
- max = window_end;
- min = ALIGN(min,align_mask);
- /* do not produce an overflow! */
- while (min < max && (max - min) >= (size - 1)) {
- RANGE(r,min,min + size - 1,type);
- tmp = ChkConflict(&r,Acc,SETUP);
- if (!tmp) {
- tmp = ChkConflict(&r,avoid,SETUP);
- if (!tmp) {
- return r;
- }
- }
- min = ALIGN(tmp,align_mask);
- }
- }
- res_range = res_range->next;
- }
- RANGE(r,0,0,ResEnd);
- return r;
-}
-
-#define mt_max ~(memType)0
-#define length sizeof(memType) * 8
-/*
- * make_base() -- assign the lowest bits to the bits set in mask.
- * example: mask 011010 val 0000110 -> 011000
- */
-static memType
-make_base(memType val, memType mask)
-{
- int i,j = 0;
- memType ret = 0
- ;
- for (i = 0;i<length;i++) {
- if ((1 << i) & mask) {
- ret |= (((val >> j) & 1) << i);
- j++;
- }
- }
- return ret;
-}
-
-/*
- * make_base() -- assign the bits set in mask to the lowest bits.
- * example: mask 011010 , val 010010 -> 000011
- */
-static memType
-unmake_base(memType val, memType mask)
-{
- int i,j = 0;
- memType ret = 0;
-
- for (i = 0;i<length;i++) {
- if ((1 << i) & mask) {
- ret |= (((val >> i) & 1) << j);
- j++;
- }
- }
- return ret;
-}
-
-static memType
-fix_counter(memType val, memType old_mask, memType mask)
-{
- mask = old_mask & mask;
-
- val = make_base(val,old_mask);
- return unmake_base(val,mask);
-}
-
-_X_EXPORT resRange
-xf86GetSparse(unsigned long type, memType fixed_bits,
- memType decode_mask, memType address_mask, resPtr avoid)
-{
- resRange r = {ResEnd,0,0};
- memType new_mask;
- memType mask1;
- memType base;
- memType counter = 0;
- memType counter1;
- memType max_counter = ~(memType)0;
- memType max_counter1;
- memType conflict = 0;
-
- /* for sanity */
- type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResSparse;
-
- /*
- * a sparse address consists of 3 parts:
- * fixed_bits: F bits which hard decoded by the hardware
- * decode_bits: D bits which are used to decode address
- * but which may be set by software
- * address_bits: A bits which are used to address the
- * sparse range.
- * the decode_mask marks all decode bits while the address_mask
- * masks out all address_bits:
- * F D A
- * decode_mask: 0 1 0
- * address_mask: 1 1 0
- */
- decode_mask &= address_mask;
- new_mask = decode_mask;
-
- /*
- * We start by setting the decode_mask bits to different values
- * when a conflict is found the address_mask of the conflicting
- * resource is returned. We remove those bits from decode_mask
- * that are also set in the returned address_mask as they always
- * conflict with resources which use them as address masks.
- * The resoulting mask is stored in new_mask.
- * We continue until no conflict is found or until we have
- * tried all possible settings of new_mask.
- */
- while (1) {
- base = make_base(counter,new_mask) | fixed_bits;
- RANGE(r,base,address_mask,type);
- conflict = ChkConflict(&r,Acc,SETUP);
- if (!conflict) {
- conflict = ChkConflict(&r,avoid,SETUP);
- if (!conflict) {
- return r;
- }
- }
- counter = fix_counter(counter,new_mask,conflict);
- max_counter = fix_counter(max_counter,new_mask,conflict);
- new_mask &= conflict;
- counter ++;
- if (counter > max_counter) break;
- }
- if (!new_mask && (new_mask == decode_mask)) {
- RANGE(r,0,0,ResEnd);
- return r;
- }
- /*
- * if we haven't been successful we also try to modify those
- * bits in decode_mask that are not at the same time set in
- * new mask. These bits overlap with address_bits of some
- * resources. If a conflict with a resource of this kind is
- * found (ie. returned_mask & mask1 != mask1) with
- * mask1 = decode_mask & ~new_mask we cannot
- * use our choice of bits in the new_mask part. We try
- * another choice.
- */
- max_counter = fix_counter(mt_max,mt_max,new_mask);
- mask1 = decode_mask & ~new_mask;
- max_counter1 = fix_counter(mt_max,mt_max,mask1);
- counter = 0;
-
- while (1) {
- counter1 = 0;
- while (1) {
- base = make_base(counter1,mask1);
- RANGE(r,base,address_mask,type);
- conflict = ChkConflict(&r,Acc,SETUP);
- if (!conflict) {
- conflict = ChkConflict(&r,avoid,SETUP);
- if (!conflict) {
- return r;
- }
- }
- counter1 ++;
- if ((mask1 & conflict) != mask1 || counter1 > max_counter1)
- break;
- }
- counter ++;
- if (counter > max_counter) break;
- }
- RANGE(r,0,0,ResEnd);
- return r;
-}
-
-#undef length
-#undef mt_max
-
-/*
* Resource registrarion
*/
@@ -1765,7 +1540,7 @@ xf86GetResourcesImplicitly(int entityIndex)
case BUS_SBUS:
return NULL;
case BUS_PCI:
- return GetImplicitPciResources(entityIndex);
+ return NULL;
case BUS_last:
return NULL;
}
@@ -1857,31 +1632,34 @@ xf86RegisterResources(int entityIndex, resList list, unsigned long access)
}
static void
-busTypeSpecific(EntityPtr pEnt, xf86State state, xf86AccessPtr *acc_mem,
+busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem,
xf86AccessPtr *acc_io, xf86AccessPtr *acc_mem_io)
{
- pciAccPtr *ppaccp;
-
switch (pEnt->bus.type) {
case BUS_ISA:
case BUS_SBUS:
- *acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
- break;
+ *acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
break;
- case BUS_PCI:
- ppaccp = xf86PciAccInfo;
- while (*ppaccp) {
- if ((*ppaccp)->busnum == pEnt->pciBusId.bus
- && (*ppaccp)->devnum == pEnt->pciBusId.device
- && (*ppaccp)->funcnum == pEnt->pciBusId.func) {
- *acc_io = &(*ppaccp)->ioAccess;
- *acc_mem = &(*ppaccp)->memAccess;
- *acc_mem_io = &(*ppaccp)->io_memAccess;
- break;
- }
- ppaccp++;
+ case BUS_PCI: {
+ struct pci_device *const dev = pEnt->bus.id.pci;
+
+ if ((dev != NULL) && ((void *)dev->user_data != NULL)) {
+ pciAccPtr const paccp = (pciAccPtr) dev->user_data;
+
+ *acc_io = & paccp->ioAccess;
+ *acc_mem = & paccp->memAccess;
+ *acc_mem_io = & paccp->io_memAccess;
+ }
+ else {
+ /* FIXME: This is an error path. We should probably have an
+ * FIXME: assertion here or something.
+ */
+ *acc_io = NULL;
+ *acc_mem = NULL;
+ *acc_mem_io = NULL;
}
break;
+ }
default:
*acc_mem = *acc_io = *acc_mem_io = NULL;
break;
@@ -1897,7 +1675,7 @@ setAccess(EntityPtr pEnt, xf86State state)
xf86AccessPtr org_mem = NULL, org_io = NULL, org_mem_io = NULL;
int prop;
- busTypeSpecific(pEnt,state,&acc_mem,&acc_io,&acc_mem_io);
+ busTypeSpecific(pEnt, &acc_mem, &acc_io, &acc_mem_io);
/* The replacement function needs to handle _all_ shared resources */
/* unless they are handeled locally and disabled otherwise */
@@ -2450,16 +2228,6 @@ xf86PostProbe(void)
#endif
}
xf86FreeResList(acc);
-#if !(defined(__alpha__) && defined(linux)) && \
- !(defined(__ia64__) && defined(linux)) && \
- !(defined(__alpha__) && defined(__OpenBSD__)) && \
- !(defined(__sparc64__) && defined(__OpenBSD__))
- /*
- * No need to validate on Alpha Linux or OpenBSD/sparc64,
- * trust the kernel.
- */
- ValidatePci();
-#endif
xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n");
xf86PrintResList(3, Acc);
@@ -2978,14 +2746,16 @@ xf86FindPrimaryDevice()
CheckGenericGA();
if (primaryBus.type != BUS_NONE) {
char *bus;
- char *loc = xnfcalloc(1,9);
- if (loc == NULL) return;
+ char loc[16];
switch (primaryBus.type) {
case BUS_PCI:
bus = "PCI";
- sprintf(loc," %2.2x:%2.2x:%1.1x",primaryBus.id.pci.bus,
- primaryBus.id.pci.device,primaryBus.id.pci.func);
+ snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x",
+ primaryBus.id.pci->bus,
+ primaryBus.id.pci->domain,
+ primaryBus.id.pci->dev,
+ primaryBus.id.pci->func);
break;
case BUS_ISA:
bus = "ISA";
@@ -2993,17 +2763,15 @@ xf86FindPrimaryDevice()
break;
case BUS_SBUS:
bus = "SBUS";
- sprintf(loc," %2.2x",primaryBus.id.sbus.fbNum);
+ snprintf(loc, sizeof(loc), " %2.2x", primaryBus.id.sbus.fbNum);
break;
default:
bus = "";
loc[0] = '\0';
}
-
+
xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc);
- xfree(loc);
}
-
}
#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__)
diff --git a/xserver/hw/xfree86/common/xf86Bus.h b/xserver/hw/xfree86/common/xf86Bus.h
index b7d16089c..489ee3459 100644
--- a/xserver/hw/xfree86/common/xf86Bus.h
+++ b/xserver/hw/xfree86/common/xf86Bus.h
@@ -40,7 +40,7 @@
#define _XF86_BUS_H
#include "xf86pciBus.h"
-#ifdef __sparc__
+#if defined(__sparc__) || defined(__sparc)
#include "xf86sbusBus.h"
#endif
@@ -91,7 +91,6 @@ typedef struct {
#define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED)
#define busType bus.type
-#define pciBusId bus.id.pci
#define isaBusId bus.id.isa
#define sbusBusId bus.id.sbus
@@ -114,7 +113,7 @@ typedef struct x_BusAccRec {
struct {
int bus;
int primary_bus;
- PCITAG acc;
+ struct pci_device * dev;
pciBridgesSave save;
} pci;
} busdep;
@@ -133,7 +132,6 @@ extern int xf86NumEntities;
extern xf86AccessRec AccessNULL;
extern BusRec primaryBus;
extern resPtr Acc;
-extern resPtr osRes;
extern resPtr ResRange;
extern BusAccPtr xf86BusAccInfo;
@@ -141,12 +139,9 @@ int xf86AllocateEntity(void);
BusType StringToBusType(const char* busID, const char **retID);
memType ChkConflict(resRange *rgp, resPtr res, xf86State state);
Bool xf86IsSubsetOf(resRange range, resPtr list);
-Bool xf86IsListSubsetOf(resPtr list, resPtr BaseList);
resPtr xf86ExtractTypeFromList(resPtr list, unsigned long type);
-resPtr findIntersect(resRange Range, resPtr list);
resPtr xf86FindIntersect(resRange Range, resPtr list);
void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment,
Bool useEstimated);
-void xf86ConvertListToHost(int entityIndex, resPtr list);
#endif /* _XF86_BUS_H */
diff --git a/xserver/hw/xfree86/common/xf86Config.c b/xserver/hw/xfree86/common/xf86Config.c
index 798602274..dfa90e361 100644
--- a/xserver/hw/xfree86/common/xf86Config.c
+++ b/xserver/hw/xfree86/common/xf86Config.c
@@ -60,6 +60,7 @@
#include "configProcs.h"
#include "globals.h"
#include "extension.h"
+#include "Pci.h"
#ifdef XINPUT
#include "xf86Xinput.h"
@@ -76,7 +77,7 @@ extern DeviceAssocRec mouse_assoc;
#include "picture.h"
#endif
-#if (defined(i386) || defined(__i386__)) && \
+#if (defined(__i386__)) && \
(defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || defined(linux) || \
(defined(SVR4) && !defined(sun)) || defined(__GNU__))
@@ -92,7 +93,6 @@ extern DeviceAssocRec mouse_assoc;
"/etc/X11/%R," "%P/etc/X11/%R," \
"%E," "%F," \
"/etc/X11/%F," "%P/etc/X11/%F," \
- "%D/%X," \
"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
"%P/etc/X11/%X," \
@@ -114,6 +114,22 @@ extern DeviceAssocRec mouse_assoc;
static char *fontPath = NULL;
+static ModuleDefault ModuleDefaults[] = {
+ {.name = "extmod", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "dbe", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "glx", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "freetype", .toLoad = TRUE, .load_opt=NULL},
+#ifdef XRECORD
+ {.name = "record", .toLoad = TRUE, .load_opt=NULL},
+#endif
+ {.name = "dri", .toLoad = TRUE, .load_opt=NULL},
+#ifdef DRI2
+ {.name = "dri2", .toLoad = TRUE, .load_opt=NULL},
+#endif
+ {.name = NULL, .toLoad = FALSE, .load_opt=NULL}
+};
+
+
/* Forward declarations */
static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
int scrnum, MessageType from);
@@ -483,7 +499,7 @@ xf86InputDriverlistFromConfig()
static void
fixup_video_driver_list(char **drivers)
{
- static const char *fallback[5] = { "vga", "vesa", "fbdev", "wsfb", NULL };
+ static const char *fallback[4] = { "vesa", "fbdev", "wsfb", NULL };
char **end, **drv;
char *x;
char **ati, **atimisc;
@@ -526,14 +542,8 @@ fixup_video_driver_list(char **drivers)
}
}
-
-/*
- * Generate a compiled-in list of driver names. This is used to produce a
- * consistent probe order. For the loader server, we also look for vendor-
- * provided modules, pre-pending them to our own list.
- */
static char **
-GenerateDriverlist(char * dirname, char * drivernames)
+GenerateDriverlist(char * dirname)
{
char **ret;
const char *subdirs[] = { dirname, NULL };
@@ -547,20 +557,13 @@ GenerateDriverlist(char * dirname, char * drivernames)
return ret;
}
-
char **
xf86DriverlistFromCompile(void)
{
static char **driverlist = NULL;
- static Bool generated = FALSE;
- /* This string is modified in-place */
- static char drivernames[] = DRIVERS;
-
- if (!generated) {
- generated = TRUE;
- driverlist = GenerateDriverlist("drivers", drivernames);
- }
+ if (!driverlist)
+ driverlist = GenerateDriverlist("drivers");
return driverlist;
}
@@ -688,21 +691,6 @@ configFiles(XF86ConfFilesPtr fileconf)
}
- /* RgbPath */
-
- pathFrom = X_DEFAULT;
-
- if (xf86coFlag)
- pathFrom = X_CMDLINE;
- else if (fileconf) {
- if (fileconf->file_rgbpath) {
- rgbPath = fileconf->file_rgbpath;
- pathFrom = X_CONFIG;
- }
- }
-
- xf86Msg(pathFrom, "RgbPath set to \"%s\"\n", rgbPath);
-
if (fileconf && fileconf->file_inputdevs) {
xf86InputDeviceList = fileconf->file_inputdevs;
xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n",
@@ -751,7 +739,6 @@ typedef enum {
FLAG_DISABLEMODINDEV,
FLAG_MODINDEVALLOWNONLOCAL,
FLAG_ALLOWMOUSEOPENFAIL,
- FLAG_VTINIT,
FLAG_VTSYSREQ,
FLAG_XKBDISABLE,
FLAG_PCIPROBE1,
@@ -781,6 +768,8 @@ typedef enum {
FLAG_USE_DEFAULT_FONT_PATH,
FLAG_AUTO_ADD_DEVICES,
FLAG_AUTO_ENABLE_DEVICES,
+ FLAG_GLX_VISUALS,
+ FLAG_DRI2,
} FlagValues;
static OptionInfoRec FlagOptions[] = {
@@ -802,8 +791,6 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE },
{ FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_VTINIT, "VTInit", OPTV_STRING,
- {0}, FALSE },
{ FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN,
{0}, FALSE },
{ FLAG_XKBDISABLE, "XkbDisable", OPTV_BOOLEAN,
@@ -854,19 +841,23 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE },
{ FLAG_ALLOW_EMPTY_INPUT, "AllowEmptyInput", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
+ { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
+ { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
{0}, FALSE },
- { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
+ { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
{0}, TRUE },
- { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
+ { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
{0}, TRUE },
+ { FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
+ {0}, FALSE },
{ -1, NULL, OPTV_NONE,
{0}, FALSE },
};
-#if defined(i386) || defined(__i386__)
+#ifdef __i386__
static Bool
detectPC98(void)
{
@@ -893,6 +884,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
Pix24Flags pix24 = Pix24DontCare;
Bool value;
MessageType from;
+ const char *s;
/*
* Merge the ServerLayout and ServerFlags options. The former have
@@ -931,7 +923,12 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
from = X_CONFIG;
}
else {
+#ifndef __OpenBSD__
xf86Info.autoAddDevices = TRUE;
+#else
+ /* No hot-plug support -> don't break static autoconfiguration */
+ xf86Info.autoAddDevices = FALSE;
+#endif
from = X_DEFAULT;
}
xf86Msg(from, "%sutomatically adding devices\n",
@@ -943,7 +940,11 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
from = X_CONFIG;
}
else {
+#ifndef __OpenBSD__
xf86Info.autoEnableDevices = TRUE;
+#else
+ xf86Info.autoEnableDevices = FALSE;
+#endif
from = X_DEFAULT;
}
xf86Msg(from, "%sutomatically enabling devices\n",
@@ -991,8 +992,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
#endif
}
- xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT);
-
if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1))
xf86Info.pciFlags = PCIProbe1;
if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2))
@@ -1010,7 +1009,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
xf86Info.pmFlag = !value;
{
- const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
if (!xf86NameCmp(s,"flush")) {
xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
@@ -1029,8 +1027,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
#ifdef RENDER
{
- const char *s;
-
if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
int policy = PictureParseCmapPolicy (s);
if (policy == PictureCmapPolicyInvalid)
@@ -1044,7 +1040,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
}
#endif
{
- const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
if (!xf86NameCmp(s,"always")) {
xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
@@ -1082,9 +1077,30 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.aiglxFrom = X_CONFIG;
}
- xf86Info.allowEmptyInput = FALSE;
- if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
- xf86Info.allowEmptyInput = TRUE;
+#ifdef GLXEXT
+ xf86Info.glxVisuals = XF86_GlxVisualsTypical;
+ xf86Info.glxVisualsFrom = X_DEFAULT;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
+ if (!xf86NameCmp(s, "minimal")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
+ } else if (!xf86NameCmp(s, "typical")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsTypical;
+ } else if (!xf86NameCmp(s, "all")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsAll;
+ } else {
+ xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
+ }
+ }
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
+ xf86Info.aiglx = value;
+ xf86Info.aiglxFrom = X_CONFIG;
+ }
+#endif
+
+ /* AllowEmptyInput is automatically true if we're hotplugging */
+ xf86Info.allowEmptyInput = (xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &xf86Info.allowEmptyInput);
xf86Info.useDefaultFontPath = TRUE;
xf86Info.useDefaultFontPathFrom = X_DEFAULT;
@@ -1153,7 +1169,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.pixmap24 = Pix24DontCare;
xf86Info.pix24From = X_DEFAULT;
}
-#if defined(i386) || defined(__i386__)
+#ifdef __i386__
if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
xf86Info.pc98 = value;
if (value) {
@@ -1178,9 +1194,23 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Msg(from, "Xinerama: enabled\n");
#endif
+#ifdef DRI2
+ xf86Info.dri2 = FALSE;
+ xf86Info.dri2From = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
+ xf86Info.dri2 = value;
+ xf86Info.dri2From = X_CONFIG;
+ }
+#endif
+
return TRUE;
}
+Bool xf86DRI2Enabled(void)
+{
+ return xf86Info.dri2;
+}
+
/*
* Locate the core input devices. These can be specified/located in
* the following ways, in order of priority:
@@ -1304,7 +1334,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 3. First core pointer device. */
- if (!foundPointer) {
+ if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
XF86ConfInputPtr p;
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@@ -1320,7 +1350,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 4. First pointer with 'mouse' as the driver. */
- if (!foundPointer) {
+ if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
confInput = xf86findInput(CONF_IMPLICIT_POINTER,
xf86configptr->conf_input_lst);
if (!confInput) {
@@ -1335,10 +1365,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 5. Built-in default. */
- if (!foundPointer) {
+ if (!foundPointer && !xf86Info.allowEmptyInput) {
bzero(&defPtr, sizeof(defPtr));
- defPtr.inp_identifier = "<default pointer>";
- defPtr.inp_driver = "mouse";
+ defPtr.inp_identifier = strdup("<default pointer>");
+ defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
foundPointer = TRUE;
from = X_DEFAULT;
@@ -1362,9 +1392,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (!foundPointer) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
- return FALSE;
+ if (!xf86Info.allowEmptyInput) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+ return FALSE;
+ } else {
+ xf86Msg(X_INFO, "Cannot locate a core pointer device.\n");
+ }
}
#if 0
/*
@@ -1381,11 +1415,11 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
found = 1; break;
}
}
- if (!found) {
+ if (!found && !xf86Info.allowEmptyInput) {
xf86Msg(X_INFO, "No default mouse found, adding one\n");
bzero(&defPtr, sizeof(defPtr));
- defPtr.inp_identifier = "<default pointer>";
- defPtr.inp_driver = "mouse";
+ defPtr.inp_identifier = strdup("<default pointer>");
+ defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
foundPointer = configInput(&Pointer, confInput, from);
if (foundPointer) {
@@ -1440,7 +1474,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 3. First core keyboard device. */
- if (!foundKeyboard) {
+ if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
XF86ConfInputPtr p;
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@@ -1456,7 +1490,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
- if (!foundKeyboard) {
+ if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
xf86configptr->conf_input_lst);
if (!confInput) {
@@ -1471,10 +1505,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 5. Built-in default. */
- if (!foundKeyboard) {
+ if (!foundKeyboard && !xf86Info.allowEmptyInput) {
bzero(&defKbd, sizeof(defKbd));
- defKbd.inp_identifier = "<default keyboard>";
- defKbd.inp_driver = "kbd";
+ defKbd.inp_identifier = strdup("<default keyboard>");
+ defKbd.inp_driver = strdup("kbd");
confInput = &defKbd;
foundKeyboard = TRUE;
keyboardMsg = "default keyboard configuration";
@@ -1498,21 +1532,39 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (!foundKeyboard) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
- return FALSE;
+ if (!xf86Info.allowEmptyInput) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+ return FALSE;
+ } else {
+ xf86Msg(X_INFO, "Cannot locate a core keyboard device.\n");
+ }
}
if (pointerMsg) {
- xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", pointerMsg);
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ pointerMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", pointerMsg);
}
if (keyboardMsg) {
- xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", keyboardMsg);
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ keyboardMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", keyboardMsg);
+ }
+
+ if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) {
+ xf86Msg(X_INFO, "The server relies on HAL to provide the list of "
+ "input devices.\n\tIf no devices become available, "
+ "reconfigure HAL or disable AllowEmptyInput.\n");
}
return TRUE;
@@ -1802,11 +1854,6 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
if (!servlayoutp)
return FALSE;
- if (conf_screen == NULL) {
- xf86ConfigError("No Screen sections present\n");
- return FALSE;
- }
-
/*
* which screen section is the active one?
*
@@ -1842,8 +1889,6 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
indp = xnfalloc(sizeof(IDevPtr));
*indp = NULL;
servlayoutp->inputs = indp;
- if (!xf86Info.allowEmptyInput && !checkCoreInputDevices(servlayoutp, TRUE))
- return FALSE;
return TRUE;
}
@@ -1894,6 +1939,12 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
XF86ConfAdaptorLinkPtr conf_adaptor;
Bool defaultMonitor = FALSE;
+ if (!conf_screen) {
+ conf_screen = xnfcalloc(1, sizeof(XF86ConfScreenRec));
+ conf_screen->scrn_identifier = "Default Screen Section";
+ xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
+ }
+
xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
scrnum);
/*
@@ -1928,9 +1979,20 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
return FALSE;
}
+ /* Configure the device. If there isn't one configured, attach to the
+ * first inactive one that we can configure. If there's none that work,
+ * set it to NULL so that the section can be autoconfigured later */
screenp->device = xnfcalloc(1, sizeof(GDevRec));
- configDevice(screenp->device,conf_screen->scrn_device, TRUE);
- screenp->device->myScreenSection = screenp;
+ if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
+ conf_screen->scrn_device = xf86configptr->conf_device_lst;
+ xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
+ "\tUsing the first device section listed.\n", screenp->id);
+ }
+ if (configDevice(screenp->device,conf_screen->scrn_device, TRUE)) {
+ screenp->device->myScreenSection = screenp;
+ } else {
+ screenp->device = NULL;
+ }
screenp->options = conf_screen->scrn_option_lst;
/*
@@ -1943,6 +2005,18 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
}
screenp->displays = xnfalloc((count) * sizeof(DispRec));
screenp->numdisplays = count;
+
+ /* Fill in the default Virtual size, if any */
+ if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
+ for (count = 0, dispptr = conf_screen->scrn_display_lst;
+ dispptr;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next, count++) {
+ screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
+ screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
+ }
+ }
+
+ /* Now do the per-Display Virtual sizes */
count = 0;
dispptr = conf_screen->scrn_display_lst;
while(dispptr) {
@@ -2066,8 +2140,7 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
*/
cmodep = conf_monitor->mon_modeline_lst;
while( cmodep ) {
- mode = xnfalloc(sizeof(DisplayModeRec));
- memset(mode,'\0',sizeof(DisplayModeRec));
+ mode = xnfcalloc(1, sizeof(DisplayModeRec));
mode->type = 0;
mode->Clock = cmodep->ml_clock;
mode->HDisplay = cmodep->ml_hdisplay;
@@ -2219,13 +2292,17 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
{
int i;
+ if (!conf_device) {
+ return FALSE;
+ }
+
if (active)
xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
conf_device->dev_identifier);
else
xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
conf_device->dev_identifier);
-
+
devicep->identifier = conf_device->dev_identifier;
devicep->vendor = conf_device->dev_vendor;
devicep->board = conf_device->dev_board;
@@ -2373,14 +2450,14 @@ configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
}
static Bool
-modeIsPresent(char * modename,MonPtr monitorp)
+modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
{
DisplayModePtr knownmodes = monitorp->Modes;
/* all I can think of is a linear search... */
while(knownmodes != NULL)
{
- if(!strcmp(modename,knownmodes->name) &&
+ if(!strcmp(mode->name, knownmodes->name) &&
!(knownmodes->type & M_T_DEFAULT))
return TRUE;
knownmodes = knownmodes->next;
@@ -2395,31 +2472,16 @@ addDefaultModes(MonPtr monitorp)
DisplayModePtr last = monitorp->Last;
int i = 0;
- while (xf86DefaultModes[i].name != NULL)
+ for (i = 0; i < xf86NumDefaultModes; i++)
{
- if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
- do
- {
- mode = xnfalloc(sizeof(DisplayModeRec));
- memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
- if (xf86DefaultModes[i].name)
- mode->name = xnfstrdup(xf86DefaultModes[i].name);
- if( last ) {
- mode->prev = last;
- last->next = mode;
- }
- else {
- /* this is the first mode */
- monitorp->Modes = mode;
- mode->prev = NULL;
- }
- last = mode;
- i++;
- }
- while((xf86DefaultModes[i].name != NULL) &&
- (!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
- else
- i++;
+ mode = xf86DuplicateMode(&xf86DefaultModes[i]);
+ if (!modeIsPresent(mode, monitorp))
+ {
+ monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
+ last = mode;
+ } else {
+ xfree(mode);
+ }
}
monitorp->Last = last;
@@ -2427,9 +2489,8 @@ addDefaultModes(MonPtr monitorp)
}
static void
-checkInput(serverLayoutPtr layout) {
- if (!xf86Info.allowEmptyInput)
- checkCoreInputDevices(layout, FALSE);
+checkInput(serverLayoutPtr layout, Bool implicit_layout) {
+ checkCoreInputDevices(layout, implicit_layout);
}
/*
@@ -2443,6 +2504,7 @@ xf86HandleConfigFile(Bool autoconfig)
MessageType from = X_DEFAULT;
char *scanptr;
Bool singlecard = 0;
+ Bool implicit_layout = FALSE;
if (!autoconfig) {
if (getuid() == 0)
@@ -2495,6 +2557,7 @@ xf86HandleConfigFile(Bool autoconfig)
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
}
+ implicit_layout = TRUE;
} else {
if (xf86configptr->conf_flags != NULL) {
char *dfltlayout = NULL;
@@ -2531,8 +2594,9 @@ xf86HandleConfigFile(Bool autoconfig)
xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
"\tIgnoring IsolateDevice option.\n");
} else if (sscanf(scanptr, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.bus = bus;
- xf86IsolateDevice.device = device;
+ xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus);
+ xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
+ xf86IsolateDevice.dev = device;
xf86IsolateDevice.func = func;
xf86Msg(X_INFO,
"Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func);
@@ -2551,7 +2615,7 @@ xf86HandleConfigFile(Bool autoconfig)
configDRI(xf86configptr->conf_dri);
#endif
- checkInput(&xf86ConfigLayout);
+ checkInput(&xf86ConfigLayout, implicit_layout);
/*
* Handle some command line options that can override some of the
diff --git a/xserver/hw/xfree86/common/xf86Config.h b/xserver/hw/xfree86/common/xf86Config.h
index 0786ec6fe..a174e463b 100644
--- a/xserver/hw/xfree86/common/xf86Config.h
+++ b/xserver/hw/xfree86/common/xf86Config.h
@@ -33,6 +33,10 @@
#ifndef _xf86_config_h
#define _xf86_config_h
+#include "xf86Optrec.h"
+#include "xf86Parser.h"
+#include "xf86str.h"
+
#ifdef HAVE_PARSER_DECLS
/*
* global structure that holds the result of parsing the config file
@@ -46,6 +50,12 @@ typedef enum _ConfigStatus {
CONFIG_NOFILE
} ConfigStatus;
+typedef struct _ModuleDefault {
+ char *name;
+ Bool toLoad;
+ XF86OptionPtr load_opt;
+} ModuleDefault;
+
/*
* prototypes
*/
@@ -53,10 +63,12 @@ char ** xf86ModulelistFromConfig(pointer **);
char ** xf86DriverlistFromConfig(void);
char ** xf86DriverlistFromCompile(void);
char ** xf86InputDriverlistFromConfig(void);
-char ** xf86InputDriverlistFromCompile(void);
Bool xf86BuiltinInputDriver(const char *);
ConfigStatus xf86HandleConfigFile(Bool);
Bool xf86AutoConfig(void);
+GDevPtr autoConfigDevice(GDevPtr preconf_device);
+char* chooseVideoDriver(void);
+int xchomp(char *line);
#endif /* _xf86_config_h */
diff --git a/xserver/hw/xfree86/common/xf86Configure.c b/xserver/hw/xfree86/common/xf86Configure.c
index 37000e5ff..eb6a645ff 100644
--- a/xserver/hw/xfree86/common/xf86Configure.c
+++ b/xserver/hw/xfree86/common/xf86Configure.c
@@ -35,20 +35,21 @@
#include <fcntl.h>
#include <X11/X.h>
#include <X11/Xmd.h>
+#include <pciaccess.h>
+#include "Pci.h"
#include "os.h"
#include "loaderProcs.h"
#include "xf86.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
#include "xf86Priv.h"
-#include "xf86PciData.h"
#define IN_XSERVER
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
#include "vbe.h"
#include "xf86DDC.h"
-#if defined(__sparc__) || defined(__sparc)
+#if (defined(__sparc__) || defined(__sparc))
#include "xf86Bus.h"
#include "xf86Sbus.h"
#endif
@@ -56,8 +57,8 @@
typedef struct _DevToConfig {
GDevRec GDev;
- pciVideoPtr pVideo;
-#if defined(__sparc__) || defined(__sparc)
+ struct pci_device * pVideo;
+#if (defined(__sparc__) || defined(__sparc))
sbusDevicePtr sVideo;
#endif
int iDriver;
@@ -101,7 +102,7 @@ GDevPtr
xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
{
int i, j;
- pciVideoPtr pVideo = NULL;
+ struct pci_device * pVideo = NULL;
Bool isPrimary = FALSE;
if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1)
@@ -110,11 +111,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
/* Check for duplicates */
switch (bus) {
case BUS_PCI:
- pVideo = (pciVideoPtr) busData;
+ pVideo = (struct pci_device *) busData;
for (i = 0; i < nDevToConfig; i++)
if (DevToConfig[i].pVideo &&
+ (DevToConfig[i].pVideo->domain == pVideo->domain) &&
(DevToConfig[i].pVideo->bus == pVideo->bus) &&
- (DevToConfig[i].pVideo->device == pVideo->device) &&
+ (DevToConfig[i].pVideo->dev == pVideo->dev) &&
(DevToConfig[i].pVideo->func == pVideo->func))
return NULL;
isPrimary = xf86IsPrimaryPci(pVideo);
@@ -131,7 +133,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
if (!DevToConfig[i].pVideo)
return NULL;
break;
-#if defined(__sparc__) || defined(__sparc)
+#if (defined(__sparc__) || defined(__sparc))
case BUS_SBUS:
for (i = 0; i < nDevToConfig; i++)
if (DevToConfig[i].sVideo &&
@@ -173,9 +175,9 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
char busnum[8];
NewDevice.pVideo = pVideo;
- xf86FindPciNamesByDevice(pVideo->vendor, pVideo->chipType,
- NOVENDOR, NOSUBSYS,
- &VendorName, &CardName, NULL, NULL);
+
+ VendorName = pci_device_get_vendor_name( pVideo );
+ CardName = pci_device_get_device_name( pVideo );
if (!VendorName) {
VendorName = xnfalloc(15);
@@ -197,20 +199,20 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
NewDevice.GDev.busID = xnfalloc(16);
xf86FormatPciBusNumber(pVideo->bus, busnum);
sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d",
- busnum, pVideo->device, pVideo->func);
+ busnum, pVideo->dev, pVideo->func);
- NewDevice.GDev.chipID = pVideo->chipType;
- NewDevice.GDev.chipRev = pVideo->chipRev;
+ NewDevice.GDev.chipID = pVideo->device_id;
+ NewDevice.GDev.chipRev = pVideo->revision;
if (chipset < 0)
- chipset = (pVideo->vendor << 16) | pVideo->chipType;
+ chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
}
break;
case BUS_ISA:
NewDevice.GDev.identifier = "ISA Adapter";
NewDevice.GDev.busID = "ISA";
break;
-#if defined(__sparc__) || defined(__sparc)
+#if (defined(__sparc__) || defined(__sparc))
case BUS_SBUS: {
char *promPath = NULL;
NewDevice.sVideo = (sbusDevicePtr) busData;
@@ -249,7 +251,8 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
* Backwards compatibility
*/
_X_EXPORT GDevPtr
-xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
+xf86AddDeviceToConfigure(const char *driver, struct pci_device * pVideo,
+ int chipset)
{
return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA,
pVideo, chipset);
@@ -369,9 +372,6 @@ configureDeviceSection (int screennum)
char identifier[16];
OptionInfoPtr p;
int i = 0;
-#ifdef DO_FBDEV_PROBE
- Bool foundFBDEV = FALSE;
-#endif
parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
/* Move device info to parser structure */
@@ -440,32 +440,6 @@ configureDeviceSection (int screennum)
}
}
-#ifdef DO_FBDEV_PROBE
- /* Crude mechanism to auto-detect fbdev (os dependent) */
- /* Skip it for now. Options list it anyway, and we can't
- * determine which screen/driver this belongs too anyway. */
- {
- int fd;
-
- fd = open("/dev/fb0", 0);
- if (fd != -1) {
- foundFBDEV = TRUE;
- close(fd);
- }
- }
-
- if (foundFBDEV) {
- XF86OptionPtr fbdev;
-
- fbdev = xf86confmalloc(sizeof(XF86OptionRec));
- memset((XF86OptionPtr)fbdev,0,sizeof(XF86OptionRec));
- fbdev->opt_name = "UseFBDev";
- fbdev->opt_val = "ON";
- ptr->dev_option_lst = (XF86OptionPtr)xf86addListItem(
- (glp)ptr->dev_option_lst, (glp)fbdev);
- }
-#endif
-
return ptr;
}
@@ -602,8 +576,6 @@ configureFilesSection (void)
ptr->file_modulepath = strdup(xf86ModulePath);
if (defaultFontPath)
ptr->file_fontpath = strdup(defaultFontPath);
- if (rgbPath)
- ptr->file_rgbpath = strdup(rgbPath);
return ptr;
}
@@ -759,22 +731,20 @@ DoConfigure()
/* Call all of the probe functions, reporting the results. */
for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
xorgHWFlags flags;
-
+ Bool found_screen;
+ DriverRec * const drv = xf86DriverList[CurrentDriver];
+
if (!xorgHWAccess) {
- if (!xf86DriverList[CurrentDriver]->driverFunc
- || !xf86DriverList[CurrentDriver]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
+ if (!drv->driverFunc
+ || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
|| NEED_IO_ENABLED(flags))
continue;
}
- if (xf86DriverList[CurrentDriver]->Probe == NULL) continue;
-
- if ((*xf86DriverList[CurrentDriver]->Probe)(
- xf86DriverList[CurrentDriver], PROBE_DETECT) &&
- xf86DriverList[CurrentDriver]->Identify)
- (*xf86DriverList[CurrentDriver]->Identify)(0);
+ found_screen = xf86CallDriverProbe( drv, TRUE );
+ if ( found_screen && drv->Identify ) {
+ (*drv->Identify)(0);
+ }
}
if (nDevToConfig <= 0) {
@@ -822,7 +792,7 @@ DoConfigure()
homebuf[PATH_MAX-1] = '\0';
home = homebuf;
if (!(filename =
- (char *)ALLOCATE_LOCAL(strlen(home) +
+ (char *)xalloc(strlen(home) +
strlen(configfile) + 3)))
if (home[0] == '/' && home[1] == '\0')
@@ -860,7 +830,7 @@ DoConfigure()
oldNumScreens = xf86NumScreens;
- (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0);
+ xf86CallDriverProbe( xf86DriverList[i], FALSE );
/* reorder */
k = screennum > 0 ? screennum : 1;
@@ -888,7 +858,6 @@ DoConfigure()
}
}
}
- xf86SetPciVideo(NULL,NONE);
}
xfree(driverProbed);
}
diff --git a/xserver/hw/xfree86/common/xf86Cursor.c b/xserver/hw/xfree86/common/xf86Cursor.c
index dcdf46674..3ea1b4d91 100644
--- a/xserver/hw/xfree86/common/xf86Cursor.c
+++ b/xserver/hw/xfree86/common/xf86Cursor.c
@@ -25,8 +25,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-/* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
-
#define NEED_EVENTS
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
@@ -77,14 +75,9 @@ static miPointerScreenFuncRec xf86PointerScreenFuncs = {
xf86CursorOffScreen,
xf86CrossScreen,
xf86WarpCursor,
-#ifdef XINPUT
- xf86eqEnqueue,
- xf86eqSwitchScreen
-#else
/* let miPointerInitialize take care of these */
NULL,
NULL
-#endif
};
static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
@@ -228,9 +221,9 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
return FALSE;
- pCursorScreen = miPointerCurrentScreen();
+ pCursorScreen = miPointerGetScreen(inputInfo.pointer);
if (pScreen == pCursorScreen)
- miPointerPosition(&px, &py);
+ miPointerGetPosition(inputInfo.pointer, &px, &py);
xf86EnterServerState(SETUP);
Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
@@ -413,18 +406,14 @@ xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
/*
* xf86CrossScreen --
* Switch to another screen
+ *
+ * Currently nothing special happens, but mi assumes the CrossScreen
+ * method exists.
*/
-/* NEED TO CHECK THIS */
-/* ARGSUSED */
static void
xf86CrossScreen (ScreenPtr pScreen, Bool entering)
{
-#if 0
- if (xf86Info.sharedMonitor)
- (XF86SCRNINFO(pScreen)->EnterLeaveMonitor)(entering);
- (XF86SCRNINFO(pScreen)->EnterLeaveCursor)(entering);
-#endif
}
@@ -569,6 +558,14 @@ xf86InitOrigins(void)
screen = &xf86ConfigLayout.screens[i];
+ if (screen->refscreen != NULL &&
+ screen->refscreen->screennum >= xf86NumScreens) {
+ screensLeft &= ~(1 << i);
+ xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
+ screen->screen->id);
+ continue;
+ }
+
switch(screen->where) {
case PosObsolete:
OldStyleConfig = TRUE;
diff --git a/xserver/hw/xfree86/common/xf86DGA.c b/xserver/hw/xfree86/common/xf86DGA.c
index 55c85e630..0daf1de44 100644
--- a/xserver/hw/xfree86/common/xf86DGA.c
+++ b/xserver/hw/xfree86/common/xf86DGA.c
@@ -43,17 +43,21 @@
#include "servermd.h"
#include "micmap.h"
#ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
#endif
#include "xf86Xinput.h"
-static unsigned long DGAGeneration = 0;
-static int DGAScreenIndex = -1;
+#include "mi.h"
+
+static DevPrivateKey DGAScreenKey = NULL;
+static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
static void DGADestroyColormap(ColormapPtr pmap);
static void DGAInstallColormap(ColormapPtr pmap);
static void DGAUninstallColormap(ColormapPtr pmap);
+static void DGAHandleEvent(int screen_num, xEvent *event,
+ DeviceIntPtr device, int nevents);
static void
DGACopyModeInfo(
@@ -63,8 +67,8 @@ DGACopyModeInfo(
_X_EXPORT int *XDGAEventBase = NULL;
-#define DGA_GET_SCREEN_PRIV(pScreen) \
- ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr))
+#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
typedef struct _FakedVisualList{
@@ -94,7 +98,6 @@ typedef struct {
Bool grabKeyboard;
} DGAScreenRec, *DGAScreenPtr;
-
_X_EXPORT Bool
DGAInit(
ScreenPtr pScreen,
@@ -112,11 +115,7 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
- if(DGAGeneration != serverGeneration) {
- if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DGAGeneration = serverGeneration;
- }
+ DGAScreenKey = &DGAScreenKey;
if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec))))
return FALSE;
@@ -144,8 +143,7 @@ DGAInit(
modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
#endif
-
- pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@@ -155,11 +153,6 @@ DGAInit(
pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
pScreen->UninstallColormap = DGAUninstallColormap;
- /*
- * This is now set in InitOutput().
- *
- pScrn->SetDGAMode = xf86SetDGAMode;
- */
return TRUE;
}
@@ -178,7 +171,7 @@ DGAReInitModes(
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -245,12 +238,19 @@ FreeMarkedVisuals(ScreenPtr pScreen)
}
}
-
static Bool
DGACloseScreen(int i, ScreenPtr pScreen)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ if (XDGAEventBase) {
+ mieqSetHandler(*XDGAEventBase + MotionNotify, NULL);
+ mieqSetHandler(*XDGAEventBase + ButtonPress, NULL);
+ mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL);
+ mieqSetHandler(*XDGAEventBase + KeyPress, NULL);
+ mieqSetHandler(*XDGAEventBase + KeyRelease, NULL);
+ }
+
FreeMarkedVisuals(pScreen);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
@@ -345,7 +345,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
- if (DGAScreenIndex < 0)
+ if (DGAScreenKey == NULL)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@@ -427,7 +427,7 @@ xf86SetDGAMode(
}
if(pMode->flags & DGA_PIXMAP_AVAILABLE) {
- if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth))) {
+ if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth, 0))) {
(*pScreen->ModifyPixmapHeader)(pPix,
pMode->pixmapWidth, pMode->pixmapHeight,
pMode->depth, pMode->bitsPerPixel,
@@ -460,6 +460,15 @@ DGASetInputMode(int index, Bool keyboard, Bool mouse)
{
pScreenPriv->grabMouse = mouse;
pScreenPriv->grabKeyboard = keyboard;
+
+ if (!mieq_installed) {
+ mieqSetHandler(*XDGAEventBase + MotionNotify, DGAHandleEvent);
+ mieqSetHandler(*XDGAEventBase + ButtonPress, DGAHandleEvent);
+ mieqSetHandler(*XDGAEventBase + ButtonRelease, DGAHandleEvent);
+ mieqSetHandler(*XDGAEventBase + KeyPress, DGAHandleEvent);
+ mieqSetHandler(*XDGAEventBase + KeyRelease, DGAHandleEvent);
+ mieq_installed = 1;
+ }
}
}
@@ -471,7 +480,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode;
PixmapPtr pPix;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -521,11 +530,12 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
_X_EXPORT Bool
DGAAvailable(int index)
{
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
- if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]->
- devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM))
+ if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate(
+ &screenInfo.screens[index]->devPrivates,
+ xf86ScreenKey))->scrnIndex, MEM))
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -539,7 +549,7 @@ DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -560,7 +570,7 @@ DGAShutdown()
ScrnInfoPtr pScrn;
int i;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -890,7 +900,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */
- if(DGAScreenIndex >= 0) {
+ if(DGAScreenKey) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@@ -901,72 +911,98 @@ DGAVTSwitch(void)
return TRUE;
}
-
-/* We have the power to steal or modify events that are about to get queued */
-
Bool
-DGAStealKeyEvent(int index, xEvent *e)
+DGAStealKeyEvent(int index, int key_code, int is_down)
{
DGAScreenPtr pScreenPriv;
- dgaEvent de;
-
- if(DGAScreenIndex < 0) /* no DGA */
- return FALSE;
+ dgaEvent de;
+
+ if(DGAScreenKey == NULL) /* no DGA */
+ return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
- return FALSE;
+ return FALSE;
+
+ de.u.u.type = *XDGAEventBase + (is_down ? KeyPress : KeyRelease);
+ de.u.u.detail = key_code;
+ de.u.event.time = GetTimeInMillis();
+ mieqEnqueue (inputInfo.keyboard, (xEvent *) &de);
- de.u.u.type = e->u.u.type + *XDGAEventBase;
- de.u.u.detail = e->u.u.detail;
- de.u.event.time = e->u.keyButtonPointer.time;
- xf86eqEnqueue ((xEvent *) &de);
return TRUE;
-}
+}
static int DGAMouseX, DGAMouseY;
Bool
-DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
+DGAStealMotionEvent(int index, int dx, int dy)
{
DGAScreenPtr pScreenPriv;
- dgaEvent de;
-
- if(DGAScreenIndex < 0) /* no DGA */
- return FALSE;
+ dgaEvent de;
+ if(DGAScreenKey == NULL) /* no DGA */
+ return FALSE;
+
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
- return FALSE;
-
+ return FALSE;
+
DGAMouseX += dx;
if (DGAMouseX < 0)
- DGAMouseX = 0;
+ DGAMouseX = 0;
else if (DGAMouseX > screenInfo.screens[index]->width)
- DGAMouseX = screenInfo.screens[index]->width;
+ DGAMouseX = screenInfo.screens[index]->width;
DGAMouseY += dy;
if (DGAMouseY < 0)
- DGAMouseY = 0;
+ DGAMouseY = 0;
else if (DGAMouseY > screenInfo.screens[index]->height)
- DGAMouseY = screenInfo.screens[index]->height;
- de.u.u.type = e->u.u.type + *XDGAEventBase;
- de.u.u.detail = e->u.u.detail;
- de.u.event.time = e->u.keyButtonPointer.time;
+ DGAMouseY = screenInfo.screens[index]->height;
+ de.u.u.type = *XDGAEventBase + MotionNotify;
+ de.u.u.detail = 0;
+ de.u.event.time = GetTimeInMillis();
de.u.event.dx = dx;
de.u.event.dy = dy;
de.u.event.pad1 = DGAMouseX;
de.u.event.pad2 = DGAMouseY;
- xf86eqEnqueue ((xEvent *) &de);
+ mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+ return TRUE;
+}
+
+Bool
+DGAStealButtonEvent(int index, int button, int is_down)
+{
+ DGAScreenPtr pScreenPriv;
+ dgaEvent de;
+
+ if (DGAScreenKey == NULL)
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if (!pScreenPriv || !pScreenPriv->grabMouse)
+ return FALSE;
+
+ de.u.u.type = *XDGAEventBase + (is_down ? ButtonPress : ButtonRelease);
+ de.u.u.detail = button;
+ de.u.event.time = GetTimeInMillis();
+ de.u.event.dx = 0;
+ de.u.event.dy = 0;
+ de.u.event.pad1 = DGAMouseX;
+ de.u.event.pad2 = DGAMouseY;
+ mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+
return TRUE;
}
+/* We have the power to steal or modify events that are about to get queued */
+
Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1168,39 +1204,6 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
}
}
-Bool
-DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
-{
- dgaEvent *de = (dgaEvent *) e;
- DGAScreenPtr pScreenPriv;
- int coreEquiv;
-
- /* no DGA */
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
- return FALSE;
- pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-
- /* DGA not initialized on this screen */
- if (!pScreenPriv)
- return FALSE;
-
- coreEquiv = de->u.u.type - *XDGAEventBase;
- /* Not a DGA event */
- if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
- return FALSE;
-
- switch (coreEquiv) {
- case KeyPress:
- case KeyRelease:
- DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
- break;
- default:
- DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
- break;
- }
- return TRUE;
-}
-
_X_EXPORT Bool
DGAOpenFramebuffer(
int index,
@@ -1259,3 +1262,35 @@ DGAGetOldDGAMode(int index)
return 0;
}
+static void
+DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
+{
+ dgaEvent *de = (dgaEvent *) event;
+ ScreenPtr pScreen = screenInfo.screens[screen_num];
+ DGAScreenPtr pScreenPriv;
+ int coreEquiv;
+
+ /* no DGA */
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
+ return;
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ /* DGA not initialized on this screen */
+ if (!pScreenPriv)
+ return;
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+ /* Not a DGA event; shouldn't happen, but you never know. */
+ if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
+ return;
+
+ switch (coreEquiv) {
+ case KeyPress:
+ case KeyRelease:
+ DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+ break;
+ default:
+ DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+ break;
+ }
+}
diff --git a/xserver/hw/xfree86/common/xf86DPMS.c b/xserver/hw/xfree86/common/xf86DPMS.c
index 3aa83e882..4fb901aae 100644
--- a/xserver/hw/xfree86/common/xf86DPMS.c
+++ b/xserver/hw/xfree86/common/xf86DPMS.c
@@ -47,8 +47,7 @@
#ifdef DPMSExtension
-static int DPMSGeneration = 0;
-static int DPMSIndex = -1;
+static DevPrivateKey DPMSKey = NULL;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
#endif
@@ -61,19 +60,17 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
DPMSPtr pDPMS;
pointer DPMSOpt;
+ MessageType enabled_from = X_INFO;
- if (serverGeneration != DPMSGeneration) {
- if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DPMSGeneration = serverGeneration;
- }
+ DPMSKey = &DPMSKey;
if (DPMSDisabledSwitch)
DPMSEnabled = FALSE;
- if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1)))
+ if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
+ xcalloc(sizeof(DPMSRec), 1)))
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
pScrn->DPMSSet = set;
pDPMS->Flags = flags;
DPMSOpt = xf86FindOption(pScrn->options, "dpms");
@@ -82,8 +79,8 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
= xf86SetBoolOption(pScrn->options, "dpms", FALSE))
&& !DPMSDisabledSwitch)
DPMSEnabled = TRUE;
+ enabled_from = X_CONFIG;
xf86MarkOptionUsed(DPMSOpt);
- xf86DrvMsg(pScreen->myNum, X_CONFIG, "DPMS enabled\n");
} else if (DPMSEnabledSwitch) {
if (!DPMSDisabledSwitch)
DPMSEnabled = TRUE;
@@ -92,6 +89,8 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
else {
pDPMS->Enabled = defaultDPMSEnabled;
}
+ if (pDPMS->Enabled)
+ xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n");
pDPMS->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DPMSClose;
DPMSCount++;
@@ -110,10 +109,10 @@ DPMSClose(int i, ScreenPtr pScreen)
DPMSPtr pDPMS;
/* This shouldn't happen */
- if (DPMSIndex < 0)
+ if (DPMSKey == NULL)
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
/* This shouldn't happen */
if (!pDPMS)
@@ -132,9 +131,9 @@ DPMSClose(int i, ScreenPtr pScreen)
}
xfree((pointer)pDPMS);
- pScreen->devPrivates[DPMSIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
- DPMSIndex = -1;
+ DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);
}
@@ -144,30 +143,35 @@ DPMSClose(int i, ScreenPtr pScreen)
* Device dependent DPMS mode setting hook. This is called whenever
* the DPMS mode is to be changed.
*/
-_X_EXPORT void
-DPMSSet(int level)
+_X_EXPORT int
+DPMSSet(ClientPtr client, int level)
{
- int i;
+ int rc, i;
DPMSPtr pDPMS;
ScrnInfoPtr pScrn;
DPMSPowerLevel = level;
- if (DPMSIndex < 0)
- return;
+ if (DPMSKey == NULL)
+ return Success;
- if (level != DPMSModeOn)
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (level != DPMSModeOn) {
+ rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (rc != Success)
+ return rc;
+ }
/* For each screen, set the DPMS level */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
xf86EnableAccess(pScrn);
pScrn->DPMSSet(pScrn, level, 0);
}
}
+ return Success;
}
@@ -182,14 +186,15 @@ DPMSSupported(void)
DPMSPtr pDPMS;
ScrnInfoPtr pScrn;
- if (DPMSIndex < 0) {
+ if (DPMSKey == NULL) {
return FALSE;
}
/* For each screen, check if DPMS is supported */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet)
return TRUE;
}
diff --git a/xserver/hw/xfree86/common/xf86DefModes.c b/xserver/hw/xfree86/common/xf86DefModes.c
deleted file mode 100644
index a39d0a212..000000000
--- a/xserver/hw/xfree86/common/xf86DefModes.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $XFree86$ */
-
-/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at
- * modeline2c.pl */
-
-/*
- * Copyright 1999-2003 by The XFree86 Project, Inc.
- *
- * Author: Dirk Hohndel <hohndel@XFree86.Org>
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifdef __UNIXOS2__
-#define I_NEED_OS2_H
-#endif
-#include "xf86.h"
-#include "xf86Config.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include "globals.h"
-
-#define MODEPREFIX(name) NULL, NULL, name, MODE_OK, M_T_DEFAULT
-#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-DisplayModeRec xf86DefaultModes [] = {
-/* 640x350 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x350"),31500, 640,672,736,832,0, 350,382,385,445,0, V_PHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("320x175"),15750, 320,336,368,416,0, 175,191,192,222,0, V_PHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 640x400 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x400"),31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("320x200"),15750, 320,336,368,416,0, 200,200,202,222,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 720x400 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("720x400"),35500, 720,756,828,936,0, 400,401,404,446,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("360x200"),17750, 360,378,414,468,0, 200,200,202,223,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */
- {MODEPREFIX("640x480"),25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("320x240"),12600, 320,328,376,400,0, 240,245,246,262,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x480"),31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("320x240"),15750, 320,332,352,416,0, 240,244,245,260,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */
- {MODEPREFIX("640x480"),31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("320x240"),15750, 320,328,360,420,0, 240,240,242,250,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */
- {MODEPREFIX("640x480"),36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("320x240"),18000, 320,348,376,416,0, 240,240,242,254,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */
- {MODEPREFIX("800x600"),36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("400x300"),18000, 400,412,448,512,0, 300,300,301,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("800x600"),40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("400x300"),20000, 400,420,484,528,0, 300,300,302,314,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */
- {MODEPREFIX("800x600"),50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("400x300"),25000, 400,428,488,520,0, 300,318,321,333,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */
- {MODEPREFIX("800x600"),49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("400x300"),24750, 400,408,448,528,0, 300,300,302,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */
- {MODEPREFIX("800x600"),56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("400x300"),28150, 400,416,448,524,0, 300,300,302,315,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */
- {MODEPREFIX("1024x768"),44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX},
- {MODEPREFIX("512x384"),22450, 512,516,604,632,0, 384,384,388,408,0, V_PHSYNC | V_PVSYNC | V_INTERLACE | V_DBLSCAN, MODESUFFIX},
-/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */
- {MODEPREFIX("1024x768"),65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("512x384"),32500, 512,524,592,672,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */
- {MODEPREFIX("1024x768"),75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("512x384"),37500, 512,524,592,664,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */
- {MODEPREFIX("1024x768"),78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("512x384"),39400, 512,520,568,656,0, 384,384,386,400,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */
- {MODEPREFIX("1024x768"),94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("512x384"),47250, 512,536,584,688,0, 384,384,386,404,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */
- {MODEPREFIX("1152x864"),108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("576x432"),54000, 576,608,672,800,0, 432,432,434,450,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1280x960 @ 60Hz (VESA) hsync: 60.0kHz */
- {MODEPREFIX("1280x960"),108000, 1280,1376,1488,1800,0, 960,961,964,1000,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("640x480"),54000, 640,688,744,900,0, 480,480,482,500,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1280x960 @ 85Hz (VESA) hsync: 85.9kHz */
- {MODEPREFIX("1280x960"),148500, 1280,1344,1504,1728,0, 960,961,964,1011,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("640x480"),74250, 640,672,752,864,0, 480,480,482,505,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz */
- {MODEPREFIX("1280x1024"),108000, 1280,1328,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("640x512"),54000, 640,664,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz */
- {MODEPREFIX("1280x1024"),135000, 1280,1296,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("640x512"),67500, 640,648,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz */
- {MODEPREFIX("1280x1024"),157500, 1280,1344,1504,1728,0, 1024,1025,1028,1072,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("640x512"),78750, 640,672,752,864,0, 512,512,514,536,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz */
- {MODEPREFIX("1600x1200"),162000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("800x600"),81000, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz */
- {MODEPREFIX("1600x1200"),175500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("800x600"),87750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz */
- {MODEPREFIX("1600x1200"),189000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("800x600"),94500, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz */
- {MODEPREFIX("1600x1200"),202500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("800x600"),101250, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz */
- {MODEPREFIX("1600x1200"),229500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("800x600"),114750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz */
- {MODEPREFIX("1792x1344"),204800, 1792,1920,2120,2448,0, 1344,1345,1348,1394,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("896x672"),102400, 896,960,1060,1224,0, 672,672,674,697,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz */
- {MODEPREFIX("1792x1344"),261000, 1792,1888,2104,2456,0, 1344,1345,1348,1417,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("896x672"),130500, 896,944,1052,1228,0, 672,672,674,708,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz */
- {MODEPREFIX("1856x1392"),218300, 1856,1952,2176,2528,0, 1392,1393,1396,1439,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("928x696"),109150, 928,976,1088,1264,0, 696,696,698,719,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz */
- {MODEPREFIX("1856x1392"),288000, 1856,1984,2208,2560,0, 1392,1393,1396,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("928x696"),144000, 928,992,1104,1280,0, 696,696,698,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz */
- {MODEPREFIX("1920x1440"),234000, 1920,2048,2256,2600,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("960x720"),117000, 960,1024,1128,1300,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz */
- {MODEPREFIX("1920x1440"),297000, 1920,2064,2288,2640,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("960x720"),148500, 960,1032,1144,1320,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz */
- {MODEPREFIX("832x624"),57284, 832,864,928,1152,0, 624,625,628,667,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("416x312"),28642, 416,432,464,576,0, 312,312,314,333,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1152x768 @ 54.8Hz (Titanium PowerBook) hsync: 44.2kHz */
- {MODEPREFIX("1152x768"),64995, 1152,1178,1314,1472,0, 768,771,777,806,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("576x384"),32497, 576,589,657,736,0, 384,385,388,403,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz */
- {MODEPREFIX("1400x1050"),122000, 1400,1488,1640,1880,0, 1050,1052,1064,1082,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("700x525"),61000, 700,744,820,940,0, 525,526,532,541,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz */
- {MODEPREFIX("1400x1050"),155800, 1400,1464,1784,1912,0, 1050,1052,1064,1090,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("700x525"),77900, 700,732,892,956,0, 525,526,532,545,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1600x1024 @ 60Hz (SGI 1600SW) hsync: 64.0kHz */
- {MODEPREFIX("1600x1024"),106910, 1600,1620,1640,1670,0, 1024,1027,1030,1067,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
- {MODEPREFIX("800x512"),53455, 800,810,820,835,0, 512,513,515,533,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz */
- {MODEPREFIX("1920x1440"),341350, 1920,2072,2288,2656,0, 1440,1441,1444,1512,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("960x720"),170675, 960,1036,1144,1328,0, 720,720,722,756,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz */
- {MODEPREFIX("2048x1536"),266950, 2048,2200,2424,2800,0, 1536,1537,1540,1589,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("1024x768"),133475, 1024,1100,1212,1400,0, 768,768,770,794,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz */
- {MODEPREFIX("2048x1536"),340480, 2048,2216,2440,2832,0, 1536,1537,1540,1603,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("1024x768"),170240, 1024,1108,1220,1416,0, 768,768,770,801,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
-/* 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz */
- {MODEPREFIX("2048x1536"),388040, 2048,2216,2440,2832,0, 1536,1537,1540,1612,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
- {MODEPREFIX("1024x768"),194020, 1024,1108,1220,1416,0, 768,768,770,806,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
- {MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}
-};
diff --git a/xserver/hw/xfree86/common/xf86DoProbe.c b/xserver/hw/xfree86/common/xf86DoProbe.c
index fc0a9f4eb..bba6ab7e8 100644
--- a/xserver/hw/xfree86/common/xf86DoProbe.c
+++ b/xserver/hw/xfree86/common/xf86DoProbe.c
@@ -92,9 +92,7 @@ DoProbe()
xf86MsgVerb(X_INFO, 3, "Probing in driver %s\n", drv->driverName);
- if (drv->Probe == NULL) continue;
-
- probeResult = (*drv->Probe)( drv, PROBE_DETECT );
+ probeResult = xf86CallDriverProbe( drv, TRUE );
if (!probeResult) {
xf86ErrorF("Probe in driver `%s' returns FALSE\n",
drv->driverName);
diff --git a/xserver/hw/xfree86/common/xf86DoScanPci.c b/xserver/hw/xfree86/common/xf86DoScanPci.c
deleted file mode 100644
index 0c6668a49..000000000
--- a/xserver/hw/xfree86/common/xf86DoScanPci.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 1999-2002 by The XFree86 Project, Inc.
- *
- * 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:
- *
- * 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
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * Finish setting up the server.
- * Call the functions from the scanpci module.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "os.h"
-#include "loaderProcs.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Pci.h"
-#include "xf86ScanPci.h"
-
-
-void DoScanPci(int argc, char **argv, int i)
-{
- int j,skip,globalVerbose,scanpciVerbose;
- ScanPciSetupProcPtr PciSetup;
- ScanPciDisplayCardInfoProcPtr DisplayPCICardInfo;
- int errmaj, errmin;
-
- /*
- * first we need to finish setup of the OS so that we can call other
- * functions in the server
- */
- OsInit();
-
- /*
- * The old verbosity processing that was here isn't useful anymore, but
- * for compatibility purposes, ignore verbosity changes after the -scanpci
- * flag.
- */
- globalVerbose = xf86Verbose;
-
- /*
- * next we process the arguments that are remaining on the command line,
- * so that things like the module path can be set there
- */
- for ( j = i+1; j < argc; j++ ) {
- if ((skip = ddxProcessArgument(argc, argv, j)))
- j += (skip - 1);
- }
-
- /*
- * Was the verbosity level increased? If so, set it back.
- */
- if (xf86Verbose > globalVerbose)
- xf86SetVerbosity(globalVerbose);
-
- /*
- * Setting scanpciVerbose to 0 will ensure that the output will go to
- * stderr for all reasonable default stderr verbosity levels.
- */
- scanpciVerbose = 0;
-
- /*
- * now get the loader set up and load the scanpci module
- */
- /* Initialise the loader */
- LoaderInit();
- /* Tell the loader the default module search path */
- LoaderSetPath(xf86ModulePath);
-
- if (!LoadModule("scanpci", NULL, NULL, NULL, NULL, NULL,
- &errmaj, &errmin)) {
- LoaderErrorMsg(NULL, "scanpci", errmaj, errmin);
- exit(1);
- }
- PciSetup = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds");
- DisplayPCICardInfo =
- (ScanPciDisplayCardInfoProcPtr)LoaderSymbol("ScanPciDisplayPCICardInfo");
-
- if (!(*PciSetup)())
- FatalError("ScanPciSetupPciIds() failed\n");
- (*DisplayPCICardInfo)(scanpciVerbose);
-
- /*
- * That's it; we really should clean things up, but a simple
- * exit seems to be all we need.
- */
- exit(0);
-}
diff --git a/xserver/hw/xfree86/common/xf86Events.c b/xserver/hw/xfree86/common/xf86Events.c
index 46fae0856..2b7cb121d 100644
--- a/xserver/hw/xfree86/common/xf86Events.c
+++ b/xserver/hw/xfree86/common/xf86Events.c
@@ -317,7 +317,7 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
}
break;
#if !defined(__SOL8__) && !defined(sgi) && \
- (!defined(sun) || defined(i386)) && defined(VT_ACTIVATE)
+ (!defined(sun) || defined(__i386__)) && defined(VT_ACTIVATE)
case ACTION_SWITCHSCREEN:
if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
int vtno = *((int *) arg);
@@ -340,7 +340,7 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
#else
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0)
#endif
-#if defined (__SCO__) || (defined(sun) && defined (i386) && defined (SVR4)) || defined(__UNIXWARE__)
+#if defined (__SCO__) || (defined(sun) && defined (__i386__) && defined (SVR4)) || defined(__UNIXWARE__)
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0)
#else
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) < 0)
@@ -857,7 +857,7 @@ xf86VTSwitch()
#endif
#ifdef DPMSExtension
if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ DPMSSet(serverClient, DPMSModeOn);
#endif
for (i = 0; i < xf86NumScreens; i++) {
if (!(dispatchException & DE_TERMINATE))
@@ -906,7 +906,7 @@ xf86VTSwitch()
(*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
}
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
@@ -970,7 +970,7 @@ xf86VTSwitch()
}
/* Turn screen saver off when switching back */
- SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
diff --git a/xserver/hw/xfree86/common/xf86Globals.c b/xserver/hw/xfree86/common/xf86Globals.c
index 745c06379..0dc42c66b 100644
--- a/xserver/hw/xfree86/common/xf86Globals.c
+++ b/xserver/hw/xfree86/common/xf86Globals.c
@@ -46,10 +46,12 @@
/* Globals that video drivers may access */
-_X_EXPORT int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */
-int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */
+/* Index into pScreen.devPrivates */
+DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey;
+/* Index of ScrnInfo in pScreen.devPrivates */
+_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey;
+_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey;
_X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-_X_EXPORT int xf86PixmapIndex = 0;
_X_EXPORT const unsigned char byte_reversed[256] =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
@@ -93,36 +95,10 @@ InputInfoPtr xf86InputDevs = NULL;
/* Globals that video drivers may not access */
xf86InfoRec xf86Info = {
- NULL, /* pKeyboard */
- NULL, /* kbdProc */
- NULL, /* kbdEvents */
-1, /* consoleFd */
- -1, /* kbdFd */
-1, /* vtno */
- -1, /* kbdType */
- -1, /* kbdRate */
- -1, /* kbdDelay */
- -1, /* bell_pitch */
- -1, /* bell_duration */
- TRUE, /* autoRepeat */
- 0, /* leds */
- 0, /* xleds */
- NULL, /* vtinit */
- 0, /* scanPrefix */
- FALSE, /* capsLock */
- FALSE, /* numLock */
- FALSE, /* scrollLock */
- FALSE, /* modeSwitchLock */
- FALSE, /* composeLock */
FALSE, /* vtSysreq */
SKWhenNeeded, /* ddxSpecialKeys */
- FALSE, /* ActionKeyBindingsSet */
-#if defined(SVR4) && defined(i386)
- FALSE, /* panix106 */
-#endif
-#if defined(__OpenBSD__) || defined(__NetBSD__)
- 0, /* wskbdType */
-#endif
NULL, /* pMouse */
#ifdef XINPUT
NULL, /* mouseLocal */
@@ -141,20 +117,6 @@ xf86InfoRec xf86Info = {
-1, /* screenFd */
-1, /* consType */
#endif
-#ifdef XKB
- NULL, /* xkbkeymap */
- NULL, /* xkbkeycodes */
- NULL, /* xkbtypes */
- NULL, /* xkbcompat */
- NULL, /* xkbsymbols */
- NULL, /* xkbgeometry */
- FALSE, /* xkbcomponents_specified */
- NULL, /* xkbrules */
- NULL, /* xkbmodel */
- NULL, /* xkblayout */
- NULL, /* xkbvariant */
- NULL, /* xkboptions */
-#endif
FALSE, /* allowMouseOpenFail */
TRUE, /* vidModeEnabled */
FALSE, /* vidModeAllowNonLocal */
@@ -163,7 +125,7 @@ xf86InfoRec xf86Info = {
PCIOsConfig, /* pciFlags */
Pix24DontCare, /* pixmap24 */
X_DEFAULT, /* pix24From */
-#if defined(i386) || defined(__i386__)
+#ifdef __i386__
FALSE, /* pc98 */
#endif
TRUE, /* pmFlag */
@@ -185,15 +147,12 @@ _X_EXPORT confDRIRec xf86ConfigDRI = {0, };
XF86ConfigPtr xf86configptr = NULL;
Bool xf86Resetting = FALSE;
Bool xf86Initialising = FALSE;
-Bool xf86ProbeFailed = FALSE;
Bool xf86DoProbe = FALSE;
Bool xf86DoConfigure = FALSE;
DriverPtr *xf86DriverList = NULL;
int xf86NumDrivers = 0;
InputDriverPtr *xf86InputDriverList = NULL;
int xf86NumInputDrivers = 0;
-ModuleInfoPtr *xf86ModuleInfoList = NULL;
-int xf86NumModuleInfos = 0;
int xf86NumScreens = 0;
const char *xf86VisualNames[] = {
@@ -243,4 +202,7 @@ Bool xf86MiscModInDevAllowNonLocal = FALSE;
RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
_X_EXPORT Bool xf86inSuspend = FALSE;
Bool xorgHWAccess = FALSE;
-PciBusId xf86IsolateDevice;
+
+struct pci_slot_match xf86IsolateDevice = {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
+};
diff --git a/xserver/hw/xfree86/common/xf86Helper.c b/xserver/hw/xfree86/common/xf86Helper.c
index c226bf2ea..475628b0c 100644
--- a/xserver/hw/xfree86/common/xf86Helper.c
+++ b/xserver/hw/xfree86/common/xf86Helper.c
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1997-2003 by The XFree86 Project, Inc.
*
@@ -39,6 +38,9 @@
#include <xorg-config.h>
#endif
+#include <pciaccess.h>
+#include "Pci.h"
+
#include <X11/X.h>
#include "os.h"
#include "servermd.h"
@@ -90,7 +92,7 @@ xf86AddDriver(DriverPtr driver, pointer module, int flags)
else {
(void) memset( xf86DriverList[xf86NumDrivers - 1], 0,
sizeof( DriverRec ) );
- (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
+ (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
sizeof(DriverRec1));
}
@@ -141,36 +143,42 @@ xf86DeleteInputDriver(int drvIndex)
xf86InputDriverList[drvIndex] = NULL;
}
-_X_EXPORT void
-xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
+InputDriverPtr
+xf86LookupInputDriver(const char *name)
{
- /* Don't add null entries */
- if (!module)
- return;
+ int i;
+
+ for (i = 0; i < xf86NumInputDrivers; i++) {
+ if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+ xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
+ return xf86InputDriverList[i];
+ }
+ return NULL;
+}
+
+InputInfoPtr
+xf86LookupInput(const char *name)
+{
+ InputInfoPtr p;
- if (xf86ModuleInfoList == NULL)
- xf86NumModuleInfos = 0;
+ for (p = xf86InputDevs; p != NULL; p = p->next) {
+ if (strcmp(name, p->name) == 0)
+ return p;
+ }
- xf86NumModuleInfos++;
- xf86ModuleInfoList = xnfrealloc(xf86ModuleInfoList,
- xf86NumModuleInfos * sizeof(ModuleInfoPtr));
- xf86ModuleInfoList[xf86NumModuleInfos - 1] = xnfalloc(sizeof(ModuleInfoRec));
- *xf86ModuleInfoList[xf86NumModuleInfos - 1] = *info;
- xf86ModuleInfoList[xf86NumModuleInfos - 1]->module = module;
- xf86ModuleInfoList[xf86NumModuleInfos - 1]->refCount = 0;
+ return NULL;
}
+/* ABI stubs of despair */
_X_EXPORT void
-xf86DeleteModuleInfo(int idx)
+xf86AddModuleInfo(pointer info, pointer module)
{
- if (xf86ModuleInfoList[idx]) {
- if (xf86ModuleInfoList[idx]->module)
- UnloadModule(xf86ModuleInfoList[idx]->module);
- xfree(xf86ModuleInfoList[idx]);
- xf86ModuleInfoList[idx] = NULL;
- }
}
+_X_EXPORT void
+xf86DeleteModuleInfo(int idx)
+{
+}
/* Allocate a new ScrnInfoRec in xf86Screens */
@@ -215,7 +223,7 @@ xf86AllocateScreen(DriverPtr drv, int flags)
#endif
xf86Screens[i]->DriverFunc = drv->driverFunc;
-
+
return xf86Screens[i];
}
@@ -267,7 +275,7 @@ xf86DeleteScreen(int scrnIndex, int flags)
xfree(pScrn);
/* Move the other entries down, updating their scrnIndex fields */
-
+
xf86NumScreens--;
for (i = scrnIndex; i < xf86NumScreens; i++) {
@@ -300,12 +308,11 @@ xf86AllocateScrnInfoPrivateIndex(void)
return idx;
}
-/* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */
-
+/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
_X_EXPORT InputInfoPtr
xf86AllocateInput(InputDriverPtr drv, int flags)
{
- InputInfoPtr new;
+ InputInfoPtr new, *prev = NULL;
if (!(new = xcalloc(sizeof(InputInfoRec), 1)))
return NULL;
@@ -313,8 +320,13 @@ xf86AllocateInput(InputDriverPtr drv, int flags)
new->drv = drv;
drv->refCount++;
new->module = DuplicateModule(drv->module, NULL);
- new->next = xf86InputDevs;
- xf86InputDevs = new;
+
+ for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
+ ;
+
+ *prev = new;
+ new->next = NULL;
+
return new;
}
@@ -345,8 +357,11 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
if (pInp->drv)
pInp->drv->refCount--;
+ /* This should *really* be handled in drv->UnInit(dev) call instead */
+#if 0
if (pInp->private)
xfree(pInp->private);
+#endif
/* Remove the entry from the list. */
if (pInp == xf86InputDevs)
@@ -452,16 +467,6 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
scrp->bitsPerPixelFrom = X_DEFAULT;
scrp->depthFrom = X_DEFAULT;
-#if BITMAP_SCANLINE_UNIT == 64
- /*
- * For platforms with 64-bit scanlines, modify the driver's depth24flags
- * to remove preferences for packed 24bpp modes, which are not currently
- * supported on these platforms.
- */
- depth24flags &= ~(SupportConvert32to24 | SupportConvert32to24 |
- PreferConvert24to32 | PreferConvert32to24);
-#endif
-
if (xf86FbBpp > 0) {
scrp->bitsPerPixel = xf86FbBpp;
scrp->bitsPerPixelFrom = X_CMDLINE;
@@ -920,7 +925,7 @@ xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
{
MessageType from = X_DEFAULT;
#if 0
- xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+ xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
#endif
if (TEST_GAMMA(xf86Gamma)) {
from = X_CMDLINE;
@@ -973,7 +978,7 @@ _X_EXPORT void
xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
{
MessageType from = X_DEFAULT;
- xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
+ xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
int ddcWidthmm, ddcHeightmm;
int widthErr, heightErr;
@@ -983,7 +988,7 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
/* DDC gives display size in mm for individual modes,
- * but cm for monitor
+ * but cm for monitor
*/
ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
@@ -1027,7 +1032,7 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
if (widthErr>10 || heightErr>10) {
/* Should include config file name for monitor here */
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
+ "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
}
}
@@ -1092,7 +1097,6 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
Bool anyMarked = FALSE;
- RegionPtr pOldClip = NULL, bsExposed;
#ifdef DO_SAVE_UNDERS
Bool dosave = FALSE;
#endif
@@ -1123,7 +1127,7 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
pWin->valdata->before.resized = TRUE;
}
}
-
+
/*
* Use REGION_BREAK to avoid optimizations in ValidateTree
* that assume the root borderClip can't change well, normally
@@ -1148,17 +1152,11 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
REGION_EMPTY(pScreen, &pWin->borderClip);
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
-
+
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
-
+
if (WasViewable)
{
- if (pWin->backStorage)
- {
- pOldClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, pOldClip, &pWin->clipList);
- }
-
if (pWin->firstChild)
{
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
@@ -1182,28 +1180,6 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
(*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
}
- if (pWin->backStorage &&
- ((pWin->backingStore == Always) || WasViewable))
- {
- if (!WasViewable)
- pOldClip = &pWin->clipList; /* a convenient empty region */
- bsExposed = (*pScreen->TranslateBackingStore)
- (pWin, 0, 0, pOldClip,
- pWin->drawable.x, pWin->drawable.y);
- if (WasViewable)
- REGION_DESTROY(pScreen, pOldClip);
- if (bsExposed)
- {
- RegionPtr valExposed = NullRegion;
-
- if (pWin->valdata)
- valExposed = &pWin->valdata->after.exposed;
- (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
- if (valExposed)
- REGION_EMPTY(pScreen, valExposed);
- REGION_DESTROY(pScreen, bsExposed);
- }
- }
if (WasViewable)
{
if (anyMarked)
@@ -1254,7 +1230,7 @@ xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
*/
pspix->devPrivate = pScrnInfo->pixmapPrivate;
/*
- * Restore all of the clip lists on the screen
+ * Restore all of the clip lists on the screen
*/
if (!xf86Resetting)
xf86SetRootClip (pScreen, TRUE);
@@ -1263,7 +1239,7 @@ xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
else
{
/*
- * Empty all of the clip lists on the screen
+ * Empty all of the clip lists on the screen
*/
xf86SetRootClip (pScreen, FALSE);
/*
@@ -1380,11 +1356,11 @@ xf86ErrorF(const char *format, ...)
void
xf86LogInit()
{
- char *lf;
+ char *lf = NULL;
#define LOGSUFFIX ".log"
#define LOGOLDSUFFIX ".old"
-
+
/* Get the log file name */
if (xf86LogFileFrom == X_DEFAULT) {
/* Append the display number and ".log" */
@@ -1404,6 +1380,8 @@ xf86LogInit()
#undef LOGSUFFIX
#undef LOGOLDSUFFIX
+
+ free(lf);
}
void
@@ -1498,9 +1476,6 @@ xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
}
-#define MAXDRIVERS 64 /* A >hack<, to be sure ... */
-
-
_X_EXPORT int
xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
{
@@ -1512,7 +1487,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
*sectlist = NULL;
if (xf86DoProbe) return 1;
-
+
if (xf86DoConfigure && xf86DoConfigurePass1) return 1;
/*
@@ -1520,18 +1495,18 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
* as they show up in the config file with the drivers that the server
* loads at run time.
*
- * ChipProbe can call
- * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
+ * ChipProbe can call
+ * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
* with its driver name. The function allocates an array of GDevPtr and
* returns this via sectlist and returns the number of elements in
* this list as return value. 0 means none found, -1 means fatal error.
- *
+ *
* It can figure out which of the Device sections to use for which card
* (using things like the Card statement, etc). For single headed servers
* there will of course be just one such Device section.
*/
i = 0;
-
+
/*
* first we need to loop over all the Screens sections to get to all
* 'active' device sections
@@ -1561,7 +1536,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
}
j++;
}
-
+
/*
* make the array NULL terminated and return its address
*/
@@ -1576,7 +1551,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
}
struct Inst {
- pciVideoPtr pci;
+ struct pci_device * pci;
GDevPtr dev;
Bool foundHW; /* PCIid in list of supported chipsets */
Bool claimed; /* BusID matches with a device section */
@@ -1587,7 +1562,7 @@ struct Inst {
/**
* Find set of unclaimed devices matching a given vendor ID.
- *
+ *
* Used by drivers to find as yet unclaimed devices matching the specified
* vendor ID.
*
@@ -1603,7 +1578,7 @@ struct Inst {
* \param drvp Pointer the driver's control structure.
* \param foundEntities Returned list of entity indicies associated with the
* driver.
- *
+ *
* \returns
* The number of elements in returned in \c foundEntities on success or zero
* on failure.
@@ -1618,13 +1593,14 @@ struct Inst {
* that parameter.
*/
_X_EXPORT int
-xf86MatchPciInstances(const char *driverName, int vendorID,
+xf86MatchPciInstances(const char *driverName, int vendorID,
SymTabPtr chipsets, PciChipsets *PCIchipsets,
GDevPtr *devList, int numDevs, DriverPtr drvp,
int **foundEntities)
{
int i,j;
- pciVideoPtr pPci, *ppPci;
+ struct pci_device * pPci;
+ struct pci_device_iterator *iter;
struct Inst *instances = NULL;
int numClaimedInstances = 0;
int allocatedInstances = 0;
@@ -1635,8 +1611,6 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*foundEntities = NULL;
- if (!xf86PciVideoInfo)
- return 0;
/* Each PCI device will contribute at least one entry. Each device
* section can contribute at most one entry. The sum of the two is
@@ -1646,21 +1620,22 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*/
if ( !xf86DoProbe && !(xf86DoConfigure && xf86DoConfigurePass1) ) {
unsigned max_entries = numDevs;
- for (ppPci = xf86PciVideoInfo ; *ppPci != NULL ; ppPci++) {
+
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
max_entries++;
}
- instances = xnfalloc( max_entries * sizeof(struct Inst) );
+ pci_iterator_destroy(iter);
+ instances = xnfalloc(max_entries * sizeof(struct Inst));
}
- for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
- unsigned device_class = ((*ppPci)->class << 16)
- | ((*ppPci)->subclass << 8) | ((*ppPci)->interface);
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ unsigned device_class = pPci->device_class;
Bool foundVendor = FALSE;
- pPci = *ppPci;
-
/* Convert the pre-PCI 2.0 device class for a VGA adapter to the
* 2.0 version of the same class.
*/
@@ -1685,18 +1660,20 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
const unsigned device_id = (id->PCIid & 0x0000FFFF);
const unsigned match_class = 0x00030000 | id->PCIid;
- if ( (vendor_id == pPci->vendor)
- || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class)) ) {
- if ( !foundVendor && (instances != NULL) ) {
+ if ((vendor_id == pPci->vendor_id)
+ || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
+ if (!foundVendor && (instances != NULL)) {
++allocatedInstances;
- instances[allocatedInstances - 1].pci = *ppPci;
+ instances[allocatedInstances - 1].pci = pPci;
instances[allocatedInstances - 1].dev = NULL;
instances[allocatedInstances - 1].claimed = FALSE;
instances[allocatedInstances - 1].foundHW = FALSE;
instances[allocatedInstances - 1].screen = 0;
- foundVendor = TRUE;
}
- if ( (device_id == pPci->chipType)
+
+ foundVendor = TRUE;
+
+ if ( (device_id == pPci->device_id)
|| ((vendorID == PCI_VENDOR_GENERIC)
&& (match_class == device_class)) ) {
if ( instances != NULL ) {
@@ -1706,11 +1683,10 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
- if ( xf86CheckPciSlot(pPci->bus, pPci->device,
- pPci->func) ) {
+ if (xf86CheckPciSlot(pPci)) {
GDevPtr pGDev =
- xf86AddDeviceToConfigure( drvp->driverName,
- pPci, -1 );
+ xf86AddDeviceToConfigure(drvp->driverName,
+ pPci, -1);
if (pGDev) {
/* After configure pass 1, chipID and chipRev
* are treated as over-rides, so clobber them
@@ -1733,6 +1709,8 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
}
+ pci_iterator_destroy(iter);
+
/* In "probe only" or "configure" mode (signaled by instances being NULL),
* our work is done. Return the number of detected devices.
@@ -1766,12 +1744,13 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*/
for (j = 0; j < numDevs; j++) {
- if (devList[j]->screen > 0 && devList[j]->busID
+ if (devList[j]->screen > 0 && devList[j]->busID
&& *devList[j]->busID) {
for (i = 0; i < allocatedInstances; i++) {
pPci = instances[i].pci;
- if (xf86ComparePciBusString(devList[j]->busID, pPci->bus,
- pPci->device,
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+ pPci->dev,
pPci->func)) {
allocatedInstances++;
instances[allocatedInstances - 1] = instances[i];
@@ -1791,11 +1770,12 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
pPci = instances[i].pci;
for (j = 0; j < numDevs; j++) {
if (devList[j]->busID && *devList[j]->busID) {
- if (xf86ComparePciBusString(devList[j]->busID, pPci->bus,
- pPci->device,
- pPci->func) &&
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+ pPci->dev,
+ pPci->func) &&
devList[j]->screen == instances[i].screen) {
-
+
if (devBus)
xf86MsgVerb(X_WARNING,0,
"%s: More than one matching Device section for "
@@ -1804,10 +1784,10 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
devList[j]->identifier);
else
devBus = devList[j];
- }
+ }
} else {
- /*
- * if device section without BusID is found
+ /*
+ * if device section without BusID is found
* only assign to it to the primary device.
*/
if (xf86IsPrimaryPci(pPci)) {
@@ -1822,12 +1802,13 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
}
}
- if (devBus) dev = devBus; /* busID preferred */
+ if (devBus) dev = devBus; /* busID preferred */
if (!dev) {
- if (xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func)) {
+ if ( xf86CheckPciSlot( pPci ) ) {
xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID PCI:%i:%i:%i) found\n",
- driverName, pPci->bus, pPci->device, pPci->func);
+ "for instance (BusID PCI:%u@%u:%u:%u) found\n",
+ driverName, pPci->domain, pPci->bus, pPci->dev,
+ pPci->func);
}
} else {
numClaimedInstances++;
@@ -1938,31 +1919,27 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
* XXX Need to make sure that two different drivers don't claim
* the same screen > 0 instance.
*/
- if (instances[i].screen == 0 &&
- !xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func))
+ if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
continue;
#ifdef DEBUG
ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n",
- driverName, pPci->bus, pPci->device, pPci->func);
+ driverName, pPci->bus, pPci->dev, pPci->func);
#endif
/* Allocate an entry in the lists to be returned */
numFound++;
retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
- retEntities[numFound - 1]
- = xf86ClaimPciSlot(pPci->bus, pPci->device,
- pPci->func,drvp, instances[i].chip,
- instances[i].dev,instances[i].dev->active ?
- TRUE : FALSE);
+ retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
+ instances[i].chip,
+ instances[i].dev,
+ instances[i].dev->active);
if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
for (j = 0; j < xf86NumEntities; j++) {
EntityPtr pEnt = xf86Entities[j];
- if (pEnt->busType != BUS_PCI)
+ if (pEnt->bus.type != BUS_PCI)
continue;
- if (pEnt->pciBusId.bus == pPci->bus &&
- pEnt->pciBusId.device == pPci->device &&
- pEnt->pciBusId.func == pPci->func) {
+ if (pEnt->bus.id.pci == pPci) {
retEntities[numFound - 1] = j;
xf86AddDevToEntity(j, instances[i].dev);
break;
@@ -2042,7 +2019,7 @@ xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
dev->identifier);
} else
foundChip = c->token;
- } else {
+ } else {
if (FindIsaDevice) foundChip = (*FindIsaDevice)(dev);
/* Probe it */
from = X_PROBED;
@@ -2053,7 +2030,7 @@ xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
if (foundChip >= 0){
for (Chips = ISAchipsets; Chips->numChipset >= 0; Chips++) {
- if (Chips->numChipset == foundChip)
+ if (Chips->numChipset == foundChip)
break;
}
if (Chips->numChipset == -1){
@@ -2076,7 +2053,7 @@ xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
}
}
*foundEntities = retEntities;
-
+
return numFound;
}
@@ -2100,7 +2077,7 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
if (num > MAXCLOCKS)
num = MAXCLOCKS;
- for (i = 0; i < num; i++)
+ for (i = 0; i < num; i++)
{
if (ProtectRegs)
(*ProtectRegs)(pScrn, TRUE);
@@ -2113,7 +2090,7 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
(*ProtectRegs)(pScrn, FALSE);
if (BlankScreen)
(*BlankScreen)(pScrn, FALSE);
-
+
usleep(50000); /* let VCO stabilise */
cnt = 0;
@@ -2127,25 +2104,25 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
ErrorF("your OS does not support disabling interrupts, then you\n");
FatalError("must specify a Clocks line in the XF86Config file.\n");
}
- while ((inb(status) & maskval) == 0x00)
+ while ((inb(status) & maskval) == 0x00)
if (sync-- == 0) goto finish;
/* Something appears to be happening, so reset sync count */
sync = 200000;
- while ((inb(status) & maskval) == maskval)
+ while ((inb(status) & maskval) == maskval)
if (sync-- == 0) goto finish;
/* Something appears to be happening, so reset sync count */
sync = 200000;
- while ((inb(status) & maskval) == 0x00)
+ while ((inb(status) & maskval) == 0x00)
if (sync-- == 0) goto finish;
-
- for (rcnt = 0; rcnt < 5; rcnt++)
+
+ for (rcnt = 0; rcnt < 5; rcnt++)
{
- while (!(inb(status) & maskval))
+ while (!(inb(status) & maskval))
cnt++;
- while ((inb(status) & maskval))
+ while ((inb(status) & maskval))
cnt++;
}
-
+
finish:
xf86EnableInterrupts();
@@ -2156,7 +2133,7 @@ finish:
xf86SetPriority(FALSE);
- for (i = 0; i < num; i++)
+ for (i = 0; i < num; i++)
{
if (i != knownclkindex)
{
@@ -2164,10 +2141,10 @@ finish:
{
pScrn->clock[i] = 0;
}
- else
+ else
{
pScrn->clock[i] = (int)(0.5 +
- (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
+ (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
(pScrn->clock[i]));
/* Round to nearest 10KHz */
pScrn->clock[i] += 5;
@@ -2178,7 +2155,7 @@ finish:
}
pScrn->clock[knownclkindex] = knownclkvalue;
- pScrn->numClocks = num;
+ pScrn->numClocks = num;
/* Restore registers that were written on */
(*ClockFunc)(pScrn, CLK_REG_RESTORE);
@@ -2345,7 +2322,7 @@ xf86GetAllowMouseOpenFail()
_X_EXPORT Bool
xf86IsPc98()
{
-#if defined(i386) || defined(__i386__)
+#ifdef __i386__
return xf86Info.pc98;
#else
return FALSE;
@@ -2399,23 +2376,19 @@ xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
/*
* xf86LoadOneModule loads a single module.
- */
+ */
_X_EXPORT pointer
xf86LoadOneModule(char *name, pointer opt)
{
int errmaj, errmin;
char *Name;
pointer mod;
-
+
if (!name)
return NULL;
-
-#ifndef NORMALISE_MODULE_NAME
- Name = xstrdup(name);
-#else
+
/* Normalise the module name */
Name = xf86NormalizeName(name);
-#endif
/* Skip empty names */
if (Name == NULL)
@@ -2481,7 +2454,7 @@ static const OptionInfoRec BSOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
-_X_EXPORT void
+_X_EXPORT void
xf86SetBackingStore(ScreenPtr pScreen)
{
Bool useBS = FALSE;
@@ -2521,7 +2494,7 @@ static const OptionInfoRec SMOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
-_X_EXPORT void
+_X_EXPORT void
xf86SetSilkenMouse (ScreenPtr pScreen)
{
Bool useSM = TRUE;
@@ -2532,12 +2505,12 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
options = xnfalloc(sizeof(SMOptions));
(void)memcpy(options, SMOptions, sizeof(SMOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
+
/* check for commandline option here */
/* disable if screen shares resources */
- if (((pScrn->racMemFlags & RAC_CURSOR) &&
+ if (((pScrn->racMemFlags & RAC_CURSOR) &&
!xf86NoSharedResources(pScrn->scrnIndex,MEM)) ||
- ((pScrn->racIoFlags & RAC_CURSOR) &&
+ ((pScrn->racIoFlags & RAC_CURSOR) &&
!xf86NoSharedResources(pScrn->scrnIndex,IO))) {
useSM = FALSE;
from = X_PROBED;
@@ -2552,7 +2525,7 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
/*
* XXX quick hack to report correctly for OSs that can't do SilkenMouse
* yet. Should handle this differently so that alternate async methods
- * like Xqueue work correctly with this too.
+ * work correctly with this too.
*/
pScrn->silkenMouse = useSM && xf86SIGIOSupported();
if (serverGeneration == 1)
@@ -2606,7 +2579,7 @@ xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
IsaChipsets *i_id;
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (!pEnt) return pScrn;
-
+
if (!(pEnt->location.type == BUS_ISA)) {
xfree(pEnt);
return pScrn;
@@ -2620,7 +2593,7 @@ xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
}
if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
xf86AddEntityToScreen(pScrn,entityIndex);
if (i_chip) {
@@ -2645,7 +2618,7 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (!pEnt) return pScrn;
- if (!(pEnt->location.type == BUS_PCI)
+ if (!(pEnt->location.type == BUS_PCI)
|| !xf86GetPciInfoForEntity(entityIndex)) {
xfree(pEnt);
return pScrn;
@@ -2682,12 +2655,12 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
_X_EXPORT ScrnInfoPtr
xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- EntityProc init, EntityProc enter, EntityProc leave,
+ EntityProc init, EntityProc enter, EntityProc leave,
pointer private)
{
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (!pEnt) return pScrn;
-
+
if (!(pEnt->location.type == BUS_NONE)) {
xfree(pEnt);
return pScrn;
@@ -2700,7 +2673,7 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
}
if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
xf86AddEntityToScreen(pScrn,entityIndex);
xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
@@ -2722,14 +2695,14 @@ xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
IsaChipsets *i_id;
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (!pEnt) return FALSE;
-
+
if (!pEnt->active || !(pEnt->location.type == BUS_ISA)) {
xfree(pEnt);
return FALSE;
}
-
+
xf86AddEntityToScreen(pScrn,entityIndex);
-
+
if (i_chip) {
for (i_id = i_chip; i_id->numChipset != -1; i_id++) {
if (pEnt->chipset == i_id->numChipset) break;
@@ -2740,10 +2713,10 @@ xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
xf86ClaimFixedResources(res,entityIndex);
if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
return FALSE;
-
+
return TRUE;
}
-
+
_X_EXPORT Bool
xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
PciChipsets *p_chip, resList res, EntityProc init,
@@ -2752,13 +2725,13 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
PciChipsets *p_id;
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (!pEnt) return FALSE;
-
+
if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
xfree(pEnt);
return FALSE;
}
xf86AddEntityToScreen(pScrn,entityIndex);
-
+
if (p_chip) {
for (p_id = p_chip; p_id->numChipset != -1; p_id++) {
if (pEnt->chipset == p_id->numChipset) break;
@@ -2766,11 +2739,11 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
xf86ClaimFixedResources(p_id->resList,entityIndex);
}
xfree(pEnt);
-
+
xf86ClaimFixedResources(res,entityIndex);
if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
return FALSE;
-
+
return TRUE;
}
@@ -2826,7 +2799,7 @@ xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
}
void
-xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
EntityProc enter, EntityProc leave, pointer private)
{
ScrnInfoPtr pScrn;
@@ -2895,7 +2868,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
pNewProp->format = format;
pNewProp->size = len;
pNewProp->data = value;
-
+
#ifdef DEBUG
ErrorF("new property filled\n");
#endif
@@ -2937,7 +2910,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
#ifdef DEBUG
ErrorF("xf86RegisterRootWindowProperty succeeded\n");
#endif
- return(Success);
+ return(Success);
}
_X_EXPORT Bool
@@ -2955,3 +2928,30 @@ xf86IsUnblank(int mode)
return TRUE;
}
}
+
+_X_EXPORT void
+xf86MotionHistoryAllocate(LocalDevicePtr local)
+{
+ AllocateMotionHistory(local->dev);
+}
+
+_X_EXPORT int
+xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
+ unsigned long stop, ScreenPtr pScreen)
+{
+ return GetMotionHistory(pDev, buff, start, stop, pScreen);
+}
+
+_X_EXPORT void
+xf86getsecs(long * secs, long * usecs)
+{
+ struct timeval tv;
+
+ X_GETTIMEOFDAY(&tv);
+ if (secs)
+ *secs = tv.tv_sec;
+ if (usecs)
+ *usecs= tv.tv_usec;
+
+ return;
+}
diff --git a/xserver/hw/xfree86/common/xf86Init.c b/xserver/hw/xfree86/common/xf86Init.c
index f0109473c..f020fbe13 100644
--- a/xserver/hw/xfree86/common/xf86Init.c
+++ b/xserver/hw/xfree86/common/xf86Init.c
@@ -92,6 +92,9 @@
#include "dpmsproc.h"
#endif
+#include <pciaccess.h>
+#include "Pci.h"
+#include "xf86Bus.h"
/* forward declarations */
@@ -99,17 +102,15 @@ static void xf86PrintBanner(void);
static void xf86PrintMarkers(void);
static void xf86PrintDefaultModulePath(void);
static void xf86PrintDefaultLibraryPath(void);
-static void xf86RunVtInit(void);
+
+static Bool probe_devices_from_device_sections(DriverPtr drvp);
+static Bool add_matching_devices_to_configure_list(DriverPtr drvp);
+static Bool check_for_matching_devices(DriverPtr drvp);
#ifdef XF86PM
void (*xf86OSPMClose)(void) = NULL;
#endif
-static char *baseModules[] = {
- "pcidata",
- NULL
-};
-
/* Common pixmap formats */
static PixmapFormatRec formats[MAXFORMATS] = {
@@ -141,8 +142,8 @@ xf86CreateRootWindow(WindowPtr pWin)
int err = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow =
- (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
#ifdef DEBUG
ErrorF("xf86CreateRootWindow(%p)\n", pWin);
@@ -158,7 +159,7 @@ xf86CreateRootWindow(WindowPtr pWin)
/* Unhook this function ... */
pScreen->CreateWindow = CreateWindow;
- pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
/* ... and call the previous CreateWindow fuction, if any */
if (NULL!=pScreen->CreateWindow) {
@@ -175,12 +176,11 @@ xf86CreateRootWindow(WindowPtr pWin)
Atom prop;
prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
- err = ChangeWindowProperty(pWin,
- prop, pProp->type,
- pProp->format, PropModeReplace,
- pProp->size, pProp->data,
- FALSE
- );
+ err = dixChangeWindowProperty(serverClient, pWin,
+ prop, pProp->type,
+ pProp->format, PropModeReplace,
+ pProp->size, pProp->data,
+ FALSE);
}
/* Look at err */
@@ -201,13 +201,6 @@ xf86CreateRootWindow(WindowPtr pWin)
}
-/*
- * InitOutput --
- * Initialize screenInfo for all actually accessible framebuffers.
- * That includes vt-manager setup, querying all possible devices and
- * collecting the pixmap formats.
- */
-
static void
PostConfigInit(void)
{
@@ -240,18 +233,246 @@ PostConfigInit(void)
xf86OSPMClose = xf86OSPMOpen();
#endif
- /* Run an external VT Init program if specified in the config file */
- xf86RunVtInit();
-
/* Do this after XF86Config is read (it's normally in OsInit()) */
OsInitColors();
}
+
+#define END_OF_MATCHES(m) \
+ (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
+
+Bool
+probe_devices_from_device_sections(DriverPtr drvp)
+{
+ int i, j;
+ struct pci_device * pPci;
+ Bool foundScreen = FALSE;
+ const struct pci_id_match * const devices = drvp->supported_devices;
+ GDevPtr *devList;
+ const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList);
+
+
+ for ( i = 0 ; i < numDevs ; i++ ) {
+ struct pci_device_iterator *iter;
+ unsigned device_id;
+
+
+ /* Find the pciVideoRec associated with this device section.
+ */
+ iter = pci_id_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ if (devList[i]->busID && *devList[i]->busID) {
+ if (xf86ComparePciBusString(devList[i]->busID,
+ ((pPci->domain << 8)
+ | pPci->bus),
+ pPci->dev,
+ pPci->func)) {
+ break;
+ }
+ }
+ else if (xf86IsPrimaryPci(pPci)) {
+ break;
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+ if (pPci == NULL) {
+ continue;
+ }
+
+ device_id = (devList[i]->chipID > 0)
+ ? devList[i]->chipID : pPci->device_id;
+
+
+ /* Once the pciVideoRec is found, determine if the device is supported
+ * by the driver. If it is, probe it!
+ */
+ for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) {
+ if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
+ && PCI_ID_COMPARE( devices[j].device_id, device_id )
+ && ((devices[j].device_class_mask & pPci->device_class)
+ == devices[j].device_class) ) {
+ int entry;
+
+ /* Allow the same entity to be used more than once for
+ * devices with multiple screens per entity. This assumes
+ * implicitly that there will be a screen == 0 instance.
+ *
+ * FIXME Need to make sure that two different drivers don't
+ * FIXME claim the same screen > 0 instance.
+ */
+ if ( (devList[i]->screen == 0) && !xf86CheckPciSlot( pPci ) )
+ continue;
+
+#ifdef DEBUG
+ ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ drvp->driverName, pPci->bus, pPci->dev, pPci->func);
+#endif
+
+ /* Allocate an entry in the lists to be returned */
+ entry = xf86ClaimPciSlot(pPci, drvp, device_id,
+ devList[i], devList[i]->active);
+
+ if ((entry == -1) && (devList[i]->screen > 0)) {
+ unsigned k;
+
+ for ( k = 0; k < xf86NumEntities; k++ ) {
+ EntityPtr pEnt = xf86Entities[k];
+ if (pEnt->busType != BUS_PCI)
+ continue;
+
+ if (pEnt->bus.id.pci == pPci) {
+ entry = k;
+ xf86AddDevToEntity(k, devList[i]);
+ break;
+ }
+ }
+ }
+
+ if (entry != -1) {
+ if ((*drvp->PciProbe)(drvp, entry, pPci,
+ devices[j].match_data)) {
+ foundScreen = TRUE;
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+
+ return foundScreen;
+}
+
+
+Bool
+add_matching_devices_to_configure_list(DriverPtr drvp)
+{
+ const struct pci_id_match * const devices = drvp->supported_devices;
+ int j;
+ struct pci_device *pPci;
+ struct pci_device_iterator *iter;
+ int numFound = 0;
+
+
+ iter = pci_id_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ /* Determine if this device is supported by the driver. If it is,
+ * add it to the list of devices to configure.
+ */
+ for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) {
+ if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
+ && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
+ && ((devices[j].device_class_mask & pPci->device_class)
+ == devices[j].device_class) ) {
+ if (xf86CheckPciSlot(pPci)) {
+ GDevPtr pGDev =
+ xf86AddDeviceToConfigure(drvp->driverName, pPci, -1);
+ if (pGDev != NULL) {
+ /* After configure pass 1, chipID and chipRev are
+ * treated as over-rides, so clobber them here.
+ */
+ pGDev->chipID = -1;
+ pGDev->chipRev = -1;
+ }
+
+ numFound++;
+ }
+
+ break;
+ }
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+
+ return (numFound != 0);
+}
+
+
+Bool
+check_for_matching_devices(DriverPtr drvp)
+{
+ const struct pci_id_match * const devices = drvp->supported_devices;
+ int j;
+
+
+ for (j = 0; ! END_OF_MATCHES(devices[j]); j++) {
+ struct pci_device_iterator *iter;
+ struct pci_device *dev;
+
+ iter = pci_id_match_iterator_create(& devices[j]);
+ dev = pci_device_next(iter);
+ pci_iterator_destroy(iter);
+
+ if (dev != NULL) {
+ return TRUE;
+ }
+ }
+
+
+ return FALSE;
+}
+
+
+/**
+ * Call the driver's correct probe function.
+ *
+ * If the driver implements the \c DriverRec::PciProbe entry-point and an
+ * appropriate PCI device (with matching Device section in the xorg.conf file)
+ * is found, it is called. If \c DriverRec::PciProbe or no devices can be
+ * successfully probed with it (e.g., only non-PCI devices are available),
+ * the driver's \c DriverRec::Probe function is called.
+ *
+ * \param drv Driver to probe
+ *
+ * \return
+ * If a device can be successfully probed by the driver, \c TRUE is
+ * returned. Otherwise, \c FALSE is returned.
+ */
+Bool
+xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
+{
+ Bool foundScreen = FALSE;
+
+ if ( drv->PciProbe != NULL ) {
+ if ( xf86DoProbe ) {
+ assert( detect_only );
+ foundScreen = check_for_matching_devices( drv );
+ }
+ else if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
+ assert( detect_only );
+ foundScreen = add_matching_devices_to_configure_list( drv );
+ }
+ else {
+ assert( ! detect_only );
+ foundScreen = probe_devices_from_device_sections( drv );
+ }
+ }
+
+ if ( ! foundScreen && (drv->Probe != NULL) ) {
+ xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
+ drv->driverName );
+ foundScreen = (*drv->Probe)( drv, (detect_only) ? PROBE_DETECT
+ : PROBE_DEFAULT );
+ }
+
+ return foundScreen;
+}
+
+/*
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * That includes vt-manager setup, querying all possible devices and
+ * collecting the pixmap formats.
+ */
void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
int i, j, k, scr_index;
- static unsigned long generation = 0;
char **modulelist;
pointer *optionlist;
screenLayoutPtr layout;
@@ -262,14 +483,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86Initialising = TRUE;
- /* Do this early? */
- if (generation != serverGeneration) {
- xf86ScreenIndex = AllocateScreenPrivateIndex();
- xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
- xf86PixmapIndex = AllocatePixmapPrivateIndex();
- generation = serverGeneration;
- }
-
if (serverGeneration == 1) {
pScreenInfo->numScreens = 0;
@@ -317,10 +530,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
}
- /* Force load mandatory base modules */
- if (!xf86LoadModules(baseModules, NULL))
- FatalError("Unable to load required base modules, Exiting...\n");
-
xf86OpenConsole();
/* Do a general bus probe. This will be a PCI probe for x86 platforms */
@@ -351,6 +560,16 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
/* Load all driver modules specified in the config file */
+ /* If there aren't any specified in the config file, autoconfig them */
+ /* FIXME: Does not handle multiple active screen sections, but I'm not
+ * sure if we really want to handle that case*/
+ GDevPtr configured_device = xf86ConfigLayout.screens->screen->device;
+ if ((!configured_device) || (!configured_device->driver)) {
+ if (!autoConfigDevice(configured_device)) {
+ xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
+ return ;
+ }
+ }
if ((modulelist = xf86DriverlistFromConfig())) {
xf86LoadModules(modulelist, NULL);
xfree(modulelist);
@@ -437,16 +656,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
|| NEED_IO_ENABLED(flags))
continue;
}
-
- if (xf86DriverList[i]->Probe != NULL)
- xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
- else {
- xf86MsgVerb(X_WARNING, 0,
- "Driver `%s' has no Probe function (ignoring)\n",
- xf86DriverList[i]->driverName
- ? xf86DriverList[i]->driverName : "noname");
- }
- xf86SetPciVideo(NULL,NONE);
+
+ xf86CallDriverProbe( xf86DriverList[i], FALSE );
}
/*
@@ -847,8 +1058,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
* Hook in our ScrnInfoRec, and initialise some other pScreen
* fields.
*/
- screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
- = (pointer)xf86Screens[i];
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
/* The driver should set this, but make sure it is set anyway */
xf86Screens[i]->vtSema = TRUE;
@@ -864,8 +1075,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
i, xf86Screens[i]->pScreen->CreateWindow );
#endif
- screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
- = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
#ifdef RENDER
@@ -915,43 +1127,35 @@ InitInput(argc, argv)
xf86Info.vtRequestsPending = FALSE;
xf86Info.inputPending = FALSE;
- if (serverGeneration == 1) {
- /* Call the PreInit function for each input device instance. */
- for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
- xf86MsgVerb(X_WARNING, 0,
- "*** WARNING the legacy keyboard driver \"%s\" has been removed\n",
- (*pDev)->driver);
- xf86MsgVerb(X_WARNING, 0,
- "*** Using the new \"kbd\" driver for \"%s\".\n",
- (*pDev)->identifier);
- strcpy((*pDev)->driver, "kbd");
- }
-
- if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
- xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
- /* XXX For now, just continue. */
- continue;
- }
- if (!pDrv->PreInit) {
- xf86MsgVerb(X_WARNING, 0,
- "Input driver `%s' has no PreInit function (ignoring)\n",
- pDrv->driverName);
- continue;
- }
- pInfo = pDrv->PreInit(pDrv, *pDev, 0);
- if (!pInfo) {
- xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
- (*pDev)->identifier);
- continue;
- } else if (!(pInfo->flags & XI86_CONFIGURED)) {
- xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
- (*pDev)->identifier);
- xf86DeleteInput(pInfo, 0);
- continue;
- }
- }
+ /* Call the PreInit function for each input device instance. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
+ strcpy((*pDev)->driver, "kbd");
+ }
+
+ if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
+ xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
+ /* XXX For now, just continue. */
+ continue;
+ }
+ if (!pDrv->PreInit) {
+ xf86MsgVerb(X_WARNING, 0,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ pDrv->driverName);
+ continue;
+ }
+ pInfo = pDrv->PreInit(pDrv, *pDev, 0);
+ if (!pInfo) {
+ xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
+ (*pDev)->identifier);
+ continue;
+ } else if (!(pInfo->flags & XI86_CONFIGURED)) {
+ xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+ (*pDev)->identifier);
+ xf86DeleteInput(pInfo, 0);
+ continue;
+ }
}
/* Initialise all input devices. */
@@ -985,8 +1189,6 @@ OsVendorInit(void)
{
static Bool beenHere = FALSE;
- xf86WrapperInit();
-
#ifdef SIGCHLD
signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
#endif
@@ -1095,13 +1297,9 @@ AbortDDX()
/*
* try to restore the original video state
*/
-#ifdef HAS_USL_VTS
- /* Need the sleep when starting X from within another X session */
- sleep(1);
-#endif
#ifdef DPMSExtension /* Turn screens back on */
if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ DPMSSet(serverClient, DPMSModeOn);
#endif
if (xf86Screens) {
if (xf86Screens[0]->vtSema)
@@ -1374,15 +1572,6 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86sFlag = TRUE;
return 0;
}
- if (!strcmp(argv[i], "-bpp"))
- {
- ErrorF("The -bpp option is no longer supported.\n"
- "\tUse -depth to set the color depth, and use -fbbpp if you really\n"
- "\tneed to force a non-default framebuffer (hardware) pixel format.\n");
- if (++i >= argc)
- return 1;
- return 2;
- }
if (!strcmp(argv[i], "-pixmap24"))
{
xf86Pix24 = Pix24Use24;
@@ -1495,10 +1684,6 @@ ddxProcessArgument(int argc, char **argv, int i)
return 1;
}
#endif
- if (!strcmp(argv[i], "-scanpci"))
- {
- DoScanPci(argc, argv, i);
- }
if (!strcmp(argv[i], "-probe"))
{
xf86DoProbe = TRUE;
@@ -1539,8 +1724,9 @@ ddxProcessArgument(int argc, char **argv, int i)
FatalError("Bus types other than PCI not yet isolable\n");
}
if (sscanf(argv[i], "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.bus = bus;
- xf86IsolateDevice.device = device;
+ xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus);
+ xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
+ xf86IsolateDevice.dev = device;
xf86IsolateDevice.func = func;
return 2;
} else {
@@ -1577,7 +1763,6 @@ ddxUseMsg()
ErrorF("-config file specify a configuration file, relative to the\n");
ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
ErrorF("-probeonly probe for devices, then exit\n");
- ErrorF("-scanpci execute the scanpci module and exit\n");
ErrorF("-verbose [n] verbose startup messages\n");
ErrorF("-logverbose [n] verbose log messages\n");
ErrorF("-quiet minimal startup messages\n");
@@ -1757,44 +1942,6 @@ xf86PrintDefaultLibraryPath(void)
ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
}
-static void
-xf86RunVtInit(void)
-{
- int i;
-
- /*
- * If VTInit was set, run that program with consoleFd as stdin and stdout
- */
-
- if (xf86Info.vtinit) {
- switch(fork()) {
- case -1:
- FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
- break;
- case 0: /* child */
- if (setuid(getuid()) == -1) {
- xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n",
- strerror(errno));
- exit(255);
- }
- /* set stdin, stdout to the consoleFd */
- for (i = 0; i < 2; i++) {
- if (xf86Info.consoleFd != i) {
- close(i);
- dup(xf86Info.consoleFd);
- }
- }
- execl("/bin/sh", "sh", "-c", xf86Info.vtinit, (void *)NULL);
- xf86Msg(X_WARNING, "exec of /bin/sh failed for VTInit (%s)\n",
- strerror(errno));
- exit(255);
- break;
- default: /* parent */
- wait(NULL);
- }
- }
-}
-
/*
* xf86LoadModules iterates over a list that is being passed in.
*/
diff --git a/xserver/hw/xfree86/common/xf86Mode.c b/xserver/hw/xfree86/common/xf86Mode.c
index 456331d3f..c1b0a5fc9 100644
--- a/xserver/hw/xfree86/common/xf86Mode.c
+++ b/xserver/hw/xfree86/common/xf86Mode.c
@@ -183,6 +183,8 @@ xf86ModeStatusToString(ModeStatus status)
return "all modes must have the same resolution";
case MODE_NO_REDUCED:
return "monitor doesn't support reduced blanking";
+ case MODE_BANDWIDTH:
+ return "mode requires too much memory bandwidth";
case MODE_BAD:
return "unknown reason";
case MODE_ERROR:
@@ -368,38 +370,6 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
return MODE_OK;
}
-static double
-ModeHSync(DisplayModePtr mode)
-{
- double hsync = 0.0;
-
- if (mode->HSync > 0.0)
- hsync = mode->HSync;
- else if (mode->HTotal > 0)
- hsync = (float)mode->Clock / (float)mode->HTotal;
-
- return hsync;
-}
-
-static double
-ModeVRefresh(DisplayModePtr mode)
-{
- double refresh = 0.0;
-
- if (mode->VRefresh > 0.0)
- refresh = mode->VRefresh;
- else if (mode->HTotal > 0 && mode->VTotal > 0) {
- refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
- if (mode->Flags & V_INTERLACE)
- refresh *= 2.0;
- if (mode->Flags & V_DBLSCAN)
- refresh /= 2.0;
- if (mode->VScan > 1)
- refresh /= (float)(mode->VScan);
- }
- return refresh;
-}
-
/*
* xf86LookupMode
*
@@ -444,7 +414,6 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
int ModePrivFlags = 0;
ModeStatus status = MODE_NOMODE;
Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
- Bool haveBuiltin;
int n;
const int types[] = {
M_T_BUILTIN | M_T_PREFERRED,
@@ -529,7 +498,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
ModePrivFlags = cp->PrivFlags;
break;
}
- refresh = ModeVRefresh(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE)
refresh /= INTERLACE_REFRESH_WEIGHT;
if (refresh > bestRefresh) {
@@ -570,7 +539,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
found = TRUE;
if (strategy == LOOKUP_BEST_REFRESH) {
- refresh = ModeVRefresh(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE)
refresh /= INTERLACE_REFRESH_WEIGHT;
if (refresh > bestRefresh) {
@@ -667,95 +636,6 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
return MODE_OK;
}
-
-/*
- * xf86SetModeCrtc
- *
- * Initialises the Crtc parameters for a mode. The initialisation includes
- * adjustments for interlaced and double scan modes.
- */
-static void
-xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
-{
- if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
- return;
-
- p->CrtcHDisplay = p->HDisplay;
- p->CrtcHSyncStart = p->HSyncStart;
- p->CrtcHSyncEnd = p->HSyncEnd;
- p->CrtcHTotal = p->HTotal;
- p->CrtcHSkew = p->HSkew;
- p->CrtcVDisplay = p->VDisplay;
- p->CrtcVSyncStart = p->VSyncStart;
- p->CrtcVSyncEnd = p->VSyncEnd;
- p->CrtcVTotal = p->VTotal;
- if (p->Flags & V_INTERLACE) {
- if (adjustFlags & INTERLACE_HALVE_V) {
- p->CrtcVDisplay /= 2;
- p->CrtcVSyncStart /= 2;
- p->CrtcVSyncEnd /= 2;
- p->CrtcVTotal /= 2;
- }
- /* Force interlaced modes to have an odd VTotal */
- /* maybe we should only do this when INTERLACE_HALVE_V is set? */
- p->CrtcVTotal |= 1;
- }
-
- if (p->Flags & V_DBLSCAN) {
- p->CrtcVDisplay *= 2;
- p->CrtcVSyncStart *= 2;
- p->CrtcVSyncEnd *= 2;
- p->CrtcVTotal *= 2;
- }
- if (p->VScan > 1) {
- p->CrtcVDisplay *= p->VScan;
- p->CrtcVSyncStart *= p->VScan;
- p->CrtcVSyncEnd *= p->VScan;
- p->CrtcVTotal *= p->VScan;
- }
- p->CrtcHAdjusted = FALSE;
- p->CrtcVAdjusted = FALSE;
-
- /*
- * XXX
- *
- * The following is taken from VGA, but applies to other cores as well.
- */
- p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
- p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
- if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) {
- /*
- * V Blanking size must be < 127.
- * Moving blank start forward is safer than moving blank end
- * back, since monitors clamp just AFTER the sync pulse (or in
- * the sync pulse), but never before.
- */
- p->CrtcVBlankStart = p->CrtcVBlankEnd - 127;
- /*
- * If VBlankStart is now > VSyncStart move VBlankStart
- * to VSyncStart using the maximum width that fits into
- * VTotal.
- */
- if (p->CrtcVBlankStart > p->CrtcVSyncStart) {
- p->CrtcVBlankStart = p->CrtcVSyncStart;
- p->CrtcVBlankEnd = min(p->CrtcHBlankStart + 127, p->CrtcVTotal);
- }
- }
- p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay);
- p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal);
-
- if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) {
- /*
- * H Blanking size must be < 63*8. Same remark as above.
- */
- p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8;
- if (p->CrtcHBlankStart > p->CrtcHSyncStart) {
- p->CrtcHBlankStart = p->CrtcHSyncStart;
- p->CrtcHBlankEnd = min(p->CrtcHBlankStart + 63 * 8, p->CrtcHTotal);
- }
- }
-}
-
/*
* xf86CheckModeForMonitor
*
@@ -789,7 +669,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
if (monitor->nHsync > 0) {
/* Check hsync against the allowed ranges */
- float hsync = ModeHSync(mode);
+ float hsync = xf86ModeHSync(mode);
for (i = 0; i < monitor->nHsync; i++)
if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
(hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -802,7 +682,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
if (monitor->nVrefresh > 0) {
/* Check vrefresh against the allowed ranges */
- float vrefrsh = ModeVRefresh(mode);
+ float vrefrsh = xf86ModeVRefresh(mode);
for (i = 0; i < monitor->nVrefresh; i++)
if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
(vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -1033,8 +913,8 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
/ (mode->CrtcHTotal * mode->CrtcVTotal);
}
- mode->HSync = ModeHSync(mode);
- mode->VRefresh = ModeVRefresh(mode);
+ mode->HSync = xf86ModeHSync(mode);
+ mode->VRefresh = xf86ModeVRefresh(mode);
/* Assume it is OK */
return MODE_OK;
@@ -1195,20 +1075,40 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy)
{
float aspect = 0.0;
MonPtr mon = scrp->monitor;
+ xf86MonPtr DDC;
int x = 0, y = 0;
DisplayModePtr mode;
if (!mon) return 0;
+ DDC = mon->DDC;
+
+ if (DDC && DDC->ver.revision >= 4) {
+ /* For 1.4, we might actually get native pixel format. How novel. */
+ if (PREFERRED_TIMING_MODE(DDC->features.msc)) {
+ for (mode = modes; mode; mode = mode->next) {
+ if (mode->type & (M_T_DRIVER | M_T_PREFERRED)) {
+ x = mode->HDisplay;
+ y = mode->VDisplay;
+ goto found;
+ }
+ }
+ }
+ /*
+ * Even if we don't, we might get aspect ratio from extra CVT info
+ * or from the monitor size fields. TODO.
+ */
+ }
/*
- * technically this triggers if _either_ is zero, which is not what EDID
- * says, but if only one is zero this is best effort. also we don't
- * know that all projectors are 4:3, but we certainly suspect it.
+ * Technically this triggers if either is zero. That wasn't legal
+ * before EDID 1.4, but right now we'll get that wrong. TODO.
*/
- if (!mon->widthmm || !mon->heightmm)
- aspect = 4.0/3.0;
- else
- aspect = (float)mon->widthmm / (float)mon->heightmm;
+ if (!aspect) {
+ if (!mon->widthmm || !mon->heightmm)
+ aspect = 4.0/3.0;
+ else
+ aspect = (float)mon->widthmm / (float)mon->heightmm;
+ }
/* find the largest M_T_DRIVER mode with that aspect ratio */
for (mode = modes; mode; mode = mode->next) {
@@ -1232,6 +1132,7 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy)
return 0;
}
+found:
*vx = x;
*vy = y;
@@ -1408,6 +1309,12 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
scrp->monitor->vrefresh[i].lo,
scrp->monitor->vrefresh[i].hi);
}
+ if (scrp->monitor->maxPixClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using maximum pixel clock of %.2f MHz\n",
+ scrp->monitor->id,
+ (float)scrp->monitor->maxPixClock / 1000.0);
+ }
}
/*
@@ -1572,7 +1479,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
"TargetRefresh", 0.0);
if (targetRefresh > 0.0) {
for (p = scrp->modePool; p != NULL; p = p->next) {
- if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
+ if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
break;
}
if (!p)
@@ -1661,7 +1568,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* If there is a target refresh rate, skip modes that
* don't match up.
*/
- if (ModeVRefresh(q) <
+ if (xf86ModeVRefresh(q) <
(1.0 - SYNC_TOLERANCE) * targetRefresh)
continue;
@@ -1825,7 +1732,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
virtX, virtY, vx, vy);
virtX = vx;
virtY = vy;
- linePitch = miScanLineWidth(vx, vy, linePitch, apertureSize,
+ linePitch = miScanLineWidth(vx, vy, minPitch, apertureSize,
BankFormat, pitchInc);
}
}
@@ -1973,6 +1880,7 @@ xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)
}
+#if 0
static void
add(char **p, char *new)
{
@@ -1981,8 +1889,8 @@ add(char **p, char *new)
strcat(*p, new);
}
-static void
-PrintModeline(int scrnIndex,DisplayModePtr mode)
+_X_EXPORT void
+xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
{
char tmp[256];
char *flags = xnfcalloc(1, 1);
@@ -2016,6 +1924,7 @@ PrintModeline(int scrnIndex,DisplayModePtr mode)
mode->VTotal, flags);
xfree(flags);
}
+#endif
_X_EXPORT void
xf86PrintModes(ScrnInfoPtr scrp)
@@ -2037,8 +1946,8 @@ xf86PrintModes(ScrnInfoPtr scrp)
do {
desc = desc2 = "";
- hsync = ModeHSync(p);
- refresh = ModeVRefresh(p);
+ hsync = xf86ModeHSync(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE) {
desc = " (I)";
}
@@ -2081,7 +1990,33 @@ xf86PrintModes(ScrnInfoPtr scrp)
p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
}
if (hsync != 0 && refresh != 0)
- PrintModeline(scrp->scrnIndex,p);
+ xf86PrintModeline(scrp->scrnIndex,p);
p = p->next;
} while (p != NULL && p != scrp->modes);
}
+
+#if 0
+/**
+ * Adds the new mode into the mode list, and returns the new list
+ *
+ * \param modes doubly-linked mode list.
+ */
+_X_EXPORT DisplayModePtr
+xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
+{
+ if (modes == NULL)
+ return new;
+
+ if (new) {
+ DisplayModePtr mode = modes;
+
+ while (mode->next)
+ mode = mode->next;
+
+ mode->next = new;
+ new->prev = mode;
+ }
+
+ return modes;
+}
+#endif
diff --git a/xserver/hw/xfree86/common/xf86Module.h b/xserver/hw/xfree86/common/xf86Module.h
index f54be49e6..5ce6e8a26 100644
--- a/xserver/hw/xfree86/common/xf86Module.h
+++ b/xserver/hw/xfree86/common/xf86Module.h
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1997-2003 by The XFree86 Project, Inc.
*
@@ -83,21 +82,17 @@ typedef enum {
* changed. The minor revision mask is 0x0000FFFF and the major revision
* mask is 0xFFFF0000.
*/
-#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 3)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(1, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 6)
-#define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 3)
-#define ABI_FONT_VERSION SET_ABI_VERSION(0, 5)
+#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(4, 1)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(2, 1)
+#define ABI_EXTENSION_VERSION SET_ABI_VERSION(1, 1)
+#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
#define MODINFOSTRING1 0xef23fdc5
#define MODINFOSTRING2 0x10dc023a
#ifndef MODULEVENDORSTRING
-#ifndef __OS2ELF__
#define MODULEVENDORSTRING "X.Org Foundation"
-#else
-#define MODULEVENDORSTRING "X.Org Foundation - OS2"
-#endif
#endif
/* Error return codes for errmaj. New codes must only be added at the end. */
diff --git a/xserver/hw/xfree86/common/xf86PM.c b/xserver/hw/xfree86/common/xf86PM.c
index ac8896879..7c8320dee 100644
--- a/xserver/hw/xfree86/common/xf86PM.c
+++ b/xserver/hw/xfree86/common/xf86PM.c
@@ -74,13 +74,11 @@ suspend (pmEvent event, Bool undo)
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
}
-#if !defined(__EMX__)
pInfo = xf86InputDevs;
while (pInfo) {
DisableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif
xf86EnterServerState(SETUP);
for (i = 0; i < xf86NumScreens; i++) {
xf86EnableAccess(xf86Screens[i]);
@@ -118,14 +116,12 @@ resume(pmEvent event, Bool undo)
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
-#if !defined(__EMX__)
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif
xf86inSuspend = FALSE;
}
diff --git a/xserver/hw/xfree86/common/xf86PciInfo.h b/xserver/hw/xfree86/common/xf86PciInfo.h
index b8ba73f6a..356c7db4d 100644
--- a/xserver/hw/xfree86/common/xf86PciInfo.h
+++ b/xserver/hw/xfree86/common/xf86PciInfo.h
@@ -40,9 +40,8 @@
* or for non-video devices unless they're needed by a driver or elsewhere.
* A comprehensive set of PCI vendor, device and subsystem data is
* auto-generated from the ../etc/pci.ids file using the pciids2c.pl script,
- * and is used in both the scanpci module and the scanpci utility. Don't
- * modify the pci.ids file. If new/corrected entries are required, add them
- * to ../etc/extrapci.ids.
+ * and is used in scanpci utility. Don't modify the pci.ids file. If
+ * new/corrected entries are required, add them to ../etc/extrapci.ids.
*/
#ifndef _XF86_PCIINFO_H
@@ -92,6 +91,7 @@
#define PCI_VENDOR_TRITECH 0x1292
#define PCI_VENDOR_NVIDIA_SGS 0x12D2
#define PCI_VENDOR_VMWARE 0x15AD
+#define PCI_VENDOR_AST 0x1A03
#define PCI_VENDOR_3DLABS 0x3D3D
#define PCI_VENDOR_AVANCE_2 0x4005
#define PCI_VENDOR_HERCULES 0x4843
@@ -358,6 +358,9 @@
#define PCI_CHIP_RS350_7834 0x7834
#define PCI_CHIP_RS350_7835 0x7835
+/* ASPEED Technology (AST) */
+#define PCI_CHIP_AST2000 0x2000
+
/* Avance Logic */
#define PCI_CHIP_ALG2064 0x2064
#define PCI_CHIP_ALG2301 0x2301
diff --git a/xserver/hw/xfree86/common/xf86Priv.h b/xserver/hw/xfree86/common/xf86Priv.h
index 5a3cba38f..c0d240dd5 100644
--- a/xserver/hw/xfree86/common/xf86Priv.h
+++ b/xserver/hw/xfree86/common/xf86Priv.h
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1997-2002 by The XFree86 Project, Inc.
*
@@ -36,6 +35,8 @@
#ifndef _XF86PRIV_H
#define _XF86PRIV_H
+#include <pciaccess.h>
+
#include "xf86Privstr.h"
#include "propertyst.h"
@@ -76,7 +77,7 @@ extern Bool xf86BestRefresh;
extern Gamma xf86Gamma;
extern char *xf86ServerName;
extern Bool xf86ShowUnresolved;
-extern PciBusId xf86IsolateDevice;
+extern struct pci_slot_match xf86IsolateDevice;
/* Other parameters */
@@ -95,13 +96,10 @@ extern Bool xf86SupportedMouseTypes[];
extern int xf86NumMouseTypes;
extern DriverPtr *xf86DriverList;
-extern ModuleInfoPtr *xf86ModuleInfoList;
-extern int xf86NumModuleInfos;
extern int xf86NumDrivers;
extern Bool xf86Resetting;
extern Bool xf86Initialising;
extern int xf86NumScreens;
-extern pciVideoPtr *xf86PciVideoInfo;
extern xf86CurrentAccessRec xf86CurrentAccess;
extern const char *xf86VisualNames[];
extern int xf86Verbose; /* verbosity level */
@@ -148,9 +146,6 @@ void xf86ClearEntityListForScreen(int scrnIndex);
void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
extern void xf86PostPreInit(void);
extern void xf86PostScreenInit(void);
-extern memType getValidBIOSBase(PCITAG tag, int num);
-extern memType getEmptyPciRange(PCITAG tag, int base_reg);
-extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag);
/* xf86Config.c */
@@ -158,11 +153,8 @@ Bool xf86PathIsSafe(const char *path);
/* xf86DefaultModes */
-extern DisplayModeRec xf86DefaultModes [];
-
-/* xf86DoScanPci.c */
-
-void DoScanPci(int argc, char **argv, int i);
+extern const DisplayModeRec xf86DefaultModes[];
+extern const int xf86NumDefaultModes;
/* xf86DoProbe.c */
void DoProbe(void);
@@ -187,6 +179,7 @@ void xf86CloseLog(void);
Bool xf86LoadModules(char **list, pointer *optlist);
int xf86SetVerbosity(int verb);
int xf86SetLogVerbosity(int verb);
+Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
/* xf86Lock.c */
diff --git a/xserver/hw/xfree86/common/xf86Privstr.h b/xserver/hw/xfree86/common/xf86Privstr.h
index 67d4304c9..8cab56ec8 100644
--- a/xserver/hw/xfree86/common/xf86Privstr.h
+++ b/xserver/hw/xfree86/common/xf86Privstr.h
@@ -60,6 +60,12 @@ typedef enum {
SKAlways
} SpecialKeysInDDX;
+typedef enum {
+ XF86_GlxVisualsMinimal,
+ XF86_GlxVisualsTypical,
+ XF86_GlxVisualsAll,
+} XF86_GlxVisuals;
+
/*
* xf86InfoRec contains global parameters which the video drivers never
* need to access. Global parameters which the video drivers do need
@@ -67,38 +73,10 @@ typedef enum {
*/
typedef struct {
-
- /* keyboard part */
- DeviceIntPtr pKeyboard;
- DeviceProc kbdProc; /* procedure for initializing */
- void (* kbdEvents)(void); /* proc for processing events */
int consoleFd;
- int kbdFd;
int vtno;
- int kbdType; /* AT84 / AT101 */
- int kbdRate;
- int kbdDelay;
- int bell_pitch;
- int bell_duration;
- Bool autoRepeat;
- unsigned long leds;
- unsigned long xleds;
- char * vtinit;
- int scanPrefix; /* scancode-state */
- Bool capsLock;
- Bool numLock;
- Bool scrollLock;
- Bool modeSwitchLock;
- Bool composeLock;
Bool vtSysreq;
SpecialKeysInDDX ddxSpecialKeys;
- Bool ActionKeyBindingsSet;
-#if defined(SVR4) && defined(i386)
- Bool panix106;
-#endif /* SVR4 && i386 */
-#if defined(__OpenBSD__) || defined(__NetBSD__)
- int wsKbdType;
-#endif
/* mouse part */
DeviceIntPtr pMouse;
@@ -125,25 +103,6 @@ typedef struct {
int consType; /* Which console driver? */
#endif
-#ifdef XKB
- /*
- * would like to use an XkbComponentNamesRec here but can't without
- * pulling in a bunch of header files. :-(
- */
- char * xkbkeymap;
- char * xkbkeycodes;
- char * xkbtypes;
- char * xkbcompat;
- char * xkbsymbols;
- char * xkbgeometry;
- Bool xkbcomponents_specified;
- char * xkbrules;
- char * xkbmodel;
- char * xkblayout;
- char * xkbvariant;
- char * xkboptions;
-#endif
-
/* Other things */
Bool allowMouseOpenFail;
Bool vidModeEnabled; /* VidMode extension enabled */
@@ -155,7 +114,7 @@ typedef struct {
PciProbeType pciFlags;
Pix24Flags pixmap24;
MessageType pix24From;
-#if defined(i386) || defined(__i386__)
+#ifdef __i386__
Bool pc98;
#endif
Bool pmFlag;
@@ -166,6 +125,11 @@ typedef struct {
MessageType randRFrom;
Bool aiglx;
MessageType aiglxFrom;
+ XF86_GlxVisuals glxVisuals;
+ MessageType glxVisualsFrom;
+
+ Bool useDefaultFontPath;
+ MessageType useDefaultFontPathFrom;
Bool ignoreABI;
struct {
Bool disabled; /* enable/disable deactivating
@@ -179,6 +143,15 @@ typedef struct {
Bool allowClosedown;
ServerGrabInfoRec server;
} grabInfo;
+
+ Bool allowEmptyInput; /* Allow the server to start with no input
+ * devices. */
+ Bool autoAddDevices; /* Whether to succeed NIDR, or ignore. */
+ Bool autoEnableDevices; /* Whether to enable, or let the client
+ * control. */
+
+ Bool dri2;
+ MessageType dri2From;
} xf86InfoRec, *xf86InfoPtr;
#ifdef DPMSExtension
diff --git a/xserver/hw/xfree86/common/xf86RandR.c b/xserver/hw/xfree86/common/xf86RandR.c
index 288d72193..a55b93d4c 100644
--- a/xserver/hw/xfree86/common/xf86RandR.c
+++ b/xserver/hw/xfree86/common/xf86RandR.c
@@ -45,16 +45,17 @@ typedef struct _xf86RandRInfo {
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
-static int xf86RandRIndex = -1;
-static int xf86RandRGeneration;
+static DevPrivateKey xf86RandRKey = NULL;
-#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr)
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
static int
xf86RandRModeRefresh (DisplayModePtr mode)
{
if (mode->VRefresh)
return (int) (mode->VRefresh + 0.5);
+ else if (mode->Clock == 0)
+ return 0;
else
return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
}
@@ -171,6 +172,25 @@ xf86RandRSetMode (ScreenPtr pScreen,
scrp->virtualX = mode->HDisplay;
scrp->virtualY = mode->VDisplay;
}
+
+ /*
+ * The DIX forgets the physical dimensions we passed into RRRegisterSize, so
+ * reconstruct them if possible.
+ */
+ if(scrp->DriverFunc) {
+ xorgRRModeMM RRModeMM;
+
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = scrp->virtualX;
+ RRModeMM.virtY = scrp->virtualY;
+ RRModeMM.mmWidth = mmWidth;
+ RRModeMM.mmHeight = mmHeight;
+
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+
+ mmWidth = RRModeMM.mmWidth;
+ mmHeight = RRModeMM.mmHeight;
+ }
if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
{
/* If the screen is rotated 90 or 270 degrees, swap the sizes. */
@@ -338,14 +358,14 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen)
scrp->currentMode = scrp->modes;
pScreen->CloseScreen = randrp->CloseScreen;
xfree (randrp);
- pScreen->devPrivates[xf86RandRIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
return (*pScreen->CloseScreen) (index, pScreen);
}
_X_EXPORT Rotation
xf86GetRotation(ScreenPtr pScreen)
{
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return RR_Rotate_0;
return XF86RANDRINFO(pScreen)->rotation;
@@ -359,7 +379,7 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
{
XF86RandRInfoPtr randrp;
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return FALSE;
randrp = XF86RANDRINFO(pScreen);
@@ -401,11 +421,8 @@ xf86RandRInit (ScreenPtr pScreen)
if (!noPanoramiXExtension)
return TRUE;
#endif
- if (xf86RandRGeneration != serverGeneration)
- {
- xf86RandRIndex = AllocateScreenPrivateIndex();
- xf86RandRGeneration = serverGeneration;
- }
+
+ xf86RandRKey = &xf86RandRKey;
randrp = xalloc (sizeof (XF86RandRInfoRec));
if (!randrp)
@@ -433,7 +450,7 @@ xf86RandRInit (ScreenPtr pScreen)
randrp->rotation = RR_Rotate_0;
- pScreen->devPrivates[xf86RandRIndex].ptr = randrp;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
return TRUE;
}
diff --git a/xserver/hw/xfree86/common/xf86Resources.h b/xserver/hw/xfree86/common/xf86Resources.h
index 97bf817fe..15bd32c69 100644
--- a/xserver/hw/xfree86/common/xf86Resources.h
+++ b/xserver/hw/xfree86/common/xf86Resources.h
@@ -133,7 +133,5 @@ extern resRange res8514Shared[];
{ResExcIoSparse | ResBus, 0x0200, 0x0200},\
{ResExcMemBlock | ResBus, 0xA0000,0xFFFFF}
-extern resRange PciAvoid[];
-
#define RES_UNDEFINED NULL
#endif
diff --git a/xserver/hw/xfree86/common/xf86VidMode.c b/xserver/hw/xfree86/common/xf86VidMode.c
index fb9151346..9260bb57b 100644
--- a/xserver/hw/xfree86/common/xf86VidMode.c
+++ b/xserver/hw/xfree86/common/xf86VidMode.c
@@ -47,12 +47,11 @@
#include "vidmodeproc.h"
#include "xf86cmap.h"
-static int VidModeGeneration = 0;
-static int VidModeIndex = -1;
+static DevPrivateKey VidModeKey = NULL;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
-#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr)
+#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey))
#endif
@@ -68,22 +67,15 @@ VidModeExtensionInit(ScreenPtr pScreen)
#ifdef XF86VIDMODE
VidModePtr pVidMode;
- DEBUG_P("VidModeExtensionInit");
-
if (!xf86GetVidModeEnabled()) {
DEBUG_P("!xf86GetVidModeEnabled()");
return FALSE;
}
- if (serverGeneration != VidModeGeneration) {
- if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) {
- DEBUG_P("AllocateScreenPrivateIndex() failed");
- return FALSE;
- }
- VidModeGeneration = serverGeneration;
- }
+ VidModeKey = &VidModeKey;
- if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) {
+ if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
+ xcalloc(sizeof(VidModeRec), 1))) {
DEBUG_P("xcalloc failed");
return FALSE;
}
@@ -109,8 +101,6 @@ VidModeClose(int i, ScreenPtr pScreen)
{
VidModePtr pVidMode = VMPTR(pScreen);
- DEBUG_P("VidModeClose");
-
/* This shouldn't happen */
if (!pVidMode)
return FALSE;
@@ -118,10 +108,9 @@ VidModeClose(int i, ScreenPtr pScreen)
pScreen->CloseScreen = pVidMode->CloseScreen;
if (--VidModeCount == 0) {
- if (pScreen->devPrivates[VidModeIndex].ptr)
- xfree(pScreen->devPrivates[VidModeIndex].ptr);
- pScreen->devPrivates[VidModeIndex].ptr = NULL;
- VidModeIndex = -1;
+ xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
+ VidModeKey = NULL;
}
return pScreen->CloseScreen(i, pScreen);
}
@@ -132,10 +121,8 @@ VidModeAvailable(int scrnIndex)
ScrnInfoPtr pScrn;
VidModePtr pVidMode;
- DEBUG_P("VidModeAvailable");
-
- if (VidModeIndex < 0) {
- DEBUG_P("VidModeIndex < 0");
+ if (VidModeKey == NULL) {
+ DEBUG_P("VidModeKey == NULL");
return FALSE;
}
@@ -159,16 +146,18 @@ VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetCurrentModeline");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
pScrn = xf86Screens[scrnIndex];
- *mode = (pointer)(pScrn->currentMode);
- *dotClock = pScrn->currentMode->Clock;
- return TRUE;
+ if (pScrn->currentMode) {
+ *mode = (pointer)(pScrn->currentMode);
+ *dotClock = pScrn->currentMode->Clock;
+
+ return TRUE;
+ }
+ return FALSE;
}
_X_EXPORT int
@@ -176,8 +165,6 @@ VidModeGetDotClock(int scrnIndex, int Clock)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetDotClock");
-
if (!VidModeAvailable(scrnIndex))
return 0;
@@ -193,8 +180,6 @@ VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetNumOfClocks");
-
if (!VidModeAvailable(scrnIndex))
return 0;
@@ -214,8 +199,6 @@ VidModeGetClocks(int scrnIndex, int *Clocks)
ScrnInfoPtr pScrn;
int i;
- DEBUG_P("VidModeGetClocks");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -237,8 +220,6 @@ VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
ScrnInfoPtr pScrn;
VidModePtr pVidMode;
- DEBUG_P("VidModeGetFirstModeline");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -263,8 +244,6 @@ VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock)
VidModePtr pVidMode;
DisplayModePtr p;
- DEBUG_P("VidModeGetNextModeline");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -288,8 +267,6 @@ VidModeDeleteModeline(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeDeleteModeline");
-
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
return FALSE;
@@ -303,8 +280,6 @@ VidModeZoomViewport(int scrnIndex, int zoom)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeZoomViewPort");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -318,8 +293,6 @@ VidModeSetViewPort(int scrnIndex, int x, int y)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeSetViewPort");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -341,8 +314,6 @@ VidModeGetViewPort(int scrnIndex, int *x, int *y)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetViewPort");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -359,8 +330,6 @@ VidModeSwitchMode(int scrnIndex, pointer mode)
DisplayModePtr pTmpMode;
Bool retval;
- DEBUG_P("VidModeSwitchMode");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -381,8 +350,6 @@ VidModeLockZoom(int scrnIndex, Bool lock)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeLockZoom");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -400,8 +367,6 @@ VidModeGetMonitor(int scrnIndex, pointer *monitor)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetMonitor");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -416,8 +381,6 @@ VidModeCheckModeForMonitor(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeCheckModeForMonitor");
-
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
return MODE_ERROR;
@@ -431,8 +394,6 @@ VidModeCheckModeForDriver(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeCheckModeForDriver");
-
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
return MODE_ERROR;
@@ -447,8 +408,6 @@ VidModeSetCrtcForMode(int scrnIndex, pointer mode)
ScrnInfoPtr pScrn;
DisplayModePtr ScreenModes;
- DEBUG_P("VidModeSetCrtcForMode");
-
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
return;
@@ -467,8 +426,6 @@ VidModeAddModeline(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeAddModeline");
-
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
return FALSE;
@@ -491,8 +448,6 @@ VidModeGetNumOfModes(int scrnIndex)
pointer mode = NULL;
int dotClock= 0, nummodes = 0;
- DEBUG_P("VidModeGetNumOfModes");
-
if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
return nummodes;
@@ -509,8 +464,6 @@ VidModeSetGamma(int scrnIndex, float red, float green, float blue)
ScrnInfoPtr pScrn;
Gamma gamma;
- DEBUG_P("VidModeSetGamma");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
@@ -529,8 +482,6 @@ VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
{
ScrnInfoPtr pScrn;
- DEBUG_P("VidModeGetGamma");
-
if (!VidModeAvailable(scrnIndex))
return FALSE;
diff --git a/xserver/hw/xfree86/common/xf86Xinput.c b/xserver/hw/xfree86/common/xf86Xinput.c
index 36a408e12..710e787fd 100644
--- a/xserver/hw/xfree86/common/xf86Xinput.c
+++ b/xserver/hw/xfree86/common/xf86Xinput.c
@@ -77,7 +77,6 @@
#define EXTENSION_PROC_ARGS void *
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "windowstr.h" /* screenIsSaved */
@@ -447,20 +446,38 @@ void
DeleteInputDeviceRequest(DeviceIntPtr pDev)
{
LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
- InputDriverPtr drv = pInfo->drv;
- IDevRec *idev = pInfo->conf_idev;
+ InputDriverPtr drv;
+ IDevRec *idev;
+ BOOL found;
+ IDevPtr *it;
+ if (pInfo) /* need to get these before RemoveDevice */
+ {
+ drv = pInfo->drv;
+ idev = pInfo->conf_idev;
+ }
RemoveDevice(pDev);
+ if (!pInfo) /* VCP and VCK */
+ return;
+
if(drv->UnInit)
drv->UnInit(drv, pInfo, 0);
else
xf86DeleteInput(pInfo, 0);
- xfree(idev->driver);
- xfree(idev->identifier);
- xf86optionListFree(idev->commonOptions);
- xfree(idev);
+ /* devices added through HAL aren't in the config layout */
+ it = xf86ConfigLayout.inputs;
+ while(*it && *it != idev)
+ it++;
+
+ if (!(*it)) /* end of list, not in the layout */
+ {
+ xfree(idev->driver);
+ xfree(idev->identifier);
+ xf86optionListFree(idev->commonOptions);
+ xfree(idev);
+ }
}
/*
@@ -508,6 +525,12 @@ xf86PostMotionEventP(DeviceIntPtr device,
int index;
int flags = 0;
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
+
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -645,6 +668,12 @@ xf86PostKeyEvent(DeviceIntPtr device,
"badly south after this message, then xf86PostKeyEvent is "
"broken.\n");
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
+
if (!xf86Events)
FatalError("Didn't allocate event store\n");
diff --git a/xserver/hw/xfree86/common/xf86cmap.c b/xserver/hw/xfree86/common/xf86cmap.c
index ea6a26dcd..764647ee4 100644
--- a/xserver/hw/xfree86/common/xf86cmap.c
+++ b/xserver/hw/xfree86/common/xf86cmap.c
@@ -60,7 +60,7 @@
#include "xf86cmap.h"
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
- ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field)
+ ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@@ -102,9 +102,8 @@ typedef struct {
int overscan;
} CMapColormapRec, *CMapColormapPtr;
-static unsigned long CMapGeneration = 0;
-static int CMapScreenIndex = -1;
-static int CMapColormapIndex = -1;
+static DevPrivateKey CMapScreenKey = NULL;
+static DevPrivateKey CMapColormapKey = &CMapColormapKey;
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@@ -119,7 +118,6 @@ static int CMapChangeGamma(int, Gamma);
static void ComputeGamma(CMapScreenPtr);
static Bool CMapAllocateColormapPrivate(ColormapPtr);
-static Bool CMapInitDefMap(ColormapPtr,int);
static void CMapRefreshColors(ColormapPtr, int, int*);
static void CMapSetOverscan(ColormapPtr, int, int *);
static void CMapReinstallMap(ColormapPtr);
@@ -145,13 +143,7 @@ _X_EXPORT Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
- if(CMapGeneration != serverGeneration) {
- if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((CMapColormapIndex = AllocateColormapPrivateIndex(
- CMapInitDefMap)) < 0))
- return FALSE;
- CMapGeneration = serverGeneration;
- }
+ CMapScreenKey = &CMapScreenKey;
elements = 1 << sigRGBbits;
@@ -169,7 +161,7 @@ _X_EXPORT Bool xf86HandleColormaps(
return FALSE;
}
- pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@@ -225,12 +217,6 @@ _X_EXPORT Bool xf86HandleColormaps(
return TRUE;
}
-static Bool
-CMapInitDefMap(ColormapPtr cmap, int index)
-{
- return TRUE;
-}
-
/**** Screen functions ****/
@@ -254,8 +240,8 @@ CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
static Bool
CMapAllocateColormapPrivate(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
CMapColormapPtr pColPriv;
CMapLinkPtr pLink;
int numColors;
@@ -274,7 +260,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
return FALSE;
}
- pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv;
+ dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
pColPriv->numColors = numColors;
pColPriv->colors = colors;
@@ -296,8 +282,8 @@ static Bool
CMapCreateColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
Bool ret = FALSE;
pScreen->CreateColormap = pScreenPriv->CreateColormap;
@@ -314,10 +300,10 @@ static void
CMapDestroyColormap (ColormapPtr cmap)
{
ScreenPtr pScreen = cmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &cmap->devPrivates, CMapColormapKey);
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
@@ -356,8 +342,8 @@ CMapStoreColors(
){
ScreenPtr pScreen = pmap->pScreen;
VisualPtr pVisual = pmap->pVisual;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int *indices = pScreenPriv->PreAllocIndices;
int num = ndef;
@@ -373,8 +359,8 @@ CMapStoreColors(
return;
if(pVisual->class == DirectColor) {
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
int i;
if (CMapColormapUseMax(pVisual, pScreenPriv)) {
@@ -431,8 +417,8 @@ CMapInstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
int index = pScreen->myNum;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if (pmap == miInstalledMaps[index])
return;
@@ -462,8 +448,8 @@ static Bool
CMapEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->EnterVT)(index, flags)) {
if(miInstalledMaps[index])
@@ -478,8 +464,8 @@ static Bool
CMapSwitchMode(int index, DisplayModePtr mode, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
if(miInstalledMaps[index])
@@ -494,8 +480,8 @@ static int
CMapSetDGAMode(int index, int num, DGADevicePtr dev)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int ret;
ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
@@ -516,10 +502,10 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
static void
CMapReinstallMap(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr cmapPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int i = cmapPriv->numColors;
int *indices = pScreenPriv->PreAllocIndices;
@@ -547,10 +533,10 @@ CMapReinstallMap(ColormapPtr pmap)
static void
CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
VisualPtr pVisual = pmap->pVisual;
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int numColors, i;
@@ -681,10 +667,10 @@ CMapCompareColors(LOCO *color1, LOCO *color2)
static void
CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
VisualPtr pVisual = pmap->pVisual;
int i;
@@ -819,8 +805,8 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
static void
CMapUnwrapScreen(ScreenPtr pScreen)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
pScreen->CloseScreen = pScreenPriv->CloseScreen;
@@ -904,10 +890,11 @@ CMapChangeGamma(
CMapLinkPtr pLink;
/* Is this sufficient checking ? */
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -925,8 +912,8 @@ CMapChangeGamma(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -997,10 +984,11 @@ xf86ChangeGammaRamp(
CMapScreenPtr pScreenPriv;
CMapLinkPtr pLink;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -1012,8 +1000,8 @@ xf86ChangeGammaRamp(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -1056,9 +1044,10 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
{
CMapScreenPtr pScreenPriv;
- if(CMapScreenIndex == -1) return 0;
+ if(CMapScreenKey == NULL) return 0;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv) return 0;
return pScreenPriv->gammaElements;
@@ -1076,10 +1065,11 @@ xf86GetGammaRamp(
LOCO *entry;
int shift, sigbits;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
diff --git a/xserver/hw/xfree86/common/xf86cvt.c b/xserver/hw/xfree86/common/xf86cvt.c
deleted file mode 100644
index dfb6e71e4..000000000
--- a/xserver/hw/xfree86/common/xf86cvt.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright 2005-2006 Luc Verhaegen.
- *
- * 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:
- *
- * 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
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- */
-
-/*
- * The reason for having this function in a file of its own is
- * so that ../utils/cvt/cvt can link to it, and that xf86CVTMode
- * code is shared directly.
- */
-
-#include "xf86.h"
-
-/*
- * Generate a CVT standard mode from HDisplay, VDisplay and VRefresh.
- *
- * These calculations are stolen from the CVT calculation spreadsheet written
- * by Graham Loveridge. He seems to be claiming no copyright and there seems to
- * be no license attached to this. He apparently just wants to see his name
- * mentioned.
- *
- * This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls
- *
- * Comments and structure corresponds to the comments and structure of the xls.
- * This should ease importing of future changes to the standard (not very
- * likely though).
- *
- * About margins; i'm sure that they are to be the bit between HDisplay and
- * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and
- * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking
- * outside sync "margin" for some reason. Since we prefer seeing proper
- * blanking instead of the overscan colour, and since the Crtc* values will
- * probably get altered after us, we will disable margins altogether. With
- * these calculations, Margins will plainly expand H/VDisplay, and we don't
- * want that. -- libv
- *
- */
-_X_EXPORT DisplayModePtr
-xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Interlaced)
-{
- DisplayModeRec *Mode = xnfalloc(sizeof(DisplayModeRec));
-
- /* 1) top/bottom margin size (% of height) - default: 1.8 */
-#define CVT_MARGIN_PERCENTAGE 1.8
-
- /* 2) character cell horizontal granularity (pixels) - default 8 */
-#define CVT_H_GRANULARITY 8
-
- /* 4) Minimum vertical porch (lines) - default 3 */
-#define CVT_MIN_V_PORCH 3
-
- /* 4) Minimum number of vertical back porch lines - default 6 */
-#define CVT_MIN_V_BPORCH 6
-
- /* Pixel Clock step (kHz) */
-#define CVT_CLOCK_STEP 250
-
- Bool Margins = FALSE;
- float VFieldRate, HPeriod;
- int HDisplayRnd, HMargin;
- int VDisplayRnd, VMargin, VSync;
- float Interlace; /* Please rename this */
-
- memset(Mode, 0, sizeof(DisplayModeRec));
-
- /* CVT default is 60.0Hz */
- if (!VRefresh)
- VRefresh = 60.0;
-
- /* 1. Required field rate */
- if (Interlaced)
- VFieldRate = VRefresh * 2;
- else
- VFieldRate = VRefresh;
-
- /* 2. Horizontal pixels */
- HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY);
-
- /* 3. Determine left and right borders */
- if (Margins) {
- /* right margin is actually exactly the same as left */
- HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
- HMargin -= HMargin % CVT_H_GRANULARITY;
- } else
- HMargin = 0;
-
- /* 4. Find total active pixels */
- Mode->HDisplay = HDisplayRnd + 2*HMargin;
-
- /* 5. Find number of lines per field */
- if (Interlaced)
- VDisplayRnd = VDisplay / 2;
- else
- VDisplayRnd = VDisplay;
-
- /* 6. Find top and bottom margins */
- /* nope. */
- if (Margins)
- /* top and bottom margins are equal again. */
- VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
- else
- VMargin = 0;
-
- Mode->VDisplay = VDisplay + 2*VMargin;
-
- /* 7. Interlace */
- if (Interlaced)
- Interlace = 0.5;
- else
- Interlace = 0.0;
-
- /* Determine VSync Width from aspect ratio */
- if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay))
- VSync = 4;
- else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay))
- VSync = 5;
- else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay))
- VSync = 6;
- else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay))
- VSync = 7;
- else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))
- VSync = 7;
- else /* Custom */
- VSync = 10;
-
- if (!Reduced) { /* simplified GTF calculation */
-
- /* 4) Minimum time of vertical sync + back porch interval (µs)
- * default 550.0 */
-#define CVT_MIN_VSYNC_BP 550.0
-
- /* 3) Nominal HSync width (% of line period) - default 8 */
-#define CVT_HSYNC_PERCENTAGE 8
-
- float HBlankPercentage;
- int VSyncAndBackPorch, VBackPorch;
- int HBlank;
-
- /* 8. Estimated Horizontal period */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
- (VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace);
-
- /* 9. Find number of lines in sync + backporch */
- if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH))
- VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH;
- else
- VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1;
-
- /* 10. Find number of lines in back porch */
- VBackPorch = VSyncAndBackPorch - VSync;
-
- /* 11. Find total number of lines in vertical field */
- Mode->VTotal = VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace
- + CVT_MIN_V_PORCH;
-
- /* 5) Definition of Horizontal blanking time limitation */
- /* Gradient (%/kHz) - default 600 */
-#define CVT_M_FACTOR 600
-
- /* Offset (%) - default 40 */
-#define CVT_C_FACTOR 40
-
- /* Blanking time scaling factor - default 128 */
-#define CVT_K_FACTOR 128
-
- /* Scaling factor weighting - default 20 */
-#define CVT_J_FACTOR 20
-
-#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256
-#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
- CVT_J_FACTOR
-
- /* 12. Find ideal blanking duty cycle from formula */
- HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0;
-
- /* 13. Blanking time */
- if (HBlankPercentage < 20)
- HBlankPercentage = 20;
-
- HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage);
- HBlank -= HBlank % (2*CVT_H_GRANULARITY);
-
- /* 14. Find total number of pixels in a line. */
- Mode->HTotal = Mode->HDisplay + HBlank;
-
- /* Fill in HSync values */
- Mode->HSyncEnd = Mode->HDisplay + HBlank / 2;
-
- Mode->HSyncStart = Mode->HSyncEnd -
- (Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100;
- Mode->HSyncStart += CVT_H_GRANULARITY -
- Mode->HSyncStart % CVT_H_GRANULARITY;
-
- /* Fill in VSync values */
- Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH;
- Mode->VSyncEnd = Mode->VSyncStart + VSync;
-
- } else { /* Reduced blanking */
- /* Minimum vertical blanking interval time (µs) - default 460 */
-#define CVT_RB_MIN_VBLANK 460.0
-
- /* Fixed number of clocks for horizontal sync */
-#define CVT_RB_H_SYNC 32.0
-
- /* Fixed number of clocks for horizontal blanking */
-#define CVT_RB_H_BLANK 160.0
-
- /* Fixed number of lines for vertical front porch - default 3 */
-#define CVT_RB_VFPORCH 3
-
- int VBILines;
-
- /* 8. Estimate Horizontal period. */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
- (VDisplayRnd + 2*VMargin);
-
- /* 9. Find number of lines in vertical blanking */
- VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1;
-
- /* 10. Check if vertical blanking is sufficient */
- if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH))
- VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH;
-
- /* 11. Find total number of lines in vertical field */
- Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines;
-
- /* 12. Find total number of pixels in a line */
- Mode->HTotal = Mode->HDisplay + CVT_RB_H_BLANK;
-
- /* Fill in HSync values */
- Mode->HSyncEnd = Mode->HDisplay + CVT_RB_H_BLANK / 2;
- Mode->HSyncStart = Mode->HSyncEnd - CVT_RB_H_SYNC;
-
- /* Fill in VSync values */
- Mode->VSyncStart = Mode->VDisplay + CVT_RB_VFPORCH;
- Mode->VSyncEnd = Mode->VSyncStart + VSync;
- }
-
- /* 15/13. Find pixel clock frequency (kHz for xf86) */
- Mode->Clock = Mode->HTotal * 1000.0 / HPeriod;
- Mode->Clock -= Mode->Clock % CVT_CLOCK_STEP;
-
- /* 16/14. Find actual Horizontal Frequency (kHz) */
- Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal);
-
- /* 17/15. Find actual Field rate */
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
- ((float) (Mode->HTotal * Mode->VTotal));
-
- /* 18/16. Find actual vertical frame frequency */
- /* ignore - just set the mode flag for interlaced */
- if (Interlaced)
- Mode->VTotal *= 2;
-
- {
- char Name[256];
- Name[0] = 0;
-
- snprintf(Name, 256, "%dx%d", HDisplay, VDisplay);
-
- Mode->name = xnfalloc(strlen(Name) + 1);
- memcpy(Mode->name, Name, strlen(Name) + 1);
- }
-
- if (Reduced)
- Mode->Flags |= V_PHSYNC | V_NVSYNC;
- else
- Mode->Flags |= V_NHSYNC | V_PVSYNC;
-
- if (Interlaced)
- Mode->Flags |= V_INTERLACE;
-
- return Mode;
-}
diff --git a/xserver/hw/xfree86/common/xf86fbman.c b/xserver/hw/xfree86/common/xf86fbman.c
index 8141a8373..9fd2e6c70 100644
--- a/xserver/hw/xfree86/common/xf86fbman.c
+++ b/xserver/hw/xfree86/common/xf86fbman.c
@@ -42,21 +42,15 @@
#define DEBUG
*/
-static int xf86FBMangerIndex = -1;
-static unsigned long xf86ManagerGeneration = 0;
+static DevPrivateKey xf86FBManagerKey = NULL;
_X_EXPORT Bool xf86RegisterOffscreenManager(
ScreenPtr pScreen,
FBManagerFuncsPtr funcs
){
- if(xf86ManagerGeneration != serverGeneration) {
- if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86ManagerGeneration = serverGeneration;
- }
-
- pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs;
+ xf86FBManagerKey = &xf86FBManagerKey;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
}
@@ -65,9 +59,9 @@ _X_EXPORT Bool xf86RegisterOffscreenManager(
_X_EXPORT Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!pScreen->devPrivates[xf86FBMangerIndex].ptr)
+ if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
return TRUE;
@@ -81,9 +75,10 @@ xf86RegisterFreeBoxCallback(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
@@ -101,9 +96,10 @@ xf86AllocateOffscreenArea(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenArea)(
@@ -122,9 +118,10 @@ xf86AllocateOffscreenLinear(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenLinear)(
@@ -139,10 +136,10 @@ xf86FreeOffscreenArea(FBAreaPtr area)
if(!area) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &area->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenArea)(area);
@@ -158,10 +155,10 @@ xf86FreeOffscreenLinear(FBLinearPtr linear)
if(!linear) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &linear->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenLinear)(linear);
@@ -179,10 +176,10 @@ xf86ResizeOffscreenArea(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenArea)(resize, w, h);
@@ -197,10 +194,10 @@ xf86ResizeOffscreenLinear(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenLinear)(resize, size);
@@ -220,9 +217,10 @@ xf86QueryLargestOffscreenArea(
*w = 0;
*h = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenArea)(
@@ -240,9 +238,10 @@ xf86QueryLargestOffscreenLinear(
*size = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenLinear)(
@@ -255,9 +254,10 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
{
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->PurgeOffscreenAreas)(pScreen);
@@ -269,8 +269,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/
-static unsigned long xf86FBGeneration = 0;
-static int xf86FBScreenIndex = -1;
+static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey;
typedef struct _FBLink {
FBArea area;
@@ -320,8 +319,8 @@ localRegisterFreeBoxCallback(
FreeBoxCallbackProcPtr *newCallbacks;
DevUnion *newPrivates;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback,
sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
@@ -368,10 +367,8 @@ AllocateArea(
/* look through the free boxes */
for(i = 0; i < num; i++, boxp++) {
x = boxp->x1;
- if(granularity) {
- int tmp = x % granularity;
- if(tmp) x += (granularity - tmp);
- }
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
continue;
@@ -398,10 +395,8 @@ AllocateArea(
boxp = &(link->area.box);
x = boxp->x1;
- if(granularity) {
- int tmp = x % granularity;
- if(tmp) x += (granularity - tmp);
- }
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
link = link->next;
@@ -450,8 +445,8 @@ localAllocateOffscreenArea(
FBManagerPtr offman;
FBAreaPtr area = NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
SendCallFreeBoxCallbacks(offman);
@@ -468,8 +463,8 @@ localFreeOffscreenArea(FBAreaPtr area)
ScreenPtr pScreen;
pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return;
@@ -509,8 +504,8 @@ localResizeOffscreenArea(
FBLinkPtr pLink, newLink, pLinkPrev = NULL;
pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* find this link */
if(!(pLink = offman->UsedAreas))
return FALSE;
@@ -629,8 +624,8 @@ localQueryLargestOffscreenArea(
if((preferences < 0) || (preferences > 3))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if(severity < 0) severity = 0;
if(severity > 2) severity = 2;
@@ -685,10 +680,8 @@ localQueryLargestOffscreenArea(
while(nbox--) {
x = pbox->x1;
- if(granularity) {
- int tmp = x % granularity;
- if(tmp) x += (granularity - tmp);
- }
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
w = pbox->x2 - x;
h = pbox->y2 - pbox->y1;
@@ -737,8 +730,8 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
RegionRec FreedRegion;
Bool anyUsed = FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return TRUE;
@@ -786,8 +779,8 @@ LinearRemoveCBWrapper(FBAreaPtr area)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -845,7 +838,9 @@ AllocateLinear(
while (linear) {
/* Make sure we get a free area that's not an XY fallback case */
if (!linear->area && linear->free) {
- offset = (linear->linear.offset + granularity) & ~granularity;
+ offset = linear->linear.offset;
+ if (granularity > 1)
+ offset = ((offset + granularity - 1) / granularity) * granularity;
end = offset+size;
if (end <= (linear->linear.offset + linear->linear.size))
break;
@@ -915,7 +910,8 @@ localAllocateOffscreenLinear(
BoxPtr extents;
int w, h, pitch;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* Try to allocate from linear memory first...... */
#ifdef DEBUG
@@ -935,17 +931,20 @@ localAllocateOffscreenLinear(
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
- if (gran && gran > pitch) {
- /* we can't match the specified alignment with XY allocations */
- xfree(link);
- return NULL;
- }
- if (gran && (pitch % gran)) {
- /* pitch and granularity aren't a perfect match, let's allocate
- * a bit more so we can align later on
- */
- length += gran - 1;
- }
+ if (gran > 1) {
+ if (gran > pitch) {
+ /* we can't match the specified alignment with XY allocations */
+ xfree(link);
+ return NULL;
+ }
+
+ if (pitch % gran) {
+ /* pitch and granularity aren't a perfect match, let's allocate
+ * a bit more so we can align later on
+ */
+ length += gran - 1;
+ }
+ }
if(length < pitch) { /* special case */
w = length;
@@ -968,8 +967,8 @@ localAllocateOffscreenLinear(
linear->pScreen = pScreen;
linear->size = h * w;
linear->offset = (pitch * area->box.y1) + area->box.x1;
- if (gran && linear->offset % gran)
- linear->offset += gran - (linear->offset % gran);
+ if (gran > 1)
+ linear->offset = ((linear->offset + gran - 1) / gran) * gran;
linear->granularity = gran;
linear->MoveLinearCallback = moveCB;
linear->RemoveLinearCallback = removeCB;
@@ -992,8 +991,8 @@ localFreeOffscreenLinear(FBLinearPtr linear)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = linear->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -1050,8 +1049,8 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
FBLinearLinkPtr pLink;
ScreenPtr pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return FALSE;
@@ -1100,7 +1099,8 @@ localQueryLargestOffscreenLinear(
int priority
)
{
- FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
FBLinearLinkPtr pLink;
FBLinearLinkPtr pLinkRet;
@@ -1131,7 +1131,8 @@ localQueryLargestOffscreenLinear(
FBManagerPtr offman;
BoxPtr extents;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
@@ -1163,9 +1164,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
{
FBLinkPtr pLink, tmp;
FBLinearLinkPtr pLinearLink, tmp2;
- FBManagerPtr offman =
- (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pScreen->CloseScreen = offman->CloseScreen;
@@ -1189,7 +1189,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
xfree(offman->FreeBoxesUpdateCallback);
xfree(offman->devPrivates);
xfree(offman);
- pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
return (*pScreen->CloseScreen) (i, pScreen);
}
@@ -1333,19 +1333,13 @@ xf86InitFBManagerRegion(
if(REGION_NIL(FullRegion))
return FALSE;
- if(xf86FBGeneration != serverGeneration) {
- if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86FBGeneration = serverGeneration;
- }
-
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;
offman = xalloc(sizeof(FBManager));
if(!offman) return FALSE;
- pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
@@ -1381,11 +1375,11 @@ xf86InitFBManagerLinear(
return FALSE;
/* we expect people to have called the Area setup first for pixmap cache */
- if (!pScreen->devPrivates[xf86FBScreenIndex].ptr)
+ if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
offman->LinearAreas = xalloc(sizeof(FBLinearLink));
if (!offman->LinearAreas)
return FALSE;
@@ -1425,19 +1419,23 @@ xf86AllocateLinearOffscreenArea (
BoxPtr extents;
int w, h;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
w = extents->x2 - extents->x1;
- if(gran && ((gran > w) || (w % gran))) {
- /* we can't match the specified alignment with XY allocations */
- return NULL;
+ if (gran > 1) {
+ if (gran > w)
+ return NULL;
+
+ if (w % gran)
+ length += gran - 1;
}
if(length <= w) { /* special case */
diff --git a/xserver/hw/xfree86/common/xf86pciBus.c b/xserver/hw/xfree86/common/xf86pciBus.c
index b763042cc..d5ae75b3a 100644
--- a/xserver/hw/xfree86/common/xf86pciBus.c
+++ b/xserver/hw/xfree86/common/xf86pciBus.c
@@ -28,8 +28,6 @@
/*
* This file contains the interfaces to the bus-specific code
*/
-#define INCLUDE_DEPRECATED 1
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -38,6 +36,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <X11/X.h>
+#include <pciaccess.h>
#include "os.h"
#include "Pci.h"
#include "xf86.h"
@@ -45,8 +44,6 @@
#include "xf86Resources.h"
/* Bus-specific headers */
-#include "xf86PciData.h"
-
#include "xf86Bus.h"
#define XF86_OS_PRIVS
@@ -57,96 +54,48 @@
/* Bus-specific globals */
Bool pciSlotClaimed = FALSE;
-pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */
-pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */
-pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */
-
-/* pcidata globals */
-ScanPciSetupProcPtr xf86SetupPciIds = NULL;
-ScanPciCloseProcPtr xf86ClosePciIds = NULL;
-ScanPciFindByDeviceProcPtr xf86FindPciNamesByDevice = NULL;
-ScanPciFindBySubsysProcPtr xf86FindPciNamesBySubsys = NULL;
-
-static resPtr pciAvoidRes = NULL;
+static struct pci_device ** xf86PciVideoInfo = NULL; /* PCI probe for video hw */
-/* PCI buses */
-static PciBusPtr xf86PciBus = NULL;
-/* Bus-specific probe/sorting functions */
/* PCI classes that get included in xf86PciVideoInfo */
-#define PCIINFOCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC) || \
- ((b) == PCI_CLASS_DISPLAY) || \
- ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO) || \
- ((b) == PCI_CLASS_PROCESSOR && (s) == PCI_SUBCLASS_PROCESSOR_COPROC))
+#define PCIINFOCLASSES(c) \
+ ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
+ || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
/*
* PCI classes that have messages printed always. The others are only
* have a message printed when the vendor/dev IDs are recognised.
*/
-#define PCIALWAYSPRINTCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
- ((b) == PCI_CLASS_DISPLAY) || \
- ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO))
-
+#define PCIALWAYSPRINTCLASSES(c) \
+ ( (((c) & 0x00ffff00) \
+ == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \
+ || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
+ || ((((c) & 0x00ffff00) \
+ == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) )
+
+#define IS_VGA(c) \
+ (((c) & 0x00ffff00) \
+ == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8)))
+
/*
* PCI classes for which potentially destructive checking of the map sizes
* may be done. Any classes where this may be unsafe should be omitted
* from this list.
*/
-#define PCINONSYSTEMCLASSES(b,s) PCIALWAYSPRINTCLASSES(b,s)
+#define PCINONSYSTEMCLASSES(c) PCIALWAYSPRINTCLASSES(c)
/*
* PCI classes that use RAC
*/
-#define PCISHAREDIOCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
- ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA))
-
-#define PCI_MEM32_LENGTH_MAX 0xFFFFFFFF
-
-#define B2M(tag,base) pciBusAddrToHostAddr(tag,PCI_MEM,base)
-#define B2I(tag,base) pciBusAddrToHostAddr(tag,PCI_IO,base)
-#define B2H(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
- B2M(tag, base) : B2I(tag, base))
-#define M2B(tag,base) pciHostAddrToBusAddr(tag,PCI_MEM,base)
-#define I2B(tag,base) pciHostAddrToBusAddr(tag,PCI_IO,base)
-#define H2B(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
- M2B(tag, base) : I2B(tag, base))
-#define TAG(pvp) (pciTag(pvp->bus,pvp->device,pvp->func))
-#define SIZE(size) ((1 << size) - 1)
-#define PCI_SIZE(type,tag,size) (((type & ResPhysMask) == ResMem) \
- ? pciBusAddrToHostAddr(tag,PCI_MEM_SIZE,size) \
- : pciBusAddrToHostAddr(tag,PCI_IO_SIZE,size))
-#define PCI_M_RANGE(range,tag,begin,end,type) \
- { \
- RANGE(range, B2M(tag, begin), B2M(tag, end), \
- RANGE_TYPE(type, xf86GetPciDomain(tag))); \
- }
-#define PCI_I_RANGE(range,tag,begin,end,type) \
- { \
- RANGE(range, B2I(tag, begin), B2I(tag, end), \
- RANGE_TYPE(type, xf86GetPciDomain(tag))); \
- }
-#define PCI_X_RANGE(range,tag,begin,end,type) \
-{ if ((type & ResPhysMask) == ResMem) PCI_M_RANGE(range,tag,begin,end,type); \
- else PCI_I_RANGE(range,tag,begin,end,type); }
-#define P_M_RANGE(range,tag,begin,size,type) \
- PCI_M_RANGE(range,tag,begin,(begin + SIZE(size)),type)
-#define P_I_RANGE(range,tag,begin,size,type) \
- PCI_I_RANGE(range,tag,begin,(begin + SIZE(size)),type)
-#define P_X_RANGE(range,tag,begin,size,type) \
-{ if ((type & ResPhysMask) == ResMem) P_M_RANGE(range,tag,begin,size,type); \
- else P_I_RANGE(range,tag,begin,size,type); }
-#define PV_M_RANGE(range,pvp,i,type) \
- P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i],type)
-#define PV_B_RANGE(range,pvp,type) \
- P_M_RANGE(range,TAG(pvp),pvp->biosBase,pvp->biosSize,type)
-#define PV_I_RANGE(range,pvp,i,type) \
- P_I_RANGE(range,TAG(pvp),pvp->ioBase[i],pvp->size[i],type)
-
-static void pciConvertListToHost(int bus, int dev, int func, resPtr list);
-static PciBusPtr xf86GetPciBridgeInfo(void);
+#define PCISHAREDIOCLASSES(c) \
+ ( (((c) & 0x00ffff00) \
+ == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \
+ || IS_VGA(c) )
+
_X_EXPORT void
xf86FormatPciBusNumber(int busnum, char *buffer)
@@ -158,360 +107,6 @@ xf86FormatPciBusNumber(int busnum, char *buffer)
sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
}
-static Bool
-IsBaseUnassigned(CARD32 base)
-{
- CARD32 mask;
-
- if (base & PCI_MAP_IO)
- mask = ~PCI_MAP_IO_ATTR_MASK;
- else
- mask = ~PCI_MAP_MEMORY_ATTR_MASK;
-
- base &= mask;
- return (!base || (base == mask));
-}
-
-static Bool
-IsBaseUnassigned64(CARD32 base0, CARD32 base1)
-{
- base0 &= ~PCI_MAP_MEMORY_ATTR_MASK;
- base1 &= 0xffffffff;
-
- return ((!base0 && !base1)
- || ((base0 == ~PCI_MAP_MEMORY_ATTR_MASK)
- && (base1 == 0xffffffff)));
-}
-
-static void
-FindPCIVideoInfo(void)
-{
- pciConfigPtr pcrp, *pcrpp;
- int i = 0, j, k;
- int num = 0;
- pciVideoPtr info;
- int DoIsolateDeviceCheck = 0;
-
- if (xf86IsolateDevice.bus || xf86IsolateDevice.device || xf86IsolateDevice.func)
- DoIsolateDeviceCheck = 1;
- pcrpp = xf86PciInfo = xf86scanpci(0);
-
-
- if (pcrpp == NULL) {
- xf86PciVideoInfo = NULL;
- return;
- }
- xf86PciBus = xf86GetPciBridgeInfo();
-
- while ((pcrp = pcrpp[i])) {
- const int baseclass = pcrp->pci_base_class;
- const int subclass = pcrp->pci_sub_class;
-
- if ( PCIINFOCLASSES(baseclass, subclass) &&
- (!DoIsolateDeviceCheck ||
- (xf86IsolateDevice.bus == pcrp->busnum &&
- xf86IsolateDevice.device == pcrp->devnum &&
- xf86IsolateDevice.func == pcrp->funcnum)) ) {
- num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- sizeof(pciVideoPtr) * (num + 1));
- xf86PciVideoInfo[num] = NULL;
- info = xf86PciVideoInfo[num - 1] = xnfalloc(sizeof(pciVideoRec));
- info->validSize = FALSE;
- info->vendor = pcrp->pci_vendor;
- info->chipType = pcrp->pci_device;
- info->chipRev = pcrp->pci_rev_id;
- info->subsysVendor = pcrp->pci_subsys_vendor;
- info->subsysCard = pcrp->pci_subsys_card;
- info->bus = pcrp->busnum;
- info->device = pcrp->devnum;
- info->func = pcrp->funcnum;
- info->class = baseclass;
- info->subclass = pcrp->pci_sub_class;
- info->interface = pcrp->pci_prog_if;
- info->biosBase = PCIGETROM(pcrp->pci_baserom);
- info->biosSize = pciGetBaseSize(pcrp->tag, 6, TRUE, NULL);
- info->thisCard = pcrp;
- info->validate = FALSE;
-#ifdef INCLUDE_XF86_NO_DOMAIN
- if ((PCISHAREDIOCLASSES(baseclass, subclass))
- && (pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
- (pcrp->pci_prog_if == 0)) {
-
- /*
- * Attempt to ensure that VGA is actually routed to this
- * adapter on entry. This needs to be fixed when we finally
- * grok host bridges (and multiple bus trees).
- */
- j = info->bus;
- while (TRUE) {
- PciBusPtr pBus = xf86PciBus;
- while (pBus && j != pBus->secondary)
- pBus = pBus->next;
- if (!pBus || !(pBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN))
- break;
- if (j == pBus->primary) {
- if (primaryBus.type == BUS_NONE) {
- /* assumption: primary adapter is always VGA */
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci.bus = pcrp->busnum;
- primaryBus.id.pci.device = pcrp->devnum;
- primaryBus.id.pci.func = pcrp->funcnum;
- } else if (primaryBus.type < BUS_last) {
- xf86Msg(X_NOTICE,
- "More than one primary device found\n");
- primaryBus.type ^= (BusType)(-1);
- }
- break;
- }
- j = pBus->primary;
- }
- }
-#endif
-
- for (j = 0; j < 6; j++) {
- info->memBase[j] = 0;
- info->ioBase[j] = 0;
- if (PCINONSYSTEMCLASSES(baseclass, subclass)) {
- info->size[j] =
- pciGetBaseSize(pcrp->tag, j, TRUE, &info->validSize);
- pcrp->minBasesize = info->validSize;
- } else {
- info->size[j] = pcrp->basesize[j];
- info->validSize = pcrp->minBasesize;
- }
- info->type[j] = 0;
- }
-
- if (PCINONSYSTEMCLASSES(baseclass, subclass)) {
- /*
- * Check of a PCI base is unassigned. If so
- * attempt to fix it. Validation will determine
- * if the value was correct later on.
- */
- CARD32 *base = &pcrp->pci_base0;
-
- for (j = 0; j < 6; j++) {
- if (!PCI_MAP_IS64BITMEM(base[j])) {
- if (info->size[j] && IsBaseUnassigned(base[j]))
- base[j] = pciCheckForBrokenBase(pcrp->tag, j);
- } else {
- if (j == 5) /* bail out */
- break;
- if (info->size[j]
- && IsBaseUnassigned64(base[j],base[j+1])) {
- base[j] = pciCheckForBrokenBase(pcrp->tag, j);
- j++;
- base[j] = pciCheckForBrokenBase(pcrp->tag, j);
- }
- }
- }
- }
-
- /*
- * 64-bit base addresses are checked for and avoided on 32-bit
- * platforms.
- */
- for (j = 0; j < 6; ++j) {
- CARD32 bar = (&pcrp->pci_base0)[j];
-
- if (bar != 0) {
- if (bar & PCI_MAP_IO) {
- info->ioBase[j] = (memType)PCIGETIO(bar);
- info->type[j] = bar & PCI_MAP_IO_ATTR_MASK;
- } else {
- info->type[j] = bar & PCI_MAP_MEMORY_ATTR_MASK;
- info->memBase[j] = (memType)PCIGETMEMORY(bar);
- if (PCI_MAP_IS64BITMEM(bar)) {
- if (j == 5) {
- xf86MsgVerb(X_WARNING, 0,
- "****BAR5 specified as 64-bit wide, "
- "which is not possible. "
- "Ignoring BAR5.****\n");
- info->memBase[j] = 0;
- } else {
- CARD32 bar_hi = PCIGETMEMORY64HIGH((&pcrp->pci_base0)[j]);
-#if defined(LONG64) || defined(WORD64)
- /* 64 bit architecture */
- info->memBase[j] |=
- (memType)bar_hi << 32;
-#else
- if (bar_hi != 0)
- info->memBase[j] = 0;
-#endif
- ++j; /* Step over the next BAR */
- }
- }
- }
- }
- }
- }
- i++;
- }
-
- /* If we haven't found a primary device try a different heuristic */
- if (primaryBus.type == BUS_NONE && num) {
- for (i = 0; i < num; i++) {
- info = xf86PciVideoInfo[i];
- pcrp = info->thisCard;
-
- if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
- (num == 1 ||
- ((info->class == PCI_CLASS_DISPLAY) &&
- (info->subclass == PCI_SUBCLASS_DISPLAY_VGA)))) {
- if (primaryBus.type == BUS_NONE) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci.bus = pcrp->busnum;
- primaryBus.id.pci.device = pcrp->devnum;
- primaryBus.id.pci.func = pcrp->funcnum;
- } else {
- xf86Msg(X_NOTICE,
- "More than one possible primary device found\n");
- primaryBus.type ^= (BusType)(-1);
- }
- }
- }
- }
-
- /* Print a summary of the video devices found */
- for (k = 0; k < num; k++) {
- const char *vendorname = NULL, *chipname = NULL;
- const char *prim = " ";
- char busnum[8];
- Bool memdone = FALSE, iodone = FALSE;
-
- i = 0;
- info = xf86PciVideoInfo[k];
- xf86FormatPciBusNumber(info->bus, busnum);
- xf86FindPciNamesByDevice(info->vendor, info->chipType,
- NOVENDOR, NOSUBSYS,
- &vendorname, &chipname, NULL, NULL);
- if ((!vendorname || !chipname) &&
- !PCIALWAYSPRINTCLASSES(info->class, info->subclass))
- continue;
- if (xf86IsPrimaryPci(info))
- prim = "*";
-
- xf86Msg(X_PROBED, "PCI:%s(%s:%d:%d) ", prim, busnum, info->device,
- info->func);
- if (vendorname)
- xf86ErrorF("%s ", vendorname);
- else
- xf86ErrorF("unknown vendor (0x%04x) ", info->vendor);
- if (chipname)
- xf86ErrorF("%s ", chipname);
- else
- xf86ErrorF("unknown chipset (0x%04x) ", info->chipType);
- xf86ErrorF("rev %d", info->chipRev);
- for (i = 0; i < 6; i++) {
- if (info->memBase[i] &&
- (info->memBase[i] < (memType)(-1 << info->size[i]))) {
- if (!memdone) {
- xf86ErrorF(", Mem @ ");
- memdone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%d", info->memBase[i], info->size[i]);
- }
- }
- for (i = 0; i < 6; i++) {
- if (info->ioBase[i] &&
- (info->ioBase[i] < (memType)(-1 << info->size[i]))) {
- if (!iodone) {
- xf86ErrorF(", I/O @ ");
- iodone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%04lx/%d", info->ioBase[i], info->size[i]);
- }
- }
- if (info->biosBase &&
- (info->biosBase < (memType)(-1 << info->biosSize)))
- xf86ErrorF(", BIOS @ 0x%08lx/%d", info->biosBase, info->biosSize);
- xf86ErrorF("\n");
- }
-}
-
-/*
- * fixPciSizeInfo() -- fix pci size info by testing it destructively
- * (if not already done), fix pciVideoInfo and entry in the resource
- * list.
- */
-/*
- * Note: once we have OS support to read the sizes GetBaseSize() will
- * have to be wrapped by the OS layer. fixPciSizeInfo() should also
- * be wrapped by the OS layer to do nothing if the size is always
- * returned correctly by GetBaseSize(). It should however set validate
- * in pciVideoRec if validation is required. ValidatePci() also needs
- * to be wrapped by the OS layer. This may do nothing if the OS has
- * already taken care of validation. fixPciResource() may be moved to
- * OS layer with minimal changes. Once the wrapping layer is in place
- * the common level and drivers should not reference these functions
- * directly but thru the OS layer.
- */
-
-static void
-fixPciSizeInfo(int entityIndex)
-{
- pciVideoPtr pvp;
- resPtr pAcc;
- PCITAG tag;
- int j;
-
- if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return;
- if (pvp->validSize) return;
-
- tag = pciTag(pvp->bus,pvp->device,pvp->func);
-
- for (j = 0; j < 6; j++) {
- pAcc = Acc;
- if (pvp->memBase[j])
- while (pAcc) {
- if (((pAcc->res_type & (ResPhysMask | ResBlock))
- == (ResMem | ResBlock))
- && (pAcc->block_begin == B2M(TAG(pvp),pvp->memBase[j]))
- && (pAcc->block_end == B2M(TAG(pvp),pvp->memBase[j]
- + SIZE(pvp->size[j])))) break;
- pAcc = pAcc->next;
- }
- else if (pvp->ioBase[j])
- while (pAcc) {
- if (((pAcc->res_type & (ResPhysMask | ResBlock)) ==
- (ResIo | ResBlock))
- && (pAcc->block_begin == B2I(TAG(pvp),pvp->ioBase[j]))
- && (pAcc->block_end == B2I(TAG(pvp),pvp->ioBase[j]
- + SIZE(pvp->size[j])))) break;
- pAcc = pAcc->next;
- }
- else continue;
- pvp->size[j] = pciGetBaseSize(tag, j, TRUE, &pvp->validSize);
- if (pAcc) {
- pAcc->block_end = pvp->memBase[j] ?
- B2M(TAG(pvp),pvp->memBase[j] + SIZE(pvp->size[j]))
- : B2I(TAG(pvp),pvp->ioBase[j] + SIZE(pvp->size[j]));
- pAcc->res_type &= ~ResEstimated;
- pAcc->res_type |= ResBios;
- }
- }
- if (pvp->biosBase) {
- pAcc = Acc;
- while (pAcc) {
- if (((pAcc->res_type & (ResPhysMask | ResBlock)) ==
- (ResMem | ResBlock))
- && (pAcc->block_begin == B2M(TAG(pvp),pvp->biosBase))
- && (pAcc->block_end == B2M(TAG(pvp),pvp->biosBase
- + SIZE(pvp->biosSize)))) break;
- pAcc = pAcc->next;
- }
- pvp->biosSize = pciGetBaseSize(tag, 6, TRUE, &pvp->validSize);
- if (pAcc) {
- pAcc->block_end = B2M(TAG(pvp),pvp->biosBase+SIZE(pvp->biosSize));
- pAcc->res_type &= ~ResEstimated;
- pAcc->res_type |= ResBios;
- }
- }
-}
-
/*
* IO enable/disable related routines for PCI
*/
@@ -520,21 +115,25 @@ fixPciSizeInfo(int entityIndex)
static void
pciIoAccessEnable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
static void
pciIoAccessDisable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl &= ~SETBITS;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
#undef SETBITS
@@ -542,21 +141,25 @@ pciIoAccessDisable(void* arg)
static void
pciIo_MemAccessEnable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
static void
pciIo_MemAccessDisable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl &= ~SETBITS;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
#undef SETBITS
@@ -564,21 +167,25 @@ pciIo_MemAccessDisable(void* arg)
static void
pciMemAccessEnable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
static void
pciMemAccessDisable(void* arg)
{
+#if 0
#ifdef DEBUG
ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
pArg->ctrl &= ~SETBITS;
- pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+ pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG);
+#endif
}
#undef SETBITS
#undef pArg
@@ -589,69 +196,46 @@ pciMemAccessDisable(void* arg)
static void
pciBusAccessEnable(BusAccPtr ptr)
{
- PCITAG tag = ptr->busdep.pci.acc;
- CARD16 ctrl;
+#if 0
+ struct pci_device * const dev = ptr->busdep.pci.dev;
+ uint16_t ctrl;
#ifdef DEBUG
ErrorF("pciBusAccessEnable: bus=%d\n", ptr->busdep.pci.bus);
#endif
- ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG );
if ((ctrl & MASKBITS) != PCI_PCI_BRIDGE_VGA_EN) {
ctrl = (ctrl | PCI_PCI_BRIDGE_VGA_EN) &
~(PCI_PCI_BRIDGE_MASTER_ABORT_EN | PCI_PCI_BRIDGE_SECONDARY_RESET);
- pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG);
}
+#endif
}
/* move to OS layer */
static void
pciBusAccessDisable(BusAccPtr ptr)
{
- PCITAG tag = ptr->busdep.pci.acc;
- CARD16 ctrl;
+#if 0
+ struct pci_device * const dev = ptr->busdep.pci.dev;
+ uint16_t ctrl;
#ifdef DEBUG
ErrorF("pciBusAccessDisable: bus=%d\n", ptr->busdep.pci.bus);
#endif
- ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG );
if (ctrl & MASKBITS) {
ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET);
- pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG);
}
-}
-#undef MASKBITS
-
-/* move to OS layer */
-static void
-pciDrvBusAccessEnable(BusAccPtr ptr)
-{
- int bus = ptr->busdep.pci.bus;
-
-#ifdef DEBUG
- ErrorF("pciDrvBusAccessEnable: bus=%d\n", bus);
#endif
- (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
- PCI_PCI_BRIDGE_VGA_EN,
- PCI_PCI_BRIDGE_VGA_EN);
}
-
-/* move to OS layer */
-static void
-pciDrvBusAccessDisable(BusAccPtr ptr)
-{
- int bus = ptr->busdep.pci.bus;
-
-#ifdef DEBUG
- ErrorF("pciDrvBusAccessDisable: bus=%d\n", bus);
-#endif
- (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
- PCI_PCI_BRIDGE_VGA_EN, 0);
-}
-
+#undef MASKBITS
static void
pciSetBusAccess(BusAccPtr ptr)
{
+#if 0
#ifdef DEBUG
ErrorF("pciSetBusAccess: route VGA to bus %d\n", ptr->busdep.pci.bus);
#endif
@@ -674,48 +258,66 @@ pciSetBusAccess(BusAccPtr ptr)
}
ptr = ptr->primary;
}
+#endif
}
/* move to OS layer */
static void
-savePciState(PCITAG tag, pciSavePtr ptr)
+savePciState( struct pci_device * dev, pciSavePtr ptr )
{
+#if 0
int i;
-
- ptr->command = pciReadLong(tag, PCI_CMD_STAT_REG);
- for (i=0; i < 6; i++)
- ptr->base[i] = pciReadLong(tag, PCI_CMD_BASE_REG + i*4);
- ptr->biosBase = pciReadLong(tag, PCI_CMD_BIOS_REG);
+
+ pci_device_cfg_read_u32( dev, & ptr->command, PCI_CMD_STAT_REG );
+
+ for ( i = 0; i < 6; i++ ) {
+ pci_device_cfg_read_u32( dev, & ptr->base[i],
+ PCI_CMD_BASE_REG + (i * 4) );
+ }
+
+ pci_device_cfg_read_u32( dev, & ptr->biosBase, PCI_CMD_BIOS_REG );
+#endif
}
/* move to OS layer */
+#if 0
static void
-restorePciState(PCITAG tag, pciSavePtr ptr)
+restorePciState( struct pci_device * dev, pciSavePtr ptr)
{
int i;
/* disable card before setting anything */
- pciSetBitsLong(tag, PCI_CMD_STAT_REG,
- PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE , 0);
- pciWriteLong(tag,PCI_CMD_BIOS_REG, ptr->biosBase);
- for (i=0; i<6; i++)
- pciWriteLong(tag, PCI_CMD_BASE_REG + i*4, ptr->base[i]);
- pciWriteLong(tag, PCI_CMD_STAT_REG, ptr->command);
+ pci_device_cfg_write_bits(dev, PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE, 0,
+ PCI_CMD_STAT_REG);
+
+ pci_device_cfg_write_u32(dev, ptr->biosBase, PCI_CMD_BIOS_REG);
+
+ for ( i = 0; i < 6; i++ ) {
+ pci_device_cfg_write_u32(dev, ptr->base[i],
+ PCI_CMD_BASE_REG + (i * 4));
+ }
+
+ pci_device_cfg_write_u32(dev, ptr->command, PCI_CMD_STAT_REG);
}
+#endif
/* move to OS layer */
static void
savePciBusState(BusAccPtr ptr)
{
- PCITAG tag = ptr->busdep.pci.acc;
+#if 0
+ struct pci_device * const dev = ptr->busdep.pci.dev;
+ uint16_t temp;
+
+ pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG );
+ ptr->busdep.pci.save.control = temp & ~PCI_PCI_BRIDGE_SECONDARY_RESET;
- ptr->busdep.pci.save.control =
- pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG) &
- ~PCI_PCI_BRIDGE_SECONDARY_RESET;
/* Allow master aborts to complete normally on non-root buses */
- if (ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN)
- pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG,
- ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN);
+ if ( ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN ) {
+ temp = ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN;
+ pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG );
+ }
+#endif
}
/* move to OS layer */
@@ -723,1935 +325,180 @@ savePciBusState(BusAccPtr ptr)
static void
restorePciBusState(BusAccPtr ptr)
{
- PCITAG tag = ptr->busdep.pci.acc;
- CARD16 ctrl;
+#if 0
+ struct pci_device * const dev = ptr->busdep.pci.dev;
+ uint16_t ctrl;
/* Only restore the bits we've changed (and don't cause resets) */
- ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG );
+
if ((ctrl ^ ptr->busdep.pci.save.control) & MASKBITS) {
ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET);
ctrl |= ptr->busdep.pci.save.control & MASKBITS;
- pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG);
}
+#endif
}
#undef MASKBITS
-/* move to OS layer */
-static void
-savePciDrvBusState(BusAccPtr ptr)
-{
- int bus = ptr->busdep.pci.bus;
-
- ptr->busdep.pci.save.control =
- (*pciBusInfo[bus]->funcs->pciControlBridge)(bus, 0, 0);
- /* Allow master aborts to complete normally on this bus */
- (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
- PCI_PCI_BRIDGE_MASTER_ABORT_EN,
- 0);
-}
-
-/* move to OS layer */
-static void
-restorePciDrvBusState(BusAccPtr ptr)
-{
- int bus = ptr->busdep.pci.bus;
-
- (*pciBusInfo[bus]->funcs->pciControlBridge)(bus, (CARD16)(-1),
- ptr->busdep.pci.save.control);
-}
-
-static void
-disablePciBios(PCITAG tag)
-{
- pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0);
-}
-
-/* ????? */
-static void
-correctPciSize(memType base, memType oldsize, memType newsize,
- unsigned long type)
-{
- pciConfigPtr pcrp, *pcrpp;
- pciVideoPtr pvp, *pvpp;
- CARD32 *basep;
- int i;
- int old_bits = 0, new_bits = 0;
-
- if (oldsize + 1) while (oldsize & 1) {
- old_bits ++;
- oldsize >>= 1;
- }
- if (newsize + 1) while (newsize & 1) {
- new_bits ++;
- newsize >>= 1;
- }
-
- for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
-
- /* Only process devices with type 0 headers */
- if ((pcrp->pci_header_type & 0x7f) != 0)
- continue;
-
- basep = &pcrp->pci_base0;
- for (i = 0; i < 6; i++) {
- if (basep[i] && (pcrp->basesize[i] == old_bits)) {
- if ((((type & ResPhysMask) == ResIo) &&
- PCI_MAP_IS_IO(basep[i]) &&
- B2I(pcrp->tag,PCIGETIO(basep[i]) == base)) ||
- (((type & ResPhysMask) == ResMem) &&
- PCI_MAP_IS_MEM(basep[i]) &&
- (((!PCI_MAP_IS64BITMEM(basep[i])) &&
- (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base))
-#if defined(LONG64) || defined(WORD64)
- ||
- (B2M(pcrp->tag,PCIGETMEMORY64(basep[i])) == base)
-#else
- ||
- (!basep[i+1]
- && (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base))
-#endif
- ))) {
- pcrp->basesize[i] = new_bits;
- break; /* to next device */
- }
- }
- if (PCI_MAP_IS64BITMEM(basep[i])) i++;
- }
- }
-
- if (xf86PciVideoInfo) {
- for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
-
- for (i = 0; i < 6; i++) {
- if (pvp->size[i] == old_bits) {
- if ((((type & ResPhysMask) == ResIo) && pvp->ioBase[i]
- && (B2I(TAG(pvp),pvp->ioBase[i]) == base)) ||
- (((type & ResPhysMask) == ResMem) && pvp->memBase[i]
- && (B2M(TAG(pvp),pvp->memBase[i]) == base))) {
- pvp->size[i] = new_bits;
- break; /* to next device */
- }
- }
- }
- }
- }
-}
-
-/* ????? */
-static void
-removeOverlapsWithBridges(int busIndex, resPtr target)
-{
- PciBusPtr pbp;
- resPtr tmp,bridgeRes = NULL;
- resRange range;
-
- if (!target)
- return;
-
- if (!ResCanOverlap(&target->val))
- return;
+/*
+ * xf86Bus.c interface
+ */
- range = target->val;
-
- for (pbp=xf86PciBus; pbp; pbp = pbp->next) {
- if (pbp->primary == busIndex) {
- tmp = xf86DupResList(pbp->preferred_io);
- bridgeRes = xf86JoinResLists(tmp,bridgeRes);
- tmp = xf86DupResList(pbp->preferred_mem);
- bridgeRes = xf86JoinResLists(tmp,bridgeRes);
- tmp = xf86DupResList(pbp->preferred_pmem);
- bridgeRes = xf86JoinResLists(tmp,bridgeRes);
- }
- }
-
- RemoveOverlaps(target, bridgeRes, TRUE, TRUE);
- if (range.rEnd > target->block_end) {
- correctPciSize(range.rBegin, range.rEnd - range.rBegin,
- target->block_end - target->block_begin,
- target->res_type);
- xf86MsgVerb(X_INFO, 3,
- "PCI %s resource overlap reduced 0x%08lx from 0x%08lx to 0x%08lx\n",
- ((target->res_type & ResPhysMask) == ResMem) ? "Memory" : "I/O",
- range.rBegin, range.rEnd, target->block_end);
- }
- xf86FreeResList(bridgeRes);
-}
-
-/* ????? */
-static void
-xf86GetPciRes(resPtr *activeRes, resPtr *inactiveRes)
+void
+xf86PciProbe(void)
{
- pciConfigPtr pcrp, *pcrpp;
- pciVideoPtr pvp, *pvpp;
- CARD32 *basep;
- int i;
- resPtr pRes, tmp;
- resRange range;
- long resMisc;
+ int i = 0, k;
+ int num = 0;
+ struct pci_device *info;
+ struct pci_device_iterator *iter;
- if (activeRes)
- *activeRes = NULL;
- if (inactiveRes)
- *inactiveRes = NULL;
- if (!activeRes || !inactiveRes || !xf86PciInfo)
+ if (!xf86scanpci()) {
+ xf86PciVideoInfo = NULL;
return;
-
- if (xf86PciVideoInfo)
- for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
- resPtr *res;
-
- if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
- resMisc = ResBios;
- else
- resMisc = 0;
-
- if (((pciConfigPtr)pvp->thisCard)->pci_command
- & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))
- res = activeRes;
- else
- res = inactiveRes;
-
- if (!pvp->validSize)
- resMisc |= ResEstimated;
-
- for (i = 0; i < 6; i++) {
- if (pvp->ioBase[i] &&
- (pvp->ioBase[i] < (memType)(-1 << pvp->size[i]))) {
- PV_I_RANGE(range,pvp,i,ResExcIoBlock | resMisc);
- tmp = xf86AddResToList(NULL, &range, -1);
- removeOverlapsWithBridges(pvp->bus,tmp);
- *res = xf86JoinResLists(tmp,*res);
- } else if (pvp->memBase[i] &&
- (pvp->memBase[i] < (memType)(-1 << pvp->size[i]))) {
- PV_M_RANGE(range, pvp,i, ResExcMemBlock | resMisc);
- tmp = xf86AddResToList(NULL, &range, -1);
- removeOverlapsWithBridges(pvp->bus,tmp);
- *res = xf86JoinResLists(tmp,*res);
- }
- }
- /* FIXME!!!: Don't use BIOS resources for overlap
- * checking but reserve them!
- */
- if (pvp->biosBase &&
- (pvp->biosBase < (memType)(-1 << pvp->biosSize))) {
- PV_B_RANGE(range, pvp, ResExcMemBlock | resMisc);
- tmp = xf86AddResToList(NULL, &range, -1);
- removeOverlapsWithBridges(pvp->bus,tmp);
- *res = xf86JoinResLists(tmp,*res);
- }
- }
-
- for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
- resPtr *res;
- const CARD8 baseclass = pcrp->pci_base_class;
- const CARD8 subclass = pcrp->pci_sub_class;
-
-
- if (PCIINFOCLASSES(baseclass, subclass))
- continue;
-
- /* Only process devices with type 0 headers */
- if ((pcrp->pci_header_type & 0x7f) != 0)
- continue;
-
- if (!pcrp->minBasesize)
- resMisc = ResEstimated;
- else
- resMisc = 0;
-
- /*
- * Allow resources allocated to host bridges to overlap. Perhaps, this
- * needs to be specific to AGP-capable chipsets. AGP "memory"
- * sometimes gets allocated within the range routed to the AGP bus.
- */
- if ((baseclass == PCI_CLASS_BRIDGE) &&
- (subclass == PCI_SUBCLASS_BRIDGE_HOST))
- resMisc |= ResOverlap;
-
- basep = &pcrp->pci_base0;
- for (i = 0; i < 6; i++) {
- if (basep[i]) {
- if (PCI_MAP_IS_IO(basep[i])) {
- if (pcrp->pci_command & PCI_CMD_IO_ENABLE)
- res = activeRes;
- else
- res = inactiveRes;
- P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]),
- pcrp->basesize[i], ResExcIoBlock | resMisc)
- } else if (!PCI_MAP_IS64BITMEM(basep[i])) {
- if (pcrp->pci_command & PCI_CMD_MEM_ENABLE)
- res = activeRes;
- else
- res = inactiveRes;
- P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]),
- pcrp->basesize[i], ResExcMemBlock | resMisc)
- } else {
- i++;
-#if defined(LONG64) || defined(WORD64)
- P_M_RANGE(range,pcrp->tag,PCIGETMEMORY64(basep[i - 1]),
- pcrp->basesize[i - 1], ResExcMemBlock | resMisc)
-#else
- if (basep[i])
- continue;
- P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i - 1]),
- pcrp->basesize[i - 1], ResExcMemBlock | resMisc)
-#endif
- if (pcrp->pci_command & PCI_CMD_MEM_ENABLE)
- res = activeRes;
- else
- res = inactiveRes;
- }
- if (range.rBegin) { /* catch cases where PCI base is unset */
- tmp = xf86AddResToList(NULL, &range, -1);
- removeOverlapsWithBridges(pcrp->busnum,tmp);
- *res = xf86JoinResLists(tmp,*res);
- }
- }
- }
-
- /* Ignore disabled non-video ROMs */
- if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
- (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) {
- P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom),
- pcrp->basesize[6], ResExcMemBlock | resMisc);
- if (range.rBegin) {
- tmp = xf86AddResToList(NULL, &range, -1);
- removeOverlapsWithBridges(pcrp->busnum, tmp);
- *activeRes = xf86JoinResLists(tmp, *activeRes);
- }
- }
- }
-
- if (*activeRes) {
- xf86MsgVerb(X_INFO, 3, "Active PCI resource ranges:\n");
- xf86PrintResList(3, *activeRes);
- }
- if (*inactiveRes) {
- xf86MsgVerb(X_INFO, 3, "Inactive PCI resource ranges:\n");
- xf86PrintResList(3, *inactiveRes);
}
- /*
- * Adjust ranges based on the assumption that there are no real
- * overlaps in the PCI base allocations. This assumption should be
- * reasonable in most cases. It may be possible to refine the
- * approximated PCI base sizes by considering bus mapping information
- * from PCI-PCI bridges.
- */
+ iter = pci_slot_match_iterator_create(& xf86IsolateDevice);
+ while ((info = pci_device_next(iter)) != NULL) {
+ if (PCIINFOCLASSES(info->device_class)) {
+ num++;
+ xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
+ (sizeof(struct pci_device *)
+ * (num + 1)));
+ xf86PciVideoInfo[num] = NULL;
+ xf86PciVideoInfo[num - 1] = info;
- if (*activeRes) {
- /* Check for overlaps */
- for (pRes = *activeRes; pRes; pRes = pRes->next) {
- if (ResCanOverlap(&pRes->val)) {
- range = pRes->val;
-
- RemoveOverlaps(pRes, *activeRes, TRUE, TRUE);
- RemoveOverlaps(pRes, *inactiveRes, TRUE,
- (xf86Info.estimateSizesAggressively > 0));
-
- if (range.rEnd > pRes->block_end) {
- correctPciSize(range.rBegin, range.rEnd - range.rBegin,
- pRes->block_end - pRes->block_begin,
- pRes->res_type);
- xf86MsgVerb(X_INFO, 3,
- "PCI %s resource overlap reduced 0x%08lx"
- " from 0x%08lx to 0x%08lx\n",
- ((pRes->res_type & ResPhysMask) == ResMem) ?
- "Memory" : "I/O",
- range.rBegin, range.rEnd, pRes->block_end);
- }
- }
+ pci_device_probe(info);
+ info->user_data = 0;
}
- xf86MsgVerb(X_INFO, 3,
- "Active PCI resource ranges after removing overlaps:\n");
- xf86PrintResList(3, *activeRes);
}
- if (*inactiveRes) {
- /* Check for overlaps */
- for (pRes = *inactiveRes; pRes; pRes = pRes->next) {
- if (ResCanOverlap(&pRes->val)) {
- range = pRes->val;
-
- RemoveOverlaps(pRes, *activeRes, TRUE,
- (xf86Info.estimateSizesAggressively > 1));
- RemoveOverlaps(pRes, *inactiveRes, TRUE,
- (xf86Info.estimateSizesAggressively > 1));
-
- if (range.rEnd > pRes->block_end) {
- correctPciSize(range.rBegin, range.rEnd - range.rBegin,
- pRes->block_end - pRes->block_begin,
- pRes->res_type);
- xf86MsgVerb(X_INFO, 3,
- "PCI %s resource overlap reduced 0x%08lx"
- " from 0x%08lx to 0x%08lx\n",
- ((pRes->res_type & ResPhysMask) == ResMem) ?
- "Memory" : "I/O",
- range.rBegin, range.rEnd, pRes->block_end);
- }
-
- }
- }
- xf86MsgVerb(X_INFO, 3,
- "Inactive PCI resource ranges after removing overlaps:\n");
- xf86PrintResList(3, *inactiveRes);
- }
-}
-resPtr
-ResourceBrokerInitPci(resPtr *osRes)
-{
- resPtr activeRes, inactiveRes;
- resPtr tmp;
-
- /* Get bus-specific system resources (PCI) */
- xf86GetPciRes(&activeRes, &inactiveRes);
-
- /*
- * Adjust OS-reported resource ranges based on the assumption that there
- * are no overlaps with the PCI base allocations. This should be a good
- * assumption because writes to PCI address space won't be routed directly
- * to host memory.
- */
-
- for (tmp = *osRes; tmp; tmp = tmp->next)
- RemoveOverlaps(tmp, activeRes, FALSE, TRUE);
-
- xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges after removing"
- " overlaps with PCI:\n");
- xf86PrintResList(3, *osRes);
-
- pciAvoidRes = xf86AddRangesToList(pciAvoidRes,PciAvoid,-1);
- for (tmp = pciAvoidRes; tmp; tmp = tmp->next)
- RemoveOverlaps(tmp, activeRes, FALSE, TRUE);
- tmp = xf86DupResList(*osRes);
- pciAvoidRes = xf86JoinResLists(pciAvoidRes,tmp);
-
- return (xf86JoinResLists(activeRes,inactiveRes));
-}
+ /* If we haven't found a primary device try a different heuristic */
+ if (primaryBus.type == BUS_NONE && num) {
+ for (i = 0; i < num; i++) {
+ uint16_t command;
+ info = xf86PciVideoInfo[i];
+ pci_device_cfg_read_u16(info, & command, 4);
-/*
- * PCI Resource modification
- */
-static Bool
-fixPciResource(int prt, memType alignment, pciVideoPtr pvp, unsigned long type)
-{
- int res_n;
- memType *p_base;
- int *p_size;
- unsigned char p_type;
- resPtr AccTmp = NULL;
- resPtr orgAcc = NULL;
- resPtr *pAcc = &AccTmp;
- resPtr avoid = NULL;
- resRange range;
- resPtr resSize = NULL;
- resPtr w_tmp, w = NULL, w_2nd = NULL;
- PCITAG tag;
- PciBusPtr pbp = xf86PciBus;
- pciConfigPtr pcp;
- resPtr tmp;
-
- if (!pvp) return FALSE;
- tag = pciTag(pvp->bus,pvp->device,pvp->func);
- pcp = pvp->thisCard;
-
- type &= ResAccMask;
- if (!type) type = ResShared;
- if (prt < 6) {
- if (pvp->memBase[prt]) {
- type |= ResMem;
- res_n = prt;
- p_base = &(pvp->memBase[res_n]);
- p_size = &(pvp->size[res_n]);
- p_type = pvp->type[res_n];
- if (!PCI_MAP_IS64BITMEM(pvp->type[res_n])) {
- PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock);
- resSize = xf86AddResToList(resSize,&range,-1);
- }
- } else if (pvp->ioBase[prt]){
- type |= ResIo;
- res_n = prt;
- p_base = &(pvp->ioBase[res_n]);
- p_size = &(pvp->size[res_n]);
- p_type = pvp->type[res_n];
- PCI_I_RANGE(range, tag, 0, 0xffffffff, ResExcIoBlock);
- resSize = xf86AddResToList(resSize, &range, -1);
- } else return FALSE;
- } else if (prt == 6) {
- type |= ResMem;
- res_n = 0xff; /* special flag for bios rom */
- p_base = &(pvp->biosBase);
- p_size = &(pvp->biosSize);
- /* XXX This should also include the PCI_MAP_MEMORY_TYPE_MASK part */
- p_type = 0;
- PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock);
- resSize = xf86AddResToList(resSize,&range,-1);
- } else return FALSE;
-
- if (! *p_base) return FALSE;
-
- type |= (range.type & ResDomain) | ResBlock;
-
- /* setup avoid: PciAvoid is bus range: convert later */
- avoid = xf86DupResList(pciAvoidRes);
-
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if ((type & ResPhysMask) == ResMem) {
- if (((p_type & PCI_MAP_MEMORY_CACHABLE)
-#if 0 /*EE*/
- || (res_n == 0xff)/* bios should also be prefetchable */
-#endif
- )) {
- if (pbp->preferred_pmem)
- w = xf86FindIntersectOfLists(pbp->preferred_pmem,
- ResRange);
- else if (pbp->pmem)
- w = xf86FindIntersectOfLists(pbp->pmem,ResRange);
-
- if (pbp->preferred_mem)
- w_2nd = xf86FindIntersectOfLists(pbp->preferred_mem,
- ResRange);
- else if (pbp->mem)
- w_2nd = xf86FindIntersectOfLists(pbp->mem,
- ResRange);
+ if ((command & PCI_CMD_MEM_ENABLE)
+ && ((num == 1) || IS_VGA(info->device_class))) {
+ if (primaryBus.type == BUS_NONE) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci = info;
} else {
- if (pbp->preferred_mem)
- w = xf86FindIntersectOfLists(pbp->preferred_mem,
- ResRange);
- else if (pbp->mem)
- w = xf86FindIntersectOfLists(pbp->mem,ResRange);
- }
- } else {
- if (pbp->preferred_io)
- w = xf86FindIntersectOfLists(pbp->preferred_io,ResRange);
- if (pbp->io)
- w = xf86FindIntersectOfLists(pbp->io,ResRange);
- }
- } else if (pbp->primary == pvp->bus) {
- if ((type & ResPhysMask) == ResMem) {
- tmp = xf86DupResList(pbp->preferred_pmem);
- avoid = xf86JoinResLists(avoid, tmp);
- tmp = xf86DupResList(pbp->preferred_mem);
- avoid = xf86JoinResLists(avoid, tmp);
- } else {
- tmp = xf86DupResList(pbp->preferred_io);
- avoid = xf86JoinResLists(avoid, tmp);
- }
- }
- pbp = pbp->next;
- }
-
- /* convert bus based entries in avoid list to host base */
- pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid);
-
- if (!w)
- w = xf86DupResList(ResRange);
- xf86MsgVerb(X_INFO, 3, "window:\n");
- xf86PrintResList(3, w);
- xf86MsgVerb(X_INFO, 3, "resSize:\n");
- xf86PrintResList(3, resSize);
-
- if (resSize) {
- w_tmp = w;
- w = xf86FindIntersectOfLists(w,resSize);
- xf86FreeResList(w_tmp);
- if (w_2nd) {
- w_tmp = w_2nd;
- w_2nd = xf86FindIntersectOfLists(w_2nd,resSize);
- xf86FreeResList(w_tmp);
- }
- xf86FreeResList(resSize);
- }
- xf86MsgVerb(X_INFO, 3, "window fixed:\n");
- xf86PrintResList(3, w);
-
- if (!alignment)
- alignment = (1 << (*p_size)) - 1;
-
- /* Access list holds bios resources -- remove this one */
-#ifdef NOTYET
- AccTmp = xf86DupResList(Acc);
- while ((*pAcc)) {
- if ((((*pAcc)->res_type & (type & ~ResAccMask))
- == (type & ~ResAccMask))
- && ((*pAcc)->block_begin == (B2H(tag,(*p_base),type)))
- && ((*pAcc)->block_end == (B2H(tag,
- (*p_base)+SIZE(*p_size),type)))) {
- resPtr acc_tmp = (*pAcc)->next;
- xfree((*pAcc));
- (*pAcc) = acc_tmp;
- break;
- } else
- pAcc = &((*pAcc)->next);
- }
- /* check if we really need to fix anything */
- P_X_RANGE(range,tag,(*p_base),(*p_base) + SIZE((*p_size)),type);
- if (!ChkConflict(&range,avoid,SETUP)
- && !ChkConflict(&range,AccTmp,SETUP)
- && ((B2H(tag,(*p_base),type) & PCI_SIZE(type,tag,alignment)
- == range->block_begin)
- && ((xf86IsSubsetOf(range,w)
- || (w_2nd && xf86IsSubsetOf(range,w_2n))))) {
-#ifdef DEBUG
- ErrorF("nothing to fix\n");
-#endif
- xf86FreeResList(AccTmp);
- xf86FreeResList(w);
- xf86FreeResList(w_2nd);
- xf86FreeResList(avoid);
- return TRUE;
- }
-#ifdef DEBUG
- ErrorF("removing old resource\n");
-#endif
- orgAcc = Acc;
- Acc = AccTmp;
-#else
- orgAcc = xf86DupResList(Acc);
- pAcc = &Acc;
- while (*pAcc) {
- if ((((*pAcc)->res_type & (ResTypeMask|ResExtMask)) ==
- (type & ~ResAccMask))
- && ((*pAcc)->block_begin == B2H(tag,(*p_base),type))
- && ((*pAcc)->block_end == B2H(tag,(*p_base) + SIZE(*p_size),
- type))) {
-#ifdef DEBUG
- ErrorF("removing old resource\n");
-#endif
- tmp = *pAcc;
- *pAcc = (*pAcc)->next;
- tmp->next = NULL;
- xf86FreeResList(tmp);
- break;
- } else
- pAcc = &((*pAcc)->next);
- }
-#endif
-
-#ifdef DEBUG
- ErrorF("base: 0x%lx alignment: 0x%lx host alignment: 0x%lx size[bit]: 0x%x\n",
- (*p_base),alignment,PCI_SIZE(type,tag,alignment),(*p_size));
- xf86MsgVerb(X_INFO, 3, "window:\n");
- xf86PrintResList(3, w);
- if (w_2nd)
- xf86MsgVerb(X_INFO, 3, "2nd window:\n");
- xf86PrintResList(3, w_2nd);
- xf86ErrorFVerb(3,"avoid:\n");
- xf86PrintResList(3,avoid);
-#endif
- w_tmp = w;
- while (w) {
- if ((type & ResTypeMask) == (w->res_type & ResTypeMask)) {
-#ifdef DEBUG
- ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w->block_begin,
- w->block_end);
-#endif
- range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1),
- w->block_begin, w->block_end,
- PCI_SIZE(type,tag,alignment),avoid);
- if (range.type != ResEnd)
- break;
- }
- w = w->next;
- }
- xf86FreeResList(w_tmp);
- /* if unsuccessful and memory prefetchable try non-prefetchable */
- if (range.type == ResEnd && w_2nd) {
- w_tmp = w_2nd;
- while (w_2nd) {
- if ((type & ResTypeMask) == (w_2nd->res_type & ResTypeMask)) {
-#ifdef DEBUG
- ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w_2nd->block_begin,
- w_2nd->block_end);
-#endif
- range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1),
- w_2nd->block_begin, w_2nd->block_end,
- PCI_SIZE(type,tag,alignment),avoid);
- if (range.type != ResEnd)
- break;
- }
- w_2nd = w_2nd->next;
- }
- xf86FreeResList(w_tmp);
- }
- xf86FreeResList(avoid);
-
- if (range.type == ResEnd) {
- xf86MsgVerb(X_ERROR,3,"Cannot find a replacement memory range\n");
- xf86FreeResList(Acc);
- Acc = orgAcc;
- return FALSE;
- }
- xf86FreeResList(orgAcc);
-#ifdef DEBUG
- ErrorF("begin: 0x%lx, end: 0x%lx\n",range.a,range.b);
-#endif
-
- (*p_size) = 0;
- while (alignment >> (*p_size))
- (*p_size)++;
- (*p_base) = H2B(tag,range.rBegin,type);
-#ifdef DEBUG
- ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n",
- res_n,(*p_base),(1 << (*p_size)),
- ((type & ResPhysMask) == ResMem) ? "Mem" : "Io");
-#endif
- if (res_n != 0xff) {
- if ((type & ResPhysMask) == ResMem)
- pvp->memBase[prt] = range.rBegin;
- else
- pvp->ioBase[prt] = range.rBegin;
- ((CARD32 *)(&(pcp->pci_base0)))[res_n] =
- (CARD32)(*p_base) | (CARD32)(p_type);
- pciWriteLong(tag, PCI_CMD_BASE_REG + res_n * sizeof(CARD32),
- ((CARD32 *)(&(pcp->pci_base0)))[res_n]);
- if (PCI_MAP_IS64BITMEM(p_type)) {
-#if defined(LONG64) || defined(WORD64)
- ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] =
- (CARD32)(*p_base >> 32);
- pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32),
- ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1]);
-#else
- ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = 0;
- pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32),
- 0);
-#endif
- }
- } else {
- pvp->biosBase = range.rBegin;
- pcp->pci_baserom = (pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01) |
- (CARD32)(*p_base);
- pciWriteLong(tag, PCI_CMD_BIOS_REG, pcp->pci_baserom);
- }
- /* @@@ fake BIOS allocated resource */
- range.type |= ResBios;
- Acc = xf86AddResToList(Acc, &range,-1);
-
- return TRUE;
-
-}
-
-_X_EXPORT Bool
-xf86FixPciResource(int entityIndex, int prt, memType alignment,
- unsigned long type)
-{
- pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
- return fixPciResource(prt, alignment, pvp, type);
-}
-
-_X_EXPORT resPtr
-xf86ReallocatePciResources(int entityIndex, resPtr pRes)
-{
- pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
- resPtr pBad = NULL,pResTmp;
- unsigned int prt = 0;
- int i;
-
- if (!pvp) return pRes;
-
- while (pRes) {
- switch (pRes->res_type & ResPhysMask) {
- case ResMem:
- if (pRes->block_begin == B2M(TAG(pvp),pvp->biosBase) &&
- pRes->block_end == B2M(TAG(pvp),pvp->biosBase
- + SIZE(pvp->biosSize)))
- prt = 6;
- else for (i = 0 ; i < 6; i++)
- if ((pRes->block_begin == B2M(TAG(pvp),pvp->memBase[i]))
- && (pRes->block_end == B2M(TAG(pvp),pvp->memBase[i]
- + SIZE(pvp->size[i])))) {
- prt = i;
- break;
- }
- break;
- case ResIo:
- for (i = 0 ; i < 6; i++)
- if (pRes->block_begin == B2I(TAG(pvp),pvp->ioBase[i])
- && pRes->block_end == B2I(TAG(pvp),pvp->ioBase[i]
- + SIZE(pvp->size[i]))) {
- prt = i;
- break;
+ xf86Msg(X_NOTICE,
+ "More than one possible primary device found\n");
+ primaryBus.type ^= (BusType)(-1);
}
- break;
- }
-
- if (!prt) return pRes;
-
- pResTmp = pRes->next;
- if (! fixPciResource(prt, 0, pvp, pRes->res_type)) {
- pRes->next = pBad;
- pBad = pRes;
- } else
- xfree(pRes);
-
- pRes = pResTmp;
- }
- return pBad;
-}
-
-/*
- * BIOS releated
- */
-static resPtr
-getOwnResources(pciVideoPtr pvp, resPtr mem)
-{
- resRange range;
- int i;
- /* Make sure we don't conflict with our own mem resources */
- for (i = 0; i < 6; i++) {
- if (!pvp->memBase[i])
- continue;
- P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i],
- ResExcMemBlock);
- mem = xf86AddResToList(mem,&range,-1);
- }
- return mem;
-}
-
-static void
-getPciRangesForMapping(pciVideoPtr pvp, resPtr *map, resPtr *avoid)
-{
- PciBusPtr pbp;
- resPtr tmp;
-
- *avoid = xf86DupResList(pciAvoidRes);
-
- pbp = xf86PciBus;
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if (pbp->preferred_pmem)
- tmp = xf86DupResList(pbp->preferred_pmem);
- else
- tmp = xf86DupResList(pbp->pmem);
- *map = xf86JoinResLists(*map,tmp);
- if (pbp->preferred_mem)
- tmp = xf86DupResList(pbp->preferred_mem);
- else
- tmp = xf86DupResList(pbp->mem);
- *map = xf86JoinResLists(*map,tmp);
- tmp = *map;
- while (tmp) {
- tmp->block_end = min(tmp->block_end,PCI_MEM32_LENGTH_MAX);
- tmp = tmp->next;
}
- } else if ((pbp->primary == pvp->bus) &&
- (pbp->secondary >= 0) &&
- (pbp->primary != pbp->secondary)) {
- tmp = xf86DupResList(pbp->preferred_pmem);
- *avoid = xf86JoinResLists(*avoid, tmp);
- tmp = xf86DupResList(pbp->pmem);
- *avoid = xf86JoinResLists(*avoid, tmp);
- tmp = xf86DupResList(pbp->preferred_mem);
- *avoid = xf86JoinResLists(*avoid, tmp);
- tmp = xf86DupResList(pbp->mem);
- *avoid = xf86JoinResLists(*avoid, tmp);
}
- pbp = pbp->next;
- }
- pciConvertListToHost(pvp->bus,pvp->device,pvp->func, *avoid);
- pciConvertListToHost(pvp->bus,pvp->device,pvp->func, *map);
-}
-
-static memType
-findPciRange(PCITAG tag, resPtr m, resPtr avoid, CARD32 size)
-{
- resRange range;
- CARD32 alignment = (1 << size) - 1;
-
- while (m) {
- range = xf86GetBlock(RANGE_TYPE(ResExcMemBlock, xf86GetPciDomain(tag)),
- PCI_SIZE(ResMem, tag, 1 << size),
- m->block_begin, m->block_end,
- PCI_SIZE(ResMem, tag, alignment),
- avoid);
- if (range.type != ResEnd) {
- return M2B(tag, range.rBase);
- }
- m = m->next;
}
- return 0;
-}
-
-pciVideoPtr
-getPciVideoPtr(tag)
-{
- int n = 0;
-
- pciVideoPtr pvp = NULL;
- if (!xf86PciVideoInfo) return 0;
- while ((pvp = xf86PciVideoInfo[n++])) {
- if (pciTag(pvp->bus,pvp->device,pvp->func) == tag)
- return pvp;
- }
- return NULL;
-}
-
-memType
-getValidBIOSBase(PCITAG tag, int num)
-{
- pciVideoPtr pvp = NULL;
- memType ret;
- CARD32 biosSize;
- resPtr mem = NULL;
- resPtr avoid = NULL, m = NULL;
- resRange range;
-
- pvp = getPciVideoPtr(tag);
-
- if (!pvp) return 0;
-
- biosSize = pvp->biosSize;
-
- if (biosSize > 24)
- biosSize = 24;
-
- switch ((romBaseSource)num) {
- case ROM_BASE_PRESET:
- return 0; /* This should not happen */
- case ROM_BASE_BIOS:
- /* In some cases the BIOS base register contains the size mask */
- if ((memType)(-1 << biosSize) == PCIGETROM(pvp->biosBase))
- return 0;
- mem = getOwnResources(pvp,mem);
- P_M_RANGE(range, tag, pvp->biosBase,biosSize,ResExcMemBlock);
- ret = pvp->biosBase;
- break;
- case ROM_BASE_MEM0:
- case ROM_BASE_MEM1:
- case ROM_BASE_MEM2:
- case ROM_BASE_MEM3:
- case ROM_BASE_MEM4:
- case ROM_BASE_MEM5:
- if (!pvp->memBase[num] || (pvp->size[num] < biosSize))
- return 0;
- P_M_RANGE(range, tag ,pvp->memBase[num],biosSize,
- ResExcMemBlock);
- ret = pvp->memBase[num];
- break;
- case ROM_BASE_FIND:
- ret = 0;
- break;
- default:
- return 0; /* This should not happen */
- }
-
- /* Now find the ranges for validation */
- getPciRangesForMapping(pvp,&m,&avoid);
-
- if (!ret) {
- /* Return a possible window */
- ret = findPciRange(tag,m,avoid,biosSize);
- } else {
-#if !defined(__ia64__) /* on ia64, trust the kernel, don't look for overlaps */
- if (mem)
- pciConvertListToHost(pvp->bus,pvp->device,pvp->func, mem);
- if (!xf86IsSubsetOf(range, m) ||
- ChkConflict(&range, avoid, SETUP)
- || (mem && ChkConflict(&range, mem, SETUP)))
- ret = 0;
-#endif
- }
-
- xf86FreeResList(avoid);
- xf86FreeResList(m);
- return ret;
-}
-
-memType
-getEmptyPciRange(PCITAG tag, int base_reg)
-{
- resPtr avoid = NULL, m = NULL;
- memType ret;
-
- pciVideoPtr pvp = getPciVideoPtr(tag);
- if (!pvp) return 0;
- getPciRangesForMapping(pvp,&m,&avoid);
- ret = findPciRange(tag,m,avoid,pvp->size[base_reg]);
- xf86FreeResList(avoid);
- xf86FreeResList(m);
-
- return ret;
-}
-
-/*
- * xf86Bus.c interface
- */
-
-void
-xf86PciProbe(void)
-{
- /*
- * Initialise the pcidata entry points.
- */
- xf86SetupPciIds = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds");
- xf86ClosePciIds = (ScanPciCloseProcPtr)LoaderSymbol("ScanPciClosePciIds");
- xf86FindPciNamesByDevice =
- (ScanPciFindByDeviceProcPtr)LoaderSymbol("ScanPciFindPciNamesByDevice");
- xf86FindPciNamesBySubsys =
- (ScanPciFindBySubsysProcPtr)LoaderSymbol("ScanPciFindPciNamesBySubsys");
-
- if (!xf86SetupPciIds())
- FatalError("xf86SetupPciIds() failed\n");
-
- FindPCIVideoInfo();
-}
-
-static void alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary);
-
-static void
-printBridgeInfo(PciBusPtr PciBus)
-{
- char primary[8], secondary[8], subordinate[8], brbus[8];
-
- xf86FormatPciBusNumber(PciBus->primary, primary);
- xf86FormatPciBusNumber(PciBus->secondary, secondary);
- xf86FormatPciBusNumber(PciBus->subordinate, subordinate);
- xf86FormatPciBusNumber(PciBus->brbus, brbus);
-
- xf86MsgVerb(X_INFO, 3, "Bus %s: bridge is at (%s:%d:%d), (%s,%s,%s),"
- " BCTRL: 0x%04x (VGA_EN is %s)\n",
- secondary, brbus, PciBus->brdev, PciBus->brfunc,
- primary, secondary, subordinate, PciBus->brcontrol,
- (PciBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN) ?
- "set" : "cleared");
- if (PciBus->preferred_io) {
- xf86MsgVerb(X_INFO, 3,
- "Bus %s I/O range:\n", secondary);
- xf86PrintResList(3, PciBus->preferred_io);
- }
- if (PciBus->preferred_mem) {
- xf86MsgVerb(X_INFO, 3,
- "Bus %s non-prefetchable memory range:\n", secondary);
- xf86PrintResList(3, PciBus->preferred_mem);
- }
- if (PciBus->preferred_pmem) {
- xf86MsgVerb(X_INFO, 3,
- "Bus %s prefetchable memory range:\n", secondary);
- xf86PrintResList(3, PciBus->preferred_pmem);
- }
-}
-
-static PciBusPtr
-xf86GetPciBridgeInfo(void)
-{
- const pciConfigPtr *pcrpp;
- pciConfigPtr pcrp;
- pciBusInfo_t *pBusInfo;
- resRange range;
- PciBusPtr PciBus, PciBusBase = NULL;
- PciBusPtr *pnPciBus = &PciBusBase;
- int MaxBus = 0;
- int i, domain;
- int primary, secondary, subordinate;
- memType base, limit;
-
- resPtr pciBusAccWindows = xf86PciBusAccWindowsFromOS();
-
- if (xf86PciInfo == NULL)
- return NULL;
-
- /* Add each bridge */
- for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *(++pcrpp)) {
- if (pcrp->busnum > MaxBus)
- MaxBus = pcrp->busnum;
- if ( pcrp->pci_base_class == PCI_CLASS_BRIDGE ) {
- const int sub_class = pcrp->pci_sub_class;
-
- domain = xf86GetPciDomain(pcrp->tag);
-
- switch (sub_class) {
- case PCI_SUBCLASS_BRIDGE_PCI:
- /* something fishy about the header? If so: just ignore! */
- if ((pcrp->pci_header_type & 0x7f) != 0x01) {
- xf86MsgVerb(X_WARNING, 3, "PCI-PCI bridge at %x:%x:%x has"
- " unexpected header: 0x%x",
- pcrp->busnum, pcrp->devnum,
- pcrp->funcnum, pcrp->pci_header_type);
- break;
- }
-
- domain = pcrp->busnum & 0x0000FF00;
- primary = pcrp->busnum;
- secondary = domain | pcrp->pci_secondary_bus_number;
- subordinate = domain | pcrp->pci_subordinate_bus_number;
-
- /* Is this the correct bridge? If not, ignore it */
- pBusInfo = pcrp->businfo;
- if (pBusInfo && (pcrp != pBusInfo->bridge)) {
- xf86MsgVerb(X_WARNING, 3, "PCI bridge mismatch for bus %x:"
- " %x:%x:%x and %x:%x:%x\n", secondary,
- pcrp->busnum, pcrp->devnum, pcrp->funcnum,
- pBusInfo->bridge->busnum,
- pBusInfo->bridge->devnum,
- pBusInfo->bridge->funcnum);
- break;
- }
-
- if (pBusInfo && pBusInfo->funcs->pciGetBridgeBuses)
- (*pBusInfo->funcs->pciGetBridgeBuses)(secondary,
- &primary,
- &secondary,
- &subordinate);
-
- if (!pcrp->fakeDevice && (primary >= secondary)) {
- xf86MsgVerb(X_WARNING, 3, "Misconfigured PCI bridge"
- " %x:%x:%x (%x,%x)\n",
- pcrp->busnum, pcrp->devnum, pcrp->funcnum,
- primary, secondary);
- break;
- }
-
- *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
- pnPciBus = &PciBus->next;
-
- PciBus->primary = primary;
- PciBus->secondary = secondary;
- PciBus->subordinate = subordinate;
-
- PciBus->brbus = pcrp->busnum;
- PciBus->brdev = pcrp->devnum;
- PciBus->brfunc = pcrp->funcnum;
-
- PciBus->subclass = sub_class;
-
- /* The Intel bridges don't report as transparent
- but guess what they are - from Linux kernel - airlied */
- if ((pcrp->pci_vendor == PCI_VENDOR_INTEL) &&
- ((pcrp->pci_device & 0xff00) == 0x2400)) {
- xf86MsgVerb(X_INFO, 3, "Intel Bridge workaround enabled\n");
- PciBus->interface = PCI_IF_BRIDGE_PCI_SUBTRACTIVE;
- } else {
- PciBus->interface = pcrp->pci_prog_if;
- }
-
- if (pBusInfo && pBusInfo->funcs->pciControlBridge)
- PciBus->brcontrol =
- (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
- else
- PciBus->brcontrol = pcrp->pci_bridge_control;
-
- if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
- (*pBusInfo->funcs->pciGetBridgeResources)(secondary,
- (pointer *)&PciBus->preferred_io,
- (pointer *)&PciBus->preferred_mem,
- (pointer *)&PciBus->preferred_pmem);
- break;
- }
-
- if ((pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
- (pcrp->pci_upper_io_base || pcrp->pci_io_base ||
- pcrp->pci_upper_io_limit || pcrp->pci_io_limit)) {
- base = (pcrp->pci_upper_io_base << 16) |
- ((pcrp->pci_io_base & 0xf0u) << 8);
- limit = (pcrp->pci_upper_io_limit << 16) |
- ((pcrp->pci_io_limit & 0xf0u) << 8) | 0x0fff;
- /*
- * Deal with bridge ISA mode (256 wide ranges spaced 1K
- * apart, but only in the first 64K).
- */
- if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
- while ((base <= (CARD16)(-1)) && (base <= limit)) {
- PCI_I_RANGE(range, pcrp->tag,
- base, base + (CARD8)(-1),
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io,
- &range, -1);
- base += 0x0400;
- }
- }
- if (base <= limit) {
- PCI_I_RANGE(range, pcrp->tag, base, limit,
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io, &range, -1);
- }
- }
- if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
- /*
- * The P2P spec requires these next two, but some bridges
- * don't comply. Err on the side of caution, making the not
- * so bold assumption that no bridge would ever re-route the
- * bottom megabyte.
- */
- if (pcrp->pci_mem_base || pcrp->pci_mem_limit) {
- base = pcrp->pci_mem_base & 0xfff0u;
- limit = pcrp->pci_mem_limit & 0xfff0u;
- if (base <= limit) {
- PCI_M_RANGE(range, pcrp->tag,
- base << 16, (limit << 16) | 0x0fffff,
- ResMem | ResBlock | ResExclusive);
- PciBus->preferred_mem =
- xf86AddResToList(PciBus->preferred_mem, &range, -1);
- }
- }
-
- if (pcrp->pci_prefetch_mem_base ||
- pcrp->pci_prefetch_mem_limit ||
- pcrp->pci_prefetch_upper_mem_base ||
- pcrp->pci_prefetch_upper_mem_limit) {
- base = pcrp->pci_prefetch_mem_base & 0xfff0u;
- limit = pcrp->pci_prefetch_mem_limit & 0xfff0u;
-#if defined(LONG64) || defined(WORD64)
- base |= (memType)pcrp->pci_prefetch_upper_mem_base << 16;
- limit |= (memType)pcrp->pci_prefetch_upper_mem_limit << 16;
-#endif
- if (base <= limit) {
- PCI_M_RANGE(range, pcrp->tag,
- base << 16, (limit << 16) | 0xfffff,
- ResMem | ResBlock | ResExclusive);
- PciBus->preferred_pmem =
- xf86AddResToList(PciBus->preferred_pmem,
- &range, -1);
- }
- }
- }
- break;
-
- case PCI_SUBCLASS_BRIDGE_CARDBUS:
- /* something fishy about the header? If so: just ignore! */
- if ((pcrp->pci_header_type & 0x7f) != 0x02) {
- xf86MsgVerb(X_WARNING, 3, "PCI-CardBus bridge at %x:%x:%x"
- " has unexpected header: 0x%x",
- pcrp->busnum, pcrp->devnum,
- pcrp->funcnum, pcrp->pci_header_type);
- break;
- }
-
- domain = pcrp->busnum & 0x0000FF00;
- primary = pcrp->busnum;
- secondary = domain | pcrp->pci_cb_cardbus_bus_number;
- subordinate = domain | pcrp->pci_subordinate_bus_number;
-
- /* Is this the correct bridge? If not, ignore it */
- pBusInfo = pcrp->businfo;
- if (pBusInfo && (pcrp != pBusInfo->bridge)) {
- xf86MsgVerb(X_WARNING, 3, "CardBus bridge mismatch for bus"
- " %x: %x:%x:%x and %x:%x:%x\n", secondary,
- pcrp->busnum, pcrp->devnum, pcrp->funcnum,
- pBusInfo->bridge->busnum,
- pBusInfo->bridge->devnum,
- pBusInfo->bridge->funcnum);
- break;
- }
-
- if (pBusInfo && pBusInfo->funcs->pciGetBridgeBuses)
- (*pBusInfo->funcs->pciGetBridgeBuses)(secondary,
- &primary,
- &secondary,
- &subordinate);
-
- if (primary >= secondary) {
- if (pcrp->pci_cb_cardbus_bus_number != 0)
- xf86MsgVerb(X_WARNING, 3, "Misconfigured CardBus"
- " bridge %x:%x:%x (%x,%x)\n",
- pcrp->busnum, pcrp->devnum, pcrp->funcnum,
- primary, secondary);
- break;
- }
-
- *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
- pnPciBus = &PciBus->next;
-
- PciBus->primary = primary;
- PciBus->secondary = secondary;
- PciBus->subordinate = subordinate;
-
- PciBus->brbus = pcrp->busnum;
- PciBus->brdev = pcrp->devnum;
- PciBus->brfunc = pcrp->funcnum;
-
- PciBus->subclass = sub_class;
- PciBus->interface = pcrp->pci_prog_if;
-
- if (pBusInfo && pBusInfo->funcs->pciControlBridge)
- PciBus->brcontrol =
- (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
- else
- PciBus->brcontrol = pcrp->pci_bridge_control;
-
- if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
- (*pBusInfo->funcs->pciGetBridgeResources)(secondary,
- (pointer *)&PciBus->preferred_io,
- (pointer *)&PciBus->preferred_mem,
- (pointer *)&PciBus->preferred_pmem);
- break;
- }
-
- if (pcrp->pci_command & PCI_CMD_IO_ENABLE) {
- if (pcrp->pci_cb_iobase0) {
- base = PCI_CB_IOBASE(pcrp->pci_cb_iobase0);
- limit = PCI_CB_IOLIMIT(pcrp->pci_cb_iolimit0);
-
- /*
- * Deal with bridge ISA mode (256-wide ranges spaced 1K
- * apart (start to start), but only in the first 64K).
- */
- if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
- while ((base <= (CARD16)(-1)) &&
- (base <= limit)) {
- PCI_I_RANGE(range, pcrp->tag,
- base, base + (CARD8)(-1),
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io,
- &range, -1);
- base += 0x0400;
- }
- }
-
- if (base <= limit) {
- PCI_I_RANGE(range, pcrp->tag, base, limit,
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io,
- &range, -1);
- }
- }
-
- if (pcrp->pci_cb_iobase1) {
- base = PCI_CB_IOBASE(pcrp->pci_cb_iobase1);
- limit = PCI_CB_IOLIMIT(pcrp->pci_cb_iolimit1);
-
- /*
- * Deal with bridge ISA mode (256-wide ranges spaced 1K
- * apart (start to start), but only in the first 64K).
- */
- if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
- while ((base <= (CARD16)(-1)) &&
- (base <= limit)) {
- PCI_I_RANGE(range, pcrp->tag,
- base, base + (CARD8)(-1),
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io,
- &range, -1);
- base += 0x0400;
- }
- }
-
- if (base <= limit) {
- PCI_I_RANGE(range, pcrp->tag, base, limit,
- ResIo | ResBlock | ResExclusive);
- PciBus->preferred_io =
- xf86AddResToList(PciBus->preferred_io,
- &range, -1);
- }
- }
- }
-
- if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
- if ((pcrp->pci_cb_membase0) &&
- (pcrp->pci_cb_membase0 <= pcrp->pci_cb_memlimit0)) {
- PCI_M_RANGE(range, pcrp->tag,
- pcrp->pci_cb_membase0 & ~0x0fff,
- pcrp->pci_cb_memlimit0 | 0x0fff,
- ResMem | ResBlock | ResExclusive);
- if (pcrp->pci_bridge_control &
- PCI_CB_BRIDGE_CTL_PREFETCH_MEM0)
- PciBus->preferred_pmem =
- xf86AddResToList(PciBus->preferred_pmem,
- &range, -1);
- else
- PciBus->preferred_mem =
- xf86AddResToList(PciBus->preferred_mem,
- &range, -1);
- }
- if ((pcrp->pci_cb_membase1) &&
- (pcrp->pci_cb_membase1 <= pcrp->pci_cb_memlimit1)) {
- PCI_M_RANGE(range, pcrp->tag,
- pcrp->pci_cb_membase1 & ~0x0fff,
- pcrp->pci_cb_memlimit1 | 0x0fff,
- ResMem | ResBlock | ResExclusive);
- if (pcrp->pci_bridge_control &
- PCI_CB_BRIDGE_CTL_PREFETCH_MEM1)
- PciBus->preferred_pmem =
- xf86AddResToList(PciBus->preferred_pmem,
- &range, -1);
- else
- PciBus->preferred_mem =
- xf86AddResToList(PciBus->preferred_mem,
- &range, -1);
- }
- }
-
- break;
-
- case PCI_SUBCLASS_BRIDGE_ISA:
- case PCI_SUBCLASS_BRIDGE_EISA:
- case PCI_SUBCLASS_BRIDGE_MC:
- *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
- pnPciBus = &PciBus->next;
- PciBus->primary = pcrp->busnum;
- PciBus->secondary = PciBus->subordinate = -1;
- PciBus->brbus = pcrp->busnum;
- PciBus->brdev = pcrp->devnum;
- PciBus->brfunc = pcrp->funcnum;
- PciBus->subclass = sub_class;
- PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
- break;
-
- case PCI_SUBCLASS_BRIDGE_HOST:
- /* Is this the correct bridge? If not, ignore bus info */
- pBusInfo = pcrp->businfo;
-
- if (!pBusInfo || pBusInfo == HOST_NO_BUS)
- break;
-
- secondary = 0;
- /* Find "secondary" bus segment */
- while (pBusInfo != pciBusInfo[secondary])
- secondary++;
- if (pcrp != pBusInfo->bridge) {
- xf86MsgVerb(X_WARNING, 3, "Host bridge mismatch for"
- " bus %x: %x:%x:%x and %x:%x:%x\n",
- pBusInfo->primary_bus,
- pcrp->busnum, pcrp->devnum, pcrp->funcnum,
- pBusInfo->bridge->busnum,
- pBusInfo->bridge->devnum,
- pBusInfo->bridge->funcnum);
- pBusInfo = NULL;
- }
-
- *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
- pnPciBus = &PciBus->next;
-
-
- PciBus->primary = PciBus->secondary = secondary;
- PciBus->subordinate = pciNumBuses - 1;
-
- if (pBusInfo->funcs->pciGetBridgeBuses)
- (*pBusInfo->funcs->pciGetBridgeBuses)
- (secondary,
- &PciBus->primary,
- &PciBus->secondary,
- &PciBus->subordinate);
-
- PciBus->brbus = pcrp->busnum;
- PciBus->brdev = pcrp->devnum;
- PciBus->brfunc = pcrp->funcnum;
+ /* Print a summary of the video devices found */
+ for (k = 0; k < num; k++) {
+ const char *vendorname = NULL, *chipname = NULL;
+ const char *prim = " ";
+ Bool memdone = FALSE, iodone = FALSE;
- PciBus->subclass = sub_class;
- if (pBusInfo && pBusInfo->funcs->pciControlBridge)
- PciBus->brcontrol =
- (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
- else
- PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
+ info = xf86PciVideoInfo[k];
- if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
- (*pBusInfo->funcs->pciGetBridgeResources)
- (secondary,
- (pointer *)&PciBus->preferred_io,
- (pointer *)&PciBus->preferred_mem,
- (pointer *)&PciBus->preferred_pmem);
- break;
- }
+ vendorname = pci_device_get_vendor_name( info );
+ chipname = pci_device_get_device_name( info );
- PciBus->preferred_io =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResIo, domain));
- PciBus->preferred_mem =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResMem, domain));
- PciBus->preferred_pmem =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResMem, domain));
- break;
-
- default:
- break;
- }
- }
- }
- for (i = 0; i <= MaxBus; i++) { /* find PCI buses not attached to bridge */
- if (!pciBusInfo[i])
+ if ((!vendorname || !chipname) &&
+ !PCIALWAYSPRINTCLASSES(info->device_class))
continue;
- for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
- if (PciBus->secondary == i) break;
- if (!PciBus) { /* We assume it's behind a HOST-PCI bridge */
- /*
- * Find the 'smallest' free HOST-PCI bridge, where 'small' is in
- * the order of pciTag().
- */
- PCITAG minTag = 0xFFFFFFFF, tag;
- PciBusPtr PciBusFound = NULL;
- for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
- if ((PciBus->subclass == PCI_SUBCLASS_BRIDGE_HOST) &&
- (PciBus->secondary == -1) &&
- ((tag = pciTag(PciBus->brbus,PciBus->brdev,PciBus->brfunc))
- < minTag) ) {
- minTag = tag;
- PciBusFound = PciBus;
- }
- if (PciBusFound)
- PciBusFound->secondary = i;
- else { /* if nothing found it may not be visible: create new */
- /* Find a device on this bus */
- domain = 0;
- for (pcrpp = xf86PciInfo; (pcrp = *pcrpp); pcrpp++) {
- if (pcrp->busnum == i) {
- domain = xf86GetPciDomain(pcrp->tag);
- break;
- }
- }
- *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
- pnPciBus = &PciBus->next;
- PciBus->primary = PciBus->secondary = i;
- PciBus->subclass = PCI_SUBCLASS_BRIDGE_HOST;
- PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
- PciBus->preferred_io =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResIo, domain));
- PciBus->preferred_mem =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResMem, domain));
- PciBus->preferred_pmem =
- xf86ExtractTypeFromList(pciBusAccWindows,
- RANGE_TYPE(ResMem, domain));
- }
- }
- }
-
- for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
- if (PciBus->primary == PciBus->secondary) {
- alignBridgeRanges(PciBusBase, PciBus);
- }
- }
- for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
- switch (PciBus->subclass) {
- case PCI_SUBCLASS_BRIDGE_PCI:
- if (PciBus->interface == PCI_IF_BRIDGE_PCI_SUBTRACTIVE)
- xf86MsgVerb(X_INFO, 3, "Subtractive PCI-to-PCI bridge:\n");
- else
- xf86MsgVerb(X_INFO, 3, "PCI-to-PCI bridge:\n");
- break;
- case PCI_SUBCLASS_BRIDGE_CARDBUS:
- xf86MsgVerb(X_INFO, 3, "PCI-to-CardBus bridge:\n");
- break;
- case PCI_SUBCLASS_BRIDGE_HOST:
- xf86MsgVerb(X_INFO, 3, "Host-to-PCI bridge:\n");
- break;
- case PCI_SUBCLASS_BRIDGE_ISA:
- xf86MsgVerb(X_INFO, 3, "PCI-to-ISA bridge:\n");
- break;
- case PCI_SUBCLASS_BRIDGE_EISA:
- xf86MsgVerb(X_INFO, 3, "PCI-to-EISA bridge:\n");
- break;
- case PCI_SUBCLASS_BRIDGE_MC:
- xf86MsgVerb(X_INFO, 3, "PCI-to-MCA bridge:\n");
- break;
- default:
- break;
- }
- printBridgeInfo(PciBus);
- }
- xf86FreeResList(pciBusAccWindows);
- return PciBusBase;
-}
-
-static void
-alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary)
-{
- PciBusPtr PciBus;
-
- for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
- if ((PciBus != primary) && (PciBus->primary != -1)
- && (PciBus->primary == primary->secondary)) {
- resPtr tmp;
- tmp = xf86FindIntersectOfLists(primary->preferred_io,
- PciBus->preferred_io);
- xf86FreeResList(PciBus->preferred_io);
- PciBus->preferred_io = tmp;
- tmp = xf86FindIntersectOfLists(primary->preferred_pmem,
- PciBus->preferred_pmem);
- xf86FreeResList(PciBus->preferred_pmem);
- PciBus->preferred_pmem = tmp;
- tmp = xf86FindIntersectOfLists(primary->preferred_mem,
- PciBus->preferred_mem);
- xf86FreeResList(PciBus->preferred_mem);
- PciBus->preferred_mem = tmp;
-
- /* Deal with subtractive decoding */
- switch (PciBus->subclass) {
- case PCI_SUBCLASS_BRIDGE_PCI:
- if (PciBus->interface != PCI_IF_BRIDGE_PCI_SUBTRACTIVE)
- break;
- /* Fall through */
-#if 0 /* Not yet */
- case PCI_SUBCLASS_BRIDGE_ISA:
- case PCI_SUBCLASS_BRIDGE_EISA:
- case PCI_SUBCLASS_BRIDGE_MC:
-#endif
- if (!(PciBus->io = primary->io))
- PciBus->io = primary->preferred_io;
- if (!(PciBus->mem = primary->mem))
- PciBus->mem = primary->preferred_mem;
- if (!(PciBus->pmem = primary->pmem))
- PciBus->pmem = primary->preferred_pmem;
- default:
- break;
- }
-
- alignBridgeRanges(PciBusBase, PciBus);
- }
- }
-}
+ if (xf86IsPrimaryPci(info))
+ prim = "*";
-void
-ValidatePci(void)
-{
- pciVideoPtr pvp, pvp1;
- PciBusPtr pbp;
- pciConfigPtr pcrp, *pcrpp;
- CARD32 *basep;
- resPtr Sys;
- resRange range;
- int n = 0, m, i;
+ xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain,
+ info->bus, info->dev, info->func );
- if (!xf86PciVideoInfo) return;
+ if (vendorname)
+ xf86ErrorF("%s ", vendorname);
+ else
+ xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id);
- /*
- * Mark all pciInfoRecs that need to be validated. These are
- * the ones which have been assigned to a screen.
- */
- Sys = xf86DupResList(osRes);
- /* Only validate graphics devices in use */
- for (i=0; i<xf86NumScreens; i++) {
- for (m = 0; m < xf86Screens[i]->numEntities; m++)
- if ((pvp = xf86GetPciInfoForEntity(xf86Screens[i]->entityList[m])))
- pvp->validate = TRUE;
- }
-
- /*
- * Collect all background PCI resources we need to validate against.
- * These are all resources which don't belong to PCINONSYSTEMCLASSES
- * and which have not been assigned to an entity.
- */
- /* First get the PCIINFOCLASSES */
- m = 0;
- while ((pvp = xf86PciVideoInfo[m++])) {
- /* is it a PCINONSYSTEMCLASS? */
- if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
- continue;
- /* has it an Entity assigned to it? */
- for (i=0; i<xf86NumEntities; i++) {
- EntityPtr p = xf86Entities[i];
- if (p->busType != BUS_PCI)
- continue;
- if (p->pciBusId.bus == pvp->bus
- && p->pciBusId.device == pvp->device
- && p->pciBusId.func == pvp->func)
- break;
- }
- if (i != xf86NumEntities) /* found an Entity for this one */
- continue;
-
- for (i = 0; i<6; i++) {
- if (pvp->ioBase[i]) {
- PV_I_RANGE(range,pvp,i,ResExcIoBlock);
- Sys = xf86AddResToList(Sys,&range,-1);
- } else if (pvp->memBase[i]) {
- PV_M_RANGE(range,pvp,i,ResExcMemBlock);
- Sys = xf86AddResToList(Sys,&range,-1);
- }
- }
- }
- for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+ if (chipname)
+ xf86ErrorF("%s ", chipname);
+ else
+ xf86ErrorF("unknown chipset (0x%04x) ", info->device_id);
- /* These were handled above */
- if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
- continue;
-
- if ((pcrp->pci_header_type & 0x7f) ||
- !(pcrp->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)))
- continue;
+ xf86ErrorF("rev %d", info->revision);
- basep = &pcrp->pci_base0;
for (i = 0; i < 6; i++) {
- if (basep[i]) {
- if (PCI_MAP_IS_IO(basep[i])) {
- if (!(pcrp->pci_command & PCI_CMD_IO_ENABLE))
- continue;
- P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]),
- pcrp->basesize[i], ResExcIoBlock)
- } else if (!PCI_MAP_IS64BITMEM(basep[i])) {
- if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE))
- continue;
- P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]),
- pcrp->basesize[i], ResExcMemBlock)
- } else {
- i++;
- if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE))
- continue;
-#if defined(LONG64) || defined(WORD64)
- P_M_RANGE(range, pcrp->tag, PCIGETMEMORY64(basep[i-1]),
- pcrp->basesize[i-1], ResExcMemBlock)
-#else
- if (basep[i])
- continue;
- P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i-1]),
- pcrp->basesize[i-1], ResExcMemBlock)
-#endif
- }
- Sys = xf86AddResToList(Sys, &range, -1);
- }
- }
- if ((pcrp->pci_baserom) &&
- (pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
- (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) {
- P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom),
- pcrp->basesize[6],ResExcMemBlock);
- Sys = xf86AddResToList(Sys, &range, -1);
- }
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"Sys:\n");
- xf86PrintResList(3,Sys);
-#endif
+ struct pci_mem_region * r = & info->regions[i];
- /*
- * The order the video devices are listed in is
- * just right: the lower buses come first.
- * This way we attempt to fix a conflict of
- * a lower bus device with a higher bus device
- * where we have more room to find different
- * resources.
- */
- while ((pvp = xf86PciVideoInfo[n++])) {
- resPtr res_mp = NULL, res_m_io = NULL;
- resPtr NonSys;
- resPtr tmp, avoid = NULL;
-
- if (!pvp->validate) continue;
- NonSys = xf86DupResList(Sys);
- m = n;
- while ((pvp1 = xf86PciVideoInfo[m++])) {
- if (!pvp1->validate) continue;
- for (i = 0; i<6; i++) {
- if (pvp1->ioBase[i]) {
- PV_I_RANGE(range,pvp1,i,ResExcIoBlock);
- NonSys = xf86AddResToList(NonSys,&range,-1);
- } else if (pvp1->memBase[i]) {
- PV_M_RANGE(range,pvp1,i,ResExcMemBlock);
- NonSys = xf86AddResToList(NonSys,&range,-1);
- }
- }
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"NonSys:\n");
- xf86PrintResList(3,NonSys);
-#endif
- pbp = xf86PciBus;
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if (pbp->preferred_pmem) {
- /* keep prefetchable separate */
- res_mp =
- xf86FindIntersectOfLists(pbp->preferred_pmem, ResRange);
- }
- if (pbp->pmem) {
- res_mp = xf86FindIntersectOfLists(pbp->pmem, ResRange);
- }
- if (pbp->preferred_mem) {
- res_m_io =
- xf86FindIntersectOfLists(pbp->preferred_mem, ResRange);
- }
- if (pbp->mem) {
- res_m_io = xf86FindIntersectOfLists(pbp->mem, ResRange);
- }
- if (pbp->preferred_io) {
- res_m_io = xf86JoinResLists(res_m_io,
- xf86FindIntersectOfLists(pbp->preferred_io, ResRange));
- }
- if (pbp->io) {
- res_m_io = xf86JoinResLists(res_m_io,
- xf86FindIntersectOfLists(pbp->preferred_io, ResRange));
- }
- } else if ((pbp->primary == pvp->bus) &&
- (pbp->secondary >= 0) &&
- (pbp->primary != pbp->secondary)) {
- tmp = xf86DupResList(pbp->preferred_pmem);
- avoid = xf86JoinResLists(avoid, tmp);
- tmp = xf86DupResList(pbp->preferred_mem);
- avoid = xf86JoinResLists(avoid, tmp);
- tmp = xf86DupResList(pbp->preferred_io);
- avoid = xf86JoinResLists(avoid, tmp);
+ if ( r->size && ! r->is_IO ) {
+ if (!memdone) {
+ xf86ErrorF(", Mem @ ");
+ memdone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size);
}
- pbp = pbp->next;
}
- if (res_m_io == NULL)
- res_m_io = xf86DupResList(ResRange);
-
- pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"avoid:\n");
- xf86PrintResList(3,avoid);
- xf86MsgVerb(X_INFO, 3,"prefetchable Memory:\n");
- xf86PrintResList(3,res_mp);
- xf86MsgVerb(X_INFO, 3,"MEM/IO:\n");
- xf86PrintResList(3,res_m_io);
-#endif
for (i = 0; i < 6; i++) {
- int j;
- resPtr own = NULL;
- for (j = i+1; j < 6; j++) {
- if (pvp->ioBase[j]) {
- PV_I_RANGE(range,pvp,j,ResExcIoBlock);
- own = xf86AddResToList(own,&range,-1);
- } else if (pvp->memBase[j]) {
- PV_M_RANGE(range,pvp,j,ResExcMemBlock);
- own = xf86AddResToList(own,&range,-1);
- }
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "own:\n");
- xf86PrintResList(3, own);
-#endif
- if (pvp->ioBase[i]) {
- PV_I_RANGE(range,pvp,i,ResExcIoBlock);
- if (xf86IsSubsetOf(range,res_m_io)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,NonSys,SETUP)) {
- xf86FreeResList(own);
- continue;
- }
- xf86MsgVerb(X_WARNING, 0,
- "****INVALID IO ALLOCATION**** b: 0x%lx e: 0x%lx "
- "correcting\a\n", range.rBegin,range.rEnd);
-#ifdef DEBUG
- sleep(2);
-#endif
- fixPciResource(i, 0, pvp, range.type);
- } else if (pvp->memBase[i]) {
- PV_M_RANGE(range,pvp,i,ResExcMemBlock);
- if (pvp->type[i] & PCI_MAP_MEMORY_CACHABLE) {
- if (xf86IsSubsetOf(range,res_mp)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,NonSys,SETUP)) {
- xf86FreeResList(own);
- continue;
- }
- }
- if (xf86IsSubsetOf(range,res_m_io)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,NonSys,SETUP)) {
- xf86FreeResList(own);
- continue;
- }
- xf86MsgVerb(X_WARNING, 0,
- "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx "
- "correcting\a\n", range.rBegin,range.rEnd);
- if (ChkConflict(&range,own,SETUP)) {
- xf86MsgVerb(X_INFO,3,"own\n");
- xf86PrintResList(3,own);
- }
- if (ChkConflict(&range,avoid,SETUP)) {
- xf86MsgVerb(X_INFO,3,"avoid\n");
- xf86PrintResList(3,avoid);
- }
- if (ChkConflict(&range,NonSys,SETUP)) {
- xf86MsgVerb(X_INFO,3,"NonSys\n");
- xf86PrintResList(3,NonSys);
- }
+ struct pci_mem_region * r = & info->regions[i];
-#ifdef DEBUG
- sleep(2);
-#endif
- fixPciResource(i, 0, pvp, range.type);
+ if ( r->size && r->is_IO ) {
+ if (!iodone) {
+ xf86ErrorF(", I/O @ ");
+ iodone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size);
}
- xf86FreeResList(own);
}
- xf86FreeResList(avoid);
- xf86FreeResList(NonSys);
- xf86FreeResList(res_mp);
- xf86FreeResList(res_m_io);
- }
- xf86FreeResList(Sys);
-}
-
-resList
-GetImplicitPciResources(int entityIndex)
-{
- pciVideoPtr pvp;
- int i;
- resList list = NULL;
- int num = 0;
-
- if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return NULL;
-
- for (i = 0; i < 6; i++) {
- if (pvp->ioBase[i]) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- PV_I_RANGE(list[num - 1],pvp,i,ResShrIoBlock | ResBios);
- } else if (pvp->memBase[i]) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- PV_M_RANGE(list[num - 1],pvp,i,ResShrMemBlock | ResBios);
+
+ if ( info->rom_size ) {
+ xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size);
}
+
+ xf86ErrorF("\n");
}
-#if 0
- if (pvp->biosBase) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- PV_B_RANGE(list[num - 1],pvp,ResShrMemBlock | ResBios);
- }
-#endif
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- list[num - 1].type = ResEnd;
-
- return list;
}
void
initPciState(void)
{
- int i = 0;
- int j = 0;
- pciVideoPtr pvp;
+ unsigned i;
pciAccPtr pcaccp;
- if (xf86PciAccInfo != NULL)
- return;
-
- if (xf86PciVideoInfo == NULL)
+ if (xf86PciVideoInfo == NULL) {
return;
+ }
- while ((pvp = xf86PciVideoInfo[i]) != NULL) {
- i++;
- j++;
- xf86PciAccInfo = xnfrealloc(xf86PciAccInfo,
- sizeof(pciAccPtr) * (j + 1));
- xf86PciAccInfo[j] = NULL;
- pcaccp = xf86PciAccInfo[j - 1] = xnfalloc(sizeof(pciAccRec));
- pcaccp->busnum = pvp->bus;
- pcaccp->devnum = pvp->device;
- pcaccp->funcnum = pvp->func;
- pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func);
- pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
- pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
- pcaccp->ioAccess.arg = &pcaccp->arg;
+ for (i = 0 ; xf86PciVideoInfo[i] != NULL ; i++) {
+ struct pci_device * const pvp = xf86PciVideoInfo[i];
+
+ if (pvp->user_data == 0) {
+ pcaccp = xnfalloc( sizeof( pciAccRec ) );
+ pvp->user_data = (intptr_t) pcaccp;
+
+ pcaccp->arg.dev = pvp;
+ pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
+ pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
+ pcaccp->ioAccess.arg = &pcaccp->arg;
pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable;
pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable;
pcaccp->io_memAccess.arg = &pcaccp->arg;
pcaccp->memAccess.AccessDisable = pciMemAccessDisable;
pcaccp->memAccess.AccessEnable = pciMemAccessEnable;
pcaccp->memAccess.arg = &pcaccp->arg;
- if (PCISHAREDIOCLASSES(pvp->class, pvp->subclass))
- pcaccp->ctrl = TRUE;
- else
- pcaccp->ctrl = FALSE;
- savePciState(pcaccp->arg.tag, &pcaccp->save);
+
+ pcaccp->ctrl = PCISHAREDIOCLASSES(pvp->device_class);
+
+ savePciState(pvp, &pcaccp->save);
pcaccp->arg.ctrl = pcaccp->save.command;
+ }
}
}
@@ -2678,59 +525,60 @@ initPciState(void)
void
initPciBusState(void)
{
+ static const struct pci_id_match bridge_match = {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+ (PCI_CLASS_BRIDGE << 16), 0x0000ff0000, 0
+ };
+ struct pci_device *dev;
+ struct pci_device_iterator *iter;
BusAccPtr pbap, pbap_tmp;
- PciBusPtr pbp = xf86PciBus;
- pciBusInfo_t *pBusInfo;
- while (pbp) {
+ iter = pci_id_match_iterator_create(& bridge_match);
+ while((dev = pci_device_next(iter)) != NULL) {
+ const uint8_t subclass = (dev->device_class >> 8) & 0x0ff;
+ int primary;
+ int secondary;
+ int subordinate;
+
+
+ pci_device_get_bridge_buses(dev, &primary, &secondary, &subordinate);
+
pbap = xnfcalloc(1,sizeof(BusAccRec));
- pbap->busdep.pci.bus = pbp->secondary;
- pbap->busdep.pci.primary_bus = pbp->primary;
+ pbap->busdep.pci.bus = secondary;
+ pbap->busdep.pci.primary_bus = primary;
pbap->busdep_type = BUS_PCI;
- pbap->busdep.pci.acc = PCITAG_SPECIAL;
+ pbap->busdep.pci.dev = dev;
- if ((pbp->secondary >= 0) && (pbp->secondary < pciNumBuses) &&
- (pBusInfo = pciBusInfo[pbp->secondary]) &&
- pBusInfo->funcs->pciControlBridge) {
- pbap->type = BUS_PCI;
- pbap->save_f = savePciDrvBusState;
- pbap->restore_f = restorePciDrvBusState;
- pbap->set_f = pciSetBusAccess;
- pbap->enable_f = pciDrvBusAccessEnable;
- pbap->disable_f = pciDrvBusAccessDisable;
- savePciDrvBusState(pbap);
- } else switch (pbp->subclass) {
+ pbap->set_f = pciSetBusAccess;
+
+ switch (subclass) {
case PCI_SUBCLASS_BRIDGE_HOST:
pbap->type = BUS_PCI;
- pbap->set_f = pciSetBusAccess;
break;
case PCI_SUBCLASS_BRIDGE_PCI:
case PCI_SUBCLASS_BRIDGE_CARDBUS:
pbap->type = BUS_PCI;
pbap->save_f = savePciBusState;
pbap->restore_f = restorePciBusState;
- pbap->set_f = pciSetBusAccess;
pbap->enable_f = pciBusAccessEnable;
pbap->disable_f = pciBusAccessDisable;
- pbap->busdep.pci.acc = pciTag(pbp->brbus,pbp->brdev,pbp->brfunc);
savePciBusState(pbap);
break;
case PCI_SUBCLASS_BRIDGE_ISA:
case PCI_SUBCLASS_BRIDGE_EISA:
case PCI_SUBCLASS_BRIDGE_MC:
pbap->type = BUS_ISA;
- pbap->set_f = pciSetBusAccess;
break;
}
pbap->next = xf86BusAccInfo;
xf86BusAccInfo = pbap;
- pbp = pbp->next;
}
- pbap = xf86BusAccInfo;
+ pci_iterator_destroy(iter);
- while (pbap) {
+ for (pbap = xf86BusAccInfo; pbap; pbap = pbap->next) {
pbap->primary = NULL;
+
if (pbap->busdep_type == BUS_PCI
&& pbap->busdep.pci.primary_bus > -1) {
pbap_tmp = xf86BusAccInfo;
@@ -2746,32 +594,34 @@ initPciBusState(void)
pbap_tmp = pbap_tmp->next;
}
}
- pbap = pbap->next;
}
}
void
PciStateEnter(void)
{
- pciAccPtr paccp;
- int i = 0;
-
- if (xf86PciAccInfo == NULL)
+#if 0
+ unsigned i;
+
+ if (xf86PciVideoInfo == NULL)
return;
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl)
- continue;
- savePciState(paccp->arg.tag, &paccp->save);
- restorePciState(paccp->arg.tag, &paccp->restore);
- paccp->arg.ctrl = paccp->restore.command;
+ for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) {
+ pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data;
+
+ if ( (paccp != NULL) && paccp->ctrl ) {
+ savePciState(paccp->arg.dev, &paccp->save);
+ restorePciState(paccp->arg.dev, &paccp->restore);
+ paccp->arg.ctrl = paccp->restore.command;
+ }
}
+#endif
}
void
PciBusStateEnter(void)
{
+#if 0
BusAccPtr pbap = xf86BusAccInfo;
while (pbap) {
@@ -2779,29 +629,33 @@ PciBusStateEnter(void)
pbap->save_f(pbap);
pbap = pbap->next;
}
+#endif
}
void
PciStateLeave(void)
{
- pciAccPtr paccp;
- int i = 0;
+#if 0
+ unsigned i;
- if (xf86PciAccInfo == NULL)
+ if (xf86PciVideoInfo == NULL)
return;
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl)
- continue;
- savePciState(paccp->arg.tag, &paccp->restore);
- restorePciState(paccp->arg.tag, &paccp->save);
+ for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) {
+ pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data;
+
+ if ( (paccp != NULL) && paccp->ctrl ) {
+ savePciState(paccp->arg.dev, &paccp->restore);
+ restorePciState(paccp->arg.dev, &paccp->save);
+ }
}
+#endif
}
void
PciBusStateLeave(void)
{
+#if 0
BusAccPtr pbap = xf86BusAccInfo;
while (pbap) {
@@ -2809,27 +663,32 @@ PciBusStateLeave(void)
pbap->restore_f(pbap);
pbap = pbap->next;
}
+#endif
}
void
DisablePciAccess(void)
{
- int i = 0;
- pciAccPtr paccp;
- if (xf86PciAccInfo == NULL)
+#if 0
+ unsigned i;
+
+ if (xf86PciVideoInfo == NULL)
return;
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl) /* disable devices that are under control initially*/
- continue;
- pciIo_MemAccessDisable(paccp->io_memAccess.arg);
+ for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) {
+ pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data;
+
+ if ( (paccp != NULL) && paccp->ctrl ) {
+ pciIo_MemAccessDisable(paccp->io_memAccess.arg);
+ }
}
+#endif
}
void
DisablePciBusAccess(void)
{
+#if 0
BusAccPtr pbap = xf86BusAccInfo;
while (pbap) {
@@ -2839,26 +698,7 @@ DisablePciBusAccess(void)
pbap->primary->current = NULL;
pbap = pbap->next;
}
-}
-
-/*
- * Public functions
- */
-
-_X_EXPORT Bool
-xf86IsPciDevPresent(int bus, int dev, int func)
-{
- int i = 0;
- pciConfigPtr pcp;
-
- while ((pcp = xf86PciInfo[i]) != NULL) {
- if ((pcp->busnum == bus)
- && (pcp->devnum == dev)
- && (pcp->funcnum == func))
- return TRUE;
- i++;
- }
- return FALSE;
+#endif
}
/*
@@ -2867,42 +707,35 @@ xf86IsPciDevPresent(int bus, int dev, int func)
*/
_X_EXPORT int
-xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
int chipset, GDevPtr dev, Bool active)
{
EntityPtr p = NULL;
- pciAccPtr *ppaccp = xf86PciAccInfo;
+ pciAccPtr paccp = (pciAccPtr) d->user_data;
BusAccPtr pbap = xf86BusAccInfo;
+ const unsigned bus = PCI_MAKE_BUS(d->domain, d->bus);
int num;
- if (xf86CheckPciSlot(bus, device, func)) {
+ if (xf86CheckPciSlot(d)) {
num = xf86AllocateEntity();
p = xf86Entities[num];
p->driver = drvp;
p->chipset = chipset;
- p->busType = BUS_PCI;
- p->pciBusId.bus = bus;
- p->pciBusId.device = device;
- p->pciBusId.func = func;
+ p->bus.type = BUS_PCI;
+ p->bus.id.pci = d;
p->active = active;
p->inUse = FALSE;
if (dev)
xf86AddDevToEntity(num, dev);
/* Here we initialize the access structure */
p->access = xnfcalloc(1,sizeof(EntityAccessRec));
- while (ppaccp && *ppaccp) {
- if ((*ppaccp)->busnum == bus
- && (*ppaccp)->devnum == device
- && (*ppaccp)->funcnum == func) {
- p->access->fallback = &(*ppaccp)->io_memAccess;
- p->access->pAccess = &(*ppaccp)->io_memAccess;
- (*ppaccp)->ctrl = TRUE; /* mark control if not already */
- break;
- }
- ppaccp++;
+ if (paccp != NULL) {
+ p->access->fallback = & paccp->io_memAccess;
+ p->access->pAccess = & paccp->io_memAccess;
+ paccp->ctrl = TRUE; /* mark control if not already */
}
- if (!ppaccp || !*ppaccp) {
+ else {
p->access->fallback = &AccessNULL;
p->access->pAccess = &AccessNULL;
}
@@ -2913,16 +746,12 @@ xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
p->busAcc = pbap;
pbap = pbap->next;
}
- fixPciSizeInfo(num);
- /* in case bios is enabled disable it */
- disablePciBios(pciTag(bus,device,func));
pciSlotClaimed = TRUE;
if (active) {
/* Map in this domain's I/O space */
- p->domainIO = xf86MapDomainIO(-1, VIDMEM_MMIO,
- pciTag(bus, device, func), 0, 1);
+ p->domainIO = xf86MapLegacyIO(d);
}
return num;
@@ -2931,138 +760,6 @@ xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
}
/*
- * Get xf86PciVideoInfo for a driver.
- */
-_X_EXPORT pciVideoPtr *
-xf86GetPciVideoInfo(void)
-{
- return xf86PciVideoInfo;
-}
-
-/* --- Used by ATI driver, but also more generally useful */
-
-/*
- * Get the full xf86scanpci data.
- */
-_X_EXPORT pciConfigPtr *
-xf86GetPciConfigInfo(void)
-{
- return xf86PciInfo;
-}
-
-/*
- * Enable a device and route VGA to it. This is intended for a driver's
- * Probe(), before creating EntityRec's. Only one device can be thus enabled
- * at any one time, and should be disabled when the driver is done with it.
- *
- * The following special calls are also available:
- *
- * pvp == NULL && rt == NONE disable previously enabled device
- * pvp != NULL && rt == NONE ensure device is disabled
- * pvp == NULL && rt != NONE disable >all< subsequent calls to this function
- * (done from xf86PostProbe())
- * The last combination has been removed! To do this cleanly we have
- * to implement stages and need to test at each stage dependent function
- * if it is allowed to execute.
- *
- * The device represented by pvp may not have been previously claimed.
- */
-_X_EXPORT void
-xf86SetPciVideo(pciVideoPtr pvp, resType rt)
-{
- static BusAccPtr pbap = NULL;
- static xf86AccessPtr pAcc = NULL;
- static Bool DoneProbes = FALSE;
- pciAccPtr pcaccp;
- int i;
-
- if (DoneProbes)
- return;
-
- /* Disable previous access */
- if (pAcc) {
- if (pAcc->AccessDisable)
- (*pAcc->AccessDisable)(pAcc->arg);
- pAcc = NULL;
- }
- if (pbap) {
- while (pbap->primary) {
- if (pbap->disable_f)
- (*pbap->disable_f)(pbap);
- pbap->primary->current = NULL;
- pbap = pbap->primary;
- }
- pbap = NULL;
- }
-
- /* Check for xf86PostProbe's magic combo */
- if (!pvp) {
- if (rt != NONE)
- DoneProbes = TRUE;
- return;
- }
-
- /* Validate device */
- if (!xf86PciVideoInfo || !xf86PciAccInfo || !xf86BusAccInfo)
- return;
-
- for (i = 0; pvp != xf86PciVideoInfo[i]; i++)
- if (!xf86PciVideoInfo[i])
- return;
-
- /* Ignore request for claimed adapters */
- if (!xf86CheckPciSlot(pvp->bus, pvp->device, pvp->func))
- return;
-
- /* Find pciAccRec structure */
- for (i = 0; ; i++) {
- if (!(pcaccp = xf86PciAccInfo[i]))
- return;
- if ((pvp->bus == pcaccp->busnum) &&
- (pvp->device == pcaccp->devnum) &&
- (pvp->func == pcaccp->funcnum))
- break;
- }
-
- if (rt == NONE) {
- /* This is a call to ensure the adapter is disabled */
- if (pcaccp->io_memAccess.AccessDisable)
- (*pcaccp->io_memAccess.AccessDisable)(pcaccp->io_memAccess.arg);
- return;
- }
-
- /* Find BusAccRec structure */
- for (pbap = xf86BusAccInfo; ; pbap = pbap->next) {
- if (!pbap)
- return;
- if (pvp->bus == pbap->busdep.pci.bus)
- break;
- }
-
- /* Route VGA */
- if (pbap->set_f)
- (*pbap->set_f)(pbap);
-
- /* Enable device */
- switch (rt) {
- case IO:
- pAcc = &pcaccp->ioAccess;
- break;
- case MEM_IO:
- pAcc = &pcaccp->io_memAccess;
- break;
- case MEM:
- pAcc = &pcaccp->memAccess;
- break;
- default: /* no compiler noise */
- break;
- }
-
- if (pAcc && pAcc->AccessEnable)
- (*pAcc->AccessEnable)(pAcc->arg);
-}
-
-/*
* Parse a BUS ID string, and return the PCI bus parameters if it was
* in the correct format for a PCI bus id.
*/
@@ -3159,54 +856,24 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
*/
_X_EXPORT Bool
-xf86IsPrimaryPci(pciVideoPtr pPci)
+xf86IsPrimaryPci(struct pci_device *pPci)
{
- if (primaryBus.type != BUS_PCI) return FALSE;
- return (pPci->bus == primaryBus.id.pci.bus &&
- pPci->device == primaryBus.id.pci.device &&
- pPci->func == primaryBus.id.pci.func);
+ return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
}
/*
* xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
*/
-_X_EXPORT pciVideoPtr
+_X_EXPORT struct pci_device *
xf86GetPciInfoForEntity(int entityIndex)
{
- pciVideoPtr *ppPci;
EntityPtr p;
if (entityIndex >= xf86NumEntities)
return NULL;
p = xf86Entities[entityIndex];
- if (p->busType != BUS_PCI)
- return NULL;
-
- for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
- if (p->pciBusId.bus == (*ppPci)->bus &&
- p->pciBusId.device == (*ppPci)->device &&
- p->pciBusId.func == (*ppPci)->func)
- return (*ppPci);
- }
- return NULL;
-}
-
-_X_EXPORT int
-xf86GetPciEntity(int bus, int dev, int func)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- EntityPtr p = xf86Entities[i];
- if (p->busType != BUS_PCI) continue;
-
- if (p->pciBusId.bus == bus &&
- p->pciBusId.device == dev &&
- p->pciBusId.func == func)
- return i;
- }
- return -1;
+ return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
}
/*
@@ -3214,12 +881,12 @@ xf86GetPciEntity(int bus, int dev, int func)
* PCI base address register values for the given PCI device.
*/
_X_EXPORT Bool
-xf86CheckPciMemBase(pciVideoPtr pPci, memType base)
+xf86CheckPciMemBase( struct pci_device * pPci, memType base )
{
int i;
for (i = 0; i < 6; i++)
- if (base == pPci->memBase[i])
+ if (base == pPci->regions[i].base_addr)
return TRUE;
return FALSE;
}
@@ -3229,154 +896,32 @@ xf86CheckPciMemBase(pciVideoPtr pPci, memType base)
*/
_X_EXPORT Bool
-xf86CheckPciSlot(int bus, int device, int func)
+xf86CheckPciSlot(const struct pci_device *d)
{
int i;
- EntityPtr p;
for (i = 0; i < xf86NumEntities; i++) {
- p = xf86Entities[i];
- /* Check if this PCI slot is taken */
- if (p->busType == BUS_PCI && p->pciBusId.bus == bus &&
- p->pciBusId.device == device && p->pciBusId.func == func)
+ const EntityPtr p = xf86Entities[i];
+
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
return FALSE;
+ }
}
-
return TRUE;
}
-/*
- * xf86FindPciVendorDevice() xf86FindPciClass(): These functions
- * are meant to be used by the pci bios emulation. Some bioses
- * need to see if there are _other_ chips of the same type around
- * so by setting pvp_exclude one pci device can be explicitely
- * _excluded if required.
- */
-_X_EXPORT pciVideoPtr
-xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
- char n, pciVideoPtr pvp_exclude)
-{
- pciVideoPtr pvp, *ppvp;
- n++;
-
- for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) {
- if (pvp == pvp_exclude) continue;
- if ((pvp->vendor == vendorID) && (pvp->chipType == deviceID)) {
- if (!(--n)) break;
- }
- }
- return pvp;
-}
-
-_X_EXPORT pciVideoPtr
-xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
- char n, pciVideoPtr pvp_exclude)
-{
- pciVideoPtr pvp, *ppvp;
- n++;
-
- for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) {
- if (pvp == pvp_exclude) continue;
- if ((pvp->interface == intf) && (pvp->subclass == subClass)
- && (pvp->class == class)) {
- if (!(--n)) break;
- }
- }
- return pvp;
-}
-
-/*
- * This attempts to detect a multi-device card and sets up a list
- * of pci tags of the devices of this card. On some of these
- * cards the BIOS is not visible from all chipsets. We therefore
- * need to use the BIOS from a chipset where it is visible.
- * We do the following heuristics:
- * If we detect only identical pci devices on a bus we assume it's
- * a multi-device card. This assumption isn't true always, however.
- * One might just use identical cards on a bus. We therefore don't
- * detect this situation when we set up the PCI video info. Instead
- * we wait until an attempt to read the BIOS fails.
- */
-int
-pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag)
+void
+pciConvertRange2Host(int entityIndex, resRange *pRange)
{
- pciConfigPtr *ppcrp = xf86PciInfo;
- pciConfigPtr pcrp = NULL;
- int i,j;
- Bool multicard = FALSE;
- Bool multifunc = FALSE;
- char str[256];
- char *str1;
-
- str1 = str;
- if (!pTag)
- return 0;
-
- *pTag = NULL;
-
- for (i=0; i < 8; i++) {
- j = 0;
+ struct pci_device *const pvp = xf86GetPciInfoForEntity(entityIndex);
+ const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(pvp->domain, pvp->bus),
+ pvp->dev, pvp->func);
- while (ppcrp[j]) {
- if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i) {
- pcrp = ppcrp[j];
- break;
- }
- j++;
- }
-
- if (!pcrp) return 0;
-
- /*
- * we check all functions here: since multifunc devices need
- * to implement func 0 we catch all devices on the bus when
- * i = 0
- */
- if (pcrp->pci_header_type &0x80)
- multifunc = TRUE;
-
- j = 0;
-
- while (ppcrp[j]) {
- if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i
- && ppcrp[j]->devnum != pcrp->devnum) {
- /* don't test subsys ID here. It might be set by POST
- - however some cards might not have been POSTed */
- if (ppcrp[j]->pci_device_vendor != pcrp->pci_device_vendor
- || ppcrp[j]->pci_header_type != pcrp->pci_header_type )
- return 0;
- else
- multicard = TRUE;
- }
- j++;
- }
- if (!multifunc)
- break;
- }
-
- if (!multicard)
- return 0;
-
- j = 0;
- i = 0;
- while (ppcrp[i]) {
- if (ppcrp[i]->busnum == bus && ppcrp[i]->funcnum == func) {
- str1 += sprintf(str1,"[%x:%x:%x]",ppcrp[i]->busnum,
- ppcrp[i]->devnum,ppcrp[i]->funcnum);
- *pTag = xnfrealloc(*pTag,sizeof(PCITAG) * (j + 1));
- (*pTag)[j++] = pciTag(ppcrp[i]->busnum,
- ppcrp[i]->devnum,ppcrp[i]->funcnum);
+ if (pvp == NULL) {
+ return;
}
- i++;
- }
- xf86MsgVerb(X_INFO,3,"Multi Device Card detected: %s\n",str);
- return j;
-}
-static void
-pciTagConvertRange2Host(PCITAG tag, resRange *pRange)
-{
if (!(pRange->type & ResBus))
return;
@@ -3413,63 +958,5 @@ pciTagConvertRange2Host(PCITAG tag, resRange *pRange)
/* Set domain number */
pRange->type &= ~(ResDomain | ResBus);
- pRange->type |= xf86GetPciDomain(tag) << 24;
-}
-
-static void
-pciConvertListToHost(int bus, int dev, int func, resPtr list)
-{
- PCITAG tag = pciTag(bus,dev,func);
- while (list) {
- pciTagConvertRange2Host(tag, &list->val);
- list = list->next;
- }
-}
-
-static void
-updateAccessInfoStatusControlInfo(PCITAG tag, CARD32 ctrl)
-{
- int i;
-
- if (!xf86PciAccInfo)
- return;
-
- for (i = 0; xf86PciAccInfo[i] != NULL; i++) {
- if (xf86PciAccInfo[i]->arg.tag == tag)
- xf86PciAccInfo[i]->arg.ctrl = ctrl;
- }
-}
-
-void
-pciConvertRange2Host(int entityIndex, resRange *pRange)
-{
- PCITAG tag;
- pciVideoPtr pvp;
-
- pvp = xf86GetPciInfoForEntity(entityIndex);
- if (!pvp) return;
- tag = TAG(pvp);
- pciTagConvertRange2Host(tag, pRange);
-}
-
-
-#ifdef INCLUDE_DEPRECATED
-_X_EXPORT void
-xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable)
-{
- CARD32 temp;
- PCITAG tag;
-
- if (!pPci) return;
-
- tag = pciTag(pPci->bus, pPci->device, pPci->func);
- temp = pciReadLong(tag, PCI_CMD_STAT_REG);
- if (enable) {
- updateAccessInfoStatusControlInfo(tag, temp | PCI_CMD_MASTER_ENABLE);
- pciWriteLong(tag, PCI_CMD_STAT_REG, temp | PCI_CMD_MASTER_ENABLE);
- } else {
- updateAccessInfoStatusControlInfo(tag, temp & ~PCI_CMD_MASTER_ENABLE);
- pciWriteLong(tag, PCI_CMD_STAT_REG, temp & ~PCI_CMD_MASTER_ENABLE);
- }
+ pRange->type |= pvp->domain << 24;
}
-#endif /* INCLUDE_DEPRECATED */
diff --git a/xserver/hw/xfree86/common/xf86pciBus.h b/xserver/hw/xfree86/common/xf86pciBus.h
index 90d9dd9b9..7d08502fc 100644
--- a/xserver/hw/xfree86/common/xf86pciBus.h
+++ b/xserver/hw/xfree86/common/xf86pciBus.h
@@ -42,14 +42,11 @@ typedef struct {
} pciSave, *pciSavePtr;
typedef struct {
- PCITAG tag;
+ struct pci_device * dev;
CARD32 ctrl;
} pciArg;
typedef struct {
- int busnum;
- int devnum;
- int funcnum;
pciArg arg;
xf86AccessRec ioAccess;
xf86AccessRec io_memAccess;
@@ -63,24 +60,7 @@ typedef union {
CARD16 control;
} pciBridgesSave, *pciBridgesSavePtr;
-typedef struct pciBusRec {
- int brbus, brdev, brfunc; /* ID of the bridge to this bus */
- int primary, secondary, subordinate;
- int subclass; /* bridge type */
- int interface;
- resPtr preferred_io; /* I/O range */
- resPtr preferred_mem; /* non-prefetchable memory range */
- resPtr preferred_pmem; /* prefetchable memory range */
- resPtr io; /* for subtractive PCI-PCI bridges */
- resPtr mem;
- resPtr pmem;
- int brcontrol; /* bridge_control byte */
- struct pciBusRec *next;
-} PciBusRec, *PciBusPtr;
-
void xf86PciProbe(void);
-void ValidatePci(void);
-resList GetImplicitPciResources(int entityIndex);
void initPciState(void);
void initPciBusState(void);
void DisablePciAccess(void);
@@ -89,10 +69,7 @@ void PciStateEnter(void);
void PciBusStateEnter(void);
void PciStateLeave(void);
void PciBusStateLeave(void);
-resPtr ResourceBrokerInitPci(resPtr *osRes);
void pciConvertRange2Host(int entityIndex, resRange *pRange);
void isaConvertRange2Host(resRange *pRange);
-extern pciAccPtr * xf86PciAccInfo;
-
#endif /* _XF86_PCI_BUS_H */
diff --git a/xserver/hw/xfree86/common/xf86sbusBus.c b/xserver/hw/xfree86/common/xf86sbusBus.c
index 2e06ffac4..63d1cb31c 100644
--- a/xserver/hw/xfree86/common/xf86sbusBus.c
+++ b/xserver/hw/xfree86/common/xf86sbusBus.c
@@ -602,8 +602,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
pScrn->virtualY = psdp->height;
}
-static int sbusPaletteIndex = -1;
-static unsigned long sbusPaletteGeneration = 0;
+static DevPrivateKey sbusPaletteKey = &sbusPaletteKey;
typedef struct _sbusCmap {
sbusDevicePtr psdp;
CloseScreenProcPtr CloseScreen;
@@ -613,7 +612,8 @@ typedef struct _sbusCmap {
unsigned char origBlue[16];
} sbusCmapRec, *sbusCmapPtr;
-#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr))
+#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey))
static void
xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
@@ -622,7 +622,7 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
int i, index;
sbusCmapPtr cmap;
struct fbcmap fbcmap;
- unsigned char *data = ALLOCATE_LOCAL(numColors*3);
+ unsigned char *data = xalloc(numColors*3);
cmap = SBUSCMAPPTR(pScrn->pScreen);
if (!cmap) return;
@@ -643,7 +643,7 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
fbcmap.blue[fbcmap.count++] = colors[index].blue;
}
ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
- DEALLOCATE_LOCAL(data);
+ xfree(data);
}
static Bool
@@ -673,13 +673,8 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
struct fbcmap fbcmap;
unsigned char data[2];
- if(sbusPaletteGeneration != serverGeneration) {
- if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- sbusPaletteGeneration = serverGeneration;
- }
cmap = xnfcalloc(1, sizeof(sbusCmapRec));
- pScreen->devPrivates[sbusPaletteIndex].ptr = cmap;
+ dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
cmap->psdp = psdp;
fbcmap.index = 0;
fbcmap.count = 16;
diff --git a/xserver/hw/xfree86/common/xf86str.h b/xserver/hw/xfree86/common/xf86str.h
index 6e62e52ff..fc94284cb 100644
--- a/xserver/hw/xfree86/common/xf86str.h
+++ b/xserver/hw/xfree86/common/xf86str.h
@@ -43,11 +43,21 @@
#include "xf86Opt.h"
#include "xf86Pci.h"
-/*
- * memType is of the size of the addressable memory (machine size)
- * usually unsigned long.
+#include <pciaccess.h>
+
+/**
+ * Integer type that is of the size of the addressable memory (machine size).
+ * On most platforms \c uintptr_t will suffice. However, on some mixed
+ * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this
+ * must be 64-bits.
*/
-typedef unsigned long memType;
+#include <inttypes.h>
+#if defined(__powerpc__)
+typedef uint64_t memType;
+#else
+typedef uintptr_t memType;
+#endif
+
/* Video mode flags */
@@ -115,6 +125,7 @@ typedef enum {
MODE_ONE_HEIGHT, /* only one height is supported */
MODE_ONE_SIZE, /* only one resolution is supported */
MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
+ MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
MODE_BAD = -2, /* unspecified reason */
MODE_ERROR = -1 /* error condition */
} ModeStatus;
@@ -132,6 +143,7 @@ typedef enum {
# define M_T_DEFAULT 0x10 /* (VESA) default modes */
# define M_T_USERDEF 0x20 /* One of the modes from the config file */
# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
+# define M_T_USERPREF 0x80 /* mode preferred by the user config */
/* Video mode */
typedef struct _DisplayModeRec {
@@ -307,6 +319,9 @@ typedef struct {
int refCount;
} DriverRec1;
+struct _SymTabRec;
+struct _PciChipsets;
+
typedef struct _DriverRec {
int driverVersion;
char * driverName;
@@ -316,6 +331,10 @@ typedef struct _DriverRec {
pointer module;
int refCount;
xorgDriverFuncProc *driverFunc;
+
+ const struct pci_id_match * supported_devices;
+ Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
+ struct pci_device * dev, intptr_t match_data );
} DriverRec, *DriverPtr;
/*
@@ -329,7 +348,7 @@ typedef struct _DriverRec {
* functions to configuration tools, the Xserver, or any other
* application/module interested in such information.
*/
-typedef struct _ModuleInfoRec {
+_X_DEPRECATED typedef struct _ModuleInfoRec {
int moduleVersion;
char * moduleName;
pointer module;
@@ -361,11 +380,7 @@ typedef enum {
BUS_last /* Keep last */
} BusType;
-typedef struct {
- int bus;
- int device;
- int func;
-} PciBusId;
+struct pci_device;
typedef struct {
unsigned int dummy;
@@ -379,7 +394,7 @@ typedef struct _bus {
BusType type;
union {
IsaBusId isa;
- PciBusId pci;
+ struct pci_device *pci;
SbusBusId sbus;
} id;
} BusRec, *BusPtr;
@@ -431,29 +446,6 @@ typedef struct {
} IDevRec, *IDevPtr;
typedef struct {
- int vendor;
- int chipType;
- int chipRev;
- int subsysVendor;
- int subsysCard;
- int bus;
- int device;
- int func;
- int class;
- int subclass;
- int interface;
- memType memBase[6];
- memType ioBase[6];
- int size[6];
- unsigned char type[6];
- memType biosBase;
- int biosSize;
- pointer thisCard;
- Bool validSize;
- Bool validate;
-} pciVideoRec, *pciVideoPtr;
-
-typedef struct {
int frameX0;
int frameY0;
int virtualX;
@@ -526,7 +518,7 @@ typedef struct _serverlayoutrec {
char * id;
screenLayoutPtr screens;
GDevPtr inactives;
- IDevPtr inputs;
+ IDevPtr* inputs; /* NULL terminated */
pointer options;
} serverLayoutRec, *serverLayoutPtr;
@@ -735,7 +727,7 @@ typedef struct {
resRange *resList;
} IsaChipsets;
-typedef struct {
+typedef struct _PciChipsets {
/**
* Key used to match this device with its name in an array of
* \c SymTabRec.
@@ -1064,7 +1056,7 @@ typedef struct {
);
} DGAFunctionRec, *DGAFunctionPtr;
-typedef struct {
+typedef struct _SymTabRec {
int token; /* id of the token */
const char * name; /* token name */
} SymTabRec, *SymTabPtr;
diff --git a/xserver/hw/xfree86/common/xf86xv.c b/xserver/hw/xfree86/common/xf86xv.c
index 89cb6bac4..7483e20d2 100644
--- a/xserver/hw/xfree86/common/xf86xv.c
+++ b/xserver/hw/xfree86/common/xf86xv.c
@@ -110,23 +110,22 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-int XF86XVWindowIndex = -1;
-int XF86XvScreenIndex = -1;
-static unsigned long XF86XVGeneration = 0;
+static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey;
+DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
-int (*XvGetScreenIndexProc)(void) = NULL;
+DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
unsigned long (*XvGetRTPortProc)(void) = NULL;
int (*XvScreenInitProc)(ScreenPtr) = NULL;
#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr))
+ ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
#define GET_XF86XV_WINDOW(pWin) \
- ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr))
+ ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -233,21 +232,12 @@ xf86XVScreenInit(
XvScreenPtr pxvs;
if(num <= 0 ||
- !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
-
- if(XF86XVGeneration != serverGeneration) {
- if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- XF86XVGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0))
+ !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
- XF86XvScreenIndex = (*XvGetScreenIndexProc)();
+ XF86XvScreenKey = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -974,10 +964,14 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(!winPriv) {
winPriv = xalloc(sizeof(XF86XVWindowRec));
if(!winPriv) return BadAlloc;
+ memset(winPriv, 0, sizeof(XF86XVWindowRec));
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
- pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
}
+
+ portPriv->pDraw = (DrawablePtr)pWin;
+
return Success;
}
@@ -994,8 +988,8 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(prevPriv)
prevPriv->next = winPriv->next;
else
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)winPriv->next;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ winPriv->next);
xfree(winPriv);
break;
}
@@ -1026,11 +1020,14 @@ xf86XVDestroyWindow(WindowPtr pWin)
pPriv->pDraw = NULL;
tmp = WinPriv;
+ if(WinPriv->pGC) {
+ FreeGC(WinPriv->pGC, 0);
+ }
WinPriv = WinPriv->next;
xfree(tmp);
}
- pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow)(pWin);
@@ -1087,8 +1084,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1118,6 +1115,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
while(WinPriv) {
pPriv = WinPriv->PortRec;
+ if(!pPriv) goto next;
+
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
REGION_DESTROY(pScreen, pPriv->pCompositeClip);
@@ -1137,8 +1136,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1148,6 +1147,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
}
}
+next:
pPrev = WinPriv;
WinPriv = WinPriv->next;
}
@@ -1368,7 +1368,6 @@ xf86XVPutVideo(
result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(result != Success) return result;
- portPriv->pDraw = pDraw;
portPriv->type = XvInputMask;
/* save a copy of these parameters */
@@ -1472,7 +1471,6 @@ xf86XVPutStill(
xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
portPriv->isOn = XV_ON;
- portPriv->pDraw = pDraw;
portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
portPriv->type = 0; /* no mask means it's transient and should
@@ -1522,7 +1520,6 @@ xf86XVGetVideo(
result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(result != Success) return result;
- portPriv->pDraw = pDraw;
portPriv->type = XvOutputMask;
/* save a copy of these parameters */
@@ -1739,9 +1736,13 @@ xf86XVPutImage(
REGION_UNINIT(pScreen, &VPReg);
}
- if(portPriv->pDraw) {
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
+
+ /* Register our port with the new window */
+ ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(ret != Success) goto PUT_IMAGE_BAILOUT;
if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
clippedAway = TRUE;
@@ -1772,9 +1773,7 @@ xf86XVPutImage(
if((ret == Success) &&
(portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
- xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
portPriv->isOn = XV_ON;
- portPriv->pDraw = pDraw;
portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
portPriv->type = 0; /* no mask means it's transient and should
@@ -1813,11 +1812,14 @@ xf86XVQueryImageAttributes(
format->id, width, height, pitches, offsets);
}
+
_X_EXPORT void
-xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
+xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
{
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+ ScreenPtr pScreen = pDraw->pScreen;
+ WindowPtr pWin = (WindowPtr)pDraw;
+ XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin);
+ GCPtr pGC = NULL;
XID pval[2];
BoxPtr pbox = REGION_RECTS(clipboxes);
int i, nbox = REGION_NUM_RECTS(clipboxes);
@@ -1825,21 +1827,27 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
if(!xf86Screens[pScreen->myNum]->vtSema) return;
- if(!ScreenPriv->videoGC) {
+ if(pPriv)
+ pGC = pPriv->pGC;
+
+ if(!pGC) {
int status;
pval[0] = key;
pval[1] = IncludeInferiors;
- ScreenPriv->videoGC = CreateGC(root, GCForeground | GCSubwindowMode,
- pval, &status);
- if(!ScreenPriv->videoGC) return;
- ValidateGC(root, ScreenPriv->videoGC);
- } else if (key != ScreenPriv->videoGC->fgPixel){
+ pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status,
+ (XID)0, serverClient);
+ if(!pGC) return;
+ ValidateGC(pDraw, pGC);
+ if (pPriv) pPriv->pGC = pGC;
+ } else if (key != pGC->fgPixel){
pval[0] = key;
- ChangeGC(ScreenPriv->videoGC, GCForeground, pval);
- ValidateGC(root, ScreenPriv->videoGC);
+ ChangeGC(pGC, GCForeground, pval);
+ ValidateGC(pDraw, pGC);
}
- rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+ REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y);
+
+ rects = xalloc(nbox * sizeof(xRectangle));
for(i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1;
@@ -1848,10 +1856,45 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
rects[i].height = pbox->y2 - pbox->y1;
}
- (*ScreenPriv->videoGC->ops->PolyFillRect)(
- root, ScreenPriv->videoGC, nbox, rects);
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nbox, rects);
+
+ if (!pPriv) FreeGC(pGC, 0);
- DEALLOCATE_LOCAL(rects);
+ xfree(rects);
+}
+
+_X_EXPORT void
+xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
+{
+ DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+ XID pval[2];
+ BoxPtr pbox = REGION_RECTS(clipboxes);
+ int i, nbox = REGION_NUM_RECTS(clipboxes);
+ xRectangle *rects;
+ GCPtr gc;
+
+ if(!xf86Screens[pScreen->myNum]->vtSema) return;
+
+ gc = GetScratchGC(root->depth, pScreen);
+ pval[0] = key;
+ pval[1] = IncludeInferiors;
+ (void) ChangeGC(gc, GCForeground|GCSubwindowMode, pval);
+ ValidateGC(root, gc);
+
+ rects = xalloc (nbox * sizeof(xRectangle));
+
+ for(i = 0; i < nbox; i++, pbox++)
+ {
+ rects[i].x = pbox->x1;
+ rects[i].y = pbox->y1;
+ rects[i].width = pbox->x2 - pbox->x1;
+ rects[i].height = pbox->y2 - pbox->y1;
+ }
+
+ (*gc->ops->PolyFillRect)(root, gc, nbox, rects);
+
+ xfree (rects);
+ FreeScratchGC (gc);
}
/* xf86XVClipVideoHelper -
diff --git a/xserver/hw/xfree86/common/xf86xvmc.c b/xserver/hw/xfree86/common/xf86xvmc.c
index f8ff0bed4..05267a240 100644
--- a/xserver/hw/xfree86/common/xf86xvmc.c
+++ b/xserver/hw/xfree86/common/xf86xvmc.c
@@ -56,11 +56,10 @@ typedef struct {
XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-static unsigned long XF86XvMCGeneration = 0;
-static int XF86XvMCScreenIndex = -1;
+static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey;
-#define XF86XVMC_GET_PRIVATE(pScreen) \
- (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr)
+#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
static int
@@ -164,19 +163,12 @@ _X_EXPORT Bool xf86XvMCScreenInit(
{
XvMCAdaptorPtr pAdapt;
xf86XvMCScreenPtr pScreenPriv;
- XvScreenPtr pxvs =
- (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
-
+ XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XF86XvScreenKey);
int i, j;
if(!XvMCScreenInitProc) return FALSE;
- if(XF86XvMCGeneration != serverGeneration) {
- if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- XF86XvMCGeneration = serverGeneration;
- }
-
if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
@@ -185,7 +177,7 @@ _X_EXPORT Bool xf86XvMCScreenInit(
return FALSE;
}
- pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86XvMCCloseScreen;
diff --git a/xserver/hw/xfree86/common/xf86xvpriv.h b/xserver/hw/xfree86/common/xf86xvpriv.h
index ced053679..4200dac80 100644
--- a/xserver/hw/xfree86/common/xf86xvpriv.h
+++ b/xserver/hw/xfree86/common/xf86xvpriv.h
@@ -30,10 +30,11 @@
#define _XF86XVPRIV_H_
#include "xf86xv.h"
+#include "privates.h"
/*** These are DDX layer privates ***/
-extern int XF86XvScreenIndex;
+extern DevPrivateKey XF86XvScreenKey;
typedef struct {
DestroyWindowProcPtr DestroyWindow;
@@ -80,6 +81,7 @@ typedef struct {
typedef struct _XF86XVWindowRec{
XvPortRecPrivatePtr PortRec;
struct _XF86XVWindowRec *next;
+ GCPtr pGC;
} XF86XVWindowRec, *XF86XVWindowPtr;
#endif /* _XF86XVPRIV_H_ */