From bc504ffbba3dec2e3467bab8ba1ac25db6dd317e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 11 Mar 2008 00:35:31 -0400 Subject: [PATCH 01/21] DRI2: Add DRI2AuthConnection(). DRI2 uses the same authentication scheme as XF86DRI, so implement this entry point so DRI2 protocol code can access it. --- hw/xfree86/dri2/dri2.c | 11 +++++++++++ hw/xfree86/dri2/dri2.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index d2664b1cb..d5273877e 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -342,6 +342,17 @@ DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName, return TRUE; } +Bool +DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds == NULL || drmAuthMagic(ds->fd, magic)) + return FALSE; + + return TRUE; +} + unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags) { diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h index a31908508..126087a2f 100644 --- a/hw/xfree86/dri2/dri2.h +++ b/hw/xfree86/dri2/dri2.h @@ -58,6 +58,8 @@ Bool DRI2Connect(ScreenPtr pScreen, const char **driverName, unsigned int *sareaHandle); +Bool DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic); + unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags); From cc05255191413b3f376edbc600122ff085f45f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 11 Mar 2008 00:51:43 -0400 Subject: [PATCH 02/21] Make WriteToClient take a const void * like any decent IO write function. Enough with the casting. Doesn't break API or even ABI, but does make a lot of silly casts superfluos. --- include/os.h | 4 ++-- os/io.c | 10 ++++++---- os/osdep.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/os.h b/include/os.h index 4be6b8010..c0f04c6af 100644 --- a/include/os.h +++ b/include/os.h @@ -115,7 +115,7 @@ extern void FlushIfCriticalOutputPending(void); extern void SetCriticalOutputPending(void); -extern int WriteToClient(ClientPtr /*who*/, int /*count*/, char* /*buf*/); +extern int WriteToClient(ClientPtr /*who*/, int /*count*/, const void* /*buf*/); extern void ResetOsBuffers(void); @@ -448,7 +448,7 @@ typedef struct { extern CallbackListPtr ReplyCallback; typedef struct { ClientPtr client; - pointer replyData; + const void *replyData; unsigned long dataLenBytes; unsigned long bytesRemaining; Bool startOfReply; diff --git a/os/io.c b/os/io.c index e7ec60952..4f4a10903 100644 --- a/os/io.c +++ b/os/io.c @@ -730,11 +730,12 @@ SetCriticalOutputPending(void) *****************/ _X_EXPORT int -WriteToClient (ClientPtr who, int count, char *buf) +WriteToClient (ClientPtr who, int count, const void *__buf) { OsCommPtr oc = (OsCommPtr)who->osPrivate; ConnectionOutputPtr oco = oc->output; int padBytes; + const char *buf = __buf; #ifdef DEBUG_COMMUNICATION Bool multicount = FALSE; #endif @@ -871,13 +872,14 @@ WriteToClient (ClientPtr who, int count, char *buf) **********************/ int -FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) +FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) { ConnectionOutputPtr oco = oc->output; int connection = oc->fd; XtransConnInfo trans_conn = oc->trans_conn; struct iovec iov[3]; static char padBuffer[3]; + const char *extraBuf = __extraBuf; long written; long padsize; long notWritten; @@ -916,14 +918,14 @@ FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) before = (-len); \ } else { \ iov[i].iov_len = len; \ - iov[i].iov_base = (pointer) + before; \ + iov[i].iov_base = (pointer) + before; \ i++; \ remain -= len; \ before = 0; \ } InsertIOV ((char *)oco->buf, oco->count) - InsertIOV (extraBuf, extraCount) + InsertIOV ((char *)extraBuf, extraCount) InsertIOV (padBuffer, padsize) errno = 0; diff --git a/os/osdep.h b/os/osdep.h index b6894c146..84f7177db 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -184,7 +184,7 @@ typedef struct _osComm { extern int FlushClient( ClientPtr /*who*/, OsCommPtr /*oc*/, - char* /*extraBuf*/, + const void * /*extraBuf*/, int /*extraCount*/ ); From c7536f4b87e089a7e7c43026b189922fec70c565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 11 Mar 2008 13:11:04 -0400 Subject: [PATCH 03/21] Silence REGION_INIT() warning. Evaluating the address of a BoxRec as a boolean gives this warning: i830_driver.c:2317: warning: the address of 'ScreenBox' will always evaluate as 'true' which is pretty annoying. This patch compares the address to NULL to avoid the pointer->bool conversion and gets rid of the warning. Seems like a lame hack, but the warning is worse. --- include/regionstr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/regionstr.h b/include/regionstr.h index f44cab7b0..5a79b1228 100644 --- a/include/regionstr.h +++ b/include/regionstr.h @@ -158,7 +158,7 @@ extern RegDataRec miBrokenData; #define REGION_INIT(_pScreen, _pReg, _rect, _size) \ { \ - if (_rect) \ + if ((_rect) != NULL) \ { \ (_pReg)->extents = *(_rect); \ (_pReg)->data = (RegDataPtr)NULL; \ From 2036851125226065891f13583ade3ce559e7bd37 Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Mon, 10 Mar 2008 19:29:07 +0100 Subject: [PATCH 04/21] Return randr interface version in xf86CrtcScreenInit() Necessary to allow drivers to be run-time backwards compatible when using the modes/ functions w/o providing their own copy. --- hw/xfree86/modes/xf86Crtc.c | 13 +++++++++++-- hw/xfree86/modes/xf86Crtc.h | 4 ++++ randr/randrstr.h | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 0bef5b42f..39e84e641 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -694,7 +694,12 @@ xf86CrtcCloseScreen (int index, ScreenPtr screen) /* * Called at ScreenInit time to set up */ -_X_EXPORT Bool +_X_EXPORT +#ifdef RANDR_13_INTERFACE +int +#else +Bool +#endif xf86CrtcScreenInit (ScreenPtr screen) { ScrnInfoPtr scrn = xf86Screens[screen->myNum]; @@ -727,7 +732,11 @@ xf86CrtcScreenInit (ScreenPtr screen) config->CloseScreen = screen->CloseScreen; screen->CloseScreen = xf86CrtcCloseScreen; +#ifdef RANDR_13_INTERFACE + return RANDR_INTERFACE_VERSION; +#else return TRUE; +#endif } static DisplayModePtr @@ -2228,7 +2237,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) } } xf86DisableUnusedFunctions(pScrn); -#if RANDR_12_INTERFACE +#ifdef RANDR_12_INTERFACE xf86RandR12TellChanged (pScrn->pScreen); #endif return ok; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index b87a32548..a542e7f39 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -692,7 +692,11 @@ xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); void xf86SetScrnInfoModes (ScrnInfoPtr pScrn); +#ifdef RANDR_13_INTERFACE +int +#else Bool +#endif xf86CrtcScreenInit (ScreenPtr pScreen); Bool diff --git a/randr/randrstr.h b/randr/randrstr.h index 3b48f5c2b..4d7c9ccfc 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -56,6 +56,8 @@ #define RANDR_12_INTERFACE 1 #define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ +#define RANDR_INTERFACE_VERSION 0x0103 + typedef XID RRMode; typedef XID RROutput; typedef XID RRCrtc; From 06c0372c3a1b45005eb6d50406f77f4e93f1de1e Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 12 Mar 2008 21:45:37 +0100 Subject: [PATCH 05/21] OpenBSD support for libpciaccess. xserver and libpciaccess both need to open /dev/xf86, which can only be opened once. I implemented pci_system_init_dev_mem() like Ian suggested. This requires some minor changes to the BSD-specific os-support code. Since pci_system_init_dev_mem() is a no-op on FreeBSD this should be no problem. --- hw/xfree86/os-support/bsd/i386_video.c | 3 +++ hw/xfree86/os-support/bus/bsd_pci.c | 2 ++ hw/xfree86/utils/ioport/Makefile.am | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 0dcff6631..7e4a4d2a3 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -212,6 +212,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; + if (useDevMem) + pci_system_init_dev_mem(devMemFd); + #ifdef HAS_MTRR_SUPPORT if (useDevMem) { if (cleanMTRR()) { diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c index bceb1087f..57ad09b6a 100644 --- a/hw/xfree86/os-support/bus/bsd_pci.c +++ b/hw/xfree86/os-support/bus/bsd_pci.c @@ -81,4 +81,6 @@ bsdPciInit(void) { pciNumBuses = 1; pciBusInfo[0] = &bsd_pci; + + xf86InitVidMem(); } diff --git a/hw/xfree86/utils/ioport/Makefile.am b/hw/xfree86/utils/ioport/Makefile.am index c1f9453a8..12f861372 100644 --- a/hw/xfree86/utils/ioport/Makefile.am +++ b/hw/xfree86/utils/ioport/Makefile.am @@ -37,7 +37,7 @@ ioport_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) ioport_LDADD = \ ../../os-support/libxorgos.la \ ../../dummylib/libdummy-nonserver.a \ - ${UTILS_SYS_LIBS} + ${UTILS_SYS_LIBS} ${PCIACCESS_LIBS} ioport_SOURCES = \ From 61c3f63a75d8b0cc47ffed4a0e30147fab2ae8f4 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 13 Mar 2008 17:34:54 -0400 Subject: [PATCH 06/21] RANDR 1.2: Don't report a square resolution to RANDR 1.1 clients. It can't possibly do anything useful, and older versions of Gnome (and proably others) get very confused by it. So do the drivers, for that matter. --- hw/xfree86/modes/xf86RandR12.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 816175cc3..af950e61c 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -145,23 +145,6 @@ xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) randrp->maxY = maxY; } - if (scrp->currentMode->HDisplay != randrp->virtualX || - scrp->currentMode->VDisplay != randrp->virtualY) - { - pSize = RRRegisterSize (pScreen, - randrp->virtualX, randrp->virtualY, - randrp->mmWidth, - randrp->mmHeight); - if (!pSize) - return FALSE; - RRRegisterRate (pScreen, pSize, refresh0); - if (scrp->virtualX == randrp->virtualX && - scrp->virtualY == randrp->virtualY) - { - RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); - } - } - return TRUE; } From 5d7437c29e686a081b20823450d78c4c2f4e0aec Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 13 Mar 2008 17:37:12 -0400 Subject: [PATCH 07/21] RANDR 1.2: Fix the RANDR 1.1 screen size estimation to approach reality. While the ScreenRec's notion of size in millimeters would get updates, the RANDR 1.1 notion wouldn't, so your screen would appear to be square and probably at some ludicrous DPI. --- hw/xfree86/modes/xf86RandR12.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index af950e61c..1dca223fe 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -355,8 +355,8 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, pScreen->width = pScrnPix->drawable.width = width; pScreen->height = pScrnPix->drawable.height = height; - pScreen->mmWidth = mmWidth; - pScreen->mmHeight = mmHeight; + randrp->mmWidth = pScreen->mmWidth = mmWidth; + randrp->mmHeight = pScreen->mmHeight = mmHeight; xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); xf86SetViewport (pScreen, 0, 0); From f7abe05b3306ed9a6f2cf5e3e45ed524d725d029 Mon Sep 17 00:00:00 2001 From: Doug Chapman Date: Thu, 13 Mar 2008 17:40:34 -0400 Subject: [PATCH 08/21] Bug #14091: Fix build (and runtime) on ia64. --- hw/xfree86/os-support/bus/Makefile.am | 12 ------ hw/xfree86/os-support/bus/Pci.h | 3 +- hw/xfree86/os-support/linux/Makefile.am | 2 +- hw/xfree86/os-support/shared/ia64Pci.c | 55 ------------------------- 4 files changed, 2 insertions(+), 70 deletions(-) diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index 381b9923c..5a15430c1 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -27,18 +27,6 @@ if LINUX_ALPHA PCI_SOURCES += axpPci.c endif -if LINUX_IA64 -PLATFORM_PCI_SOURCES = \ - 460gxPCI.c \ - 460gxPCI.h \ - altixPCI.c \ - altixPCI.h \ - e8870PCI.c \ - e8870PCI.h \ - zx1PCI.c \ - zx1PCI.h -endif - if XORG_BUS_SPARC PLATFORM_SOURCES = Sbus.c sdk_HEADERS += xf86Sbus.h diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 0abb34f98..ebac0905b 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -207,9 +207,8 @@ # endif #elif defined(__ia64__) # if defined(linux) -# define ARCH_PCI_INIT ia64linuxPciInit +# define ARCH_PCI_INIT linuxPciInit # endif -# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper #elif defined(__i386__) || defined(__i386) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am index 5a52ffdd4..beaae3d5b 100644 --- a/hw/xfree86/os-support/linux/Makefile.am +++ b/hw/xfree86/os-support/linux/Makefile.am @@ -1,7 +1,7 @@ noinst_LTLIBRARIES = liblinux.la if LINUX_IA64 -PLATFORM_PCI_SUPPORT = $(srcdir)/lnx_ia64.c $(srcdir)/../shared/ia64Pci.c +PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c PLATFORM_DEFINES = -DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset PLATFORM_INCLUDES = -I$(srcdir)/../shared endif diff --git a/hw/xfree86/os-support/shared/ia64Pci.c b/hw/xfree86/os-support/shared/ia64Pci.c index 45522e933..6f6924b59 100644 --- a/hw/xfree86/os-support/shared/ia64Pci.c +++ b/hw/xfree86/os-support/shared/ia64Pci.c @@ -42,12 +42,7 @@ #include #include "compiler.h" -#include "460gxPCI.h" -#include "e8870PCI.h" -#include "zx1PCI.h" -#include "altixPCI.h" #include "Pci.h" -#include "ia64Pci.h" /* * We use special in/out routines here since Altix platforms require the @@ -191,53 +186,3 @@ _X_EXPORT unsigned int inl(unsigned long port) return val; } -void -ia64ScanPCIWrapper(scanpciWrapperOpt flags) -{ - static IA64Chipset chipset = NONE_CHIPSET; - - if (flags == SCANPCI_INIT) { - - /* PCI configuration space probes should be done first */ - if (xorgProbe460GX(flags)) { - chipset = I460GX_CHIPSET; - xf86PreScan460GX(); - return; - } else if (xorgProbeE8870(flags)) { - chipset = E8870_CHIPSET; - xf86PreScanE8870(); - return; - } -#ifdef OS_PROBE_PCI_CHIPSET - chipset = OS_PROBE_PCI_CHIPSET(flags); - switch (chipset) { - case ZX1_CHIPSET: - xf86PreScanZX1(); - return; - case ALTIX_CHIPSET: - xf86PreScanAltix(); - return; - default: - return; - } -#endif - } else /* if (flags == SCANPCI_TERM) */ { - - switch (chipset) { - case I460GX_CHIPSET: - xf86PostScan460GX(); - return; - case E8870_CHIPSET: - xf86PostScanE8870(); - return; - case ZX1_CHIPSET: - xf86PostScanZX1(); - return; - case ALTIX_CHIPSET: - xf86PostScanAltix(); - return; - default: - return; - } - } -} From 1b9878ffcfc0c0dbc4a6e674827fe508ba77db4b Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Thu, 13 Mar 2008 17:42:16 -0400 Subject: [PATCH 09/21] Bug #14332: Fix PCI access cycles from x86emu. The address written to 0xcf8 contains the PCI slot address to send the config cycle to. However, we would ignore that and always send the cycle to the device whose BIOS we were running. This breaks some integrated graphics platforms that have explicit knowledge about the system's host bridge, for example. --- hw/xfree86/int10/helper_exec.c | 57 +++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index de6fde5d8..9daff22dc 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -33,6 +33,7 @@ #ifdef _X86EMU #include "x86emu/x86emui.h" #endif +#include static int pciCfg1in(CARD16 addr, CARD32 *val); static int pciCfg1out(CARD16 addr, CARD32 val); @@ -459,7 +460,43 @@ Mem_wl(CARD32 addr, CARD32 val) static CARD32 PciCfg1Addr = 0; -#define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff) +#define PCI_OFFSET(x) ((x) & 0x000000ff) +#define PCI_TAG(x) ((x) & 0xffffff00) + +static struct pci_device* +pci_device_for_cfg_address (CARD32 addr) +{ + struct pci_device *dev = NULL; + PCITAG tag = PCI_TAG(addr); + struct pci_slot_match slot_match = { + .domain = PCI_DOM_FROM_TAG(tag), + .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)), + .dev = PCI_DEV_FROM_TAG(tag), + .func = PCI_FUNC_FROM_TAG(tag), + .match_data = 0 + }; + + struct pci_device_iterator *iter = + pci_slot_match_iterator_create (&slot_match); + if (iter) + dev = pci_device_next(iter); + if (!dev) { + char buf[128]; /* enough to store "%u@%u" */ + xf86FormatPciBusNumber(tag >> 16, buf); + ErrorF("Failed to find device matching %s:%u:%u\n", + buf, slot_match.dev, slot_match.func); + return NULL; + } + + if (pci_device_next(iter)) { + char buf[128]; /* enough to store "%u@%u" */ + xf86FormatPciBusNumber(tag >> 16, buf); + ErrorF("Multiple devices matching %s:%u:%u\n", + buf, slot_match.dev, slot_match.func); + } + + return dev; +} static int pciCfg1in(CARD16 addr, CARD32 *val) @@ -469,7 +506,8 @@ pciCfg1in(CARD16 addr, CARD32 *val) return 1; } if (addr == 0xCFC) { - pci_device_cfg_read_u32(Int10Current->dev, val, OFFSET(PciCfg1Addr)); + pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inl(%#x) = %8.8x\n", PciCfg1Addr, *val); return 1; @@ -487,7 +525,8 @@ pciCfg1out(CARD16 addr, CARD32 val) if (addr == 0xCFC) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outl(%#x, %8.8x)\n", PciCfg1Addr, val); - pci_device_cfg_write_u32(Int10Current->dev, val, OFFSET(PciCfg1Addr)); + pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); return 1; } return 0; @@ -506,7 +545,8 @@ pciCfg1inw(CARD16 addr, CARD16 *val) if ((addr >= 0xCFC) && (addr <= 0xCFF)) { const unsigned offset = addr - 0xCFC; - pci_device_cfg_read_u16(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset); + pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inw(%#x) = %4.4x\n", PciCfg1Addr + offset, *val); return 1; @@ -530,7 +570,8 @@ pciCfg1outw(CARD16 addr, CARD16 val) if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outw(%#x, %4.4x)\n", PciCfg1Addr + offset, val); - pci_device_cfg_write_u16(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset); + pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); return 1; } return 0; @@ -549,7 +590,8 @@ pciCfg1inb(CARD16 addr, CARD8 *val) if ((addr >= 0xCFC) && (addr <= 0xCFF)) { const unsigned offset = addr - 0xCFC; - pci_device_cfg_read_u8(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset); + pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inb(%#x) = %2.2x\n", PciCfg1Addr + offset, *val); return 1; @@ -573,7 +615,8 @@ pciCfg1outb(CARD16 addr, CARD8 val) if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outb(%#x, %2.2x)\n", PciCfg1Addr + offset, val); - pci_device_cfg_write_u8(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset); + pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); return 1; } return 0; From 824853772241acf64bc37ac8b85254194741ae13 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 14 Mar 2008 14:24:21 -0400 Subject: [PATCH 10/21] RANDR 1.2: Fix initial mode aspect ratio match in a corner case. Actually more like in the mainline case, where the ideal mode happens to be the very first aspect match on the first monitor. But let's not split hairs. --- hw/xfree86/modes/xf86Crtc.c | 55 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 39e84e641..6b845b7c9 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1683,14 +1683,19 @@ aspectMatch(float a, float b) } static DisplayModePtr -nextAspectMode(DisplayModePtr start, float aspect) +nextAspectMode(xf86OutputPtr o, DisplayModePtr last, float aspect) { - DisplayModePtr m = start; + DisplayModePtr m = NULL; - if (!m) + if (!o) return NULL; - for (m = m->next; m; m = m->next) + if (!last) + m = o->probed_modes; + else + m = last->next; + + for (; m; m = m->next) if (aspectMatch(aspect, (float)m->HDisplay / (float)m->VDisplay)) return m; @@ -1700,31 +1705,29 @@ nextAspectMode(DisplayModePtr start, float aspect) static DisplayModePtr bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect) { - int o, p; - DisplayModePtr mode, test = NULL, match = NULL; + int o = -1, p; + DisplayModePtr mode = NULL, test = NULL, match = NULL; - for (o = -1; nextEnabledOutput(config, enabled, &o); ) { - mode = config->output[o]->probed_modes; - while ((mode = nextAspectMode(mode, aspect))) { - for (p = o; nextEnabledOutput(config, enabled, &p); ) { - test = xf86OutputFindClosestMode(config->output[p], mode); - if (!test) - break; - if (test->HDisplay != mode->HDisplay || - test->VDisplay != mode->VDisplay) { - test = NULL; - break; - } - } - - /* if we didn't match it on all outputs, try the next one */ + nextEnabledOutput(config, enabled, &o); + while ((mode = nextAspectMode(config->output[o], mode, aspect))) { + for (p = o; nextEnabledOutput(config, enabled, &p); ) { + test = xf86OutputFindClosestMode(config->output[p], mode); if (!test) - continue; - - /* if it's bigger than the last one, save it */ - if (!match || (test->HDisplay > match->HDisplay)) - match = test; + break; + if (test->HDisplay != mode->HDisplay || + test->VDisplay != mode->VDisplay) { + test = NULL; + break; + } } + + /* if we didn't match it on all outputs, try the next one */ + if (!test) + continue; + + /* if it's bigger than the last one, save it */ + if (!match || (test->HDisplay > match->HDisplay)) + match = test; } /* return the biggest one found */ From 57d48d94b8947c571925e6fd4c9bf041fbd1b2ac Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 14 Mar 2008 14:37:42 -0400 Subject: [PATCH 11/21] Fix a stray use of ALLOCATE_LOCAL. --- hw/xfree86/xf4bpp/ppcSpMcro.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/xf4bpp/ppcSpMcro.h b/hw/xfree86/xf4bpp/ppcSpMcro.h index 2b7f951d4..655a883e5 100644 --- a/hw/xfree86/xf4bpp/ppcSpMcro.h +++ b/hw/xfree86/xf4bpp/ppcSpMcro.h @@ -28,11 +28,11 @@ #define SETSPANPTRS(IN,N,IPW,PW,IPPT,PPT,FPW,FPPT,FSORT) \ { \ N = IN * miFindMaxBand(pGC->pCompositeClip); \ - if(!(PW = (int *)ALLOCATE_LOCAL(N * sizeof(int)))) \ + if(!(PW = (int *)xalloc(N * sizeof(int)))) \ return; \ - if(!(PPT = (DDXPointRec *)ALLOCATE_LOCAL(N * sizeof(DDXPointRec)))) \ + if(!(PPT = (DDXPointRec *)xalloc(N * sizeof(DDXPointRec)))) \ { \ - DEALLOCATE_LOCAL(PW); \ + free(PW); \ return; \ } \ FPW = PW; \ From 88bec0915e3867f8dbf859a3dfbb771d0d07092d Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 14 Mar 2008 21:54:13 +0200 Subject: [PATCH 12/21] mi: More meaningful assert crashes When we fail an assert in miregion.c (which happens every now and then, though I haven't yet checked up why), at least generate a segfault, so we'll get a backtrace. --- mi/miregion.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mi/miregion.c b/mi/miregion.c index 45768a34f..69ecdc246 100644 --- a/mi/miregion.c +++ b/mi/miregion.c @@ -89,9 +89,14 @@ Equipment Corporation. #undef assert #ifdef DEBUG -#define assert(expr) {if (!(expr)) \ - FatalError("Assertion failed file %s, line %d: expr\n", \ - __FILE__, __LINE__); } +#define assert(expr) { \ + CARD32 *foo = NULL; \ + if (!(expr)) { \ + ErrorF("Assertion failed file %s, line %d: %s\n", \ + __FILE__, __LINE__, #expr); \ + *foo = 0xdeadbeef; /* to get a backtrace */ \ + } \ + } #else #define assert(expr) #endif From 090b26db767d296e7a3452da83b136d1caa0ed01 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 14 Mar 2008 21:58:27 +0200 Subject: [PATCH 13/21] XkbCopyKeymap: Fix broken indentation An astute observer will note that the entirety of XkbCopyKeymap is indented with spaces, and no tabs whatsoever, and not commit changes which break the otherwise consistent indentation. A non-astute observer will note the breakage when the commit mail comes through with clearly broken indentation. A polite, non-astute, observer will then fix it. C'est la vie. --- xkb/xkbUtils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index a3ae655f0..8339cef00 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -1796,7 +1796,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) dsection = dst->geom->sections; i < src->geom->num_sections; i++, ssection++, dsection++) { - *dsection = *ssection; + *dsection = *ssection; if (ssection->num_rows) { tmp = xcalloc(ssection->num_rows, sizeof(XkbRowRec)); if (!tmp) @@ -1852,9 +1852,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) } ddoodad->any.type = sdoodad->any.type; } - dsection->overlays = NULL; - dsection->sz_overlays = 0; - dsection->num_overlays = 0; + dsection->overlays = NULL; + dsection->sz_overlays = 0; + dsection->num_overlays = 0; } } else { From a955c3b587b22b8bf20cb6bedbbec4ad5fcb32ac Mon Sep 17 00:00:00 2001 From: Donnie Berkholz Date: Fri, 14 Mar 2008 18:41:07 -0700 Subject: [PATCH 14/21] Xephyr: Distribute ephyrdriext.h in tarballs. --- hw/kdrive/ephyr/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am index d025c201c..81d3d69ea 100644 --- a/hw/kdrive/ephyr/Makefile.am +++ b/hw/kdrive/ephyr/Makefile.am @@ -35,6 +35,7 @@ if XEPHYR_HAS_DRI libxephyr_hostdri_a_SOURCES= \ ephyrdriext.c \ +ephyrdriext.h \ ephyrdri.c \ ephyrdri.h \ XF86dri.c \ From aa231f28d56402d7daea6cbd3002fbf760f79497 Mon Sep 17 00:00:00 2001 From: Donnie Berkholz Date: Fri, 14 Mar 2008 18:41:25 -0700 Subject: [PATCH 15/21] Xephyr: Build fix: Port across XF86dri.c changes from Mesa. --- hw/kdrive/ephyr/XF86dri.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c index 506d7bed8..e656ff5a0 100644 --- a/hw/kdrive/ephyr/XF86dri.c +++ b/hw/kdrive/ephyr/XF86dri.c @@ -385,9 +385,8 @@ Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext) context, hHWContext ); } -GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid context) +GLboolean XF86DRIDestroyContext( Display *dpy, int screen, XID context) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyContextReq *req; @@ -407,10 +406,9 @@ GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid } GLboolean -XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen, - __DRIid drawable, drm_drawable_t * hHWDrawable) +XF86DRICreateDrawable (Display *dpy, int screen, + XID drawable, drm_drawable_t * hHWDrawable) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRICreateDrawableReply rep; xXF86DRICreateDrawableReq *req; @@ -437,16 +435,36 @@ XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen, return True; } -GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen, - __DRIid drawable ) +static int noopErrorHandler(Display *dpy, XErrorEvent *xerr) +{ + return 0; +} + +GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen, + XID drawable ) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyDrawableReq *req; + int (*oldXErrorHandler)(Display *, XErrorEvent *); TRACE("DestroyDrawable..."); XF86DRICheckExtension (dpy, info, False); + /* This is called from the DRI driver, which used call it like this + * + * if (windowExists(drawable)) + * destroyDrawable(drawable); + * + * which is a textbook race condition - the window may disappear + * from the server between checking for its existance and + * destroying it. Instead we change the semantics of + * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if + * the windows is gone, by wrapping the destroy call in an error + * handler. */ + + XSync(dpy, GL_FALSE); + oldXErrorHandler = XSetErrorHandler(noopErrorHandler); + LockDisplay(dpy); GetReq(XF86DRIDestroyDrawable, req); req->reqType = info->codes->major_opcode; @@ -455,6 +473,9 @@ GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen, req->drawable = drawable; UnlockDisplay(dpy); SyncHandle(); + + XSetErrorHandler(oldXErrorHandler); + TRACE("DestroyDrawable... return True"); return True; } From db248ffb840a0c113b6eb508a0fa1e74e752474d Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sun, 16 Mar 2008 18:46:11 +0100 Subject: [PATCH 16/21] test for the presence of pci_system_init_dev_mem() before calling it. This avoids creating a dependency on -current libpciaccess for BSD systems other than OpenBSD (which don't otherwise need it). --- configure.ac | 7 +++++++ hw/xfree86/os-support/bsd/i386_video.c | 2 ++ include/xorg-config.h.in | 3 +++ 3 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 5417bbbda..49f2395fa 100644 --- a/configure.ac +++ b/configure.ac @@ -1308,6 +1308,13 @@ if test "x$XORG" = xyes -o "x$XGL" = xyes; then XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB" PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) + SAVE_LIBS=$LIBS + SAVE_CFLAGS=$CFLAGS + CFLAGS=$PCIACCESS_CFLAGS + LIBS=$PCIACCESS_LIBS + AC_CHECK_FUNCS([pci_system_init_dev_mem]) + LIBS=$SAVE_LIBS + CFLAGS=$SAVE_CFLAGS XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 7e4a4d2a3..1ebac678d 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -212,8 +212,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; +#if HAVE_PCI_SYSTEM_INIT_DEV_MEM if (useDevMem) pci_system_init_dev_mem(devMemFd); +#endif #ifdef HAS_MTRR_SUPPORT if (useDevMem) { diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in index 0603eab67..5587c0a8d 100644 --- a/include/xorg-config.h.in +++ b/include/xorg-config.h.in @@ -115,6 +115,9 @@ /* Have execinfo.h */ #undef HAVE_EXECINFO_H +/* Have pci_system_init_dev_mem() */ +#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM + /* Path to text files containing PCI IDs */ #undef PCI_TXT_IDS_PATH From bee2ddf35f75086cee951142098637f2c756b96b Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 17 Mar 2008 08:33:01 -0700 Subject: [PATCH 17/21] Fail CRTC configuration if !vtSema Unless we check for vtSema before calling into the CRTC and output callbacks, we may end up trying to access video memory that no longer exists, leading to a crash. So if we don't have vtSema, return FALSE to the caller, indicating that we didn't do anything. Fixes #14444. --- hw/xfree86/modes/xf86RandR12.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 1dca223fe..4767f2671 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -743,6 +743,9 @@ xf86RandR12CrtcSet (ScreenPtr pScreen, xf86CrtcPtr *save_crtcs; Bool save_enabled = crtc->enabled; + if (!crtc->scrn->vtSema) + return FALSE; + save_crtcs = xalloc(config->num_output * sizeof (xf86CrtcPtr)); if ((randr_mode != NULL) != crtc->enabled) changed = TRUE; From ba85caacb565b9aa0aeace52a362350304b0566d Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 17 Mar 2008 14:13:09 -0700 Subject: [PATCH 18/21] Make xf86SetDesiredModes aware of current output configuration By adding a new output callback, ->get_crtc, xf86SetDesiredModes is able to avoid turning off outputs & CRTCs if the current output<->CRTC mappings are the same as the desired configuration. This helps avoid flickering displays at startup time, which speeds things up a little and looks better. --- hw/xfree86/modes/xf86Crtc.c | 87 +++++++++++++++++++++++++++++-------- hw/xfree86/modes/xf86Crtc.h | 7 +++ randr/randrstr.h | 1 + 3 files changed, 77 insertions(+), 18 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 6b845b7c9..536b53033 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2033,6 +2033,72 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) return TRUE; } +/* + * Check the CRTC we're going to map each output to vs. it's current + * CRTC. If they don't match, we have to disable the output and the CRTC + * since the driver will have to re-route things. + */ +static void +xf86PrepareOutputs (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + for (o = 0; o < config->num_output; o++) { + xf86OutputPtr output = config->output[o]; +#if RANDR_GET_CRTC_INTERFACE + /* If we can't get the current CRTC, play it safe */ + if (!output->funcs->get_crtc) { + (*output->funcs->dpms)(output, DPMSModeOff); + continue; + } + /* Disable outputs that are unused or will be re-routed */ + if (output->crtc != (*output->funcs->get_crtc)(output) || + output->crtc == NULL) +#endif + (*output->funcs->dpms)(output, DPMSModeOff); + } +} + +static void +xf86PrepareCrtcs (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < config->num_crtc; c++) { +#if RANDR_GET_CRTC_INTERFACE + xf86CrtcPtr crtc = config->crtc[c]; + xf86OutputPtr output = NULL; + uint32_t desired_outputs = 0, current_outputs = 0; + int o; + + for (o = 0; o < config->num_output; o++) { + output = config->output[o]; + if (output->crtc == crtc) + desired_outputs |= (1<funcs->get_crtc) { + desired_outputs = 0; + break; + } + if ((*output->funcs->get_crtc)(output) == crtc) + current_outputs |= (1<funcs->dpms)(crtc, DPMSModeOff); +#else + (*crtc->funcs->dpms)(crtc, DPMSModeOff); +#endif + } +} + /* * Using the desired mode information in each crtc, set * modes (used in EnterVT functions, or at server startup) @@ -2042,26 +2108,11 @@ _X_EXPORT Bool xf86SetDesiredModes (ScrnInfoPtr scrn) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int c, o; + int c; - /* - * Turn off everything so mode setting is done - * with hardware in a consistent state - */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - (*output->funcs->dpms)(output, DPMSModeOff); - } + xf86PrepareOutputs(scrn); + xf86PrepareCrtcs(scrn); - for (c = 0; c < config->num_crtc; c++) - { - xf86CrtcPtr crtc = config->crtc[c]; - - crtc->funcs->dpms(crtc, DPMSModeOff); - memset(&crtc->mode, 0, sizeof(crtc->mode)); - } - for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index a542e7f39..2d723a5cd 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -424,6 +424,13 @@ typedef struct _xf86OutputFuncs { Bool (*get_property)(xf86OutputPtr output, Atom property); +#endif +#ifdef RANDR_GET_CRTC_INTERFACE + /** + * Callback to get current CRTC for a given output + */ + xf86CrtcPtr + (*get_crtc)(xf86OutputPtr output); #endif /** * Clean up driver-specific bits of the output diff --git a/randr/randrstr.h b/randr/randrstr.h index 4d7c9ccfc..62d4bbf46 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -55,6 +55,7 @@ #define RANDR_10_INTERFACE 1 #define RANDR_12_INTERFACE 1 #define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ +#define RANDR_GET_CRTC_INTERFACE 1 #define RANDR_INTERFACE_VERSION 0x0103 From afd7428690d87097117ab20335658f6d59d60103 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 17 Mar 2008 14:55:44 -0700 Subject: [PATCH 19/21] Cleanup logic in xf86PrepareOutputs Should have done this in the first place. Since we're checking for the absence of the get_crtc callback in the first place, we'll short circuit the later call and disable the output, so the ugly "continue" block is unnecesary. --- hw/xfree86/modes/xf86Crtc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 536b53033..8c2b24786 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2047,13 +2047,9 @@ xf86PrepareOutputs (ScrnInfoPtr scrn) for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; #if RANDR_GET_CRTC_INTERFACE - /* If we can't get the current CRTC, play it safe */ - if (!output->funcs->get_crtc) { - (*output->funcs->dpms)(output, DPMSModeOff); - continue; - } /* Disable outputs that are unused or will be re-routed */ - if (output->crtc != (*output->funcs->get_crtc)(output) || + if (!output->funcs->get_crtc || + output->crtc != (*output->funcs->get_crtc)(output) || output->crtc == NULL) #endif (*output->funcs->dpms)(output, DPMSModeOff); From cdadd2ff9bade318caac5c1d9bcdc8a001347da9 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 18 Mar 2008 14:00:15 +0100 Subject: [PATCH 20/21] [Xephyr/DRI] correctly route motion events targeted at GL drawable --- hw/kdrive/ephyr/ephyr.c | 34 ++++++++++++++++++++++++++++------ hw/kdrive/ephyr/hostx.c | 3 ++- hw/kdrive/ephyr/hostx.h | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e95001dcd..b02f9903c 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -891,9 +891,12 @@ ephyrPoll(void) continue; } { - if (ephyrCurScreen != ev.data.mouse_motion.screen) + if (ev.data.mouse_motion.screen >=0 + && (ephyrCurScreen != ev.data.mouse_motion.screen)) { - EPHYR_LOG ("warping mouse cursor:%d\n", ephyrCurScreen) ; + EPHYR_LOG ("warping mouse cursor. " + "cur_screen%d, motion_screen:%d\n", + ephyrCurScreen, ev.data.mouse_motion.screen) ; if (ev.data.mouse_motion.screen >= 0) { ephyrWarpCursor @@ -904,11 +907,30 @@ ephyrPoll(void) } else { + int x=0, y=0; +#ifdef XEPHYR_DRI + EphyrWindowPair *pair = NULL; +#endif EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ; - KdEnqueuePointerEvent(ephyrMouse, mouseState, - ev.data.mouse_motion.x, - ev.data.mouse_motion.y, - 0); + x = ev.data.mouse_motion.x; + y = ev.data.mouse_motion.y; + EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ; +#ifdef XEPHYR_DRI + EPHYR_LOG ("is this window peered by a gl drawable ?\n") ; + if (findWindowPairFromRemote (ev.data.mouse_motion.window, + &pair)) + { + EPHYR_LOG ("yes, it is peered\n") ; + x += pair->local->drawable.x; + y += pair->local->drawable.y; + } + else + { + EPHYR_LOG ("no, it is not peered\n") ; + } + EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ; +#endif + KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0); } } break; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ae1bb4bf9..fd84ec0ef 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -914,8 +914,9 @@ hostx_get_event(EphyrHostXEvent *ev) host_screen_from_window (xev.xmotion.window); ev->type = EPHYR_EV_MOUSE_MOTION; - ev->data.mouse_motion.x = xev.xmotion.x; + ev->data.mouse_motion.x = xev.xmotion.x; ev->data.mouse_motion.y = xev.xmotion.y; + ev->data.mouse_motion.window = xev.xmotion.window; ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1); } return 1; diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index f72cfe700..48d314748 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -70,6 +70,7 @@ struct EphyrHostXEvent int x; int y; int screen; + int window; } mouse_motion; struct mouse_down { From edad0a9dfebcce5c54b2f9c32bd9d45549e20c51 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Tue, 18 Mar 2008 17:51:21 -0400 Subject: [PATCH 21/21] Apply __glXDisp_GetVisualConfigs message patch From http://bugs.freedesktop.org/show_bug.cgi?id=13863 Problem was that the glxcmds.c __glXDisp_GetVisualConfigs function left garbage in the tail end of the message used for extensions. --- GL/glx/glxcmds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index 32d1bc834..3b79cca20 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -944,6 +944,12 @@ int __glXDisp_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) buf[p++] = modes->transparentAlpha; buf[p++] = GLX_TRANSPARENT_INDEX_VALUE; buf[p++] = modes->transparentIndex; + buf[p++] = 0; + buf[p++] = 0; + buf[p++] = 0; + buf[p++] = 0; + buf[p++] = 0; + buf[p++] = 0; if (client->swapped) { __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);