aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r--xorg-server/hw/xfree86/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/doc/README.DRIcomp3
-rw-r--r--xorg-server/hw/xfree86/doc/Registry1
-rw-r--r--xorg-server/hw/xfree86/drivers/Makefile.am5
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/Makefile.am61
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/driver.c1113
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/driver.h81
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c1616
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h136
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/modesetting.man54
-rw-r--r--xorg-server/hw/xfree86/int10/generic.c16
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c46
-rw-r--r--xorg-server/hw/xfree86/man/xorg.conf.man6
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/Makefile.am4
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/alpha_video.c434
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/arm_video.c284
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c71
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/i386_video.c562
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/ppc_video.c56
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c40
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c94
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/hurd_video.c65
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/Makefile.am10
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/int10/linux.c19
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_axp.c103
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c6
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_video.c676
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/bios_mmap.c135
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/vidmem.c205
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/xf86Axp.c60
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/xf86Axp.h33
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_vid.c140
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/Makefile.am1
-rw-r--r--xorg-server/hw/xfree86/os-support/stub/stub_bios.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86OSpriv.h11
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86_OSproc.h26
37 files changed, 3118 insertions, 3071 deletions
diff --git a/xorg-server/hw/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am
index c5992c372..30f7c8ffd 100644
--- a/xorg-server/hw/xfree86/Makefile.am
+++ b/xorg-server/hw/xfree86/Makefile.am
@@ -38,7 +38,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
ramdac $(VGAHW_SUBDIR) loader modes $(DRI_SUBDIR) \
$(DRI2_SUBDIR) . $(VBE_SUBDIR) i2c dixmods \
fbdevhw shadowfb exa $(XF86UTILS_SUBDIR) doc man \
- $(GLAMOR_EGL_SUBDIR)
+ $(GLAMOR_EGL_SUBDIR) drivers
DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
parser ramdac shadowfb vbe vgahw \
diff --git a/xorg-server/hw/xfree86/doc/README.DRIcomp b/xorg-server/hw/xfree86/doc/README.DRIcomp
index 2d3ebf148..73886504f 100644
--- a/xorg-server/hw/xfree86/doc/README.DRIcomp
+++ b/xorg-server/hw/xfree86/doc/README.DRIcomp
@@ -142,9 +142,6 @@ Here are the basic steps for kernel setup.
o Enable all chipsets' support for AGP
- o It's recommended that you turn on MTRRs under Processor type and
- Features, but not required.
-
o Configure the rest of the kernel as required for your system (i.e. Eth-
ernet, SCSI, etc)
diff --git a/xorg-server/hw/xfree86/doc/Registry b/xorg-server/hw/xfree86/doc/Registry
index 48e24a2f4..ad5b9bffb 100644
--- a/xorg-server/hw/xfree86/doc/Registry
+++ b/xorg-server/hw/xfree86/doc/Registry
@@ -231,7 +231,6 @@ DDC B C Enable/disable DDC
DDC1 B C Enable/disable DDC1
DDC2 B C Enable/disable DDC2
DPMS O C Enable DPMS
-MTRR B C Enable/disable setting MTRRs
BaudRate I I Serial port baud rate
ButtonNumber I I Button number (for touch screen?)
diff --git a/xorg-server/hw/xfree86/drivers/Makefile.am b/xorg-server/hw/xfree86/drivers/Makefile.am
new file mode 100644
index 000000000..04d787f52
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/Makefile.am
@@ -0,0 +1,5 @@
+SUBDIRS =
+
+if XORG_DRIVER_MODESETTING
+SUBDIRS += modesetting
+endif
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am b/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am
new file mode 100644
index 000000000..ca3279e23
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am
@@ -0,0 +1,61 @@
+# Copyright 2005 Adam Jackson.
+#
+# 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
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+# ADAM JACKSON 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.
+
+# this is obnoxious:
+# -module lets us name the module exactly how we want
+# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
+# _ladir passes a dummy rpath to libtool so the thing will actually link
+# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS) $(UDEV_CFLAGS) $(CWARNFLAGS)
+
+AM_CPPFLAGS = \
+ $(XORG_INCS) \
+ -I$(srcdir)/../../ddc \
+ -I$(srcdir)/../../i2c \
+ -I$(srcdir)/../../modes \
+ -I$(srcdir)/../../parser \
+ -I$(srcdir)/../../ramdac \
+ $(NULL)
+
+modesetting_drv_la_LTLIBRARIES = modesetting_drv.la
+modesetting_drv_la_LDFLAGS = -module -avoid-version
+modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS)
+modesetting_drv_ladir = @moduledir@/drivers
+
+modesetting_drv_la_SOURCES = \
+ driver.c \
+ driver.h \
+ drmmode_display.c \
+ drmmode_display.h
+
+drivermandir = $(DRIVER_MAN_DIR)
+driverman_PRE = modesetting.man
+driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
+
+EXTRA_DIST = modesetting.man
+
+CLEANFILES = $(driverman_DATA)
+
+# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+.man.$(DRIVER_MAN_SUFFIX):
+ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
new file mode 100644
index 000000000..adfb69c9f
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
@@ -0,0 +1,1113 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2011 Dave Airlie
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ *
+ * Original Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Rewrite: Dave Airlie <airlied@redhat.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86Pci.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include <X11/extensions/randr.h>
+#include "fb.h"
+#include "edid.h"
+#include "xf86i2c.h"
+#include "xf86Crtc.h"
+#include "miscstruct.h"
+#include "dixstruct.h"
+#include "shadow.h"
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+#include <xorg-config.h>
+#ifdef XSERVER_PLATFORM_BUS
+#include "xf86platformBus.h"
+#endif
+#if XSERVER_LIBPCIACCESS
+#include <pciaccess.h>
+#endif
+
+#include "driver.h"
+
+static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
+static Bool CloseScreen(ScreenPtr pScreen);
+static Bool EnterVT(ScrnInfoPtr pScrn);
+static void Identify(int flags);
+static const OptionInfoRec *AvailableOptions(int chipid, int busid);
+static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose,
+ int flags);
+static void FreeScreen(ScrnInfoPtr pScrn);
+static void LeaveVT(ScrnInfoPtr pScrn);
+static Bool SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static Bool ScreenInit(ScreenPtr pScreen, int argc, char **argv);
+static Bool PreInit(ScrnInfoPtr pScrn, int flags);
+
+static Bool Probe(DriverPtr drv, int flags);
+static Bool ms_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *device,
+ intptr_t match_data);
+static Bool ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op,
+ void *data);
+
+#ifdef XSERVER_LIBPCIACCESS
+static const struct pci_id_match ms_device_match[] = {
+ {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+ 0x00030000, 0x00ff0000, 0
+ },
+
+ { 0, 0, 0 },
+};
+#endif
+
+#ifdef XSERVER_PLATFORM_BUS
+static Bool ms_platform_probe(DriverPtr driver,
+ int entity_num, int flags, struct xf86_platform_device *device,
+ intptr_t match_data);
+#endif
+
+_X_EXPORT DriverRec modesetting = {
+ 1,
+ "modesetting",
+ Identify,
+ Probe,
+ AvailableOptions,
+ NULL,
+ 0,
+ ms_driver_func,
+ ms_device_match,
+ ms_pci_probe,
+#ifdef XSERVER_PLATFORM_BUS
+ ms_platform_probe,
+#endif
+};
+
+static SymTabRec Chipsets[] = {
+ {0, "kms" },
+ {-1, NULL}
+};
+
+typedef enum
+{
+ OPTION_SW_CURSOR,
+ OPTION_DEVICE_PATH,
+ OPTION_SHADOW_FB,
+} modesettingOpts;
+
+static const OptionInfoRec Options[] = {
+ {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE },
+ {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
+ {-1, NULL, OPTV_NONE, {0}, FALSE}
+};
+
+int modesettingEntityIndex = -1;
+
+static MODULESETUPPROTO(Setup);
+
+static XF86ModuleVersionInfo VersRec = {
+ "modesetting",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR,
+ XORG_VERSION_PATCH,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL };
+
+static void *
+Setup(void * module, void * opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+
+ /* This module should be loaded only once, but check to be sure.
+ */
+ if (!setupDone) {
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (void *) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+static void
+Identify(int flags)
+{
+ xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+ Chipsets);
+}
+
+static int open_hw(const char *dev)
+{
+ int fd;
+ if (dev)
+ fd = open(dev, O_RDWR, 0);
+ else {
+ dev = getenv("KMSDEVICE");
+ if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+ dev = "/dev/dri/card0";
+ fd = open(dev,O_RDWR, 0);
+ }
+ }
+ if (fd == -1)
+ xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno));
+
+ return fd;
+}
+
+static int check_outputs(int fd)
+{
+ drmModeResPtr res = drmModeGetResources(fd);
+ int ret;
+
+ if (!res)
+ return FALSE;
+ ret = res->count_connectors > 0;
+ drmModeFreeResources(res);
+ return ret;
+}
+
+static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
+{
+ int fd;
+
+#if XF86_PDEV_SERVER_FD
+ if (platform_dev && (platform_dev->flags & XF86_PDEV_SERVER_FD)) {
+ fd = xf86_platform_device_odev_attributes(platform_dev)->fd;
+ if (fd == -1)
+ return FALSE;
+ return check_outputs(fd);
+ }
+#endif
+
+ fd = open_hw(dev);
+ if (fd != -1) {
+ int ret = check_outputs(fd);
+ close(fd);
+ return ret;
+ }
+ return FALSE;
+}
+
+static char *
+ms_DRICreatePCIBusID(const struct pci_device *dev)
+{
+ char *busID;
+
+ if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
+ dev->domain, dev->bus, dev->dev, dev->func) == -1)
+ return NULL;
+
+ return busID;
+}
+
+
+static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
+{
+ int ret = FALSE, fd = open_hw(dev);
+ char *id, *devid;
+ drmSetVersion sv;
+
+ if (fd == -1)
+ return FALSE;
+
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 4;
+ sv.drm_dd_major = -1;
+ sv.drm_dd_minor = -1;
+ if (drmSetInterfaceVersion(fd, &sv)) {
+ close(fd);
+ return FALSE;
+ }
+
+
+ id = drmGetBusid(fd);
+ devid = ms_DRICreatePCIBusID(pdev);
+
+ if (id && devid && !strcmp(id, devid))
+ ret = check_outputs(fd);
+
+ close(fd);
+ free(id);
+ free(devid);
+ return ret;
+}
+static const OptionInfoRec *
+AvailableOptions(int chipid, int busid)
+{
+ return Options;
+}
+
+static Bool
+ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
+{
+ xorgHWFlags *flag;
+
+ switch (op) {
+ case GET_REQUIRED_HW_INTERFACES:
+ flag = (CARD32 *)data;
+ (*flag) = 0;
+ return TRUE;
+ case SUPPORTS_SERVER_FDS:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+#if XSERVER_LIBPCIACCESS
+static Bool
+ms_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *dev, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+ if (scrn) {
+ const char *devpath;
+ GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
+ scrn->entityInstanceList[0]);
+
+ devpath = xf86FindOptionValue(devSection->options, "kmsdev");
+ if (probe_hw_pci(devpath, dev)) {
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modeset";
+ scrn->Probe = NULL;
+ scrn->PreInit = PreInit;
+ scrn->ScreenInit = ScreenInit;
+ scrn->SwitchMode = SwitchMode;
+ scrn->AdjustFrame = AdjustFrame;
+ scrn->EnterVT = EnterVT;
+ scrn->LeaveVT = LeaveVT;
+ scrn->FreeScreen = FreeScreen;
+ scrn->ValidMode = ValidMode;
+
+ xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
+ "claimed PCI slot %d@%d:%d:%d\n",
+ dev->bus, dev->domain, dev->dev, dev->func);
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "using %s\n", devpath ? devpath : "default device");
+ } else
+ scrn = NULL;
+ }
+ return scrn != NULL;
+}
+#endif
+
+#ifdef XSERVER_PLATFORM_BUS
+static Bool
+ms_platform_probe(DriverPtr driver,
+ int entity_num, int flags, struct xf86_platform_device *dev, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ const char *path = xf86_platform_device_odev_attributes(dev)->path;
+ int scr_flags = 0;
+
+ if (flags & PLATFORM_PROBE_GPU_SCREEN)
+ scr_flags = XF86_ALLOCATE_GPU_SCREEN;
+
+ if (probe_hw(path, dev)) {
+ scrn = xf86AllocateScreen(driver, scr_flags);
+ xf86AddEntityToScreen(scrn, entity_num);
+
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->PreInit = PreInit;
+ scrn->ScreenInit = ScreenInit;
+ scrn->SwitchMode = SwitchMode;
+ scrn->AdjustFrame = AdjustFrame;
+ scrn->EnterVT = EnterVT;
+ scrn->LeaveVT = LeaveVT;
+ scrn->FreeScreen = FreeScreen;
+ scrn->ValidMode = ValidMode;
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "using drv %s\n", path ? path : "default device");
+ }
+
+ return scrn != NULL;
+}
+#endif
+
+static Bool
+Probe(DriverPtr drv, int flags)
+{
+ int i, numDevSections;
+ GDevPtr *devSections;
+ Bool foundScreen = FALSE;
+ const char *dev;
+ ScrnInfoPtr scrn = NULL;
+
+ /* For now, just bail out for PROBE_DETECT. */
+ if (flags & PROBE_DETECT)
+ return FALSE;
+
+ /*
+ * Find the config file Device sections that match this
+ * driver, and return if there are none.
+ */
+ if ((numDevSections = xf86MatchDevice("modesetting", &devSections)) <= 0) {
+ return FALSE;
+ }
+
+ for (i = 0; i < numDevSections; i++) {
+
+ dev = xf86FindOptionValue(devSections[i]->options,"kmsdev");
+ if (probe_hw(dev, NULL)) {
+ int entity;
+ entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
+ scrn = xf86ConfigFbEntity(scrn, 0, entity,
+ NULL, NULL, NULL, NULL);
+ }
+
+ if (scrn) {
+ foundScreen = TRUE;
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->Probe = Probe;
+ scrn->PreInit = PreInit;
+ scrn->ScreenInit = ScreenInit;
+ scrn->SwitchMode = SwitchMode;
+ scrn->AdjustFrame = AdjustFrame;
+ scrn->EnterVT = EnterVT;
+ scrn->LeaveVT = LeaveVT;
+ scrn->FreeScreen = FreeScreen;
+ scrn->ValidMode = ValidMode;
+
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "using %s\n", dev ? dev : "default device");
+ }
+ }
+
+ free(devSections);
+
+ return foundScreen;
+}
+
+static Bool
+GetRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1);
+
+ return TRUE;
+}
+
+static int dispatch_dirty_region(ScrnInfoPtr scrn,
+ PixmapPtr pixmap,
+ DamagePtr damage,
+ int fb_id)
+{
+ modesettingPtr ms = modesettingPTR(scrn);
+ RegionPtr dirty = DamageRegion(damage);
+ unsigned num_cliprects = REGION_NUM_RECTS(dirty);
+
+ if (num_cliprects) {
+ drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
+ BoxPtr rect = REGION_RECTS(dirty);
+ int i, ret;
+
+ if (!clip)
+ return -ENOMEM;
+
+ /* XXX no need for copy? */
+ for (i = 0; i < num_cliprects; i++, rect++) {
+ clip[i].x1 = rect->x1;
+ clip[i].y1 = rect->y1;
+ clip[i].x2 = rect->x2;
+ clip[i].y2 = rect->y2;
+ }
+
+ /* TODO query connector property to see if this is needed */
+ ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
+ free(clip);
+ DamageEmpty(damage);
+ if (ret) {
+ if (ret == -EINVAL)
+ return ret;
+ }
+ }
+ return 0;
+}
+
+static void dispatch_dirty(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+ PixmapPtr pixmap = pScreen->GetScreenPixmap(pScreen);
+ int fb_id = ms->drmmode.fb_id;
+ int ret;
+
+ ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
+ if (ret == -EINVAL || ret == -ENOSYS) {
+ ms->dirty_enabled = FALSE;
+ DamageUnregister(ms->damage);
+ DamageDestroy(ms->damage);
+ ms->damage = NULL;
+ xf86DrvMsg(scrn->scrnIndex, X_INFO, "Disabling kernel dirty updates, not required.\n");
+ return;
+ }
+}
+
+static void dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(scrn);
+ PixmapPtr pixmap = crtc->randr_crtc->scanout_pixmap;
+ msPixmapPrivPtr ppriv = msGetPixmapPriv(&ms->drmmode, pixmap);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ DamagePtr damage = drmmode_crtc->slave_damage;
+ int fb_id = ppriv->fb_id;
+ int ret;
+
+ ret = dispatch_dirty_region(scrn, pixmap, damage, fb_id);
+ if (ret) {
+
+ }
+}
+
+static void dispatch_slave_dirty(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (!crtc->randr_crtc)
+ continue;
+ if (!crtc->randr_crtc->scanout_pixmap)
+ continue;
+
+ dispatch_dirty_crtc(scrn, crtc);
+ }
+}
+
+static void msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
+{
+ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
+
+ pScreen->BlockHandler = ms->BlockHandler;
+ pScreen->BlockHandler(pScreen, pTimeout, pReadmask);
+ pScreen->BlockHandler = msBlockHandler;
+ if (pScreen->isGPU)
+ dispatch_slave_dirty(pScreen);
+ else if (ms->dirty_enabled)
+ dispatch_dirty(pScreen);
+}
+
+static void
+FreeRec(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms;
+
+ if (!pScrn)
+ return;
+
+ ms = modesettingPTR(pScrn);
+ if (!ms)
+ return;
+ pScrn->driverPrivate = NULL;
+
+ if (ms->fd > 0) {
+ int ret;
+
+ if (ms->pEnt->location.type == BUS_PCI)
+ ret = drmClose(ms->fd);
+ else
+#ifdef XF86_PDEV_SERVER_FD
+ if (!(ms->pEnt->location.type == BUS_PLATFORM &&
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)))
+#endif
+ ret = close(ms->fd);
+ (void) ret;
+ }
+ free(ms->Options);
+ free(ms);
+
+}
+
+#ifndef DRM_CAP_CURSOR_WIDTH
+#define DRM_CAP_CURSOR_WIDTH 0x8
+#endif
+
+#ifndef DRM_CAP_CURSOR_HEIGHT
+#define DRM_CAP_CURSOR_HEIGHT 0x9
+#endif
+
+static Bool
+PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ modesettingPtr ms;
+ rgb defaultWeight = { 0, 0, 0 };
+ EntityInfoPtr pEnt;
+ EntPtr msEnt = NULL;
+ char *BusID = NULL;
+ const char *devicename;
+ Bool prefer_shadow = TRUE;
+ uint64_t value = 0;
+ int ret;
+ int bppflags;
+ int defaultdepth, defaultbpp;
+
+ if (pScrn->numEntities != 1)
+ return FALSE;
+
+ pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ if (flags & PROBE_DETECT) {
+ return FALSE;
+ }
+
+ /* Allocate driverPrivate */
+ if (!GetRec(pScrn))
+ return FALSE;
+
+ ms = modesettingPTR(pScrn);
+ ms->SaveGeneration = -1;
+ ms->pEnt = pEnt;
+
+ pScrn->displayWidth = 640; /* default it */
+
+ /* Allocate an entity private if necessary */
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+ modesettingEntityIndex)->ptr;
+ ms->entityPrivate = msEnt;
+ } else
+ ms->entityPrivate = NULL;
+
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ if (xf86IsPrimInitDone(pScrn->entityList[0])) {
+ /* do something */
+ } else {
+ xf86SetPrimInitDone(pScrn->entityList[0]);
+ }
+ }
+
+ pScrn->monitor = pScrn->confScreen->monitor;
+ pScrn->progClock = TRUE;
+ pScrn->rgbBits = 8;
+
+#if XSERVER_PLATFORM_BUS
+ if (pEnt->location.type == BUS_PLATFORM) {
+#ifdef XF86_PDEV_SERVER_FD
+ if (pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)
+ ms->fd = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->fd;
+ else
+#endif
+ {
+ char *path = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->path;
+ ms->fd = open_hw(path);
+ }
+ }
+ else
+#endif
+ if (pEnt->location.type == BUS_PCI) {
+ ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
+ if (ms->PciInfo) {
+ BusID = malloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+#if XSERVER_LIBPCIACCESS
+ ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+ ms->PciInfo->dev, ms->PciInfo->func
+#else
+ ((pciConfigPtr) ms->PciInfo->thisCard)->busnum,
+ ((pciConfigPtr) ms->PciInfo->thisCard)->devnum,
+ ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum
+#endif
+ );
+ }
+ ms->fd = drmOpen(NULL, BusID);
+ } else {
+ devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev");
+ ms->fd = open_hw(devicename);
+ }
+ if (ms->fd < 0)
+ return FALSE;
+
+ ms->drmmode.fd = ms->fd;
+
+ pScrn->capabilities = 0;
+#ifdef DRM_CAP_PRIME
+ ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value);
+ if (ret == 0) {
+ if (value & DRM_PRIME_CAP_IMPORT)
+ pScrn->capabilities |= RR_Capability_SinkOutput;
+ }
+#endif
+ drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
+ if (defaultdepth == 24 && defaultbpp == 24)
+ bppflags = SupportConvert32to24 | Support24bppFb;
+ else
+ bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
+
+ if (!xf86SetDepthBpp
+ (pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
+ return FALSE;
+
+ switch (pScrn->depth) {
+ case 15:
+ case 16:
+ case 24:
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by the driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ xf86PrintDepthBpp(pScrn);
+
+ /* Process the options */
+ xf86CollectOptions(pScrn, NULL);
+ if (!(ms->Options = malloc(sizeof(Options))))
+ return FALSE;
+ memcpy(ms->Options, Options, sizeof(Options));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
+
+ if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
+ return FALSE;
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
+ ms->drmmode.sw_cursor = TRUE;
+ }
+
+ ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
+ if (!ret) {
+ prefer_shadow = !!value;
+ }
+
+ ms->cursor_width = 64;
+ ms->cursor_height = 64;
+ ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
+ if (!ret) {
+ ms->cursor_width = value;
+ }
+ ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_HEIGHT, &value);
+ if (!ret) {
+ ms->cursor_height = value;
+ }
+
+ ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n", prefer_shadow ? "YES" : "NO", ms->drmmode.shadow_enable ? "YES" : "NO");
+ if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
+ goto fail;
+ }
+
+ /*
+ * If the driver can do gamma correction, it should call xf86SetGamma() here.
+ */
+ {
+ Gamma zeros = { 0.0, 0.0, 0.0 };
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ if (pScrn->modes == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
+ return FALSE;
+ }
+
+ pScrn->currentMode = pScrn->modes;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ /* Load the required sub modules */
+ if (!xf86LoadSubModule(pScrn, "fb")) {
+ return FALSE;
+ }
+
+ if (ms->drmmode.shadow_enable) {
+ if (!xf86LoadSubModule(pScrn, "shadow")) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ fail:
+ return FALSE;
+}
+
+static void *
+msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
+ CARD32 *size, void *closure)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(pScrn);
+ int stride;
+
+ stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
+ *size = stride;
+
+ return ((uint8_t *)ms->drmmode.front_bo->ptr + row * stride + offset);
+}
+
+static void
+msUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ shadowUpdatePacked(pScreen, pBuf);
+}
+
+static Bool
+CreateScreenResources(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(pScrn);
+ PixmapPtr rootPixmap;
+ Bool ret;
+ void *pixels;
+ pScreen->CreateScreenResources = ms->createScreenResources;
+ ret = pScreen->CreateScreenResources(pScreen);
+ pScreen->CreateScreenResources = CreateScreenResources;
+
+ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
+ return FALSE;
+
+ drmmode_uevent_init(pScrn, &ms->drmmode);
+
+ if (!ms->drmmode.sw_cursor)
+ drmmode_map_cursor_bos(pScrn, &ms->drmmode);
+ pixels = drmmode_map_front_bo(&ms->drmmode);
+ if (!pixels)
+ return FALSE;
+
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
+
+ if (ms->drmmode.shadow_enable)
+ pixels = ms->drmmode.shadow_fb;
+
+ if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
+ FatalError("Couldn't adjust screen pixmap\n");
+
+ if (ms->drmmode.shadow_enable) {
+ if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked,
+ msShadowWindow, 0, 0))
+ return FALSE;
+ }
+
+ ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
+ pScreen, rootPixmap);
+
+ if (ms->damage) {
+ DamageRegister(&rootPixmap->drawable, ms->damage);
+ ms->dirty_enabled = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to create screen damage record\n");
+ return FALSE;
+ }
+ return ret;
+}
+
+static Bool
+msShadowInit(ScreenPtr pScreen)
+{
+ if (!shadowSetup(pScreen)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static Bool
+msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
+{
+ ScreenPtr screen = ppix->drawable.pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+ Bool ret;
+ int size = ppix->devKind * ppix->drawable.height;
+ int ihandle = (int)(long)fd_handle;
+
+ ret = drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, ppix->devKind, size);
+ if (ret == FALSE)
+ return ret;
+
+ return TRUE;
+}
+
+static Bool
+SetMaster(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ int ret;
+
+#ifdef XF86_PDEV_SERVER_FD
+ if (ms->pEnt->location.type == BUS_PLATFORM &&
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+ return TRUE;
+#endif
+
+ ret = drmSetMaster(ms->fd);
+ if (ret)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "drmSetMaster failed: %s\n",
+ strerror(errno));
+
+ return ret == 0;
+}
+
+static Bool
+ScreenInit(ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(pScrn);
+ VisualPtr visual;
+
+ pScrn->pScreen = pScreen;
+
+ if (!SetMaster(pScrn))
+ return FALSE;
+
+ /* HW dependent - FIXME */
+ pScrn->displayWidth = pScrn->virtualX;
+ if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
+ return FALSE;
+
+ if (ms->drmmode.shadow_enable) {
+ ms->drmmode.shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY *
+ ((pScrn->bitsPerPixel + 7) >> 3));
+ if (!ms->drmmode.shadow_fb)
+ ms->drmmode.shadow_enable = FALSE;
+ }
+
+ miClearVisualTypes();
+
+ if (!miSetVisualTypes(pScrn->depth,
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ if (!miSetPixmapDepths())
+ return FALSE;
+
+ if (!dixRegisterScreenSpecificPrivateKey(pScreen, &ms->drmmode.pixmapPrivateKeyRec,
+ PRIVATE_PIXMAP, sizeof(msPixmapPrivRec))) {
+ return FALSE;
+ }
+
+ pScrn->memPhysBase = 0;
+ pScrn->fbOffset = 0;
+
+ if (!fbScreenInit(pScreen, NULL,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth, pScrn->bitsPerPixel))
+ return FALSE;
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
+ }
+
+ fbPictureInit(pScreen, NULL, 0);
+
+ if (ms->drmmode.shadow_enable && !msShadowInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "shadow fb init failed\n");
+ return FALSE;
+ }
+
+ ms->createScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = CreateScreenResources;
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+ /* Need to extend HWcursor support to handle mask interleave */
+ if (!ms->drmmode.sw_cursor)
+ xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+ HARDWARE_CURSOR_ARGB);
+
+ /* Must force it before EnterVT, so we are in control of VT and
+ * later memory should be bound when allocating, e.g rotate_mem */
+ pScrn->vtSema = TRUE;
+
+ pScreen->SaveScreen = xf86SaveScreen;
+ ms->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = CloseScreen;
+
+ ms->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = msBlockHandler;
+
+ pScreen->SetSharedPixmapBacking = msSetSharedPixmapBacking;
+
+ if (!xf86CrtcScreenInit(pScreen))
+ return FALSE;
+
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ xf86DPMSInit(pScreen, xf86DPMSSet, 0);
+
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+
+ return EnterVT(pScrn);
+}
+
+static void
+AdjustFrame(ScrnInfoPtr pScrn, int x, int y)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ drmmode_adjust_frame(pScrn, &ms->drmmode, x, y);
+}
+
+static void
+FreeScreen(ScrnInfoPtr pScrn)
+{
+ FreeRec(pScrn);
+}
+
+static void
+LeaveVT(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ xf86_hide_cursors(pScrn);
+
+ pScrn->vtSema = FALSE;
+
+#ifdef XF86_PDEV_SERVER_FD
+ if (ms->pEnt->location.type == BUS_PLATFORM &&
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+ return;
+#endif
+
+ drmDropMaster(ms->fd);
+}
+
+/*
+ * This gets called when gaining control of the VT, and from ScreenInit().
+ */
+static Bool
+EnterVT(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ pScrn->vtSema = TRUE;
+
+ SetMaster(pScrn);
+
+ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
+}
+
+static Bool
+CloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ if (ms->damage) {
+ DamageUnregister(ms->damage);
+ DamageDestroy(ms->damage);
+ ms->damage = NULL;
+ }
+
+ if (ms->drmmode.shadow_enable) {
+ shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+ free(ms->drmmode.shadow_fb);
+ ms->drmmode.shadow_fb = NULL;
+ }
+ drmmode_uevent_fini(pScrn, &ms->drmmode);
+
+ drmmode_free_bos(pScrn, &ms->drmmode);
+
+ if (pScrn->vtSema) {
+ LeaveVT(pScrn);
+ }
+
+ pScreen->CreateScreenResources = ms->createScreenResources;
+ pScreen->BlockHandler = ms->BlockHandler;
+
+ pScrn->vtSema = FALSE;
+ pScreen->CloseScreen = ms->CloseScreen;
+ return (*pScreen->CloseScreen) (pScreen);
+}
+
+static ModeStatus
+ValidMode(ScrnInfoPtr arg, DisplayModePtr mode, Bool verbose, int flags)
+{
+ return MODE_OK;
+}
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.h b/xorg-server/hw/xfree86/drivers/modesetting/driver.h
new file mode 100644
index 000000000..450b29c2b
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ *
+ */
+
+#include <errno.h>
+#include <drm.h>
+#include <xf86drm.h>
+#include <damage.h>
+
+#include "drmmode_display.h"
+#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
+
+typedef struct
+{
+ int lastInstance;
+ int refCount;
+ ScrnInfoPtr pScrn_1;
+ ScrnInfoPtr pScrn_2;
+} EntRec, *EntPtr;
+
+typedef struct _modesettingRec
+{
+ int fd;
+
+ EntPtr entityPrivate;
+
+ int Chipset;
+ EntityInfoPtr pEnt;
+#if XSERVER_LIBPCIACCESS
+ struct pci_device *PciInfo;
+#else
+ pciVideoPtr PciInfo;
+ PCITAG PciTag;
+#endif
+
+ Bool noAccel;
+ CloseScreenProcPtr CloseScreen;
+
+ /* Broken-out options. */
+ OptionInfoPtr Options;
+
+ unsigned int SaveGeneration;
+
+ CreateScreenResourcesProcPtr createScreenResources;
+ ScreenBlockHandlerProcPtr BlockHandler;
+ void *driver;
+
+ drmmode_rec drmmode;
+
+ DamagePtr damage;
+ Bool dirty_enabled;
+
+ uint32_t cursor_width, cursor_height;
+} modesettingRec, *modesettingPtr;
+
+#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
new file mode 100644
index 000000000..9723ccd0e
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -0,0 +1,1616 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include "xf86str.h"
+#include "X11/Xatom.h"
+#include "micmap.h"
+#include "xf86cmap.h"
+#include "xf86DDC.h"
+
+#include <xf86drm.h>
+#include "xf86Crtc.h"
+#include "drmmode_display.h"
+
+#include <cursorstr.h>
+
+#include <X11/extensions/dpmsconst.h>
+
+#include "driver.h"
+
+static struct dumb_bo *dumb_bo_create(int fd,
+ const unsigned width, const unsigned height,
+ const unsigned bpp)
+{
+ struct drm_mode_create_dumb arg;
+ struct dumb_bo *bo;
+ int ret;
+
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return NULL;
+
+ memset(&arg, 0, sizeof(arg));
+ arg.width = width;
+ arg.height = height;
+ arg.bpp = bpp;
+
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
+ if (ret)
+ goto err_free;
+
+ bo->handle = arg.handle;
+ bo->size = arg.size;
+ bo->pitch = arg.pitch;
+
+ return bo;
+ err_free:
+ free(bo);
+ return NULL;
+}
+
+static int dumb_bo_map(int fd, struct dumb_bo *bo)
+{
+ struct drm_mode_map_dumb arg;
+ int ret;
+ void *map;
+
+ if (bo->ptr) {
+ bo->map_count++;
+ return 0;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->handle;
+
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+ if (ret)
+ return ret;
+
+ map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, arg.offset);
+ if (map == MAP_FAILED)
+ return -errno;
+
+ bo->ptr = map;
+ return 0;
+}
+
+#if 0
+static int dumb_bo_unmap(int fd, struct dumb_bo *bo)
+{
+ bo->map_count--;
+ return 0;
+}
+#endif
+
+static int dumb_bo_destroy(int fd, struct dumb_bo *bo)
+{
+ struct drm_mode_destroy_dumb arg;
+ int ret;
+
+ if (bo->ptr) {
+ munmap(bo->ptr, bo->size);
+ bo->ptr = NULL;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->handle;
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+ if (ret)
+ return -errno;
+
+ free(bo);
+ return 0;
+}
+
+static struct dumb_bo *dumb_get_bo_from_handle(int fd, int handle, int pitch, int size)
+{
+ struct dumb_bo *bo;
+ int ret;
+
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return NULL;
+
+ ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
+ if (ret) {
+ free(bo);
+ return NULL;
+ }
+ bo->pitch = pitch;
+ bo->size = size;
+ return bo;
+}
+
+Bool drmmode_SetSlaveBO(PixmapPtr ppix,
+ drmmode_ptr drmmode,
+ int fd_handle, int pitch, int size)
+{
+ msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
+
+ ppriv->backing_bo = dumb_get_bo_from_handle(drmmode->fd, fd_handle, pitch, size);
+ if (!ppriv->backing_bo)
+ return FALSE;
+
+ close(fd_handle);
+ return TRUE;
+}
+
+static void
+drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
+ drmModeModeInfo *kmode,
+ DisplayModePtr mode)
+{
+ memset(mode, 0, sizeof(DisplayModeRec));
+ mode->status = MODE_OK;
+
+ mode->Clock = kmode->clock;
+
+ mode->HDisplay = kmode->hdisplay;
+ mode->HSyncStart = kmode->hsync_start;
+ mode->HSyncEnd = kmode->hsync_end;
+ mode->HTotal = kmode->htotal;
+ mode->HSkew = kmode->hskew;
+
+ mode->VDisplay = kmode->vdisplay;
+ mode->VSyncStart = kmode->vsync_start;
+ mode->VSyncEnd = kmode->vsync_end;
+ mode->VTotal = kmode->vtotal;
+ mode->VScan = kmode->vscan;
+
+ mode->Flags = kmode->flags; //& FLAG_BITS;
+ mode->name = strdup(kmode->name);
+
+ if (kmode->type & DRM_MODE_TYPE_DRIVER)
+ mode->type = M_T_DRIVER;
+ if (kmode->type & DRM_MODE_TYPE_PREFERRED)
+ mode->type |= M_T_PREFERRED;
+ xf86SetModeCrtc (mode, scrn->adjustFlags);
+}
+
+static void
+drmmode_ConvertToKMode(ScrnInfoPtr scrn,
+ drmModeModeInfo *kmode,
+ DisplayModePtr mode)
+{
+ memset(kmode, 0, sizeof(*kmode));
+
+ kmode->clock = mode->Clock;
+ kmode->hdisplay = mode->HDisplay;
+ kmode->hsync_start = mode->HSyncStart;
+ kmode->hsync_end = mode->HSyncEnd;
+ kmode->htotal = mode->HTotal;
+ kmode->hskew = mode->HSkew;
+
+ kmode->vdisplay = mode->VDisplay;
+ kmode->vsync_start = mode->VSyncStart;
+ kmode->vsync_end = mode->VSyncEnd;
+ kmode->vtotal = mode->VTotal;
+ kmode->vscan = mode->VScan;
+
+ kmode->flags = mode->Flags; //& FLAG_BITS;
+ if (mode->name)
+ strncpy(kmode->name, mode->name, DRM_DISPLAY_MODE_LEN);
+ kmode->name[DRM_DISPLAY_MODE_LEN-1] = 0;
+
+}
+
+static void
+drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
+{
+#if 0
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+// drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+// drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+ /* bonghits in the randr 1.2 - uses dpms to disable crtc - bad buzz */
+ if (mode == DPMSModeOff) {
+// drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+// 0, 0, 0, NULL, 0, NULL);
+ }
+#endif
+}
+
+#if 0
+static PixmapPtr
+create_pixmap_for_fbcon(drmmode_ptr drmmode,
+ ScrnInfoPtr pScrn, int crtc_id)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ drmmode_crtc_private_ptr drmmode_crtc;
+ ScreenPtr pScreen = pScrn->pScreen;
+ PixmapPtr pixmap;
+ struct radeon_bo *bo;
+ drmModeFBPtr fbcon;
+ struct drm_gem_flink flink;
+
+ drmmode_crtc = xf86_config->crtc[crtc_id]->driver_private;
+
+ fbcon = drmModeGetFB(drmmode->fd, drmmode_crtc->mode_crtc->buffer_id);
+ if (fbcon == NULL)
+ return NULL;
+
+ flink.handle = fbcon->handle;
+ if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Couldn't flink fbcon handle\n");
+ return NULL;
+ }
+
+ bo = radeon_bo_open(drmmode->bufmgr, flink.name, 0, 0, 0, 0);
+ if (bo == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Couldn't allocate bo for fbcon handle\n");
+ return NULL;
+ }
+
+ pixmap = drmmode_create_bo_pixmap(pScreen, fbcon->width, fbcon->height,
+ fbcon->depth, fbcon->bpp,
+ fbcon->pitch, bo);
+ if (!pixmap)
+ return NULL;
+
+ radeon_bo_unref(bo);
+ drmModeFreeFB(fbcon);
+ return pixmap;
+}
+
+#endif
+
+static Bool
+drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y)
+{
+ ScrnInfoPtr pScrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ int saved_x, saved_y;
+ Rotation saved_rotation;
+ DisplayModeRec saved_mode;
+ uint32_t *output_ids;
+ int output_count = 0;
+ Bool ret = TRUE;
+ int i;
+ uint32_t fb_id;
+ drmModeModeInfo kmode;
+ int height;
+
+ height = pScrn->virtualY;
+
+ if (drmmode->fb_id == 0) {
+ ret = drmModeAddFB(drmmode->fd,
+ pScrn->virtualX, height,
+ pScrn->depth, pScrn->bitsPerPixel,
+ drmmode->front_bo->pitch,
+ drmmode->front_bo->handle,
+ &drmmode->fb_id);
+ if (ret < 0) {
+ ErrorF("failed to add fb %d\n", ret);
+ return FALSE;
+ }
+ }
+
+ saved_mode = crtc->mode;
+ saved_x = crtc->x;
+ saved_y = crtc->y;
+ saved_rotation = crtc->rotation;
+
+ if (mode) {
+ crtc->mode = *mode;
+ crtc->x = x;
+ crtc->y = y;
+ crtc->rotation = rotation;
+ crtc->transformPresent = FALSE;
+ }
+
+ output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+ if (!output_ids) {
+ ret = FALSE;
+ goto done;
+ }
+
+ if (mode) {
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+ drmmode_output_private_ptr drmmode_output;
+
+ if (output->crtc != crtc)
+ continue;
+
+ drmmode_output = output->driver_private;
+ output_ids[output_count] = drmmode_output->mode_output->connector_id;
+ output_count++;
+ }
+
+ if (!xf86CrtcRotate(crtc)) {
+ goto done;
+ }
+ crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+ crtc->gamma_blue, crtc->gamma_size);
+
+ drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
+
+ fb_id = drmmode->fb_id;
+ if (crtc->randr_crtc->scanout_pixmap) {
+ msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
+ fb_id = ppriv->fb_id;
+ x = y = 0;
+ } else if (drmmode_crtc->rotate_fb_id) {
+ fb_id = drmmode_crtc->rotate_fb_id;
+ x = y = 0;
+ }
+ ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ fb_id, x, y, output_ids, output_count, &kmode);
+ if (ret)
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
+ "failed to set mode: %s", strerror(-ret));
+ else
+ ret = TRUE;
+
+ if (crtc->scrn->pScreen)
+ xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
+ /* go through all the outputs and force DPMS them back on? */
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+
+ if (output->crtc != crtc)
+ continue;
+
+ output->funcs->dpms(output, DPMSModeOn);
+ }
+ }
+
+#if 0
+ if (pScrn->pScreen &&
+ !xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
+ xf86_reload_cursors(pScrn->pScreen);
+#endif
+done:
+ if (!ret) {
+ crtc->x = saved_x;
+ crtc->y = saved_y;
+ crtc->rotation = saved_rotation;
+ crtc->mode = saved_mode;
+ }
+#if defined(XF86_CRTC_VERSION) && XF86_CRTC_VERSION >= 3
+ else
+ crtc->active = TRUE;
+#endif
+
+ return ret;
+}
+
+static void
+drmmode_set_cursor_colors (xf86CrtcPtr crtc, int bg, int fg)
+{
+
+}
+
+static void
+drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+ drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
+}
+
+static void
+drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ int i;
+ uint32_t *ptr;
+ uint32_t handle = drmmode_crtc->cursor_bo->handle;
+ int ret;
+ /* cursor should be mapped already */
+ ptr = (uint32_t *)(drmmode_crtc->cursor_bo->ptr);
+
+ for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
+ ptr[i] = image[i];// cpu_to_le32(image[i]);
+
+ ret = drmModeSetCursor(drmmode_crtc->drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
+ ms->cursor_width, ms->cursor_height);
+ if (ret) {
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+
+ cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
+ drmmode_crtc->drmmode->sw_cursor = TRUE;
+ /* fallback to swcursor */
+ }
+}
+
+
+static void
+drmmode_hide_cursor (xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+ drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
+ ms->cursor_width, ms->cursor_height);
+
+}
+
+static void
+drmmode_show_cursor (xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ uint32_t handle = drmmode_crtc->cursor_bo->handle;
+ static Bool use_set_cursor2 = TRUE;
+
+ if (use_set_cursor2) {
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ CursorPtr cursor = xf86_config->cursor;
+ int ret;
+ ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, ms->cursor_width, ms->cursor_height, cursor->bits->xhot, cursor->bits->yhot);
+ if (ret == -EINVAL)
+ use_set_cursor2 = FALSE;
+ else
+ return;
+ }
+
+ drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
+ ms->cursor_width, ms->cursor_height);
+}
+
+static void
+drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green,
+ uint16_t *blue, int size)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+ drmModeCrtcSetGamma(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ size, red, green, blue);
+}
+
+static Bool
+drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ msPixmapPrivPtr ppriv;
+ void *ptr;
+
+ if (!ppix) {
+ if (crtc->randr_crtc->scanout_pixmap) {
+ ppriv = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
+ drmModeRmFB(drmmode->fd, ppriv->fb_id);
+ }
+ if (drmmode_crtc->slave_damage) {
+ DamageUnregister(drmmode_crtc->slave_damage);
+ drmmode_crtc->slave_damage = NULL;
+ }
+ return TRUE;
+ }
+
+ ppriv = msGetPixmapPriv(drmmode, ppix);
+ if (!drmmode_crtc->slave_damage) {
+ drmmode_crtc->slave_damage = DamageCreate(NULL, NULL,
+ DamageReportNone,
+ TRUE,
+ crtc->randr_crtc->pScreen,
+ NULL);
+ }
+ ptr = drmmode_map_slave_bo(drmmode, ppriv);
+ ppix->devPrivate.ptr = ptr;
+ DamageRegister(&ppix->drawable, drmmode_crtc->slave_damage);
+
+ if (ppriv->fb_id == 0) {
+ drmModeAddFB(drmmode->fd, ppix->drawable.width,
+ ppix->drawable.height,
+ ppix->drawable.depth,
+ ppix->drawable.bitsPerPixel,
+ ppix->devKind,
+ ppriv->backing_bo->handle,
+ &ppriv->fb_id);
+ }
+ return TRUE;
+}
+
+static void *drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+{
+ return NULL;
+}
+
+static PixmapPtr drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width,
+ int height)
+{
+ return NULL;
+}
+
+static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
+ .dpms = drmmode_crtc_dpms,
+ .set_mode_major = drmmode_set_mode_major,
+ .set_cursor_colors = drmmode_set_cursor_colors,
+ .set_cursor_position = drmmode_set_cursor_position,
+ .show_cursor = drmmode_show_cursor,
+ .hide_cursor = drmmode_hide_cursor,
+ .load_cursor_argb = drmmode_load_cursor_argb,
+
+ .gamma_set = drmmode_crtc_gamma_set,
+ .destroy = NULL, /* XXX */
+ .set_scanout_pixmap = drmmode_set_scanout_pixmap,
+ .shadow_allocate = drmmode_shadow_allocate,
+ .shadow_create = drmmode_shadow_create,
+};
+
+static void
+drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
+{
+ xf86CrtcPtr crtc;
+ drmmode_crtc_private_ptr drmmode_crtc;
+
+ crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs);
+ if (crtc == NULL)
+ return;
+
+ drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
+ drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
+ drmmode_crtc->drmmode = drmmode;
+ crtc->driver_private = drmmode_crtc;
+}
+
+static xf86OutputStatus
+drmmode_output_detect(xf86OutputPtr output)
+{
+ /* go to the hw and retrieve a new output struct */
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ xf86OutputStatus status;
+ drmModeFreeConnector(drmmode_output->mode_output);
+
+ drmmode_output->mode_output = drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
+ if (!drmmode_output->mode_output)
+ return XF86OutputStatusDisconnected;
+
+ switch (drmmode_output->mode_output->connection) {
+ case DRM_MODE_CONNECTED:
+ status = XF86OutputStatusConnected;
+ break;
+ case DRM_MODE_DISCONNECTED:
+ status = XF86OutputStatusDisconnected;
+ break;
+ default:
+ case DRM_MODE_UNKNOWNCONNECTION:
+ status = XF86OutputStatusUnknown;
+ break;
+ }
+ return status;
+}
+
+static Bool
+drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes)
+{
+ return MODE_OK;
+}
+
+static Bool
+has_panel_fitter(xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmModeConnectorPtr koutput = drmmode_output->mode_output;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ int i;
+
+ /* Presume that if the output supports scaling, then we have a
+ * panel fitter capable of adjust any mode to suit.
+ */
+ for (i = 0; i < koutput->count_props; i++) {
+ drmModePropertyPtr props;
+ Bool found = FALSE;
+
+ props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+ if (props) {
+ found = strcmp(props->name, "scaling mode") == 0;
+ drmModeFreeProperty(props);
+ }
+
+ if (found)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static DisplayModePtr
+drmmode_output_add_gtf_modes(xf86OutputPtr output,
+ DisplayModePtr Modes)
+{
+ xf86MonPtr mon = output->MonInfo;
+ DisplayModePtr i, m, preferred = NULL;
+ int max_x = 0, max_y = 0;
+ float max_vrefresh = 0.0;
+
+ if (mon && GTF_SUPPORTED(mon->features.msc))
+ return Modes;
+
+ if (!has_panel_fitter(output))
+ return Modes;
+
+ for (m = Modes; m; m = m->next) {
+ if (m->type & M_T_PREFERRED)
+ preferred = m;
+ max_x = max(max_x, m->HDisplay);
+ max_y = max(max_y, m->VDisplay);
+ max_vrefresh = max(max_vrefresh, xf86ModeVRefresh(m));
+ }
+
+ max_vrefresh = max(max_vrefresh, 60.0);
+ max_vrefresh *= (1 + SYNC_TOLERANCE);
+
+ m = xf86GetDefaultModes();
+ xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0);
+
+ for (i = m; i; i = i->next) {
+ if (xf86ModeVRefresh(i) > max_vrefresh)
+ i->status = MODE_VSYNC;
+ if (preferred &&
+ i->HDisplay >= preferred->HDisplay &&
+ i->VDisplay >= preferred->VDisplay &&
+ xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred))
+ i->status = MODE_VSYNC;
+ }
+
+ xf86PruneInvalidModes(output->scrn, &m, FALSE);
+
+ return xf86ModesAdd(Modes, m);
+}
+
+static DisplayModePtr
+drmmode_output_get_modes(xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmModeConnectorPtr koutput = drmmode_output->mode_output;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ int i;
+ DisplayModePtr Modes = NULL, Mode;
+ drmModePropertyPtr props;
+ xf86MonPtr mon = NULL;
+
+ if (!koutput)
+ return NULL;
+
+ /* look for an EDID property */
+ for (i = 0; i < koutput->count_props; i++) {
+ props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+ if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
+ if (!strcmp(props->name, "EDID")) {
+ if (drmmode_output->edid_blob)
+ drmModeFreePropertyBlob(drmmode_output->edid_blob);
+ drmmode_output->edid_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
+ }
+ drmModeFreeProperty(props);
+ }
+ }
+
+ if (drmmode_output->edid_blob) {
+ mon = xf86InterpretEDID(output->scrn->scrnIndex,
+ drmmode_output->edid_blob->data);
+ if (mon && drmmode_output->edid_blob->length > 128)
+ mon->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
+ }
+ xf86OutputSetEDID(output, mon);
+
+ /* modes should already be available */
+ for (i = 0; i < koutput->count_modes; i++) {
+ Mode = xnfalloc(sizeof(DisplayModeRec));
+
+ drmmode_ConvertFromKMode(output->scrn, &koutput->modes[i], Mode);
+ Modes = xf86ModesAdd(Modes, Mode);
+
+ }
+
+ return drmmode_output_add_gtf_modes(output, Modes);
+}
+
+static void
+drmmode_output_destroy(xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ int i;
+
+ if (drmmode_output->edid_blob)
+ drmModeFreePropertyBlob(drmmode_output->edid_blob);
+ for (i = 0; i < drmmode_output->num_props; i++) {
+ drmModeFreeProperty(drmmode_output->props[i].mode_prop);
+ free(drmmode_output->props[i].atoms);
+ }
+ free(drmmode_output->props);
+ for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
+ drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
+ }
+ free(drmmode_output->mode_encoders);
+ drmModeFreeConnector(drmmode_output->mode_output);
+ free(drmmode_output);
+ output->driver_private = NULL;
+}
+
+static void
+drmmode_output_dpms(xf86OutputPtr output, int mode)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmModeConnectorPtr koutput = drmmode_output->mode_output;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+
+ if (!koutput)
+ return;
+
+ drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id,
+ drmmode_output->dpms_enum_id, mode);
+ return;
+}
+
+
+static Bool
+drmmode_property_ignore(drmModePropertyPtr prop)
+{
+ if (!prop)
+ return TRUE;
+ /* ignore blob prop */
+ if (prop->flags & DRM_MODE_PROP_BLOB)
+ return TRUE;
+ /* ignore standard property */
+ if (!strcmp(prop->name, "EDID") ||
+ !strcmp(prop->name, "DPMS"))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void
+drmmode_output_create_resources(xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmModeConnectorPtr mode_output = drmmode_output->mode_output;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ drmModePropertyPtr drmmode_prop;
+ int i, j, err;
+
+ drmmode_output->props = calloc(mode_output->count_props, sizeof(drmmode_prop_rec));
+ if (!drmmode_output->props)
+ return;
+
+ drmmode_output->num_props = 0;
+ for (i = 0, j = 0; i < mode_output->count_props; i++) {
+ drmmode_prop = drmModeGetProperty(drmmode->fd, mode_output->props[i]);
+ if (drmmode_property_ignore(drmmode_prop)) {
+ drmModeFreeProperty(drmmode_prop);
+ continue;
+ }
+ drmmode_output->props[j].mode_prop = drmmode_prop;
+ drmmode_output->props[j].value = mode_output->prop_values[i];
+ drmmode_output->num_props++;
+ j++;
+ }
+
+ for (i = 0; i < drmmode_output->num_props; i++) {
+ drmmode_prop_ptr p = &drmmode_output->props[i];
+ drmmode_prop = p->mode_prop;
+
+ if (drmmode_prop->flags & DRM_MODE_PROP_RANGE) {
+ INT32 prop_range[2];
+ INT32 value = p->value;
+
+ p->num_atoms = 1;
+ p->atoms = calloc(p->num_atoms, sizeof(Atom));
+ if (!p->atoms)
+ continue;
+ p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
+ prop_range[0] = drmmode_prop->values[0];
+ prop_range[1] = drmmode_prop->values[1];
+ err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
+ FALSE, TRUE,
+ drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE,
+ 2, prop_range);
+ if (err != 0) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+ "RRConfigureOutputProperty error, %d\n", err);
+ }
+ err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
+ XA_INTEGER, 32, PropModeReplace, 1, &value, FALSE, TRUE);
+ if (err != 0) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+ "RRChangeOutputProperty error, %d\n", err);
+ }
+ } else if (drmmode_prop->flags & DRM_MODE_PROP_ENUM) {
+ p->num_atoms = drmmode_prop->count_enums + 1;
+ p->atoms = calloc(p->num_atoms, sizeof(Atom));
+ if (!p->atoms)
+ continue;
+ p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
+ for (j = 1; j <= drmmode_prop->count_enums; j++) {
+ struct drm_mode_property_enum *e = &drmmode_prop->enums[j-1];
+ p->atoms[j] = MakeAtom(e->name, strlen(e->name), TRUE);
+ }
+ err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
+ FALSE, FALSE,
+ drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE,
+ p->num_atoms - 1, (INT32 *)&p->atoms[1]);
+ if (err != 0) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+ "RRConfigureOutputProperty error, %d\n", err);
+ }
+ for (j = 0; j < drmmode_prop->count_enums; j++)
+ if (drmmode_prop->enums[j].value == p->value)
+ break;
+ /* there's always a matching value */
+ err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
+ XA_ATOM, 32, PropModeReplace, 1, &p->atoms[j+1], FALSE, TRUE);
+ if (err != 0) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+ "RRChangeOutputProperty error, %d\n", err);
+ }
+ }
+ }
+}
+
+static Bool
+drmmode_output_set_property(xf86OutputPtr output, Atom property,
+ RRPropertyValuePtr value)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ int i;
+
+ for (i = 0; i < drmmode_output->num_props; i++) {
+ drmmode_prop_ptr p = &drmmode_output->props[i];
+
+ if (p->atoms[0] != property)
+ continue;
+
+ if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
+ uint32_t val;
+
+ if (value->type != XA_INTEGER || value->format != 32 ||
+ value->size != 1)
+ return FALSE;
+ val = *(uint32_t *)value->data;
+
+ drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id,
+ p->mode_prop->prop_id, (uint64_t)val);
+ return TRUE;
+ } else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
+ Atom atom;
+ const char *name;
+ int j;
+
+ if (value->type != XA_ATOM || value->format != 32 || value->size != 1)
+ return FALSE;
+ memcpy(&atom, value->data, 4);
+ name = NameForAtom(atom);
+
+ /* search for matching name string, then set its value down */
+ for (j = 0; j < p->mode_prop->count_enums; j++) {
+ if (!strcmp(p->mode_prop->enums[j].name, name)) {
+ drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id,
+ p->mode_prop->prop_id, p->mode_prop->enums[j].value);
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static Bool
+drmmode_output_get_property(xf86OutputPtr output, Atom property)
+{
+ return TRUE;
+}
+
+static const xf86OutputFuncsRec drmmode_output_funcs = {
+ .dpms = drmmode_output_dpms,
+ .create_resources = drmmode_output_create_resources,
+ .set_property = drmmode_output_set_property,
+ .get_property = drmmode_output_get_property,
+ .detect = drmmode_output_detect,
+ .mode_valid = drmmode_output_mode_valid,
+
+ .get_modes = drmmode_output_get_modes,
+ .destroy = drmmode_output_destroy
+};
+
+static int subpixel_conv_table[7] = { 0, SubPixelUnknown,
+ SubPixelHorizontalRGB,
+ SubPixelHorizontalBGR,
+ SubPixelVerticalRGB,
+ SubPixelVerticalBGR,
+ SubPixelNone };
+
+static const char * const output_names[] = { "None",
+ "VGA",
+ "DVI",
+ "DVI",
+ "DVI",
+ "Composite",
+ "S-video",
+ "LVDS",
+ "CTV",
+ "DIN",
+ "DisplayPort",
+ "HDMI",
+ "HDMI",
+ "TV",
+ "eDP",
+ "Virtual",
+ "DSI",
+};
+
+static void
+drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dvi, int *num_hdmi)
+{
+ xf86OutputPtr output;
+ drmModeConnectorPtr koutput;
+ drmModeEncoderPtr *kencoders = NULL;
+ drmmode_output_private_ptr drmmode_output;
+ drmModePropertyPtr props;
+ char name[32];
+ int i;
+
+ koutput = drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]);
+ if (!koutput)
+ return;
+
+ kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
+ if (!kencoders) {
+ goto out_free_encoders;
+ }
+
+ for (i = 0; i < koutput->count_encoders; i++) {
+ kencoders[i] = drmModeGetEncoder(drmmode->fd, koutput->encoders[i]);
+ if (!kencoders[i]) {
+ goto out_free_encoders;
+ }
+ }
+
+ /* need to do smart conversion here for compat with non-kms ATI driver */
+ if (koutput->connector_type >= MS_ARRAY_SIZE(output_names))
+ snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1);
+ else if (pScrn->is_gpu)
+ snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1, koutput->connector_type_id - 1);
+ else
+ snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1);
+
+ output = xf86OutputCreate (pScrn, &drmmode_output_funcs, name);
+ if (!output) {
+ goto out_free_encoders;
+ }
+
+ drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1);
+ if (!drmmode_output) {
+ xf86OutputDestroy(output);
+ goto out_free_encoders;
+ }
+
+ drmmode_output->output_id = drmmode->mode_res->connectors[num];
+ drmmode_output->mode_output = koutput;
+ drmmode_output->mode_encoders = kencoders;
+ drmmode_output->drmmode = drmmode;
+ output->mm_width = koutput->mmWidth;
+ output->mm_height = koutput->mmHeight;
+
+ output->subpixel_order = subpixel_conv_table[koutput->subpixel];
+ output->interlaceAllowed = TRUE;
+ output->doubleScanAllowed = TRUE;
+ output->driver_private = drmmode_output;
+
+ output->possible_crtcs = 0x7f;
+ for (i = 0; i < koutput->count_encoders; i++) {
+ output->possible_crtcs &= kencoders[i]->possible_crtcs;
+ }
+ /* work out the possible clones later */
+ output->possible_clones = 0;
+
+ for (i = 0; i < koutput->count_props; i++) {
+ props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+ if (props && (props->flags & DRM_MODE_PROP_ENUM)) {
+ if (!strcmp(props->name, "DPMS")) {
+ drmmode_output->dpms_enum_id = koutput->props[i];
+ drmModeFreeProperty(props);
+ break;
+ }
+ drmModeFreeProperty(props);
+ }
+ }
+
+ return;
+out_free_encoders:
+ if (kencoders){
+ for (i = 0; i < koutput->count_encoders; i++)
+ drmModeFreeEncoder(kencoders[i]);
+ free(kencoders);
+ }
+ drmModeFreeConnector(koutput);
+
+}
+
+static uint32_t find_clones(ScrnInfoPtr scrn, xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private, clone_drmout;
+ int i;
+ xf86OutputPtr clone_output;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int index_mask = 0;
+
+ if (drmmode_output->enc_clone_mask == 0)
+ return index_mask;
+
+ for (i = 0; i < xf86_config->num_output; i++) {
+ clone_output = xf86_config->output[i];
+ clone_drmout = clone_output->driver_private;
+ if (output == clone_output)
+ continue;
+
+ if (clone_drmout->enc_mask == 0)
+ continue;
+ if (drmmode_output->enc_clone_mask == clone_drmout->enc_mask)
+ index_mask |= (1 << i);
+ }
+ return index_mask;
+}
+
+
+static void
+drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+{
+ int i, j;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+ drmmode_output_private_ptr drmmode_output;
+
+ drmmode_output = output->driver_private;
+ drmmode_output->enc_clone_mask = 0xff;
+ /* and all the possible encoder clones for this output together */
+ for (j = 0; j < drmmode_output->mode_output->count_encoders; j++)
+ {
+ int k;
+ for (k = 0; k < drmmode->mode_res->count_encoders; k++) {
+ if (drmmode->mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id)
+ drmmode_output->enc_mask |= (1 << k);
+ }
+
+ drmmode_output->enc_clone_mask &= drmmode_output->mode_encoders[j]->possible_clones;
+ }
+ }
+
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+ output->possible_clones = find_clones(scrn, output);
+ }
+}
+
+static Bool
+drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ drmmode_crtc_private_ptr
+ drmmode_crtc = xf86_config->crtc[0]->driver_private;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ struct dumb_bo *old_front = NULL;
+ Bool ret;
+ ScreenPtr screen = xf86ScrnToScreen(scrn);
+ uint32_t old_fb_id;
+ int i, pitch, old_width, old_height, old_pitch;
+ int cpp = (scrn->bitsPerPixel + 7) / 8;
+ PixmapPtr ppix = screen->GetScreenPixmap(screen);
+ void *new_pixels;
+
+ if (scrn->virtualX == width && scrn->virtualY == height)
+ return TRUE;
+
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Allocate new frame buffer %dx%d stride\n",
+ width, height);
+
+ old_width = scrn->virtualX;
+ old_height = scrn->virtualY;
+ old_pitch = drmmode->front_bo->pitch;
+ old_fb_id = drmmode->fb_id;
+ old_front = drmmode->front_bo;
+
+ drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel);
+ if (!drmmode->front_bo)
+ goto fail;
+
+ pitch = drmmode->front_bo->pitch;
+
+ scrn->virtualX = width;
+ scrn->virtualY = height;
+ scrn->displayWidth = pitch / cpp;
+
+ ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
+ scrn->bitsPerPixel, pitch,
+ drmmode->front_bo->handle,
+ &drmmode->fb_id);
+ if (ret)
+ goto fail;
+
+ new_pixels = drmmode_map_front_bo(drmmode);
+ if (!new_pixels)
+ goto fail;
+
+ if (!drmmode->shadow_enable)
+ screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
+ pitch, new_pixels);
+ else {
+ void *new_shadow;
+ uint32_t size = scrn->displayWidth * scrn->virtualY *
+ ((scrn->bitsPerPixel + 7) >> 3);
+ new_shadow = calloc(1, size);
+ if (new_shadow == NULL)
+ goto fail;
+ free(drmmode->shadow_fb);
+ drmmode->shadow_fb = new_shadow;
+ screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
+ pitch, drmmode->shadow_fb);
+ }
+
+ for (i = 0; i < xf86_config->num_crtc; i++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[i];
+
+ if (!crtc->enabled)
+ continue;
+
+ drmmode_set_mode_major(crtc, &crtc->mode,
+ crtc->rotation, crtc->x, crtc->y);
+ }
+
+ if (old_fb_id) {
+ drmModeRmFB(drmmode->fd, old_fb_id);
+ dumb_bo_destroy(drmmode->fd, old_front);
+ }
+
+ return TRUE;
+
+ fail:
+ if (drmmode->front_bo)
+ dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+ drmmode->front_bo = old_front;
+ scrn->virtualX = old_width;
+ scrn->virtualY = old_height;
+ scrn->displayWidth = old_pitch / cpp;
+ drmmode->fb_id = old_fb_id;
+
+ return FALSE;
+}
+
+static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
+ drmmode_xf86crtc_resize
+};
+
+Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
+{
+ int i, num_dvi = 0, num_hdmi = 0;
+ int ret;
+ uint64_t value = 0;
+
+ /* check for dumb capability */
+ ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value);
+ if (ret > 0 || value != 1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS doesn't support dumb interface\n");
+ return FALSE;
+ }
+
+ xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
+
+ drmmode->scrn = pScrn;
+ drmmode->cpp = cpp;
+ drmmode->mode_res = drmModeGetResources(drmmode->fd);
+ if (!drmmode->mode_res)
+ return FALSE;
+
+ xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height);
+ for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
+ if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i)
+ drmmode_crtc_init(pScrn, drmmode, i);
+
+ for (i = 0; i < drmmode->mode_res->count_connectors; i++)
+ drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi);
+
+ /* workout clones */
+ drmmode_clones_init(pScrn, drmmode);
+
+#if XF86_CRTC_VERSION >= 5
+ xf86ProviderSetup(pScrn, NULL, "modesetting");
+#endif
+
+ xf86InitialConfiguration(pScrn, TRUE);
+
+ return TRUE;
+}
+
+void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86OutputPtr output = config->output[config->compat_output];
+ xf86CrtcPtr crtc = output->crtc;
+
+ if (crtc && crtc->enabled) {
+ drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+ x, y);
+ }
+}
+
+Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ xf86OutputPtr output = NULL;
+ int o;
+
+ /* Skip disabled CRTCs */
+ if (!crtc->enabled) {
+ drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ 0, 0, 0, NULL, 0, NULL);
+ continue;
+ }
+
+ if (config->output[config->compat_output]->crtc == crtc)
+ output = config->output[config->compat_output];
+ else
+ {
+ for (o = 0; o < config->num_output; o++)
+ if (config->output[o]->crtc == crtc)
+ {
+ output = config->output[o];
+ break;
+ }
+ }
+ /* paranoia */
+ if (!output)
+ continue;
+
+ /* Mark that we'll need to re-set the mode for sure */
+ memset(&crtc->mode, 0, sizeof(crtc->mode));
+ if (!crtc->desiredMode.CrtcHDisplay)
+ {
+ DisplayModePtr mode = xf86OutputFindClosestMode (output, pScrn->currentMode);
+
+ if (!mode)
+ return FALSE;
+ crtc->desiredMode = *mode;
+ crtc->desiredRotation = RR_Rotate_0;
+ crtc->desiredX = 0;
+ crtc->desiredY = 0;
+ }
+
+ if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
+ crtc->desiredX, crtc->desiredY))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
+ int *indices, LOCO *colors, VisualPtr pVisual)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ uint16_t lut_r[256], lut_g[256], lut_b[256];
+ int index, j, i;
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ for (i = 0 ; i < 256; i++) {
+ lut_r[i] = drmmode_crtc->lut_r[i] << 6;
+ lut_g[i] = drmmode_crtc->lut_g[i] << 6;
+ lut_b[i] = drmmode_crtc->lut_b[i] << 6;
+ }
+
+ switch(pScrn->depth) {
+ case 15:
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ for (j = 0; j < 8; j++) {
+ lut_r[index * 8 + j] = colors[index].red << 6;
+ lut_g[index * 8 + j] = colors[index].green << 6;
+ lut_b[index * 8 + j] = colors[index].blue << 6;
+ }
+ }
+ break;
+ case 16:
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+
+ if (i <= 31) {
+ for (j = 0; j < 8; j++) {
+ lut_r[index * 8 + j] = colors[index].red << 6;
+ lut_b[index * 8 + j] = colors[index].blue << 6;
+ }
+ }
+
+ for (j = 0; j < 4; j++) {
+ lut_g[index * 4 + j] = colors[index].green << 6;
+ }
+ }
+ break;
+ default:
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ lut_r[index] = colors[index].red << 6;
+ lut_g[index] = colors[index].green << 6;
+ lut_b[index] = colors[index].blue << 6;
+ }
+ break;
+ }
+
+ /* Make the change through RandR */
+ if (crtc->randr_crtc)
+ RRCrtcGammaSet(crtc->randr_crtc, lut_r, lut_g, lut_b);
+ else
+ crtc->funcs->gamma_set(crtc, lut_r, lut_g, lut_b, 256);
+ }
+}
+
+Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+{
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
+ "Initializing kms color map\n");
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+ /* all radeons support 10 bit CLUTs */
+ if (!xf86HandleColormaps(pScreen, 256, 10,
+ drmmode_load_palette, NULL,
+ CMAP_PALETTED_TRUECOLOR
+#if 0 /* This option messes up text mode! (eich@suse.de) */
+ | CMAP_LOAD_EVEN_IF_OFFSCREEN
+#endif
+ | CMAP_RELOAD_ON_MODE_SWITCH))
+ return FALSE;
+ return TRUE;
+}
+
+#ifdef HAVE_UDEV
+static void
+drmmode_handle_uevents(int fd, void *closure)
+{
+ drmmode_ptr drmmode = closure;
+ ScrnInfoPtr scrn = drmmode->scrn;
+ struct udev_device *dev;
+ dev = udev_monitor_receive_device(drmmode->uevent_monitor);
+ if (!dev)
+ return;
+
+ RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
+ udev_device_unref(dev);
+}
+#endif
+
+void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+{
+#ifdef HAVE_UDEV
+ struct udev *u;
+ struct udev_monitor *mon;
+
+ u = udev_new();
+ if (!u)
+ return;
+ mon = udev_monitor_new_from_netlink(u, "udev");
+ if (!mon) {
+ udev_unref(u);
+ return;
+ }
+
+ if (udev_monitor_filter_add_match_subsystem_devtype(mon,
+ "drm",
+ "drm_minor") < 0 ||
+ udev_monitor_enable_receiving(mon) < 0) {
+ udev_monitor_unref(mon);
+ udev_unref(u);
+ return;
+ }
+
+ drmmode->uevent_handler =
+ xf86AddGeneralHandler(udev_monitor_get_fd(mon),
+ drmmode_handle_uevents,
+ drmmode);
+
+ drmmode->uevent_monitor = mon;
+#endif
+}
+
+void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+{
+#ifdef HAVE_UDEV
+ if (drmmode->uevent_handler) {
+ struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor);
+ xf86RemoveGeneralHandler(drmmode->uevent_handler);
+
+ udev_monitor_unref(drmmode->uevent_monitor);
+ udev_unref(u);
+ }
+#endif
+}
+
+/* create front and cursor BOs */
+Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int width;
+ int height;
+ int bpp = pScrn->bitsPerPixel;
+ int i;
+ int cpp = (bpp + 7) / 8;
+
+ width = pScrn->virtualX;
+ height = pScrn->virtualY;
+
+ drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
+ if (!drmmode->front_bo)
+ return FALSE;
+ pScrn->displayWidth = drmmode->front_bo->pitch / cpp;
+
+ width = ms->cursor_width;
+ height = ms->cursor_height;
+ bpp = 32;
+ for (i = 0; i < xf86_config->num_crtc; i++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[i];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_crtc->cursor_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
+ }
+ return TRUE;
+}
+
+void *drmmode_map_front_bo(drmmode_ptr drmmode)
+{
+ int ret;
+
+ if (drmmode->front_bo->ptr)
+ return drmmode->front_bo->ptr;
+
+ ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
+ if (ret)
+ return NULL;
+
+ return drmmode->front_bo->ptr;
+
+}
+
+void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv)
+{
+ int ret;
+
+ if (ppriv->backing_bo->ptr)
+ return ppriv->backing_bo->ptr;
+
+ ret = dumb_bo_map(drmmode->fd, ppriv->backing_bo);
+ if (ret)
+ return NULL;
+
+ return ppriv->backing_bo->ptr;
+}
+
+Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int i, ret;
+ for (i = 0; i < xf86_config->num_crtc; i++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[i];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ ret = dumb_bo_map(drmmode->fd, drmmode_crtc->cursor_bo);
+ if (ret)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int i;
+
+ if (drmmode->fb_id) {
+ drmModeRmFB(drmmode->fd, drmmode->fb_id);
+ drmmode->fb_id = 0;
+ }
+
+ dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+ drmmode->front_bo = NULL;
+
+ for (i = 0; i < xf86_config->num_crtc; i++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[i];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
+ }
+}
+
+/* ugly workaround to see if we can create 32bpp */
+void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int *depth, int *bpp)
+{
+ drmModeResPtr mode_res;
+ uint64_t value;
+ struct dumb_bo *bo;
+ uint32_t fb_id;
+ int ret;
+
+ /* 16 is fine */
+ ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_PREFERRED_DEPTH, &value);
+ if (!ret && (value == 16 || value == 8)) {
+ *depth = value;
+ *bpp = value;
+ return;
+ }
+
+ *depth = 24;
+ mode_res = drmModeGetResources(drmmode->fd);
+ if (!mode_res)
+ return;
+
+ if (mode_res->min_width == 0)
+ mode_res->min_width = 1;
+ if (mode_res->min_height == 0)
+ mode_res->min_height = 1;
+ /*create a bo */
+ bo = dumb_bo_create(drmmode->fd, mode_res->min_width, mode_res->min_height, 32);
+ if (!bo) {
+ *bpp = 24;
+ goto out;
+ }
+
+ ret = drmModeAddFB(drmmode->fd, mode_res->min_width, mode_res->min_height,
+ 24, 32, bo->pitch, bo->handle, &fb_id);
+
+ if (ret) {
+ *bpp = 24;
+ dumb_bo_destroy(drmmode->fd, bo);
+ goto out;
+ }
+
+ drmModeRmFB(drmmode->fd, fb_id);
+ *bpp = 32;
+
+ dumb_bo_destroy(drmmode->fd, bo);
+out:
+ drmModeFreeResources(mode_res);
+ return;
+}
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
new file mode 100644
index 000000000..7bfe885f5
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ *
+ */
+#ifndef DRMMODE_DISPLAY_H
+#define DRMMODE_DISPLAY_H
+
+#include "xf86drmMode.h"
+#ifdef HAVE_UDEV
+#include "libudev.h"
+#endif
+
+struct dumb_bo {
+ uint32_t handle;
+ uint32_t size;
+ void *ptr;
+ int map_count;
+ uint32_t pitch;
+};
+
+typedef struct {
+ int fd;
+ unsigned fb_id;
+ drmModeResPtr mode_res;
+ drmModeFBPtr mode_fb;
+ int cpp;
+ ScrnInfoPtr scrn;
+#ifdef HAVE_UDEV
+ struct udev_monitor *uevent_monitor;
+ InputHandlerProc uevent_handler;
+#endif
+ drmEventContext event_context;
+ struct dumb_bo *front_bo;
+ Bool sw_cursor;
+
+ Bool shadow_enable;
+ void *shadow_fb;
+
+ DevPrivateKeyRec pixmapPrivateKeyRec;
+} drmmode_rec, *drmmode_ptr;
+
+typedef struct {
+ drmmode_ptr drmmode;
+ drmModeCrtcPtr mode_crtc;
+ int hw_id;
+ struct dumb_bo *cursor_bo;
+ unsigned rotate_fb_id;
+ uint16_t lut_r[256], lut_g[256], lut_b[256];
+ DamagePtr slave_damage;
+} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
+
+typedef struct {
+ drmModePropertyPtr mode_prop;
+ uint64_t value;
+ int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
+ Atom *atoms;
+} drmmode_prop_rec, *drmmode_prop_ptr;
+
+
+typedef struct {
+ drmmode_ptr drmmode;
+ int output_id;
+ drmModeConnectorPtr mode_output;
+ drmModeEncoderPtr *mode_encoders;
+ drmModePropertyBlobPtr edid_blob;
+ int dpms_enum_id;
+ int num_props;
+ drmmode_prop_ptr props;
+ int enc_mask;
+ int enc_clone_mask;
+} drmmode_output_private_rec, *drmmode_output_private_ptr;
+
+typedef struct _msPixmapPriv {
+ uint32_t fb_id;
+ struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
+} msPixmapPrivRec, *msPixmapPrivPtr;
+
+
+extern DevPrivateKeyRec msPixmapPrivateKeyRec;
+#define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
+
+#define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
+
+void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
+Bool drmmode_SetSlaveBO(PixmapPtr ppix,
+ drmmode_ptr drmmode,
+ int fd_handle, int pitch, int size);
+
+extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
+void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
+extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
+
+extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
+extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
+
+Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+void *drmmode_map_front_bo(drmmode_ptr drmmode);
+Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth, int *bpp);
+
+
+#ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
+#define DRM_CAP_DUMB_PREFERRED_DEPTH 3
+#endif
+#ifndef DRM_CAP_DUMB_PREFER_SHADOW
+#define DRM_CAP_DUMB_PREFER_SHADOW 4
+#endif
+
+#define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
+
+#endif
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/modesetting.man b/xorg-server/hw/xfree86/drivers/modesetting/modesetting.man
new file mode 100644
index 000000000..34baa9c53
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/modesetting.man
@@ -0,0 +1,54 @@
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH MODESETTING __drivermansuffix__ __vendorversion__
+.SH NAME
+modesetting \- video driver for framebuffer device
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qmodesetting\*q"
+.BI " BusID \*qpci:" bus : dev : func \*q
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B modesetting
+is an __xservername__ driver for KMS devices. This is a non-accelerated
+driver, the following framebuffer depths are supported: 8, 15, 16, 24.
+All visual types are supported for depth 8, and TrueColor visual is
+supported for the other depths. RandR 1.2 is supported.
+.SH SUPPORTED HARDWARE
+The
+.B modesetting
+driver supports all hardware where a KMS driver is available.
+modesetting uses the Linux DRM KMS ioctls and dumb object create/map.
+.SH CONFIGURATION DETAILS
+Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to
+this driver.
+.PP
+For this driver it is not required to specify modes in the screen
+section of the config file. The
+.B modesetting
+driver can pick up the currently used video mode from the kernel
+driver and will use it if there are no video modes configured.
+.PP
+For PCI boards you might have to add a BusID line to the Device
+section. See above for a sample line.
+.PP
+The following driver
+.B Options
+are supported:
+.TP
+.BI "Option \*qkmsdev\*q \*q" string \*q
+The framebuffer device to use. Default: /dev/dri/card0.
+.TP
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
+Enable or disable use of the shadow framebuffer layer. Default: on.
+.TP
+.SH "SEE ALSO"
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__),
+X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Dave Airlie
diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c
index 73a1e5e49..012d1941a 100644
--- a/xorg-server/hw/xfree86/int10/generic.c
+++ b/xorg-server/hw/xfree86/int10/generic.c
@@ -99,6 +99,20 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
static void *sysMem = NULL;
+static Bool
+readIntVec(struct pci_device *dev, unsigned char *buf, int len)
+{
+ void *map;
+
+ if (!pci_device_map_legacy(dev, 0, len, 0, &map))
+ return FALSE;
+
+ memcpy(buf, map, len);
+ pci_device_unmap_legacy(dev, map, len);
+
+ return TRUE;
+}
+
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
{
@@ -144,7 +158,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
INTPriv(pInt)->sysMem = sysMem;
- if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
+ if (!readIntVec(pInt->dev, base, LOW_PAGE_SIZE)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot read int vect\n");
goto error1;
}
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index f1f7c224f..21ccb1bf9 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -584,7 +584,6 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
const XF86ModReqInfo * req)
{
int vercode[4];
- char verstr[4];
long ver = data->xf86version;
MessageType errtype;
@@ -592,42 +591,15 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
data->modname ? data->modname : "UNKNOWN!",
data->vendor ? data->vendor : "UNKNOWN!");
- /* Check for the different scheme used in XFree86 4.0.x releases:
- * ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
- * Since it wasn't used in 4.1.0 or later, limit to versions in the 4.0.x
- * range, which limits the overlap with the new version scheme to conflicts
- * with 6.71.8.764 through 6.72.39.934.
- */
- if ((ver > (4 << 24)) && (ver < ((4 << 24) + (1 << 17)))) {
- /* 4.0.x and earlier */
- verstr[1] = verstr[3] = 0;
- verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
- ver >>= 5;
- verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
- ver >>= 5;
- vercode[2] = ver & 0x7f;
- ver >>= 7;
- vercode[1] = ver & 0x7f;
- ver >>= 7;
- vercode[0] = ver;
- xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
- if (vercode[2] != 0)
- xf86ErrorF(".%d", vercode[2]);
- xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
- data->majorversion, data->minorversion, data->patchlevel);
- }
- else {
- vercode[0] = ver / 10000000;
- vercode[1] = (ver / 100000) % 100;
- vercode[2] = (ver / 1000) % 100;
- vercode[3] = ver % 1000;
- xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
- vercode[2]);
- if (vercode[3] != 0)
- xf86ErrorF(".%d", vercode[3]);
- xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
- data->minorversion, data->patchlevel);
- }
+ vercode[0] = ver / 10000000;
+ vercode[1] = (ver / 100000) % 100;
+ vercode[2] = (ver / 1000) % 100;
+ vercode[3] = ver % 1000;
+ xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], vercode[2]);
+ if (vercode[3] != 0)
+ xf86ErrorF(".%d", vercode[3]);
+ xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
+ data->minorversion, data->patchlevel);
if (data->moduleclass)
xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man
index 16312124d..378f26b59 100644
--- a/xorg-server/hw/xfree86/man/xorg.conf.man
+++ b/xorg-server/hw/xfree86/man/xorg.conf.man
@@ -2023,12 +2023,6 @@ Default: false.
Disables the Int10 module, a module that uses the int10 call to the BIOS
of the graphics card to initialize it.
Default: false.
-.TP 7
-.BI "Option \*qNoMTRR\*q"
-Disables MTRR (Memory Type Range Register) support, a feature of modern
-processors which can improve video performance by a factor of up to 2.5.
-Some hardware has buggy MTRR support, and some video drivers have been
-known to exhibit problems when MTRR's are used.
.PP
Each
.B Screen
diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am
index 7133c0f21..b01ea5bca 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am
@@ -27,9 +27,7 @@ if ALPHA_VIDEO
# Cheat here and piggyback other alpha bits on ALPHA_VIDEO.
ARCH_SOURCES = \
alpha_video.c \
- bsd_ev56.c \
- bsd_axp.c \
- $(srcdir)/../shared/xf86Axp.c
+ bsd_ev56.c
endif
if ARM_VIDEO
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
index f656f5595..236def6ff 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
@@ -35,11 +35,6 @@
#ifndef __NetBSD__
#include <sys/sysctl.h>
#endif
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
-#include <machine/sysarch.h>
-#endif
-
-#include "xf86Axp.h"
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
@@ -50,69 +45,9 @@
#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
#endif
-axpDevice bsdGetAXP(void);
-
#ifndef __NetBSD__
extern unsigned long dense_base(void);
-
-static int axpSystem = -1;
-static unsigned long hae_thresh;
-static unsigned long hae_mask;
-
-static unsigned long
-memory_base(void)
-{
- static unsigned long base = 0;
-
- if (base == 0) {
- size_t len = sizeof(base);
- int error;
-
-#ifdef __OpenBSD__
- int mib[3];
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_MEM;
-
- if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
-#else
- if ((error = sysctlbyname("hw.chipset.memory", &base, &len, 0, 0)) < 0)
-#endif
- FatalError("xf86MapVidMem: can't find memory\n");
- }
-
- return base;
-}
-
-static int
-has_bwx(void)
-{
- static int bwx = 0;
- size_t len = sizeof(bwx);
- int error;
-
-#ifdef __OpenBSD__
- int mib[3];
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_BWX;
-
- if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
- return FALSE;
- else
- return bwx;
-#else
- if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
- return FALSE;
- else
- return bwx;
-#endif
-}
#else /* __NetBSD__ */
-static unsigned long hae_thresh = (1UL << 24);
-static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
static struct alpha_bus_window *abw;
static int abw_count = -1;
@@ -126,16 +61,6 @@ init_abw(void)
}
}
-static int
-has_bwx(void)
-{
- if (abw_count < 0)
- init_abw();
-
- xf86Msg(X_INFO, "has_bwx = %d\n", abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
- return abw[0].abw_abst.abst_flags & ABST_BWX;
-}
-
static unsigned long
dense_base(void)
{
@@ -147,30 +72,9 @@ dense_base(void)
return abw[0].abw_abst.abst_sys_start;
}
-static unsigned long
-memory_base(void)
-{
- if (abw_count < 0)
- init_abw();
-
- if (abw_count > 1) {
- xf86Msg(X_INFO, "memory base = %#lx\n", abw[1].abw_abst.abst_sys_start); /* XXXX */
- return abw[1].abw_abst.abst_sys_start;
- }
- else if (abw_count == 1) {
- /* assume memory_base == dense_base */
- xf86Msg(X_INFO, "memory base = %#lx\n", abw[0].abw_abst.abst_sys_start); /* XXXX */
- return abw[0].abw_abst.abst_sys_start;
- }
- else {
- xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
- return 0;
- }
-}
#endif /* __NetBSD__ */
#define BUS_BASE dense_base()
-#define BUS_BASE_BWX memory_base()
/***************************************************************************/
/* Video Memory Mapping section */
@@ -182,18 +86,12 @@ memory_base(void)
"\trefer to xf86(4) for details"
#endif
-static Bool useDevMem = FALSE;
static int devMemFd = -1;
#ifdef HAS_APERTURE_DRV
#define DEV_APERTURE "/dev/xf86"
#endif
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-static void *mapVidMemSparse(int, unsigned long, unsigned long, int);
-static void unmapVidMemSparse(int, void *, unsigned long);
-
/*
* Check if /dev/mem can be mmap'd. If it can't print a warning when
* "warn" is TRUE.
@@ -219,7 +117,6 @@ checkDevMem(Bool warn)
if (base != MAP_FAILED) {
munmap((caddr_t) base, 4096);
devMemFd = fd;
- useDevMem = TRUE;
xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
DEV_APERTURE);
return;
@@ -240,7 +137,6 @@ checkDevMem(Bool warn)
if (base != MAP_FAILED) {
munmap((caddr_t) base, 4096);
devMemFd = fd;
- useDevMem = TRUE;
return;
}
else {
@@ -266,7 +162,6 @@ checkDevMem(Bool warn)
#endif
xf86ErrorF("\tlinear framebuffer access unavailable\n");
}
- useDevMem = FALSE;
return;
}
@@ -274,117 +169,10 @@ void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- if (has_bwx()) {
- xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n");
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- }
- else {
- xf86Msg(X_PROBED, "Machine needs sparse mapping\n");
- pVidMem->mapMem = mapVidMemSparse;
- pVidMem->unmapMem = unmapVidMemSparse;
-#ifndef __NetBSD__
- if (axpSystem == -1)
- axpSystem = bsdGetAXP();
- hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
- hae_mask = xf86AXPParams[axpSystem].hae_mask;
-#endif /* __NetBSD__ */
- }
pVidMem->initialised = TRUE;
}
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- void *base;
-
- checkDevMem(FALSE);
- Base = Base & ((1L << 32) - 1);
-
- if (useDevMem) {
- if (devMemFd < 0) {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t) 0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
- if (base == MAP_FAILED) {
- FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
- FatalError("%s: Address 0x%lx outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base + BUS_BASE);
- if (base == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- munmap((caddr_t) Base, Size);
-}
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
- if ((long) ptr == -1) {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return -1;
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,
- "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base,
- ptr[0] | (ptr[1] << 8));
-#endif
- (void) memcpy(Buf, (void *) (ptr + Offset), Len);
- (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return Len;
-}
-
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
extern int ioperm(unsigned long from, unsigned long num, int on);
@@ -422,11 +210,6 @@ xf86DisableIO()
#endif /* USE_ALPHA_PIO */
-#define vuip volatile unsigned int *
-
-static void *memSBase = 0;
-static void *memBase = 0;
-
extern int readDense8(void *Base, register unsigned long Offset);
extern int readDense16(void *Base, register unsigned long Offset);
extern int readDense32(void *Base, register unsigned long Offset);
@@ -437,223 +220,6 @@ extern void
extern void
writeDense32(int Value, void *Base, register unsigned long Offset);
-static int readSparse8(void *Base, register unsigned long Offset);
-static int readSparse16(void *Base, register unsigned long Offset);
-static int readSparse32(void *Base, register unsigned long Offset);
-static void
- writeSparseNB8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB32(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse32(int Value, void *Base, register unsigned long Offset);
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-extern int sysarch(int, void *);
-
-struct parms {
- u_int64_t hae;
-};
-
-static void
-sethae(u_int64_t hae)
-{
-#ifndef ALPHA_SETHAE
-#define ALPHA_SETHAE 0
-#endif
- static struct parms p;
-
- if (p.hae != hae) {
- p.hae = hae;
- sysarch(ALPHA_SETHAE, (char *) &p);
- }
-}
-#endif
-
-static void *
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
- int flags)
-{
- static Bool was_here = FALSE;
-
- if (!was_here) {
- was_here = TRUE;
-
- checkDevMem(FALSE);
-
- xf86WriteMmio8 = writeSparse8;
- xf86WriteMmio16 = writeSparse16;
- xf86WriteMmio32 = writeSparse32;
- xf86WriteMmioNB8 = writeSparseNB8;
- xf86WriteMmioNB16 = writeSparseNB16;
- xf86WriteMmioNB32 = writeSparseNB32;
- xf86ReadMmio8 = readSparse8;
- xf86ReadMmio16 = readSparse16;
- xf86ReadMmio32 = readSparse32;
-
- memBase = mmap((caddr_t) 0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd, (off_t) BUS_BASE);
- memSBase = mmap((caddr_t) 0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd, (off_t) BUS_BASE_BWX);
-
- if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
- strerror(errno));
- }
- }
- return (void *) ((unsigned long) memBase + Base);
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size)
-{
-}
-
-static int
-readSparse8(void *Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
-
- mem_barrier();
- Offset += (unsigned long) Base - (unsigned long) memBase;
- shift = (Offset & 0x3) << 3;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- result = *(vuip) ((unsigned long) memSBase + (Offset << 5));
- result >>= shift;
- return 0xffUL & result;
-}
-
-static int
-readSparse16(void *Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
-
- mem_barrier();
- Offset += (unsigned long) Base - (unsigned long) memBase;
- shift = (Offset & 0x2) << 3;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- result =
- *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2)));
- result >>= shift;
- return 0xffffUL & result;
-}
-
-static int
-readSparse32(void *Base, register unsigned long Offset)
-{
- mem_barrier();
- return *(vuip) ((unsigned long) Base + (Offset));
-}
-
-static void
-writeSparse8(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- write_mem_barrier();
- Offset += (unsigned long) Base - (unsigned long) memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparse16(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- write_mem_barrier();
- Offset += (unsigned long) Base - (unsigned long) memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
- w * 0x00010001;
-
-}
-
-static void
-writeSparse32(int Value, void *Base, register unsigned long Offset)
-{
- write_mem_barrier();
- *(vuip) ((unsigned long) Base + (Offset)) = Value;
- return;
-}
-
-static void
-writeSparseNB8(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- Offset += (unsigned long) Base - (unsigned long) memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparseNB16(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- Offset += (unsigned long) Base - (unsigned long) memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
-#endif
- }
- *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
- w * 0x00010001;
-}
-
-static void
-writeSparseNB32(int Value, void *Base, register unsigned long Offset)
-{
- *(vuip) ((unsigned long) Base + (Offset)) = Value;
- return;
-}
-
void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset)
= writeDense8;
void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
index e295c9244..3a639b8c6 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
@@ -66,35 +66,6 @@
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
-#ifdef __arm32__
-#include "machine/devmap.h"
-struct memAccess {
- int ioctl;
- struct map_info memInfo;
- void *regionVirtBase;
- Bool Checked;
- Bool OK;
-};
-
-static void *xf86MapInfoMap();
-static void xf86MapInfoUnmap();
-static struct memAccess *checkMapInfo();
-extern int vgaPhysLinearBase;
-
-/* A memAccess structure is needed for each possible region */
-struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
- FALSE, FALSE
-};
-
-struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
- FALSE, FALSE
-};
-
-struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
- FALSE, FALSE
-};
-#endif /* __arm32__ */
-
#if defined(__NetBSD__) && !defined(MAP_FILE)
#define MAP_FLAGS MAP_SHARED
#else
@@ -108,12 +79,8 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
/* Video Memory Mapping section */
/***************************************************************************/
-static Bool useDevMem = FALSE;
static int devMemFd = -1;
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
/*
* Check if /dev/mem can be mmap'd. If it can't print a warning when
* "warn" is TRUE.
@@ -137,7 +104,6 @@ checkDevMem(Bool warn)
if (base != MAP_FAILED) {
munmap((caddr_t) base, 4096);
devMemFd = fd;
- useDevMem = TRUE;
return;
}
else {
@@ -146,7 +112,6 @@ checkDevMem(Bool warn)
xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
DEV_MEM, strerror(errno));
}
- useDevMem = FALSE;
return;
}
}
@@ -154,266 +119,17 @@ checkDevMem(Bool warn)
xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
DEV_MEM, strerror(errno));
}
- useDevMem = FALSE;
return;
}
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
-
checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = armMapVidMem;
- pVidMem->unmapVidMem = armUnmapVidMem;
pVidMem->initialised = TRUE;
}
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- void *base;
-
- checkDevMem(FALSE);
-
- if (useDevMem) {
- if (devMemFd < 0) {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t) 0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
- if (base == MAP_FAILED) {
- FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
- FatalError("%s: Address 0x%x outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
- if (base == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- munmap((caddr_t) Base, Size);
-}
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
- if ((long) ptr == -1) {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return -1;
- }
-#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
-#endif
- (void) memcpy(Buf, (void *) (ptr + Offset), Len);
- (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return Len;
-}
-
-/* XXX This needs to be updated for the ND */
-
-/*
-** Find out whether the console driver provides memory mapping information
-** for the specified region and return the map_info pointer. Print a warning if required.
-*/
-static struct memAccess *
-checkMapInfo(Bool warn, int Region)
-{
- struct memAccess *memAccP;
-
- switch (Region) {
- case VGA_REGION:
- memAccP = &vgaMemInfo;
- break;
-
- case LINEAR_REGION:
- memAccP = &linearMemInfo;
- break;
-
- case MMIO_REGION:
- memAccP = &ioMemInfo;
- break;
-
- default:
- return NULL;
- break;
- }
-
- if (!memAccP->Checked) {
- if (ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) ==
- -1) {
- if (warn) {
- xf86Msg(X_WARNING,
- "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
- Region, strerror(errno));
- }
- }
- else {
- if (memAccP->memInfo.u.map_info_mmap.map_offset != MAP_INFO_UNKNOWN)
- memAccP->OK = TRUE;
- }
- memAccP->Checked = TRUE;
- }
- if (memAccP->OK) {
- return memAccP;
- }
- else {
- return NULL;
- }
-}
-
-static void *
-xf86MapInfoMap(struct memAccess *memInfoP, void *Base, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
- Size = (unsigned long) Base + Size;
- }
- else {
- Size = mapInfoP->u.map_info_mmap.map_size;
- }
-
- switch (mapInfoP->method) {
- case MAP_MMAP:
- /* Need to remap if size is unknown because we may not have
- mapped the whole region initially */
- if (memInfoP->regionVirtBase == NULL ||
- mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
- if ((memInfoP->regionVirtBase =
- mmap((caddr_t) 0,
- Size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- xf86Info.consoleFd,
- (unsigned long) mapInfoP->u.map_info_mmap.map_offset))
- == (void *) -1) {
- FatalError
- ("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
- mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
- }
- if (mapInfoP->u.map_info_mmap.internal_offset > 0)
- memInfoP->regionVirtBase +=
- mapInfoP->u.map_info_mmap.internal_offset;
- }
- break;
-
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-
- return (void *) ((int) memInfoP->regionVirtBase + (int) Base);
-}
-
-static void
-xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- switch (mapInfoP->method) {
- case MAP_MMAP:
- if (memInfoP->regionVirtBase != NULL) {
- if (mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
- Size = mapInfoP->u.map_info_mmap.map_size;
- munmap((caddr_t) memInfoP->regionVirtBase, Size);
- memInfoP->regionVirtBase = NULL;
- }
- break;
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-}
-
-static void *
-armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- struct memAccess *memInfoP;
-
- if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
- /*
- ** xf86 passes in a physical address offset from the start
- ** of physical memory, but xf86MapInfoMap expects an
- ** offset from the start of the specified region - it gets
- ** the physical address of the region from the display driver.
- */
- switch (Region) {
- case LINEAR_REGION:
- if (vgaPhysLinearBase) {
- Base -= vgaPhysLinearBase;
- }
- break;
- case VGA_REGION:
- Base -= 0xA0000;
- break;
- }
-
- base = xf86MapInfoMap(memInfoP, Base, Size);
- return base;
- }
- return mapVidMem(ScreenNum, Base, Size, flags);
-}
-
-static void
-armUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- struct memAccess *memInfoP;
-
- if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
- xf86MapInfoUnmap(memInfoP, Base, Size);
- }
- unmapVidMem(ScreenNum, Base, Size);
-}
-
#ifdef USE_DEV_IO
static int IoFd = -1;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c
deleted file mode 100644
index e7a36f8bf..000000000
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "shared/xf86Axp.h"
-#include <sys/param.h>
-#include "xf86_OSlib.h"
-#include <stdio.h>
-#include <sys/sysctl.h>
-
-axpDevice bsdGetAXP(void);
-
-/*
- * BSD does a very nice job providing system information to
- * user space programs. Unfortunately it doesn't provide all
- * the information required. Therefore we just obtain the
- * system type and look up the rest from a list we maintain
- * ourselves.
- */
-
-typedef struct {
- char *name;
- int type;
-} _AXP;
-
-static _AXP axpList[] = {
- {"apecs", APECS},
- {"pyxis", PYXIS},
- {"cia", CIA},
- {"irongate", IRONGATE},
- {"lca", LCA},
- {"t2", T2},
- {"tsunami", TSUNAMI},
- {NULL, SYS_NONE}
-};
-
-axpDevice
-bsdGetAXP(void)
-{
- int i;
- char sysname[64];
- size_t len = sizeof(sysname);
-
-#ifdef __OpenBSD__
- int mib[3];
- int error;
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_TYPE;
-
- if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
-#else
- if ((sysctlbyname("hw.chipset.type", &sysname, &len, 0, 0)) < 0)
-#endif
- FatalError("bsdGetAXP: can't find machine type\n");
-#ifdef DEBUG
- xf86Msg(X_INFO, "AXP is a: %s\n", sysname);
-#endif
- for (i = 0;; i++) {
- if (axpList[i].name == NULL)
- return SYS_NONE;
- if (!strcmp(sysname, axpList[i].name))
- return axpList[i].type;
- }
-}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
index 745319054..6c3bbcb48 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
@@ -34,27 +34,6 @@
#include <errno.h>
#include <sys/mman.h>
-#ifdef HAS_MTRR_SUPPORT
-#ifndef __NetBSD__
-#include <sys/types.h>
-#include <sys/memrange.h>
-#else
-#include "memrange.h"
-#endif
-#define X_MTRR_ID "XFree86"
-#endif
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-#include <machine/mtrr.h>
-#include <machine/sysarch.h>
-#include <sys/queue.h>
-#ifdef __x86_64__
-#define i386_set_mtrr x86_64_set_mtrr
-#define i386_get_mtrr x86_64_get_mtrr
-#define i386_iopl x86_64_iopl
-#endif
-#endif
-
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
@@ -85,20 +64,6 @@ static int devMemFd = -1;
#define DEV_APERTURE "/dev/xf86"
#endif
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
-#ifdef HAS_MTRR_SUPPORT
-static void *setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, void *);
-static Bool cleanMTRR(void);
-#endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static void *NetBSDsetWC(int, unsigned long, unsigned long, Bool,
- MessageType);
-static void NetBSDundoWC(int, void *);
-#endif
-
/*
* Check if /dev/mem can be mmap'd. If it can't print a warning when
* "warn" is TRUE.
@@ -188,119 +153,10 @@ void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
-
- if (useDevMem)
- pci_system_init_dev_mem(devMemFd);
-
-#ifdef HAS_MTRR_SUPPORT
- if (useDevMem) {
- if (cleanMTRR()) {
- pVidMem->setWC = setWC;
- pVidMem->undoWC = undoWC;
- }
- }
-#endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
- pVidMem->setWC = NetBSDsetWC;
- pVidMem->undoWC = NetBSDundoWC;
-#endif
- pVidMem->initialised = TRUE;
-}
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- void *base;
+ pci_system_init_dev_mem(devMemFd);
- checkDevMem(FALSE);
-
- if (useDevMem) {
- if (devMemFd < 0) {
- FatalError("xf86MapVidMem: failed to open %s (%s)",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t) 0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t) Base);
- if (base == MAP_FAILED) {
- FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
- "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
- FatalError("%s: Address 0x%lx outside allowable range",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
- if (base == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
- strerror(errno));
- }
- return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- munmap((caddr_t) Base, Size);
-}
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t) Base);
- if ((long) ptr == -1) {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
-#ifdef __OpenBSD__
- if (Base < 0xa0000) {
- xf86Msg(X_WARNING, SYSCTL_MSG2);
- }
-#endif
- return -1;
- }
-#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
-#endif
- (void) memcpy(Buf, (void *) (ptr + Offset), Len);
- (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return Len;
+ pVidMem->initialised = TRUE;
}
#ifdef USE_I386_IOPL
@@ -470,417 +326,3 @@ xf86SetRGBOut()
return;
}
#endif
-
-#ifdef HAS_MTRR_SUPPORT
-/* memory range (MTRR) support for FreeBSD */
-
-/*
- * This code is experimental. Some parts may be overkill, and other parts
- * may be incomplete.
- */
-
-/*
- * getAllRanges returns the full list of memory ranges with attributes set.
- */
-
-static struct mem_range_desc *
-getAllRanges(int *nmr)
-{
- struct mem_range_desc *mrd;
- struct mem_range_op mro;
-
- /*
- * Find how many ranges there are. If this fails, then the kernel
- * probably doesn't have MTRR support.
- */
- mro.mo_arg[0] = 0;
- if (ioctl(devMemFd, MEMRANGE_GET, &mro))
- return NULL;
- *nmr = mro.mo_arg[0];
- mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
- mro.mo_arg[0] = *nmr;
- mro.mo_desc = mrd;
- if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
- free(mrd);
- return NULL;
- }
- return mrd;
-}
-
-/*
- * cleanMTRR removes any memory attribute that may be left by a previous
- * X server. Normally there won't be any, but this takes care of the
- * case where a server crashed without being able finish cleaning up.
- */
-
-static Bool
-cleanMTRR()
-{
- struct mem_range_desc *mrd;
- struct mem_range_op mro;
- int nmr, i;
-
- /* This shouldn't happen */
- if (devMemFd < 0)
- return FALSE;
-
- if (!(mrd = getAllRanges(&nmr)))
- return FALSE;
-
- for (i = 0; i < nmr; i++) {
- if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
- (mrd[i].mr_flags & MDF_ACTIVE)) {
-#ifdef DEBUG
- ErrorF("Clean for (0x%lx,0x%lx)\n",
- (unsigned long) mrd[i].mr_base,
- (unsigned long) mrd[i].mr_len);
-#endif
- if (mrd[i].mr_flags & MDF_FIXACTIVE) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- mrd[i].mr_flags = MDF_UNCACHEABLE;
- }
- else {
- mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
- }
- mro.mo_desc = mrd + i;
- ioctl(devMemFd, MEMRANGE_SET, &mro);
- }
- }
-#ifdef DEBUG
- sleep(10);
-#endif
- free(mrd);
- return TRUE;
-}
-
-typedef struct x_RangeRec {
- struct mem_range_desc mrd;
- Bool wasWC;
- struct x_RangeRec *next;
-} RangeRec, *RangePtr;
-
-static void
-freeRangeList(RangePtr range)
-{
- RangePtr rp;
-
- while (range) {
- rp = range;
- range = rp->next;
- free(rp);
- }
-}
-
-static RangePtr
-dupRangeList(RangePtr list)
-{
- RangePtr new = NULL, rp, p;
-
- rp = list;
- while (rp) {
- p = xnfalloc(sizeof(RangeRec));
- *p = *rp;
- p->next = new;
- new = p;
- rp = rp->next;
- }
- return new;
-}
-
-static RangePtr
-sortRangeList(RangePtr list)
-{
- RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
- unsigned long minBase;
-
- /* Sort by base address */
- rp1 = copy = dupRangeList(list);
- while (rp1) {
- minBase = rp1->mrd.mr_base;
- minp = rp1;
- minprev = NULL;
- prev = rp1;
- rp2 = rp1->next;
- while (rp2) {
- if (rp2->mrd.mr_base < minBase) {
- minBase = rp2->mrd.mr_base;
- minp = rp2;
- minprev = prev;
- }
- prev = rp2;
- rp2 = rp2->next;
- }
- if (minprev) {
- minprev->next = minp->next;
- rp1 = copy;
- }
- else {
- rp1 = minp->next;
- }
- minp->next = sorted;
- sorted = minp;
- }
- return sorted;
-}
-
-/*
- * findRanges returns a list of ranges that overlap the specified range.
- */
-
-static void
-findRanges(unsigned long base, unsigned long size, RangePtr * ucp,
- RangePtr * wcp)
-{
- struct mem_range_desc *mrd;
- int nmr, i;
- RangePtr rp, *p;
-
- if (!(mrd = getAllRanges(&nmr)))
- return;
-
- for (i = 0; i < nmr; i++) {
- if ((mrd[i].mr_flags & MDF_ACTIVE) &&
- mrd[i].mr_base < base + size &&
- mrd[i].mr_base + mrd[i].mr_len > base) {
- if (mrd[i].mr_flags & MDF_WRITECOMBINE)
- p = wcp;
- else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
- p = ucp;
- else
- continue;
- rp = xnfalloc(sizeof(RangeRec));
- rp->mrd = mrd[i];
- rp->next = *p;
- *p = rp;
- }
- }
- free(mrd);
-}
-
-/*
- * This checks if the existing overlapping ranges fully cover the requested
- * range. Is this overkill?
- */
-
-static Bool
-fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
-{
- RangePtr rp1, sorted = NULL;
- unsigned long end;
-
- sorted = sortRangeList(overlap);
- /* Look for gaps */
- rp1 = sorted;
- end = base + size;
- while (rp1) {
- if (rp1->mrd.mr_base > base) {
- freeRangeList(sorted);
- return FALSE;
- }
- else {
- base = rp1->mrd.mr_base + rp1->mrd.mr_len;
- }
- if (base >= end) {
- freeRangeList(sorted);
- return TRUE;
- }
- rp1 = rp1->next;
- }
- freeRangeList(sorted);
- return FALSE;
-}
-
-static void *
-addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
- RangePtr uc = NULL, wc = NULL, retlist = NULL;
- struct mem_range_desc mrd;
- struct mem_range_op mro;
-
- findRanges(base, size, &uc, &wc);
-
- /* See of the full range is already WC */
- if (!uc && fullCoverage(base, size, wc)) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx) was already set\n",
- base, size);
- return NULL;
- }
-
- /* Otherwise, try to add the new range */
- mrd.mr_base = base;
- mrd.mr_len = size;
- strcpy(mrd.mr_owner, X_MTRR_ID);
- mrd.mr_flags = MDF_WRITECOMBINE;
- mro.mo_desc = &mrd;
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to set write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- return NULL;
- }
- else {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx)\n", base, size);
- retlist = xnfalloc(sizeof(RangeRec));
- retlist->mrd = mrd;
- retlist->wasWC = FALSE;
- retlist->next = NULL;
- return retlist;
- }
-}
-
-static void *
-delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
- RangePtr uc = NULL, wc = NULL, retlist = NULL;
- struct mem_range_desc mrd;
- struct mem_range_op mro;
-
- findRanges(base, size, &uc, &wc);
-
- /*
- * See of the full range is already not WC, or if there is full
- * coverage from UC ranges.
- */
- if (!wc || fullCoverage(base, size, uc)) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx) was already clear\n",
- base, size);
- return NULL;
- }
-
- /* Otherwise, try to add the new range */
- mrd.mr_base = base;
- mrd.mr_len = size;
- strcpy(mrd.mr_owner, X_MTRR_ID);
- mrd.mr_flags = MDF_UNCACHEABLE;
- mro.mo_desc = &mrd;
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to remove write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- /* XXX Should then remove all of the overlapping WC ranges */
- return NULL;
- }
- else {
- xf86DrvMsg(screenNum, from,
- "Removed Write-combining range (0x%lx,0x%lx)\n", base, size);
- retlist = xnfalloc(sizeof(RangeRec));
- retlist->mrd = mrd;
- retlist->wasWC = TRUE;
- retlist->next = NULL;
- return retlist;
- }
-}
-
-static void *
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
- MessageType from)
-{
- if (enable)
- return addWC(screenNum, base, size, from);
- else
- return delWC(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, void *list)
-{
- RangePtr rp;
- struct mem_range_op mro;
- Bool failed;
-
- rp = list;
- while (rp) {
-#ifdef DEBUG
- ErrorF("Undo for (0x%lx,0x%lx), %d\n",
- (unsigned long) rp->mrd.mr_base,
- (unsigned long) rp->mrd.mr_len, rp->wasWC);
-#endif
- failed = FALSE;
- if (rp->wasWC) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- rp->mrd.mr_flags = MDF_WRITECOMBINE;
- strcpy(rp->mrd.mr_owner, "unknown");
- }
- else {
- mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
- }
- mro.mo_desc = &rp->mrd;
-
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- if (!rp->wasWC) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- rp->mrd.mr_flags = MDF_UNCACHEABLE;
- strcpy(rp->mrd.mr_owner, "unknown");
- if (ioctl(devMemFd, MEMRANGE_SET, &mro))
- failed = TRUE;
- }
- else
- failed = TRUE;
- }
- if (failed) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to restore MTRR range (0x%lx,0x%lx)\n",
- (unsigned long) rp->mrd.mr_base,
- (unsigned long) rp->mrd.mr_len);
- }
- rp = rp->next;
- }
-}
-
-#endif /* HAS_MTRR_SUPPORT */
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static void *
-NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
- MessageType from)
-{
- struct mtrr *mtrrp;
- int n;
-
- xf86DrvMsg(screenNum, X_WARNING,
- "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
- base, (base + size));
-
- mtrrp = xnfalloc(sizeof(struct mtrr));
- mtrrp->base = base;
- mtrrp->len = size;
- mtrrp->type = MTRR_TYPE_WC;
-
- /*
- * MTRR_PRIVATE will make this MTRR get reset automatically
- * if this process exits, so we have no need for an explicit
- * cleanup operation when starting a new server.
- */
-
- if (enable)
- mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
- else
- mtrrp->flags = 0;
- n = 1;
-
- if (i386_set_mtrr(mtrrp, &n) < 0) {
- free(mtrrp);
- return NULL;
- }
- return mtrrp;
-}
-
-static void
-NetBSDundoWC(int screenNum, void *list)
-{
- struct mtrr *mtrrp = (struct mtrr *) list;
- int n;
-
- if (mtrrp == NULL)
- return;
- n = 1;
- mtrrp->flags &= ~MTRR_VALID;
- i386_set_mtrr(mtrrp, &n);
- free(mtrrp);
-}
-#endif
diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
index 3fd28c3b5..b1cf7eb1b 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
@@ -44,74 +44,18 @@
#define DEV_MEM "/dev/xf86"
#endif
-static void *ppcMapVidMem(int, unsigned long, unsigned long, int flags);
-static void ppcUnmapVidMem(int, void *, unsigned long);
-
Bool xf86EnableIO(void);
void xf86DisableIO(void);
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = ppcMapVidMem;
- pVidMem->unmapMem = ppcUnmapVidMem;
pVidMem->initialised = TRUE;
xf86EnableIO();
}
volatile unsigned char *ioBase = MAP_FAILED;
-static void *
-ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- int fd = xf86Info.consoleFd;
- void *base;
-
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
-#endif
-
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
- if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)",
- "xf86MapVidMem", Size, Base, strerror(errno));
-
- return base;
-}
-
-static void
-ppcUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- munmap(Base, Size);
-}
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int rv;
- static int kmem = -1;
-
- if (kmem == -1) {
- kmem = open(DEV_MEM, 2);
- if (kmem == -1) {
- FatalError("xf86ReadBIOS: open %s", DEV_MEM);
- }
- }
-
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len);
-#endif
-
- lseek(kmem, Base + Offset, 0);
- rv = read(kmem, Buf, Len);
-
- return rv;
-}
-
Bool
xf86EnableIO()
{
diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
index 02951d602..5bed01790 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -38,48 +38,8 @@
/* Video Memory Mapping section */
/***************************************************************************/
-static void *sparc64MapVidMem(int, unsigned long, unsigned long, int);
-static void sparc64UnmapVidMem(int, void *, unsigned long);
-
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = sparc64MapVidMem;
- pVidMem->unmapMem = sparc64UnmapVidMem;
pVidMem->initialised = TRUE;
}
-
-static void *
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
- int flags)
-{
- int fd = xf86Info.consoleFd;
- void *base;
-
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
-#endif
-
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
- if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
- "xf86MapVidMem", Size, Base, strerror(errno));
- return base;
-}
-
-static void
-sparc64UnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- munmap(Base, Size);
-}
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
-
- return 0;
-}
diff --git a/xorg-server/hw/xfree86/os-support/hurd/Makefile.am b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am
index f228c1ce4..38660544a 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libhurd.la
-libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \
+libhurd_la_SOURCES = hurd_bell.c hurd_init.c \
hurd_video.c \
$(srcdir)/../shared/VTsw_noop.c \
$(srcdir)/../shared/posix_tty.c \
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c
deleted file mode 100644
index 8e089cadb..000000000
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 1997 by UCHIYAMA Yasushi
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of UCHIYAMA Yasushi not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. UCHIYAMA Yasushi makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include<mach.h>
-#include<device/device.h>
-#include<mach/machine/mach_i386.h>
-#include <hurd.h>
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define BIOS_SIZE 0x20000
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- mach_port_t device, mem_dev;
- memory_object_t mem_obj;
- vm_address_t addr = (vm_address_t) 0; /* serach starting address */
- kern_return_t err;
-
- err = get_privileged_ports(NULL, &device);
- if (err) {
- errno = err;
- FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",
- strerror(errno));
- }
- err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
- mach_port_deallocate(mach_task_self(), device);
- if (err) {
- errno = err;
- FatalError("xf86ReadBIOS() can't device_open. (%s)\n", strerror(errno));
- }
- err =
- device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, BIOS_SIZE,
- &mem_obj, 0);
- if (err) {
- errno = err;
- FatalError("xf86ReadBIOS() can't device_map. (%s)\n", strerror(errno));
- }
- err = vm_map(mach_task_self(),
- &addr,
- BIOS_SIZE,
- 0,
- TRUE,
- mem_obj,
- Base,
- FALSE,
- VM_PROT_READ | VM_PROT_WRITE,
- VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
- mach_port_deallocate(mach_task_self(), mem_obj);
- if (err) {
- errno = err;
- FatalError("xf86ReadBIOS() can't vm_map. (%s)\n", strerror(errno));
- }
-
- memcpy(Buf, (void *) ((int) addr + Offset), Len);
-
- err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
- if (err) {
- errno = err;
- FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",
- strerror(errno));
- }
-
- return Len;
-}
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
index dc1a8e670..2a96393b0 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
@@ -42,68 +42,6 @@
/**************************************************************************
* Video Memory Mapping section
***************************************************************************/
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
- mach_port_t device, mem_dev;
- memory_object_t mem_obj;
- kern_return_t err;
- vm_address_t addr = (vm_address_t) 0;
-
- err = get_privileged_ports(NULL, &device);
- if (err) {
- errno = err;
- FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",
- strerror(errno));
- }
- err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
- mach_port_deallocate(mach_task_self(), device);
- if (err) {
- errno = err;
- FatalError("xf86MapVidMem() can't device_open. (%s)\n",
- strerror(errno));
- }
-
- err =
- device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, Size, &mem_obj,
- 0);
- if (err) {
- errno = err;
- FatalError("xf86MapVidMem() can't device_map. (%s)\n", strerror(errno));
- }
- err = vm_map(mach_task_self(), &addr, Size, 0, /* mask */
- TRUE, /* anywhere */
- mem_obj, (vm_offset_t) Base, FALSE, /* copy on write */
- VM_PROT_READ | VM_PROT_WRITE,
- VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
- mach_port_deallocate(mach_task_self(), mem_obj);
- if (err) {
- errno = err;
- FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n",
- strerror(errno));
- }
- mach_port_deallocate(mach_task_self(), mem_dev);
- if (err) {
- errno = err;
- FatalError
- ("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n",
- strerror(errno));
- }
- return (void *) addr;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- kern_return_t err = vm_deallocate(mach_task_self(), (int) Base, Size);
-
- if (err) {
- errno = err;
- ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",
- strerror(errno));
- }
- return;
-}
/**************************************************************************
* I/O Permissions section
@@ -146,8 +84,5 @@ xf86DisableIO()
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
pVidMem->initialised = TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.am b/xorg-server/hw/xfree86/os-support/linux/Makefile.am
index 1686dc2c1..50fcd1f28 100644
--- a/xorg-server/hw/xfree86/os-support/linux/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.am
@@ -2,9 +2,6 @@ noinst_LTLIBRARIES = liblinux.la
if LINUX_ALPHA
noinst_LTLIBRARIES += liblinuxev56.la
-PLATFORM_PCI_SUPPORT = \
- $(srcdir)/lnx_axp.c \
- $(srcdir)/../shared/xf86Axp.c
liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56
@@ -28,23 +25,18 @@ endif
liblinux_la_SOURCES = lnx_init.c lnx_video.c \
lnx_agp.c lnx_kmod.c lnx_bell.c lnx_platform.c \
- $(srcdir)/../shared/bios_mmap.c \
$(srcdir)/../shared/VTsw_usl.c \
$(srcdir)/../shared/posix_tty.c \
$(srcdir)/../shared/vidmem.c \
$(srcdir)/../shared/sigio.c \
$(ACPI_SRCS) \
$(APM_SRCS) \
- $(LOGIND_SRCS) \
- $(PLATFORM_PCI_SUPPORT)
+ $(LOGIND_SRCS)
AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES)
AM_CPPFLAGS = $(XORG_INCS) $(PLATFORM_INCLUDES) $(LIBDRM_CFLAGS)
-EXTRA_DIST = \
- $(srcdir)/../shared/xf86Axp.h
-
if LINUX_ALPHA
liblinux_la_LIBADD = liblinuxev56.la
endif
diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
index 6181eb9c5..79b9a8858 100644
--- a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
+++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
@@ -70,6 +70,20 @@ static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
#endif /* DoSubModules */
+static Bool
+readLegacy(struct pci_device *dev, unsigned char *buf, int base, int len)
+{
+ void *map;
+
+ if (!pci_device_map_legacy(dev, base, len, 0, &map))
+ return FALSE;
+
+ memcpy(buf, map, len);
+ pci_device_unmap_legacy(dev, man, len);
+
+ return TRUE;
+}
+
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
{
@@ -222,7 +236,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
Int10Current = pInt;
DebugF("Mapping int area\n");
- if (xf86ReadBIOS(0, 0, (unsigned char *) 0, LOW_PAGE_SIZE) < 0) {
+ /* note: yes, we really are writing the 0 page here */
+ if (!readLegacy(pInt->dev, (unsigned char *) 0, 0, LOW_PAGE_SIZE)) {
xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
goto error3;
}
@@ -236,7 +251,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
memset((void *) V_BIOS, 0, SYS_BIOS - V_BIOS);
DebugF("Reading BIOS\n");
for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
- if (xf86ReadBIOS(cs, 0, (void *) cs, V_BIOS_SIZE) < V_BIOS_SIZE)
+ if (!readLegacy(pInt->dev, (void *)cs, cs, V_BIOS_SIZE))
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x%06lX.\n",
(long) cs);
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c
deleted file mode 100644
index d65a3a487..000000000
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c
+++ /dev/null
@@ -1,103 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "xf86.h"
-#include "shared/xf86Axp.h"
-
-axpDevice lnxGetAXP(void);
-
-typedef struct {
- char *sysName;
- char *sysVari;
- char *cpu;
- axpDevice sys;
-} AXP;
-
-static AXP axpList[] = {
- {"Tsunami", NULL, NULL, TSUNAMI},
- {"Eiger", NULL, NULL, TSUNAMI},
- {"Noname", NULL, NULL, LCA},
- {"AlphaBook1", NULL, NULL, LCA},
- {"EB66", NULL, NULL, LCA},
- {"EB64+", NULL, NULL, APECS},
- {"Noritake", NULL, "EV5", CIA},
- {"Noritake", NULL, "EV56", CIA},
- {"Noritake", NULL, NULL, APECS},
- {"XL", NULL, NULL, APECS},
- {"Avanti", NULL, NULL, APECS},
- {"Mikasa", NULL, "EV5", CIA},
- {"Mikasa", NULL, "EV56", CIA},
- {"Mikasa", NULL, NULL, APECS},
- {"EB164", "EB164", NULL, CIA},
- {"EB164", "PC164", NULL, CIA},
- {"EB164", "LX164", NULL, PYXIS},
- {"EB164", "SX164", NULL, PYXIS},
- {"EB164", "RX164", NULL, POLARIS},
- {"Alcor", NULL, NULL, CIA},
- {"Takara", NULL, NULL, CIA},
- {"Sable", NULL, "EV5", T2_GAMMA},
- {"Sable", NULL, "EV56", T2_GAMMA},
- {"Sable", NULL, NULL, T2},
- {"Rawhide", NULL, NULL, MCPCIA},
- {"Jensen", NULL, NULL, JENSEN},
- {"Miata", NULL, NULL, PYXIS_CIA},
- {"Ruffian", NULL, NULL, PYXIS_CIA},
- {"Nautilus", NULL, NULL, IRONGATE},
- {NULL, NULL, NULL, SYS_NONE}
-};
-
-axpDevice
-lnxGetAXP(void)
-{
- FILE *file;
- int count = 0;
- char res[256];
- char cpu[255];
- char systype[255];
- char sysvari[255];
-
- if (!(file = fopen("/proc/cpuinfo", "r")))
- return SYS_NONE;
- do {
- if (!fgets(res, 0xff, file))
- return SYS_NONE;
- switch (count) {
- case 1:
- sscanf(res, "cpu model : %s", cpu);
- DebugF("CPU %s\n", cpu);
- break;
- case 5:
- sscanf(res, "system type : %s", systype);
- DebugF("system type : %s\n", systype);
- break;
- case 6:
- sscanf(res, "system variation : %s", sysvari);
- DebugF("system variation: %s\n", sysvari);
- break;
- }
- count++;
- } while (count < 8);
-
- fclose(file);
-
- count = 0;
-
- do {
- if (!axpList[count].sysName || !strcmp(axpList[count].sysName, systype)) {
- if (axpList[count].sysVari &&
- strcmp(axpList[count].sysVari, sysvari)) {
- count++;
- continue;
- };
- if (axpList[count].cpu && strcmp(axpList[count].cpu, cpu)) {
- count++;
- continue;
- }
- return axpList[count].sys;
- }
- count++;
- } while (1);
-}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 85709c629..94853070d 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -76,6 +76,9 @@ switch_to(int vt, const char *from)
FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
void
xf86OpenConsole(void)
{
@@ -166,7 +169,6 @@ xf86OpenConsole(void)
i = 0;
while (vcs[i] != NULL) {
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0)
break;
@@ -272,6 +274,8 @@ xf86OpenConsole(void)
}
}
+#pragma GCC diagnostic pop
+
void
xf86CloseConsole(void)
{
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
index ffffc81c5..c09d71947 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
@@ -38,13 +38,6 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
-#ifdef __alpha__
-#include "shared/xf86Axp.h"
-#endif
-
-#ifdef HAS_MTRR_SUPPORT
-#include <asm/mtrr.h>
-#endif
static Bool ExtendedEnabled = FALSE;
@@ -72,405 +65,16 @@ extern int iopl(int __level);
#endif
-#ifdef __alpha__
-#define BUS_BASE bus_base
-#else
-#define BUS_BASE (0)
-#endif /* __alpha__ */
-
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
-#if defined (__alpha__)
-extern void sethae(unsigned long hae);
-extern unsigned long _bus_base __P((void)) __attribute__ ((const));
-extern unsigned long _bus_base_sparse __P((void)) __attribute__ ((const));
-
-static void *mapVidMemSparse(int, unsigned long, unsigned long, int);
-extern axpDevice lnxGetAXP(void);
-static void unmapVidMemSparse(int, void *, unsigned long);
-static axpDevice axpSystem = -1;
-static Bool needSparse;
-static unsigned long hae_thresh;
-static unsigned long hae_mask;
-static unsigned long bus_base;
-#endif
-
-#ifdef HAS_MTRR_SUPPORT
-
-#define SPLIT_WC_REGIONS 1
-
-static void *setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, void *);
-
-/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
- driver will clean up when we exit. */
-#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */
-#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had
- a problem. */
-static int mtrr_fd = MTRR_FD_UNOPENED;
-
-/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0,
- and will fail on Linux 2.2 with MTRR support configured out,
- so verbosity should be chosen appropriately. */
-static Bool
-mtrr_open(int verbosity)
-{
- /* Only report absence of /proc/mtrr once. */
- static Bool warned = FALSE;
-
- if (mtrr_fd == MTRR_FD_UNOPENED) {
- mtrr_fd = open("/proc/mtrr", O_WRONLY);
-
- if (mtrr_fd < 0)
- mtrr_fd = MTRR_FD_PROBLEM;
- }
-
- if (mtrr_fd == MTRR_FD_PROBLEM) {
- /* To make sure we only ever warn once, need to check
- verbosity outside xf86MsgVerb */
- if (!warned && verbosity <= xf86GetVerbosity()) {
- xf86MsgVerb(X_WARNING, verbosity,
- "System lacks support for changing MTRRs\n");
- warned = TRUE;
- }
-
- return FALSE;
- }
- else
- return TRUE;
-}
-
-/*
- * We maintain a list of WC regions for each physical mapping so they can
- * be undone when unmapping.
- */
-
-struct mtrr_wc_region {
- struct mtrr_sentry sentry;
- Bool added; /* added WC or removed it */
- struct mtrr_wc_region *next;
-};
-
-static struct mtrr_wc_region *
-mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
-{
- /* Some BIOS writers thought that setting wc over the mmio
- region of a graphics devices was a good idea. Try to fix
- it. */
-
- struct mtrr_gentry gent;
- struct mtrr_wc_region *wcreturn = NULL, *wcr;
- int count, ret = 0;
-
- /* Linux 2.0 users should not get a warning without -verbose */
- if (!mtrr_open(2))
- return NULL;
-
- for (gent.regnum = 0;
- ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
- if (gent.type != MTRR_TYPE_WRCOMB
- || gent.base + gent.size <= base || base + size <= gent.base)
- continue;
-
- /* Found an overlapping region. Delete it. */
-
- wcr = malloc(sizeof(*wcr));
- if (!wcr)
- return NULL;
- wcr->sentry.base = gent.base;
- wcr->sentry.size = gent.size;
- wcr->sentry.type = MTRR_TYPE_WRCOMB;
- wcr->added = FALSE;
-
- count = 3;
- while (count-- &&
- (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
-
- if (ret >= 0) {
- xf86DrvMsg(screenNum, from,
- "Removed MMIO write-combining range "
- "(0x%lx,0x%lx)\n",
- (unsigned long) gent.base, (unsigned long) gent.size);
- wcr->next = wcreturn;
- wcreturn = wcr;
- gent.regnum--;
- }
- else {
- free(wcr);
- xf86DrvMsgVerb(screenNum, X_WARNING, 0,
- "Failed to remove MMIO "
- "write-combining range (0x%lx,0x%lx)\n",
- (unsigned long)gent.base, (unsigned long) gent.size);
- }
- }
- return wcreturn;
-}
-
-static struct mtrr_wc_region *
-mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
-{
- struct mtrr_gentry gent;
- struct mtrr_wc_region *wcreturn = NULL, **wcr;
-
- if (!mtrr_open(2))
- return NULL;
-
- wcr = &wcreturn;
- for (gent.regnum = 0;
- ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
- if (gent.type == MTRR_TYPE_WRCOMB
- && ((gent.base >= base && gent.base + gent.size < base + size) ||
- (gent.base > base && gent.base + gent.size <= base + size))) {
- *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
- if (*wcr)
- gent.regnum--;
- while (*wcr) {
- wcr = &((*wcr)->next);
- }
- }
- }
- return wcreturn;
-}
-
-static struct mtrr_wc_region *
-mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
-{
- struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
-
- /*
- * There can be only one....
- */
-
- wcreturn = mtrr_remove_offending(screenNum, base, size, from);
- wcr = &wcreturn;
- while (*wcr) {
- wcr = &((*wcr)->next);
- }
-
- /* Linux 2.0 should not warn, unless the user explicitly asks for
- WC. */
-
- if (!mtrr_open(from == X_CONFIG ? 0 : 2))
- return wcreturn;
-
- *wcr = curwcr = malloc(sizeof(**wcr));
- if (!curwcr)
- return wcreturn;
-
- curwcr->sentry.base = base;
- curwcr->sentry.size = size;
- curwcr->sentry.type = MTRR_TYPE_WRCOMB;
- curwcr->added = TRUE;
- curwcr->next = NULL;
-
-#if SPLIT_WC_REGIONS
- /*
- * Splits up the write-combining region if it is not aligned on a
- * size boundary.
- */
-
- {
- unsigned long lbase, d_size = 1;
- unsigned long n_size = size;
- unsigned long n_base = base;
-
- for (lbase = n_base, d_size = 1; !(lbase & 1);
- lbase = lbase >> 1, d_size <<= 1);
- while (d_size > n_size)
- d_size = d_size >> 1;
- DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n", base, base + d_size - 1);
- n_base += d_size;
- n_size -= d_size;
- if (n_size) {
- xf86DrvMsgVerb(screenNum, X_INFO, 3, "Splitting WC range: "
- "base: 0x%lx, size: 0x%lx\n", base, size);
- curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size, from);
- }
- curwcr->sentry.size = d_size;
- }
-
- /*****************************************************************/
-#endif /* SPLIT_WC_REGIONS */
-
- if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
- /* Avoid printing on every VT switch */
- if (xf86ServerIsInitialising()) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx)\n", base, size);
- }
- return wcreturn;
- }
- else {
- *wcr = curwcr->next;
- free(curwcr);
-
- /* Don't complain about the VGA region: MTRR fixed
- regions aren't currently supported, but might be in
- the future. */
- if ((unsigned long) base >= 0x100000) {
- xf86DrvMsgVerb(screenNum, X_WARNING, 0,
- "Failed to set up write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- }
- return wcreturn;
- }
-}
-
-static void
-mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
-{
- struct mtrr_wc_region *p, *prev;
-
- if (mtrr_fd >= 0) {
- p = wcr;
- while (p) {
- if (p->added)
- ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
- prev = p;
- p = p->next;
- free(prev);
- }
- }
-}
-
-static void *
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
- MessageType from)
-{
- if (enable)
- return mtrr_add_wc_region(screenNum, base, size, from);
- else
- return mtrr_cull_wc_region(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, void *regioninfo)
-{
- mtrr_undo_wc_region(screenNum, regioninfo);
-}
-
-#endif /* HAS_MTRR_SUPPORT */
-
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
-#ifdef __alpha__
- if (axpSystem == -1) {
- axpSystem = lnxGetAXP();
- if ((needSparse = (_bus_base_sparse() > 0))) {
- hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
- hae_mask = xf86AXPParams[axpSystem].hae_mask;
- }
- bus_base = _bus_base();
- }
- if (needSparse) {
- xf86Msg(X_INFO, "Machine needs sparse mapping\n");
- pVidMem->mapMem = mapVidMemSparse;
- pVidMem->unmapMem = unmapVidMemSparse;
- }
- else {
- xf86Msg(X_INFO, "Machine type has 8/16 bit access\n");
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- }
-#else
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
-#endif /* __alpha__ */
-
-#ifdef HAS_MTRR_SUPPORT
- pVidMem->setWC = setWC;
- pVidMem->undoWC = undoWC;
-#endif
pVidMem->initialised = TRUE;
}
-#ifdef __sparc__
-/* Basically, you simply cannot do this on Sparc. You have to do something portable
- * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
- */
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- return NULL;
-}
-#else
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- void *base;
- int fd;
- int mapflags = MAP_SHARED;
- int prot;
- memType realBase, alignOff;
-
- realBase = Base & ~(getpagesize() - 1);
- alignOff = Base - realBase;
- DebugF("base: %lx, realBase: %lx, alignOff: %lx \n",
- Base, realBase, alignOff);
-
-#if defined(__ia64__) || defined(__arm__) || defined(__s390__)
-#ifndef MAP_WRITECOMBINED
-#define MAP_WRITECOMBINED 0x00010000
-#endif
-#ifndef MAP_NONCACHED
-#define MAP_NONCACHED 0x00020000
-#endif
- if (flags & VIDMEM_FRAMEBUFFER)
- mapflags |= MAP_WRITECOMBINED;
- else
- mapflags |= MAP_NONCACHED;
-#endif
-
-#if 0
- /* this will disappear when people upgrade their kernels */
- fd = open(DEV_MEM,
- ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
-#else
- fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
-#endif
- if (fd < 0) {
- FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
- strerror(errno));
- }
-
- if (flags & VIDMEM_READONLY)
- prot = PROT_READ;
- else
- prot = PROT_READ | PROT_WRITE;
-
- /* This requires linux-0.99.pl10 or above */
- base = mmap((caddr_t) 0, Size + alignOff, prot, mapflags, fd,
- (off_t) realBase + BUS_BASE);
- close(fd);
- if (base == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap framebuffer"
- " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno));
- }
- DebugF("base: %lx aligned base: %lx\n", base, (char *) base + alignOff);
- return (char *) base + alignOff;
-}
-#endif /* !(__sparc__) */
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- uintptr_t alignOff = (uintptr_t) Base
- - ((uintptr_t) Base & ~(getpagesize() - 1));
-
- DebugF("alignment offset: %lx\n", (unsigned long) alignOff);
- munmap((void *) ((uintptr_t) Base - alignOff), (Size + alignOff));
-}
-
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
@@ -565,8 +169,6 @@ xf86DisableIO(void)
#if defined (__alpha__)
-#define vuip volatile unsigned int *
-
extern int readDense8(void *Base, register unsigned long Offset);
extern int readDense16(void *Base, register unsigned long Offset);
extern int readDense32(void *Base, register unsigned long Offset);
@@ -577,284 +179,6 @@ extern void
extern void
writeDense32(int Value, void *Base, register unsigned long Offset);
-static int readSparse8(void *Base, register unsigned long Offset);
-static int readSparse16(void *Base, register unsigned long Offset);
-static int readSparse32(void *Base, register unsigned long Offset);
-static void
- writeSparseNB8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB32(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse32(int Value, void *Base, register unsigned long Offset);
-
-#define DENSE_BASE 0x2ff00000000UL
-#define SPARSE_BASE 0x30000000000UL
-
-static unsigned long msb_set = 0;
-
-static void *
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
- int flags)
-{
- int fd, prot;
- unsigned long ret, rets = 0;
-
- static Bool was_here = FALSE;
-
- if (!was_here) {
- was_here = TRUE;
-
- xf86WriteMmio8 = writeSparse8;
- xf86WriteMmio16 = writeSparse16;
- xf86WriteMmio32 = writeSparse32;
- xf86WriteMmioNB8 = writeSparseNB8;
- xf86WriteMmioNB16 = writeSparseNB16;
- xf86WriteMmioNB32 = writeSparseNB32;
- xf86ReadMmio8 = readSparse8;
- xf86ReadMmio16 = readSparse16;
- xf86ReadMmio32 = readSparse32;
- }
-
- fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
- if (fd < 0) {
- FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
- strerror(errno));
- }
-
-#if 0
- xf86Msg(X_INFO, "mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
- Base, Size, flags);
-#endif
-
- if (flags & VIDMEM_READONLY)
- prot = PROT_READ;
- else
- prot = PROT_READ | PROT_WRITE;
-
- /* This requirers linux-0.99.pl10 or above */
-
- /*
- * Always do DENSE mmap, since read32/write32 currently require it.
- */
- ret = (unsigned long) mmap((caddr_t) (DENSE_BASE + Base), Size,
- prot, MAP_SHARED, fd, (off_t) (bus_base + Base));
-
- /*
- * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
- * and SPARSE (which should require the use of read/write macros).
- *
- * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
- * bytes worth of pagetable (32 pages).
- */
- if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
- ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
- rets = (unsigned long) mmap((caddr_t) (SPARSE_BASE + (Base << 5)),
- Size << 5, prot, MAP_SHARED, fd,
- (off_t) _bus_base_sparse() + (Base << 5));
- }
-
- close(fd);
-
- if (ret == (unsigned long) MAP_FAILED) {
- FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
- strerror(errno));
- }
-
- if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
- ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
- if (rets == (unsigned long) MAP_FAILED ||
- rets != (SPARSE_BASE + (Base << 5))) {
- FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
- strerror(errno));
- }
- }
-
-#if 1
- if (rets)
- xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
- " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
- Base, Size, ret, rets);
- else
- xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
- " to DENSE only at 0x%lx\n", Base, Size, ret);
-
-#endif
- return (void *) ret;
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size)
-{
- unsigned long Offset = (unsigned long) Base - DENSE_BASE;
-
-#if 1
- xf86Msg(X_INFO, "unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
- Base, Size);
-#endif
- /* Unmap DENSE always. */
- munmap((caddr_t) Base, Size);
-
- /* Unmap SPARSE always, and ignore error in case we did not map it. */
- munmap((caddr_t) (SPARSE_BASE + (Offset << 5)), Size << 5);
-}
-
-static int
-readSparse8(void *Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
-
- mem_barrier();
- Offset += (unsigned long) Base - DENSE_BASE;
- shift = (Offset & 0x3) << 3;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
-
- mem_barrier();
- result = *(vuip) (SPARSE_BASE + (Offset << 5));
- result >>= shift;
- return 0xffUL & result;
-}
-
-static int
-readSparse16(void *Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
-
- mem_barrier();
- Offset += (unsigned long) Base - DENSE_BASE;
- shift = (Offset & 0x2) << 3;
- if (Offset >= hae_thresh) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
-
- mem_barrier();
- result = *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2)));
- result >>= shift;
- return 0xffffUL & result;
-}
-
-static int
-readSparse32(void *Base, register unsigned long Offset)
-{
- /* NOTE: this is really using DENSE. */
- mem_barrier();
- return *(vuip) ((unsigned long) Base + (Offset));
-}
-
-static void
-writeSparse8(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- write_mem_barrier();
- Offset += (unsigned long) Base - DENSE_BASE;
- if (Offset >= hae_thresh) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
-
- write_mem_barrier();
- *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparse16(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- write_mem_barrier();
- Offset += (unsigned long) Base - DENSE_BASE;
- if (Offset >= hae_thresh) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
-
- write_mem_barrier();
- *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
-}
-
-static void
-writeSparse32(int Value, void *Base, register unsigned long Offset)
-{
- /* NOTE: this is really using DENSE. */
- write_mem_barrier();
- *(vuip) ((unsigned long) Base + (Offset)) = Value;
- return;
-}
-
-static void
-writeSparseNB8(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- Offset += (unsigned long) Base - DENSE_BASE;
- if (Offset >= hae_thresh) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
- *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparseNB16(int Value, void *Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- Offset += (unsigned long) Base - DENSE_BASE;
- if (Offset >= hae_thresh) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
- }
- *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
-}
-
-static void
-writeSparseNB32(int Value, void *Base, register unsigned long Offset)
-{
- /* NOTE: this is really using DENSE. */
- *(vuip) ((unsigned long) Base + (Offset)) = Value;
- return;
-}
-
void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset)
= writeDense8;
void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
deleted file mode 100644
index e000dc9c8..000000000
--- a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. David Wexelblat makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-#ifndef __alpha__
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int fd;
- unsigned char *ptr;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t) Base);
- if (ptr == MAP_FAILED) {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
- (void) memcpy(Buf, (void *) (ptr + Offset), Len);
- (void) munmap((caddr_t) ptr, mlen);
- (void) close(fd);
- return Len;
-}
-
-#else /* __alpha__ */
-
- /*
- * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
- * which is the KSEG address of the start of the DENSE memory
- * area.
- */
-
- /*
- * NOTE: there prolly ought to be more validity checks and all
- * re: boundaries and sizes and such...
- */
-
-#ifdef linux
-
-extern unsigned long _bus_base(void);
-
-#define BUS_BASE _bus_base()
-
-#else
-
-extern u_int64_t dense_base(void);
-
-#define BUS_BASE dense_base()
-
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- caddr_t base;
- int fd;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- base = mmap((caddr_t) 0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t) (Base + BUS_BASE));
-
- if (base == MAP_FAILED) {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- xf86SlowBCopyFromBus((unsigned char *) (base + Offset), Buf, Len);
-
- munmap((caddr_t) base, mlen);
- close(fd);
- return Len;
-}
-
-#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
index f473293c7..a6bf677f5 100644
--- a/xorg-server/hw/xfree86/os-support/shared/vidmem.c
+++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
@@ -42,119 +42,7 @@
* This file contains the common part of the video memory mapping functions
*/
-/*
- * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold
- * the MTRR option information, but it is likely to be expanded if we do
- * auto unmapping of memory at VT switch.
- *
- */
-
-typedef struct {
- unsigned long size;
- void *virtBase;
- void *mtrrInfo;
-} MappingRec, *MappingPtr;
-
-typedef struct {
- int numMappings;
- MappingPtr *mappings;
- Bool mtrrEnabled;
- MessageType mtrrFrom;
- Bool mtrrOptChecked;
- ScrnInfoPtr pScrn;
-} VidMapRec, *VidMapPtr;
-
-static int vidMapIndex = -1;
-
-#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-
static VidMemInfo vidMemInfo = { FALSE, };
-static VidMapRec vidMapRec = { 0, NULL, TRUE, X_DEFAULT, FALSE, NULL };
-
-static VidMapPtr
-getVidMapRec(int scrnIndex)
-{
- VidMapPtr vp;
- ScrnInfoPtr pScrn;
-
- if ((scrnIndex < 0) || !(pScrn = xf86Screens[scrnIndex]))
- return &vidMapRec;
-
- if (vidMapIndex < 0)
- vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
-
- if (VIDMAPPTR(pScrn) != NULL)
- return VIDMAPPTR(pScrn);
-
- vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
- vp->mtrrEnabled = TRUE; /* default to enabled */
- vp->mtrrFrom = X_DEFAULT;
- vp->mtrrOptChecked = FALSE;
- vp->pScrn = pScrn;
- return vp;
-}
-
-static MappingPtr
-newMapping(VidMapPtr vp)
-{
- vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
- (vp->numMappings + 1));
- vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
- return vp->mappings[vp->numMappings++];
-}
-
-static MappingPtr
-findMapping(VidMapPtr vp, void *vbase, unsigned long size)
-{
- int i;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i]->virtBase == vbase && vp->mappings[i]->size == size)
- return vp->mappings[i];
- }
- return NULL;
-}
-
-static void
-removeMapping(VidMapPtr vp, MappingPtr mp)
-{
- int i, found = 0;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i] == mp) {
- found = 1;
- free(vp->mappings[i]);
- }
- else if (found) {
- vp->mappings[i - 1] = vp->mappings[i];
- }
- }
- vp->numMappings--;
- vp->mappings[vp->numMappings] = NULL;
-}
-
-enum { OPTION_MTRR };
-
-static const OptionInfoRec opts[] = {
- {OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE},
- {-1, NULL, OPTV_NONE, {0}, FALSE}
-};
-
-static void
-checkMtrrOption(VidMapPtr vp)
-{
- if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(opts));
- (void) memcpy(options, opts, sizeof(opts));
- xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, options);
- if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
- vp->mtrrFrom = X_CONFIG;
- free(options);
- vp->mtrrOptChecked = TRUE;
- }
-}
void
xf86InitVidMem(void)
@@ -164,96 +52,3 @@ xf86InitVidMem(void)
xf86OSInitVidMem(&vidMemInfo);
}
}
-
-void *
-xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
-{
- void *vbase = NULL;
- VidMapPtr vp;
- MappingPtr mp;
-
- if (((Flags & VIDMEM_FRAMEBUFFER) &&
- (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
- FatalError("Mapping memory with more than one type\n");
-
- xf86InitVidMem();
- if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
- return NULL;
-
- vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
- if (!vbase || vbase == (void *) -1)
- return NULL;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->size = Size;
- mp->virtBase = vbase;
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC) {
- if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, vp->mtrrFrom);
- else if (Flags & VIDMEM_FRAMEBUFFER)
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, vp->mtrrFrom);
- }
- return vbase;
-}
-
-void
-xf86UnMapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- VidMapPtr vp;
- MappingPtr mp;
-
- if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem() called before xf86MapVidMem()\n");
- return;
- }
-
- vp = getVidMapRec(ScreenNum);
- mp = findMapping(vp, Base, Size);
- if (!mp) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
- Base, Size);
- return;
- }
- if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
- vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
- vidMemInfo.unmapMem(ScreenNum, Base, Size);
- removeMapping(vp, mp);
-}
-
-Bool
-xf86CheckMTRR(int ScreenNum)
-{
- VidMapPtr vp = getVidMapRec(ScreenNum);
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC)
- return TRUE;
-
- return FALSE;
-}
-
-Bool
-xf86LinearVidMem(void)
-{
- xf86InitVidMem();
- return vidMemInfo.linearSupported;
-}
diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c
deleted file mode 100644
index 5f2f3985e..000000000
--- a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2000 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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Axp.h"
-
-axpParams xf86AXPParams[] = {
- {SYS_NONE, 0, 0, 0}
- ,
- {TSUNAMI, 0, 0, 0}
- ,
- {LCA, 1 << 24, 0xf8000000, 1UL << 32}
- ,
- {APECS, 1 << 24, 0xf8000000, 1UL << 32}
- ,
- {T2, 0, 0xFC000000, 1UL << 31}
- ,
- {T2_GAMMA, 0, 0xFC000000, 1UL << 31}
- ,
- {CIA, 0, 0xE0000000, 1UL << 34}
- ,
- {MCPCIA, 0, 0xf8000000, 1UL << 31}
- ,
- {JENSEN, 0, 0xE000000, 1UL << 32}
- ,
- {POLARIS, 0, 0, 0}
- ,
- {PYXIS, 0, 0, 0}
- ,
- {PYXIS_CIA, 0, 0xE0000000, 1UL << 34}
- ,
- {IRONGATE, 0, 0, 0}
-};
diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h
deleted file mode 100644
index fded9d8c9..000000000
--- a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86_AXP_H_
-#define _XF86_AXP_H_
-
-typedef enum {
- SYS_NONE,
- TSUNAMI,
- LCA,
- APECS,
- T2,
- T2_GAMMA,
- CIA,
- MCPCIA,
- JENSEN,
- POLARIS,
- PYXIS,
- PYXIS_CIA,
- IRONGATE
-} axpDevice;
-
-typedef struct {
- axpDevice id;
- unsigned long hae_thresh;
- unsigned long hae_mask;
- unsigned long size;
-} axpParams;
-
-extern axpParams xf86AXPParams[];
-
-#endif
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
index fc464871d..25f76181c 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
@@ -63,152 +63,12 @@
/* Video Memory Mapping section */
/***************************************************************************/
-static char *apertureDevName = NULL;
-static int apertureDevFD_ro = -1;
-static int apertureDevFD_rw = -1;
-
-static Bool
-solOpenAperture(void)
-{
- if (apertureDevName == NULL) {
- apertureDevName = "/dev/xsvc";
- if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0) {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- apertureDevName = "/dev/fbs/aperture";
- apertureDevFD_rw = open(apertureDevName, O_RDWR);
- }
- apertureDevFD_ro = open(apertureDevName, O_RDONLY);
-
- if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0)) {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: either /dev/fbs/aperture"
- " or /dev/xsvc required\n");
-
- apertureDevName = NULL;
-
- if (apertureDevFD_rw >= 0) {
- close(apertureDevFD_rw);
- }
- apertureDevFD_rw = -1;
-
- if (apertureDevFD_ro >= 0) {
- close(apertureDevFD_ro);
- }
- apertureDevFD_ro = -1;
-
- return FALSE;
- }
- }
- return TRUE;
-}
-
-static void *
-solMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
- void *base;
- int fd;
- int prot;
-
- if (Flags & VIDMEM_READONLY) {
- fd = apertureDevFD_ro;
- prot = PROT_READ;
- }
- else {
- fd = apertureDevFD_rw;
- prot = PROT_READ | PROT_WRITE;
- }
-
- if (fd < 0) {
- xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- return NULL;
- }
-
- base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t) Base);
-
- if (base == MAP_FAILED) {
- xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n",
- apertureDevName, Base, Size, strerror(errno));
- return NULL;
- }
-
- return base;
-}
-
-/* ARGSUSED */
-static void
-solUnMapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
- if (munmap(Base, Size) != 0) {
- xf86DrvMsgVerb(ScreenNum, X_WARNING, 0,
- "solUnMapVidMem: failed to unmap %s"
- " (0x%p,0x%lx) (%s)\n",
- apertureDevName, Base, Size, strerror(errno));
- }
-}
-
_X_HIDDEN void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = solOpenAperture();
- if (pVidMem->linearSupported) {
- pVidMem->mapMem = solMapVidMem;
- pVidMem->unmapMem = solUnMapVidMem;
- }
- else {
- xf86MsgVerb(X_WARNING, 0,
- "xf86OSInitVidMem: linear memory access disabled\n");
- }
pVidMem->initialised = TRUE;
}
-/*
- * Read BIOS via mmap()ing physical memory.
- */
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-
- if (solOpenAperture() == FALSE) {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
- return -1;
- }
-
- ptr = (unsigned char *) mmap(NULL, mlen, PROT_READ,
- MAP_SHARED, apertureDevFD_ro, (off_t) Base);
- if (ptr == MAP_FAILED) {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
- apertureDevName, Base, mlen);
- return -1;
- }
-
- (void) memcpy(Buf, (void *) (ptr + Offset), Len);
- if (munmap((caddr_t) ptr, mlen) != 0) {
- xf86MsgVerb(X_WARNING, 0,
- "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
- apertureDevName, ptr, mlen, strerror(errno));
- }
-
- return Len;
-}
-
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
diff --git a/xorg-server/hw/xfree86/os-support/stub/Makefile.am b/xorg-server/hw/xfree86/os-support/stub/Makefile.am
index a39e17d55..19468c6de 100644
--- a/xorg-server/hw/xfree86/os-support/stub/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/stub/Makefile.am
@@ -14,6 +14,5 @@ libstub_la_SOURCES = \
$(srcdir)/../shared/posix_tty.c \
$(srcdir)/../shared/sigio.c \
stub_bell.c \
- stub_bios.c \
stub_init.c \
stub_video.c
diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c
deleted file mode 100644
index dbc92fcdb..000000000
--- a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86_OSlib.h"
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- return -1;
-}
diff --git a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
index b56f45a3e..ce1ec33a1 100644
--- a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
+++ b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
@@ -32,19 +32,8 @@
#ifndef _XF86OSPRIV_H
#define _XF86OSPRIV_H
-typedef void *(*MapMemProcPtr) (int, unsigned long, unsigned long, int);
-typedef void (*UnmapMemProcPtr) (int, void *, unsigned long);
-typedef void *(*SetWCProcPtr) (int, unsigned long, unsigned long, Bool,
- MessageType);
-typedef void (*UndoWCProcPtr) (int, void *);
-
typedef struct {
Bool initialised;
- MapMemProcPtr mapMem;
- UnmapMemProcPtr unmapMem;
- SetWCProcPtr setWC;
- UndoWCProcPtr undoWC;
- Bool linearSupported;
} VidMemInfo, *VidMemInfoPtr;
void xf86OSInitVidMem(VidMemInfoPtr);
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
index 8d27e8b7b..822bab2ca 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
@@ -74,24 +74,6 @@
*/
/*
- * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The
- * flags may be used as hints. For example it would be permissible to
- * enable write combining for memory marked only for framebuffer use.
- */
-
-#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */
-#define VIDMEM_MMIO 0x02 /* memory for I/O use */
-#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */
-#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */
-#define VIDMEM_SPARSE 0x10 /* sparse mapping required
- * assumed when VIDMEM_MMIO is
- * set. May be used with
- * VIDMEM_FRAMEBUFFER) */
-#define VIDMEM_READONLY 0x20 /* read-only mapping
- * used when reading BIOS images
- * through xf86MapVidMem() */
-
-/*
* OS-independent modem state flags for xf86SetSerialModemState() and
* xf86GetSerialModemState().
*/
@@ -130,14 +112,6 @@
_XFUNCPROTOBEGIN
/* public functions */
-extern _X_EXPORT Bool xf86LinearVidMem(void);
-extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
-extern _X_EXPORT _X_DEPRECATED void *xf86MapVidMem(int, int, unsigned long,
- unsigned long);
-extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, void *,
- unsigned long);
-extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *,
- int);
extern _X_EXPORT Bool xf86EnableIO(void);
extern _X_EXPORT void xf86DisableIO(void);