summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/common
diff options
context:
space:
mode:
authorfaith <faith>2000-01-06 12:41:09 +0000
committerfaith <faith>2000-01-06 12:41:09 +0000
commit0387caff984518490a7dc7834a184390bbf4fb97 (patch)
tree3e384e8272b323453802e0cb015c3e28e1077174 /xc/programs/Xserver/hw/xfree86/common
parentb700746a28cb32d457c7aae74d8d04ffd0e4ab5d (diff)
Import of XFree86 3.9.17
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/common')
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/Imakefile33
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/compiler.h114
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/modeline2c.pl27
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86.h27
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Bus.c3260
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Bus.h62
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Config.c639
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c498
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86DGA.c457
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c76
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c80
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Events.c465
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Globals.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Helper.c334
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Init.c188
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Io.c152
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86KbdSol8.c26
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c114
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Mode.c924
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h63
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Priv.h34
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h66
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Resources.h127
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c80
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c75
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h12
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86cmap.c17
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86fbman.c24
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c107
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c2418
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h57
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86str.h113
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86xv.c869
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86xv.h75
35 files changed, 6427 insertions, 5205 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/common/Imakefile b/xc/programs/Xserver/hw/xfree86/common/Imakefile
index 2ccf88e62..c126bb805 100644
--- a/xc/programs/Xserver/hw/xfree86/common/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/common/Imakefile
@@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/34 1996/10/27 11:05:08 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.105 1999/08/14 10:49:34 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.109 1999/12/03 19:17:21 eich Exp $
@@ -23,8 +23,12 @@ XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.105 1999/08/
# ifdef LinuxArchitecture
KBD = xf86KbdLnx
# else
+# if defined(SunArchitecture) && defined(SVR4Architecture) && OSMinorVersion >= 8
+ KBD = xf86KbdSol8
+#else
KBD = xf86Kbd
# endif
+# endif
# endif
#endif
@@ -45,16 +49,6 @@ LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XFree86.\"
EXT_MODULES_DEFINES = $(GLX_DEFINES)
#endif
-#if !NewInput
-#if !defined(LynxOSArchitecture) && !defined(OS2Architecture)
- PNPMOUSESRCS = xf86PnPMouse.c
- PNPMOUSEOBJS = xf86PnPMouse.o
- PNPMOUSEDEFINES = -DPNP_MOUSE
-#endif
- MOUSESRCS = xf86Mouse.c
- MOUSEOBJS = xf86Mouse.o
-#endif
-
#if defined(LinuxArchitecture) && defined(PpcArchitecture)
KBDDEFINES = -DASSUME_CUSTOM_KEYCODES
#endif
@@ -82,12 +76,15 @@ EXP_FORCE_DEFINES = -DSHOW_BETA_MESSAGE -DEXPIRE_SERVER
SRCS = \
xf86Bus.c \
+ xf86isaBus.c \
+ xf86pciBus.c \
xf86IniExt.c \
xf86Config.c \
xf86Cursor.c \
xf86DGA.c \
xf86DPMS.c \
xf86DefModes.c \
+ xf86DoProbe.c \
xf86DoScanPci.c \
xf86Events.c \
xf86Globals.c \
@@ -96,8 +93,6 @@ SRCS = \
xf86Io.c \
xf86MiscExt.c \
xf86Mode.c \
- $(MOUSESRCS) \
- $(PNPMOUSESRCS) \
xf86Option.c \
xf86VidMode.c \
xf86fbman.c \
@@ -112,11 +107,14 @@ SRCS = \
OBJS = \
xf86Bus.o \
+ xf86isaBus.o \
+ xf86pciBus.o \
xf86Config.o \
xf86Cursor.o \
xf86DGA.o \
xf86DPMS.o \
xf86DefModes.o \
+ xf86DoProbe.o \
xf86DoScanPci.o \
xf86Events.o \
xf86Globals.o \
@@ -124,8 +122,6 @@ OBJS = \
xf86Io.o \
xf86MiscExt.o \
xf86Mode.o \
- $(MOUSEOBJS) \
- $(PNPMOUSEOBJS) \
xf86Option.o \
xf86VidMode.o \
xf86fbman.o \
@@ -136,6 +132,7 @@ OBJS = \
$(BETAOBJ) \
$(KBD).o
+
OFILES = \
xf86Init.o \
xf86IniExt.o
@@ -158,7 +155,11 @@ EXP_DEFINES = -DEXPIRY_TIME=XF86ServerExpiry $(EXP_FORCE_DEFINES)
PROJECTROOT = ProjectRoot
XCONFIGDEFINES = -DPROJECTROOT='"$(PROJECTROOT)"'
- DEFINES = $(CONSDEFINES) $(PNPMOUSEDEFINES) $(KBDDEFINES) $(EXT_DEFINES)
+#if defined(SunArchitecture) && defined(SVR4Architecture) && OSMinorVersion >= 8
+ OSDEFINES = -DSOL8
+#endif
+
+ DEFINES = $(CONSDEFINES) $(KBDDEFINES) $(EXT_DEFINES) $(OSDEFINES)
AllTarget($(OFILES))
diff --git a/xc/programs/Xserver/hw/xfree86/common/compiler.h b/xc/programs/Xserver/hw/xfree86/common/compiler.h
index 61c487d68..e6b6678c1 100644
--- a/xc/programs/Xserver/hw/xfree86/common/compiler.h
+++ b/xc/programs/Xserver/hw/xfree86/common/compiler.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.43 1999/06/14 12:02:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.47 1999/12/27 00:39:41 robin Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -63,6 +63,31 @@
#define inl RealInl
#endif
+#if defined(QNX4) /* Do this for now to keep Watcom happy */
+#define outb outp
+#define outw outpw
+#define outl outpd
+#define inb inp
+#define inw inpw
+#define inl inpd
+
+/* Define the ffs function for inlining */
+extern int ffs(unsigned long);
+#pragma aux ffs_ = \
+ "bsf edx, eax" \
+ "jnz bits_set" \
+ "xor eax, eax" \
+ "jmp exit1" \
+ "bits_set:" \
+ "mov eax, edx" \
+ "inc eax" \
+ "exit1:" \
+ __parm [eax] \
+ __modify [eax edx] \
+ __value [eax] \
+ ;
+#endif
+
#if defined(NO_INLINE) || defined(DO_PROTOTYPES)
#if !defined(__sparc__)
@@ -488,13 +513,13 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
}
#define stq_u(v,p) stl_u(v,p)
-#define stl_u(v,p) ((unsigned char *)(p)) = (v); \
- ((unsigned char *)(p)+1) = ((v) >> 8); \
- ((unsigned char *)(p)+2) = ((v) >> 16); \
- ((unsigned char *)(p)+3) = ((v) >> 24)
+#define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8); \
+ (*(unsigned char *)(p)+2) = ((v) >> 16); \
+ (*(unsigned char *)(p)+3) = ((v) >> 24)
-#define stw_u(v,p) ((unsigned char *)(p)) = (v); \
- ((unsigned char *)(p)+1) = ((v) >> 8)
+#define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8)
#define mem_barrier() /* NOP */
#endif /* __mips__ */
@@ -503,9 +528,9 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
#define ldq_u(p) (*((unsigned long *)(p)))
#define ldl_u(p) (*((unsigned int *)(p)))
#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned int *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
+#define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+#define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+#define stw_u(v,p) (*(unsigned short *)(p)) = (v)
#define mem_barrier() /* NOP */
#define write_mem_barrier() /* NOP */
#endif /* __arm32__ */
@@ -606,9 +631,9 @@ inl(unsigned short port)
#define ldq_u(p) (*((unsigned long *)(p)))
#define ldl_u(p) (*((unsigned int *)(p)))
#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned int *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
+#define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+#define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+#define stw_u(v,p) (*(unsigned short *)(p)) = (v)
#define mem_barrier() /* NOP */
#define write_mem_barrier() /* NOP */
@@ -1023,9 +1048,9 @@ inl(unsigned short port)
#define ldq_u(p) (*((unsigned long long *)(p)))
#define ldl_u(p) (*((unsigned long *)(p)))
#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned long *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
+#define stq_u(v,p) (*(unsigned long long *)(p)) = (v)
+#define stl_u(v,p) (*(unsigned long *)(p)) = (v)
+#define stw_u(v,p) (*(unsigned short *)(p)) = (v)
#define mem_barrier() eieio()
#define write_mem_barrier() eieio()
@@ -1081,7 +1106,7 @@ extern void outl(unsigned int a, unsigned char l);
#endif /* !PPCIO_DEBUG */
#else /* !GNUC && !PPC */
-#if !defined(AMOEBA) && !defined(MINIX)
+#if !defined(AMOEBA) && !defined(MINIX) && !defined(QNX4)
# if defined(__STDC__) && (__STDC__ == 1)
# ifndef asm
# define asm __asm
@@ -1387,13 +1412,31 @@ static int inb(port)
#define ldq_u(p) (*((unsigned long *)(p)))
#define ldl_u(p) (*((unsigned int *)(p)))
#define ldw_u(p) (*((unsigned short *)(p)))
-#define stq_u(v,p) ((unsigned long *)(p)) = (v)
-#define stl_u(v,p) ((unsigned int *)(p)) = (v)
-#define stw_u(v,p) ((unsigned short *)(p)) = (v)
+#define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+#define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+#define stw_u(v,p) (*(unsigned short *)(p)) = (v)
#define mem_barrier() /* NOP */
#define write_mem_barrier() /* NOP */
#endif /* __GNUC__ */
+#if defined(QNX4)
+#include <sys/types.h>
+extern unsigned inb(unsigned port);
+extern unsigned inw(unsigned port);
+extern unsigned inl(unsigned port);
+extern void outb(unsigned port, unsigned val);
+extern void outw(unsigned port, unsigned val);
+extern void outl(unsigned port, unsigned val);
+#define ldq_u(p) (*((unsigned long *)(p)))
+#define ldl_u(p) (*((unsigned int *)(p)))
+#define ldw_u(p) (*((unsigned short *)(p)))
+#define stq_u(v,p) ((unsigned long *)(p)) = (v)
+#define stl_u(v,p) ((unsigned int *)(p)) = (v)
+#define stw_u(v,p) ((unsigned short *)(p)) = (v)
+#define mem_barrier() /* NOP */
+#define write_mem_barrier() /* NOP */
+#endif /* QNX4 */
+
#if defined(IODEBUG) && defined(__GNUC__)
#undef inb
#undef inw
@@ -1517,4 +1560,35 @@ testinx(unsigned short port, unsigned char ind)
#endif /* NO_COMPILER_H_EXTRAS */
#endif /* NO_INLINE */
+
+/* Some macros to hide the system dependencies for MMIO accesses */
+#ifdef __alpha__
+#define MMIO_IN8(base, offset) xf86ReadSparse8(base, offset)
+#define MMIO_IN16(base, offset) xf86ReadSparse16(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadSparse32(base, offset)
+#define MMIO_OUT8(base, offset, val) xf86WriteSparse8(val, base, offset)
+#define MMIO_OUT16(base, offset, val) xf86WriteSparse16(val, base, offset)
+#define MMIO_OUT32(base, offset, val) xf86WriteSparse32(val, base, offset)
+#else /* !__alpha__ */
+#define MMIO_IN8(base, offset) *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
+#define MMIO_IN16(base, offset) *(volatile CARD16 *)(((CARD8*)(base)) + (offset))
+#define MMIO_IN32(base, offset) *(volatile CARD32 *)(((CARD8*)(base)) + (offset))
+#define MMIO_OUT8(base, offset, val) *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
+#define MMIO_OUT16(base, offset, val) *(volatile CARD16 *)(((CARD8*)(base)) + (offset)) = (val)
+#define MMIO_OUT32(base, offset, val) *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) = (val)
+#endif /* __alpha__ */
+
+/*
+ * With Intel, the version in os-support/misc/SlowBcopy.s is used.
+ * This avoids port I/O during the copy (which causes problems with
+ * some hardware).
+ */
+#ifdef __alpha__
+#define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+#define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+#else /* __alpha__ */
+#define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+#define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+#endif /* __alpha__ */
+
#endif /* _COMPILER_H */
diff --git a/xc/programs/Xserver/hw/xfree86/common/modeline2c.pl b/xc/programs/Xserver/hw/xfree86/common/modeline2c.pl
index 24c0609d7..1b36ff39b 100644
--- a/xc/programs/Xserver/hw/xfree86/common/modeline2c.pl
+++ b/xc/programs/Xserver/hw/xfree86/common/modeline2c.pl
@@ -10,15 +10,24 @@
# hackish perl - author Dirk Hohndel
# Copyright 1999 by The XFree86 Project, Inc.
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/common/modeline2c.pl,v 1.2 1999/03/29 12:55:55 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/common/modeline2c.pl,v 1.3 1999/11/18 16:52:06 tsi Exp $
my %flagshash;
$flagshash{""} = "0";
-$flagshash{"Interlace"} = "V_INTERLACE";
-$flagshash{"+hsync"} = "V_PHSYNC";
-$flagshash{"-hsync"} = "V_NHSYNC";
-$flagshash{"+vsync"} = "V_PVSYNC";
-$flagshash{"-vsync"} = "V_NVSYNC";
+# $flagshash{"Interlace"} = "V_INTERLACE";
+# $flagshash{"+hsync"} = "V_PHSYNC";
+# $flagshash{"-hsync"} = "V_NHSYNC";
+# $flagshash{"+vsync"} = "V_PVSYNC";
+# $flagshash{"-vsync"} = "V_NVSYNC";
+# XXX I'm definitely not a perl guru... -- tsi
+$flagshash{"+hsync +vsync"} = "V_PHSYNC | V_PVSYNC";
+$flagshash{"+hsync -vsync"} = "V_PHSYNC | V_NVSYNC";
+$flagshash{"-hsync +vsync"} = "V_NHSYNC | V_PVSYNC";
+$flagshash{"-hsync -vsync"} = "V_NHSYNC | V_NVSYNC";
+$flagshash{"+hsync +vsync Interlace"} = "V_PHSYNC | V_PVSYNC | V_INTERLACE";
+$flagshash{"+hsync -vsync Interlace"} = "V_PHSYNC | V_NVSYNC | V_INTERLACE";
+$flagshash{"-hsync +vsync Interlace"} = "V_NHSYNC | V_PVSYNC | V_INTERLACE";
+$flagshash{"-hsync -vsync Interlace"} = "V_NHSYNC | V_NVSYNC | V_INTERLACE";
# stop CVS from expanding the XFree86 Id here...
@@ -42,8 +51,8 @@ printf("/* \$$proj: \$ */
#include \"globals.h\"
-#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DEFAULT
-#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,0,0
+#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DEFAULT
+#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
DisplayModeRec xf86DefaultModes [] = {
");
@@ -64,4 +73,4 @@ while (<>) {
}
-printf("\t{MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,MODESUFFIX}\n};\n");
+printf("\t{MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}\n};\n");
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86.h b/xc/programs/Xserver/hw/xfree86/common/xf86.h
index bf818fef8..212d3a2fd 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.116 1999/08/21 13:48:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.120 1999/12/03 19:17:21 eich Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -19,12 +19,16 @@
#include <X11/Xfuncproto.h>
#include <stdarg.h>
+#include "propertyst.h"
+
/* General parameters */
extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
+extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
extern int xf86PixmapIndex;
extern Bool xf86ResAccessEnter;
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern const unsigned char byte_reversed[256];
+extern PropertyPtr *xf86RegisteredPropertiesTable;
#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
@@ -41,6 +45,11 @@ extern const unsigned char byte_reversed[256];
#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
(((p) == Pix24Use32) ? 32 : 0))
+/* variables for debugging */
+extern CARD32 xf86DummyVar1;
+extern CARD32 xf86DummyVar2;
+extern CARD32 xf86DummyVar3;
+
/* Function Prototypes */
#ifndef _NO_XF86_PROTOTYPES
@@ -58,10 +67,12 @@ pciConfigPtr *xf86GetPciConfigInfo(void);
#endif
void xf86SetPciVideo(pciVideoPtr, resType);
void xf86PrintResList(int verb, resPtr list);
+resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
int xf86GetIsaInfoForScreen(int scrnIndex);
Bool xf86ParseIsaBusString(const char *busID);
void xf86EnableAccess(ScrnInfoPtr pScrn);
+void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
Bool xf86IsPrimaryPci(pciVideoPtr pPci);
Bool xf86IsPrimaryIsa(void);
int xf86CheckPciGAType(pciVideoPtr pPci);
@@ -92,17 +103,20 @@ resRange xf86GetSparse(long type, memType fixed_bits,
memType decode_mask, memType address_mask,
resPtr avoid);
memType xf86ChkConflict(resRange *rgp, int entityIndex);
-
+Bool xf86IsPciDevPresent(int bus, int dev, int func);
+ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
+Bool xf86NoSharedMem(int screenIndex);
+resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
/* xf86Cursor.c */
void xf86LockZoom(ScreenPtr pScreen, int lock);
void xf86InitViewport(ScrnInfoPtr pScr);
-void xf86SetScreenLayout(int scrnIndex, int left, int right, int up, int down);
void xf86SetViewport(ScreenPtr pScreen, int x, int y);
Bool xf86ZoomLocked(ScreenPtr pScreen);
void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
void *xf86GetPointerScreenFuncs(void);
+void xf86InitOrigins(void);
/* xf86DPMS.c */
@@ -192,6 +206,7 @@ void xf86Break1(void);
void xf86Break2(void);
void xf86Break3(void);
void xf86SetBackingStore(ScreenPtr pScreen);
+void xf86SetSilkenMouse(ScreenPtr pScreen);
int xf86NewSerialNumber(WindowPtr p, pointer unused);
pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
char **adaptor_name, pointer *adaptor_options);
@@ -213,6 +228,9 @@ void xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
EntityProc enter, EntityProc leave,
pointer private);
Bool xf86IsScreenPrimary(int scrnIndex);
+extern int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len,
+ pointer value);
/* xf86Init.c */
@@ -229,6 +247,8 @@ ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
ClockRangePtr clockRanges, LookupModeFlags strategy);
ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
int maxPitch, int virtualX,
int virtualY);
ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
@@ -241,7 +261,6 @@ int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
LookupModeFlags strategy);
void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
void xf86PruneDriverModes(ScrnInfoPtr scrp);
-void xf86PruneMonitorModes(MonPtr monp);
void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
void xf86PrintModes(ScrnInfoPtr scrp);
void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
index a8e60853c..88d88916f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
@@ -1,9 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.37 1999/08/28 09:00:51 dawes Exp $ */
-#define DEBUG
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.41 1999/12/03 19:17:21 eich Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
*/
-
+#define REDUCER
/*
* This file contains the interfaces to the bus-specific code
*/
@@ -13,7 +12,6 @@
#include <unistd.h>
#include "X.h"
#include "os.h"
-#include "xf86Pci.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Resources.h"
@@ -21,8 +19,6 @@
/* Bus-specific headers */
#include "xf86Bus.h"
-#define DECLARE_CARD_DATASTRUCTURES TRUE
-#include "xf86PciInfo.h"
#define XF86_OS_PRIVS
#define NEED_OS_RAC_PROTOS
@@ -30,311 +26,50 @@
#include "xf86RAC.h"
-/* Bus-specific globals */
-pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */
-pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */
-pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */
-BusAccPtr xf86PciBusAccInfo = NULL;
-
-/* PCI buses */
-static PciBusPtr xf86PciBus = NULL;
-
/* Entity data */
-static EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
-static int xf86NumEntities = 0;
+EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
+int xf86NumEntities = 0;
+BusAccPtr xf86BusAccInfo = NULL;
-static xf86AccessRec AccessNULL = {NULL,NULL,NULL};
+xf86AccessRec AccessNULL = {NULL,NULL,NULL};
xf86CurrentAccessRec xf86CurrentAccess = {NULL,NULL};
-static BusRec primaryBus = { BUS_NONE, {{0}}};
+BusRec primaryBus = { BUS_NONE, {{0}}};
Bool xf86ResAccessEnter = FALSE;
-/* new RAC */
+int xf86EstimateSizesAggressively = 0;
+
+#ifdef REDUCER
+/* Resources that temporarily conflict with estimated resources */
+static resPtr AccReducers = NULL;
+#endif
/* resource lists */
-static resPtr Acc = NULL;
+resPtr Acc = NULL;
/* allocatable ranges */
-static resPtr ResRange = NULL;
+resPtr ResRange = NULL;
/* predefined special resources */
resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
resRange resVgaShared[] = {_VGA_SHARED, _END};
+resRange resVgaMemShared[] = {_VGA_SHARED_MEM,_END};
+resRange resVgaIoShared[] = {_VGA_SHARED_IO,_END};
resRange resVgaUnusedExclusive[] = {_VGA_EXCLUSIVE_UNUSED, _END};
resRange resVgaUnusedShared[] = {_VGA_SHARED_UNUSED, _END};
resRange resVgaSparseExclusive[] = {_VGA_EXCLUSIVE_SPARSE, _END};
resRange resVgaSparseShared[] = {_VGA_SHARED_SPARSE, _END};
resRange res8514Exclusive[] = {_8514_EXCLUSIVE, _END};
resRange res8514Shared[] = {_8514_SHARED, _END};
-resRange PciAvoid[] = {_PCI_AVOID, _END};
/* Flag: do we need RAC ? */
static Bool needRAC = FALSE;
-/* Bus-specific probe/sorting functions */
-
-/* PCI classes that get included in xf86PciVideoInfo */
-#define PCIINFOCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC) || \
- ((b) == PCI_CLASS_DISPLAY) || \
- ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO) || \
- ((b) == PCI_CLASS_PROCESSOR && (s) == PCI_SUBCLASS_PROCESSOR_COPROC))
-
-/*
- * PCI classes that have messages printed always. The others are only
- * have a message printed when the vendor/dev IDs are recognised.
- */
-#define PCIALWAYSPRINTCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
- ((b) == PCI_CLASS_DISPLAY) || \
- ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO))
-
-/*
- * PCI classes for which potentially destructive checking of the map sizes
- * may be done. Any classes where this may be unsafe should be omitted
- * from this list.
- */
-#define PCINONSYSTEMCLASSES(b,s) PCIALWAYSPRINTCLASSES(b,s)
-
-/*
- * PCI classes that use RAC
- */
-#define PCISHAREDIOCLASSES(b,s) \
- (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
- ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA))
-
-/* XXX Fixme: Hack: so far we only support 32 bit PCI addresses */
-#define PCI_MEMBASE_LENGTH_TYPE(x) 0xFFFFFFFF
-#define PCI_MEMBASE_LENGTH_MAX 0xFFFFFFFF
-#define PCI_IOBASE_LENGTH_MAX 0xFFFF
#undef MIN
#define MIN(x,y) ((x<y)?x:y)
-SymTabPtr xf86PCIVendorNameInfo;
-pciVendorCardInfo *xf86PCICardInfo;
-pciVendorDeviceInfo * xf86PCIVendorInfo;
-
-static void
-xf86FindPCIVideoInfo(void)
-{
- pciConfigPtr pcrp, *pcrpp;
- int i = 0, j, k;
- int num = 0;
- pciVideoPtr info;
- Bool mem64 = FALSE;
-
- pcrpp = xf86PciInfo = xf86scanpci(0);
-
- if (pcrpp == NULL) {
- xf86PciVideoInfo = NULL;
- return;
- }
-
- while ((pcrp = pcrpp[i])) {
- if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class)) {
- num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- sizeof(pciVideoPtr) * (num + 1));
- xf86PciVideoInfo[num] = NULL;
- info = xf86PciVideoInfo[num - 1] = xnfalloc(sizeof(pciVideoRec));
- info->validate = FALSE;
- info->vendor = pcrp->pci_vendor;
- info->chipType = pcrp->pci_device;
- info->chipRev = pcrp->pci_rev_id;
- info->subsysVendor = pcrp->pci_subsys_vendor;
- info->subsysCard = pcrp->pci_subsys_card;
- info->bus = pcrp->busnum;
- info->device = pcrp->devnum;
- info->func = pcrp->funcnum;
- info->class = pcrp->pci_base_class;
- info->subclass = pcrp->pci_sub_class;
- info->interface = pcrp->pci_prog_if;
- info->biosBase = pcrp->pci_baserom;
- info->biosSize = pciGetBaseSize(pcrp->tag, 6, TRUE, NULL);
- info->thisCard = pcrp;
- if ((PCISHAREDIOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
- && (pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
- (pcrp->pci_prog_if == 0)) {
- /* assumption: primary bus is always VGA */
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci.bus = pcrp->busnum;
- primaryBus.id.pci.device = pcrp->devnum;
- primaryBus.id.pci.func = pcrp->funcnum;
- }
-
- for (j = 0; j < 6; j++) {
- info->memBase[j] = 0;
- info->ioBase[j] = 0;
- if (PCINONSYSTEMCLASSES(info->class, info->subclass)) {
- info->size[j] = pciGetBaseSize(pcrp->tag, j, TRUE, NULL);
- info->validate = TRUE;
- }
- else
- info->size[j] = pcrp->basesize[j];
- /* pciGetBaseSize(pcrp->tag, j, FALSE, NULL) */
- info->type[j] = 0;
- }
-
- /*
- * 64-bit base addresses are checked for and avoided.
- * XXX Should deal with them on platforms that support them.
- */
-
- if (pcrp->pci_base0) {
- if (pcrp->pci_base0 & PCI_MAP_IO) {
- info->ioBase[0] = (memType)PCIGETIO(pcrp->pci_base0);
- info->type[0] = pcrp->pci_base0 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base0))
- mem64 = TRUE;
- else {
- info->memBase[0] = (memType)PCIGETMEMORY(pcrp->pci_base0);
- info->type[0] = pcrp->pci_base0 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- }
-
- if (pcrp->pci_base1 && !mem64) {
- if (pcrp->pci_base1 & PCI_MAP_IO) {
- info->ioBase[1] = (memType)PCIGETIO(pcrp->pci_base1);
- info->type[1] = pcrp->pci_base1 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base1))
- mem64 = TRUE;
- else {
- info->memBase[1] = (memType)PCIGETMEMORY(pcrp->pci_base1);
- info->type[1] = pcrp->pci_base1 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- } else if (mem64)
- mem64 = FALSE;
-
- if (pcrp->pci_base2 && !mem64) {
- if (pcrp->pci_base2 & PCI_MAP_IO) {
- info->ioBase[2] = (memType)PCIGETIO(pcrp->pci_base2);
- info->type[2] = pcrp->pci_base2 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base2))
- mem64 = TRUE;
- else {
- info->memBase[2] = (memType)PCIGETMEMORY(pcrp->pci_base2);
- info->type[2] = pcrp->pci_base2 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- } else if (mem64)
- mem64 = FALSE;
-
- if (pcrp->pci_base3 && !mem64) {
- if (pcrp->pci_base3 & PCI_MAP_IO) {
- info->ioBase[3] = (memType)PCIGETIO(pcrp->pci_base3);
- info->type[3] = pcrp->pci_base3 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base3))
- mem64 = TRUE;
- else {
- info->memBase[3] = (memType)PCIGETMEMORY(pcrp->pci_base3);
- info->type[3] = pcrp->pci_base3 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- } else if (mem64)
- mem64 = FALSE;
-
- if (pcrp->pci_base4 && !mem64) {
- if (pcrp->pci_base4 & PCI_MAP_IO) {
- info->ioBase[4] = (memType)PCIGETIO(pcrp->pci_base4);
- info->type[4] = pcrp->pci_base4 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base4))
- mem64 = TRUE;
- else {
- info->memBase[4] = (memType)PCIGETMEMORY(pcrp->pci_base4);
- info->type[4] = pcrp->pci_base4 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- } else if (mem64)
- mem64 = FALSE;
-
- if (pcrp->pci_base5 && !mem64) {
- if (pcrp->pci_base5 & PCI_MAP_IO) {
- info->ioBase[5] = (memType)PCIGETIO(pcrp->pci_base5);
- info->type[5] = pcrp->pci_base5 & PCI_MAP_IO_ATTR_MASK;
- } else
- if (PCI_MAP_IS64BITMEM(pcrp->pci_base5))
- mem64 = TRUE;
- else {
- info->memBase[5] = (memType)PCIGETMEMORY(pcrp->pci_base5);
- info->type[5] = pcrp->pci_base5 & PCI_MAP_MEMORY_ATTR_MASK;
- }
- }
- }
- i++;
- }
-
- /* Print a summary of the video devices found */
- {
- for (k = 0; k < num; k++) {
- char *vendorname = NULL, *chipname = NULL;
- Bool memdone = FALSE, iodone = FALSE;
-
- i = 0;
- info = xf86PciVideoInfo[k];
- while (xf86PCIVendorNameInfo[i].token) {
- if (xf86PCIVendorNameInfo[i].token == info->vendor)
- vendorname = (char *)xf86PCIVendorNameInfo[i].name;
- i++;
- }
- i = 0;
- while(xf86PCIVendorInfo[i].VendorID) {
- if (xf86PCIVendorInfo[i].VendorID == info->vendor) {
- j = 0;
- while (xf86PCIVendorInfo[i].Device[j].DeviceName) {
- if (xf86PCIVendorInfo[i].Device[j].DeviceID ==
- info->chipType) {
- chipname =
- xf86PCIVendorInfo[i].Device[j].DeviceName;
- break;
- }
- j++;
- }
- break;
- }
- i++;
- }
- if ((!vendorname || !chipname) &&
- !PCIALWAYSPRINTCLASSES(info->class, info->subclass))
- continue;
- xf86Msg(X_PROBED, "PCI: (%d:%d:%d) ", info->bus, info->device,
- info->func);
- if (vendorname)
- ErrorF("%s ", vendorname);
- else
- ErrorF("unknown vendor (0x%04x) ", info->vendor);
- if (chipname)
- ErrorF("%s ", chipname);
- else
- ErrorF("unknown chipset (0x%04x) ", info->chipType);
- ErrorF("rev %d", info->chipRev);
- for (i = 0; i < 6; i++) {
- if (info->memBase[i]) {
- if (!memdone) {
- ErrorF(", Mem @ ");
- memdone = TRUE;
- } else
- ErrorF(", ");
- ErrorF("0x%08x/%d", info->memBase[i], info->size[i]);
- }
- }
- for (i = 0; i < 6; i++) {
- if (info->ioBase[i]) {
- if (!iodone) {
- ErrorF(", I/O @ ");
- iodone = TRUE;
- } else
- ErrorF(", ");
- ErrorF("0x%04x/%d", info->ioBase[i], info->size[i]);
- }
- }
- ErrorF("\n");
- }
- }
-}
/*
* Call the bus probes relevant to the architecture.
@@ -345,330 +80,15 @@ xf86FindPCIVideoInfo(void)
void
xf86BusProbe(void)
{
-
-#ifdef XFree86LOADER
- /*
- * we need to get the pointer to the pci data structures initialized
- */
- xf86PCIVendorNameInfo =
- (SymTabPtr)LoaderSymbol("xf86PCIVendorNameInfoData");
- xf86PCIVendorInfo =
- (pciVendorDeviceInfo*)LoaderSymbol("xf86PCIVendorInfoData");
- xf86PCICardInfo =
- (pciVendorCardInfo*)LoaderSymbol("xf86PCICardInfoData");
-#else
- xf86PCIVendorNameInfo = xf86PCIVendorNameInfoData;
- xf86PCIVendorInfo = xf86PCIVendorInfoData;
- xf86PCICardInfo = xf86PCICardInfoData;
-#endif
- xf86FindPCIVideoInfo();
-}
-
-/*
- * Functions to access the bus list. The data structures are opaque to
- * the video drivers.
- */
-
-static int
-xf86AllocateEntity(void)
-{
- xf86NumEntities++;
- xf86Entities = xnfrealloc(xf86Entities, sizeof(EntityPtr) * xf86NumEntities);
- xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
- return (xf86NumEntities - 1);
-}
-
-/*
- * Check if the slot requested is free. If it is already in use, return FALSE.
- */
-
-Bool
-xf86CheckPciSlot(int bus, int device, int func)
-{
- int i;
- EntityPtr p;
-
- for (i = 0; i < xf86NumEntities; i++) {
- p = xf86Entities[i];
- /* Check if this PCI slot is taken */
- if (p->busType == BUS_PCI && p->pciBusId.bus == bus &&
- p->pciBusId.device == device && p->pciBusId.func == func)
- return FALSE;
- }
-
- return TRUE;
+ xf86PciProbe();
}
/*
- * fixPciSizeInfo() -- fix pci size info by testing it destructively
- * (if not already done), fix pciVideoInfo and entry in the resource
- * list.
- */
-/*
- * Note: once we have OS support to read the sizes GetBaseSize() will
- * have to be wrapped by the OS layer. fixPciSizeInfo() should also
- * be wrapped by the OS layer to do nothing if the size is always
- * returned correctly by GetBaseSize(). It should however set validate
- * in pciVideoRec if validation is required. PciValidate() also needs
- * to be wrapped by the OS layer. This may do nothing if the OS has
- * already taken care of validation. fixPciResource() may be moved to
- * OS layer with minimal changes. Once the wrapping layer is in place
- * the common level and drivers should not reference these functions
- * directly but thru the OS layer.
- */
-
-static void
-fixPciSizeInfo(int entityIndex)
-{
- pciVideoPtr pvp;
- resPtr pAcc;
- PCITAG tag;
- int j;
-
- if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return;
- if (pvp->validate) return;
-
- tag = pciTag(pvp->bus,pvp->device,pvp->func);
-
- for (j = 0; j < 6; j++) {
- pAcc = Acc;
- if (pvp->memBase[j])
- while (pAcc) {
- if (((pAcc->res_type & (ResMem | ResBlock))
- == (ResMem | ResBlock))
- && (pAcc->block_begin == pvp->memBase[j])
- && (pAcc->block_end == pvp->memBase[j]
- + (1 << (pvp->size[j])) - 1)) break;
- pAcc = pAcc->next;
- } else if (pvp->ioBase[j])
- while (pAcc) {
- if (((pAcc->res_type & (ResIo | ResBlock)) ==
- (ResIo | ResBlock))
- && (pAcc->block_begin == pvp->ioBase[j])
- && (pAcc->block_end == pvp->ioBase[j]
- + (1 << (pvp->size[j])) - 1)) break;
- pAcc = pAcc->next;
- } else continue;
- pvp->size[j] = pciGetBaseSize(tag, j, TRUE, NULL);
- if (pAcc)
- pAcc->block_end = pAcc->block_begin + (1 << (pvp->size[j])) - 1;
- }
- if (pvp->biosBase) {
- pAcc = Acc;
- while (pAcc) {
- if (((pAcc->res_type & (ResMem | ResBlock)) == (ResMem | ResBlock))
- && (pAcc->block_begin == pvp->biosBase)
- && (pAcc->block_end == pvp->biosBase
- + (1 << (pvp->biosSize)) - 1)) break;
- pAcc = pAcc->next;
- }
- pvp->biosSize = pciGetBaseSize(tag, 6, TRUE, NULL);
- if (pAcc)
- pAcc->block_end = pAcc->block_begin + (1 << (pvp->biosSize))- 1;
- }
-
- pvp->validate = TRUE;
-}
-
-/*
- * If the slot requested is already in use, return -1.
- * Otherwise, claim the slot for the screen requesting it.
- */
-static void disablePciBios(PCITAG tag);
-
-int
-xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active)
-{
- EntityPtr p;
- pciAccPtr *ppaccp = xf86PciAccInfo;
- BusAccPtr pbap = xf86PciBusAccInfo;
-
- int num;
-
- if (xf86CheckPciSlot(bus, device, func)) {
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = chipset;
- p->busType = BUS_PCI;
- p->device = dev;
- p->pciBusId.bus = bus;
- p->pciBusId.device = device;
- p->pciBusId.func = func;
- p->active = active;
- p->inUse = FALSE;
- /* Here we initialize the access structure */
- p->access = xnfcalloc(1,sizeof(EntityAccessRec));
- while (ppaccp && *ppaccp) {
- if ((*ppaccp)->busnum == bus
- && (*ppaccp)->devnum == device
- && (*ppaccp)->funcnum == func) {
- p->access->fallback = &(*ppaccp)->io_memAccess;
- p->access->pAccess = &(*ppaccp)->io_memAccess;
- (*ppaccp)->ctrl = TRUE; /* mark control if not already */
- break;
- }
- ppaccp++;
- }
- if (!ppaccp || !*ppaccp) {
- p->access->fallback = &AccessNULL;
- p->access->pAccess = &AccessNULL;
- }
-
- p->busAcc = NULL;
- while (pbap) {
- if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == bus)
- p->busAcc = pbap;
- pbap = pbap->next;
- }
- fixPciSizeInfo(num);
-
- /* in case bios is enabled disable it */
- disablePciBios(pciTag(bus,device,func));
-
- return num;
- } else
- return -1;
-}
-
-/*
- * Get xf86PciVideoInfo for a driver.
- */
-pciVideoPtr *
-xf86GetPciVideoInfo(void)
-{
- return xf86PciVideoInfo;
-}
-
-/* --- Used by ATI driver, but also more generally useful */
-
-/*
- * Get the full xf86scanpci data.
- */
-pciConfigPtr *
-xf86GetPciConfigInfo(void)
-{
- return xf86PciInfo;
-}
-
-/*
- * Enable a device and route VGA to it. This is intended for a driver's
- * Probe(), before creating EntityRec's. Only one device can be thus enabled
- * at any one time, and should be disabled when the driver is done with it.
- *
- * The following special calls are also available:
- *
- * pvp == NULL && rt == NONE disable previously enabled device
- * pvp != NULL && rt == NONE ensure device is disabled
- * pvp == NULL && rt != NONE disable >all< subsequent calls to this function
- * (done from xf86PostProbe())
- *
- * The device represented by pvp may not have been previously claimed.
- */
-void
-xf86SetPciVideo(pciVideoPtr pvp, resType rt)
-{
- static BusAccPtr pbap = NULL;
- static xf86AccessPtr pAcc = NULL;
- static Bool DoneProbes = FALSE;
- pciAccPtr pcaccp;
- int i;
-
- if (DoneProbes)
- return;
-
- /* Disable previous access */
- if (pAcc) {
- if (pAcc->AccessDisable)
- (*pAcc->AccessDisable)(pAcc->arg);
- pAcc = NULL;
- }
- if (pbap) {
- while (pbap->primary) {
- if (pbap->disable_f)
- (*pbap->disable_f)(pbap);
- pbap->primary->current = NULL;
- pbap = pbap->primary;
- }
- pbap = NULL;
- }
-
- /* Check for xf86PostProbe's magic combo */
- if (!pvp) {
- if (rt != NONE)
- DoneProbes = TRUE;
- return;
- }
-
- /* Validate device */
- if (!xf86PciVideoInfo || !xf86PciAccInfo || !xf86PciBusAccInfo)
- return;
-
- for (i = 0; pvp != xf86PciVideoInfo[i]; i++)
- if (!xf86PciVideoInfo[i])
- return;
-
- /* Ignore request for claimed adapters */
- if (!xf86CheckPciSlot(pvp->bus, pvp->device, pvp->func))
- return;
-
- /* Find pciAccRec structure */
- for (i = 0; ; i++) {
- if (!(pcaccp = xf86PciAccInfo[i]))
- return;
- if ((pvp->bus == pcaccp->busnum) &&
- (pvp->device == pcaccp->devnum) &&
- (pvp->func == pcaccp->funcnum))
- break;
- }
-
- if (rt == NONE) {
- /* This is a call to ensure the adapter is disabled */
- if (pcaccp->io_memAccess.AccessDisable)
- (*pcaccp->io_memAccess.AccessDisable)(pcaccp->io_memAccess.arg);
- return;
- }
-
- /* Find BusAccRec structure */
- for (pbap = xf86PciBusAccInfo; ; pbap = pbap->next) {
- if (!pbap)
- return;
- if (pvp->bus == pbap->busdep.pci.bus)
- break;
- }
-
- /* Route VGA */
- if (pbap->set_f)
- (*pbap->set_f)(pbap);
-
- /* Enable device */
- switch (rt) {
- case IO:
- pAcc = &pcaccp->ioAccess;
- break;
- case MEM_IO:
- pAcc = &pcaccp->io_memAccess;
- break;
- case MEM:
- pAcc = &pcaccp->memAccess;
- break;
- default: /* no compiler noise */
- break;
- }
-
- if (pAcc && pAcc->AccessEnable)
- (*pAcc->AccessEnable)(pAcc->arg);
-}
-
-/* --- */
-
-/*
* Determine what bus type the busID string represents. The start of the
* bus-dependent part of the string is returned as retID.
*/
-static BusType
+BusType
StringToBusType(const char* busID, const char **retID)
{
char *p, *s;
@@ -698,587 +118,8 @@ StringToBusType(const char* busID, const char **retID)
return ret;
}
-
-/*
- * Parse a BUS ID string, and return the PCI bus parameters if it was
- * in the correct format for a PCI bus id.
- */
-
-Bool
-xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
-{
- /*
- * The format is assumed to be "bus:device:func", where bus, device
- * and func are decimal integers. func may be omitted and assumed to
- * be zero, although it doing this isn't encouraged.
- */
-
- char *p, *s;
- const char *id;
- int i;
-
- if (StringToBusType(busID, &id) != BUS_PCI)
- return FALSE;
-
- s = xstrdup(id);
- p = strtok(s, ":");
- if (p == NULL || *p == 0) {
- xfree(s);
- return FALSE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- xfree(s);
- return FALSE;
- }
- }
- *bus = atoi(p);
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- xfree(s);
- return FALSE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- xfree(s);
- return FALSE;
- }
- }
- *device = atoi(p);
- *func = 0;
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- xfree(s);
- return TRUE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- xfree(s);
- return FALSE;
- }
- }
- *func = atoi(p);
- xfree(s);
- return TRUE;
-}
-
-/*
- * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
- */
-
-Bool
-xf86ComparePciBusString(const char *busID, int bus, int device, int func)
-{
- int ibus, idevice, ifunc;
-
- if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
- return bus == ibus && device == idevice && func == ifunc;
- } else {
- return FALSE;
- }
-}
-
-/*
- * If the slot requested is already in use, return FALSE.
- * Otherwise, claim the slot for the screen requesting it.
- */
-
-int
-xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
-{
- EntityPtr p;
- BusAccPtr pbap = xf86PciBusAccInfo;
- int num;
-
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = chipset;
- p->busType = BUS_ISA;
- p->device = dev;
- p->active = active;
- p->inUse = FALSE;
- p->access = xnfcalloc(1,sizeof(EntityAccessRec));
- p->access->fallback = &AccessNULL;
- p->access->pAccess = &AccessNULL;
- p->busAcc = NULL;
- while (pbap) {
- if (pbap->type == BUS_ISA)
- p->busAcc = pbap;
- pbap = pbap->next;
- }
- return num;
-}
-
/*
- * Get the list of ISA "slots" claimed by a screen
- *
- * Note: The ISA implementation here assumes that only one ISA "slot" type
- * can be claimed by any one screen. That means a return value other than
- * 0 or 1 isn't useful.
- */
-int
-xf86GetIsaInfoForScreen(int scrnIndex)
-{
- int num = 0;
- int i;
- EntityPtr p;
-
- for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) {
- p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]];
- if (p->busType == BUS_ISA) {
- num++;
- }
- }
- return num;
-}
-
-/*
- * Parse a BUS ID string, and return True if it is a ISA bus id.
- */
-
-Bool
-xf86ParseIsaBusString(const char *busID)
-{
- /*
- * The format assumed to be "isa" or "isa:"
- */
- return (StringToBusType(busID,NULL) == BUS_ISA);
-}
-
-/*
- * IO enable/disable related routines for PCI
- */
-#define SETBITS PCI_CMD_IO_ENABLE
-static void
-pciIoAccessEnable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-}
-
-static void
-pciIoAccessDisable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
-}
-
-#undef SETBITS
-#define SETBITS (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)
-static void
-pciIo_MemAccessEnable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-}
-
-static void
-pciIo_MemAccessDisable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
-}
-
-#undef SETBITS
-#define SETBITS (PCI_CMD_MEM_ENABLE)
-static void
-pciMemAccessEnable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-}
-
-static void
-pciMemAccessDisable(void* arg)
-{
-#ifdef DEBUG
- ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
-#endif
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,SETBITS, 0);
-}
-#undef SETBITS
-
-#define PCI_PCI_BRDG_CTRL_BASE (PCI_PCI_BRIDGE_CONTROL_REG & 0xFC)
-#define SHIFT_BITS ((PCI_PCI_BRIDGE_CONTROL_REG & 0x3) << 3)
-#define SETBITS (CARD32)((PCI_PCI_BRIDGE_VGA_EN) << SHIFT_BITS)
-static void
-pciBusAccessEnable(BusAccPtr ptr)
-{
- ptr->busdep.pci.func(ptr->busdep.pci.acc,PCI_PCI_BRDG_CTRL_BASE,
- SETBITS,SETBITS);
-}
-
-static void
-pciBusAccessDisable(BusAccPtr ptr)
-{
- ptr->busdep.pci.func(ptr->busdep.pci.acc,PCI_PCI_BRDG_CTRL_BASE,SETBITS,0);
-}
-#undef SETBITS
-#undef SHIFT_BITS
-static void
-pciSetBusAccess(BusAccPtr ptr)
-{
-#ifdef DEBUG
- ErrorF("pciSetBusAccess: route VGA to bus %d\n", ptr->busdep.pci.bus);
-#endif
-
- if (!ptr->primary && !ptr->current)
- return;
-
- if (ptr->current && ptr->current->disable_f)
- ptr->current->disable_f(ptr->current);
- ptr->current = NULL;
-
- /* walk down */
- while (ptr->primary) { /* no enable for top bus */
- if (ptr->primary->current != ptr) {
- if (ptr->primary->current && ptr->primary->current->disable_f)
- ptr->primary->current->disable_f(ptr->primary->current);
- if (ptr->enable_f) ptr->enable_f(ptr);
- ptr->primary->current = ptr;
- }
- ptr = ptr->primary;
- }
-}
-
-static void
-savePciState(PCITAG tag, pciSavePtr ptr)
-{
- int i;
-
- ptr->command = pciReadLong(tag,PCI_CMD_STAT_REG);
- for (i=0; i < 6; i++)
- ptr->base[i] = pciReadLong(tag,PCI_CMD_BASE_REG + i*4 );
- ptr->biosBase = pciReadLong(tag,PCI_CMD_BIOS_REG);
-}
-
-static void
-restorePciState(PCITAG tag, pciSavePtr ptr)
-{
- int i;
-
- /* disable card before setting anything */
- pciSetBitsLong(tag, PCI_CMD_STAT_REG, PCI_CMD_MEM_ENABLE
- | PCI_CMD_IO_ENABLE , 0);
- pciWriteLong(tag,PCI_CMD_BIOS_REG,ptr->biosBase);
- for (i=0; i<6; i++)
- pciWriteLong(tag,PCI_CMD_BASE_REG + i*4, ptr->base[i]);
- pciWriteLong(tag,PCI_CMD_STAT_REG,ptr->command);
-}
-
-static void
-savePciBusState(BusAccPtr ptr)
-{
- ptr->busdep.pci.save.io =
- pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_IO_REG);
- ptr->busdep.pci.save.mem =
- pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_MEM_REG);
- ptr->busdep.pci.save.pmem =
- pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_PMEM_REG);
- ptr->busdep.pci.save.control =
- pciReadByte(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_CONTROL_REG);
-}
-
-static void
-restorePciBusState(BusAccPtr ptr)
-{
- pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_IO_REG,
- ptr->busdep.pci.save.io);
- pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_MEM_REG,
- ptr->busdep.pci.save.mem);
- pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_PMEM_REG,
- ptr->busdep.pci.save.pmem);
- pciWriteByte(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_CONTROL_REG,
- ptr->busdep.pci.save.control);
-}
-
-/*-----------------------------------------------------------------*/
-static void
-initPciState(void)
-{
- int i = 0;
- int j = 0;
- pciVideoPtr pvp;
- pciAccPtr pcaccp;
-
- if (xf86PciAccInfo != NULL)
- return;
-
- if (xf86PciVideoInfo == NULL)
- return;
-
- while ((pvp = xf86PciVideoInfo[i]) != NULL) {
- i++;
- j++;
- xf86PciAccInfo = xnfrealloc(xf86PciAccInfo,
- sizeof(pciAccPtr) * (j + 1));
- xf86PciAccInfo[j] = NULL;
- pcaccp = xf86PciAccInfo[j - 1] = xnfalloc(sizeof(pciAccRec));
- pcaccp->busnum = pvp->bus;
- pcaccp->devnum = pvp->device;
- pcaccp->funcnum = pvp->func;
- pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func);
- pcaccp->arg.func =
- (SetBitsProcPtr)pciLongFunc(pcaccp->arg.tag,SET_BITS);
- pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
- pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
- pcaccp->ioAccess.arg = &pcaccp->arg;
- pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable;
- pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable;
- pcaccp->io_memAccess.arg = &pcaccp->arg;
- pcaccp->memAccess.AccessDisable = pciMemAccessDisable;
- pcaccp->memAccess.AccessEnable = pciMemAccessEnable;
- pcaccp->memAccess.arg = &pcaccp->arg;
- if (PCISHAREDIOCLASSES(pvp->class, pvp->subclass))
- pcaccp->ctrl = TRUE;
- else
- pcaccp->ctrl = FALSE;
- savePciState(pcaccp->arg.tag, &pcaccp->save);
- }
-}
-
-/*
- * initPciBusState() - fill out the BusAccRec for a PCI bus.
- * Theory: each bus is associated with one bridge connecting it
- * to its parent bus. The address of a bridge is therefore stored
- * in the BusAccRec of the bus it connects to. Each bus can
- * have several bridges connecting secondary buses to it. Only one
- * of these bridges can be open. Therefore the status of a bridge
- * associated with a bus is stored in the BusAccRec of the parent
- * the bridge connects to. The first member of the structure is
- * a pointer to a function that open access to this bus. This function
- * receives a pointer to the structure itself as argument. This
- * design should be common to BusAccRecs of any type of buses we
- * support. The remeinder of the structure is bus type specific.
- * In this case it contains a pointer to the structure of the
- * parent bus. Thus enabling access to a specific bus is simple:
- * 1. Close any bridge going to secondary buses.
- * 2. Climb down the ladder and enable any bridge on buses
- * on the path from the CPU to this bus.
- */
-
-static void
-initPciBusState(void)
-{
- BusAccPtr *ppbap_next = &xf86PciBusAccInfo;
- BusAccPtr pbap, pbap_tmp;
- PciBusPtr pbp = xf86PciBus;
-
- while (pbp) {
- (*ppbap_next) = pbap = xnfcalloc(1,sizeof(BusAccRec));
- pbap->busdep.pci.bus = pbp->secondary;
-#if 0
- pbap->save_f = NULL;
- pbap->restore_f = NULL;
- pbap->set_f = NULL;
- pbap->enable_f = NULL;
- pbap->disable_f = NULL;
- pbap->current = NULL;
- pbap->next = NULL;
-#endif
- pbap->busdep.pci.acc = PCITAG_SPECIAL;
- switch (pbp->subclass) {
- case PCI_SUBCLASS_BRIDGE_HOST:
-#ifdef DEBUG
- ErrorF("setting up HOST: %i\n",pbap->busdep.pci.bus);
-#endif
- pbap->type = BUS_PCI;
- pbap->set_f = pciSetBusAccess;
- break;
- case PCI_SUBCLASS_BRIDGE_PCI:
-#ifdef DEBUG
- ErrorF("setting up PCI: %i\n",pbap->busdep.pci.bus);
-#endif
- pbap->type = BUS_PCI;
- pbap->save_f = savePciBusState;
- pbap->restore_f = restorePciBusState;
- pbap->set_f = pciSetBusAccess;
- pbap->enable_f = pciBusAccessEnable;
- pbap->disable_f = pciBusAccessDisable;
- pbap->busdep.pci.acc = pciTag(pbp->brbus,pbp->brdev,pbp->brfunc);
- pbap->busdep.pci.func =
- (SetBitsProcPtr)pciLongFunc(pbap->busdep.pci.acc,SET_BITS);
- savePciBusState(pbap);
- break;
- case PCI_SUBCLASS_BRIDGE_ISA:
-#ifdef DEBUG
- ErrorF("setting up ISA: %i\n",pbap->busdep.pci.bus);
-#endif
- pbap->type = BUS_ISA;
- pbap->set_f = pciSetBusAccess;
- break;
- }
- pbap->next = NULL;
- ppbap_next = &pbap->next;
- pbp = pbp->next;
- }
-
- pbp = xf86PciBus;
- pbap = xf86PciBusAccInfo;
-
- while (pbp) {
- pbap->primary = NULL;
- if (pbp->primary > -1) {
- pbap_tmp = xf86PciBusAccInfo;
- while (pbap_tmp) {
- if (pbap_tmp->busdep.pci.bus == pbp->primary) {
- pbap->primary = pbap_tmp;
- break;
- }
- pbap_tmp = pbap_tmp->next;
- }
- /* set initial state */
-#if 0 /* before doing anything we close all bridges */
- if (pbap->primary
- && pbp->subclass == PCI_SUBCLASS_BRIDGE_PCI
- && pbp->brcontrol & 0x08)
- pbap->primary->current = pbap;
-#endif
- }
- pbap = pbap->next;
- pbp = pbp->next;
- }
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-PciStateEnter(void)
-{
- pciAccPtr paccp;
- int i = 0;
-
- if (xf86PciAccInfo == NULL)
- return;
-
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl)
- continue;
- savePciState(paccp->arg.tag, &paccp->save);
- restorePciState(paccp->arg.tag, &paccp->restore);
- }
-}
-
-static void
-PciBusStateEnter(void)
-{
- BusAccPtr pbap = xf86PciBusAccInfo;
-
- while (pbap) {
- if (pbap->save_f)
- pbap->save_f(pbap);
- pbap = pbap->next;
- }
-}
-
-static void
-PciStateLeave(void)
-{
- pciAccPtr paccp;
- int i = 0;
-
- if (xf86PciAccInfo == NULL)
- return;
-
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl)
- continue;
- savePciState(paccp->arg.tag, &paccp->restore);
- restorePciState(paccp->arg.tag, &paccp->save);
- }
-}
-
-static void
-PciBusStateLeave(void)
-{
- BusAccPtr pbap = xf86PciBusAccInfo;
-
- while (pbap) {
- if (pbap->restore_f)
- pbap->restore_f(pbap);
- pbap = pbap->next;
- }
-}
-
-static void
-DisablePciAccess(void)
-{
- int i = 0;
- pciAccPtr paccp;
- if (xf86PciAccInfo == NULL)
- return;
-
- while ((paccp = xf86PciAccInfo[i]) != NULL) {
- i++;
- if (!paccp->ctrl) /* disable devices that are under control initially*/
- continue;
- pciIo_MemAccessDisable(paccp->io_memAccess.arg);
- }
-}
-
-static void
-disablePciBios(PCITAG tag)
-{
- pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0);
-}
-
-static void
-DisablePciBusAccess(void)
-{
- BusAccPtr pbap = xf86PciBusAccInfo;
-
- while (pbap) {
- if (pbap->disable_f)
- pbap->disable_f(pbap);
- if (pbap->primary)
- pbap->primary->current = NULL;
- pbap = pbap->next;
- }
-}
-
-/*
- * xf86IsPrimaryPci() -- return TRUE if primary device
- * is PCI and bus, dev and func numbers match.
- */
-
-Bool
-xf86IsPrimaryPci(pciVideoPtr pPci)
-{
- if (primaryBus.type != BUS_PCI) return FALSE;
- return (pPci->bus == primaryBus.id.pci.bus &&
- pPci->device == primaryBus.id.pci.device &&
- pPci->func == primaryBus.id.pci.func);
-}
-
-/*
- * xf86IsPrimaryIsa() -- return TRUE if primary device
- * is ISA.
- */
-
-Bool
-xf86IsPrimaryIsa(void)
-{
- return ( primaryBus.type == BUS_ISA );
-}
-
-/*
- * Generic VGA IO part - add other buses here
+ * Entity related code.
*/
void
@@ -1314,6 +155,16 @@ xf86EntityInit(void)
}
}
+int
+xf86AllocateEntity(void)
+{
+ xf86NumEntities++;
+ xf86Entities = xnfrealloc(xf86Entities,
+ sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
+ return (xf86NumEntities - 1);
+}
+
static void
EntityEnter(void)
{
@@ -1354,6 +205,181 @@ EntityLeave(void)
}
}
+Bool
+xf86IsEntityPrimary(int entityIndex)
+{
+ EntityPtr pEnt = xf86Entities[entityIndex];
+
+ if (primaryBus.type != pEnt->busType) return FALSE;
+
+ switch (pEnt->busType) {
+ case BUS_PCI:
+ return (primaryBus.type == BUS_PCI &&
+ pEnt->pciBusId.bus == primaryBus.id.pci.bus &&
+ pEnt->pciBusId.device == primaryBus.id.pci.device &&
+ pEnt->pciBusId.func == primaryBus.id.pci.func);
+ case BUS_ISA:
+ return ( primaryBus.type == BUS_ISA );
+ default:
+ return FALSE;
+ }
+}
+
+Bool
+xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ if (entityIndex >= xf86NumEntities)
+ return FALSE;
+ xf86Entities[entityIndex]->entityInit = init;
+ xf86Entities[entityIndex]->entityEnter = enter;
+ xf86Entities[entityIndex]->entityLeave = leave;
+ xf86Entities[entityIndex]->private = private;
+ return TRUE;
+}
+
+void
+xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ if (entityIndex == -1)
+ return;
+ if (xf86Entities[entityIndex]->inUse)
+ FatalError("Requested Entity already in use!\n");
+
+ pScrn->numEntities++;
+ pScrn->entityList = xnfrealloc(pScrn->entityList,
+ pScrn->numEntities * sizeof(int));
+ pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
+ xf86Entities[entityIndex]->access->next = pScrn->access;
+ pScrn->access = xf86Entities[entityIndex]->access;
+ xf86Entities[entityIndex]->inUse = TRUE;
+}
+
+ScrnInfoPtr
+xf86FindScreenForEntity(int entityIndex)
+{
+ int i,j;
+
+ if (entityIndex == -1) return NULL;
+
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if ( xf86Screens[i]->entityList[j] == entityIndex )
+ return (xf86Screens[i]);
+ }
+ }
+ }
+ return NULL;
+}
+
+void
+xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ int i;
+ EntityAccessPtr *ptr = (EntityAccessPtr *)&pScrn->access;
+ EntityAccessPtr peacc;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (pScrn->entityList[i] == entityIndex) {
+ peacc = xf86Entities[pScrn->entityList[i]]->access;
+ (*ptr) = peacc->next;
+ /* disable entity: call disable func */
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ /* also disable fallback - just in case */
+ if (peacc->fallback && peacc->fallback->AccessDisable)
+ peacc->fallback->AccessDisable(peacc->fallback->arg);
+ for (i++; i < pScrn->numEntities; i++)
+ pScrn->entityList[i-1] = pScrn->entityList[i];
+ pScrn->numEntities--;
+ xf86Entities[entityIndex]->inUse = FALSE;
+ break;
+ }
+ ptr = &(xf86Entities[pScrn->entityList[i]]->access->next);
+ }
+}
+
+/*
+ * xf86ClearEntitiesForScreen() - called when a screen is deleted
+ * to mark it's entities unused. Called by xf86DeleteScreen().
+ */
+void
+xf86ClearEntityListForScreen(int scrnIndex)
+{
+ int i;
+ EntityAccessPtr peacc;
+
+ if (xf86Screens[scrnIndex]->entityList == NULL
+ || xf86Screens[scrnIndex]->numEntities == 0) return;
+
+ for (i=0; i<xf86Screens[scrnIndex]->numEntities; i++) {
+ xf86Entities[xf86Screens[scrnIndex]->entityList[i]]->inUse = FALSE;
+ /* disable resource: call the disable function */
+ peacc = xf86Entities[xf86Screens[scrnIndex]->entityList[i]]->access;
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ /* and the fallback function */
+ if (peacc->fallback && peacc->fallback->AccessDisable)
+ peacc->fallback->AccessDisable(peacc->fallback->arg);
+ /* shared resources are only needed when entity is active: remove */
+ xf86DeallocateResourcesForEntity(i, ResShared);
+ }
+ xfree(xf86Screens[scrnIndex]->entityList);
+ if (xf86Screens[scrnIndex]->CurrentAccess->pIoAccess
+ == (EntityAccessPtr) xf86Screens[scrnIndex]->access)
+ xf86Screens[scrnIndex]->CurrentAccess->pIoAccess = NULL;
+ if (xf86Screens[scrnIndex]->CurrentAccess->pMemAccess
+ == (EntityAccessPtr) xf86Screens[scrnIndex]->access)
+ xf86Screens[scrnIndex]->CurrentAccess->pMemAccess = NULL;
+ xf86Screens[scrnIndex]->entityList = NULL;
+}
+
+void
+xf86DeallocateResourcesForEntity(int entityIndex, long type)
+{
+ resPtr *pprev_next = &Acc;
+ resPtr res = Acc;
+
+ while (res) {
+ if (res->entityIndex == entityIndex &&
+ (type & ResAccMask & res->res_type))
+ {
+ (*pprev_next) = res->next;
+ xfree(res);
+ } else
+ pprev_next = &(res->next);
+ res = (*pprev_next);
+ }
+}
+
+/*
+ * xf86GetEntityInfo() -- This function hands information from the
+ * EntityRec struct to the drivers. The EntityRec structure itself
+ * remains invisible to the driver.
+ */
+EntityInfoPtr
+xf86GetEntityInfo(int entityIndex)
+{
+ EntityInfoPtr pEnt;
+
+ if (entityIndex >= xf86NumEntities)
+ return NULL;
+
+ pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
+ pEnt->index = entityIndex;
+ pEnt->location = xf86Entities[entityIndex]->bus;
+ pEnt->active = xf86Entities[entityIndex]->active;
+ pEnt->chipset = xf86Entities[entityIndex]->chipset;
+ pEnt->resources = xf86Entities[entityIndex]->resources;
+ pEnt->device = xf86Entities[entityIndex]->device;
+
+ return pEnt;
+}
+
+/*
+ * general generic disable function.
+ */
static void
disableAccess(void)
{
@@ -1389,10 +415,13 @@ disableAccess(void)
}
/*
+ * Generic interface to bus specific code - add other buses here
+ */
+
+/*
* xf86AccessInit() - set up everything needed for access control
* called only once on first server generation.
*/
-
void
xf86AccessInit(void)
{
@@ -1407,8 +436,7 @@ xf86AccessInit(void)
/*
* xf86AccessEnter() -- gets called to save the text mode VGA IO
* resources when reentering the server after a VT switch.
- */
-
+ */
void
xf86AccessEnter(void)
{
@@ -1437,7 +465,6 @@ xf86AccessEnter(void)
* This was split to call xf86AccessLeaveState() from
* ddxGiveUp().
*/
-
void
xf86AccessLeave(void)
{
@@ -1494,10 +521,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
case IO:
pceAcc = pScrn->CurrentAccess->pIoAccess;
if (peAcc == pceAcc) {
-#if 0
- if (pScrn->busAccess)
- ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
-#endif
return;
}
if (pScrn->CurrentAccess->pMemAccess == pceAcc)
@@ -1542,10 +565,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
} else { /* current Io == pAccess */
pceAcc = pScrn->CurrentAccess->pMemAccess;
if (pceAcc == peAcc) { /* current Mem == pAccess */
-#if 0
- if (pScrn->busAccess)
- ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
-#endif
return;
}
while (pceAcc) { /* current Mem != pAccess */
@@ -1570,10 +589,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
case MEM:
pceAcc = pScrn->CurrentAccess->pMemAccess;
if (peAcc == pceAcc) {
-#if 0
- if (pScrn->busAccess)
- ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
-#endif
return;
}
if (pScrn->CurrentAccess->pIoAccess == pceAcc)
@@ -1603,6 +618,48 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
}
void
+xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
+{
+ EntityAccessPtr pceAcc2 = NULL;
+ register EntityAccessPtr pceAcc = NULL;
+ register xf86AccessPtr pAcc;
+
+
+ switch(pScrn->resourceType) {
+ case IO:
+ pceAcc = pScrn->CurrentAccess->pIoAccess;
+ break;
+ case MEM:
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ break;
+ case MEM_IO:
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ pceAcc2 = pScrn->CurrentAccess->pIoAccess;
+ break;
+ default:
+ break;
+ }
+
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if ( pAcc) {
+ if (!Enable) {
+ if (pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ } else {
+ if (pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+ }
+ }
+ pceAcc = pceAcc->next;
+ if (!pceAcc) {
+ pceAcc = pceAcc2;
+ pceAcc2 = NULL;
+ }
+ }
+}
+
+void
xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io, xf86AccessPtr p_mem,
xf86AccessPtr p_io_mem, xf86AccessPtr *ppAccessOld)
{
@@ -1625,83 +682,9 @@ xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io, xf86AccessPtr p_mem,
rac->old = ppAccessOld;
}
-/*------------------------------------------------------------*/
-static void CheckGenericGA(void);
-
/*
- * xf86FindPrimaryDevice() - Find the display device which
- * was active when the server was started. Side effects:
- * - disable IO access to all VGA/8514 display adaptors
- * if possible.
+ * Conflict checking
*/
-void
-xf86FindPrimaryDevice()
-{
- /* if no VGA device is found check for primary PCI device */
- if (primaryBus.type == BUS_NONE)
- CheckGenericGA();
-}
-
-#include "vgaHW.h"
-#include "compiler.h"
-
-/*
- * CheckGenericGA() - Check for presence of a VGA device.
- */
-static void
-CheckGenericGA()
-{
-#if !defined(__sparc__) && !defined(__powerpc__) /* FIXME ?? */
- CARD16 GenericIOBase = VGAHW_GET_IOBASE();
- CARD8 CurrentValue, TestValue;
-
- /* VGA CRTC registers are not used here, so don't bother unlocking them */
-
- /* VGA has one more read/write attribute register than EGA */
- (void) inb(GenericIOBase + 0x0AU); /* Reset flip-flop */
- outb(0x3C0, 0x14 | 0x20);
- CurrentValue = inb(0x3C1);
- outb(0x3C0, CurrentValue ^ 0x0F);
- outb(0x3C0, 0x14 | 0x20);
- TestValue = inb(0x3C1);
- outb(0x3C0, CurrentValue);
-
- if ((CurrentValue ^ 0x0F) == TestValue) {
- primaryBus.type = BUS_ISA;
- }
-#endif
-}
-
-/*
- * xf86CheckPciGAType() -- return type of PCI graphics adapter.
- */
-int
-xf86CheckPciGAType(pciVideoPtr pPci)
-{
- int i = 0;
- pciConfigPtr pcp;
-
- while ((pcp = xf86PciInfo[i]) != NULL) {
- if (pPci->bus == pcp->busnum && pPci->device == pcp->devnum
- && pPci->func == pcp->funcnum) {
- if (pcp->pci_base_class == PCI_CLASS_PREHISTORIC &&
- pcp->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA)
- return PCI_CHIP_VGA ;
- if (pcp->pci_base_class == PCI_CLASS_DISPLAY &&
- pcp->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA) {
- if (pcp->pci_prog_if == 0)
- return PCI_CHIP_VGA ;
- if (pcp->pci_prog_if == 1)
- return PCI_CHIP_8514;
- }
- return -1;
- }
- i++;
- }
- return -1;
-}
-
-/* new RAC */
static memType
getMask(memType val)
@@ -1750,9 +733,6 @@ checkConflictBlock(resRange *range, resPtr pRes)
tmp = prev = pRes->sparse_base;
while (i) {
-#ifdef DEBUG
- ErrorF("tmp = 0x%lx\n",tmp);
-#endif
tmp |= 1<< (--i) & val;
if (tmp > range->rEnd)
tmp = prev;
@@ -1851,7 +831,8 @@ needCheck(resPtr pRes, long type, int entityIndex, xf86State state)
BusType loc = BUS_NONE;
BusType r_loc = BUS_NONE;
- if (!((pRes->res_type & type) & ResPhysMask)) return FALSE;
+ if (!(pRes->res_type & type & ResPhysMask))
+ return FALSE;
/*
* Resources set by BIOS (ResBios) are allowed to conflict
@@ -1860,7 +841,12 @@ needCheck(resPtr pRes, long type, int entityIndex, xf86State state)
if (pRes->res_type & type & ResBios)
return FALSE;
- if (type & pRes->res_type & ResUnused) return FALSE;
+ /*If requested, skip over estimated resources */
+ if (pRes->res_type & type & ResEstimated)
+ return FALSE;
+
+ if (type & pRes->res_type & ResUnused)
+ return FALSE;
if (state == OPERATING) {
if (type & ResDisableOpr || pRes->res_type & ResDisableOpr)
@@ -1958,9 +944,9 @@ checkConflict(resRange *rgp, resPtr pRes, int entityIndex, xf86State state)
}
/*
- * ChkConflict() -- used locally ; find conflict with any location.
+ * ChkConflict() -- used within xxxBus ; find conflict with any location.
*/
-static memType
+memType
ChkConflict(resRange *rgp, resPtr res, xf86State state)
{
return checkConflict(rgp, res, -2, state);
@@ -1977,6 +963,10 @@ xf86ChkConflict(resRange *rgp, int entityIndex)
return checkConflict(rgp, Acc, entityIndex, SETUP);
}
+/*
+ * Resources List handling
+ */
+
resPtr
xf86JoinResLists(resPtr rlist1, resPtr rlist2)
{
@@ -2018,6 +1008,13 @@ xf86AddResToList(resPtr rlist, resRange *range, int entityIndex)
}
new = xnfalloc(sizeof(resRec));
+ /*
+ * Only background resources may be registered with ResBios
+ * and ResEstimated set. Other resources only set it for
+ * testing.
+ */
+ if (entityIndex != (-1))
+ range->type &= ~(ResBios | ResEstimated);
new->val = *range;
new->entityIndex = entityIndex;
new->next = rlist;
@@ -2136,6 +1133,42 @@ xf86PrintResList(int verb, resPtr list)
}
}
+resPtr
+xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
+{
+ while(pRange && pRange->type != ResEnd) {
+ list = xf86AddResToList(list,pRange,entityIndex);
+ pRange++;
+ }
+ return list;
+}
+
+void
+xf86ResourceBrokerInit(void)
+{
+ resPtr resPci;
+ resPtr osRes = NULL;
+
+ /* Get the addressable ranges */
+ ResRange = xf86AccWindowsFromOS();
+ xf86MsgVerb(X_INFO, 3, "Addressable resource ranges are\n");
+ xf86PrintResList(3, ResRange);
+
+ /* Get the ranges used exclusively by the system */
+ osRes = xf86AccResFromOS(osRes);
+ xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
+ xf86PrintResList(3, osRes);
+
+ /* Bus dep initialization */
+ resPci = ResourceBrokerInitPci(&osRes);
+ Acc = xf86JoinResLists(osRes, resPci);
+
+
+ xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n");
+ xf86PrintResList(3, Acc);
+
+}
+
#define MEM_ALIGN (1024 * 1024)
/*
@@ -2145,8 +1178,8 @@ xf86PrintResList(int verb, resPtr list)
* At resource broker initialization this is no problem as this
* only deals with exclusive resources.
*/
-static void
-RemoveOverlaps(resPtr target, resPtr list, Bool pciAlignment)
+void
+RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment)
{
resPtr pRes;
memType size, newsize, adjust;
@@ -2176,11 +1209,11 @@ RemoveOverlaps(resPtr target, resPtr list, Bool pciAlignment)
/* Otherwise, trim target to remove the overlap */
if (pRes->block_begin <= target->block_end) {
target->block_end = pRes->block_begin - 1;
- } else if (!pciAlignment &&
+ } else if (!pow2Alignment &&
pRes->block_end >= target->block_begin) {
target->block_begin = pRes->block_end + 1;
}
- if (pciAlignment) {
+ if (pow2Alignment) {
/*
* Align to a power of two. This requires finding the
* largest power of two that is smaller than the adjusted
@@ -2200,752 +1233,9 @@ RemoveOverlaps(resPtr target, resPtr list, Bool pciAlignment)
}
}
-#define PSR_SYS 0x01 /* non-display devices */
-#define PSR_NONSYS 0x02 /* display devices */
-#define PSR_ALL (PSR_SYS | PSR_NONSYS)
-#define PSR_VIDEO 0x04
-#define PSR_NO_OVERLAP 0x08
-
-static void
-xf86GetPciSysRes(resPtr *res, int flags)
-{
- pciConfigPtr pcrp, *pcrpp;
- pciVideoPtr pvp, *pvpp;
- CARD32 *basep;
- memType end;
- resPtr sysRes = NULL, nonsysRes = NULL;
- int i;
- resPtr pRes;
- int verb;
- resRange range;
- static Bool printed = FALSE;
-
- if (!res || !xf86PciInfo)
- return;
-
- if (xf86PciVideoInfo)
- for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
- if (!(flags & PSR_VIDEO) &&
- !PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
- continue;
- for (i = 0; i < 6; i++) {
- if (pvp->ioBase[i]) {
- RANGE(range,pvp->ioBase[i],
- pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
- ResExcIoBlock | ResBios);
- nonsysRes = xf86AddResToList(nonsysRes, &range,-1);
- } else if (pvp->memBase[i]) {
- RANGE(range,pvp->memBase[i],
- pvp->memBase[i] + (1 << pvp->size[i]) - 1,
- ResExcMemBlock | ResBios);
- nonsysRes = xf86AddResToList(nonsysRes, &range, -1);
- }
- }
- if (pvp->biosBase) {
- RANGE(range, pvp->biosBase,
- pvp->biosBase + (1 << pvp->biosSize) - 1,
- ResExcMemBlock | ResBios);
- nonsysRes = xf86AddResToList(nonsysRes, &range, -1);
- }
- }
-
- /* No need to resolve overlaps for NONSYS, so can return here */
- if (!(flags & PSR_SYS)) {
- *res = nonsysRes;
- return;
- }
-
- /* XXX Needs to be updated for 64 bit mappings */
- for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
- long resMisc;
- if (PCINONSYSTEMCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
- continue;
- /* Only process devices with type 0 headers */
- if ((pcrp->pci_header_type & 0x7f) != 0)
- continue;
- if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
- resMisc = ResBios;
- else
- resMisc = ResEstimated;
-
- basep = &pcrp->pci_base0;
- for (i = 0; i < 6; i++) {
- if (basep[i]) {
- if (PCI_MAP_IS_IO(basep[i])) {
- RANGE(range,PCIGETIO(basep[i]),
- range.rBegin + (1 << pcrp->basesize[i]) - 1,
- ResExcIoBlock | resMisc);
- sysRes = xf86AddResToList(sysRes, &range, -1);
- } else {
- RANGE(range,PCIGETMEMORY(basep[i]),
- range.rBegin + (1 << pcrp->basesize[i]) - 1,
- ResExcMemBlock | resMisc);
- sysRes = xf86AddResToList(sysRes, &range, -1);
- }
- }
- }
- if (pcrp->pci_baserom) {
- RANGE(range,PCIGETROM(pcrp->pci_baserom),
- range.rBegin + (1 << pcrp->basesize[6]) - 1,
- ResExcMemBlock | resMisc);
- sysRes = xf86AddResToList(sysRes, &range, -1);
- }
- }
-
- /* Only print the messages once unless very verbose */
- if (!printed) {
- printed = TRUE;
- verb = 3;
- } else {
- verb = 5;
- }
- /* Check for overlaps */
- if (flags & PSR_NO_OVERLAP) {
- for (pRes = sysRes; pRes; pRes = pRes->next) {
- resRange r = pRes->val;
- r.type = (r.type & ResPhysMask) | ResExclusive | ResBlock;
- r.type &= ~(CARD32)ResBios; /* remove for overlap checking */
- if ((end = ChkConflict(&r, pRes->next, SETUP)))
- xf86MsgVerb(X_INFO, verb,
- "PCI %s Resource overlap for 0x%08x at 0x%08x\n",
- (pRes->res_type & ResMem)?"Memory":"Io",
- pRes->block_begin, end);
- if ((end = ChkConflict(&r, nonsysRes, SETUP)))
- xf86MsgVerb(X_INFO, verb,
- "PCI %s Resource overlap for 0x%08x at 0x%08x\n",
- (pRes->res_type & ResMem)?"Memory":"Io",
- pRes->block_begin, end);
- }
- }
-
- xf86MsgVerb(X_INFO, verb, "Non-system PCI resource ranges:\n");
- xf86PrintResList(verb, nonsysRes);
-
- /*
- * Adjust ranges based on the assumption that there are no real
- * overlaps in the PCI base allocations. This assumption should be
- * reasonable in most cases. It may be possible to refine the
- * approximated PCI base sizes by considering bus mapping information
- * from PCI-PCI bridges.
- */
- xf86MsgVerb(X_INFO, verb, "System PCI resource ranges:\n");
- xf86PrintResList(verb, sysRes);
- if (flags & PSR_NO_OVERLAP) {
- for (pRes = sysRes; pRes; pRes = pRes->next) {
- if (ResIsEstimated(&pRes->val)) {
- RemoveOverlaps(pRes, nonsysRes, TRUE);
- RemoveOverlaps(pRes, sysRes, TRUE);
- }
- }
- xf86MsgVerb(X_INFO, verb,
- "System PCI resource ranges after removing overlaps:\n");
- xf86PrintResList(verb, sysRes);
- }
-
- if (flags & (PSR_NONSYS | PSR_VIDEO)) {
- *res = xf86JoinResLists(sysRes, nonsysRes);
- } else {
- xf86FreeResList(nonsysRes);
- *res = sysRes;
- }
-}
-
-static Bool fixPciResource(int prt, memType alignment,
- pciVideoPtr pvp, long type);
-
-static void
-ValidatePci(void)
-{
- pciVideoPtr pvp, pvp1;
- PciBusPtr pbp, pbp1;
- resPtr res_mp = NULL, res_m_io = NULL;
- resPtr tmp, avoid;
- resPtr Sys;
- resPtr Fix;
- resRange range;
- int n = 0, m, i;
-
- if (!xf86PciVideoInfo) return;
-
- /*
- * The order the video devices are listed in is
- * just right: the lower buses come first.
- * This way we attempt to fix a conflict of
- * a lower bus device with a higher bus device
- * where we have more room to find different
- * resources.
- */
- while ((pvp = xf86PciVideoInfo[n++])) {
- if (!pvp->validate) continue;
- Sys = NULL;
- m = n;
- while ((pvp1 = xf86PciVideoInfo[m++])) {
- if (!pvp1->validate) continue;
- for (i = 0; i<6; i++) {
- if (pvp1->ioBase[i]) {
- RANGE(range,pvp1->ioBase[i],
- pvp1->ioBase[i] + (1 << pvp1->size[i]) - 1,
- ResExcIoBlock);
- Sys = xf86AddResToList(Sys,&range,-1);
- } else if (pvp1->memBase[i]) {
- RANGE(range,pvp1->memBase[i],
- pvp1->memBase[i] + (1 << pvp1->size[i]) - 1,
- ResExcMemBlock);
- Sys = xf86AddResToList(Sys,&range,-1);
- }
- }
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"Sys:\n");
- xf86PrintResList(3,Sys);
-#endif
- avoid = NULL;
- pbp = pbp1 = xf86PciBus;
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if (pbp->pmem) {
- /* keep prefetchable separate */
- res_mp = findIntersectOfLists(pbp->pmem,ResRange);
- }
- if (pbp->mem) {
- res_m_io = findIntersectOfLists(pbp->mem,ResRange);
- }
- if (pbp->io) {
- res_m_io = xf86JoinResLists(res_m_io,
- findIntersectOfLists(pbp->io,ResRange));
- }
- }
- while (pbp1) {
- if (pbp1->primary == pvp->bus) {
- tmp = xf86DupResList(pbp1->pmem);
- avoid = xf86JoinResLists(avoid,tmp);
- tmp = xf86DupResList(pbp1->mem);
- avoid = xf86JoinResLists(avoid,tmp);
- tmp = xf86DupResList(pbp1->io);
- avoid = xf86JoinResLists(avoid,tmp);
- }
- pbp1 = pbp1->next;
- }
- pbp = pbp->next;
- }
- if (res_m_io == NULL)
- res_m_io = xf86DupResList(ResRange);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"avoid:\n");
- xf86PrintResList(3,avoid);
- xf86MsgVerb(X_INFO, 3,"prefetchable Memory:\n");
- xf86PrintResList(3,res_mp);
- xf86MsgVerb(X_INFO, 3,"MEM/IO:\n");
- xf86PrintResList(3,res_m_io);
-#endif
- Fix = NULL;
- for (i = 0; i < 6; i++) {
- int j;
- resPtr own = NULL;
- for (j = i+1; j < 6; j++) {
- if (pvp->ioBase[j]) {
- RANGE(range,pvp->ioBase[j],
- pvp->ioBase[j] + (1 << pvp->size[j]) - 1,
- ResExcIoBlock);
- own = xf86AddResToList(own,&range,-1);
- } else if (pvp->memBase[j]) {
- RANGE(range,pvp->memBase[j],
- pvp->memBase[j] + (1 << pvp->size[j]) - 1,
- ResExcMemBlock);
- own = xf86AddResToList(own,&range,-1);
- }
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3,"own:\n");
- xf86PrintResList(3,own);
-#endif
- if (pvp->ioBase[i]) {
- RANGE(range,pvp->ioBase[i],
- pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
- ResExcIoBlock);
- if (isSubsetOf(range,res_m_io)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,Sys,SETUP))
- continue;
- xf86MsgVerb(X_WARNING, 0,
- "****INVALID IO ALLOCATION**** b: 0x%lx e: 0x%lx "
- "correcting\a\n", range.rBegin,range.rEnd);
-#ifdef DEBUG
- sleep(2);
-#endif
- fixPciResource(i, 0, pvp, range.type);
- } else if (pvp->memBase[i]) {
- RANGE(range,pvp->memBase[i],
- pvp->memBase[i] + (1 << pvp->size[i]) - 1,
- ResExcMemBlock);
- if (pvp->type[i] & PCI_MAP_MEMORY_CACHABLE) {
- if (isSubsetOf(range,res_mp)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,Sys,SETUP))
- continue;
- }
- if (isSubsetOf(range,res_m_io)
- && ! ChkConflict(&range,own,SETUP)
- && ! ChkConflict(&range,avoid,SETUP)
- && ! ChkConflict(&range,Sys,SETUP))
- continue;
- xf86MsgVerb(X_WARNING, 0,
- "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx "
- "correcting\a\n", range.rBegin,range.rEnd);
-#ifdef DEBUG
- sleep(2);
-#endif
- fixPciResource(i, 0, pvp, range.type);
- }
- xf86FreeResList(own);
- }
- xf86FreeResList(avoid);
- xf86FreeResList(Sys);
- xf86FreeResList(res_mp);
- xf86FreeResList(res_m_io);
- }
- return;
-}
-
-
-static resList
-GetImplicitPciResources(int entityIndex)
-{
- pciVideoPtr pvp;
- int i;
- resList list = NULL;
-
- int num = 0;
-
- if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return NULL;
-
- for (i = 0; i < 6; i++) {
- if (pvp->ioBase[i]) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- RANGE(list[num - 1],pvp->ioBase[i],
- pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
- ResShrIoBlock | ResBios);
- } else if (pvp->memBase[i]) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- RANGE(list[num - 1],pvp->memBase[i],
- pvp->memBase[i] + (1 << pvp->size[i]) - 1,
- ResShrMemBlock | ResBios);
- }
- }
- if (pvp->biosBase) {
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- RANGE(list[num - 1], pvp->biosBase,
- pvp->biosBase + (1 << pvp->biosSize) - 1,
- ResShrMemBlock | ResBios);
- }
- list = xnfrealloc(list,sizeof(resRange) * (++num));
- list[num - 1].type = ResEnd;
-
- return list;
-}
-
-void
-xf86ResourceBrokerInit(void)
-{
- resPtr resPci = NULL;
- resPtr pRes = NULL, tmp;
-
- /* Get the addressable ranges */
- ResRange = xf86AccWindowsFromOS();
- xf86MsgVerb(X_INFO, 3, "Addressable resource ranges are\n");
- xf86PrintResList(3, ResRange);
-
- /* Get the ranges used exclusively by the system */
- pRes = xf86AccResFromOS(pRes);
-
- /* Get bus-specific system resources (PCI) */
- xf86GetPciSysRes(&resPci, PSR_SYS | PSR_NO_OVERLAP);
-
- /*
- * Adjust OS-reported resource ranges based on the assumption that there
- * are no overlaps with the PCI base allocations. This should be a good
- * assumption because writes to PCI address space won't be routed directly
- * host memory.
- */
- xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
- xf86PrintResList(3, pRes);
-
- for (tmp = pRes; tmp; tmp = tmp->next)
- RemoveOverlaps(tmp, resPci, FALSE);
-
- xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges after removing"
- " overlaps with PCI:\n");
- xf86PrintResList(3, pRes);
-
- pRes = xf86JoinResLists(pRes, resPci);
- xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n");
- xf86PrintResList(3, pRes);
-
- resPci = NULL;
- xf86GetPciSysRes(&resPci, PSR_NONSYS);
- /* Initialise the OS-layer PCI allocator */
- xf86PciBus = xf86InitOSPciAllocator(xf86PciInfo, &pRes, resPci);
- Acc = pRes;
-
-}
-
/*
- * xf86ClaimFixedResources() -- This function gets called from the
- * driver Probe() function to claim fixed resources.
- */
-static void
-resError(resList list)
-{
- FatalError("The driver tried to allocate the %s %sresource at \n"
- "0x%x:0x%x which collided with a resource. Send the\n"
- "output of the server to xfree86@xfree86.org. Please \n"
- "specify your computer hardware as closely as possible\n",
- ResIsBlock(list)?"Block":"Sparse",
- ResIsMem(list)?"Mem":"Io",
- ResIsBlock(list)?list->rBegin:list->rBase,
- ResIsBlock(list)?list->rEnd:list->rMask);
-}
-
-/*
- * xf86ClaimFixedResources() is used to allocate static
- * (ie. fixed non-sharable reosurces).
+ * Resource request code
*/
-void
-xf86ClaimFixedResources(resList list, int entityIndex)
-{
- resPtr ptr = NULL;
-
- if (!list) return;
-
- while (list->type !=ResEnd) {
- switch (list->type & ResAccMask) {
- case ResExclusive:
- if (!xf86ChkConflict(list, entityIndex)) {
- list->type &= ~ResBios;
- Acc = xf86AddResToList(Acc,list,entityIndex);
- } else resError(list); /* no return */
- break;
- case ResShared:
- /* at this stage the resources are just added to the
- * EntityRec. After the Probe() phase this list is checked by
- * xf86PostProbe(). All resources which don't
- * conflict with already allocated ones are allocated
- * and removed from the EntityRec. Thus a non-empty resource
- * list in the EntityRec indicates resource conflicts the
- * driver should either handle or fail.
- */
- if (xf86Entities[entityIndex]->active)
- ptr = xf86AddResToList(ptr,list,entityIndex);
- break;
- }
- list++;
- }
- xf86Entities[entityIndex]->resources =
- xf86JoinResLists(xf86Entities[entityIndex]->resources,ptr);
- xf86MsgVerb(X_INFO, 3,
- "resource ranges after xf86ClaimFixedResources() call:\n");
- xf86PrintResList(3,Acc);
-#ifdef DEBUG
- if (ptr) {
- xf86MsgVerb(X_INFO, 3, "to be registered later:\n");
- xf86PrintResList(3,ptr);
- }
-#endif
-}
-
-static void
-checkRoutingForScreens(xf86State state)
-{
- resList list = resVgaUnusedExclusive;
- resPtr pResVGA = NULL;
- pointer vga = NULL;
- int i,j;
- int entityIndex;
- EntityPtr pEnt;
- resPtr pAcc;
-
- /*
- * find devices that need VGA routed: ie the ones that have
- * registered VGA resources without ResUnused. ResUnused
- * doesn't conflict with itself therefore use it here.
- */
- while (list->type != ResEnd) {
- pResVGA = xf86AddResToList(pResVGA,list,-1);
- list++;
- }
-
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- entityIndex = xf86Screens[i]->entityList[j];
- pEnt = xf86Entities[entityIndex];
- pAcc = Acc;
- vga = NULL;
- while (pAcc) {
- if (pAcc->entityIndex == entityIndex)
- if (checkConflict(&pAcc->val,pResVGA,
- entityIndex,state)) {
- if (vga && vga != pEnt->busAcc) {
- xf86Msg(X_ERROR, "Screen %i needs vga routed to"
- "different buses - deleting\n",i);
- xf86DeleteScreen(i--,0);
- }
- vga = pEnt->busAcc;
- pEnt->entityProp |= (state == SETUP
- ? NEED_VGA_ROUTED_SETUP : NEED_VGA_ROUTED);
- break;
- }
- pAcc = pAcc->next;
- }
- if (vga)
- xf86MsgVerb(X_INFO, 3,"Setting vga for screen %i.\n",i);
- }
- }
- xf86FreeResList(pResVGA);
-}
-
-
-/*
- * xf86PostProbe() -- Allocate all non conflicting resources
- * This function gets called by xf86Init().
- */
-void
-xf86PostProbe(void)
-{
- memType val;
- int i,j;
- resPtr resp, acc, tmp, resp_x, *pprev_next;
-
- xf86SetPciVideo(NULL, MEM_IO);
-
- /* don't compare against ResInit - remove it from clone.*/
- acc = tmp = xf86DupResList(Acc);
- pprev_next = &acc;
- while (tmp) {
- if (tmp->res_type & ResInit) {
- (*pprev_next) = tmp->next;
- xfree(tmp);
- } else
- pprev_next = &(tmp->next);
- tmp = (*pprev_next);
- }
-
- for (i=0; i<xf86NumEntities; i++) {
- resp = xf86Entities[i]->resources;
- xf86Entities[i]->resources = NULL;
- resp_x = NULL;
- while (resp) {
- if (! (val = checkConflict(&resp->val,acc,i,SETUP)))
- {
- tmp = resp_x;
- resp_x = resp;
- resp = resp->next;
- resp_x->next = tmp;
- } else {
- xf86MsgVerb(X_INFO, 3, "Found conflict at: 0x%lx\n",val);
- tmp = xf86Entities[i]->resources;
- xf86Entities[i]->resources = resp;
- resp = resp->next;
- xf86Entities[i]->resources->next = tmp;
- }
- }
- xf86JoinResLists(Acc,resp_x);
- }
- xf86FreeResList(acc);
-
- ValidatePci();
-
- xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n");
- xf86PrintResList(3, Acc);
- checkRoutingForScreens(SETUP);
-
- for (i = 0; i < xf86NumScreens; i++) {
- pointer *route = NULL;
- for (j = 0; j<xf86Screens[i]->numEntities; j++) {
- EntityPtr pEnt = xf86Entities[xf86Screens[i]->entityList[j]];
- if (pEnt->entityProp & NEED_VGA_ROUTED_SETUP)
- route = pEnt->busAcc;
- if (route) {
- xf86Screens[i]->busAccess = route;
- break;
- }
- }
- }
-}
-
-void
-xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- if (entityIndex == -1)
- return;
- if (xf86Entities[entityIndex]->inUse)
- FatalError("Requested Entity already in use!\n");
-
- pScrn->numEntities++;
- pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
- pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
- xf86Entities[entityIndex]->access->next = pScrn->access;
- pScrn->access = xf86Entities[entityIndex]->access;
- xf86Entities[entityIndex]->inUse = TRUE;
-}
-
-Bool
-xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
-{
- if (entityIndex >= xf86NumEntities)
- return FALSE;
- xf86Entities[entityIndex]->entityInit = init;
- xf86Entities[entityIndex]->entityEnter = enter;
- xf86Entities[entityIndex]->entityLeave = leave;
- xf86Entities[entityIndex]->private = private;
- return TRUE;
-}
-
-void
-xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- int i;
- EntityAccessPtr *ptr = (EntityAccessPtr *)&pScrn->access;
- EntityAccessPtr peacc;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- peacc = xf86Entities[pScrn->entityList[i]]->access;
- (*ptr) = peacc->next;
- /* disable entity: call disable func */
- if (peacc->pAccess && peacc->pAccess->AccessDisable)
- peacc->pAccess->AccessDisable(peacc->pAccess->arg);
- /* also disable fallback - just in case */
- if (peacc->fallback && peacc->fallback->AccessDisable)
- peacc->fallback->AccessDisable(peacc->fallback->arg);
- for (i++; i < pScrn->numEntities; i++)
- pScrn->entityList[i-1] = pScrn->entityList[i];
- pScrn->numEntities--;
- xf86Entities[entityIndex]->inUse = FALSE;
- break;
- }
- ptr = &(xf86Entities[pScrn->entityList[i]]->access->next);
- }
-}
-
-void
-xf86DeallocateResourcesForEntity(int entityIndex, long type)
-{
- resPtr *pprev_next = &Acc;
- resPtr res = Acc;
-
- while (res) {
- if (res->entityIndex == entityIndex &&
- (type & ResAccMask & res->res_type))
- {
- (*pprev_next) = res->next;
- xfree(res);
- } else
- pprev_next = &(res->next);
- res = (*pprev_next);
- }
-}
-
-/*
- * xf86ClearEntitiesForScreen() - called when a screen is deleted
- * to mark it's entities unused. Called by xf86DeleteScreen().
- */
-void
-xf86ClearEntityListForScreen(int scrnIndex)
-{
- int i;
- EntityAccessPtr peacc;
-
- if (xf86Screens[scrnIndex]->entityList == NULL
- || xf86Screens[scrnIndex]->numEntities == 0) return;
-
- for (i=0; i<xf86Screens[scrnIndex]->numEntities; i++) {
- xf86Entities[xf86Screens[scrnIndex]->entityList[i]]->inUse = FALSE;
- /* disable resource: call the disable function */
- peacc = xf86Entities[xf86Screens[scrnIndex]->entityList[i]]->access;
- if (peacc->pAccess && peacc->pAccess->AccessDisable)
- peacc->pAccess->AccessDisable(peacc->pAccess->arg);
- /* and the fallback function */
- if (peacc->fallback && peacc->fallback->AccessDisable)
- peacc->fallback->AccessDisable(peacc->fallback->arg);
- /* shared resources are only needed when entity is active: remove */
- xf86DeallocateResourcesForEntity(i, ResShared);
- }
- xfree(xf86Screens[scrnIndex]->entityList);
- if (xf86Screens[scrnIndex]->CurrentAccess->pIoAccess
- == (EntityAccessPtr) xf86Screens[scrnIndex]->access)
- xf86Screens[scrnIndex]->CurrentAccess->pIoAccess = NULL;
- if (xf86Screens[scrnIndex]->CurrentAccess->pMemAccess
- == (EntityAccessPtr) xf86Screens[scrnIndex]->access)
- xf86Screens[scrnIndex]->CurrentAccess->pMemAccess = NULL;
- xf86Screens[scrnIndex]->entityList = NULL;
-}
-
-/*
- * xf86GetEntityInfo() -- This function hands information from the
- * EntityRec struct to the drivers. The EntityRec structure itself
- * remains invisible to the driver.
- */
-EntityInfoPtr
-xf86GetEntityInfo(int entityIndex)
-{
- EntityInfoPtr pEnt;
-
- if (entityIndex >= xf86NumEntities)
- return NULL;
-
- pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
- pEnt->index = entityIndex;
- pEnt->location = xf86Entities[entityIndex]->bus;
- pEnt->active = xf86Entities[entityIndex]->active;
- pEnt->chipset = xf86Entities[entityIndex]->chipset;
- pEnt->resources = xf86Entities[entityIndex]->resources;
- pEnt->device = xf86Entities[entityIndex]->device;
-
- return pEnt;
-}
-
-/*
- * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
- */
-pciVideoPtr
-xf86GetPciInfoForEntity(int entityIndex)
-{
- pciVideoPtr *ppPci;
- EntityPtr p = xf86Entities[entityIndex];
-
- if (entityIndex >= xf86NumEntities
- || p->busType != BUS_PCI) return NULL;
-
- for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
- if (p->pciBusId.bus == (*ppPci)->bus &&
- p->pciBusId.device == (*ppPci)->device &&
- p->pciBusId.func == (*ppPci)->func)
- return (*ppPci);
- }
- return NULL;
-}
-
-ScrnInfoPtr
-xf86FindScreenForEntity(int entityIndex)
-{
- int i,j;
-
- if (entityIndex == -1) return NULL;
-
- if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- if ( xf86Screens[i]->entityList[j] == entityIndex )
- return (xf86Screens[i]);
- }
- }
- }
- return NULL;
-}
#define ALIGN(x,a) ((x) + a) &~(a)
@@ -2965,7 +1255,7 @@ xf86GetBlock(long type, memType size,
window_start,window_end,size);
return r;
}
- type = (type & ~ResExtMask & ~ResNoAvoid) | ResBlock;
+ type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResBlock;
while (res_range) {
if (type & res_range->res_type & ResPhysMask) {
@@ -3062,7 +1352,7 @@ xf86GetSparse(long type, memType fixed_bits,
memType conflict = 0;
/* for sanity */
- type = (type & ~ResExtMask & ~ResNoAvoid) | ResSparse;
+ type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResSparse;
/*
* a sparse address consists of 3 parts:
@@ -3152,6 +1442,10 @@ xf86GetSparse(long type, memType fixed_bits,
#undef length
#undef mt_max
+/*
+ * Resource registrarion
+ */
+
static resList
xf86GetResourcesImplicitly(int entityIndex)
{
@@ -3187,10 +1481,10 @@ xf86RegisterResources(int entityIndex, resList list, int access)
if ((access != ResNone) && (access & ResAccMask)) {
range.type = (range.type & ~ResAccMask) | (access & ResAccMask);
}
+ range.type &= ~ResEstimated; /* Not allowed for drivers */
if(xf86ChkConflict(&range,entityIndex))
res = xf86AddResToList(res,&range,entityIndex);
else {
- range.type &= ~ResBios;
Acc = xf86AddResToList(Acc,&range,entityIndex);
}
list++;
@@ -3199,70 +1493,17 @@ xf86RegisterResources(int entityIndex, resList list, int access)
xf86MsgVerb(X_INFO, 3,"Resources after driver initialization\n");
xf86PrintResList(3, Acc);
if (res) xf86MsgVerb(X_INFO, 3,
- "Failed Resources after driver initialization\n");
+ "Failed Resources after driver initialization "
+ "for Entity: %i\n",entityIndex);
xf86PrintResList(3, res);
#endif
return res;
}
-static void
-checkRequiredResources(int entityIndex)
-{
- resRange range;
- resPtr pAcc = Acc;
- const EntityPtr pEnt = xf86Entities[entityIndex];
- while (pAcc) {
- if (pAcc->entityIndex == entityIndex) {
- range = pAcc->val;
- /* ResAny to find conflicts with anything. */
- range.type = (range.type & ~ResAccMask) | ResAny | ResBios;
- if (checkConflict(&range,Acc,entityIndex,OPERATING))
- switch (pAcc->res_type & ResPhysMask) {
- case ResMem:
- pEnt->entityProp |= NEED_MEM_SHARED;
- break;
- case ResIo:
- pEnt->entityProp |= NEED_IO_SHARED;
- break;
- }
- if (!(pAcc->res_type & ResOprMask)) {
- switch (pAcc->res_type & ResPhysMask) {
- case ResMem:
- pEnt->entityProp |= NEED_MEM;
- break;
- case ResIo:
- pEnt->entityProp |= NEED_IO;
- break;
- }
- }
- }
- pAcc = pAcc->next;
- }
-
- /* check if we can separately enable mem/io resources */
- /* XXX we still need to find out how to set this yet */
- if ( ((pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)
- && (pEnt->entityProp & NEED_MEM_SHARED))
- || ((pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)
- && (pEnt->entityProp & NEED_IO_SHARED)) )
- pEnt->entityProp |= NEED_SHARED;
- /*
- * After we have checked all resources of an entity agains any
- * other resource we know if the entity need this resource type
- * (ie. mem/io) at all. if not we can disable this type completely,
- * so no need to share it either.
- */
- if ((pEnt->entityProp & NEED_MEM_SHARED)
- && (!(pEnt->entityProp & NEED_MEM))
- && (!(pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)))
- pEnt->entityProp &= ~(unsigned long)NEED_MEM_SHARED;
-
- if ((pEnt->entityProp & NEED_IO_SHARED)
- && (!(pEnt->entityProp & NEED_IO))
- && (!(pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)))
- pEnt->entityProp &= ~(unsigned long)NEED_IO_SHARED;
-}
+/*
+ * Server State
+ */
static xf86AccessPtr
busTypeSpecific(EntityPtr pEnt, xf86State state)
@@ -3417,7 +1658,9 @@ setAccess(EntityPtr pEnt, xf86State state)
}
}
-
+/*
+ * xf86EnterServerState() -- set state the server is in.
+ */
void
xf86EnterServerState(xf86State state)
{
@@ -3500,6 +1743,334 @@ xf86EnterServerState(xf86State state)
}
}
+/*
+ * xf86SetOperatingState() -- Set ResOperMask for resources listed.
+ */
+resPtr
+xf86SetOperatingState(resList list, int entityIndex, int mask)
+{
+ resPtr acc;
+ resPtr r_fail = NULL;
+
+ while (list->type != ResEnd) {
+ acc = Acc;
+ while (acc) {
+#define MASK (ResPhysMask | ResExtMask)
+ if ((acc->entityIndex == entityIndex)
+ && (acc->val.a == list->a) && (acc->val.b == list->b)
+ && ((acc->val.type & MASK) == (list->type & MASK)))
+ break;
+#undef MASK
+ acc = acc->next;
+ }
+ if (acc)
+ acc->val.type = (acc->val.type & ~ResOprMask)
+ | (mask & ResOprMask);
+ else {
+ r_fail = xf86AddResToList(r_fail,list,entityIndex);
+ }
+ list ++;
+ }
+
+ return r_fail;
+}
+
+/*
+ * Stage specific code
+ */
+ /*
+ * ProcessEstimatedConflicts() -- Do something about driver-registered
+ * resources that conflict with estimated resources. For now, just register
+ * them with a logged warning.
+ */
+#ifdef REDUCER
+static void
+ProcessEstimatedConflicts(void)
+{
+ if (!AccReducers)
+ return;
+
+ /* Temporary */
+ xf86MsgVerb(X_WARNING, 3,
+ "Registering the following despite conflicts with estimated"
+ " resources:\n");
+ xf86PrintResList(3, AccReducers);
+ Acc = xf86JoinResLists(Acc, AccReducers);
+ AccReducers = NULL;
+}
+#endif
+
+/*
+ * xf86ClaimFixedResources() -- This function gets called from the
+ * driver Probe() function to claim fixed resources.
+ */
+static void
+resError(resList list)
+{
+ FatalError("A driver tried to allocate the %s %sresource at \n"
+ "0x%x:0x%x which conflicted with another resource. Send the\n"
+ "output of the server to xfree86@xfree86.org. Please \n"
+ "specify your computer hardware as closely as possible.\n",
+ ResIsBlock(list)?"Block":"Sparse",
+ ResIsMem(list)?"Mem":"Io",
+ ResIsBlock(list)?list->rBegin:list->rBase,
+ ResIsBlock(list)?list->rEnd:list->rMask);
+}
+
+/*
+ * xf86ClaimFixedResources() is used to allocate non-relocatable resources.
+ * This should only be done by a driver's Probe() function.
+ */
+void
+xf86ClaimFixedResources(resList list, int entityIndex)
+{
+ resPtr ptr = NULL;
+ resRange range;
+
+ if (!list) return;
+
+ while (list->type !=ResEnd) {
+ range = *list;
+ range.type &= ~ResEstimated; /* Not allowed for drivers */
+ switch (range.type & ResAccMask) {
+ case ResExclusive:
+ if (!xf86ChkConflict(&range, entityIndex)) {
+ Acc = xf86AddResToList(Acc, &range, entityIndex);
+#ifdef REDUCER
+ } else {
+ range.type |= ResEstimated;
+ if (!xf86ChkConflict(&range, entityIndex) &&
+ !checkConflict(&range, AccReducers, entityIndex, SETUP)) {
+ range.type &= ~(ResEstimated | ResBios);
+ AccReducers =
+ xf86AddResToList(AccReducers, &range, entityIndex);
+#endif
+ } else resError(&range); /* no return */
+#ifdef REDUCER
+ }
+#endif
+ break;
+ case ResShared:
+ /* at this stage the resources are just added to the
+ * EntityRec. After the Probe() phase this list is checked by
+ * xf86PostProbe(). All resources which don't
+ * conflict with already allocated ones are allocated
+ * and removed from the EntityRec. Thus a non-empty resource
+ * list in the EntityRec indicates resource conflicts the
+ * driver should either handle or fail.
+ */
+ if (xf86Entities[entityIndex]->active)
+ ptr = xf86AddResToList(ptr,&range,entityIndex);
+ break;
+ }
+ list++;
+ }
+ xf86Entities[entityIndex]->resources =
+ xf86JoinResLists(xf86Entities[entityIndex]->resources,ptr);
+ xf86MsgVerb(X_INFO, 3,
+ "resource ranges after xf86ClaimFixedResources() call:\n");
+ xf86PrintResList(3,Acc);
+#ifdef REDUCER
+ ProcessEstimatedConflicts();
+#endif
+#ifdef DEBUG
+ if (ptr) {
+ xf86MsgVerb(X_INFO, 3, "to be registered later:\n");
+ xf86PrintResList(3,ptr);
+ }
+#endif
+}
+
+static void
+checkRoutingForScreens(xf86State state)
+{
+ resList list = resVgaUnusedExclusive;
+ resPtr pResVGA = NULL;
+ pointer vga = NULL;
+ int i,j;
+ int entityIndex;
+ EntityPtr pEnt;
+ resPtr pAcc;
+ resRange range;
+
+ /*
+ * find devices that need VGA routed: ie the ones that have
+ * registered VGA resources without ResUnused. ResUnused
+ * doesn't conflict with itself therefore use it here.
+ */
+ while (list->type != ResEnd) { /* create resPtr from resList for VGA */
+ range = *list;
+ range.type &= ~(ResBios | ResEstimated); /* if set remove them */
+ pResVGA = xf86AddResToList(pResVGA, &range, -1);
+ list++;
+ }
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ entityIndex = xf86Screens[i]->entityList[j];
+ pEnt = xf86Entities[entityIndex];
+ pAcc = Acc;
+ vga = NULL;
+ while (pAcc) {
+ if (pAcc->entityIndex == entityIndex)
+ if (checkConflict(&pAcc->val,pResVGA,
+ entityIndex,state)) {
+ if (vga && vga != pEnt->busAcc) {
+ xf86Msg(X_ERROR, "Screen %i needs vga routed to"
+ "different buses - deleting\n",i);
+ xf86DeleteScreen(i--,0);
+ }
+ vga = pEnt->busAcc;
+ pEnt->entityProp |= (state == SETUP
+ ? NEED_VGA_ROUTED_SETUP : NEED_VGA_ROUTED);
+ break;
+ }
+ pAcc = pAcc->next;
+ }
+ if (vga)
+ xf86MsgVerb(X_INFO, 3,"Setting vga for screen %i.\n",i);
+ }
+ }
+ xf86FreeResList(pResVGA);
+}
+
+/*
+ * xf86PostProbe() -- Allocate all non conflicting resources
+ * This function gets called by xf86Init().
+ */
+void
+xf86PostProbe(void)
+{
+ memType val;
+ int i,j;
+ resPtr resp, acc, tmp, resp_x, *pprev_next;
+
+ /* don't compare against ResInit - remove it from clone.*/
+ acc = tmp = xf86DupResList(Acc);
+ pprev_next = &acc;
+ while (tmp) {
+ if (tmp->res_type & ResInit) {
+ (*pprev_next) = tmp->next;
+ xfree(tmp);
+ } else
+ pprev_next = &(tmp->next);
+ tmp = (*pprev_next);
+ }
+
+ for (i=0; i<xf86NumEntities; i++) {
+ resp = xf86Entities[i]->resources;
+ xf86Entities[i]->resources = NULL;
+ resp_x = NULL;
+ while (resp) {
+ if (! (val = checkConflict(&resp->val,acc,i,SETUP))) {
+ resp->res_type &= ~(ResBios); /* just used for chkConflict() */
+ tmp = resp_x;
+ resp_x = resp;
+ resp = resp->next;
+ resp_x->next = tmp;
+#ifdef REDUCER
+ } else {
+ resp->res_type |= ResEstimated;
+ if (!checkConflict(&resp->val, acc, i, SETUP)) {
+ resp->res_type &= ~(ResEstimated | ResBios);
+ tmp = AccReducers;
+ AccReducers = resp;
+ resp = resp->next;
+ AccReducers->next = tmp;
+#endif
+ } else {
+ xf86MsgVerb(X_INFO, 3, "Found conflict at: 0x%lx\n",val);
+ resp->res_type &= ~ResEstimated;
+ tmp = xf86Entities[i]->resources;
+ xf86Entities[i]->resources = resp;
+ resp = resp->next;
+ xf86Entities[i]->resources->next = tmp;
+ }
+#ifdef REDUCER
+ }
+#endif
+ }
+ xf86JoinResLists(Acc,resp_x);
+#ifdef REDUCER
+ ProcessEstimatedConflicts();
+#endif
+ }
+ xf86FreeResList(acc);
+
+ ValidatePci();
+
+ xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n");
+ xf86PrintResList(3, Acc);
+ checkRoutingForScreens(SETUP);
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j<xf86Screens[i]->numEntities; j++) {
+ EntityPtr pEnt = xf86Entities[xf86Screens[i]->entityList[j]];
+ if ((pEnt->entityProp & NEED_VGA_ROUTED_SETUP) &&
+ ((xf86Screens[i]->busAccess = pEnt->busAcc)))
+ break;
+ }
+ }
+}
+
+static void
+checkRequiredResources(int entityIndex)
+{
+ resRange range;
+ resPtr pAcc = Acc;
+ const EntityPtr pEnt = xf86Entities[entityIndex];
+ while (pAcc) {
+ if (pAcc->entityIndex == entityIndex) {
+ range = pAcc->val;
+ /* ResAny to find conflicts with anything. */
+ range.type = (range.type & ~ResAccMask) | ResAny | ResBios;
+ if (checkConflict(&range,Acc,entityIndex,OPERATING))
+ switch (pAcc->res_type & ResPhysMask) {
+ case ResMem:
+ pEnt->entityProp |= NEED_MEM_SHARED;
+ break;
+ case ResIo:
+ pEnt->entityProp |= NEED_IO_SHARED;
+ break;
+ }
+ if (!(pAcc->res_type & ResOprMask)) {
+ switch (pAcc->res_type & ResPhysMask) {
+ case ResMem:
+ pEnt->entityProp |= NEED_MEM;
+ break;
+ case ResIo:
+ pEnt->entityProp |= NEED_IO;
+ break;
+ }
+ }
+ }
+ pAcc = pAcc->next;
+ }
+
+ /* check if we can separately enable mem/io resources */
+ /* XXX we still need to find out how to set this yet */
+ if ( ((pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)
+ && (pEnt->entityProp & NEED_MEM_SHARED))
+ || ((pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)
+ && (pEnt->entityProp & NEED_IO_SHARED)) )
+ pEnt->entityProp |= NEED_SHARED;
+ /*
+ * After we have checked all resources of an entity agains any
+ * other resource we know if the entity need this resource type
+ * (ie. mem/io) at all. if not we can disable this type completely,
+ * so no need to share it either.
+ */
+ if ((pEnt->entityProp & NEED_MEM_SHARED)
+ && (!(pEnt->entityProp & NEED_MEM))
+ && (!(pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)))
+ pEnt->entityProp &= ~(unsigned long)NEED_MEM_SHARED;
+
+ if ((pEnt->entityProp & NEED_IO_SHARED)
+ && (!(pEnt->entityProp & NEED_IO))
+ && (!(pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)))
+ pEnt->entityProp &= ~(unsigned long)NEED_IO_SHARED;
+}
+
void
xf86PostPreInit()
{
@@ -3610,446 +2181,12 @@ xf86PostScreenInit(void)
}
/*
- * xf86CheckPciMemBase() checks that the memory base value matches one of the
- * PCI base address register values for the given PCI device.
+ * Sets
*/
-Bool
-xf86CheckPciMemBase(pciVideoPtr pPci, memType base)
-{
- int i;
- /* XXX Doesn't handle 64-bit base addresses */
- for (i = 0; i < 6; i++)
- if (base == pPci->memBase[i])
- return TRUE;
- return FALSE;
-}
+ /* not yet used. FIXME: add support for sparse */
Bool
-xf86IsEntityPrimary(int entityIndex)
-{
- EntityPtr pEnt = xf86Entities[entityIndex];
-
- if (primaryBus.type != pEnt->busType) return FALSE;
-
- switch (pEnt->busType) {
- case BUS_PCI:
- return (pEnt->pciBusId.bus == primaryBus.id.pci.bus &&
- pEnt->pciBusId.device == primaryBus.id.pci.device &&
- pEnt->pciBusId.func == primaryBus.id.pci.func);
- case BUS_ISA:
- return ( primaryBus.type == BUS_ISA );
- default:
- return FALSE;
- }
-}
-
-static Bool
-fixPciResource(int prt, memType alignment, pciVideoPtr pvp, long type)
-{
- int res_n;
- memType *p_base;
- int *p_size;
- unsigned char p_type;
- resPtr AccTmp = NULL;
- resPtr *pAcc = &AccTmp;
- resPtr avoid = NULL;
- resList p_avoid = PciAvoid;
- resRange range;
- resPtr resBios = 0;
- resPtr w_tmp, w = NULL, w_2nd = NULL;
- PCITAG tag;
- PciBusPtr pbp = xf86PciBus, pbp1 = xf86PciBus;
- resPtr tmp;
-
- if (!pvp) return FALSE;
-
- type &= ResAccMask;
- if (!type) type = ResShared;
- if (prt < 6) {
- if (pvp->memBase[prt]) {
- type |= ResMem;
- res_n = prt;
- p_base = &(pvp->memBase[res_n]);
- p_size = &(pvp->size[res_n]);
- p_type = pvp->type[res_n];
- } else if (pvp->ioBase[prt]){
- type |= ResIo;
- res_n = prt;
- p_base = &(pvp->ioBase[res_n]);
- p_size = &(pvp->size[res_n]);
- p_type = pvp->type[res_n];
- } else return FALSE;
- } else if (prt == 6) {
- type |= ResMem;
- res_n = 0xff; /* special flag for bios rom */
- p_base = &(pvp->biosBase);
- p_size = &(pvp->biosSize);
- /* XXX This should also include the PCI_MAP_MEMORY_TYPE_MASK part */
- p_type = 0;
- RANGE(range,0,0xffffffff,ResExcMemBlock);
- resBios = xf86AddResToList(resBios,&range,-1);
- } else return FALSE;
-
- if (! *p_base) return FALSE;
-
- type |= ResBlock;
-
- /* setup avoid */
- avoid = addRangesToList(avoid,p_avoid,-1);
-
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if (type & ResMem) {
- if (((p_type & PCI_MAP_MEMORY_CACHABLE)
-#if 0 /*EE*/
- || (res_n == 0xff)/* bios should also be prefetchable */
-#endif
- )
- && pbp->pmem) {
- w = findIntersectOfLists(pbp->pmem,ResRange);
- if (pbp->mem) {
- w_2nd = findIntersectOfLists(pbp->mem,ResRange);
- }
- } else if (pbp->mem) {
- w = findIntersectOfLists(pbp->mem,ResRange);
- }
- } else if (pbp->io) {
- w = findIntersectOfLists(pbp->io,ResRange);
- }
-
- while (pbp1) {
- if (pbp1->primary == pvp->bus) {
- if (type & ResMem) {
- tmp = xf86DupResList(pbp1->pmem);
- avoid = xf86JoinResLists(avoid,tmp);
- tmp = xf86DupResList(pbp1->mem);
- avoid = xf86JoinResLists(avoid,tmp);
- } else {
- tmp = xf86DupResList(pbp1->io);
- avoid = xf86JoinResLists(avoid,tmp);
- }
- }
- pbp1 = pbp1->next;
- }
- break;
- }
- pbp = pbp->next;
- }
-
- if (!w)
- w = xf86DupResList(ResRange);
-
- if (resBios) {
- w_tmp = w;
- w = findIntersectOfLists(w,resBios);
- xf86FreeResList(w_tmp);
- xf86FreeResList(resBios);
- }
-
- if (!alignment)
- alignment = (1 << (*p_size)) - 1;
-
- /* Access list holds bios resources -- remove this one */
-#ifdef NOTYET
- AccTmp = xf86DupResList(Acc);
- while ((*pAcc)) {
- if ((((*pAcc)->res_type & (type & ~ResAccMask))
- == (type & ~ResAccMask))
- && ((*pAcc)->block_begin == (*p_base))
- && ((*pAcc)->block_end == (*p_base) + (1 << (*p_size)) - 1)) {
- resPtr acc_tmp = (*pAcc)->next;
- xfree((*pAcc));
- (*pAcc) = acc_tmp;
- break;
- } else
- pAcc = &((*pAcc)->next);
- }
- /* check if we really need to fix anything */
- RANGE(range, (*p_base), (*p_base) + (1 << (*p_size)) - 1, type);
- if (!ChkConflict(&range,avoid,SETUP)
- && !ChkConflict(&range,AccTmp,SETUP)
- && (((*p_base) & alignment) == (*p_base)->block_begin)
- && ((isSubsetOf(range,w)
- || (w_2nd && isSubsetOf(range,w_2n))))) {
-#ifdef DEBUG
- ErrorF("nothing to fix\n");
-#endif
- xf86FreeResList(AccTmp);
- xf86FreeResList(w);
- xf86FreeResList(w_2nd);
- xf86FreeResList(avoid);
- return TRUE;
- } else {
-#ifdef DEBUG
- ErrorF("removing old resource\n");
-#endif
- xf86FreeResList(Acc);
- Acc = AccTmp;
- }
-#else
- pAcc = &Acc;
- while ((*pAcc)) {
- if ((((*pAcc)->res_type & (type & ~ResAccMask))
- == (type & ~ResAccMask))
- && ((*pAcc)->block_begin == (*p_base))
- && ((*pAcc)->block_end == (*p_base) + (1 << (*p_size)) - 1)) {
-#ifdef DEBUG
- ErrorF("removing old resource\n");
-#endif
- (*pAcc) = (*pAcc)->next;
- break;
- } else
- pAcc = &((*pAcc)->next);
- }
-#endif
-
-#ifdef DEBUG
- ErrorF("base: 0x%lx alignment: 0x%lx size[bit]: 0x%x\n",
- (*p_base),alignment,(*p_size));
- xf86MsgVerb(X_INFO, 3, "window:\n");
- xf86PrintResList(3, w);
- if (w_2nd)
- xf86MsgVerb(X_INFO, 3, "2nd window:\n");
- xf86PrintResList(3, w_2nd);
- xf86ErrorFVerb(3,"avoid:\n");
- xf86PrintResList(3,avoid);
-#endif
- w_tmp = w;
- while (w) {
- if (type & w->res_type & ResPhysMask) {
- range = xf86GetBlock(type,alignment + 1, w->block_begin,
- w->block_end, alignment,avoid);
- if (range.type != ResEnd)
- break;
- }
- w = w->next;
- }
- xf86FreeResList(w_tmp);
- /* if unsuccessful and memory prefetchable try non-prefetchable */
- if (range.type == ResEnd && w_2nd) {
- w_tmp = w_2nd;
- while (w_2nd) {
- if (type & w_2nd->res_type & ResPhysMask) {
- range = xf86GetBlock(type,alignment + 1, w_2nd->block_begin,
- w_2nd->block_end,alignment,avoid);
- if (range.type != ResEnd)
- break;
- }
- w_2nd = w_2nd->next;
- }
- xf86FreeResList(w_tmp);
- }
- xf86FreeResList(avoid);
-
- if (range.type == ResEnd)
- return FALSE;
-
- (*p_size) = 0;
- while (alignment >> (*p_size))
- (*p_size)++;
- (*p_base) = range.rBegin;
-
-#ifdef DEBUG
- ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n",
- res_n,(*p_base),(1 << (*p_size)),type | ResMem ? "Mem" : "Io");
-#endif
- tag = pciTag(pvp->bus,pvp->device,pvp->func);
-
- if (res_n != 0xff) /*XXX fix for 64 bit */
- pciWriteLong(tag,PCI_CMD_BASE_REG + res_n * sizeof(CARD32),
- (CARD32)(*p_base) | (CARD32)(p_type));
- else {
- CARD32 val = pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01;
- pciWriteLong(tag,PCI_CMD_BIOS_REG,(CARD32)(*p_base) | val);
- }
- /* fake BIOS allocated resource */
- range.type |= ResBios;
- Acc = xf86AddResToList(Acc, &range,-1);
-
- return TRUE;
-
-}
-
-Bool
-xf86FixPciResource(int entityIndex, int prt, memType alignment,
- long type)
-{
- pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
- return fixPciResource(prt, alignment, pvp, type);
-}
-
-resPtr
-xf86ReallocatePciResources(int entityIndex, resPtr pRes)
-{
- pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
- resPtr pBad = NULL,pResTmp;
- unsigned int prt = 0;
- int i;
-
- if (!pvp) return pRes;
-
- while (pRes) {
- switch (pRes->res_type & ResPhysMask) {
- case ResMem:
- if (pRes->block_begin == pvp->biosBase &&
- pRes->block_end == pvp->biosBase + (1 << (pvp->biosSize)) - 1)
- prt = 6;
- else for (i = 0 ; i < 6; i++)
- if (pRes->block_begin == pvp->memBase[i]
- && pRes->block_end
- == pvp->memBase[i] + (1 << (pvp->size[i])) - 1) {
- prt = i;
- break;
- }
- break;
- case ResIo:
- for (i = 0 ; i < 6; i++)
- if (pRes->block_begin == pvp->ioBase[i]
- && pRes->block_end
- == pvp->ioBase[i] + (1 << (pvp->size[i])) - 1) {
- prt = i;
- break;
- }
- break;
- }
-
- if (!prt) return pRes;
-
- pResTmp = pRes->next;
- if (! fixPciResource(prt, 0, pvp, pRes->res_type)) {
- pRes->next = pBad;
- pBad = pRes;
- } else
- xfree(pRes);
-
- pRes = pResTmp;
- }
- return pBad;
-}
-
-
-resPtr
-xf86SetOperatingState(resList list, int entityIndex, int mask)
-{
- resPtr acc;
- resPtr r_fail = NULL;
-
- while (list->type != ResEnd) {
- acc = Acc;
- while (acc) {
-#define MASK (ResPhysMask | ResExtMask)
- if (acc->entityIndex == entityIndex
- && acc->val.a == list->a && acc->val.b == list->b
- && (acc->val.type & MASK) == (list->type & MASK))
- break;
-#undef MASK
- acc = acc->next;
- }
- if (acc)
- acc->val.type = (acc->val.type & ~ResOprMask)
- | (mask & ResOprMask);
- else
- r_fail = xf86AddResToList(r_fail,list,entityIndex);
-
- list ++;
- }
-
- return r_fail;
-}
-
-memType
-getValidBIOSBase(PCITAG tag, int num)
-{
- pciVideoPtr pvp;
- PciBusPtr pbp, pbp1;
- memType start_mp = 0, start_m = 0;
- memType end_mp, end_m;
- resPtr tmp, avoid;
- resRange range;
- int n = 0;
-
- if (!xf86PciVideoInfo) return 0;
-
- while ((pvp = xf86PciVideoInfo[n++])) {
- if (pciTag(pvp->bus,pvp->device,pvp->func) == tag)
- break;
- }
- if (!pvp) return 0;
- avoid = NULL;
- end_m = PCI_MEMBASE_LENGTH_MAX;
- end_mp = PCI_MEMBASE_LENGTH_MAX;
- pbp = pbp1 = xf86PciBus;
- while (pbp) {
- if (pbp->secondary == pvp->bus) {
- if (pbp->pmem) {
- start_mp = pbp->pmem->block_begin;
- end_mp = MIN(end_mp,pbp->pmem->block_end);
- }
- if (pbp->mem) {
- start_m = pbp->mem->block_begin;
- end_m = MIN(end_m,pbp->mem->block_end);
- }
- }
- while (pbp1) {
- if (pbp1->primary == pvp->bus) {
- tmp = xf86DupResList(pbp1->pmem);
- avoid = xf86JoinResLists(avoid,tmp);
- tmp = xf86DupResList(pbp1->mem);
- avoid = xf86JoinResLists(avoid,tmp);
- tmp = xf86DupResList(pbp1->io);
- avoid = xf86JoinResLists(avoid,tmp);
- }
- pbp1 = pbp1->next;
- }
- pbp = pbp->next;
- }
-
- if (pvp->biosBase) { /* try biosBase first */
- RANGE(range, pvp->biosBase,
- pvp->biosBase + (1 << pvp->biosSize) - 1,
- ResExcMemBlock);
- if (((range.rBegin >= start_m && range.rEnd <= end_m) ||
- (range.rBegin >= start_mp && range.rEnd <= end_mp))
- && ! ChkConflict(&range,avoid,SETUP)) {
- xf86FreeResList(avoid);
- return pvp->biosBase;
- }
- }
-#if 0
- if (num >= 0 && num <= 5 && pvp->memBase[num]) {
- /* then try suggested memBase */
- RANGE(range, pvp->memBase[num],
- pvp->memBase[num] + (1 << pvp->biosSize) - 1,
- ResExcMemBlock); /* keep bios size ! */
- if (((range.rBegin >= start_m && range.rEnd <= end_m) ||
- (range.rBegin >= start_mp && range.rEnd <= end_mp))
- && ! ChkConflict(&range,avoid,SETUP)) {
- xf86FreeResList(avoid);
- return pvp->memBase[num];
- }
- }
-#endif
- range = xf86GetBlock(ResExcMemBlock, (1 << pvp->biosSize),start_m,end_m,
- (1 << pvp->biosSize) -1, avoid);
- xf86FreeResList(avoid);
- return range.rBase;
-}
-
-static resPtr
-addRangesToList(resPtr list, resRange *pRange, int entityIndex)
-{
- while(pRange && pRange->type != ResEnd) {
- list = xf86AddResToList(list,pRange,entityIndex);
- pRange++;
- }
- return list;
-}
-
-/*
- * not yet used. FIXME: add support for sparse
- */
-static Bool
isSubsetOf(resRange range, resPtr list)
{
while (list) {
@@ -4071,7 +2208,7 @@ isSubsetOf(resRange range, resPtr list)
return FALSE;
}
-static Bool
+Bool
isListSubsetOf(resPtr list, resPtr BaseList)
{
while (list) {
@@ -4082,7 +2219,7 @@ isListSubsetOf(resPtr list, resPtr BaseList)
return TRUE;
}
-static resPtr
+resPtr
findIntersect(resRange Range, resPtr list)
{
resRange range;
@@ -4098,13 +2235,13 @@ findIntersect(resRange Range, resPtr list)
range.rBegin = Range.rBegin;
else
range.rBegin = list->block_begin;
- if (range.rEnd <= list->block_end)
+ if (Range.rEnd <= list->block_end)
range.rEnd = Range.rEnd;
else
- range.rEnd = Range.rEnd;
+ range.rEnd = list->block_end;
if (range.rEnd > range.rBegin) {
range.type = Range.type;
- xf86AddResToList(new,&range,-1);
+ new = xf86AddResToList(new,&range,-1);
}
break;
}
@@ -4116,8 +2253,8 @@ findIntersect(resRange Range, resPtr list)
return new;
}
-static resPtr
-findIntersectOfLists(resPtr l1, resPtr l2)
+resPtr
+xf86FindIntersectOfLists(resPtr l1, resPtr l2)
{
resPtr ret = NULL;
@@ -4127,3 +2264,66 @@ findIntersectOfLists(resPtr l1, resPtr l2)
}
return ret;
}
+
+
+/*------------------------------------------------------------*/
+static void CheckGenericGA(void);
+
+/*
+ * xf86FindPrimaryDevice() - Find the display device which
+ * was active when the server was started.
+ */
+void
+xf86FindPrimaryDevice()
+{
+ /* if no VGA device is found check for primary PCI device */
+ if (primaryBus.type == BUS_NONE)
+ CheckGenericGA();
+}
+
+#include "vgaHW.h"
+#include "compiler.h"
+
+/*
+ * CheckGenericGA() - Check for presence of a VGA device.
+ */
+static void
+CheckGenericGA()
+{
+#if !defined(__sparc__) && !defined(__powerpc__) /* FIXME ?? */
+ CARD16 GenericIOBase = VGAHW_GET_IOBASE();
+ CARD8 CurrentValue, TestValue;
+
+ /* VGA CRTC registers are not used here, so don't bother unlocking them */
+
+ /* VGA has one more read/write attribute register than EGA */
+ (void) inb(GenericIOBase + 0x0AU); /* Reset flip-flop */
+ outb(0x3C0, 0x14 | 0x20);
+ CurrentValue = inb(0x3C1);
+ outb(0x3C0, CurrentValue ^ 0x0F);
+ outb(0x3C0, 0x14 | 0x20);
+ TestValue = inb(0x3C1);
+ outb(0x3C0, CurrentValue);
+
+ if ((CurrentValue ^ 0x0F) == TestValue) {
+ primaryBus.type = BUS_ISA;
+ }
+#endif
+}
+
+Bool
+xf86NoSharedMem(int screenIndex)
+{
+ int j;
+
+ if (screenIndex > xf86NumScreens)
+ return TRUE;
+
+ for (j = 0; j < xf86Screens[screenIndex]->numEntities; j++) {
+ if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp
+ & NEED_MEM_SHARED)
+ return FALSE;
+ }
+ return TRUE;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
index ec6678e03..f47ba47e6 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
@@ -1,5 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.h,v 1.9 1999/08/21 13:48:24 dawes Exp $ */
-
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.h,v 1.10 1999/12/03 19:17:22 eich Exp $ */
+#define DEBUG
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
*/
@@ -13,6 +13,8 @@
#ifndef _XF86_BUS_H
#define _XF86_BUS_H
+#include "xf86pciBus.h"
+
typedef struct racInfo {
xf86AccessPtr mem_new;
xf86AccessPtr io_new;
@@ -20,7 +22,6 @@ typedef struct racInfo {
xf86AccessPtr *old;
} AccessFuncRec, *AccessFuncPtr;
-#define PCITAG_SPECIAL pciTag(0xFF,0xFF,0xFF)
typedef struct {
DriverPtr driver;
@@ -55,39 +56,6 @@ typedef struct {
#define pciBusId bus.id.pci
#define isaBusId bus.id.isa
-typedef struct {
- CARD32 command;
- CARD32 base[6];
- CARD32 biosBase;
-} pciSave, *pciSavePtr;
-
-typedef void (*SetBitsProcPtr)(PCITAG, int, CARD32, CARD32);
-
-typedef struct {
- PCITAG tag;
- SetBitsProcPtr func;
-} pciArg;
-
-typedef struct pci_io {
- int busnum;
- int devnum;
- int funcnum;
- pciArg arg;
- xf86AccessRec ioAccess;
- xf86AccessRec io_memAccess;
- xf86AccessRec memAccess;
- pciSave save;
- pciSave restore;
- Bool ctrl;
-} pciAccRec, *pciAccPtr;
-
-typedef struct {
- CARD16 io;
- CARD32 mem;
- CARD32 pmem;
- CARD8 control;
-} pciBridgeSave, *pciBridgeSavePtr;
-
struct x_BusAccRec;
typedef void (*BusAccProcPtr)(struct x_BusAccRec *ptr);
@@ -101,10 +69,12 @@ typedef struct x_BusAccRec {
struct x_BusAccRec *primary; /* pointer to the bus connecting to this */
struct x_BusAccRec *next; /* this links the different buses together */
BusType type;
+ BusType busdep_type;
/* Bus-specific fields */
union {
struct {
int bus;
+ int primary_bus;
PCITAG acc;
pciBridgeSave save;
void (*func)(PCITAG,int,CARD32,CARD32);
@@ -112,10 +82,20 @@ typedef struct x_BusAccRec {
} busdep;
} BusAccRec, *BusAccPtr;
-static resPtr addRangesToList(resPtr list, resRange *pRange,int entityIndex);
-static Bool isSubsetOf(resRange range, resPtr list);
-static Bool isListSubsetOf(resPtr list, resPtr BaseList);
-static resPtr findIntersect(resRange Range, resPtr list);
-static resPtr findIntersectOfLists(resPtr l1, resPtr l2);
+extern EntityPtr *xf86Entities;
+extern int xf86NumEntities;
+extern xf86AccessRec AccessNULL;
+extern BusRec primaryBus;
+extern resPtr Acc;
+extern resPtr ResRange;
+extern BusAccPtr xf86BusAccInfo;
+
+int xf86AllocateEntity(void);
+BusType StringToBusType(const char* busID, const char **retID);
+memType ChkConflict(resRange *rgp, resPtr res, xf86State state);
+Bool isSubsetOf(resRange range, resPtr list);
+Bool isListSubsetOf(resPtr list, resPtr BaseList);
+resPtr findIntersect(resRange Range, resPtr list);
+void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment);
#endif /* _XF86_BUS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
index c49361ab5..e5950a72f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.191 1999/07/18 08:14:30 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.197 1999/12/13 23:52:56 robin Exp $ */
/*
- * Copyright 1991-1997 by The XFree86 Project, Inc.
+ * Copyright 1991-1999 by The XFree86 Project, Inc.
* Copyright 1997 by Metro Link, Inc.
*
* Loosely based on code bearing the following copyright:
@@ -507,7 +507,8 @@ typedef enum {
FLAG_DPMS_SUSPENDTIME,
FLAG_DPMS_OFFTIME,
FLAG_PIXMAP,
- FLAG_PC98
+ FLAG_PC98,
+ FLAG_ESTIMATE_SIZES_AGGRESSIVELY
} FlagValues;
static OptionInfoRec FlagOptions[] = {
@@ -549,6 +550,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE },
{ FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
{0}, FALSE },
+ { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER,
+ {0}, FALSE },
{ FLAG_PC98, "PC98", OPTV_BOOLEAN,
{0}, FALSE },
{ -1, NULL, OPTV_NONE,
@@ -556,7 +559,7 @@ static OptionInfoRec FlagOptions[] = {
};
static Bool
-detectPC98()
+detectPC98(void)
{
#ifdef SUPPORT_PC98
unsigned char buf[2];
@@ -647,6 +650,11 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.pciFlags = PCIForceConfig2;
i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i);
+ if (i >= 0)
+ xf86EstimateSizesAggressively = i;
+
+ i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
if (i >= 0)
ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
@@ -707,475 +715,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
return TRUE;
}
-#ifndef NEW_INPUT
-static Bool
-configKeyboard(XF86ConfKeyboardPtr keybconf)
-{
-#ifdef XKB
- MessageType from = X_DEFAULT;
-#endif
-
- /* Initialize defaults */
- xf86Info.xleds = 0L;
- xf86Info.kbdDelay = 500;
- xf86Info.kbdRate = 30;
- xf86Info.kbdProc = NULL;
- xf86Info.vtinit = NULL;
- xf86Info.vtSysreq = VT_SYSREQ_DEFAULT;
-#if defined(SVR4) && defined(i386)
- xf86Info.panix106 = FALSE;
-#endif
-#ifdef XKB
- if (!xf86IsPc98()) {
- xf86Info.xkbrules = "xfree86";
- xf86Info.xkbmodel = "pc101";
- xf86Info.xkblayout = "us";
- xf86Info.xkbvariant = NULL;
- xf86Info.xkboptions = NULL;
- } else {
- xf86Info.xkbrules = "xfree86";
- xf86Info.xkbmodel = "pc98";
- xf86Info.xkblayout = "nec/jp";
- xf86Info.xkbvariant = NULL;
- xf86Info.xkboptions = NULL;
- }
- xf86Info.xkbcomponents_specified = FALSE;
- /* Should discourage the use of these. */
- xf86Info.xkbkeymap = NULL;
- xf86Info.xkbtypes = NULL;
- xf86Info.xkbcompat = NULL;
- xf86Info.xkbkeycodes = NULL;
- xf86Info.xkbsymbols = NULL;
- xf86Info.xkbgeometry = NULL;
-#endif
-
- if ( NameCompare(keybconf->keyb_protocol,"standard") == 0 ) {
- xf86Info.kbdProc = xf86KbdProc;
-#ifdef AMOEBA
- xf86Info.kbdEvents = NULL;
-#else
- xf86Info.kbdEvents = xf86KbdEvents;
-#endif
- } else if ( NameCompare(keybconf->keyb_protocol,"xqueue") == 0 ) {
-#ifdef XQUEUE
- xf86Info.kbdProc = xf86XqueKbdProc;
- xf86Info.kbdEvents = xf86XqueEvents;
-#ifndef NEW_INPUT
- xf86Info.mouseDev->xqueSema = 0;
-#endif
- xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
-#endif
- } else {
- xf86ConfigError("\"%s\" is not a valid keyboard protocol name",
- keybconf->keyb_protocol);
- return 0;
- }
-
- if ( keybconf->keyb_kbdDelay > 0 ) {
- xf86Info.kbdDelay = keybconf->keyb_kbdDelay;
- }
-
- if ( keybconf->keyb_kbdRate > 0 ) {
- xf86Info.kbdRate = keybconf->keyb_kbdRate;
- }
-
- if ( keybconf->keyb_xleds ) {
- xf86Info.xleds = keybconf->keyb_xleds;
- }
-
-#ifdef XKB
- if ( keybconf->keyb_xkbDisable ) {
- noXkbExtension = TRUE;
- from = X_CONFIG;
- xf86Msg(X_CONFIG, "XKB: disabled\n");
- } else if (noXkbExtension)
- from = X_CMDLINE;
- if (noXkbExtension)
- xf86Msg(from, "XKB: disabled\n");
-
- if (!noXkbExtension && !XkbInitialMap) {
- if ( keybconf->keyb_xkbkeymap ) {
- xf86Info.xkbkeymap = keybconf->keyb_xkbkeymap;
- xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" "
- "(overrides other XKB settings)\n", xf86Info.xkbkeymap);
- } else {
- if ( keybconf->keyb_xkbcompat ) {
- xf86Info.xkbcompat = keybconf->keyb_xkbcompat;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", xf86Info.xkbcompat);
- }
-
- if ( keybconf->keyb_xkbtypes ) {
- xf86Info.xkbtypes = keybconf->keyb_xkbtypes;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", xf86Info.xkbtypes);
- }
-
- if ( keybconf->keyb_xkbkeycodes ) {
- xf86Info.xkbkeycodes = keybconf->keyb_xkbkeycodes;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", xf86Info.xkbkeycodes);
- }
-
- if ( keybconf->keyb_xkbgeometry ) {
- xf86Info.xkbgeometry = keybconf->keyb_xkbgeometry;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", xf86Info.xkbgeometry);
- }
-
- if ( keybconf->keyb_xkbsymbols ) {
- xf86Info.xkbsymbols = keybconf->keyb_xkbsymbols;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", xf86Info.xkbsymbols);
- }
-
- if ( keybconf->keyb_xkbrules ) {
- xf86Info.xkbrules = keybconf->keyb_xkbrules;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", xf86Info.xkbrules);
- }
-
- if ( keybconf->keyb_xkbmodel ) {
- xf86Info.xkbmodel = keybconf->keyb_xkbmodel;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", xf86Info.xkbmodel);
- }
-
- if ( keybconf->keyb_xkblayout ) {
- xf86Info.xkblayout = keybconf->keyb_xkblayout;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", xf86Info.xkblayout);
- }
-
- if ( keybconf->keyb_xkbvariant ) {
- xf86Info.xkbvariant = keybconf->keyb_xkbvariant;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", xf86Info.xkbvariant);
- }
-
- if ( keybconf->keyb_xkboptions ) {
- xf86Info.xkboptions = keybconf->keyb_xkboptions;
- xf86Info.xkbcomponents_specified = TRUE;
- xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", xf86Info.xkboptions);
- }
- }
- }
-#endif
-#if defined(SVR4) && defined(i386)
- if ( keybconf->keyb_panix106 ) {
- xf86Info.panix106 = TRUE;
- xf86Msg(X_CONFIG, "PANIX106: enabled\n");
- }
-#endif
-
- return TRUE;
-}
-
-static SymTabRec MouseTab[] = {
- { PROT_MS, "microsoft" },
- { PROT_MSC, "mousesystems" },
- { PROT_MM, "mmseries" },
- { PROT_LOGI, "logitech" },
- { PROT_BM, "busmouse" },
- { PROT_LOGIMAN, "mouseman" },
- { PROT_PS2, "ps/2" },
- { PROT_MMHIT, "mmhittab" },
- { PROT_GLIDEPOINT, "glidepoint" },
- { PROT_IMSERIAL, "intellimouse" },
- { PROT_THINKING, "thinkingmouse" },
- { PROT_IMPS2, "imps/2" },
- { PROT_THINKINGPS2, "thinkingmouseps/2" },
- { PROT_MMANPLUSPS2, "mousemanplusps/2" },
- { PROT_GLIDEPOINTPS2, "glidepointps/2" },
- { PROT_NETPS2, "netmouseps/2" },
- { PROT_NETSCROLLPS2, "netscrollps/2" },
- { PROT_SYSMOUSE, "sysmouse" },
- { PROT_WSMOUSE, "wsmouse" },
- { PROT_SUN, "sun" },
- { PROT_AUTO, "auto" },
- { PROT_ACECAD, "acecad" },
- { -1, "" },
-};
-
-#define ISSERIALPROT(m) \
- ((m) == PROT_MS || (m) == PROT_MSC || (m) == PROT_MM || \
- (m) == PROT_LOGI || (m) == PROT_LOGIMAN || (m) == PROT_MMHIT || \
- (m) == PROT_GLIDEPOINT || (m) == PROT_IMSERIAL || \
- (m) == PROT_THINKING || (m) == PROT_AUTO || (m) == PROT_ACECAD)
-
-/* XXXSTU The interface in xf86XInput.c also needs to change to match this.
- * This function is also used for the (*device_config)() function */
-
-static Bool
-configPointer(MouseDevPtr mouse_dev, XF86ConfPointerPtr pointerconf)
-{
- int mtoken = -1;
-
- /* Set defaults */
- mouse_dev->baudRate = 1200;
- mouse_dev->oldBaudRate = -1;
- mouse_dev->sampleRate = 0;
- mouse_dev->emulate3Buttons = FALSE;
- mouse_dev->emulate3Timeout = 50;
- mouse_dev->chordMiddle = FALSE;
- mouse_dev->mouseFlags = 0;
- mouse_dev->mseProc = NULL;
- mouse_dev->mseDevice = NULL;
- mouse_dev->mseType = -1;
- mouse_dev->mseModel = 0;
- mouse_dev->resolution = 0;
- mouse_dev->buttons = MSE_DFLTBUTTONS;
- mouse_dev->negativeZ = 0;
- mouse_dev->positiveZ = 0;
-
- if ( pointerconf->pntr_protocol ) {
-#if defined(USE_OSMOUSE) || defined(OSMOUSE_ONLY)
- if ( NameCompare(pointerconf->pntr_protocol,"osmouse") == 0 ) {
- xf86Msg(X_CONFIG, "OsMouse selected for mouse input\n");
- mouse_dev->mseProc = xf86OsMouseProc;
- mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86OsMouseEvents;
- }
-#endif
-#ifdef XQUEUE
- if ( NameCompare(pointerconf->pntr_protocol,"xqueue") == 0 ) {
- mouse_dev->mseProc = xf86XqueMseProc;
- mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86XqueEvents;
- mouse_dev->xqueSema = 0;
- xf86Msg(X_CONFIG, "Xqueue selected for mouse input\n");
- }
-#endif
-#ifndef OSMOUSE_ONLY
- if( !mouse_dev->mseProc ) {
- mtoken = xf86StringToToken(MouseTab, pointerconf->pntr_protocol);
-#ifdef AMOEBA
- mouse_dev->mseProc = xf86MseProc;
- mouse_dev->mseEvents = NULL;
-#else
- mouse_dev->mseProc = xf86MseProc;
- mouse_dev->mseEvents = xf86MseEvents;
-#endif
- if (mtoken == -1)
- {
- xf86ConfigError("Pointer Protocol \"%s\" not recognized",
- pointerconf->pntr_protocol);
- return FALSE;
- }
- mouse_dev->mseType = mtoken;
- if (!xf86MouseSupported(mouse_dev->mseType))
- {
- xf86ConfigError("Mouse type \"%s\"not supported by this OS",
- pointerconf->pntr_protocol);
- return FALSE;
- }
- }
-#endif /* !OSMOUSE_ONLY */
-
- if( !mouse_dev->mseProc ) {
- xf86ConfigError("Mouse type \"%s\" not supported by this OS",
- pointerconf->pntr_protocol);
- return FALSE;
- }
- } else {
- xf86ConfigError("No mouse protocol given\n");
- return FALSE;
- }
-
-#ifndef OSMOUSE_ONLY
-#ifdef MACH386
- mouse_dev->mseDevice = "/dev/mouse";
-#else
- if( pointerconf->pntr_device ) {
- mouse_dev->mseDevice = pointerconf->pntr_device;
- }
-#endif
-
- if( pointerconf->pntr_baudrate ) {
- if (mouse_dev->mseType == PROT_LOGIMAN) {
- /*
- * XXXX This should be extended to other mouse types -- most
- * support only 1200. Should also disallow baudrate for bus mice
- */
- /* Moan if illegal baud rate! [CHRIS-211092] */
- if ((pointerconf->pntr_baudrate != 1200)
- && (pointerconf->pntr_baudrate != 9600)) {
- xf86ConfigError("Only 1200 or 9600 Baud are supported by MouseMan");
- return FALSE;
- }
- }
- else {
- if (pointerconf->pntr_baudrate%1200 != 0
- || pointerconf->pntr_baudrate < 1200
- || pointerconf->pntr_baudrate > 9600) {
- xf86ConfigError("Baud rate must be one of 1200, 2400, 4800, or 9600");
- return FALSE;
- }
- }
- mouse_dev->baudRate = pointerconf->pntr_baudrate;
- }
-
- if( pointerconf->pntr_samplerate ) {
- if (mouse_dev->mseType == PROT_LOGIMAN) {
- /* XXXX Most mice don't allow this */
- /* Moan about illegal sample rate! [CHRIS-211092] */
- xf86ConfigError("Selection of sample rate is not supported by MouseMan");
- return FALSE;
- }
- mouse_dev->sampleRate = pointerconf->pntr_samplerate;
- }
-
- if (pointerconf->pntr_resolution) {
- if (pointerconf->pntr_resolution <= 0) {
- xf86ConfigError("Resolution must be a positive value");
- } else {
- mouse_dev->resolution = pointerconf->pntr_resolution;
- }
- }
-
-#endif /* !OSMOUSE_ONLY */
- if( pointerconf->pntr_emulate3Buttons ) {
- if( pointerconf->pntr_chordMiddle ) {
- xf86ConfigError("Can't use Emulate3Buttons with ChordMiddle");
- return FALSE;
- }
- mouse_dev->emulate3Buttons = pointerconf->pntr_emulate3Buttons;
- }
- if( pointerconf->pntr_emulate3Timeout ) {
- mouse_dev->emulate3Timeout = pointerconf->pntr_emulate3Timeout;
- }
-#ifndef OSMOUSE_ONLY
- if( pointerconf->pntr_chordMiddle ) {
- if (mouse_dev->mseType == PROT_MS ||
- mouse_dev->mseType == PROT_LOGIMAN) {
- if (mouse_dev->emulate3Buttons) {
- xf86ConfigError("Can't use ChordMiddle with Emulate3Buttons");
- return FALSE;
- }
- mouse_dev->chordMiddle = pointerconf->pntr_chordMiddle;
- }
- else {
- xf86ConfigError("ChordMiddle is only supported for "
- "Microsoft and Logiman");
- return 0;
- }
- }
- if( pointerconf->pntr_clearDtr ) {
-#ifdef CLEARDTR_SUPPORT
- if (mouse_dev->mseType == PROT_MSC)
- mouse_dev->mouseFlags |= MF_CLEAR_DTR;
- else
- xf86ConfigError("ClearDTR only supported for MouseSystems mouse");
-#else
- xf86ConfigError("ClearDTR not supported on this OS");
-#endif
- }
-
- if( pointerconf->pntr_clearRts ) {
-#ifdef CLEARDTR_SUPPORT
- if (mouse_dev->mseType == PROT_MSC)
- mouse_dev->mouseFlags |= MF_CLEAR_RTS;
- else
- xf86ConfigError("ClearRTS only supported for MouseSystems mouse");
-#else
- xf86ConfigError("ClearRTS not supported on this OS");
-#endif
- }
-
- if( pointerconf->pntr_alwaysCore ) {
-#ifdef XINPUT
- xf86AlwaysCore(mouse_dev->local, TRUE);
-#else
- xf86ConfigError("AlwaysCore not supported in this Server");
-#endif
- }
-#endif /* OSMOUSE_ONLY */
-
- if (pointerconf->pntr_buttons) {
- if (pointerconf->pntr_buttons <= 0
- || pointerconf->pntr_buttons > MSE_MAXBUTTONS) {
- xf86ConfigError("Number of buttons (1..12) expected");
- } else {
- mouse_dev->buttons = pointerconf->pntr_buttons;
- }
- }
-
- if (pointerconf->pntr_positiveZ) {
- switch (pointerconf->pntr_positiveZ) {
- case CONF_ZAXIS_MAPTOX:
- mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOX;
- break;
- case CONF_ZAXIS_MAPTOY:
- mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOY;
- break;
- default: /* number */
- if (pointerconf->pntr_negativeZ <= 0
- || pointerconf->pntr_negativeZ > MSE_MAXBUTTONS
- || pointerconf->pntr_positiveZ <= 0
- || pointerconf->pntr_positiveZ > MSE_MAXBUTTONS) {
- xf86ConfigError("Button number (1..12) expected");
- } else {
- mouse_dev->negativeZ = 1 << (pointerconf->pntr_negativeZ - 1);
- mouse_dev->positiveZ = 1 << (pointerconf->pntr_positiveZ - 1);
- if (pointerconf->pntr_negativeZ > mouse_dev->buttons)
- mouse_dev->buttons = pointerconf->pntr_negativeZ;
- if (pointerconf->pntr_positiveZ > mouse_dev->buttons)
- mouse_dev->buttons = pointerconf->pntr_positiveZ;
- }
- break;
- }
- }
-
- /*
- * If mseProc is set and mseType isn't, then using Xqueue or OSmouse.
- * Otherwise, a mouse device is required.
- */
- if (mouse_dev->mseType >= 0 && !mouse_dev->mseDevice) {
- xf86ConfigError("No mouse device given");
- }
-
- if (mouse_dev->mseType >= 0) {
- Bool formatFlag = FALSE;
- xf86Msg(X_CONFIG, "Mouse: type: %s, device: %s",
- pointerconf->pntr_protocol, mouse_dev->mseDevice);
- if (ISSERIALPROT(mouse_dev->mseType)) {
- formatFlag = TRUE;
- xf86ErrorF(", baudrate: %d", mouse_dev->baudRate);
- }
- if (mouse_dev->sampleRate) {
- xf86ErrorF("%ssamplerate: %d", formatFlag ? ",\n\t" : ", ",
- mouse_dev->sampleRate);
- formatFlag = !formatFlag;
- }
- if (mouse_dev->resolution) {
- xf86ErrorF("%sresolution: %d", formatFlag ? ",\n\t" : ", ",
- mouse_dev->resolution);
- if (formatFlag)
- formatFlag = FALSE;
- }
- if (mouse_dev->emulate3Buttons)
- xf86ErrorF("%s3 button emulation (timeout: %dms)",
- formatFlag ? ",\n\t" : ", ", mouse_dev->emulate3Timeout);
- if (mouse_dev->chordMiddle)
- xf86ErrorF("%sChorded middle button", formatFlag ? ",\n\t" : ", ");
- switch (mouse_dev->negativeZ) {
- case 0: /* none */
- break;
- case MSE_MAPTOX:
- xf86ErrorF("%szaxis mapping: X", formatFlag ? ",\n\t" : ", ");
- break;
- case MSE_MAPTOY:
- xf86ErrorF("%szaxis mapping: Y", formatFlag ? ",\n\t" : ", ");
- break;
- default: /* buttons */
- xf86ErrorF("%szaxis mapping: (-)%d (+)%d", formatFlag ? ",\n\t" : ", ",
- pointerconf->pntr_negativeZ, pointerconf->pntr_positiveZ);
- break;
- }
- xf86ErrorF("\n");
- }
- return TRUE;
-}
-#endif
-
/*
* XXX This function is temporary, and will be removed when the keyboard
* driver is converted into a regular input driver.
@@ -1201,7 +740,11 @@ configInputKbd(IDevPtr inputp)
#ifdef XKB
if (!xf86IsPc98()) {
xf86Info.xkbrules = "xfree86";
+#ifdef SOL8
+ xf86Info.xkbmodel = "pc101_sol8x86";
+#else
xf86Info.xkbmodel = "pc101";
+#endif
xf86Info.xkblayout = "us";
xf86Info.xkbvariant = NULL;
xf86Info.xkboptions = NULL;
@@ -1466,7 +1009,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
* which drivers and monitors are used in these screens
*/
static Bool
-configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
{
XF86ConfAdjacencyPtr adjp;
XF86ConfInactivePtr idp;
@@ -1478,6 +1022,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
screenLayoutPtr slp;
GDevPtr gdp;
IDevPtr indp;
+ int i = 0, j;
if (!servlayoutp)
return FALSE;
@@ -1488,7 +1033,13 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
* If there is a -layout command line option, use that one, otherwise
* pick the first one.
*/
- from = X_CONFIG;
+ from = X_DEFAULT;
+ if (xf86LayoutName != NULL)
+ from = X_CMDLINE;
+ else if (default_layout) {
+ xf86LayoutName = default_layout;
+ from = X_CONFIG;
+ }
if (xf86LayoutName != NULL) {
if ((l = xf86FindLayout(xf86LayoutName, conf_layout)) == NULL) {
xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
@@ -1496,7 +1047,6 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
return FALSE;
}
conf_layout = l;
- from = X_CMDLINE;
}
xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
adjp = conf_layout->lay_adjacency_lst;
@@ -1533,9 +1083,108 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
X_CONFIG))
return FALSE;
+ slp[count].x = adjp->adj_x;
+ slp[count].y = adjp->adj_y;
+ slp[count].refname = adjp->adj_refscreen;
+ switch (adjp->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ slp[count].where = PosObsolete;
+ slp[count].topname = adjp->adj_top_str;
+ slp[count].bottomname = adjp->adj_bottom_str;
+ slp[count].leftname = adjp->adj_left_str;
+ slp[count].rightname = adjp->adj_right_str;
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ slp[count].where = PosAbsolute;
+ break;
+ case CONF_ADJ_RIGHTOF:
+ slp[count].where = PosRightOf;
+ break;
+ case CONF_ADJ_LEFTOF:
+ slp[count].where = PosLeftOf;
+ break;
+ case CONF_ADJ_ABOVE:
+ slp[count].where = PosAbove;
+ break;
+ case CONF_ADJ_BELOW:
+ slp[count].where = PosBelow;
+ break;
+ case CONF_ADJ_RELATIVE:
+ slp[count].where = PosRelative;
+ break;
+ }
count++;
adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
}
+
+ /* XXX Need to tie down the upper left screen. */
+
+ /* Fill in the refscreen and top/bottom/left/right values */
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < count; j++) {
+ if (slp[i].refname &&
+ strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+ slp[i].refscreen = slp[j].screen;
+ }
+ if (slp[i].topname &&
+ strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+ slp[i].top = slp[j].screen;
+ }
+ if (slp[i].bottomname &&
+ strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+ slp[i].bottom = slp[j].screen;
+ }
+ if (slp[i].leftname &&
+ strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+ slp[i].left = slp[j].screen;
+ }
+ if (slp[i].rightname &&
+ strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+ slp[i].right = slp[j].screen;
+ }
+ }
+ }
+
+#define LAYOUT_DEBUG
+#ifdef LAYOUT_DEBUG
+ ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier);
+ for (i = 0; i < count; i++) {
+ ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id,
+ slp[i].screen->screennum);
+ switch (slp[i].where) {
+ case PosObsolete:
+ ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n",
+ slp[i].top, slp[i].bottom, slp[i].left, slp[i].right);
+ break;
+ case PosAbsolute:
+ if (slp[i].x == -1)
+ if (slp[i].screen->screennum == 0)
+ ErrorF("\tImplicitly left-most\n");
+ else
+ ErrorF("\tImplicitly right of screen %d\n",
+ slp[i].screen->screennum - 1);
+ else
+ ErrorF("\t%d %d\n", slp[i].x, slp[i].y);
+ break;
+ case PosRightOf:
+ ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosLeftOf:
+ ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosAbove:
+ ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosBelow:
+ ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosRelative:
+ ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y,
+ slp[i].refscreen->id);
+ break;
+ }
+ }
+#endif
/*
* Count the number of inactive devices.
*/
@@ -1588,10 +1237,19 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout)
servlayoutp->inactives = gdp;
servlayoutp->inputs = indp;
servlayoutp->options = conf_layout->lay_option_lst;
-#ifdef NEW_INPUT
+ from = X_DEFAULT;
+ if (!noPanoramiXExtension)
+ from = X_CMDLINE;
+ else if (xf86FindOption(conf_layout->lay_option_lst, "Xinerama")) {
+ noPanoramiXExtension =
+ !xf86SetBoolOption(conf_layout->lay_option_lst, "Xinerama", FALSE);
+ from = X_CONFIG;
+ }
+ if (!noPanoramiXExtension)
+ xf86Msg(from, "Xinerama: enabled\n");
+
if (!checkCoreInputDevices(servlayoutp, FALSE))
return FALSE;
-#endif
return TRUE;
}
@@ -1648,10 +1306,8 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
indp = xnfalloc(sizeof(IDevRec));
indp->identifier = NULL;
servlayoutp->inputs = indp;
-#ifdef NEW_INPUT
if (!checkCoreInputDevices(servlayoutp, TRUE))
return FALSE;
-#endif
return TRUE;
}
@@ -2157,17 +1813,6 @@ xf86HandleConfigFile(void)
/* Initialise a few things. */
-#ifndef NEW_INPUT
-#if defined(XINPUT)
- xf86Info.mouseLocal = mouse_assoc.device_allocate();
- xf86Info.mouseDev = (MouseDevPtr)
- ((LocalDevicePtr)xf86Info.mouseLocal)->private;
- xf86Info.mouseDev->mseProc = NULL;
-#else
- xf86Info.mouseDev = (MouseDevPtr)xnfcalloc(1, sizeof(MouseDevRec));
-#endif
-#endif
-
/* Show what the marker symbols mean */
xf86ErrorF("Markers: " X_PROBE_STRING " probed, "
X_CONFIG_STRING " from config file, "
@@ -2201,7 +1846,13 @@ xf86HandleConfigFile(void)
return FALSE;
}
} else {
- if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst)) {
+ char *dfltlayout = NULL;
+ pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+ dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ dfltlayout)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return FALSE;
}
@@ -2212,10 +1863,6 @@ xf86HandleConfigFile(void)
if (!configFiles(xf86configptr->conf_files) ||
!configServerFlags(xf86configptr->conf_flags,
xf86ConfigLayout.options)
-#ifndef NEW_INPUT
- || !configKeyboard(xf86configptr->conf_keyboard)
- || !configPointer(xf86Info.mouseDev,xf86configptr->conf_pointer)
-#endif
#ifdef XF86DRI
|| !configDRI(xf86configptr->conf_dri)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c b/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
index 36e9d3152..31683f90f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
@@ -1,26 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.18 1999/08/22 05:57:30 dawes Exp $ */
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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.
- *
- */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.23 1999/11/26 02:26:09 mvojkovi Exp $ */
/* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
#define NEED_EVENTS
@@ -30,11 +8,13 @@
#include "cursor.h"
#include "mipointer.h"
#include "scrnintstr.h"
+#include "globals.h"
#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86_OSproc.h"
#ifdef XINPUT
#include "XIproto.h"
@@ -45,8 +25,16 @@
#include "dgaproc.h"
#endif
+typedef struct _xf86EdgeRec {
+ short screen;
+ short start;
+ short end;
+ DDXPointRec offset;
+ struct _xf86EdgeRec *next;
+} xf86EdgeRec, *xf86EdgePtr;
+
typedef struct {
- short left, right, up, down;
+ xf86EdgePtr left, right, up, down;
} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
@@ -70,7 +58,8 @@ static miPointerScreenFuncRec xf86PointerScreenFuncs = {
};
static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
-static Bool haveScreenLayout;
+
+static Bool HardEdges;
/*
* xf86InitViewport --
@@ -83,16 +72,6 @@ void
xf86InitViewport(ScrnInfoPtr pScr)
{
- /* Set a default layout if none has been specified directly */
- if (!haveScreenLayout) {
- int left, right;
-
- left = pScr->scrnIndex ? pScr->scrnIndex - 1 : xf86NumScreens - 1;
- right = (pScr->scrnIndex + 1) % xf86NumScreens;
-
- xf86SetScreenLayout(pScr->scrnIndex, left, right, -1, -1);
- }
-
pScr->PointerMoved = xf86PointerMoved;
/*
@@ -256,6 +235,18 @@ xf86ZoomViewport (ScreenPtr pScreen, int zoom)
+static xf86EdgePtr
+FindEdge(xf86EdgePtr edge, int val)
+{
+ while(edge && (edge->end <= val))
+ edge = edge->next;
+
+ if(edge && (edge->start <= val))
+ return edge;
+
+ return NULL;
+}
+
/*
* xf86CursorOffScreen --
* Check whether it is necessary to switch to another screen
@@ -264,47 +255,86 @@ xf86ZoomViewport (ScreenPtr pScreen, int zoom)
static Bool
xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
{
- int newX, newY;
- int newScreen = -1;
- ScreenPtr oldScreen = *pScreen;
- xf86ScreenLayoutPtr layout = &(xf86ScreenLayout[(*pScreen)->myNum]);
+ xf86EdgePtr edge;
+ int tmp;
- /* This is a trivial case but it is not checked anywhere else. */
- if (screenInfo.numScreens == 1)
+ if(screenInfo.numScreens == 1)
return FALSE;
- newX = *x;
- newY = *y;
-
- /* Find the new screen number from the screen layout array. */
- if (*y < 0) {
- newScreen = layout->up;
- } else if (*y >= (*pScreen)->height) {
- newScreen = layout->down;
- } else if (*x < 0) {
- newScreen = layout->left;
- } else if (*x >= (*pScreen)->width) {
- newScreen = layout->right;
+ if(*x < 0) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- if (newScreen < 0 || newScreen >= screenInfo.numScreens)
- return FALSE;
+ if(*x >= (*pScreen)->width) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
+ edge = FindEdge(edge, tmp);
- /* Set pScreen, adjust x and y, set x and y. */
- *pScreen = screenInfo.screens[newScreen];
-
- if (*y < 0) {
- newY += (*pScreen)->height;
- } else if (*y >= oldScreen->height) {
- newY -= oldScreen->height;
- } else if (*x < 0) {
- newX += (*pScreen)->width;
- } else if (*x >= oldScreen->width) {
- newX -= oldScreen->width;
+ if(!edge) *x = (*pScreen)->width - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- *x = newX;
- *y = newY;
+ if(*y < 0) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*y >= (*pScreen)->height) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = (*pScreen)->height - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ (*pScreen) = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+
+#if 0
+ /* This presents problems for overlapping screens when
+ HardEdges is used. Have to think about the logic more */
+ if((*x < 0) || (*x >= (*pScreen)->width) ||
+ (*y < 0) || (*y >= (*pScreen)->height)) {
+ /* We may have crossed more than one screen */
+ xf86CursorOffScreen(pScreen, x, y);
+ }
+#endif
return TRUE;
}
@@ -338,30 +368,332 @@ xf86CrossScreen (ScreenPtr pScreen, Bool entering)
static void
xf86WarpCursor (ScreenPtr pScreen, int x, int y)
{
+ int sigstate;
+ sigstate = xf86BlockSIGIO ();
miPointerWarpCursor(pScreen,x,y);
xf86Info.currentScreen = pScreen;
+ xf86UnblockSIGIO (sigstate);
}
-void
-xf86SetScreenLayout(int num, int left, int right, int up, int down)
+
+void *
+xf86GetPointerScreenFuncs(void)
{
-#ifdef DEBUG
- ErrorF("xf86SetScreenLayout: %d %d %d %d %d\n", num, left,right,up,down);
-#endif
- if (num >= MAXSCREENS) {
- ErrorF("xf86SetScreenLayout: Screen number %d >= MAXSCREENS\n", num);
- return;
+ return (void *)&xf86PointerScreenFuncs;
+}
+
+
+static xf86EdgePtr
+AddEdge(
+ xf86EdgePtr edge,
+ short min,
+ short max,
+ short dx,
+ short dy,
+ short screen
+){
+ xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
+
+ while(1) {
+ while(pEdge && (min >= pEdge->end)) {
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+ }
+
+ if(!pEdge) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->end = max;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = NULL;
+
+ if(pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ break;
+ } else if (min < pEdge->start) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = pEdge;
+
+ if(pPrev) pPrev->next = pNew;
+ else edge = pNew;
+
+ if(max <= pEdge->start) {
+ pNew->end = max;
+ break;
+ } else {
+ pNew->end = pEdge->start;
+ min = pEdge->end;
+ }
+ } else
+ min = pEdge->end;
+
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+
+ if(max <= min) break;
+ }
+
+ return edge;
+}
+
+static void
+FillOutEdge(xf86EdgePtr pEdge, int limit)
+{
+ xf86EdgePtr pNext;
+ int diff;
+
+ if(pEdge->start > 0) pEdge->start = 0;
+
+ while((pNext = pEdge->next)) {
+ diff = pNext->start - pEdge->end;
+ if(diff > 0) {
+ pEdge->end += diff >> 1;
+ pNext->start -= diff - (diff >> 1);
+ }
+ pEdge = pNext;
}
- xf86ScreenLayout[num].left = left;
- xf86ScreenLayout[num].right = right;
- xf86ScreenLayout[num].up = up;
- xf86ScreenLayout[num].down = down;
+ if(pEdge->end < limit)
+ pEdge->end = limit;
}
-void *
-xf86GetPointerScreenFuncs(void)
+/*
+ * xf86InitOrigins() can deal with a maximum of 32 screens
+ * on 32 bit architectures, 64 on 64 bit architectures.
+ */
+
+void
+xf86InitOrigins(void)
{
- return (void *)&xf86PointerScreenFuncs;
+ unsigned long screensLeft, prevScreensLeft, mask;
+ screenLayoutPtr screen;
+ ScreenPtr pScreen;
+ int x1, x2, y1, y2, left, right, top, bottom;
+ int i, j, ref, minX, minY, min, max;
+ xf86ScreenLayoutPtr pLayout;
+ Bool OldStyleConfig = FALSE;
+
+ /* need to have this set up with a config file option */
+ HardEdges = FALSE;
+
+ bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+
+ screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
+
+ while(1) {
+ for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
+ if(!(mask & 1L)) continue;
+
+ screen = &xf86ConfigLayout.screens[i];
+
+ switch(screen->where) {
+ case PosObsolete:
+ OldStyleConfig = TRUE;
+ pLayout = &xf86ScreenLayout[i];
+ /* force edge lists */
+ if(screen->left) {
+ ref = screen->left->screennum;
+ pLayout->left = AddEdge(pLayout->left,
+ 0, xf86Screens[i]->pScreen->height,
+ xf86Screens[ref]->pScreen->width, 0, ref);
+ }
+ if(screen->right) {
+ ref = screen->right->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->right = AddEdge(pLayout->right,
+ 0, pScreen->height, -pScreen->width, 0, ref);
+ }
+ if(screen->top) {
+ ref = screen->top->screennum;
+ pLayout->up = AddEdge(pLayout->up,
+ 0, xf86Screens[i]->pScreen->width,
+ 0, xf86Screens[ref]->pScreen->height, ref);
+ }
+ if(screen->bottom) {
+ ref = screen->bottom->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->down = AddEdge(pLayout->down,
+ 0, pScreen->width, 0, -pScreen->height, ref);
+ }
+ /* we could also try to place it based on those
+ relative locations if we wanted to */
+ screen->x = screen->y = 0;
+ /* FALLTHROUGH */
+ case PosAbsolute:
+ dixScreenOrigins[i].x = screen->x;
+ dixScreenOrigins[i].y = screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRelative:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRightOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x + pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosLeftOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x - pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosBelow:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y + pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosAbove:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y - pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ default:
+ ErrorF("Illegal placement keyword in Layout!\n");
+ break;
+ }
+
+ }
+
+ if(!screensLeft) break;
+
+ if(screensLeft == prevScreensLeft) {
+ /* All the remaining screens are referencing each other.
+ Assign a value to one of them and go through again */
+ i = 0;
+ while(!((1 << i) & screensLeft)){ i++; }
+
+ ref = xf86ConfigLayout.screens[i].refscreen->screennum;
+ dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ screensLeft &= ~(1 << ref);
+ }
+
+ prevScreensLeft = screensLeft;
+ }
+
+ /* justify the topmost and leftmost to (0,0) */
+ minX = dixScreenOrigins[0].x;
+ minY = dixScreenOrigins[0].y;
+
+ for(i = 1; i < xf86NumScreens; i++) {
+ if(dixScreenOrigins[i].x < minX)
+ minX = dixScreenOrigins[i].x;
+ if(dixScreenOrigins[i].y < minY)
+ minY = dixScreenOrigins[i].y;
+ }
+
+ if (minX | minY) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ dixScreenOrigins[i].x -= minX;
+ dixScreenOrigins[i].y -= minY;
+ }
+ }
+
+
+ /* Create the edge lists */
+
+ if(!OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+
+ pScreen = xf86Screens[i]->pScreen;
+
+ left = dixScreenOrigins[i].x;
+ right = left + pScreen->width;
+ top = dixScreenOrigins[i].y;
+ bottom = top + pScreen->height;
+
+ for(j = 0; j < xf86NumScreens; j++) {
+ if(i == j) continue;
+
+ x1 = dixScreenOrigins[j].x;
+ x2 = x1 + xf86Screens[j]->pScreen->width;
+ y1 = dixScreenOrigins[j].y;
+ y2 = y1 + xf86Screens[j]->pScreen->height;
+
+ if((bottom > y1) && (top < y2)) {
+ min = y1 - top;
+ if(min < 0) min = 0;
+ max = pScreen->height - (bottom - y2);
+ if(max > pScreen->height) max = pScreen->height;
+
+ if(((left - 1) >= x1) && ((left - 1) < x2))
+ pLayout->left = AddEdge(pLayout->left, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((right >= x1) && (right < x2))
+ pLayout->right = AddEdge(pLayout->right, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+
+
+ if((left < x2) && (right > x1)) {
+ min = x1 - left;
+ if(min < 0) min = 0;
+ max = pScreen->width - (right - x2);
+ if(max > pScreen->width) max = pScreen->width;
+
+ if(((top - 1) >= y1) && ((top - 1) < y2))
+ pLayout->up = AddEdge(pLayout->up, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((bottom >= y1) && (bottom < y2))
+ pLayout->down = AddEdge(pLayout->down, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+ }
+ }
+ }
+
+ if(!HardEdges && !OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+ pScreen = xf86Screens[i]->pScreen;
+ if(pLayout->left)
+ FillOutEdge(pLayout->left, pScreen->height);
+ if(pLayout->right)
+ FillOutEdge(pLayout->right, pScreen->height);
+ if(pLayout->up)
+ FillOutEdge(pLayout->up, pScreen->width);
+ if(pLayout->down)
+ FillOutEdge(pLayout->down, pScreen->width);
+ }
+ }
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c b/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
index ce9c4cc04..944e02500 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
@@ -3,7 +3,7 @@
Written by Mark Vojkovich
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.24 1999/08/22 05:57:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.31 1999/12/31 15:14:48 robin Exp $ */
#include "xf86.h"
#include "xf86str.h"
@@ -20,6 +20,7 @@
#ifdef XKB
#include "XKBsrv.h"
#endif
+#include "xf86Xinput.h"
static unsigned long DGAGeneration = 0;
static int DGAScreenIndex = -1;
@@ -265,7 +266,7 @@ DGASetDGAMode(
pScreenPriv->savedColormap = NULL;
}
pScreenPriv->dgaColormap = NULL;
- (*pScreenPriv->funcs->SetMode)(pScreenPriv->pScrn, NULL);
+ (*pScreenPriv->funcs->SetMode)(pScrn, NULL);
(*pScrn->SaveRestoreImage)(index, RestoreImage);
FreeMarkedVisuals(pScreen);
@@ -284,18 +285,29 @@ DGASetDGAMode(
if(!(device = (DGADevicePtr)xalloc(sizeof(DGADeviceRec))))
return BadAlloc;
- if(!pScreenPriv->current && !(*pScrn->SaveRestoreImage)(index, SaveImage)){
- xfree(device);
- return BadAlloc;
+ if(!pScreenPriv->current) {
+ Bool oldVTSema = pScrn->vtSema;
+ Bool result;
+
+ pScrn->vtSema = FALSE; /* kludge until we rewrite VT switching */
+ result = (*pScrn->SaveRestoreImage)(index, SaveImage);
+ pScrn->vtSema = oldVTSema;
+
+ if(!result) {
+ xfree(device);
+ return BadAlloc;
+ }
}
- if(!(*pScreenPriv->funcs->SetMode)(pScreenPriv->pScrn, pMode)) {
+ if(!(*pScreenPriv->funcs->SetMode)(pScrn, pMode)) {
xfree(device);
if(!pScreenPriv->current)
(*pScrn->SaveRestoreImage)(index, FreeImage);
return BadAlloc;
}
+ pScrn->currentMode = pMode->mode;
+
if(!pScreenPriv->current && !pScreenPriv->input) {
/* if it's multihead we need to warp the cursor off of
our screen so it doesn't get trapped */
@@ -304,8 +316,13 @@ DGASetDGAMode(
pScrn->vtSema = FALSE;
if(pScreenPriv->current) {
- if(pScreenPriv->current->pPix)
- (*pScreen->DestroyPixmap)(pPix);
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+ if(oldPix) {
+ if(oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap)(oldPix);
+ }
xfree(pScreenPriv->current);
pScreenPriv->current = NULL;
}
@@ -392,7 +409,11 @@ DGAAvailable(int index)
{
if(DGAScreenIndex < 0)
return FALSE;
-
+
+ if (!xf86NoSharedMem(((ScrnInfoPtr)screenInfo.screens[index]->
+ devPrivates[xf86ScreenIndex].ptr)->scrnIndex))
+ return FALSE;
+
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
return TRUE;
@@ -434,8 +455,13 @@ DGAShutdown()
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current) {
- if(pScreenPriv->current->pPix)
- (*pScreen->DestroyPixmap)(pScreenPriv->current->pPix);
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+ if(oldPix) {
+ if(oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap)(oldPix);
+ }
xfree(pScreenPriv->current);
(*pScreenPriv->funcs->SetMode)(pScreenPriv->pScrn, NULL);
@@ -772,17 +798,11 @@ DGAVTSwitch(void)
/* We have the power to steal or modify events that are about to get queued */
-extern InputInfo inputInfo;
-
Bool
DGAStealKeyEvent(int index, xEvent *e)
{
DGAScreenPtr pScreenPriv;
- DeviceIntPtr keybd;
- KeyClassPtr keyc;
- int key, bit, i;
- BYTE *kptr;
- CARD8 modifiers, mask;
+ dgaEvent de;
if(DGAScreenIndex < 0) /* no DGA */
return FALSE;
@@ -792,92 +812,10 @@ DGAStealKeyEvent(int index, xEvent *e)
if(!pScreenPriv || !pScreenPriv->current) /* no direct mode */
return FALSE;
- keybd = (DeviceIntPtr)xf86Info.pKeyboard;
- keyc = keybd->key;
-
- e->u.keyButtonPointer.state = (keyc->state |
- inputInfo.pointer->button->state);
-
- key = e->u.u.detail;
- kptr = &keyc->down[key >> 3];
- bit = 1 << (key & 7);
- modifiers = keyc->modifierMap[key];
-
- if(e->u.u.type == KeyPress) {
- if(!(*kptr & bit)) {
- *kptr |= bit;
- keyc->prev_state = keyc->state;
- keyc->state |= modifiers;
-
- for(mask = 0x80, i = 0; mask; mask >>= 1, i++) {
- if(mask & modifiers)
- keyc->modifierKeyCount[i]++;
- }
- }
- } else { /* KeyRelease */
- if(!(*kptr & bit))
- return TRUE;
- *kptr &= ~bit;
- keyc->prev_state = keyc->state;
- for(mask = 0x80, i = 0; mask; mask >>= 1, i++) {
- if(mask & modifiers) {
- if(--keyc->modifierKeyCount[i] <= 0) {
- keyc->state &= ~mask;
- keyc->modifierKeyCount[i] = 0;
- }
- }
- }
- }
-
- if(pScreenPriv->client && !pScreenPriv->client->clientGone) {
- Bool GrabEvent = FALSE;
-
- switch(e->u.u.type) {
- case KeyPress:
- if(pScreenPriv->input & KeyPressMask)
- GrabEvent = TRUE;
- break;
- case KeyRelease:
- if(pScreenPriv->input & KeyReleaseMask)
- GrabEvent = TRUE;
- break;
- }
-
- if(GrabEvent){ /* steal this event */
- dgaEvent de;
-
- de.u.u.type = e->u.u.type + *XDGAEventBase;
- de.u.u.detail = key;
- de.u.u.sequenceNumber = pScreenPriv->client->sequence;
- de.u.event.time = e->u.keyButtonPointer.time;
- de.u.event.screen = index;
- de.u.event.state = e->u.keyButtonPointer.state;
-
- TryClientEvents(pScreenPriv->client, (xEvent*)&de, 1,
- NoEventMask, NoEventMask, NullGrab);
- }
- return TRUE;
- }
-
-
- /* Not sure how best to handle this stuff. It's only for
- DGA 1.0 compatibility. Hopefully, we can remove this
- some day */
-
- if(((DeviceIntPtr)(xf86Info.pKeyboard))->grab){
- /* these would be non-sense otherwise */
- e->u.keyButtonPointer.eventX = 0;
- e->u.keyButtonPointer.eventY = 0;
- e->u.keyButtonPointer.rootX = 0;
- e->u.keyButtonPointer.rootY = 0;
-
- keybd->public.processInputProc(e, keybd, 1);
- }
-
- /* Direct mode but the client doesn't want the events.
- We have to keep them from hitting the other windows.
- */
-
+ de.u.u.type = e->u.u.type + *XDGAEventBase;
+ de.u.u.detail = e->u.u.detail;
+ de.u.event.time = e->u.keyButtonPointer.time;
+ xf86eqEnqueue ((xEvent *) &de);
return TRUE;
}
@@ -886,7 +824,7 @@ Bool
DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
{
DGAScreenPtr pScreenPriv;
- ButtonClassPtr butc;
+ dgaEvent de;
if(DGAScreenIndex < 0) /* no DGA */
return FALSE;
@@ -895,107 +833,245 @@ DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
if(!pScreenPriv || !pScreenPriv->current) /* no direct mode */
return FALSE;
+
+ if (!dx && !dy)
+ de.u.u.type = e->u.u.type + *XDGAEventBase;
+ else
+ de.u.u.type = MotionNotify + *XDGAEventBase;
+ de.u.u.detail = e->u.u.detail;
+ de.u.event.time = e->u.keyButtonPointer.time;
+ de.u.event.dx = dx;
+ de.u.event.dy = dy;
+ xf86eqEnqueue ((xEvent *) &de);
+ return TRUE;
+}
- /* I hope this part is correct. Motion events are different
- in the sense that the mipointer code is relied on to fill
- out the rest of the event info. We steal the event before
- then so we need to fill that info out here */
-
- if(dx | dy) {
- e->u.u.type = MotionNotify;
- e->u.keyButtonPointer.time = GetTimeInMillis();
- }
+Bool
+DGAIsDgaEvent (xEvent *e)
+{
+ int coreEquiv;
+ if (DGAScreenIndex < 0)
+ return FALSE;
+ coreEquiv = e->u.u.type - *XDGAEventBase;
+ if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
+ return TRUE;
+ return FALSE;
+}
- butc = ((DeviceIntPtr)xf86Info.pMouse)->button;
+#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
+static Mask filters[] =
+{
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask, /* MotionNotify (initial state) */
+};
- e->u.keyButtonPointer.state = butc->state | (
-#ifdef XKB
- !noXkbExtension ? inputInfo.keyboard->key->xkbInfo->state.grab_mods :
-#endif
- inputInfo.keyboard->key->state);
+static void
+DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
+{
+ int key, bit;
+ register BYTE *kptr;
+ register int i;
+ register CARD8 modifiers;
+ register CARD16 mask;
+ int coreEquiv;
+ xEvent core;
+ KeyClassPtr keyc = keybd->key;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+
+ /*
+ * Fill in remaining event state
+ */
+ de->u.event.dx = 0;
+ de->u.event.dy = 0;
+ de->u.event.screen = pScreen->myNum;
+ de->u.event.state = keyc->state | (inputInfo.pointer)->button->state;
+
+ /*
+ * Keep the core state in sync by duplicating what
+ * CoreProcessKeyboardEvent does
+ */
+ key = de->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+ modifiers = keyc->modifierMap[key];
+ switch (coreEquiv)
+ {
+ case KeyPress:
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr |= bit;
+ keyc->prev_state = keyc->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers)
+ {
+ /* This key affects modifier "i" */
+ keyc->modifierKeyCount[i]++;
+ keyc->state |= mask;
+ modifiers &= ~mask;
+ }
+ }
+ break;
+ case KeyRelease:
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr &= ~bit;
+ keyc->prev_state = keyc->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers) {
+ /* This key affects modifier "i" */
+ if (--keyc->modifierKeyCount[i] <= 0) {
+ keyc->state &= ~mask;
+ keyc->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ break;
+ }
- if(e->u.u.type != MotionNotify) {
- ButtonClassPtr butc = ((DeviceIntPtr)xf86Info.pMouse)->button;
- int key = e->u.u.detail;
- BYTE *kptr = &butc->down[key >> 3];
- int bit = 1 << (key & 7);
+ /*
+ * Deliver the DGA event
+ */
+ if (pScreenPriv->client)
+ {
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ filters[coreEquiv], pScreenPriv->input, 0);
+ }
+ else
+ {
+ /* If the keyboard is actively grabbed, deliver a grabbed core event */
+ if (keybd->grab && !keybd->fromPassiveGrab)
+ {
+ core.u.u.type = coreEquiv;
+ core.u.u.detail = de->u.u.detail;
+ core.u.keyButtonPointer.time = de->u.event.time;
+ core.u.keyButtonPointer.eventX = de->u.event.dx;
+ core.u.keyButtonPointer.eventY = de->u.event.dy;
+ core.u.keyButtonPointer.rootX = de->u.event.dx;
+ core.u.keyButtonPointer.rootY = de->u.event.dy;
+ core.u.keyButtonPointer.state = de->u.event.state;
+ DeliverGrabbedEvent (&core, keybd, FALSE, 1);
+ }
+ }
+}
- if(e->u.u.type == ButtonPress) {
+static void
+DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
+{
+ ButtonClassPtr butc = mouse->button;
+ int coreEquiv;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ xEvent core;
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+ /*
+ * Fill in remaining event state
+ */
+ de->u.event.screen = pScreen->myNum;
+ de->u.event.state = butc->state | inputInfo.keyboard->key->state;
+ /*
+ * Keep the core state in sync by duplicating what
+ * CoreProcessPointerEvent does
+ */
+ if (coreEquiv != MotionNotify)
+ {
+ register int key;
+ register BYTE *kptr;
+ int bit;
+
+ key = de->u.u.detail;
+ kptr = &butc->down[key >> 3];
+ bit = 1 << (key & 7);
+ switch (coreEquiv)
+ {
+ case ButtonPress:
+ mouse->valuator->motionHintWindow = NullWindow;
butc->buttonsDown++;
butc->motionMask = ButtonMotionMask;
*kptr |= bit;
- if (!e->u.u.detail)
- return TRUE;
- if (e->u.u.detail <= 5)
- butc->state |= (Button1Mask >> 1) << e->u.u.detail;
- } else { /* ButtonRelease */
+ if (key <= 5)
+ butc->state |= (Button1Mask >> 1) << key;
+ break;
+ case ButtonRelease:
+ mouse->valuator->motionHintWindow = NullWindow;
if (!--butc->buttonsDown)
butc->motionMask = 0;
*kptr &= ~bit;
- if (!e->u.u.detail)
- return TRUE;
- if (e->u.u.detail <= 5)
- butc->state &= ~((Button1Mask >> 1) << e->u.u.detail);
+ if (key == 0)
+ return;
+ if (key <= 5)
+ butc->state &= ~((Button1Mask >> 1) << key);
+ break;
}
- }
-
- if(pScreenPriv->client && !pScreenPriv->client->clientGone) {
- Bool GrabEvent = FALSE;
-
- switch(e->u.u.type) {
- case MotionNotify:
- if(pScreenPriv->input & PointerMotionMask)
- GrabEvent = TRUE;
- break;
- case ButtonPress:
- if(pScreenPriv->input & ButtonPressMask)
- GrabEvent = TRUE;
- break;
- case ButtonRelease:
- if(pScreenPriv->input & ButtonReleaseMask)
- GrabEvent = TRUE;
- break;
- }
-
- if(GrabEvent){ /* steal this event */
- dgaEvent de;
-
- de.u.u.type = e->u.u.type + *XDGAEventBase;
- de.u.u.detail = e->u.u.detail;
- de.u.u.sequenceNumber = pScreenPriv->client->sequence;
- de.u.event.dx = dx;
- de.u.event.dy = dy;
- de.u.event.time = e->u.keyButtonPointer.time;
- de.u.event.screen = index;
- de.u.event.state = e->u.keyButtonPointer.state;
-
- TryClientEvents(pScreenPriv->client, (xEvent*)&de, 1,
- NoEventMask, NoEventMask, NullGrab);
+ }
+ /*
+ * Deliver the DGA event
+ */
+ if (pScreenPriv->client)
+ {
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ filters[coreEquiv], pScreenPriv->input, 0);
+ }
+ else
+ {
+ /* If the pointer is actively grabbed, deliver a grabbed core event */
+ if (mouse->grab && !mouse->fromPassiveGrab)
+ {
+ core.u.u.type = coreEquiv;
+ core.u.u.detail = de->u.u.detail;
+ core.u.keyButtonPointer.time = de->u.event.time;
+ core.u.keyButtonPointer.eventX = de->u.event.dx;
+ core.u.keyButtonPointer.eventY = de->u.event.dy;
+ core.u.keyButtonPointer.rootX = de->u.event.dx;
+ core.u.keyButtonPointer.rootY = de->u.event.dy;
+ core.u.keyButtonPointer.state = de->u.event.state;
+ DeliverGrabbedEvent (&core, mouse, FALSE, 1);
}
- return TRUE;
- }
-
-
- /* Not sure how best to handle this stuff. It's only for
- DGA 1.0 compatibility. Hopefully, we can remove this
- some day */
-
- if(((DeviceIntPtr)(xf86Info.pMouse))->grab) {
- e->u.keyButtonPointer.eventX = dx;
- e->u.keyButtonPointer.eventY = dy;
- e->u.keyButtonPointer.rootX = dx;
- e->u.keyButtonPointer.rootY = dy;
- DeliverGrabbedEvent(e, (xf86Info.pMouse), FALSE, 1);
- }
+ }
+}
- /* Direct mode but the client doesn't want the events.
- We have to keep them from hitting the other windows.
- */
+Bool
+DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
+{
+ dgaEvent *de = (dgaEvent *) e;
+ DGAScreenPtr pScreenPriv;
+ int coreEquiv;
- return TRUE;
+ /* no DGA */
+ if (DGAScreenIndex < 0)
+ return FALSE;
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ /* DGA not initialized on this screen */
+ if (!pScreenPriv)
+ return FALSE;
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+ /* Not a DGA event */
+ if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
+ return FALSE;
+
+ switch (coreEquiv) {
+ case KeyPress:
+ case KeyRelease:
+ DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+ break;
+ default:
+ DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+ break;
+ }
+ return TRUE;
}
-
Bool
DGAOpenFramebuffer(
int index,
@@ -1044,7 +1120,8 @@ DGAGetOldDGAMode(int index)
if((mode->viewportWidth == w) && (mode->viewportHeight == h) &&
(mode->bytesPerScanline == p) &&
- (mode->bitsPerPixel == pScrn->bitsPerPixel)) {
+ (mode->bitsPerPixel == pScrn->bitsPerPixel) &&
+ (mode->depth == pScrn->depth)) {
return mode->num;
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c b/xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c
index b0e8a84c8..9d8dbf250 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c,v 1.2 1999/03/29 12:55:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DefModes.c,v 1.4 1999/11/18 16:52:06 tsi Exp $ */
/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at
* modeline2c.pl */
@@ -17,77 +17,77 @@
#include "globals.h"
-#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DEFAULT
-#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,0,0
+#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DEFAULT
+#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
DisplayModeRec xf86DefaultModes [] = {
/* 640x350 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x350"),31500, 640,672,736,832,0, 350,382,385,445,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x350"),31500, 640,672,736,832,0, 350,382,385,445,0, V_PHSYNC | V_NVSYNC, MODESUFFIX},
/* 640x400 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x400"),31500, 640,672,736,832,0, 400,401,404,445,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x400"),31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 720x400 @ 85Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("720x400"),35500, 720,756,828,936,0, 400,401,404,446,0, 0, MODESUFFIX},
+ {MODEPREFIX("720x400"),35500, 720,756,828,936,0, 400,401,404,446,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */
- {MODEPREFIX("640x480"),25200, 640,656,752,800,0, 480,490,492,525,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x480"),25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("640x480"),31500, 640,664,704,832,0, 480,489,491,520,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x480"),31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */
- {MODEPREFIX("640x480"),31500, 640,656,720,840,0, 480,481,484,500,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x480"),31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */
- {MODEPREFIX("640x480"),36000, 640,696,752,832,0, 480,481,484,509,0, 0, MODESUFFIX},
+ {MODEPREFIX("640x480"),36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */
- {MODEPREFIX("800x600"),36000, 800,824,896,1024,0, 600,601,603,625,0, 0, MODESUFFIX},
+ {MODEPREFIX("800x600"),36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */
- {MODEPREFIX("800x600"),40000, 800,840,968,1056,0, 600,601,605,628,0, 0, MODESUFFIX},
+ {MODEPREFIX("800x600"),40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */
- {MODEPREFIX("800x600"),50000, 800,856,976,1040,0, 600,637,643,666,0, 0, MODESUFFIX},
+ {MODEPREFIX("800x600"),50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */
- {MODEPREFIX("800x600"),49500, 800,816,896,1056,0, 600,601,604,625,0, 0, MODESUFFIX},
+ {MODEPREFIX("800x600"),49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */
- {MODEPREFIX("800x600"),56300, 800,832,896,1048,0, 600,601,604,631,0, 0, MODESUFFIX},
+ {MODEPREFIX("800x600"),56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */
- {MODEPREFIX("1024x768"),44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_INTERLACE, MODESUFFIX},
+ {MODEPREFIX("1024x768"),44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX},
/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */
- {MODEPREFIX("1024x768"),65000, 1024,1048,1184,1344,0, 768,771,777,806,0, 0, MODESUFFIX},
+ {MODEPREFIX("1024x768"),65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */
- {MODEPREFIX("1024x768"),75000, 1024,1048,1184,1328,0, 768,771,777,806,0, 0, MODESUFFIX},
+ {MODEPREFIX("1024x768"),75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */
- {MODEPREFIX("1024x768"),78800, 1024,1040,1136,1312,0, 768,769,772,800,0, 0, MODESUFFIX},
+ {MODEPREFIX("1024x768"),78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */
- {MODEPREFIX("1024x768"),94500, 1024,1072,1168,1376,0, 768,769,772,808,0, 0, MODESUFFIX},
+ {MODEPREFIX("1024x768"),94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */
- {MODEPREFIX("1152x864"),108000, 1152,1216,1344,1600,0, 864,865,868,900,0, 0, MODESUFFIX},
+ {MODEPREFIX("1152x864"),108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1280x960 @ 60Hz (VESA) hsync: 60.0kHz */
- {MODEPREFIX("1280x960"),108000, 1280,1376,1488,1800,0, 960,961,964,1000,0, 0, MODESUFFIX},
+ {MODEPREFIX("1280x960"),108000, 1280,1376,1488,1800,0, 960,961,964,1000,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1280x960 @ 85Hz (VESA) hsync: 85.9kHz */
- {MODEPREFIX("1280x960"),148500, 1280,1344,1504,1728,0, 960,961,964,1011,0, 0, MODESUFFIX},
+ {MODEPREFIX("1280x960"),148500, 1280,1344,1504,1728,0, 960,961,964,1011,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz */
- {MODEPREFIX("1280x1024"),108000, 1280,1328,1440,1688,0, 1024,1025,1028,1066,0, 0, MODESUFFIX},
+ {MODEPREFIX("1280x1024"),108000, 1280,1328,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz */
- {MODEPREFIX("1280x1024"),135000, 1280,1296,1440,1688,0, 1024,1025,1028,1066,0, 0, MODESUFFIX},
+ {MODEPREFIX("1280x1024"),135000, 1280,1296,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz */
- {MODEPREFIX("1280x1024"),157500, 1280,1344,1504,1728,0, 1024,1025,1028,1072,0, 0, MODESUFFIX},
+ {MODEPREFIX("1280x1024"),157500, 1280,1344,1504,1728,0, 1024,1025,1028,1072,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz */
- {MODEPREFIX("1600x1200"),162000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, 0, MODESUFFIX},
+ {MODEPREFIX("1600x1200"),162000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz */
- {MODEPREFIX("1600x1200"),175500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, 0, MODESUFFIX},
+ {MODEPREFIX("1600x1200"),175500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz */
- {MODEPREFIX("1600x1200"),189000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, 0, MODESUFFIX},
+ {MODEPREFIX("1600x1200"),189000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz */
- {MODEPREFIX("1600x1200"),202500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, 0, MODESUFFIX},
+ {MODEPREFIX("1600x1200"),202500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz */
- {MODEPREFIX("1600x1200"),229500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, 0, MODESUFFIX},
+ {MODEPREFIX("1600x1200"),229500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
/* 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz */
- {MODEPREFIX("1792x1344"),204800, 1792,1920,2120,2448,0, 1344,1345,1348,1394,0, 0, MODESUFFIX},
+ {MODEPREFIX("1792x1344"),204800, 1792,1920,2120,2448,0, 1344,1345,1348,1394,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz */
- {MODEPREFIX("1792x1344"),261000, 1792,1888,2104,2456,0, 1344,1345,1348,1417,0, 0, MODESUFFIX},
+ {MODEPREFIX("1792x1344"),261000, 1792,1888,2104,2456,0, 1344,1345,1348,1417,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz */
- {MODEPREFIX("1856x1392"),218300, 1856,1952,2176,2528,0, 1392,1393,1396,1439,0, 0, MODESUFFIX},
+ {MODEPREFIX("1856x1392"),218300, 1856,1952,2176,2528,0, 1392,1393,1396,1439,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz */
- {MODEPREFIX("1856x1392"),288000, 1856,1984,2208,2560,0, 1392,1393,1396,1500,0, 0, MODESUFFIX},
+ {MODEPREFIX("1856x1392"),288000, 1856,1984,2208,2560,0, 1392,1393,1396,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz */
- {MODEPREFIX("1920x1444"),234000, 1920,2048,2256,2600,0, 1440,1441,1444,1500,0, 0, MODESUFFIX},
+ {MODEPREFIX("1920x1440"),234000, 1920,2048,2256,2600,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
/* 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz */
- {MODEPREFIX("1920x1444"),297000, 1920,2064,2288,2640,0, 1440,1441,1444,1500,0, 0, MODESUFFIX},
- {MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,MODESUFFIX}
+ {MODEPREFIX("1920x1440"),297000, 1920,2064,2288,2640,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}
};
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c b/xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c
new file mode 100644
index 000000000..d3297f499
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c
@@ -0,0 +1,80 @@
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c,v 1.4 1999/10/26 15:58:12 tsi Exp $ */
+/*
+ * finish setting up the server
+ * Load the driver modules and call their probe functions.
+ *
+ * Copyright 1999 by The XFree86 Project, Inc.
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include "X.h"
+#include "Xmd.h"
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+
+void
+DoProbeArgs(int argc, char **argv, int i)
+{
+}
+
+void
+DoProbe()
+{
+ int i;
+ Bool probeResult;
+
+#ifdef XFree86LOADER
+ /* Find the list of video driver modules. */
+ char **list, **l;
+ const char *subdirs[] = {
+ "drivers",
+ NULL
+ };
+ const char *patlist[] = {
+ "(.*)_drv\\.so",
+ "(.*)_drv\\.o",
+ NULL
+ };
+
+ list = LoaderListDirs(subdirs, NULL);
+ if (list) {
+ ErrorF("List of video driver modules:\n");
+ for (l = list; *l; l++)
+ ErrorF("\t%s\n", *l);
+ } else {
+ ErrorF("No video driver modules found\n");
+ }
+
+ /* Load all the drivers that were found. */
+ xf86LoadModules(list, NULL);
+#endif /* XFree86LOADER */
+
+ /* Disable PCI devices */
+ xf86AccessInit();
+
+ /* Call all of the probe functions, reporting the results. */
+ for (i = 0; i < xf86NumDrivers; i++) {
+ probeResult = FALSE;
+ if (xf86DriverList[i]->Probe != NULL)
+ probeResult = xf86DriverList[i]->Probe(xf86DriverList[i],
+ PROBE_DETECT);
+ ErrorF("Probe in driver `%s' returns %s\n",
+ xf86DriverList[i]->driverName, BOOLTOSTRING(probeResult));
+ }
+
+#ifdef XFree86LOADER
+ LoaderFreeDirList(list);
+#endif /* XFree86LOADER */
+
+ OsCleanup();
+ AbortDDX();
+ fflush(stderr);
+ exit(0);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
index baecd9b5d..3f234554a 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.75 1999/06/27 09:20:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.83 1999/12/27 00:39:42 robin Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -60,6 +60,18 @@ extern Bool noXkbExtension;
#define XE_POINTER 1
#define XE_KEYBOARD 2
+#ifdef XINPUT
+#define __EqEnqueue(ev) xf86eqEnqueue(ev)
+#else
+#define __EqEnqueue(ev) mieqEnqueue(ev)
+#endif
+
+#define EqEnqueue(ev) { \
+ int __sigstate = xf86BlockSIGIO (); \
+ __EqEnqueue (ev); \
+ xf86UnblockSIGIO(__sigstate); \
+}
+
#ifdef XTESTEXT1
#define XTestSERVER_SIDE
@@ -69,45 +81,19 @@ extern short xtest_mousey;
extern int on_steal_input;
extern Bool XTestStealKeyData();
extern void XTestStealMotionData();
-
-#ifdef XINPUT
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
if (!on_steal_input || \
XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
xtest_mousex, xtest_mousey)) \
- xf86eqEnqueue((ev))
-#else
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- if (!on_steal_input || \
- XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
- xtest_mousex, xtest_mousey)) \
- mieqEnqueue((ev))
-#endif
-
-#define MOVEPOINTER(dx, dy, time) \
- if (on_steal_input) \
- XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \
- miPointerDeltaCursor (dx, dy, time)
-
+ EqEnqueue((ev))
#else /* ! XTESTEXT1 */
-#ifdef XINPUT
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
- xf86eqEnqueue((ev))
-#else
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- mieqEnqueue((ev))
-#endif
-#define MOVEPOINTER(dx, dy, time) \
- miPointerDeltaCursor (dx, dy, time)
+ EqEnqueue((ev))
#endif
@@ -153,114 +139,6 @@ typedef struct x_IHRec {
static IHPtr InputHandlers = NULL;
-#ifndef NEW_INPUT
-static CARD32 buttonTimer(OsTimerPtr timer, CARD32 now, pointer arg);
-
-/*
- * Lets create a simple finite-state machine:
- *
- * state[?][0]: action1
- * state[?][1]: action2
- * state[?][2]: next state
- *
- * action > 0: ButtonPress
- * action = 0: nothing
- * action < 0: ButtonRelease
- *
- * Why this stuff ??? Normally you cannot press both mousebuttons together, so
- * the mouse reports both pressed at the same time ...
- */
-
-static signed char stateTab[48][3] = {
-
-/* nothing pressed */
- { 0, 0, 0 },
- { 0, 0, 8 }, /* 1 right -> delayed right */
- { 0, 0, 0 }, /* 2 nothing */
- { 0, 0, 8 }, /* 3 right -> delayed right */
- { 0, 0, 16 }, /* 4 left -> delayed left */
- { 2, 0, 24 }, /* 5 left & right (middle press) -> middle pressed */
- { 0, 0, 16 }, /* 6 left -> delayed left */
- { 2, 0, 24 }, /* 7 left & right (middle press) -> middle pressed */
-
-/* delayed right */
- { 1, -1, 0 }, /* 8 nothing (right event) -> init */
- { 1, 0, 32 }, /* 9 right (right press) -> right pressed */
- { 1, -1, 0 }, /* 10 nothing (right event) -> init */
- { 1, 0, 32 }, /* 11 right (right press) -> right pressed */
- { 1, -1, 16 }, /* 12 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 13 left & right (middle press) -> middle pressed */
- { 1, -1, 16 }, /* 14 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 15 left & right (middle press) -> middle pressed */
-
-/* delayed left */
- { 3, -3, 0 }, /* 16 nothing (left event) -> init */
- { 3, -3, 8 }, /* 17 right (left event) -> delayed right */
- { 3, -3, 0 }, /* 18 nothing (left event) -> init */
- { 3, -3, 8 }, /* 19 right (left event) -> delayed right */
- { 3, 0, 40 }, /* 20 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 21 left & right (middle press) -> pressed middle */
- { 3, 0, 40 }, /* 22 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 23 left & right (middle press) -> pressed middle */
-
-/* pressed middle */
- { -2, 0, 0 }, /* 24 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 25 right (middle release) -> init */
- { -2, 0, 0 }, /* 26 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 27 right (middle release) -> init */
- { -2, 0, 0 }, /* 28 left (middle release) -> init */
- { 0, 0, 24 }, /* 29 left & right -> pressed middle */
- { -2, 0, 0 }, /* 30 left (middle release) -> init */
- { 0, 0, 24 }, /* 31 left & right -> pressed middle */
-
-/* pressed right */
- { -1, 0, 0 }, /* 32 nothing (right release) -> init */
- { 0, 0, 32 }, /* 33 right -> pressed right */
- { -1, 0, 0 }, /* 34 nothing (right release) -> init */
- { 0, 0, 32 }, /* 35 right -> pressed right */
- { -1, 0, 16 }, /* 36 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 37 left & right (r rel, m prs) -> middle pressed */
- { -1, 0, 16 }, /* 38 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 39 left & right (r rel, m prs) -> middle pressed */
-
-/* pressed left */
- { -3, 0, 0 }, /* 40 nothing (left release) -> init */
- { -3, 0, 8 }, /* 41 right (left release) -> delayed right */
- { -3, 0, 0 }, /* 42 nothing (left release) -> init */
- { -3, 0, 8 }, /* 43 right (left release) -> delayed right */
- { 0, 0, 40 }, /* 44 left -> left pressed */
- { -3, 2, 24 }, /* 45 left & right (l rel, mprs) -> middle pressed */
- { 0, 0, 40 }, /* 46 left -> left pressed */
- { -3, 2, 24 }, /* 47 left & right (l rel, mprs) -> middle pressed */
-};
-
-
-/*
- * Table to allow quick reversal of natural button mapping to correct mapping
- */
-
-/*
- * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
- * with a fourth button activated by tapping the PAD.
- * The 2nd line corresponds to 4th button on; the drv sends
- * the buttons in the following map (MSBit described first) :
- * 0 | 4th | 1st | 2nd | 3rd
- * And we remap them (MSBit described first) :
- * 0 | 4th | 3rd | 2nd | 1st
- */
-static char reverseMap[32] = { 0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15,
- 16, 20, 18, 22, 17, 21, 19, 23,
- 24, 28, 26, 30, 25, 29, 27, 31};
-
-
-static char hitachMap[16] = { 0, 2, 1, 3,
- 8, 10, 9, 11,
- 4, 6, 5, 7,
- 12, 14, 13, 15 };
-
-#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
-#endif
/*
* TimeSinceLastInputEvent --
@@ -417,12 +295,12 @@ ProcessInputEvents ()
extern u_char SpecialServerMap[];
#endif /* ASSUME_CUSTOM_KEYCODES */
-#if !defined(__EMX__)
+#if !defined(__EMX__) && !defined(SOL8)
void
xf86PostKbdEvent(unsigned key)
{
int scanCode = (key & 0x7f);
- int specialkey;
+ int specialkey = 0;
Bool down = (key & 0x80 ? FALSE : TRUE);
KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
Bool updateLeds = FALSE;
@@ -648,6 +526,28 @@ special:
}
break;
+ /* Under QNX4, we set the vtPending flag for VT switching and
+ * let the VT switch function do the rest...
+ * This is a little different from the other OS'es.
+ */
+#if defined(QNX4)
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (down){
+ xf86Info.vtRequestsPending =
+ specialkey - KEY_1 + 1;
+ return;
+ }
+ break;
+#endif
+
#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) || defined(SCO)
/*
* Under Linux, the raw keycodes are consumed before the kernel
@@ -990,208 +890,6 @@ special:
#endif /* !__EMX__ */
-#ifndef NEW_INPUT
-static CARD32
-buttonTimer(OsTimerPtr timer, CARD32 now, pointer arg)
-{
-#ifndef NEW_INPUT
- MouseDevPtr priv = MOUSE_DEV((DeviceIntPtr) arg);
-
- xf86PostMseEvent(((DeviceIntPtr) arg), priv->truebuttons, 0, 0);
-#endif
- return(0);
-}
-#endif
-
-
-/*
- * xf86PostMseEvent --
- * Translate the raw hardware MseEvent into an XEvent(s), and tell DIX
- * about it. Perform a 3Button emulation if required.
- */
-
-#ifndef NEW_INPUT
-void
-xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy)
-{
- static OsTimerPtr timer = NULL;
- MouseDevPtr private = MOUSE_DEV(device);
- int id, change;
- int truebuttons;
- xEvent mevent[2];
-
-#ifdef AMOEBA
- int pressed;
-
- pressed = ((buttons & BUTTON_PRESS) != 0);
- buttons &= ~BUTTON_PRESS;
-#endif
-
- xf86Info.lastEventTime = mevent->u.keyButtonPointer.time = GetTimeInMillis();
-
- truebuttons = buttons;
- if (private->mseType == PROT_MMHIT)
- buttons = reverseBits(hitachMap, buttons);
- else
- buttons = reverseBits(reverseMap, buttons);
-
- if (dx || dy) {
- /*
- * The accelaration stuff is now done in xf86Xinput.c when XInput
- * support is enabled.
- */
-#ifndef XINPUT
-
- /*
- * accelerate the baby now if sqrt(dx*dx + dy*dy) > threshold !
- * but do some simpler arithmetic here...
- */
- if ((abs(dx) + abs(dy)) >= private->threshold) {
- dx = (dx * private->num) / private->den;
- dy = (dy * private->num)/ private->den;
- }
-
- MOVEPOINTER(dx, dy, mevent->u.keyButtonPointer.time);
-#else
- xf86PostMotionEvent(device, 0, 0, 2, dx, dy);
-#endif
- }
-
- if (private->emulate3Buttons)
- {
-
- /*
- * Hack to operate the middle button even with Emulate3Buttons set.
- * Modifying the state table to keep track of the middle button state
- * would nearly double its size, so I'll stick with this fix. - TJW
- */
- if (private->mseType == PROT_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- if (change & 02)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- 2, (buttons & 02) ? ButtonPress : ButtonRelease,
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, 2, (buttons & 02), 0, 0);
-#endif
- }
-
- /*
- * emulate the third button by the other two
- */
- if ((id = stateTab[(buttons & 0x07) + private->emulateState][0]) != 0)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, abs(id), (id >= 0), 0, 0);
-#endif
- }
-
- if ((id = stateTab[(buttons & 0x07) + private->emulateState][1]) != 0)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, abs(id), (id >= 0), 0, 0);
-#endif
- }
-
- private->emulateState = stateTab[(buttons & 0x07) + private->emulateState][2];
- if (stateTab[(buttons & 0x07) + private->emulateState][0] ||
- stateTab[(buttons & 0x07) + private->emulateState][1])
- {
- private->truebuttons = truebuttons;
- timer = TimerSet(timer, 0, private->emulate3Timeout, buttonTimer,
- (pointer)device);
- }
- else
- {
- if (timer)
- {
- TimerFree(timer);
- timer = NULL;
- }
- }
- }
- else
- {
-#ifdef AMOEBA
- if (truebuttons != 0) {
-# ifndef XINPUT
- ENQUEUE(mevent,
- truebuttons, (pressed ? ButtonPress : ButtonRelease),
- XE_POINTER);
-# else
- xf86PostButtonEvent(device, 0, truebuttons, pressed, 0, 0);
-# endif
- }
-#else
- /*
- * real three button event
- * Note that xf86Info.lastButtons has the hardware button mapping which
- * is the reverse of the button mapping reported to the server.
- */
- if (private->mseType == PROT_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- while (change)
- {
- id = ffs(change);
- change &= ~(1 << (id-1));
-# ifndef XINPUT
- ENQUEUE(mevent,
- id, (buttons&(1<<(id-1)))? ButtonPress : ButtonRelease,
- XE_POINTER);
-# else
- xf86PostButtonEvent(device, 0, id, (buttons&(1<<(id-1))), 0, 0);
-# endif
- }
-#endif
- }
- private->lastButtons = truebuttons;
-}
-#endif
-
-
-
-#ifndef NEW_INPUT
-/*
- * xf86Block --
- * Os block handler.
- */
-
-/* ARGSUSED */
-void
-xf86Block(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
-{
-#if defined(XQUEUE)
- /*
- * On MP SVR4 boxes, a race condition exists because the XQUEUE does
- * not have anyway to lock it for exclusive access. This results in one
- * processor putting something on the queue at the same time the other
- * processor is taking it something off. The count of items in the queue
- * can get off by 1. This just goes and checks to see if an extra event
- * was put in the queue a during this period. The signal for this event
- * was ignored while processing the previous event.
- */
-
- if (xf86Screens[0]->vtSema)
- xf86XqueRequest();
-#endif
-}
-#endif
-
-
#ifndef AMOEBA
/*
@@ -1203,17 +901,14 @@ xf86Block(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
void
xf86Wakeup(pointer blockData, int err, pointer pReadmask)
{
-
-#ifndef __EMX__
+#if !defined(__EMX__) && !defined(__QNX__)
#ifdef __OSF__
fd_set kbdDevices;
fd_set mseDevices;
#endif /* __OSF__ */
fd_set* LastSelectMask = (fd_set*)pReadmask;
fd_set devicesWithInput;
-#ifdef NEW_INPUT
InputInfoPtr pInfo;
-#endif
if (err >= 0) {
@@ -1221,14 +916,14 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
#ifndef __OSF__
if (XFD_ANYSET(&devicesWithInput)) {
(xf86Info.kbdEvents)();
-#ifndef NEW_INPUT
- (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
if (pInfo->read_input && pInfo->fd >= 0 &&
(FD_ISSET(pInfo->fd, ((fd_set *)pReadmask)) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
/*
* Must break here because more than one device may share
* the same file descriptor.
@@ -1237,7 +932,6 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
}
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
}
#else /* __OSF__ */
/*
@@ -1259,12 +953,12 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
(xf86Info.mouseDev->mseEvents)(1);
#endif /* __OSF__ */
}
-#else /* __EMX__ */
+#else /* __EMX__ and __QNX__ */
- (xf86Info.kbdEvents)(); /* Under OS/2, always call */
+ (xf86Info.kbdEvents)(); /* Under OS/2 and QNX, always call */
(xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
-#endif /* __EMX__ */
+#endif /* __EMX__ and __QNX__ */
{
IHPtr ih;
@@ -1277,14 +971,6 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
}
}
-#ifndef NEW_INPUT
-#if defined(XQUEUE) && !defined(XQUEUE_ASYNC)
- /* This could be done more cleanly */
- if (xf86Info.mouseDev->xqueSema && xf86Info.mouseDev->xquePending)
- xf86XqueRequest();
-#endif
-#endif
-
if (xf86VTSwitchPending()) xf86VTSwitch();
if (xf86Info.inputPending) ProcessInputEvents();
@@ -1292,6 +978,45 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
#endif /* AMOEBA */
+/*
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
+ */
+static void
+xf86SigioReadInput(int fd,
+ void *closure)
+{
+ int sigstate = xf86BlockSIGIO();
+ InputInfoPtr pInfo = (InputInfoPtr) closure;
+
+ pInfo->read_input(pInfo);
+
+ xf86UnblockSIGIO(sigstate);
+}
+
+/*
+ * xf86AddEnabledDevice --
+ *
+ */
+void
+xf86AddEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
+
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
+}
/*
* xf86SigHandler --
@@ -1317,9 +1042,7 @@ static void
xf86VTSwitch()
{
int i;
-#ifdef NEW_INPUT
InputInfoPtr pInfo;
-#endif
IHPtr ih;
#ifdef DEBUG
@@ -1339,10 +1062,10 @@ xf86VTSwitch()
#ifdef DEBUG
ErrorF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING(xf86Exiting));
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
#endif
for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Exiting)
+ if (!(dispatchException & DE_TERMINATE))
if (xf86Screens[i]->SaveRestoreImage)
xf86Screens[i]->SaveRestoreImage(i, SaveImage);
}
@@ -1352,15 +1075,11 @@ xf86VTSwitch()
}
#ifndef __EMX__
DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- DisableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
DisableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86DisableInputHandler(ih);
@@ -1382,7 +1101,7 @@ xf86VTSwitch()
FatalError("EnterVT failed for screen %d\n", i);
}
xf86EnterServerState(OPERATING);
- if (!xf86Exiting) {
+ if (!(dispatchException & DE_TERMINATE)) {
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->SaveRestoreImage)
xf86Screens[i]->SaveRestoreImage(i, RestoreImage);
@@ -1392,15 +1111,11 @@ xf86VTSwitch()
#ifndef __EMX__
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
@@ -1442,15 +1157,11 @@ xf86VTSwitch()
#ifndef __EMX__
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c b/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
index eab83aa62..86b12f77e 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v 1.21 1999/07/11 10:27:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v 1.26 1999/11/02 16:16:27 tsi Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -10,6 +10,8 @@
#include "X.h"
#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Parser.h"
@@ -19,6 +21,7 @@
/* Globals that video drivers may access */
int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */
+int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */
ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
int xf86PixmapIndex = 0;
const unsigned char byte_reversed[256] =
@@ -93,9 +96,6 @@ xf86InfoRec xf86Info = {
#ifdef XINPUT
NULL, /* mouseLocal */
#endif
-#ifndef NEW_INPUT
- NULL, /* mouseDev */
-#endif
-1, /* lastEventTime */
FALSE, /* vtRequestsPending */
FALSE, /* inputPending */
@@ -146,10 +146,10 @@ MessageType xf86LogFileFrom = X_DEFAULT;
serverLayoutRec xf86ConfigLayout = {NULL, };
confDRIRec xf86ConfigDRI = {0, };
XF86ConfigPtr xf86configptr = NULL;
-Bool xf86Exiting = FALSE;
Bool xf86Resetting = FALSE;
Bool xf86Initialising = FALSE;
Bool xf86ProbeFailed = FALSE;
+Bool xf86DoProbe = FALSE;
#ifdef XFree86LOADER
DriverPtr *xf86DriverList = NULL;
int xf86NumDrivers = 0;
@@ -174,6 +174,7 @@ Bool xf86coFlag = FALSE;
Bool xf86sFlag = FALSE;
Bool xf86bsEnableFlag = FALSE;
Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
char *xf86LayoutName = NULL;
char *xf86ScreenName = NULL;
char *xf86PointerName = NULL;
@@ -198,6 +199,7 @@ Bool xf86VidModeAllowNonLocal = FALSE;
Bool xf86MiscModInDevDisabled = FALSE;
Bool xf86MiscModInDevAllowNonLocal = FALSE;
#endif
+PropertyPtr *xf86RegisteredPropertiesTable = NULL;
#ifdef DLOPEN_HACK
/*
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
index 6f37aa087..7bb5f5a42 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.56 1999/08/28 09:00:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.64 1999/12/03 19:17:23 eich Exp $ */
/*
* Copyright (c) 1997-1998 by The XFree86 Project, Inc.
@@ -15,6 +15,7 @@
#include "servermd.h"
#include "pixmapstr.h"
#include "windowstr.h"
+#include "propertyst.h"
#include "gcstruct.h"
#include "loaderProcs.h"
#include "xf86.h"
@@ -134,6 +135,15 @@ xf86AllocateScreen(DriverPtr drv, int flags)
*/
xf86Screens[i]->CurrentAccess = &xf86CurrentAccess;
xf86Screens[i]->resourceType = MEM_IO;
+
+ /* OOps -- What's this ? */
+ ErrorF("xf86AllocateScreen - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ if ( NULL != xf86Screens[i]->pScreen ) {
+ ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+ }
+
return xf86Screens[i];
}
@@ -785,8 +795,9 @@ Bool
xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
{
MessageType from = X_DEFAULT;
+#if 0
xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
-
+#endif
if (TEST_GAMMA(xf86Gamma)) {
from = X_CMDLINE;
scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
@@ -915,18 +926,63 @@ xf86SetBlackWhitePixels(ScreenPtr pScreen)
}
/*
- * create a new serial number for the window. Used in xf86SaveRestoreImage
+ * Create a new serial number for the window. Used in xf86SaveRestoreImage()
* to force revalidation of all the GC in the window tree of each screen.
*/
/*ARGSUSED*/
int
-xf86NewSerialNumber(WindowPtr p, pointer unused)
+xf86NewSerialNumber(WindowPtr pWin, pointer unused)
{
- p->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
return WT_WALKCHILDREN;
}
/*
+ * A second utility function for xf86SaveRestoreImage(). This one finds the
+ * pixmaps whose private data is to be exchanged and creates a region that
+ * covers the virtual screen.
+ */
+static void
+xf86GetPixmapsAndRegion(ScrnInfoPtr pScrnInfo, ScreenPtr pScreen,
+ PixmapPtr *pspix, PixmapPtr *ppix, RegionPtr pRegion)
+{
+ BoxRec pixBox;
+
+ *pspix = (*pScreen->GetScreenPixmap)(pScreen);
+ *ppix = pScrnInfo->ppix;
+
+ pixBox.x1 = pixBox.y1 = 0;
+ pixBox.x2 = pScreen->width;
+ pixBox.y2 = pScreen->height;
+ REGION_INIT(pScreen, pRegion, &pixBox, 1);
+}
+
+/*
+ * A third utility function for xf86SaveRestoreImage(). This one exchanges the
+ * private data of two pixmaps.
+ */
+static void
+xf86ExchangePixmapData(PixmapPtr pspix, PixmapPtr ppix)
+{
+#ifdef PIXPRIV
+ DevUnion *devPrivates = pspix->devPrivates;
+#endif
+ DevUnion devPrivate = pspix->devPrivate;
+ int devKind = pspix->devKind;
+
+#ifdef PIXPRIV
+ pspix->devPrivates = ppix->devPrivates;
+ ppix->devPrivates = devPrivates;
+#endif
+
+ pspix->devPrivate = ppix->devPrivate;
+ ppix->devPrivate = devPrivate;
+
+ pspix->devKind = ppix->devKind;
+ ppix->devKind = devKind;
+}
+
+/*
* Function to save/restore the video image and replace the root drawable
* with a pixmap.
*
@@ -934,119 +990,96 @@ xf86NewSerialNumber(WindowPtr p, pointer unused)
*
* This has been rewritten compared with the older code, with the intention
* of making it more general. It relies on some new functions added to
- * the ScreenRec. It has not been tested yet.
+ * the ScreenRec.
*
- * Here, we switch the pixmap data pointers, rather than the pixmaps themselves
- * to avoid having to find and change any references to the screen pixmap
- * such as GC's, window privates etc.
+ * Here, we exchange the pixmap private data, rather than the pixmaps
+ * themselves to avoid having to find and change any references to the screen
+ * pixmap such as GC's, window privates etc. This also means that this code
+ * does not need to know exactly how the pixmap pixels are accessed. Further,
+ * this exchange is >not< done through the screen's ModifyPixmapHeader()
+ * vector. This means the called frame buffer code layers can determine
+ * whether they are switched in or out by keeping track of the root pixmap's
+ * private data, and therefore don't need to access pScrnInfo->vtSema.
*/
-
Bool
xf86SaveRestoreImage(int scrnIndex, SaveRestoreFlags what)
{
- ScreenPtr pScreen;
- static unsigned char *devPrivates[MAXSCREENS];
- static int devKinds[MAXSCREENS];
- pointer devPrivate;
- Bool ret = FALSE;
- int width, height, devKind, bitsPerPixel;
- PixmapPtr pScreenPix, pPix;
-
- BoxRec pixBox;
+ ScrnInfoPtr pScrnInfo = xf86Screens[scrnIndex];
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ PixmapPtr pspix, ppix;
RegionRec pixReg;
- pScreen = xf86Screens[scrnIndex]->pScreen;
+ switch (what) {
+ case SaveImage:
+ /*
+ * Create a dummy pixmap to write to while VT is switched out, and
+ * copy the screen to that pixmap.
+ */
+ if (!pScrnInfo->ppix) {
+ pScrnInfo->ppix = (*pScreen->CreatePixmap)(pScreen,
+ pScrnInfo->displayWidth, pScreen->height, pScreen->rootDepth);
+ if (!pScrnInfo->ppix)
+ return FALSE;
+ }
- pixBox.x1 = pixBox.y1 = 0;
- pixBox.x2 = pScreen->width;
- pixBox.y2 = pScreen->height;
- (*pScreen->RegionInit)(&pixReg, &pixBox, 1);
+ /* Determine pixmaps to swap and virtual screen region */
+ xf86GetPixmapsAndRegion(pScrnInfo, pScreen, &pspix, &ppix, &pixReg);
- pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
+ /* Copy screen to temporary pixmap */
+ (*pScreen->BackingStoreFuncs.SaveAreas)(ppix, &pixReg, 0, 0,
+ WindowTable[scrnIndex]);
- switch (what) {
- case SaveImage:
- /*
- * Create a dummy pixmap to write to while VT is switched out, and
- * copy the screen to that pixmap.
- */
- width = pScreenPix->drawable.width;
- height = pScreenPix->drawable.height;
- bitsPerPixel = pScreenPix->drawable.bitsPerPixel;
+ /* Swap pixmap data */
+ xf86ExchangePixmapData(pspix, ppix);
- /* save the old data */
- devPrivates[scrnIndex] = pScreenPix->devPrivate.ptr;
- devKinds[scrnIndex] = pScreenPix->devKind;
-
- /* allocate new data */
- devKind = (((width * bitsPerPixel) + 31) >> 5) << 2; /* which macro ? */
- devPrivate = xalloc(devKind * height);
-
- if(devPrivate) {
- pPix = GetScratchPixmapHeader(pScreen, width, height,
- pScreen->rootDepth, bitsPerPixel, devKind, devPrivate);
-
- if(pPix) {
- (*pScreen->BackingStoreFuncs.SaveAreas)(pPix, &pixReg, 0, 0,
- WindowTable[scrnIndex]);
-
- FreeScratchPixmapHeader(pPix);
-
- /* modify the pixmap */
- pScreenPix->devPrivate.ptr = devPrivate;
- pScreenPix->devKind = devKind;
-
- WalkTree(xf86Screens[scrnIndex]->pScreen,xf86NewSerialNumber,0);
- ret = TRUE;
- } else
- xfree(devPrivate);
- }
+ /* Cause revalidation of all GC's */
+ WalkTree(pScreen, xf86NewSerialNumber, 0);
+
+ /* Turf region */
+ REGION_UNINIT(pScreen, &pixReg);
break;
+
case RestoreImage:
/*
* Reinstate the screen pixmap and copy the dummy pixmap back
* to the screen.
*/
-
if (!xf86Resetting) {
- width = pScreenPix->drawable.width;
- height = pScreenPix->drawable.height;
- bitsPerPixel = pScreenPix->drawable.bitsPerPixel;
- devPrivate = pScreenPix->devPrivate.ptr;
- devKind = pScreenPix->devKind;
-
- /* scratch pixmap for the saved screen */
- pPix = GetScratchPixmapHeader(pScreen, width, height,
- pScreen->rootDepth, bitsPerPixel, devKind, devPrivate);
-
- if(pPix) {
- /* restore the screen pixmap's correct values */
- pScreenPix->devPrivate.ptr = devPrivates[scrnIndex];
- pScreenPix->devKind = devKinds[scrnIndex];
-
- (*pScreen->BackingStoreFuncs.RestoreAreas)(pPix, &pixReg, 0, 0,
- WindowTable[scrnIndex]);
- xfree(devPrivate);
- FreeScratchPixmapHeader(pPix);
- /* restore old values */
- WalkTree(xf86Screens[scrnIndex]->pScreen,xf86NewSerialNumber,0);
- ret = TRUE;
- }
- break;
- }
+ if (!pScrnInfo->ppix)
+ return FALSE;
+
+ /* Determine pixmaps to swap and virtual screen region */
+ xf86GetPixmapsAndRegion(pScrnInfo, pScreen,
+ &pspix, &ppix, &pixReg);
+
+ /* Swap pixmap data */
+ xf86ExchangePixmapData(pspix, ppix);
+
+ /* Restore screen from temporary pixmap */
+ (*pScreen->BackingStoreFuncs.RestoreAreas)(ppix, &pixReg, 0, 0,
+ WindowTable[scrnIndex]);
+
+ /* Cause revalidation of all GC's */
+ WalkTree(pScreen, xf86NewSerialNumber, 0);
+
+ /* Turf region */
+ REGION_UNINIT(pScreen, &pixReg);
+ }
/* Fall through */
+
case FreeImage:
- if (pScreenPix->devPrivate.ptr)
- xfree(pScreenPix->devPrivate.ptr);
- ret = TRUE;
+ if (pScrnInfo->ppix) {
+ (*pScreen->DestroyPixmap)(pScrnInfo->ppix);
+ pScrnInfo->ppix = NULL;
+ }
break;
+
default:
ErrorF("xf86SaveRestoreImage: Invalid flag (%d)\n", what);
+ return FALSE;
}
- (*pScreen->RegionUninit)(&pixReg);
- return ret;
+ return TRUE;
}
-
/* Buffer to hold log data written before the log file is opened */
static char *saveBuffer = NULL;
static int size = 0, unused = 0, pos = 0;
@@ -1377,6 +1410,8 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist)
confScreenPtr screensecptr;
int i,j;
+if (xf86DoProbe) return 1;
+
/*
* This is a very important function that matches the device sections
* as they show up in the config file with the drivers that the server
@@ -1579,8 +1614,9 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
xfree(instances);
return 0;
}
+ if (xf86DoProbe) return 1;
#ifdef DEBUG
- ErrorF("%s instances found: %d\n", driverName, numClaimedInstances);
+ ErrorF("%s instances found: %d\n", driverName, allocatedInstances);
#endif
for (i = 0; i < allocatedInstances; i++) {
@@ -1629,6 +1665,9 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
instances[i].dev = dev;
}
}
+#ifdef DEBUG
+ ErrorF("%s instances found: %d\n", driverName, numClaimedInstances);
+#endif
/*
* Now check that a chipset or chipID override in the device section
* is valid. Chipset has precedence over chipID.
@@ -1753,7 +1792,11 @@ xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
int i;
int numFound = 0;
int *retEntities = NULL;
-
+
+ /* For now, bail here when xf86DoProbe is set. */
+ if (xf86DoProbe)
+ return 0;
+
for (i = 0; i < numDevs; i++) {
MessageType from = X_CONFIG;
GDevPtr dev = NULL;
@@ -2007,7 +2050,7 @@ xf86GetServerName()
Bool
xf86ServerIsExiting()
{
- return xf86Exiting;
+ return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
}
@@ -2137,6 +2180,9 @@ void xf86Break3(void)
{
}
+CARD32 xf86DummyVar1;
+CARD32 xf86DummyVar2;
+CARD32 xf86DummyVar3;
typedef enum {
OPTION_BACKING_STORE
@@ -2174,6 +2220,43 @@ xf86SetBackingStore(ScreenPtr pScreen)
}
+typedef enum {
+ OPTION_SILKEN_MOUSE
+} SMOpts;
+
+static OptionInfoRec SMOptions[] = {
+ { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xf86SetSilkenMouse (ScreenPtr pScreen)
+{
+ Bool useSM = TRUE;
+ MessageType from = X_DEFAULT;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, SMOptions);
+
+ /* check for commandline option here */
+ if (xf86silkenMouseDisableFlag) {
+ from = X_CMDLINE;
+ useSM = FALSE;
+ } else {
+ if (xf86GetOptValBool(SMOptions, OPTION_SILKEN_MOUSE, &useSM))
+ from = X_CONFIG;
+ }
+ /*
+ * XXX quick hack to report correctly for OSs that can't do SilkenMouse
+ * yet. Should handle this differently so that alternate async methods
+ * like Xqueue work correctly with this too.
+ */
+ pScrn->silkenMouse = useSM && xf86SIGIOSupported();
+ if (serverGeneration == 1)
+ xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
+ pScrn->silkenMouse ? "enabled" : "disabled");
+}
+
/* Wrote this function for the PM2 Xv driver, preliminary. */
pointer
@@ -2334,4 +2417,63 @@ xf86IsScreenPrimary(int scrnIndex)
return FALSE;
}
+int
+xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len, pointer value )
+{
+ PropertyPtr pNewProp, pRegProp;
+ int i;
+
+ErrorF("xf86RegisterRootWindowProperty(%d, %d, %d, %d, %d, %p)\n",
+ ScrnIndex, property, type, format, len, value);
+
+ if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
+ return(BadMatch);
+ }
+
+ if ( (pNewProp = (PropertyPtr)xalloc(sizeof(PropertyRec)))==NULL ) {
+ return(BadAlloc);
+ }
+
+ pNewProp->propertyName = property;
+ pNewProp->type = type;
+ pNewProp->format = format;
+ pNewProp->size = len;
+ pNewProp->data = value;
+ /* We will put this property at the end of the list so that
+ * the changes are made in the order they were requested.
+ */
+ pNewProp->next = NULL;
+
+ ErrorF("new property filled\n");
+
+ if (NULL==xf86RegisteredPropertiesTable) {
+ ErrorF("creating xf86RegisteredPropertiesTable[] size %d\n",
+ xf86NumScreens);
+ if ( NULL==(xf86RegisteredPropertiesTable=(PropertyPtr*)xnfcalloc(sizeof(PropertyPtr),xf86NumScreens) )) {
+ return(BadAlloc);
+ }
+ for (i=0; i<xf86NumScreens; i++) {
+ xf86RegisteredPropertiesTable[i] = NULL;
+ }
+ }
+
+ ErrorF("xf86RegisteredPropertiesTable %p\n",
+ xf86RegisteredPropertiesTable);
+ ErrorF("xf86RegisteredPropertiesTable[%d] %p\n",
+ ScrnIndex, xf86RegisteredPropertiesTable[ScrnIndex]);
+
+ if ( xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
+ xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
+ } else {
+ pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ while (pRegProp->next != NULL) {
+ ErrorF("- next %p\n", pRegProp);
+ pRegProp = pRegProp->next;
+ }
+ pRegProp->next = pNewProp;
+ }
+ErrorF("xf86RegisterRootWindowProperty succeeded\n");
+ return(Success);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
index 2e222b1fd..4d4331a71 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.134 1999/08/28 09:00:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.142 1999/11/19 13:54:21 hohndel Exp $ */
/*
* Copyright 1991-1999 by The XFree86 Project, Inc.
@@ -18,8 +18,10 @@ extern int atoi();
#include "X.h"
#include "Xmd.h"
#include "Xproto.h"
+#include "Xatom.h"
#include "input.h"
#include "servermd.h"
+#include "windowstr.h"
#include "scrnintstr.h"
#include "site.h"
@@ -93,7 +95,6 @@ static PixmapFormatRec formats[MAXFORMATS] = {
static int numFormats = 6;
static Bool formatsDone = FALSE;
-#ifdef NEW_INPUT
InputDriverRec xf86KEYBOARD = {
1,
"keyboard",
@@ -105,7 +106,85 @@ InputDriverRec xf86KEYBOARD = {
};
#undef MOUSE
extern InputDriverRec MOUSE;
-#endif
+
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PropertyPtr pRegProp, pOldRegProp;
+ CreateWindowProcPtr CreateWindow =
+ (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+
+ErrorF("xf86CreateRootWindow(%p)\n", pWin);
+
+ if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ xf86CreateRootWindow, pScreen->CreateWindow );
+ }
+
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL!=pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow)(pWin);
+ }
+
+ /* Now do our stuff */
+
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pRegProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pRegProp != NULL && err==Success;
+ pRegProp = pRegProp->next )
+ {
+ Atom oldNameAtom = pRegProp->propertyName;
+ char *nameString;
+ /* propertyName was created before the screen existed,
+ * so the atom does not belong to any screen;
+ * we need to create a new atom with the same name.
+ */
+ nameString = NameForAtom(oldNameAtom);
+ pRegProp->propertyName = MakeAtom(nameString, strlen(nameString), TRUE);
+ err = ChangeWindowProperty(pWin,
+ pRegProp->propertyName, pRegProp->type,
+ pRegProp->format, PropModeReplace,
+ pRegProp->size, pRegProp->data,
+ FALSE
+ );
+ }
+
+ /* Look at err */
+ ret &= (err==Success);
+
+ /* free memory */
+ pOldRegProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ while (pOldRegProp!=NULL) {
+ xfree(pOldRegProp->data);
+ pOldRegProp->data = NULL;
+
+ pRegProp = pOldRegProp->next;
+ xfree(pOldRegProp);
+ pOldRegProp = pRegProp;
+ }
+ xf86RegisteredPropertiesTable[pScreen->myNum] = NULL;
+ } else {
+ ErrorF("xf86CreateRootWindow unexpectedly called with non-root window %p (parent %p)\n",
+ pWin, pWin->parent);
+ ret = FALSE;
+ }
+ }
+
+ ErrorF("xf86CreateRootWindow() returns %d\n", ret);
+ return (ret);
+}
+
/*
* InitOutput --
@@ -137,7 +216,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
/* Do this early? */
if (generation != serverGeneration) {
xf86ScreenIndex = AllocateScreenPrivateIndex();
+ xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
xf86PixmapIndex = AllocatePixmapPrivateIndex();
+ xf86RegisteredPropertiesTable=NULL;
generation = serverGeneration;
}
@@ -166,9 +247,11 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
/* Read and parse the config file */
- if (!xf86HandleConfigFile()) {
- xf86Msg(X_ERROR, "Error from xf86HandleConfigFile()\n");
- return;
+ if (!xf86DoProbe) {
+ if (!xf86HandleConfigFile()) {
+ xf86Msg(X_ERROR, "Error from xf86HandleConfigFile()\n");
+ return;
+ }
}
/*
@@ -256,6 +339,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
/* Do a general bus probe. This will be a PCI probe for x86 platforms */
xf86BusProbe();
+ if (xf86DoProbe)
+ DoProbe();
+
/* Initialise the resource broker */
xf86ResourceBrokerInit();
@@ -268,11 +354,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
if ((modulelist = xf86DriverlistFromConfig()))
xf86LoadModules(modulelist, NULL);
-#ifdef NEW_INPUT
/* Setup the builtin input drivers */
xf86AddInputDriver(&xf86KEYBOARD, NULL, 0);
xf86AddInputDriver(&MOUSE, NULL, 0);
-#endif
/* Load all input driver modules specified in the config file. */
if ((modulelist = xf86InputDriverlistFromConfig()))
xf86LoadModules(modulelist, NULL);
@@ -328,7 +412,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
for (i = 0; i < xf86NumDrivers; i++) {
if (xf86DriverList[i]->Probe != NULL)
- xf86DriverList[i]->Probe(xf86DriverList[i], 0);
+ xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
else {
xf86MsgVerb(X_WARNING, 0,
"Driver `%s' has no Probe function (ignoring)\n",
@@ -421,17 +505,11 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
/*
- * Prune the set of monitor modes for each monitor that is referenced
- * by a screen section.
- *
- * XXX Probably best to do this here than elsewhere?
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
*/
for (i = 0; i < xf86NumScreens; i++) {
- xf86PruneMonitorModes(xf86Screens[i]->confScreen->monitor);
- }
-
- for (i = 0; i < xf86NumScreens; i++) {
xf86EnableAccess(xf86Screens[i]);
if (xf86Screens[i]->PreInit &&
xf86Screens[i]->PreInit(xf86Screens[i], 0))
@@ -686,7 +764,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
if (serverGeneration != 1) {
xf86Resetting = TRUE;
- xf86Exiting = FALSE;
#ifdef HAS_USL_VTS
/* All screens are in the same state, so just check the first */
if (!xf86Screens[0]->vtSema) {
@@ -727,6 +804,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
}
+ ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+
+ screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
+ = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
#ifdef NOT_USED
/*
* Here we have to let the driver getting access of the VT. Note that
@@ -738,16 +824,14 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
xf86PostScreenInit();
+ xf86InitOrigins();
+
xf86Resetting = FALSE;
xf86Initialising = FALSE;
#ifndef AMOEBA
-#ifdef NEW_INPUT
RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
NULL);
-#else
- RegisterBlockAndWakeupHandlers(xf86Block, xf86Wakeup, NULL);
-#endif
#endif
}
@@ -852,7 +936,6 @@ InitInput(argc, argv)
}
}
}
-#ifdef NEW_INPUT
if (!corePointer) {
xf86Msg(X_WARNING, "No core pointer registered\n");
/* XXX register a dummy core pointer */
@@ -863,50 +946,27 @@ InitInput(argc, argv)
/* XXX register a dummy core keyboard */
}
#endif
-#endif
}
-#ifdef NEW_INPUT
/* Initialise all input devices. */
pInfo = xf86InputDevs;
while (pInfo) {
xf86ActivateDevice(pInfo);
pInfo = pInfo->next;
}
-#endif
- xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
-#ifndef NEW_INPUT
- xf86Info.pMouse = AddInputDevice(xf86Info.mouseDev->mseProc, TRUE);
-#else
+ if (coreKeyboard) {
+ xf86Info.pKeyboard = coreKeyboard->dev;
+ }
+ else {
+ xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
+ }
if (corePointer)
xf86Info.pMouse = corePointer->dev;
-#endif
RegisterKeyboardDevice(xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- RegisterPointerDevice(xf86Info.pMouse);
-#endif
-
-#ifndef NEW_INPUT
-#ifdef XINPUT
- (xf86Info.pMouse)->public.devicePrivate = xf86Info.mouseLocal;
- ((LocalDevicePtr) xf86Info.mouseLocal)->dev = xf86Info.pMouse;
-#else
- (xf86Info.pMouse)->public.devicePrivate = (pointer) xf86Info.mouseDev;
-#endif
-#endif
-
-#ifndef NEW_INPUT
-#ifdef XINPUT
- InitExtInput();
-#endif
-#endif
miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
#ifdef XINPUT
-#ifndef NEW_INPUT
- xf86XinputFinalizeInit(xf86Info.pMouse);
-#endif
xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
#else
mieqInit (xf86Info.pKeyboard, xf86Info.pMouse);
@@ -980,20 +1040,9 @@ AbortDDX()
{
int i;
-#if 0
- if (xf86Exiting)
- return;
-#endif
-
- xf86Exiting = TRUE;
-
/*
* try to deinitialize all input devices
*/
-#ifndef NEW_INPUT
- if (xf86Info.pMouse)
- (xf86Info.mouseDev->mseProc)(xf86Info.pMouse, DEVICE_CLOSE);
-#endif
if (xf86Info.pKeyboard)
(xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
@@ -1354,10 +1403,23 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86KeyboardName = argv[i];
return 2;
}
+ if (!strcmp(argv[i], "-nosilk"))
+ {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
+ }
if (!strcmp(argv[i], "-scanpci"))
{
DoScanPci(argc, argv, i);
}
+ if (!strcmp(argv[i], "-probe"))
+ {
+ xf86DoProbe = TRUE;
+#if 0
+ DoProbe(argc, argv, i);
+#endif
+ return 1;
+ }
/* OS-specific processing */
return xf86ProcessArgument(argc, argv, i);
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
index 510c037a4..684ab6cd4 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.36 1999/05/09 06:06:20 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.38 1999/12/27 00:39:43 robin Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -396,155 +396,7 @@ xf86KbdProc (pKeyboard, what)
return (Success);
}
-#ifndef NEW_INPUT
-/*
- * xf86MseCtrl --
- * Alter the control parameters for the mouse. Note that all special
- * protocol values are handled by dix.
- */
-
-void
-xf86MseCtrl(pPointer, ctrl)
- DevicePtr pPointer;
- PtrCtrl *ctrl;
-{
- MouseDevPtr mouse = MOUSE_DEV((DeviceIntPtr) pPointer);
-
- mouse->num = ctrl->num;
- mouse->den = ctrl->den;
- mouse->threshold = ctrl->threshold;
-}
-
-/*
- * xf86MseProc --
- * Handle the initialization, etc. of a mouse
- */
-
-int
-xf86MseProc(pPointer, what)
- DeviceIntPtr pPointer;
- int what;
-{
- MouseDevPtr mouse = MOUSE_DEV(pPointer);
-
- mouse->device = pPointer;
-
- return xf86MseProcAux(pPointer, what, mouse, NULL,
- (PtrCtrlProcPtr)xf86MseCtrl);
-}
-
-int
-xf86MseProcAux(pPointer, what, mouse, fd, ctrl)
- DeviceIntPtr pPointer;
- int what;
- MouseDevPtr mouse;
- int *fd;
- PtrCtrlProcPtr ctrl;
-{
- unsigned char map[MSE_MAXBUTTONS + 1];
- int nbuttons;
- int mousefd;
-
- switch (what)
- {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- /*
- * [KAZU-241097] We don't know exactly how many buttons the
- * device has...
- */
- for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
- map[nbuttons + 1] = nbuttons + 1;
-
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- min(mouse->buttons, MSE_MAXBUTTONS),
- miPointerGetMotionEvents,
- ctrl,
- miPointerGetMotionBufferSize());
-#ifdef XINPUT
- InitValuatorAxisStruct(pPointer,
- 0,
- 0, /* min val */
- screenInfo.screens[0]->width, /* max val */
- 1, /* resolution */
- 0, /* min_res */
- 1); /* max_res */
- InitValuatorAxisStruct(pPointer,
- 1,
- 0, /* min val */
- screenInfo.screens[0]->height, /* max val */
- 1, /* resolution */
- 0, /* min_res */
- 1); /* max_res */
- /* Initialize valuator values in synch
- * with dix/event.c DefineInitialRootWindow
- */
- *pPointer->valuator->axisVal = screenInfo.screens[0]->width / 2;
- *(pPointer->valuator->axisVal+1) = screenInfo.screens[0]->height / 2;
-#endif
- xf86MouseInit(mouse);
-
- break;
-
- case DEVICE_ON:
-
- mousefd = xf86MouseOn(mouse);
-
- if (fd)
- *fd = mousefd;
-
- if (mousefd != -1) {
- if (mousefd == -2) {
- if (fd)
- *fd = -1;
- } else {
- if (mouse->mseType == PROT_PS2)
- write(mousefd, "\364", 1);
-
- AddEnabledDevice(mousefd);
- }
- mouse->lastButtons = 0;
- mouse->emulateState = 0;
- pPointer->public.on = TRUE;
- } else {
- return !Success;
- }
-
- break;
-
- case DEVICE_OFF:
- case DEVICE_CLOSE:
-
- mousefd = xf86MouseOff(mouse, what == DEVICE_CLOSE);
-
- if (mousefd != -1)
- RemoveEnabledDevice(mousefd);
-
- pPointer->public.on = FALSE;
- usleep(300000);
- break;
- }
- return Success;
-}
-
-/*
- * xf86MseEvents --
- * Read the new events from the device, and pass them to the eventhandler.
- * This should is not used if there is only an OS_MOUSE driver.
- */
-#ifndef OSMOUSE_ONLY
-void
-xf86MseEvents(mouse)
- MouseDevPtr mouse;
-{
- xf86MouseEvents(mouse);
-}
-#endif
-#endif /* !NEW_INPUT */
-
-#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__)
+#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__) && !defined(QNX4)
/*
* These are getting tossed in here until I can think of where
* they really belong
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c b/xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c
index c8777dbc6..c7e07da14 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.19 1999/04/29 05:12:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.20 1999/12/27 00:39:43 robin Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -44,13 +44,14 @@
#if defined(KDGKBTYPE) && \
!defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && \
!defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) && \
- !defined(__arm32__) && !defined(__GNU__)
+ !defined(__arm32__) && !defined(__GNU__) && !defined(__QNX__)
#define HAS_GETKBTYPE
#endif
#if defined(GIO_KEYMAP) && \
!defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && \
!defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) && \
- !defined(__arm32__) && !defined(__GNU__) && !defined(DGUX)
+ !defined(__arm32__) && !defined(__GNU__) && !defined(DGUX) && \
+ !defined(__QNX__)
#define HAS_GETKEYMAP
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86KbdSol8.c b/xc/programs/Xserver/hw/xfree86/common/xf86KbdSol8.c
new file mode 100644
index 000000000..471fcdb14
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86KbdSol8.c
@@ -0,0 +1,26 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdSol8.c,v 1.1 1999/09/25 14:45:02 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * 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 Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL 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.
+ *
+ */
+/* $XConsortium: xf86Kbd.c /main/10 1996/02/21 17:38:32 kaleb $ */
+
+/* Dummy C File for place holder - see os-support/sol8_x86 */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c b/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
index 83e114c63..28be0ad8b 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1999 by The XFree86 Project, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.2 1999/07/18 03:26:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.3 1999/09/04 13:04:34 dawes Exp $ */
/*
* This file contains the Pointer/Keyboard functions needed by the
@@ -32,11 +32,9 @@
#include "inputstr.h"
#endif
-#ifdef NEW_INPUT
#include "xf86OSmouse.h"
#include "../input/mouse/mouse.h"
const char * xf86ProtocolIDToName(ProtocolID id);
-#endif
#define DEBUG
#ifdef DEBUG
@@ -81,29 +79,6 @@ typedef enum {
static int
MapMseProto(int proto, MseProtoMapDirection mapping)
{
-#ifndef NEW_INPUT
- static int MapProto_ToMisc[] = {
- MTYPE_MICROSOFT, MTYPE_MOUSESYS, MTYPE_MMSERIES,
- MTYPE_LOGITECH, MTYPE_BUSMOUSE, MTYPE_LOGIMAN,
- MTYPE_PS_2, MTYPE_MMHIT, MTYPE_GLIDEPOINT,
- MTYPE_IMSERIAL, MTYPE_THINKING, MTYPE_IMPS2,
- MTYPE_THINKINGPS2, MTYPE_MMANPLUSPS2, MTYPE_GLIDEPOINTPS2,
- MTYPE_NETPS2, MTYPE_NETSCROLLPS2, MTYPE_SYSMOUSE,
- MTYPE_UNKNOWN, MTYPE_UNKNOWN, MTYPE_AUTOMOUSE,
- MTYPE_ACECAD
- };
-
- static MouseProtocol MapProto_FromMisc[] = {
- PROT_MS, PROT_MSC, PROT_MM,
- PROT_LOGI, PROT_BM, PROT_LOGIMAN,
- PROT_PS2, PROT_MMHIT, PROT_GLIDEPOINT,
- PROT_IMSERIAL, PROT_THINKING, PROT_IMPS2,
- PROT_THINKINGPS2, PROT_MMPLUSPS2, PROT_GLIDEPOINTPS2,
- PROT_NETPS2, PROT_NETSCROLLPS2, PROT_SYSMOUSE,
- PROT_AUTO, PROT_ACECAD
- };
-#define PROT_DEFAULT 0 /* PROT_MS */
-#else
static int MapProto_ToMisc[] = {
MTYPE_MICROSOFT, MTYPE_MOUSESYS, MTYPE_MMSERIES,
MTYPE_LOGITECH, MTYPE_LOGIMAN, MTYPE_MMHIT,
@@ -122,21 +97,12 @@ MapMseProto(int proto, MseProtoMapDirection mapping)
PROT_NETSCPS2, PROT_SYSMOUSE, PROT_AUTO, PROT_ACECAD
};
#define PROT_DEFAULT -2 /* PROT_UNKNOWN */
-#endif
if (mapping == TO_MISC) {
-#ifndef NEW_INPUT
- if ((MouseProtocol) proto == PROT_OSMOUSE)
- return MTYPE_OSMOUSE;
-#endif
if (proto < 0 || proto >= sizeof(MapProto_ToMisc)/sizeof(int))
return MTYPE_UNKNOWN;
return MapProto_ToMisc[proto];
} else {
-#ifndef NEW_INPUT
- if (proto == MTYPE_OSMOUSE || proto == MTYPE_XQUEUE)
- return -1; /* PROT_OSMOUSE */
-#endif
if (proto < 0 || proto >= sizeof(MapProto_FromMisc)/sizeof(int))
return PROT_DEFAULT;
return MapProto_FromMisc[proto];
@@ -155,26 +121,6 @@ MiscExtGetMouseSettings(pointer *mouse, char **devname)
if (!mseptr)
return FALSE;
-#ifndef NEW_INPUT
- *devname = xf86Info.mouseDev->mseDevice;
- mseptr->type = MapMseProto(xf86Info.mouseDev->mseType, TO_MISC);
-#ifdef XQUEUE
- if (xf86Info.mouseDev->mseProc == xf86XqueMseProc)
- mseptr->type = MTYPE_XQUEUE;
-#endif
-#if defined(USE_OSMOUSE) || defined(OSMOUSE_ONLY)
- if (xf86Info.mouseDev->mseProc == xf86OsMouseProc)
- mseptr->type = MTYPE_OSMOUSE;
-#endif
- mseptr->baudrate = xf86Info.mouseDev->baudRate;
- mseptr->samplerate = xf86Info.mouseDev->sampleRate;
- mseptr->resolution = xf86Info.mouseDev->resolution;
- mseptr->buttons = xf86Info.mouseDev->buttons;
- mseptr->em3buttons = xf86Info.mouseDev->emulate3Buttons;
- mseptr->em3timeout = xf86Info.mouseDev->emulate3Timeout;
- mseptr->chordmiddle = xf86Info.mouseDev->chordMiddle;
- mseptr->flags = xf86Info.mouseDev->mouseFlags;
-#else
{
InputInfoPtr pInfo;
MouseDevPtr pMse;
@@ -202,7 +148,6 @@ MiscExtGetMouseSettings(pointer *mouse, char **devname)
mseptr->flags = pMse->mouseFlags;
mseptr->private = pInfo;
}
-#endif
*mouse = mseptr;
return TRUE;
}
@@ -355,14 +300,10 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
if (mse_or_kbd == MISC_POINTER) {
Bool reopen = FALSE;
mseParamsPtr mse = structure;
-#ifndef NEW_INPUT
- int msetype;
-#else
InputInfoPtr pInfo;
MouseDevPtr pMse;
MouseProtocolPtr protocol;
char tmpbuf[128];
-#endif
if (mse->type < MTYPE_MICROSOFT
|| ( mse->type > MTYPE_ACECAD
@@ -372,14 +313,10 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
if (mse->type != MTYPE_OSMOUSE)
return MISC_RET_BADMSEPROTO;
#else
-#if !defined(XQUEUE) || defined(NEW_INPUT)
if (mse->type == MTYPE_XQUEUE)
return MISC_RET_BADMSEPROTO;
-#endif
-#if !defined(USE_OSMOUSE) || defined(NEW_INPUT)
if (mse->type == MTYPE_OSMOUSE)
return MISC_RET_BADMSEPROTO;
-#endif
#endif /* OSMOUSE_ONLY */
if (mse->em3timeout < 0)
@@ -391,26 +328,6 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
if (mse->type == MTYPE_LOGIMAN && mse->samplerate)
return MISC_RET_BADCOMBO;
-#ifndef NEW_INPUT
- msetype = xf86Info.mouseDev->mseType;
-#ifdef XQUEUE
- if (xf86Info.mouseDev->mseProc == xf86XqueMseProc)
- msetype = MTYPE_XQUEUE;
-#endif
-#if defined(USE_OSMOUSE) || defined(OSMOUSE_ONLY)
- if (xf86Info.mouseDev->mseProc == xf86OsMouseProc)
- msetype = MTYPE_OSMOUSE;
-#endif
-
- if (mse->type != msetype) {
- if (mse->type == MTYPE_XQUEUE || mse->type == MTYPE_OSMOUSE
- || msetype == MTYPE_XQUEUE || msetype == MTYPE_OSMOUSE)
- return MISC_RET_BADMSEPROTO;
- else
- reopen = TRUE;
- }
-#endif /* NEW_INPUT */
-
if (mse->flags & MF_REOPEN) {
reopen = TRUE;
mse->flags &= ~MF_REOPEN;
@@ -452,34 +369,6 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
return MISC_RET_BADCOMBO;
}
-#ifndef NEW_INPUT
- if (xf86Info.mouseDev->mseType != MapMseProto(mse->type, FROM_MISC)
- || xf86Info.mouseDev->baudRate != mse->baudRate
- || xf86Info.mouseDev->sampleRate != mse->sampleRate
- || xf86Info.mouseDev->resolution != mse->resolution
- || xf86Info.mouseDev->mouseFlags != mse->flags)
- reopen = TRUE;
-
- if (reopen && msetype != MTYPE_OSMOUSE && msetype != MTYPE_XQUEUE)
- (xf86Info.mouseDev->mseProc)(xf86Info.pMouse, DEVICE_CLOSE);
-
- xf86Info.mouseDev->mseType = MapMseProto(mse->type, FROM_MISC);
- xf86Info.mouseDev->baudRate = mse->baudRate;
- xf86Info.mouseDev->sampleRate = mse->sampleRate;
- xf86Info.mouseDev->resolution = mse->resolution;
- xf86Info.mouseDev->buttons = mse->buttons;
- xf86Info.mouseDev->emulate3Buttons = mse->em3buttons;
- xf86Info.mouseDev->emulate3Timeout = mse->em3timeout;
- xf86Info.mouseDev->chordMiddle = mse->chordMiddle;
- xf86Info.mouseDev->mouseFlags = mse->flags;
-
- if (reopen && msetype != MTYPE_OSMOUSE && msetype != MTYPE_XQUEUE) {
- xf86Info.pMouse->public.on = FALSE;
- xf86AllowMouseOpenFail = TRUE;
- xf86MouseInit(xf86Info.mouseDev);
- (xf86Info.mouseDev->mseProc)(xf86Info.pMouse, DEVICE_ON);
- }
-#else /* NEW_INPUT */
/* XXX - This still needs work */
pInfo = mse->private;
@@ -510,7 +399,6 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
(pMse->device->deviceProc)(pMse->device, DEVICE_ON);
/* Set pInfo->options too */
-#endif /* NEW_INPUT */
}
if (mse_or_kbd == MISC_KEYBOARD) {
kbdParamsPtr kbd = structure;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c b/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
index 115a29929..1daad11ef 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.20 1999/08/01 07:57:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.25 1999/12/13 01:39:46 robin Exp $ */
/*
* Copyright (c) 1997,1998 by The XFree86 Project, Inc.
@@ -123,12 +123,15 @@ xf86ModeStatusToString(ModeStatus status)
return "vertical blanking too wide";
case MODE_PANEL:
return "exceeds panel dimensions";
+ case MODE_INTERLACE_WIDTH:
+ return "width too large for interlaced mode";
case MODE_BAD:
return "unknown reason";
case MODE_ERROR:
return "internal error";
+ default:
+ return "unknown";
}
- return "unknown";
}
/*
@@ -169,6 +172,26 @@ xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges)
}
}
+
+/*
+ * xf86FindClockRangeForMode() [... like the name says ...]
+ */
+static ClockRangePtr
+xf86FindClockRangeForMode(ClockRangePtr clockRanges, DisplayModePtr p)
+{
+ ClockRangePtr cp;
+
+ for (cp = clockRanges; ; cp = cp->next)
+ if (!cp ||
+ ((p->Clock >= cp->minClock) &&
+ (p->Clock <= cp->maxClock) &&
+ (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN)))))
+ return cp;
+}
+
+
/*
* xf86HandleBuiltinMode() - handles built-in modes
*/
@@ -185,19 +208,20 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
int DivFactor = 1;
int clockIndex;
+ /* Reject previously rejected modes */
+ if (p->status != MODE_OK)
+ return p->status;
+
+ /* Reject previously considered modes */
+ if (p->prev)
+ return MODE_NOMODE;
+
if ((p->type & M_T_CLOCK_C) == M_T_CLOCK_C) {
/* Check clock is in range */
- for (cp = clockRanges; cp != NULL; cp = cp->next) {
- if ((cp->minClock <= p->Clock) &&
- (cp->maxClock >= p->Clock) &&
- (cp->interlaceAllowed ||
- !(p->Flags & V_INTERLACE)) &&
- (cp->doubleScanAllowed ||
- ((!(p->Flags & V_DBLSCAN)) && (p->VScan <= 1))))
- break;
- }
+ cp = xf86FindClockRangeForMode(clockRanges, p);
if (cp == NULL){
modep->type = p->type;
+ p->status = MODE_CLOCK_RANGE;
return MODE_CLOCK_RANGE;
}
DivFactor = cp->ClockDivFactor;
@@ -233,29 +257,37 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
}
modep->PrivFlags = p->PrivFlags;
}
- modep->type = p->type;
- modep->HDisplay = p->HDisplay;
- modep->HSyncStart = p->HSyncStart;
- modep->HSyncEnd = p->HSyncEnd;
- modep->HTotal = p->HTotal;
- modep->HSkew = p->HSkew;
- modep->VDisplay = p->VDisplay;
- modep->VSyncStart = p->VSyncStart;
- modep->VSyncEnd = p->VSyncEnd;
- modep->VTotal = p->VTotal;
- modep->VScan = p->VScan;
- modep->Flags = p->Flags | extraFlags;
- modep->CrtcHDisplay = p->CrtcHDisplay;
- modep->CrtcHSyncStart = p->CrtcHSyncStart;
- modep->CrtcHSyncEnd = p->CrtcHSyncEnd;
- modep->CrtcHTotal = p->CrtcHTotal;
- modep->CrtcHSkew = p->CrtcHSkew;
- modep->CrtcVDisplay = p->CrtcVDisplay;
- modep->CrtcVSyncStart = p->CrtcVSyncStart;
- modep->CrtcVSyncEnd = p->CrtcVSyncEnd;
- modep->CrtcVTotal = p->CrtcVTotal;
- modep->CrtcHAdjusted = p->CrtcHAdjusted;
- modep->CrtcVAdjusted = p->CrtcVAdjusted;
+ modep->type = p->type;
+ modep->HDisplay = p->HDisplay;
+ modep->HSyncStart = p->HSyncStart;
+ modep->HSyncEnd = p->HSyncEnd;
+ modep->HTotal = p->HTotal;
+ modep->HSkew = p->HSkew;
+ modep->VDisplay = p->VDisplay;
+ modep->VSyncStart = p->VSyncStart;
+ modep->VSyncEnd = p->VSyncEnd;
+ modep->VTotal = p->VTotal;
+ modep->VScan = p->VScan;
+ modep->Flags = p->Flags | extraFlags;
+ modep->CrtcHDisplay = p->CrtcHDisplay;
+ modep->CrtcHBlankStart = p->CrtcHBlankStart;
+ modep->CrtcHSyncStart = p->CrtcHSyncStart;
+ modep->CrtcHSyncEnd = p->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = p->CrtcHBlankEnd;
+ modep->CrtcHTotal = p->CrtcHTotal;
+ modep->CrtcHSkew = p->CrtcHSkew;
+ modep->CrtcVDisplay = p->CrtcVDisplay;
+ modep->CrtcVBlankStart = p->CrtcVBlankStart;
+ modep->CrtcVSyncStart = p->CrtcVSyncStart;
+ modep->CrtcVSyncEnd = p->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = p->CrtcVBlankEnd;
+ modep->CrtcVTotal = p->CrtcVTotal;
+ modep->CrtcHAdjusted = p->CrtcHAdjusted;
+ modep->CrtcVAdjusted = p->CrtcVAdjusted;
+ modep->HSync = p->HSync;
+ modep->VRefresh = p->VRefresh;
+
+ p->prev = modep;
return MODE_OK;
}
@@ -266,8 +298,7 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
* This function returns a mode from the given list which matches the
* given name. When multiple modes with the same name are available,
* the method of picking the matching mode is determined by the
- * strategy selected. There is an implicit assumption in this that modes
- * with the same name are of the same size.
+ * strategy selected.
*
* This function takes the following parameters:
* scrp ScrnInfoPtr
@@ -339,21 +370,26 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
if (p->type & M_T_BUILTIN)
return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
allowDiv2);
+
+ /* Skip over previously rejected modes */
+ if (p->status != MODE_OK) {
+ if (!found)
+ status = p->status;
+ continue;
+ }
+ /* Skip over previously considered modes */
+ if (p->prev)
+ continue;
+
/* Check clock is in range */
- for (cp = clockRanges; cp != NULL; cp = cp->next) {
- if ((cp->minClock <= p->Clock) &&
- (cp->maxClock >= p->Clock) &&
- (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
- (cp->doubleScanAllowed ||
- ((!(p->Flags & V_DBLSCAN)) && (p->VScan <= 1))))
- break;
- }
+ cp = xf86FindClockRangeForMode(clockRanges, p);
if (cp == NULL) {
/*
* XXX Could do more here to provide a more detailed
* reason for not finding a mode.
*/
+ p->status = MODE_CLOCK_RANGE;
if (!found)
status = MODE_CLOCK_RANGE;
continue;
@@ -372,25 +408,28 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
MulFactor = cp->ClockMulFactor;
ModePrivFlags = cp->PrivFlags;
break;
- } else {
+ }
+ if (p->VRefresh > 0.0)
+ refresh = p->VRefresh;
+ else {
refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal;
- if (p->Flags & V_INTERLACE) {
+ if (p->Flags & V_INTERLACE)
refresh *= 2.0;
- refresh /= INTERLACE_REFRESH_WEIGHT;
- }
if (p->Flags & V_DBLSCAN)
refresh /= 2.0;
if (p->VScan > 1)
refresh /= p->VScan;
- if (refresh > bestRefresh) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- bestRefresh = refresh;
- }
- continue;
}
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (refresh > bestRefresh) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ bestRefresh = refresh;
+ }
+ continue;
}
/*
@@ -411,38 +450,27 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
gap = abs(p->Clock -
((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
if (gap > minimumGap) {
+ p->status = MODE_NOCLOCK;
if (!found)
status = MODE_NOCLOCK;
continue;
- } else {
- found = TRUE;
}
+ found = TRUE;
- /*
- * If strategy is neither LOOKUP_BEST_REFRESH or
- * LOOKUP_CLOSEST_CLOCK the required mode has been found.
- */
- if (strategy != LOOKUP_BEST_REFRESH &&
- strategy != LOOKUP_CLOSEST_CLOCK) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- extraFlags = k;
- clockIndex = i;
- break;
- } else
- /* Otherwise, record the refresh or gap and continue looking */
if (strategy == LOOKUP_BEST_REFRESH) {
- refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal;
- if (p->Flags & V_INTERLACE) {
- refresh *= 2.0;
- refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (p->VRefresh > 0.0)
+ refresh = p->VRefresh;
+ else {
+ refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal;
+ if (p->Flags & V_INTERLACE)
+ refresh *= 2.0;
+ if (p->Flags & V_DBLSCAN)
+ refresh /= 2.0;
+ if (p->VScan > 1)
+ refresh /= p->VScan;
}
- if (p->Flags & V_DBLSCAN)
- refresh /= 2.0;
- if (p->VScan > 1)
- refresh /= p->VScan;
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
if (refresh > bestRefresh) {
bestMode = p;
DivFactor = cp->ClockDivFactor;
@@ -453,7 +481,8 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
bestRefresh = refresh;
}
continue;
- } else if (strategy == LOOKUP_CLOSEST_CLOCK) {
+ }
+ if (strategy == LOOKUP_CLOSEST_CLOCK) {
if (gap < minimumGap) {
bestMode = p;
DivFactor = cp->ClockDivFactor;
@@ -465,6 +494,17 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
}
continue;
}
+ /*
+ * If strategy is neither LOOKUP_BEST_REFRESH or
+ * LOOKUP_CLOSEST_CLOCK the required mode has been found.
+ */
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
}
}
if (!found || bestMode == NULL)
@@ -498,27 +538,104 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
modep->VScan = bestMode->VScan;
modep->Flags = bestMode->Flags | extraFlags;
modep->CrtcHDisplay = bestMode->CrtcHDisplay;
+ modep->CrtcHBlankStart = bestMode->CrtcHBlankStart;
modep->CrtcHSyncStart = bestMode->CrtcHSyncStart;
modep->CrtcHSyncEnd = bestMode->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = bestMode->CrtcHBlankEnd;
modep->CrtcHTotal = bestMode->CrtcHTotal;
modep->CrtcHSkew = bestMode->CrtcHSkew;
modep->CrtcVDisplay = bestMode->CrtcVDisplay;
+ modep->CrtcVBlankStart = bestMode->CrtcVBlankStart;
modep->CrtcVSyncStart = bestMode->CrtcVSyncStart;
modep->CrtcVSyncEnd = bestMode->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = bestMode->CrtcVBlankEnd;
modep->CrtcVTotal = bestMode->CrtcVTotal;
modep->CrtcHAdjusted = bestMode->CrtcHAdjusted;
modep->CrtcVAdjusted = bestMode->CrtcVAdjusted;
+ modep->HSync = bestMode->HSync;
+ modep->VRefresh = bestMode->VRefresh;
+
+ bestMode->prev = modep;
return MODE_OK;
}
+
+/*
+ * xf86SetModeCrtc
+ *
+ * Initialises the Crtc parameters for a mode. The initialisation includes
+ * adjustments for interlaced and double scan modes.
+ */
+static void
+xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
+{
+ if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
+ return;
+
+ p->CrtcHDisplay = p->HDisplay;
+ p->CrtcHSyncStart = p->HSyncStart;
+ p->CrtcHSyncEnd = p->HSyncEnd;
+ p->CrtcHTotal = p->HTotal;
+ p->CrtcHSkew = p->HSkew;
+ p->CrtcVDisplay = p->VDisplay;
+ p->CrtcVSyncStart = p->VSyncStart;
+ p->CrtcVSyncEnd = p->VSyncEnd;
+ p->CrtcVTotal = p->VTotal;
+ if ((p->Flags & V_INTERLACE) && (adjustFlags & INTERLACE_HALVE_V))
+ {
+ p->CrtcVDisplay /= 2;
+ p->CrtcVSyncStart /= 2;
+ p->CrtcVSyncEnd /= 2;
+ p->CrtcVTotal /= 2;
+ }
+ if (p->Flags & V_DBLSCAN) {
+ p->CrtcVDisplay *= 2;
+ p->CrtcVSyncStart *= 2;
+ p->CrtcVSyncEnd *= 2;
+ p->CrtcVTotal *= 2;
+ }
+ if (p->VScan > 1) {
+ p->CrtcVDisplay *= p->VScan;
+ p->CrtcVSyncStart *= p->VScan;
+ p->CrtcVSyncEnd *= p->VScan;
+ p->CrtcVTotal *= p->VScan;
+ }
+ p->CrtcHAdjusted = FALSE;
+ p->CrtcVAdjusted = FALSE;
+
+ /*
+ * XXX
+ *
+ * The following is taken from VGA, but applies to other cores as well.
+ */
+ p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
+ p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
+ if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) {
+ /*
+ * V Blanking size must be < 127.
+ * Moving blank start forward is safer than moving blank end
+ * back, since monitors clamp just AFTER the sync pulse (or in
+ * the sync pulse), but never before.
+ */
+ p->CrtcVBlankStart = p->CrtcVBlankEnd - 127;
+ }
+ p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay);
+ p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal);
+ if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) {
+ /*
+ * H Blanking size must be < 63*8. Same remark as above.
+ */
+ p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8;
+ }
+}
+
/*
* xf86CheckModeForMonitor
*
* This function takes a mode and monitor description, and determines
* if the mode is valid for the monitor.
*/
-
ModeStatus
xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
{
@@ -540,33 +657,37 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
return MODE_V_ILLEGAL;
- /* Check hsync against the allowed ranges */
- hsync = (float)mode->Clock / (float)mode->HTotal;
- for (i = 0; i < monitor->nHsync; i++)
- if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
- (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
- break;
+ if (monitor->nHsync > 0) {
+ /* Check hsync against the allowed ranges */
+ hsync = (float)mode->Clock / (float)mode->HTotal;
+ for (i = 0; i < monitor->nHsync; i++)
+ if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
- /* Now see whether we ran out of sync ranges without finding a match */
- if (i == monitor->nHsync)
- return MODE_HSYNC;
+ /* Now see whether we ran out of sync ranges without finding a match */
+ if (i == monitor->nHsync)
+ return MODE_HSYNC;
+ }
- /* Check vrefresh against the allowed ranges */
- vrefresh = mode->Clock * 1000.0 / (mode->HTotal * mode->VTotal);
- if (mode->Flags & V_INTERLACE)
- vrefresh *= 2.0;
- if (mode->Flags & V_DBLSCAN)
- vrefresh /= 2.0;
- if (mode->VScan > 1)
- vrefresh /= (float)(mode->VScan);
- for (i = 0; i < monitor->nVrefresh; i++)
- if ((vrefresh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
- (vrefresh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
- break;
+ if (monitor->nVrefresh > 0) {
+ /* Check vrefresh against the allowed ranges */
+ vrefresh = mode->Clock * 1000.0 / (mode->HTotal * mode->VTotal);
+ if (mode->Flags & V_INTERLACE)
+ vrefresh *= 2.0;
+ if (mode->Flags & V_DBLSCAN)
+ vrefresh /= 2.0;
+ if (mode->VScan > 1)
+ vrefresh /= (float)(mode->VScan);
+ for (i = 0; i < monitor->nVrefresh; i++)
+ if ((vrefresh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (vrefresh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
- /* Now see whether we ran out of refresh ranges without finding a match */
- if (i == monitor->nVrefresh)
- return MODE_VSYNC;
+ /* Now see whether we ran out of refresh ranges without finding a match */
+ if (i == monitor->nVrefresh)
+ return MODE_VSYNC;
+ }
/* Force interlaced modes to have an odd VTotal */
if (mode->Flags & V_INTERLACE)
@@ -592,6 +713,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
* virtualY (optional) virtual height requested
*
* In addition, the following fields from the ScrnInfoRec are used:
+ * monitor pointer to structure for monitor section
* fbFormat pixel format for the framebuffer
* videoRam video memory size (in kB)
* maxHValue maximum horizontal timing value
@@ -600,15 +722,32 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
ModeStatus
xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
int maxPitch, int virtualX, int virtualY)
{
+ MonPtr monitor;
+ ClockRangePtr cp;
+ ModeStatus status;
+ Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
+ int i, needDiv2;
+
/* Sanity checks */
- if (scrp == NULL || mode == NULL) {
+ if (!scrp || !mode || !clockRanges) {
ErrorF("xf86InitialCheckModeForDriver: "
"called with invalid parameters\n");
return MODE_ERROR;
}
+ /* Some basic mode validity checks */
+ if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
+ mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+ return MODE_H_ILLEGAL;
+
+ if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
+ mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+ return MODE_V_ILLEGAL;
+
if (mode->HDisplay * mode->VDisplay * scrp->fbFormat.bitsPerPixel >
scrp->videoRam * (1024 * 8))
return MODE_MEM;
@@ -628,8 +767,88 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
return MODE_BAD_VVALUE;
- if (scrp->ValidMode)
- return scrp->ValidMode(scrp->scrnIndex, mode, FALSE, 0);
+ /*
+ * The use of the DisplayModeRec's Crtc* and SynthClock elements below is
+ * provisional, in that they are later reused by the driver at mode-set
+ * time. Here, they are temporarily enlisted to contain the mode timings
+ * as seen by the CRT or panel (rather than the CRTC). The driver's
+ * ValidMode() is allowed to modify these so it can deal with such things
+ * as mode stretching and/or centering. The driver should >NOT< modify the
+ * user-supplied values as these are reported back when mode validation is
+ * said and done.
+ */
+ xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
+
+ cp = xf86FindClockRangeForMode(clockRanges, mode);
+ if (!cp)
+ return MODE_CLOCK_RANGE;
+
+ if (cp->ClockMulFactor < 1)
+ cp->ClockMulFactor = 1;
+ if (cp->ClockDivFactor < 1)
+ cp->ClockDivFactor = 1;
+
+ /*
+ * XXX The effect of clock dividers and multipliers on the monitor's
+ * pixel clock needs to be verified.
+ */
+ if (scrp->progClock) {
+ mode->SynthClock = mode->Clock;
+ } else {
+ i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor,
+ &needDiv2);
+ mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor;
+ if (needDiv2 & V_CLKDIV2)
+ mode->SynthClock /= 2;
+ }
+
+ if (scrp->ValidMode) {
+ status = (*scrp->ValidMode)(scrp->scrnIndex, mode, FALSE,
+ MODECHECK_INITIAL);
+ if (status != MODE_OK)
+ return status;
+ }
+
+ if (!(monitor = scrp->monitor)) {
+ ErrorF("xf86InitialCheckModeForDriver: "
+ "called with invalid monitor\n");
+ return MODE_ERROR;
+ }
+
+ mode->HSync = (float)mode->SynthClock / (float)mode->CrtcHTotal;
+ if (monitor->nHsync > 0) {
+ /* Check hsync against the allowed ranges */
+ for (i = 0; i < monitor->nHsync; i++)
+ if ((mode->HSync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (mode->HSync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of sync ranges without finding a match */
+ if (i == monitor->nHsync)
+ return MODE_HSYNC;
+ }
+
+ mode->VRefresh = (mode->SynthClock * 1000.0) /
+ (mode->CrtcHTotal * mode->CrtcVTotal);
+ if (monitor->nVrefresh > 0) {
+ /* Check vrefresh against the allowed ranges */
+ for (i = 0; i < monitor->nVrefresh; i++)
+ if ((mode->VRefresh >
+ monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (mode->VRefresh <
+ monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of refresh ranges without finding a match */
+ if (i == monitor->nVrefresh)
+ return MODE_VSYNC;
+ }
+
+ /* Force interlaced modes to have an odd VTotal */
+ if (mode->Flags & V_INTERLACE)
+ mode->CrtcVTotal |= 1;
/* Assume it is OK */
return MODE_OK;
@@ -662,7 +881,130 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
ModeStatus
xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
{
-/* To be implemented */
+ ClockRangesPtr cp;
+ int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1;
+ int extraFlags = 0;
+ int clockIndex = -1;
+ int MulFactor = 1;
+ int DivFactor = 1;
+ int ModePrivFlags = 0;
+ Bool allowDiv2;
+ ModeStatus status = MODE_NOMODE;
+
+ /* Some sanity checking */
+ if (scrp == NULL || (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n");
+ return MODE_ERROR;
+ }
+ if (mode == NULL) {
+ ErrorF("xf86CheckModeForDriver: called with invalid modep\n");
+ return MODE_ERROR;
+ }
+ if (scrp->clockRanges == NULL) {
+ ErrorF("xf86CheckModeForDriver: called with invalid clockRanges\n");
+ return MODE_ERROR;
+ }
+
+ /* Check the mode size */
+ if (mode->HDisplay > scrp->virtualX)
+ return MODE_VIRTUAL_X;
+
+ if (mode->VDisplay > scrp->virtualY)
+ return MODE_VIRTUAL_Y;
+
+ if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
+ return MODE_BAD_HVALUE;
+
+ if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
+ return MODE_BAD_VVALUE;
+
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ /* DivFactor and MulFactor must be > 0 */
+ cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+ cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+ }
+
+ if (scrp->progClock) {
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if ((cp->minClock <= mode->Clock) &&
+ (cp->maxClock >= mode->Clock) &&
+ (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1))))
+ break;
+ }
+ if (cp == NULL) {
+ return MODE_CLOCK_RANGE;
+ }
+ /*
+ * If programmable clock the required mode has been found
+ */
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ } else {
+ status = MODE_CLOCK_RANGE;
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if ((cp->minClock <= mode->Clock) &&
+ (cp->maxClock >= mode->Clock) &&
+ (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1)))) {
+
+ /*
+ * Clock is in range, so if it is not a programmable clock,
+ * find a matching clock.
+ */
+
+ allowDiv2 = (cp->strategy & LOOKUP_CLKDIV2) != 0;
+ i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor, &k);
+ /*
+ * If the clock is too far from the requested clock, this
+ * mode is no good.
+ */
+ if (k & V_CLKDIV2)
+ gap = abs((mode->Clock * 2) -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ else
+ gap = abs(mode->Clock -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ if (gap > minimumGap) {
+ status = MODE_NOCLOCK;
+ continue;
+ }
+
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
+ }
+ }
+ if (cp == NULL)
+ return status;
+ }
+
+ /* Fill in the mode parameters */
+ if (scrp->progClock) {
+ mode->ClockIndex = -1;
+ mode->SynthClock = (mode->Clock * MulFactor) / DivFactor;
+ } else {
+ mode->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+ mode->ClockIndex = clockIndex;
+ mode->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ mode->Clock /= 2;
+ mode->SynthClock /= 2;
+ }
+ }
+ mode->PrivFlags = ModePrivFlags;
+
return MODE_OK;
}
@@ -675,7 +1017,7 @@ xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
* This function takes the following parameters:
* scrp ScrnInfoPtr
* availModes the list of modes available for the monitor
- * modeNames list of mode names that the screen is requesting
+ * modeNames (optional) list of mode names that the screen is requesting
* clockRanges a list of clock ranges
* linePitches (optional) a list of line pitches
* minPitch (optional) minimum line pitch (in pixels)
@@ -693,6 +1035,7 @@ xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
* clocks a list of discrete clocks
* numClocks number of discrete clocks
* progClock clock is programmable
+ * monitor pointer to structure for monitor section
* fbFormat format of the framebuffer
* videoRam video memory size
* maxHValue maximum horizontal timing value
@@ -720,28 +1063,24 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
int minHeight, int maxHeight, int virtualX, int virtualY,
int apertureSize, LookupModeFlags strategy)
{
- /* XXX Implement checking against minHeight and maxHeight */
-
- DisplayModePtr p, q, new;
+ DisplayModePtr p, q, r, new, last, *endp;
int i, numModes = 0;
- Bool firstMode = TRUE;
ModeStatus status;
int linePitch = -1, virtX = 0, virtY = 0;
int newLinePitch, newVirtX, newVirtY;
int pixelArea = scrp->videoRam * (1024 * 8); /* in bits */
+ int modeSize; /* in pixels */
int bitsPerPixel, pixmapPad;
PixmapFormatRec *BankFormat;
+ ClockRangePtr cp;
+ ClockRangesPtr storeClockRanges;
/* Some sanity checking */
- if (scrp == NULL || scrp->name == NULL ||
+ if (scrp == NULL || scrp->name == NULL || !scrp->monitor ||
(!scrp->progClock && scrp->numClocks == 0)) {
ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n");
return -1;
}
- if (modeNames == NULL || modeNames[0] == NULL) {
- ErrorF("xf86ValidateModes: called with invalid modeNames\n");
- return -1;
- }
if (linePitches != NULL && linePitches[0] <= 0) {
ErrorF("xf86ValidateModes: called with invalid linePitches\n");
return -1;
@@ -759,6 +1098,42 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
return -1;
}
+ /*
+ * If requested by the driver, allow missing hsync and/or vrefresh ranges
+ * in the monitor section.
+ */
+ if (strategy & LOOKUP_OPTIONAL_TOLERANCES) {
+ strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
+ } else {
+ if (scrp->monitor->nHsync <= 0) {
+ ErrorF("xf86ValidateModes: called with missing monitor horizontal"
+ " sync rates\n");
+ return -1;
+ }
+ if (scrp->monitor->nVrefresh <= 0) {
+ ErrorF("xf86ValidateModes: called with missing monitor vertical"
+ " refresh rates\n");
+ return -1;
+ }
+ }
+
+ /*
+ * Store the clockRanges for later use by the VidMode extension. Must
+ * also store the strategy, since ClockDiv2 flag is stored there.
+ */
+ storeClockRanges = scrp->clockRanges;
+ while (storeClockRanges != NULL) {
+ storeClockRanges = storeClockRanges->next;
+ }
+ for (cp = clockRanges; cp != NULL; cp = cp->next,
+ storeClockRanges = storeClockRanges->next) {
+ storeClockRanges = xnfalloc(sizeof(ClockRanges));
+ if (scrp->clockRanges == NULL)
+ scrp->clockRanges = storeClockRanges;
+ memcpy(storeClockRanges, cp, sizeof(ClockRange));
+ storeClockRanges->strategy = strategy;
+ }
+
/* Determine which pixmap format to pass to miScanLineWidth() */
if (scrp->depth > 4)
BankFormat = &scrp->fbFormat;
@@ -806,6 +1181,13 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
return -1;
}
+ if (minHeight > 0 && virtualY < minHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtualY, minHeight);
+ return -1;
+ }
+
virtualX = _VIRTUALX(virtualX);
if (linePitches != NULL) {
for (i = 0; linePitches[i] != 0; i++) {
@@ -840,19 +1222,22 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
virtY = virtualY;
scrp->virtualFrom = X_CONFIG;
}
+
/* Print clock ranges and scaled clocks */
xf86ShowClockRanges(scrp, clockRanges);
/*
- * If scrp->modePool hasn't been setup yet, set it up now. This allows
- * the modes that the driver definitely can't use to be weeded out
- * early.
+ * If scrp->modePool hasn't been setup yet, set it up now. This allows the
+ * modes that the driver definitely can't use to be weeded out early. Note
+ * that a modePool mode's prev field is used to hold a pointer to the
+ * member of the scrp->modes list for which a match was considered.
*/
if (scrp->modePool == NULL) {
q = NULL;
for (p = availModes; p != NULL; p = p->next) {
- status = xf86InitialCheckModeForDriver(scrp, p, maxPitch, virtualX,
- virtualY);
+ status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
+ strategy, maxPitch,
+ virtualX, virtualY);
if (status == MODE_OK) {
new = xnfalloc(sizeof(DisplayModeRec));
*new = *p;
@@ -862,9 +1247,10 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
} else {
q->next = new;
}
- new->prev = q;
+ new->prev = NULL;
q = new;
q->name = xnfstrdup(p->name);
+ q->status = MODE_OK;
} else {
if (p->type & M_T_BUILTIN)
xf86DrvMsg(scrp->scrnIndex, X_WARNING,
@@ -876,51 +1262,85 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
xf86ModeStatusToString(status));
}
}
- }
- if (scrp->modePool == NULL) {
- xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
- return 0;
+ if (scrp->modePool == NULL) {
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
+ return 0;
+ }
+ } else {
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+ p->prev = NULL;
+ p->status = MODE_OK;
+ }
}
/*
- * Allocate one entry in scrp->modes for each named mode, if not already
- * done.
+ * Allocate one entry in scrp->modes for each named mode.
*/
- if (scrp->modes == NULL) {
- scrp->modes = xnfalloc(sizeof(DisplayModeRec));
- scrp->modes->next = NULL;
- scrp->modes->prev = NULL;
- }
- q = scrp->modes;
- for (i = 0; modeNames[i] != NULL; i++) {
- if (firstMode) {
- firstMode = FALSE;
- } else {
- if (q->next == NULL) {
- q->next = xnfalloc(sizeof(DisplayModeRec));
- q->next->next = NULL;
- q->next->name = NULL;
- } else {
- if (q->next->name)
- xfree(q->next->name);
- }
- q->next->prev = q;
- q = q->next;
+ while (scrp->modes)
+ xf86DeleteMode(&scrp->modes, scrp->modes);
+ endp = &scrp->modes;
+ last = NULL;
+ if (modeNames != NULL) {
+ for (i = 0; modeNames[i] != NULL; i++) {
+ new = xnfcalloc(1, sizeof(DisplayModeRec));
+ new->prev = last;
+ new->name = xnfalloc(strlen(modeNames[i]) + 1);
+ strcpy(new->name, modeNames[i]);
+ if (new->prev)
+ new->prev->next = new;
+ *endp = last = new;
+ endp = &new->next;
}
- q->name = xnfalloc(strlen(modeNames[i]) + 1);
- strcpy(q->name, modeNames[i]);
- q->type = 0;
}
- q->next = NULL;
- /*
- * XXX Check if there are any remaining previously allocated entries
- * which should be freed? (but there shouldn't normally be any such
- * entries)
- */
/* Lookup each mode */
- for (p = scrp->modes; p != NULL; p = p->next) {
+ for (p = scrp->modes; ; p = p->next) {
+ /*
+ * If the supplied mode names don't produce a valid mode, scan through
+ * unconsidered modePool members until one survives validation. This
+ * is done in decreasing order by mode pixel area.
+ */
+ if (p == NULL) {
+ if (numModes > 0)
+ break;
+
+ r = NULL;
+ modeSize = 0;
+ for (q = scrp->modePool; q != NULL; q = q->next) {
+ if ((q->prev == NULL) && (q->status == MODE_OK)) {
+ /*
+ * Deal with the case where this mode wasn't considered
+ * because of a builtin mode of the same name.
+ */
+ for (p = scrp->modes; p != NULL; p = p->next) {
+ if ((p->status != MODE_OK) &&
+ !strcmp(p->name, q->name))
+ break;
+ }
+
+ if (p != NULL)
+ q->prev = p;
+ else if (modeSize < (q->HDisplay * q->VDisplay)) {
+ r = q;
+ modeSize = q->HDisplay * q->VDisplay;
+ }
+ }
+ }
+
+ if (r == NULL)
+ break;
+
+ p = xnfcalloc(1, sizeof(DisplayModeRec));
+ p->prev = last;
+ p->name = xnfalloc(strlen(r->name) + 1);
+ strcpy(p->name, r->name);
+ if (p->prev)
+ p->prev->next = p;
+ *endp = last = p;
+ endp = &p->next;
+ }
+ lookupNext:
status = xf86LookupMode(scrp, p, clockRanges, strategy);
if (status == MODE_ERROR) {
ErrorF("xf86ValidateModes: "
@@ -928,7 +1348,8 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
return -1;
}
if (status != MODE_OK) {
- p->status = status;
+ if (p->status == MODE_OK)
+ p->status = status;
continue;
}
@@ -942,8 +1363,13 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
*/
if (virtualX <= 0 && p->HDisplay > newVirtX)
newVirtX = _VIRTUALX(p->HDisplay);
- if (virtualY <= 0 && p->VDisplay > newVirtY)
+ if (virtualY <= 0 && p->VDisplay > newVirtY) {
+ if (maxHeight > 0 && p->VDisplay > maxHeight) {
+ p->status = MODE_VIRTUAL_Y; /* ? */
+ goto lookupNext;
+ }
newVirtY = p->VDisplay;
+ }
/*
* If virtual resolution is to be increased, revalidate it.
@@ -970,7 +1396,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
}
if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) {
p->status = MODE_BAD_WIDTH;
- continue;
+ goto lookupNext;
}
/*
@@ -979,15 +1405,28 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
*/
if (_VIDEOSIZE(newLinePitch, newVirtX, newVirtY) > pixelArea) {
p->status = MODE_MEM_VIRT;
- continue;
+ goto lookupNext;
}
+ }
- virtX = newVirtX;
- virtY = newVirtY;
- linePitch = newLinePitch;
+ if (scrp->ValidMode) {
+ /*
+ * Give the driver a final say, passing it the proposed virtual
+ * geometry.
+ */
+ scrp->virtualX = newVirtX;
+ scrp->virtualY = newVirtY;
+ scrp->displayWidth = newLinePitch;
+ p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE,
+ MODECHECK_FINAL);
+ if (p->status != MODE_OK)
+ goto lookupNext;
}
/* Mode has passed all the tests */
+ virtX = newVirtX;
+ virtY = newVirtY;
+ linePitch = newLinePitch;
p->status = MODE_OK;
numModes++;
}
@@ -1011,6 +1450,13 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
scrp->modes->prev = p;
}
+ if (minHeight > 0 && virtY < minHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtY, minHeight);
+ return -1;
+ }
+
return numModes;
}
@@ -1019,8 +1465,9 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
*
* This function removes a mode from a list of modes.
*
- * There are two types of mode lists:
+ * There are different types of mode lists:
*
+ * - singly linked linear lists, ending in NULL
* - doubly linked linear lists, starting and ending in NULL
* - doubly linked circular lists
*
@@ -1038,12 +1485,12 @@ xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)
*modeList = mode->next;
/* If mode is the only one on the list, set the list to NULL */
- if ((mode == mode->prev) && (mode->prev == mode->next)) {
+ if ((mode == mode->prev) && (mode == mode->next)) {
*modeList = NULL;
} else {
- if (mode->prev != NULL)
+ if ((mode->prev != NULL) && (mode->prev->next == mode))
mode->prev->next = mode->next;
- if (mode->next != NULL)
+ if ((mode->next != NULL) && (mode->next->prev == mode))
mode->next->prev = mode->prev;
}
@@ -1052,59 +1499,6 @@ xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)
}
/*
- * xf86PruneMonitorModes
- *
- * Remove the monitor modes which are inconsistent with the monitor's
- * specs.
- */
-
-void
-xf86PruneMonitorModes(MonPtr monp)
-{
- DisplayModePtr p, n;
- ModeStatus status;
- Bool first = TRUE;
- float refresh;
-
- p = monp->Modes;
- while (p != NULL) {
- n = p->next;
- status = xf86CheckModeForMonitor(p, monp);
- if (status != MODE_OK) {
- if ((p->type & M_T_DEFAULT) == 0) {
- if (first) {
- first = FALSE;
- xf86Msg(X_INFO, "Bad modes for monitor \"%s\"\n",
- monp->id);
- }
- xf86Msg(X_INFO, " Mode \"%s\" deleted (%s", p->name, /*) */
- xf86ModeStatusToString(status));
- switch (status) {
- case MODE_HSYNC:
- xf86ErrorF(": %.2f kHz", (double)p->Clock / p->HTotal);
- break;
- case MODE_VSYNC:
- refresh = p->Clock * 1000.0 / (p->HTotal * p->VTotal);
- if (p->Flags & V_INTERLACE)
- refresh *= 2.0;
- if (p->Flags & V_DBLSCAN)
- refresh /= 2.0;
- if (p->VScan > 1)
- refresh /= (float)(p->VScan);
- xf86ErrorF(": %.2f Hz", refresh);
- break;
- default:
- break;
- }
- xf86ErrorF( /*( */ ")\n");
- }
- xf86DeleteMode(&(monp->Modes), p);
- }
- p = n;
- }
-}
-
-/*
* xf86PruneDriverModes
*
* Remove modes from the driver's mode list which have been marked as
@@ -1137,6 +1531,10 @@ xf86PruneDriverModes(ScrnInfoPtr scrp)
}
p = n;
} while (p != NULL && p != first);
+
+ /* modePool is no longer needed, turf it */
+ while (scrp->modePool)
+ xf86DeleteMode(&scrp->modePool, scrp->modePool);
}
@@ -1152,66 +1550,21 @@ xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)
{
DisplayModePtr p;
+ /*
+ * Store adjustFlags for use with the VidMode extension. There is an
+ * implicit assumption here that SetCrtcForModes is called once.
+ */
+ scrp->adjustFlags = adjustFlags;
+
p = scrp->modes;
if (p == NULL)
return;
do {
- if (!(p->type & M_T_BUILTIN) ||
- ((p->type & M_T_CRTC_C) == M_T_CRTC_C)) {
- p->CrtcHDisplay = p->HDisplay;
- p->CrtcHSyncStart = p->HSyncStart;
- p->CrtcHSyncEnd = p->HSyncEnd;
- p->CrtcHTotal = p->HTotal;
- p->CrtcHSkew = p->HSkew;
- p->CrtcVDisplay = p->VDisplay;
- p->CrtcVSyncStart = p->VSyncStart;
- p->CrtcVSyncEnd = p->VSyncEnd;
- p->CrtcVTotal = p->VTotal;
- if ((p->Flags & V_INTERLACE) && (adjustFlags & INTERLACE_HALVE_V))
- {
- p->CrtcVDisplay /= 2;
- p->CrtcVSyncStart /= 2;
- p->CrtcVSyncEnd /= 2;
- p->CrtcVTotal /= 2;
- }
- if (p->Flags & V_DBLSCAN) {
- p->CrtcVDisplay *= 2;
- p->CrtcVSyncStart *= 2;
- p->CrtcVSyncEnd *= 2;
- p->CrtcVTotal *= 2;
- }
- if (p->VScan > 1) {
- p->CrtcVDisplay *= p->VScan;
- p->CrtcVSyncStart *= p->VScan;
- p->CrtcVSyncEnd *= p->VScan;
- p->CrtcVTotal *= p->VScan;
- }
- p->CrtcHAdjusted = FALSE;
- p->CrtcVAdjusted = FALSE;
- p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
- p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
- if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) {
- /*
- * V Blanking size must be < 127.
- * Moving blank start forward is safer than moving blank end
- * back, since monitors clamp just AFTER the sync pulse (or in
- * the sync pulse), but never before.
- */
- p->CrtcVBlankStart = p->CrtcVBlankEnd - 127;
- }
- p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay);
- p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal);
- if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) {
- /*
- * H Blanking size must be < 63*8. Same remark as above.
- */
- p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8;
- }
- }
+ xf86SetModeCrtc(p, adjustFlags);
#ifdef DEBUG
- ErrorF("%s %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
- (p->type & M_T_DEFAULT) ? "(VESA)Mode" : "Mode",
+ ErrorF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
+ (p->type & M_T_DEFAULT) ? "Default " : "",
p->name, p->CrtcHDisplay, p->CrtcHBlankStart,
p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd,
p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart,
@@ -1243,7 +1596,10 @@ xf86PrintModes(ScrnInfoPtr scrp)
do {
desc = desc2 = "";
- hsync = (float)p->Clock / (float)p->HTotal;
+ if (p->HSync > 0.0)
+ hsync = p->HSync;
+ else
+ hsync = (float)p->Clock / (float)p->HTotal;
refresh = hsync * 1000.0 / p->VTotal;
if (p->Flags & V_INTERLACE) {
refresh *= 2.0;
@@ -1257,10 +1613,12 @@ xf86PrintModes(ScrnInfoPtr scrp)
refresh /= p->VScan;
desc2 = " (VScan)";
}
+ if (p->VRefresh > 0.0)
+ refresh = p->VRefresh;
if (p->type & M_T_BUILTIN)
prefix = "Built-in mode";
else if (p->type & M_T_DEFAULT)
- prefix = "VESA mode";
+ prefix = "Default mode";
else
prefix = "Mode";
if (p->Clock == p->SynthClock) {
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
index 084bfc7dd..f30bac9a9 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.39 1999/08/29 12:42:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.46 1999/12/27 00:16:07 robin Exp $ */
/*
* PCI Probe
*
@@ -169,17 +169,34 @@
#define PCI_CHIP_MACH64GB 0x4742
#define PCI_CHIP_MACH64GD 0x4744
#define PCI_CHIP_MACH64GI 0x4749
+#define PCI_CHIP_MACH64GL 0x474C
+#define PCI_CHIP_MACH64GM 0x474D
+#define PCI_CHIP_MACH64GN 0x474E
+#define PCI_CHIP_MACH64GO 0x474F
#define PCI_CHIP_MACH64GP 0x4750
#define PCI_CHIP_MACH64GQ 0x4751
+#define PCI_CHIP_MACH64GR 0x4752
+#define PCI_CHIP_MACH64GS 0x4753
#define PCI_CHIP_MACH64GT 0x4754
#define PCI_CHIP_MACH64GU 0x4755
+#define PCI_CHIP_MACH64GV 0x4756
+#define PCI_CHIP_MACH64GW 0x4757
#define PCI_CHIP_MACH64GX 0x4758
#define PCI_CHIP_MACH64GZ 0x475A
#define PCI_CHIP_MACH64LB 0x4C42
#define PCI_CHIP_MACH64LD 0x4C44
#define PCI_CHIP_MACH64LG 0x4C47
#define PCI_CHIP_MACH64LI 0x4C49
+#define PCI_CHIP_MACH64LM 0x4C4D
+#define PCI_CHIP_MACH64LN 0x4C4E
#define PCI_CHIP_MACH64LP 0x4C50
+#define PCI_CHIP_MACH64LR 0x4C52
+#define PCI_CHIP_MACH64LS 0x4C53
+#define PCI_CHIP_RAGE128RE 0x5245
+#define PCI_CHIP_RAGE128RF 0x5246
+#define PCI_CHIP_RAGE128RK 0x524B
+#define PCI_CHIP_RAGE128RL 0x524C
+#define PCI_CHIP_RAGE128PF 0x5046
#define PCI_CHIP_MACH64VT 0x5654
#define PCI_CHIP_MACH64VU 0x5655
#define PCI_CHIP_MACH64VV 0x5656
@@ -404,6 +421,9 @@
#define PCI_CHIP_VTNT2 0x002C
#define PCI_CHIP_UVTNT2 0x002D
#define PCI_CHIP_ITNT2 0x00A0
+#define PCI_CHIP_GEFORCE256 0x0100
+#define PCI_CHIP_GEFORCEDDR 0x0101
+#define PCI_CHIP_QUADRO 0x0103
/* NVIDIA & SGS */
#define PCI_CHIP_RIVA128 0x0018
@@ -412,6 +432,7 @@
#define PCI_CHIP_AP6410 0x3210
#define PCI_CHIP_AP6422 0x6422
#define PCI_CHIP_AT24 0x6424
+#define PCI_CHIP_AT3D 0x643D
/* 3Dfx Interactive */
#define PCI_CHIP_VOODOO_GRAPHICS 0x0001
@@ -450,10 +471,13 @@
#define PCI_CHIP_TRIO64V2_DXGX 0x8901
#define PCI_CHIP_PLATO_PX 0x8902
#define PCI_CHIP_Trio3D 0x8904
+#define PCI_CHIP_Trio3D_2X 0x8A13
#define PCI_CHIP_VIRGE_DXGX 0x8A01
#define PCI_CHIP_VIRGE_GX2 0x8A10
#define PCI_CHIP_Savage3D 0x8A20
#define PCI_CHIP_Savage3D_MV 0x8A21
+#define PCI_CHIP_Savage4 0x8A22
+#define PCI_CHIP_Savage2000 0x9102
#define PCI_CHIP_VIRGE_MX 0x8C01
#define PCI_CHIP_VIRGE_MXPLUS 0x8C01
#define PCI_CHIP_VIRGE_MXP 0x8C03
@@ -647,17 +671,34 @@ pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_MACH64GB, "Mach64 GB"},
{PCI_CHIP_MACH64GD, "Mach64 GD"},
{PCI_CHIP_MACH64GI, "Mach64 GI"},
+ {PCI_CHIP_MACH64GL, "Mach64 GL"},
+ {PCI_CHIP_MACH64GM, "Mach64 GM"},
+ {PCI_CHIP_MACH64GN, "Mach64 GN"},
+ {PCI_CHIP_MACH64GO, "Mach64 GO"},
{PCI_CHIP_MACH64GP, "Mach64 GP"},
{PCI_CHIP_MACH64GQ, "Mach64 GQ"},
+ {PCI_CHIP_MACH64GR, "Mach64 GR"},
+ {PCI_CHIP_MACH64GS, "Mach64 GS"},
{PCI_CHIP_MACH64GT, "Mach64 GT"},
- {PCI_CHIP_MACH64GU, "Mach64 GT"},
+ {PCI_CHIP_MACH64GU, "Mach64 GU"},
+ {PCI_CHIP_MACH64GV, "Mach64 GV"},
+ {PCI_CHIP_MACH64GW, "Mach64 GW"},
{PCI_CHIP_MACH64GX, "Mach64 GX"},
{PCI_CHIP_MACH64GZ, "Mach64 GZ"},
{PCI_CHIP_MACH64LB, "Mach64 LB"},
{PCI_CHIP_MACH64LD, "Mach64 LD"},
{PCI_CHIP_MACH64LG, "Mach64 LG"},
{PCI_CHIP_MACH64LI, "Mach64 LI"},
+ {PCI_CHIP_MACH64LM, "Mach64 LM"},
+ {PCI_CHIP_MACH64LN, "Mach64 LN"},
{PCI_CHIP_MACH64LP, "Mach64 LP"},
+ {PCI_CHIP_MACH64LR, "Mach64 LR"},
+ {PCI_CHIP_MACH64LS, "Mach64 LS"},
+ {PCI_CHIP_RAGE128RE, "Rage 128 RE"},
+ {PCI_CHIP_RAGE128RF, "Rage 128 RF"},
+ {PCI_CHIP_RAGE128RK, "Rage 128 RK"},
+ {PCI_CHIP_RAGE128RL, "Rage 128 RL"},
+ {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF"},
{PCI_CHIP_MACH64VT, "Mach64 VT"},
{PCI_CHIP_MACH64VU, "Mach64 VU"},
{PCI_CHIP_MACH64VV, "Mach64 VV"},
@@ -1031,6 +1072,9 @@ pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_VTNT2, "Riva Vanta"},
{PCI_CHIP_UVTNT2, "Riva Ultra 64"},
{PCI_CHIP_ITNT2, "Riva Integrated"},
+ {PCI_CHIP_GEFORCE256, "GeForce 256"},
+ {PCI_CHIP_GEFORCEDDR, "GeForce DDR"},
+ {PCI_CHIP_QUADRO, "Quadro"},
{0x0000, NULL}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_IMS, {
@@ -1116,7 +1160,7 @@ pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
#endif
{PCI_VENDOR_RENDITION, {
{PCI_CHIP_V1000, "Verite 1000"},
- {PCI_CHIP_V2x00, "Verite 2x00"},
+ {PCI_CHIP_V2x00, "Verite 2100/2200"},
{0x0000, NULL}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_TOSHIBA, {
@@ -1137,6 +1181,7 @@ pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_VOODOO_GRAPHICS, "Voodoo Graphics"},
{PCI_CHIP_VOODOO2, "Voodoo2"},
{PCI_CHIP_BANSHEE, "Banshee"},
+ {PCI_CHIP_VOODOO3, "Voodoo3"},
{0x0000, NULL}}},
{PCI_VENDOR_SIGMADESIGNS, {
{0x6401, "REALmagic64/GX (SD 6425)" },
@@ -1186,11 +1231,14 @@ pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_TRIO64V2_DXGX,"Trio64V2/DX or /GX"},
{PCI_CHIP_PLATO_PX, "PLATO/PX"},
{PCI_CHIP_Trio3D, "Trio3D"},
+ {PCI_CHIP_Trio3D_2X, "Trio3D/2X"},
{PCI_CHIP_VIRGE_VX, "ViRGE/VX"},
{PCI_CHIP_VIRGE_DXGX, "ViRGE/DX or /GX"},
{PCI_CHIP_VIRGE_GX2, "ViRGE/GX2"},
{PCI_CHIP_Savage3D, "Savage3D (86E391)"},
{PCI_CHIP_Savage3D_MV, "Savage3D+MacroVision (86E390)"},
+ {PCI_CHIP_Savage4, "Savage4"},
+ {PCI_CHIP_Savage2000, "Savage2000"},
{PCI_CHIP_VIRGE_MX, "ViRGE/MX"},
{PCI_CHIP_VIRGE_MXPLUS, "ViRGE/MX+"},
{PCI_CHIP_VIRGE_MXP, "ViRGE/MX+MV"},
@@ -1317,14 +1365,7 @@ pciVendorCardInfo xf86PCICardInfoData[] = {
{ 0x7881, "AHA-2940U/UW SCSI", NF },
{ 0x0000, (char *)NULL, NF } } },
#endif
- { PCI_VENDOR_ATI, {
- { 0x4750, "XPERT XL", NF },
- { 0x4755, "Mach64-GT-B+DVD", NF },
- { 0x0084, "Xpert'98", NF },
- { 0x4d55, "264GT3 (Rage3D III)", NF },
- { 0x0088, "Mach64 (SuSE Econ)", NF },
- { 0x4c42, "XPERT LCD", NF },
- { 0x0000, (char *)NULL, NF } } },
+ /* ATI card info deleted; unmaintainable */
#ifdef VENDOR_INCLUDE_NONVIDEO
#ifdef INCLUDE_EMPTY_LISTS
{ PCI_VENDOR_COMPAQ, {
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
index 94db1d290..0002312ac 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.54 1999/08/01 07:57:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.61 1999/12/03 19:17:23 eich Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -15,6 +15,7 @@
#define _XF86PRIV_H
#include "xf86Privstr.h"
+#include "propertyst.h"
/*
* Parameters set ONLY from the command line options
@@ -35,6 +36,7 @@ extern Bool xf86coFlag;
extern Bool xf86sFlag;
extern Bool xf86bsEnableFlag;
extern Bool xf86bsDisableFlag;
+extern Bool xf86silkenMouseDisableFlag;
extern char *xf86LayoutName;
extern char *xf86ScreenName;
extern char *xf86PointerName;
@@ -66,6 +68,7 @@ extern confDRIRec xf86ConfigDRI;
extern unsigned short xf86MouseCflags[];
extern Bool xf86SupportedMouseTypes[];
extern int xf86NumMouseTypes;
+extern int xf86EstimateSizesAggressively;
#ifdef XFree86LOADER
extern DriverPtr *xf86DriverList;
@@ -73,7 +76,6 @@ extern DriverPtr *xf86DriverList;
extern DriverPtr xf86DriverList[];
#endif
extern int xf86NumDrivers;
-extern Bool xf86Exiting;
extern Bool xf86Resetting;
extern Bool xf86Initialising;
extern Bool xf86ProbeFailed;
@@ -84,6 +86,7 @@ extern const char *xf86VisualNames[];
extern int xf86Verbose; /* verbosity level */
extern int xf86LogVerbose; /* log file verbosity level */
extern Bool xf86ProbeOnly;
+extern Bool xf86DoProbe;
#ifndef DEFAULT_VERBOSE
#define DEFAULT_VERBOSE 1
@@ -125,7 +128,6 @@ void xf86FreeResList(resPtr rlist);
void xf86ResourceBrokerInit(void);
void xf86PostProbe(void);
void xf86ClearEntityListForScreen(int scrnIndex);
-ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
extern void xf86PostPreInit(void);
extern void xf86PostScreenInit(void);
extern memType getValidBIOSBase(PCITAG tag, int num);
@@ -143,13 +145,14 @@ extern DisplayModeRec xf86DefaultModes [];
void DoScanPci(int argc, char **argv, int i);
+/* xf86DoProbe.c */
+void DoProbeArgs(int argc, char **argv, int i);
+void DoProbe(void);
+
/* xf86Events.c */
void xf86PostKbdEvent(unsigned key);
void xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy);
-#ifndef NEW_INPUT
-void xf86Block(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
-#endif
void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
void xf86SigHandler(int signo);
@@ -169,25 +172,6 @@ void xf86KbdLeds(void);
void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl);
void xf86InitKBD(Bool init);
int xf86KbdProc(DeviceIntPtr pKeyboard, int what);
-#ifndef NEW_INPUT
-void xf86MseCtrl(DevicePtr pPointer, PtrCtrl *ctrl);
-int xf86MseProc(DeviceIntPtr pPointer, int what);
-int xf86MseProcAux(DeviceIntPtr pPointer, int what, MouseDevPtr mouse,
- int *fd, PtrCtrlProcPtr ctrl);
-void xf86MseEvents(MouseDevPtr mouse);
-
-/* xf86Mouse.c */
-
-Bool xf86MouseSupported(int mousetype);
-void xf86SetupMouse(MouseDevPtr mouse);
-void xf86MouseProtocol(DeviceIntPtr device, unsigned char *rBuf, int nBytes);
-#ifdef XINPUT
-void xf86MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
-#endif
-
-/* xf86PnPMouse.c */
-int xf86GetPnPMouseProtocol(MouseDevPtr mouse);
-#endif
/* xf86Kbd.c */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
index 4bf5efd0d..99b5b6eb4 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.16 1999/07/11 10:27:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.17 1999/09/04 13:04:35 dawes Exp $ */
/*
* Copyright (c) 1997,1998 by The XFree86 Project, Inc.
@@ -17,67 +17,6 @@
#ifdef XINPUT
#endif
-#ifndef NEW_INPUT
-/* Mouse device private record */
-
-typedef struct _MouseDevRec {
- DeviceProc mseProc; /* procedure for initializing */
- void (*mseEvents)(struct _MouseDevRec *);
- /* proc for processing events */
- DeviceIntPtr device;
- int mseFd;
- char * mseDevice;
- MouseProtocol mseType;
- int mseModel;
- int baudRate;
- int oldBaudRate;
- int sampleRate;
- int lastButtons;
- int threshold; /* acceleration */
- int num;
- int den;
- int buttons; /* # of buttons */
- int emulateState; /* automata state for 2 button mode */
- Bool emulate3Buttons;
- int emulate3Timeout;/* Timeout for 3 button emulation */
- Bool chordMiddle;
- int mouseFlags; /* Flags to Clear after opening
- * mouse dev */
- int truebuttons; /* Arg to maintain before
- * emulate3buttons timer callback */
- int resolution;
- int negativeZ;
- int positiveZ;
-#ifndef MOUSE_PROTOCOL_IN_KERNEL
- int protoBufTail;
-#ifndef WSCONS_SUPPORT
- unsigned char protoBuf[8];
-#else
- unsigned char protoBuf[32];
-#endif
- unsigned char protoPara[7];
- unsigned char inSync; /* driver in sync with datastream */
-#endif
- /* xqueue part */
- int xquePending; /* was xqueFd, but nothing uses that */
- int xqueSema;
-#ifdef XINPUT
- struct _LocalDeviceRec *local;
-#endif
-} MouseDevRec, *MouseDevPtr;
-
-#ifndef XINPUT
-#define MOUSE_DEV(dev) (MouseDevPtr) (dev)->public.devicePrivate
-#endif
-
-/* Mouse device private record */
-
-#define MSE_MAPTOX -1
-#define MSE_MAPTOY -2
-#define MSE_MAXBUTTONS 12
-#define MSE_DFLTBUTTONS 3
-#endif
-
/* PCI probe flags */
typedef enum {
@@ -127,9 +66,6 @@ typedef struct {
#ifdef XINPUT
pointer mouseLocal;
#endif
-#ifndef NEW_INPUT
- MouseDevPtr mouseDev;
-#endif
/* event handler part */
int lastEventTime;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h b/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
index f1380d426..76b3fd614 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.5 1999/08/01 07:57:12 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.7 1999/12/03 19:17:23 eich Exp $ */
#ifndef _XF86_RESOURCES_H
@@ -8,57 +8,82 @@
#define _END {ResEnd,0,0}
-#define _VGA_EXCLUSIVE {ResExcMemBlock,0xA0000,0xAFFFF},\
- {ResExcMemBlock,0xB0000,0xB7FFF},\
- {ResExcMemBlock,0xB8000,0xBFFFF},\
- {ResExcIoBlock,0x3B0,0x3BB},\
- {ResExcIoBlock,0x3C0,0x3DF}
-
-#define _VGA_SHARED {ResShrMemBlock,0xA0000,0xAFFFF},\
- {ResShrMemBlock,0xB0000,0xB7FFF},\
- {ResShrMemBlock,0xB8000,0xBFFFF},\
- {ResShrIoBlock,0x3B0,0x3BB},\
- {ResShrIoBlock,0x3C0,0x3DF}
-
-/* exclusive unused VGA: resource uneeded but cannot be disabled. */
-/* like old Millennium */
-#define _VGA_EXCLUSIVE_UNUSED {ResExcUusdMemBlock,0xA0000,0xAFFFF},\
- {ResExcUusdMemBlock,0xB0000,0xB7FFF},\
- {ResExcUusdMemBlock,0xB8000,0xBFFFF},\
- {ResExcUusdIoBlock,0x3B0,0x3BB},\
- {ResExcUusdIoBlock,0x3C0,0x3DF}
-
-/* shared unused VGA: resources unneeded but cannot be disabled */
-/* independently. This is used to determine if a device needs rac */
-#define _VGA_SHARED_UNUSED {ResShrUusdMemBlock,0xA0000,0xAFFFF},\
- {ResShrUusdMemBlock,0xB0000,0xB7FFF},\
- {ResShrUusdMemBlock,0xB8000,0xBFFFF},\
- {ResShrUusdIoBlock,0x3B0,0x3BB},\
- {ResShrUusdIoBlock,0x3C0,0x3DF}
-
-/* Sparse versions of the above for those adapters that respond to all ISA
- * aliases of VGA ports. */
-#define _VGA_EXCLUSIVE_SPARSE {ResExcMemBlock,0xA0000,0xAFFFF},\
- {ResExcMemBlock,0xB0000,0xB7FFF},\
- {ResExcMemBlock,0xB8000,0xBFFFF},\
- {ResExcIoSparse,0x3B0,0x3F8},\
- {ResExcIoSparse,0x3B8,0x3FC},\
- {ResExcIoSparse,0x3C0,0x3E0}
-
-#define _VGA_SHARED_SPARSE {ResShrMemBlock,0xA0000,0xAFFFF},\
- {ResShrMemBlock,0xB0000,0xB7FFF},\
- {ResShrMemBlock,0xB8000,0xBFFFF},\
- {ResShrIoSparse,0x3B0,0x3F8},\
- {ResShrIoSparse,0x3B8,0x3FC},\
- {ResShrIoSparse,0x3C0,0x3E0}
-
-#define _8514_EXCLUSIVE {ResExcIoSparse,0x2E8,0x3F8}
-
-#define _8514_SHARED {ResShrIoSparse,0x2E8,0x3F8}
+#define _VGA_EXCLUSIVE \
+ {ResExcMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResExcMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResExcMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResExcIoBlock | ResBios, 0x03B0, 0x03BB},\
+ {ResExcIoBlock | ResBios, 0x03C0, 0x03DF}
+
+#define _VGA_SHARED \
+ {ResShrMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResShrIoBlock | ResBios, 0x03B0, 0x03BB},\
+ {ResShrIoBlock | ResBios, 0x03C0, 0x03DF}
+
+#define _VGA_SHARED_MEM \
+ {ResShrMemBlock | ResBios, 0xA0000, 0xAFFFF},\
+ {ResShrMemBlock | ResBios, 0xB0000, 0xB7FFF},\
+ {ResShrMemBlock | ResBios, 0xB8000, 0xBFFFF}
+
+#define _VGA_SHARED_IO \
+ {ResShrIoBlock | ResBios, 0x03B0, 0x03BB},\
+ {ResShrIoBlock | ResBios, 0x03C0, 0x03DF}
+
+/*
+ * Exclusive unused VGA: resources unneeded but cannot be disabled.
+ * Like old Millennium.
+ */
+#define _VGA_EXCLUSIVE_UNUSED \
+ {ResExcUusdMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResExcUusdMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResExcUusdMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResExcUusdIoBlock | ResBios, 0x03B0, 0x03BB},\
+ {ResExcUusdIoBlock | ResBios, 0x3C0, 0x3DF}
+
+/*
+ * Shared unused VGA: resources unneeded but cannot be disabled
+ * independently. This is used to determine if a device needs RAC.
+ */
+#define _VGA_SHARED_UNUSED \
+ {ResShrUusdMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResShrUusdMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResShrUusdMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResShrUusdIoBlock | ResBios, 0x03B0, 0x03BB},\
+ {ResShrUusdIoBlock | ResBios, 0x03C0, 0x03DF}
+
+/*
+ * Sparse versions of the above for those adapters that respond to all ISA
+ * aliases of VGA ports.
+ */
+#define _VGA_EXCLUSIVE_SPARSE \
+ {ResExcMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResExcMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResExcMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResExcIoSparse | ResBios, 0x03B0, 0x03F8},\
+ {ResExcIoSparse | ResBios, 0x03B8, 0x03FC},\
+ {ResExcIoSparse | ResBios, 0x03C0, 0x03E0}
+
+#define _VGA_SHARED_SPARSE \
+ {ResShrMemBlock | ResBios, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios, 0x000B8000, 0x000BFFFF},\
+ {ResShrIoSparse | ResBios, 0x03B0, 0x03F8},\
+ {ResShrIoSparse | ResBios, 0x03B8, 0x03FC},\
+ {ResShrIoSparse | ResBios, 0x03C0, 0x03E0}
+
+#define _8514_EXCLUSIVE \
+ {ResExcIoSparse | ResBios, 0x02E8, 0x03F8}
+
+#define _8514_SHARED \
+ {ResShrIoSparse | ResBios, 0x02E8, 0x03F8}
/* predefined resources */
extern resRange resVgaExclusive[];
extern resRange resVgaShared[];
+extern resRange resVgaIoShared[];
+extern resRange resVgaMemShared[];
extern resRange resVgaUnusedExclusive[];
extern resRange resVgaUnusedShared[];
extern resRange resVgaSparseExclusive[];
@@ -72,8 +97,10 @@ extern resRange res8514Shared[];
#define RES_EXCLUSIVE_8514 res8514Exclusive
#define RES_SHARED_8514 res8514Shared
-#define _PCI_AVOID {ResExcIoSparse, 0x100, 0x300},\
- {ResExcIoSparse, 0x200, 0x200}
+#define _PCI_AVOID \
+ {ResExcIoSparse, 0x0100, 0x0300},\
+ {ResExcIoSparse, 0x0200, 0x0200},\
+ {ResExcMemBlock, 0xA0000,0xFFFFF}
extern resRange PciAvoid[];
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c b/xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c
index fd274c78b..f97643938 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1999 by The XFree86 Project, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c,v 1.6 1999/08/28 09:00:54 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c,v 1.8 1999/12/13 01:39:46 robin Exp $ */
/*
* This file contains the VidMode functions required by the extension.
@@ -405,54 +405,6 @@ VidModeGetMonitor(int scrnIndex, pointer *monitor)
return TRUE;
}
-Bool
-VidModeCheckModeClock(int scrnIndex, pointer mode, int dotClock)
-{
- ScrnInfoPtr pScrn;
- int extraFlags = 0;
- int minimumGap = CLOCK_TOLERANCE + 1;
- int i, gap;
-
- DEBUG_P("VidModeCheckModeClock");
-
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
-
- /* Clock checking code, mostly copied from the xf86LookupMode function */
- if ((dotClock < pScrn->numClocks) || (pScrn->progClock)) {
- ((DisplayModePtr)mode)->Clock = dotClock;
- } else {
- Bool allowDiv2 = FALSE; /* The driver passes these, so where do I */
- int ClockDivFactor = 1; /* them from? For now just set them to */
- int ClockMulFactor = 1; /* sensible values. maxClock set to a no. */
- int maxClock = 1000000; /* large enough so it is ignored */
-
- i = xf86GetNearestClock(pScrn, dotClock, allowDiv2,
- ClockDivFactor, ClockMulFactor, &extraFlags);
-
- if (extraFlags & V_CLKDIV2) {
- if ( ((pScrn->clock[i]/2) / 1000) > (maxClock / 1000) )
- return FALSE;
- gap = abs((dotClock * 2) -
- ((pScrn->clock[i] * ClockDivFactor) / ClockMulFactor));
- } else {
- if ( ((pScrn->clock[i]) / 1000) > (maxClock / 1000) )
- return FALSE;
- gap = abs(dotClock -
- ((pScrn->clock[i] * ClockDivFactor) / ClockMulFactor));
- }
-
- if (gap > minimumGap) {
- return FALSE;
- } else {
- ((DisplayModePtr)mode)->Clock = i;
- }
- }
- return TRUE;
- }
-
ModeStatus
VidModeCheckModeForMonitor(int scrnIndex, pointer mode)
{
@@ -480,7 +432,7 @@ VidModeCheckModeForDriver(int scrnIndex, pointer mode)
pScrn = xf86Screens[scrnIndex];
- return xf86CheckModeForMonitor((DisplayModePtr)mode, pScrn->monitor);
+ return xf86CheckModeForDriver(pScrn, (DisplayModePtr)mode, 0);
}
void
@@ -499,13 +451,7 @@ VidModeSetCrtcForMode(int scrnIndex, pointer mode)
ScreenModes = pScrn->modes;
pScrn->modes = (DisplayModePtr)mode;
- /*
- * XXXX What can we do here!!! Generally this call is from the driver
- * and so there is no way to find the value of the flags in the VidMode
- * extension. Pick INTERLACE_HALVE_V as the flags as this seems to be
- * universally used!!
- */
- xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
+ xf86SetCrtcForModes(pScrn, pScrn->adjustFlags);
pScrn->modes = ScreenModes;
return;
}
@@ -692,35 +638,35 @@ VidModeSetModeValue(pointer mode, int valtyp, int val)
return;
}
-int
+vidMonitorValue
VidModeGetMonitorValue(pointer monitor, int valtyp, int indx)
{
- int ret = 0;
+ vidMonitorValue ret;
switch (valtyp) {
case VIDMODE_MON_VENDOR:
- ret = (int)(((MonPtr)monitor)->vendor);
+ ret.ptr = (((MonPtr)monitor)->vendor);
break;
case VIDMODE_MON_MODEL:
- ret = (int)(((MonPtr)monitor)->model);
+ ret.ptr = (((MonPtr)monitor)->model);
break;
case VIDMODE_MON_NHSYNC:
- ret = ((MonPtr)monitor)->nHsync;
+ ret.i = ((MonPtr)monitor)->nHsync;
break;
case VIDMODE_MON_NVREFRESH:
- ret = ((MonPtr)monitor)->nVrefresh;
+ ret.i = ((MonPtr)monitor)->nVrefresh;
break;
case VIDMODE_MON_HSYNC_LO:
- ret = (int)(100.0 * ((MonPtr)monitor)->hsync[indx].lo);
+ ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].lo);
break;
case VIDMODE_MON_HSYNC_HI:
- ret = (int)(100.0 * ((MonPtr)monitor)->hsync[indx].hi);
+ ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].hi);
break;
case VIDMODE_MON_VREFRESH_LO:
- ret = (int)(100.0 * ((MonPtr)monitor)->vrefresh[indx].lo);
+ ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].lo);
break;
case VIDMODE_MON_VREFRESH_HI:
- ret = (int)(100.0 * ((MonPtr)monitor)->vrefresh[indx].hi);
+ ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].hi);
break;
}
return ret;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
index 7d8abf9c7..8f5061d7b 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
@@ -22,7 +22,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.52 1999/06/13 05:18:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.54 1999/12/13 23:38:11 robin Exp $ */
#include "Xfuncproto.h"
#include "Xmd.h"
@@ -62,6 +62,8 @@
#include "osdep.h" /* EnabledDevices */
+#include "xf86_OSproc.h" /* sigio stuff */
+
/******************************************************************************
* debugging macro
*****************************************************************************/
@@ -82,7 +84,14 @@ static int debug_level = 0;
#define DBG(lvl, f)
#endif
+/******************************************************************************
+ * macros
+ *****************************************************************************/
+#define ENQUEUE(e) xf86eqEnqueue((e))
+/******************************************************************************
+ * Global variables
+ *****************************************************************************/
static LocalDevicePtr switch_device = NULL;
extern DeviceAssocRec switch_assoc;
@@ -668,6 +677,7 @@ xf86eqEnqueue (xEvent *e)
#ifdef XINPUT
int count;
+ xf86AssertBlockedSIGIO ("xf86eqEnqueue");
switch (e->u.u.type) {
case KeyPress:
case KeyRelease:
@@ -685,6 +695,13 @@ xf86eqEnqueue (xEvent *e)
count = 1;
break;
default:
+#ifdef XFreeXDGA
+ if (DGAIsDgaEvent (e))
+ {
+ count = 1;
+ break;
+ }
+#endif
if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS) {
count = 1;
}
@@ -740,7 +757,12 @@ xf86eqProcessInputEvents ()
{
EventRec *e;
int x, y;
- xEvent xe;
+ struct {
+ xEvent event;
+#ifdef XINPUT
+ deviceValuator val;
+#endif
+ } xe;
#ifdef XINPUT
DeviceIntPtr dev;
int id, count;
@@ -770,27 +792,32 @@ xf86eqProcessInputEvents ()
NewCurrentScreen (xf86EventQueue.pDequeueScreen, x, y);
}
else {
- xe = e->event;
+ xe.event = e->event;
+ xe.val = e->val;
if (xf86EventQueue.head == QUEUE_SIZE - 1)
xf86EventQueue.head = 0;
else
++xf86EventQueue.head;
- switch (xe.u.u.type) {
+ switch (xe.event.u.u.type) {
case KeyPress:
case KeyRelease:
(*xf86EventQueue.pKbd->processInputProc)
- (&xe, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
break;
#ifdef XINPUT
case ButtonPress:
case ButtonRelease:
case MotionNotify:
(*(inputInfo.pointer->public.processInputProc))
- (&xe, (DeviceIntPtr)inputInfo.pointer, 1);
+ (&xe.event, (DeviceIntPtr)inputInfo.pointer, 1);
break;
default:
- dev_xe = (deviceKeyButtonPointer *) e;
+#ifdef XFreeXDGA
+ if (DGADeliverEvent (xf86EventQueue.pDequeueScreen, &xe.event))
+ break;
+#endif
+ dev_xe = (deviceKeyButtonPointer *) &xe.event;
id = dev_xe->deviceid & DEVICE_BITS;
if (!(dev_xe->deviceid & MORE_EVENTS)) {
count = 1;
@@ -809,11 +836,11 @@ xf86eqProcessInputEvents ()
FatalError("xf86eqProcessInputEvents : device has no input proc.\n");
break;
}
- (*dev->public.processInputProc)(&e->event, dev, count);
+ (*dev->public.processInputProc)(&xe.event, dev, count);
#else
default:
(*xf86EventQueue.pPtr->processInputProc)
- (&xe, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
#endif
break;
}
@@ -873,7 +900,7 @@ xf86PostMotionEvent(DeviceIntPtr device,
#ifdef XFreeXDGA
int xdelta = 0, ydelta = 0;
#endif
-
+
DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) switch=0x%x is_core=%s is_shared=%s is_absolute=%s\n",
device, device->name, switch_device,
is_core ? "True" : "False",
@@ -1018,8 +1045,7 @@ xf86PostMotionEvent(DeviceIntPtr device,
memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator, &xv->valuator0,
sizeof(INT32)*xv->num_valuators);
}
-
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
}
/* Drag is true if no buttons are down, or if there are buttons
* down and SendDragEvents is true.
@@ -1130,7 +1156,7 @@ xf86PostProximityEvent(DeviceIntPtr device,
ValuatorClassPtr val = device->valuator;
Bool is_core = xf86IsCorePointer(device);
Bool is_absolute = val && ((val->mode & 1) == Relative);
-
+
DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
device, device->name, is_in ? "true" : "false",
is_core ? "True" : "False",
@@ -1188,8 +1214,7 @@ xf86PostProximityEvent(DeviceIntPtr device,
xv->num_valuators = (loop % 6) + 1;
xv->first_valuator = first_valuator + (loop / 6) * 6;
-
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
}
}
va_end(var);
@@ -1200,8 +1225,7 @@ xf86PostProximityEvent(DeviceIntPtr device,
xv->num_valuators = 0;
xv->first_valuator = 0;
-
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
}
DBG(5, ErrorF("xf86PostProximityEvent END 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
device, device->name, is_in ? "true" : "false",
@@ -1290,7 +1314,8 @@ xf86PostButtonEvent(DeviceIntPtr device,
xf86Info.lastEventTime = xev->time = GetTimeInMillis();
xv->num_valuators = (loop % 6) + 1;
xv->first_valuator = first_valuator + (loop / 6) * 6;
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
+
}
}
va_end(var);
@@ -1300,26 +1325,20 @@ xf86PostButtonEvent(DeviceIntPtr device,
xf86Info.lastEventTime = xev->time = GetTimeInMillis();
xv->num_valuators = 0;
xv->first_valuator = 0;
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
}
}
+ /* removed rootX/rootY as DIX sets these fields */
if (is_core || is_shared) {
- /* core pointer */
- int cx, cy;
-
- GetSpritePosition(&cx, &cy);
-
xE->u.u.type = is_down ? ButtonPress : ButtonRelease;
xE->u.u.detail = device->button->map[button];
- xE->u.keyButtonPointer.rootY = cx;
- xE->u.keyButtonPointer.rootX = cy;
xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis();
#ifdef XFreeXDGA
if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, 0, 0))
#endif
- xf86eqEnqueue (xE);
+ ENQUEUE(xE);
}
DBG(5, ErrorF("xf86PostButtonEvent END\n"));
}
@@ -1376,7 +1395,7 @@ xf86PostKeyEvent(DeviceIntPtr device,
xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0;
xv->first_valuator = first_valuator + (loop / 6) * 6;
- xf86eqEnqueue(xE);
+ ENQUEUE(xE);
/* if the device is in the relative mode only one event is needed */
if (!is_absolute) break;
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h
index 7ca6f3e83..ba6303095 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h
@@ -22,7 +22,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.27 1999/06/13 05:18:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.31 1999/12/27 00:39:43 robin Exp $ */
#ifndef _xf86Xinput_h
#define _xf86Xinput_h
@@ -34,8 +34,8 @@
#include "Xproto.h"
#include "inputstr.h"
#ifdef XINPUT
-#include "XI.h"
-#include "XIproto.h"
+#include "extensions/XI.h"
+#include "extensions/XIproto.h"
#include "XIstubs.h"
#endif
@@ -61,10 +61,6 @@
#define XI_PRIVATE(dev) \
(((LocalDevicePtr)((dev)->public.devicePrivate))->private)
-#ifndef NEW_INPUT
-#define MOUSE_DEV(dev) (MouseDevPtr) XI_PRIVATE(dev)
-#endif
-
#ifdef DBG
#undef DBG
#endif
@@ -181,6 +177,8 @@ void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval,
int maxval, int resolution, int min_res,
int max_res);
void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
+void xf86AddEnabledDevice(InputInfoPtr pInfo);
+void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
/* xf86Helper.c */
void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
index 32e11ecd9..4436186ec 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.16 1999/08/01 07:57:12 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.18 1999/11/12 02:11:13 mvojkovi Exp $ */
#ifdef _XOPEN_SOURCE
#include <math.h>
@@ -37,7 +37,7 @@
#define LOAD_PALETTE(pmap, index) \
((pmap == miInstalledMaps[index]) && \
((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
- (xf86Screens[index]->vtSema || pScreenPriv->isDGAmode)))
+ xf86Screens[index]->vtSema || pScreenPriv->isDGAmode))
typedef struct _CMapLink {
@@ -170,9 +170,11 @@ Bool xf86HandleColormaps(
pScreenPriv->SwitchMode = pScrn->SwitchMode;
pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
- pScrn->EnterVT = CMapEnterVT;
- if(flags & CMAP_RELOAD_ON_MODE_SWITCH)
- pScrn->SwitchMode = CMapSwitchMode;
+ if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
+ pScrn->EnterVT = CMapEnterVT;
+ if (flags & CMAP_RELOAD_ON_MODE_SWITCH)
+ pScrn->SwitchMode = CMapSwitchMode;
+ }
#ifdef XFreeXDGA
pScrn->SetDGAMode = CMapSetDGAMode;
#endif
@@ -463,7 +465,7 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
pScreenPriv->isDGAmode = DGAActive(index);
- if(miInstalledMaps[index])
+ if(!pScreenPriv->isDGAmode && miInstalledMaps[index])
CMapReinstallMap(miInstalledMaps[index]);
return ret;
@@ -889,7 +891,8 @@ CMapChangeGamma(
}
if(miInstalledMaps[pScreen->myNum] &&
- (pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
if(!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
index dbbd20b1e..7e0e604c7 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.12 1999/06/27 14:07:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.13 1999/11/28 20:29:37 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -395,7 +395,7 @@ xf86ResizeOffscreenArea(
BoxRec OrigArea;
RegionRec FreedReg;
FBAreaPtr area = NULL;
- FBLinkPtr pLink, pLinkPrev = NULL;
+ FBLinkPtr pLink, newLink, pLinkPrev = NULL;
if(!resize || !xf86FBManagerRunning(resize->pScreen))
return FALSE;
@@ -460,7 +460,25 @@ xf86ResizeOffscreenArea(
resize->MoveAreaCallback, resize->RemoveAreaCallback,
resize->devPrivate.ptr))) {
- xfree(pLink);
+ /* copy data over to our link and replace the new with old */
+ memcpy(resize, area, sizeof(FBArea));
+
+ pLinkPrev = NULL;
+ newLink = offman->UsedAreas;
+
+ while(&(newLink->area) != area) {
+ pLinkPrev = newLink;
+ newLink = newLink->next;
+ }
+
+ if(pLinkPrev)
+ pLinkPrev->next = newLink->next;
+ else offman->UsedAreas = newLink->next;
+
+ pLink->next = offman->UsedAreas;
+ offman->UsedAreas = pLink;
+
+ xfree(newLink);
/* AllocateArea added one but we really only exchanged one */
offman->NumUsedAreas--;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c b/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c
new file mode 100644
index 000000000..ad71fafb0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c
@@ -0,0 +1,107 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.2 1999/12/06 03:52:40 robin Exp $ */
+
+/*
+ * Copyright (c) 1997-1999 by The XFree86 Project, Inc.
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+
+/*
+ * If the slot requested is already in use, return FALSE.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p;
+ BusAccPtr pbap = xf86BusAccInfo;
+ int num;
+
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->busType = BUS_ISA;
+ p->device = dev;
+ p->active = active;
+ p->inUse = FALSE;
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ p->busAcc = NULL;
+ while (pbap) {
+ if (pbap->type == BUS_ISA)
+ p->busAcc = pbap;
+ pbap = pbap->next;
+ }
+ return num;
+}
+
+/*
+ * Get the list of ISA "slots" claimed by a screen
+ *
+ * Note: The ISA implementation here assumes that only one ISA "slot" type
+ * can be claimed by any one screen. That means a return value other than
+ * 0 or 1 isn't useful.
+ */
+int
+xf86GetIsaInfoForScreen(int scrnIndex)
+{
+ int num = 0;
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) {
+ p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]];
+ if (p->busType == BUS_ISA) {
+ num++;
+ }
+ }
+ return num;
+}
+
+/*
+ * Parse a BUS ID string, and return True if it is a ISA bus id.
+ */
+
+Bool
+xf86ParseIsaBusString(const char *busID)
+{
+ /*
+ * The format assumed to be "isa" or "isa:"
+ */
+ return (StringToBusType(busID,NULL) == BUS_ISA);
+}
+
+
+/*
+ * xf86IsPrimaryIsa() -- return TRUE if primary device
+ * is ISA.
+ */
+
+Bool
+xf86IsPrimaryIsa(void)
+{
+ return ( primaryBus.type == BUS_ISA );
+}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
new file mode 100644
index 000000000..5f6a7fe14
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
@@ -0,0 +1,2418 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.2 1999/12/06 03:52:40 robin Exp $ */
+
+/*
+ * Copyright (c) 1997-1999 by The XFree86 Project, Inc.
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+#define DEBUG
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "X.h"
+#include "os.h"
+#include "xf86Pci.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+/* Bus-specific headers */
+#define DECLARE_CARD_DATASTRUCTURES TRUE
+#include "xf86PciInfo.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+resRange PciAvoid[] = {_PCI_AVOID, _END};
+
+/* Bus-specific globals */
+pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */
+pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */
+pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */
+
+/* PCI buses */
+static PciBusPtr xf86PciBus = NULL;
+/* Bus-specific probe/sorting functions */
+
+/* PCI classes that get included in xf86PciVideoInfo */
+#define PCIINFOCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC) || \
+ ((b) == PCI_CLASS_DISPLAY) || \
+ ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO) || \
+ ((b) == PCI_CLASS_PROCESSOR && (s) == PCI_SUBCLASS_PROCESSOR_COPROC))
+
+/*
+ * PCI classes that have messages printed always. The others are only
+ * have a message printed when the vendor/dev IDs are recognised.
+ */
+#define PCIALWAYSPRINTCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
+ ((b) == PCI_CLASS_DISPLAY) || \
+ ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO))
+
+/*
+ * PCI classes for which potentially destructive checking of the map sizes
+ * may be done. Any classes where this may be unsafe should be omitted
+ * from this list.
+ */
+#define PCINONSYSTEMCLASSES(b,s) PCIALWAYSPRINTCLASSES(b,s)
+
+/*
+ * PCI classes that use RAC
+ */
+#define PCISHAREDIOCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
+ ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA))
+
+#define PCI_MEM32_LENGTH_MAX 0xFFFFFFFF
+
+#undef MIN
+#define MIN(x,y) ((x<y)?x:y)
+
+SymTabPtr xf86PCIVendorNameInfo;
+pciVendorCardInfo *xf86PCICardInfo;
+pciVendorDeviceInfo * xf86PCIVendorInfo;
+
+static void
+FindPCIVideoInfo(void)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ int i = 0, j, k;
+ int num = 0;
+ pciVideoPtr info;
+ Bool mem64 = FALSE;
+
+ pcrpp = xf86PciInfo = xf86scanpci(0);
+
+ if (pcrpp == NULL) {
+ xf86PciVideoInfo = NULL;
+ return;
+ }
+ xf86PciBus = xf86GetPciBridgeInfo(xf86PciInfo);
+
+ while ((pcrp = pcrpp[i])) {
+ if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class)) {
+ num++;
+ xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
+ sizeof(pciVideoPtr) * (num + 1));
+ xf86PciVideoInfo[num] = NULL;
+ info = xf86PciVideoInfo[num - 1] = xnfalloc(sizeof(pciVideoRec));
+ info->validSize = FALSE;
+ info->vendor = pcrp->pci_vendor;
+ info->chipType = pcrp->pci_device;
+ info->chipRev = pcrp->pci_rev_id;
+ info->subsysVendor = pcrp->pci_subsys_vendor;
+ info->subsysCard = pcrp->pci_subsys_card;
+ info->bus = pcrp->busnum;
+ info->device = pcrp->devnum;
+ info->func = pcrp->funcnum;
+ info->class = pcrp->pci_base_class;
+ info->subclass = pcrp->pci_sub_class;
+ info->interface = pcrp->pci_prog_if;
+ info->biosBase = PCIGETROM(pcrp->pci_baserom);
+ info->biosSize = pciGetBaseSize(pcrp->tag, 6, TRUE, NULL);
+ info->thisCard = pcrp;
+ info->validate = FALSE;
+ if ((PCISHAREDIOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
+ && (pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
+ (pcrp->pci_prog_if == 0)) {
+ /* assumption: primary bus is always VGA */
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci.bus = pcrp->busnum;
+ primaryBus.id.pci.device = pcrp->devnum;
+ primaryBus.id.pci.func = pcrp->funcnum;
+ }
+
+ for (j = 0; j < 6; j++) {
+ info->memBase[j] = 0;
+ info->ioBase[j] = 0;
+ if (PCINONSYSTEMCLASSES(info->class, info->subclass)) {
+ info->size[j] = pciGetBaseSize(pcrp->tag, j, TRUE,
+ &info->validSize);
+ } else {
+ info->size[j] = pcrp->basesize[j];
+ info->validSize = pcrp->minBasesize;
+ }
+ /* pciGetBaseSize(pcrp->tag, j, FALSE, NULL) */
+ info->type[j] = 0;
+ }
+
+ /*
+ * 64-bit base addresses are checked for and avoided.
+ * XXX Should deal with them on platforms that support them.
+ */
+
+ if (pcrp->pci_base0) {
+ if (pcrp->pci_base0 & PCI_MAP_IO) {
+ info->ioBase[0] = (memType)PCIGETIO(pcrp->pci_base0);
+ info->type[0] = pcrp->pci_base0 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[0] = pcrp->pci_base0 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[0] = (memType)PCIGETMEMORY(pcrp->pci_base0);
+ if (PCI_MAP_IS64BITMEM(pcrp->pci_base0)) {
+ mem64 = TRUE;
+#if defined LONG64 || defined WORD64
+ info->memBase[0] |=
+ (memType)PCIGETMEMORY64HIGH(pcrp->pci_base0) << 32;
+#else
+ info->memBase[0] = 0;
+#endif
+ }
+ }
+ }
+
+ if (pcrp->pci_base1 && !mem64) {
+ if (pcrp->pci_base1 & PCI_MAP_IO) {
+ info->ioBase[1] = (memType)PCIGETIO(pcrp->pci_base1);
+ info->type[1] = pcrp->pci_base1 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[1] = pcrp->pci_base1 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[1] = (memType)PCIGETMEMORY(pcrp->pci_base1);
+ if (PCI_MAP_IS64BITMEM(pcrp->pci_base1)) {
+ mem64 = TRUE;
+#if defined LONG64 || defined WORD64
+ info->memBase[1] |=
+ (memType)PCIGETMEMORY64HIGH(pcrp->pci_base1) << 32;
+#else
+ info->memBase[1] = 0;
+#endif
+ }
+ }
+ } else if (mem64)
+ mem64 = FALSE;
+
+ if (pcrp->pci_base2 && !mem64) {
+ if (pcrp->pci_base2 & PCI_MAP_IO) {
+ info->ioBase[2] = (memType)PCIGETIO(pcrp->pci_base2);
+ info->type[2] = pcrp->pci_base2 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[2] = pcrp->pci_base2 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[2] = (memType)PCIGETMEMORY(pcrp->pci_base2);
+ if (PCI_MAP_IS64BITMEM(pcrp->pci_base2)) {
+ mem64 = TRUE;
+#if defined LONG64 || defined WORD64
+ info->memBase[1] |=
+ (memType)PCIGETMEMORY64HIGH(pcrp->pci_base1) << 32;
+#else
+ info->memBase[1] = 0;
+#endif
+ }
+ }
+ } else if (mem64)
+ mem64 = FALSE;
+
+ if (pcrp->pci_base3 && !mem64) {
+ if (pcrp->pci_base3 & PCI_MAP_IO) {
+ info->ioBase[3] = (memType)PCIGETIO(pcrp->pci_base3);
+ info->type[3] = pcrp->pci_base3 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[3] = pcrp->pci_base3 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[3] = (memType)PCIGETMEMORY(pcrp->pci_base3);
+ if (PCI_MAP_IS64BITMEM(pcrp->pci_base3)) {
+ mem64 = TRUE;
+#if defined LONG64 || defined WORD64
+ info->memBase[3] |=
+ (memType)PCIGETMEMORY64HIGH(pcrp->pci_base3) << 32;
+#else
+ info->memBase[3] = 0;
+#endif
+ }
+ }
+ } else if (mem64)
+ mem64 = FALSE;
+
+ if (pcrp->pci_base4 && !mem64) {
+ if (pcrp->pci_base4 & PCI_MAP_IO) {
+ info->ioBase[4] = (memType)PCIGETIO(pcrp->pci_base4);
+ info->type[4] = pcrp->pci_base4 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[4] = pcrp->pci_base4 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[4] = (memType)PCIGETMEMORY(pcrp->pci_base4);
+ if (PCI_MAP_IS64BITMEM(pcrp->pci_base4)) {
+ mem64 = TRUE;
+#if defined LONG64 || defined WORD64
+ info->memBase[4] |=
+ (memType)PCIGETMEMORY64HIGH(pcrp->pci_base4) << 32;
+#else
+ info->memBase[4] = 0;
+#endif
+ }
+ }
+ } else if (mem64)
+ mem64 = FALSE;
+
+ if (pcrp->pci_base5 && !mem64) {
+ if (pcrp->pci_base5 & PCI_MAP_IO) {
+ info->ioBase[5] = (memType)PCIGETIO(pcrp->pci_base5);
+ info->type[5] = pcrp->pci_base5 & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[5] = pcrp->pci_base5 & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[5] = (memType)PCIGETMEMORY(pcrp->pci_base5);
+ }
+ }
+ }
+ i++;
+ }
+
+ /* Print a summary of the video devices found */
+ {
+ for (k = 0; k < num; k++) {
+ char *vendorname = NULL, *chipname = NULL;
+ Bool memdone = FALSE, iodone = FALSE;
+
+ i = 0;
+ info = xf86PciVideoInfo[k];
+ while (xf86PCIVendorNameInfo[i].token) {
+ if (xf86PCIVendorNameInfo[i].token == info->vendor)
+ vendorname = (char *)xf86PCIVendorNameInfo[i].name;
+ i++;
+ }
+ i = 0;
+ while(xf86PCIVendorInfo[i].VendorID) {
+ if (xf86PCIVendorInfo[i].VendorID == info->vendor) {
+ j = 0;
+ while (xf86PCIVendorInfo[i].Device[j].DeviceName) {
+ if (xf86PCIVendorInfo[i].Device[j].DeviceID ==
+ info->chipType) {
+ chipname =
+ xf86PCIVendorInfo[i].Device[j].DeviceName;
+ break;
+ }
+ j++;
+ }
+ break;
+ }
+ i++;
+ }
+ if ((!vendorname || !chipname) &&
+ !PCIALWAYSPRINTCLASSES(info->class, info->subclass))
+ continue;
+ xf86Msg(X_PROBED, "PCI: (%d:%d:%d) ", info->bus, info->device,
+ info->func);
+ if (vendorname)
+ ErrorF("%s ", vendorname);
+ else
+ ErrorF("unknown vendor (0x%04x) ", info->vendor);
+ if (chipname)
+ ErrorF("%s ", chipname);
+ else
+ ErrorF("unknown chipset (0x%04x) ", info->chipType);
+ ErrorF("rev %d", info->chipRev);
+ for (i = 0; i < 6; i++) {
+ if (info->memBase[i]) {
+ if (!memdone) {
+ ErrorF(", Mem @ ");
+ memdone = TRUE;
+ } else
+ ErrorF(", ");
+ ErrorF("0x%08x/%d", info->memBase[i], info->size[i]);
+ }
+ }
+ for (i = 0; i < 6; i++) {
+ if (info->ioBase[i]) {
+ if (!iodone) {
+ ErrorF(", I/O @ ");
+ iodone = TRUE;
+ } else
+ ErrorF(", ");
+ ErrorF("0x%04x/%d", info->ioBase[i], info->size[i]);
+ }
+ }
+ ErrorF("\n");
+ }
+ }
+}
+
+/*
+ * fixPciSizeInfo() -- fix pci size info by testing it destructively
+ * (if not already done), fix pciVideoInfo and entry in the resource
+ * list.
+ */
+/*
+ * Note: once we have OS support to read the sizes GetBaseSize() will
+ * have to be wrapped by the OS layer. fixPciSizeInfo() should also
+ * be wrapped by the OS layer to do nothing if the size is always
+ * returned correctly by GetBaseSize(). It should however set validate
+ * in pciVideoRec if validation is required. ValidatePci() also needs
+ * to be wrapped by the OS layer. This may do nothing if the OS has
+ * already taken care of validation. fixPciResource() may be moved to
+ * OS layer with minimal changes. Once the wrapping layer is in place
+ * the common level and drivers should not reference these functions
+ * directly but thru the OS layer.
+ */
+
+static void
+fixPciSizeInfo(int entityIndex)
+{
+ pciVideoPtr pvp;
+ resPtr pAcc;
+ PCITAG tag;
+ int j;
+
+ if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return;
+ if (pvp->validSize) return;
+
+ tag = pciTag(pvp->bus,pvp->device,pvp->func);
+
+ for (j = 0; j < 6; j++) {
+ pAcc = Acc;
+ if (pvp->memBase[j])
+ while (pAcc) {
+ if (((pAcc->res_type & (ResMem | ResBlock))
+ == (ResMem | ResBlock))
+ && (pAcc->block_begin == pvp->memBase[j]) /*@@@*/
+ && (pAcc->block_end == pvp->memBase[j] /*@@@*/
+ + (1 << (pvp->size[j])) - 1)) break;
+ pAcc = pAcc->next;
+ } else if (pvp->ioBase[j])
+ while (pAcc) {
+ if (((pAcc->res_type & (ResIo | ResBlock)) ==
+ (ResIo | ResBlock))
+ && (pAcc->block_begin == pvp->ioBase[j]) /*@@@*/
+ && (pAcc->block_end == pvp->ioBase[j] /*@@@*/
+ + (1 << (pvp->size[j])) - 1)) break;
+ pAcc = pAcc->next;
+ } else continue;
+ pvp->size[j] = pciGetBaseSize(tag, j, TRUE, &pvp->validSize);
+ if (pAcc) {
+ pAcc->block_end = pAcc->block_begin + (1 << (pvp->size[j])) - 1;
+ pAcc->res_type &= ~ResEstimated;
+ pAcc->res_type |= ResBios;
+ }
+ }
+ if (pvp->biosBase) {
+ pAcc = Acc;
+ while (pAcc) {
+ if (((pAcc->res_type & (ResMem | ResBlock)) == (ResMem | ResBlock))
+ && (pAcc->block_begin == pvp->biosBase)/*@@@*/
+ && (pAcc->block_end == pvp->biosBase/*@@@*/
+ + (1 << (pvp->biosSize)) - 1)) break;
+ pAcc = pAcc->next;
+ }
+ pvp->biosSize = pciGetBaseSize(tag, 6, TRUE, &pvp->validSize);
+ if (pAcc) {
+ pAcc->block_end = pAcc->block_begin + (1 << (pvp->biosSize))- 1;
+ pAcc->res_type &= ~ResEstimated;
+ pAcc->res_type |= ResBios;
+ }
+ }
+}
+
+/*
+ * IO enable/disable related routines for PCI
+ */
+#define SETBITS PCI_CMD_IO_ENABLE
+static void
+pciIoAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
+ SETBITS, SETBITS);
+}
+
+static void
+pciIoAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
+}
+
+#undef SETBITS
+#define SETBITS (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)
+static void
+pciIo_MemAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
+ SETBITS, SETBITS);
+}
+
+static void
+pciIo_MemAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
+}
+
+#undef SETBITS
+#define SETBITS (PCI_CMD_MEM_ENABLE)
+static void
+pciMemAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
+ SETBITS, SETBITS);
+}
+
+static void
+pciMemAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,SETBITS, 0);
+}
+#undef SETBITS
+
+#define PCI_PCI_BRDG_CTRL_BASE (PCI_PCI_BRIDGE_CONTROL_REG & 0xFC)
+#define SHIFT_BITS ((PCI_PCI_BRIDGE_CONTROL_REG & 0x3) << 3)
+#define SETBITS (CARD32)((PCI_PCI_BRIDGE_VGA_EN) << SHIFT_BITS)
+static void
+pciBusAccessEnable(BusAccPtr ptr)
+{
+ ptr->busdep.pci.func(ptr->busdep.pci.acc,PCI_PCI_BRDG_CTRL_BASE,
+ SETBITS,SETBITS);
+}
+
+static void
+pciBusAccessDisable(BusAccPtr ptr)
+{
+ ptr->busdep.pci.func(ptr->busdep.pci.acc,PCI_PCI_BRDG_CTRL_BASE,SETBITS,0);
+}
+#undef SETBITS
+#undef SHIFT_BITS
+
+static void
+pciSetBusAccess(BusAccPtr ptr)
+{
+#ifdef DEBUG
+ ErrorF("pciSetBusAccess: route VGA to bus %d\n", ptr->busdep.pci.bus);
+#endif
+
+ if (!ptr->primary && !ptr->current)
+ return;
+
+ if (ptr->current && ptr->current->disable_f)
+ ptr->current->disable_f(ptr->current);
+ ptr->current = NULL;
+
+ /* walk down */
+ while (ptr->primary) { /* no enable for top bus */
+ if (ptr->primary->current != ptr) {
+ if (ptr->primary->current && ptr->primary->current->disable_f)
+ ptr->primary->current->disable_f(ptr->primary->current);
+ if (ptr->enable_f) ptr->enable_f(ptr);
+ ptr->primary->current = ptr;
+ }
+ ptr = ptr->primary;
+ }
+}
+
+static void
+savePciState(PCITAG tag, pciSavePtr ptr)
+{
+ int i;
+
+ ptr->command = pciReadLong(tag,PCI_CMD_STAT_REG);
+ for (i=0; i < 6; i++)
+ ptr->base[i] = pciReadLong(tag,PCI_CMD_BASE_REG + i*4 );
+ ptr->biosBase = pciReadLong(tag,PCI_CMD_BIOS_REG);
+}
+
+static void
+restorePciState(PCITAG tag, pciSavePtr ptr)
+{
+ int i;
+
+ /* disable card before setting anything */
+ pciSetBitsLong(tag, PCI_CMD_STAT_REG, PCI_CMD_MEM_ENABLE
+ | PCI_CMD_IO_ENABLE , 0);
+ pciWriteLong(tag,PCI_CMD_BIOS_REG,ptr->biosBase);
+ for (i=0; i<6; i++)
+ pciWriteLong(tag,PCI_CMD_BASE_REG + i*4, ptr->base[i]);
+ pciWriteLong(tag,PCI_CMD_STAT_REG,ptr->command);
+}
+
+static void
+savePciBusState(BusAccPtr ptr)
+{
+ ptr->busdep.pci.save.io =
+ pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_IO_REG);
+ ptr->busdep.pci.save.mem =
+ pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_MEM_REG);
+ ptr->busdep.pci.save.pmem =
+ pciReadWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_PMEM_REG);
+ ptr->busdep.pci.save.control =
+ pciReadByte(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_CONTROL_REG);
+}
+
+static void
+restorePciBusState(BusAccPtr ptr)
+{
+ pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_IO_REG,
+ ptr->busdep.pci.save.io);
+ pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_MEM_REG,
+ ptr->busdep.pci.save.mem);
+ pciWriteWord(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_PMEM_REG,
+ ptr->busdep.pci.save.pmem);
+ pciWriteByte(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_CONTROL_REG,
+ ptr->busdep.pci.save.control);
+}
+
+
+static void
+disablePciBios(PCITAG tag)
+{
+ pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0);
+}
+
+static void
+correctPciSize(memType base, int oldsize, int newsize, long type)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ pciVideoPtr pvp, *pvpp;
+ CARD32 *basep;
+ int i;
+ int old_bits =0, new_bits = 0;
+
+ while (oldsize & 1) {
+ old_bits ++;
+ oldsize >>= 1;
+ }
+ while (newsize & 1) {
+ new_bits ++;
+ newsize >>= 1;
+ }
+
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+
+ /* Only process devices with type 0 headers */
+ if ((pcrp->pci_header_type & 0x7f) != 0)
+ continue;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ int j = i;
+ if (basep[i] && (pcrp->basesize[i] == old_bits))
+ if (((type & ResIo) && PCI_MAP_IS_IO(basep[i])
+ && (PCIGETIO(basep[i]) == base))
+ || ((type & ResMem) && PCI_MAP_IS_MEM(basep[i])
+ && (((!PCI_MAP_IS64BITMEM(basep[i]))
+ && (PCIGETMEMORY(basep[i]) == base))
+#if defined LONG64 || defined WORD64
+ || (((PCIGETMEMORY(basep[i])
+ | ((memType)basep[++i] << 32)) == base))
+#endif
+ ))) {
+ pcrp->basesize[j] = new_bits;
+ return;
+ }
+ }
+ }
+
+ if (xf86PciVideoInfo)
+ for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->size[i] == old_bits) {
+ if (((type & ResIo) && pvp->ioBase[i]
+ && (pvp->ioBase[i] == base)) ||
+ ((type & ResMem) && pvp->memBase[i]
+ && (pvp->memBase[i] == base))) {
+ pvp->size[i] = new_bits;
+ return;
+ }
+ }
+ }
+ }
+}
+
+static void
+removeOverlapsWithBridges(int busIndex, resPtr target)
+{
+ PciBusPtr pbp;
+ resPtr tmp,bridgeRes = NULL;
+ resRange range = target->val;
+
+ if (!ResIsEstimated(&target->val))
+ return;
+
+ for (pbp=xf86PciBus; pbp; pbp = pbp->next) {
+ if (pbp->primary == busIndex) {
+ tmp = xf86DupResList(pbp->io);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ tmp = xf86DupResList(pbp->mem);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ tmp = xf86DupResList(pbp->pmem);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ }
+ }
+
+ RemoveOverlaps(target,bridgeRes,TRUE);
+ if (range.rEnd > target->block_end) {
+ correctPciSize(range.rBegin,range.rEnd - range.rBegin,
+ target->block_end - target->block_begin,
+ target->res_type);
+ }
+ xf86FreeResList(bridgeRes);
+}
+
+static void
+xf86GetPciRes(resPtr *activeRes, resPtr *inactiveRes)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ pciVideoPtr pvp, *pvpp;
+ CARD32 *basep;
+ int i;
+ resPtr pRes, tmp;
+ resRange range;
+ long resMisc;
+
+ if (activeRes)
+ *activeRes = NULL;
+ if (inactiveRes)
+ *inactiveRes = NULL;
+
+ if (!activeRes || !inactiveRes || !xf86PciInfo)
+ return;
+
+ if (xf86PciVideoInfo)
+ for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
+ resPtr *res;
+
+ if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
+ resMisc = ResBios;
+ else
+ resMisc = 0;
+
+ if (((pciConfigPtr)pvp->thisCard)->pci_command
+ & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))
+ res = activeRes;
+ else
+ res = inactiveRes;
+
+ if (!pvp->validSize)
+ resMisc |= ResEstimated;
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->ioBase[i]) {
+ RANGE(range, pvp->ioBase[i],/*@@@*/
+ pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcIoBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ } else if (pvp->memBase[i]) {
+ RANGE(range, pvp->memBase[i],/*@@@*/
+ pvp->memBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcMemBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+ /* FIXME!!!: Don't use BIOS resources for overlap
+ * checking but reserve them!
+ */
+ if (pvp->biosBase) {
+ RANGE(range, pvp->biosBase,/*@@@*/
+ pvp->biosBase + (1 << pvp->biosSize) - 1,
+ ResExcMemBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+ resPtr *res;
+
+ if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
+ continue;
+
+ /* Only process devices with type 0 headers */
+ if ((pcrp->pci_header_type & 0x7f) != 0)
+ continue;
+
+ if (!pcrp->minBasesize)
+ resMisc = ResEstimated;
+ else
+ resMisc = 0;
+
+ if ((pcrp->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)))
+ res = activeRes;
+ else
+ res = inactiveRes;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ if (basep[i]) {
+ if (PCI_MAP_IS_IO(basep[i]))
+ RANGE(range,PCIGETIO(basep[i]),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[i]) - 1,
+ ResExcIoBlock | resMisc)
+ else if (!PCI_MAP_IS64BITMEM(basep[i]))
+ RANGE(range,PCIGETMEMORY(basep[i]),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[i]) - 1,
+ ResExcMemBlock | resMisc)
+ else {
+ i++;
+#if defined LONG64 || defined WORD64
+ RANGE(range,PCIGETMEMORY(basep[i-1])/*@@@*/
+ | ((memType)basep[i] << 32),
+ range.rBegin + (1<<pcrp->basesize[i-1]) - 1,
+ ResExcMemBlock | resMisc)
+#else
+ continue;
+#endif
+ }
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pcrp->busnum,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+ if (pcrp->pci_baserom) {
+ RANGE(range,PCIGETROM(pcrp->pci_baserom),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[6]) - 1,
+ ResExcMemBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pcrp->busnum,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+
+ if (*activeRes) {
+ xf86MsgVerb(X_INFO, 3, "Active PCI resource ranges:\n");
+ xf86PrintResList(3, *activeRes);
+ }
+ if (*inactiveRes) {
+ xf86MsgVerb(X_INFO, 3, "Inactive PCI resource ranges:\n");
+ xf86PrintResList(3, *inactiveRes);
+ }
+
+ /*
+ * Adjust ranges based on the assumption that there are no real
+ * overlaps in the PCI base allocations. This assumption should be
+ * reasonable in most cases. It may be possible to refine the
+ * approximated PCI base sizes by considering bus mapping information
+ * from PCI-PCI bridges.
+ */
+
+ if (*activeRes) {
+ /* Check for overlaps */
+ for (pRes = *activeRes; pRes; pRes = pRes->next) {
+ if (ResIsEstimated(&pRes->val)) {
+ range = pRes->val;
+
+ RemoveOverlaps(pRes, *activeRes, TRUE);
+ if (xf86EstimateSizesAggressively > 0)
+ RemoveOverlaps(pRes, *inactiveRes, TRUE);
+
+ if (range.rEnd > pRes->block_end) {
+ correctPciSize(range.rBegin,range.rEnd - range.rBegin,
+ pRes->block_end - pRes->block_begin,
+ pRes->res_type);
+ xf86MsgVerb(X_INFO, 3,
+ "PCI %s resource overlap reduced 0x%08x"
+ " from 0x%08x to 0x%08x\n",
+ (pRes->res_type & ResMem) ? "Memory" : "I/O",
+ range.rBegin, range.rEnd, pRes->block_end);
+ }
+ }
+ }
+ xf86MsgVerb(X_INFO, 3,
+ "Active PCI resource ranges after removing overlaps:\n");
+ xf86PrintResList(3, *activeRes);
+ }
+
+ if (*inactiveRes && (xf86EstimateSizesAggressively > 1)) {
+ /* Check for overlaps */
+ for (pRes = *inactiveRes; pRes; pRes = pRes->next) {
+ if (ResIsEstimated(&pRes->val)) {
+ range = pRes->val;
+
+ RemoveOverlaps(pRes, *activeRes, TRUE);
+ RemoveOverlaps(pRes, *inactiveRes, TRUE);
+
+ if (range.rEnd > pRes->block_end) {
+ correctPciSize(range.rBegin,range.rEnd - range.rBegin,
+ pRes->block_end - pRes->block_begin,
+ pRes->res_type);
+ xf86MsgVerb(X_INFO, 3,
+ "PCI %s resource overlap reduced 0x%08x"
+ " from 0x%08x to 0x%08x\n",
+ (pRes->res_type & ResMem) ? "Memory" : "I/O",
+ range.rBegin, range.rEnd, pRes->block_end);
+ }
+
+ }
+ }
+ xf86MsgVerb(X_INFO, 3,
+ "Ative PCI resource ranges after removing overlaps:\n");
+ xf86PrintResList(3, *inactiveRes);
+ }
+}
+
+resPtr
+ResourceBrokerInitPci(resPtr *osRes)
+{
+ resPtr activeRes, inactiveRes;
+ resPtr tmp;
+
+ /* Get bus-specific system resources (PCI) */
+ xf86GetPciRes(&activeRes, &inactiveRes);
+
+ /*
+ * Adjust OS-reported resource ranges based on the assumption that there
+ * are no overlaps with the PCI base allocations. This should be a good
+ * assumption because writes to PCI address space won't be routed directly
+ * host memory.
+ */
+
+ for (tmp = *osRes; tmp; tmp = tmp->next)
+ RemoveOverlaps(tmp, activeRes, FALSE);
+
+ xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges after removing"
+ " overlaps with PCI:\n");
+ xf86PrintResList(3, *osRes);
+
+ return (xf86JoinResLists(activeRes,inactiveRes));
+}
+
+
+/*
+ * PCI Resource modification
+ */
+static Bool
+fixPciResource(int prt, memType alignment, pciVideoPtr pvp, long type)
+{
+ int res_n;
+ memType *p_base;
+ int *p_size;
+ unsigned char p_type;
+ resPtr AccTmp = NULL;
+ resPtr *pAcc = &AccTmp;
+ resPtr avoid = NULL;
+ resList p_avoid = PciAvoid;
+ resRange range;
+ resPtr resSize = NULL;
+ resPtr w_tmp, w = NULL, w_2nd = NULL;
+ PCITAG tag;
+ PciBusPtr pbp = xf86PciBus, pbp1 = xf86PciBus;
+ resPtr tmp;
+
+ if (!pvp) return FALSE;
+
+ type &= ResAccMask;
+ if (!type) type = ResShared;
+ if (prt < 6) {
+ if (pvp->memBase[prt]) {
+ type |= ResMem;
+ res_n = prt;
+ p_base = &(pvp->memBase[res_n]);
+ p_size = &(pvp->size[res_n]);
+ p_type = pvp->type[res_n];
+ if (!PCI_MAP_IS64BITMEM(pvp->type[res_n])) {
+ RANGE(range,0,0xffffffff,ResExcMemBlock);/*@@@*/
+ resSize = xf86AddResToList(resSize,&range,-1);
+ }
+ } else if (pvp->ioBase[prt]){
+ type |= ResIo;
+ res_n = prt;
+ p_base = &(pvp->ioBase[res_n]);
+ p_size = &(pvp->size[res_n]);
+ p_type = pvp->type[res_n];
+ } else return FALSE;
+ } else if (prt == 6) {
+ type |= ResMem;
+ res_n = 0xff; /* special flag for bios rom */
+ p_base = &(pvp->biosBase);
+ p_size = &(pvp->biosSize);
+ /* XXX This should also include the PCI_MAP_MEMORY_TYPE_MASK part */
+ p_type = 0;
+ RANGE(range,0,0xffffffff,ResExcMemBlock);/*@@@*/
+ resSize = xf86AddResToList(resSize,&range,-1);
+ } else return FALSE;
+
+ if (! *p_base) return FALSE;
+
+ type |= ResBlock;
+
+ /* setup avoid */
+ avoid = xf86AddRangesToList(avoid,p_avoid,-1);
+
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if (type & ResMem) {
+ if (((p_type & PCI_MAP_MEMORY_CACHABLE)
+#if 0 /*EE*/
+ || (res_n == 0xff)/* bios should also be prefetchable */
+#endif
+ )
+ && pbp->pmem) {
+ w = xf86FindIntersectOfLists(pbp->pmem,ResRange);
+ if (pbp->mem) {
+ w_2nd = xf86FindIntersectOfLists(pbp->mem,ResRange);
+ }
+ } else if (pbp->mem) {
+ w = xf86FindIntersectOfLists(pbp->mem,ResRange);
+ }
+ } else if (pbp->io) {
+ w = xf86FindIntersectOfLists(pbp->io,ResRange);
+ }
+
+ while (pbp1) {
+ if (pbp1->primary == pvp->bus) {
+ if (type & ResMem) {
+ tmp = xf86DupResList(pbp1->pmem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ tmp = xf86DupResList(pbp1->mem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ } else {
+ tmp = xf86DupResList(pbp1->io);
+ avoid = xf86JoinResLists(avoid,tmp);
+ }
+ }
+ pbp1 = pbp1->next;
+ }
+ break;
+ }
+ pbp = pbp->next;
+ }
+
+ if (!w)
+ w = xf86DupResList(ResRange);
+ xf86MsgVerb(X_INFO, 3, "window:\n");
+ xf86PrintResList(3, w);
+ xf86MsgVerb(X_INFO, 3, "resSize:\n");
+ xf86PrintResList(3, resSize);
+
+ if (resSize) {
+ w_tmp = w;
+ w = xf86FindIntersectOfLists(w,resSize);
+ xf86FreeResList(w_tmp);
+ if (w_2nd) {
+ w_tmp = w_2nd;
+ w_2nd = xf86FindIntersectOfLists(w_2nd,resSize);
+ xf86FreeResList(w_tmp);
+ }
+ xf86FreeResList(resSize);
+ }
+ xf86MsgVerb(X_INFO, 3, "window fixed:\n");
+ xf86PrintResList(3, w);
+
+ if (!alignment)
+ alignment = (1 << (*p_size)) - 1;
+
+ /* Access list holds bios resources -- remove this one */
+#ifdef NOTYET
+ AccTmp = xf86DupResList(Acc);
+ while ((*pAcc)) {
+ if ((((*pAcc)->res_type & (type & ~ResAccMask))
+ == (type & ~ResAccMask))
+ && ((*pAcc)->block_begin == (*p_base))/*@@@*/
+ && ((*pAcc)->block_end == (*p_base) + (1 << (*p_size)) - 1)) {
+ resPtr acc_tmp = (*pAcc)->next;
+ xfree((*pAcc));
+ (*pAcc) = acc_tmp;
+ break;
+ } else
+ pAcc = &((*pAcc)->next);
+ }
+ /* check if we really need to fix anything */
+ RANGE(range, (*p_base), (*p_base) + (1 << (*p_size)) - 1, type);/*@@@*/
+ if (!ChkConflict(&range,avoid,SETUP)
+ && !ChkConflict(&range,AccTmp,SETUP)
+ && (((*p_base) & alignment) == (*p_base)->block_begin)/*@@@*/
+ && ((isSubsetOf(range,w)
+ || (w_2nd && isSubsetOf(range,w_2n))))) {
+#ifdef DEBUG
+ ErrorF("nothing to fix\n");
+#endif
+ xf86FreeResList(AccTmp);
+ xf86FreeResList(w);
+ xf86FreeResList(w_2nd);
+ xf86FreeResList(avoid);
+ return TRUE;
+ } else {
+#ifdef DEBUG
+ ErrorF("removing old resource\n");
+#endif
+ xf86FreeResList(Acc);
+ Acc = AccTmp;
+ }
+#else
+ pAcc = &Acc;
+ while ((*pAcc)) {
+ if ((((*pAcc)->res_type & (type & ~ResAccMask))
+ == (type & ~ResAccMask))
+ && ((*pAcc)->block_begin == (*p_base))/*@@@*/
+ && ((*pAcc)->block_end == (*p_base) + (1 << (*p_size)) - 1)) {
+#ifdef DEBUG
+ ErrorF("removing old resource\n");
+#endif
+ (*pAcc) = (*pAcc)->next;
+ break;
+ } else
+ pAcc = &((*pAcc)->next);
+ }
+#endif
+
+#ifdef DEBUG
+ ErrorF("base: 0x%lx alignment: 0x%lx size[bit]: 0x%x\n",
+ (*p_base),alignment,(*p_size));
+ xf86MsgVerb(X_INFO, 3, "window:\n");
+ xf86PrintResList(3, w);
+ if (w_2nd)
+ xf86MsgVerb(X_INFO, 3, "2nd window:\n");
+ xf86PrintResList(3, w_2nd);
+ xf86ErrorFVerb(3,"avoid:\n");
+ xf86PrintResList(3,avoid);
+#endif
+ w_tmp = w;
+ while (w) {
+ if (type & w->res_type & ResPhysMask) {
+#ifdef DEBUG
+ ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w->block_begin,
+ w->block_end);
+#endif
+ range = xf86GetBlock(type,alignment + 1, w->block_begin,
+ w->block_end, alignment,avoid);
+ if (range.type != ResEnd)
+ break;
+ }
+ w = w->next;
+ }
+ xf86FreeResList(w_tmp);
+ /* if unsuccessful and memory prefetchable try non-prefetchable */
+ if (range.type == ResEnd && w_2nd) {
+ w_tmp = w_2nd;
+ while (w_2nd) {
+ if (type & w_2nd->res_type & ResPhysMask) {
+#ifdef DEBUG
+ ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w_2nd->block_begin,
+ w_2nd->block_end);
+#endif
+ range = xf86GetBlock(type,alignment + 1, w_2nd->block_begin,
+ w_2nd->block_end,alignment,avoid);
+ if (range.type != ResEnd)
+ break;
+ }
+ w_2nd = w_2nd->next;
+ }
+ xf86FreeResList(w_tmp);
+ }
+ xf86FreeResList(avoid);
+
+ if (range.type == ResEnd) {
+ xf86MsgVerb(X_ERROR,3,"Cannot find a replacement memory range\n");
+ return FALSE;
+ }
+#ifdef DEBUG
+ ErrorF("begin: 0x%lx, end: 0x%lx\n",range.a,range.b);
+#endif
+
+ (*p_size) = 0;
+ while (alignment >> (*p_size))
+ (*p_size)++;
+ (*p_base) = range.rBegin;/*@@@*/
+
+#ifdef DEBUG
+ ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n",
+ res_n,(*p_base),(1 << (*p_size)),type | ResMem ? "Mem" : "Io");
+#endif
+ tag = pciTag(pvp->bus,pvp->device,pvp->func);
+
+ if (res_n != 0xff) {
+ pciWriteLong(tag,PCI_CMD_BASE_REG + res_n * sizeof(CARD32),
+ (CARD32)(*p_base) | (CARD32)(p_type));
+#if defined LONG64 || defined WORD64
+ if (PCI_MAP_IS64BITMEM(p_type))
+ pciWriteLong(tag,PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32),
+ (CARD32)(*p_base >> 32));
+#endif
+ } else {
+ CARD32 val = pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01;
+ pciWriteLong(tag,PCI_CMD_BIOS_REG,(CARD32)(*p_base) | val);
+ }
+ /* @@@ fake BIOS allocated resource */
+ range.type |= ResBios;
+ Acc = xf86AddResToList(Acc, &range,-1);
+
+ return TRUE;
+
+}
+
+Bool
+xf86FixPciResource(int entityIndex, int prt, memType alignment,
+ long type)
+{
+ pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
+ return fixPciResource(prt, alignment, pvp, type);
+}
+
+resPtr
+xf86ReallocatePciResources(int entityIndex, resPtr pRes)
+{
+ pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
+ resPtr pBad = NULL,pResTmp;
+ unsigned int prt = 0;
+ int i;
+
+ if (!pvp) return pRes;
+
+ while (pRes) {
+ switch (pRes->res_type & ResPhysMask) {
+ case ResMem:
+ if (pRes->block_begin == pvp->biosBase &&/*@@@*/
+ pRes->block_end == pvp->biosBase + (1 << (pvp->biosSize)) - 1)
+ prt = 6;
+ else for (i = 0 ; i < 6; i++)
+ if (pRes->block_begin == pvp->memBase[i]/*@@@*/
+ && pRes->block_end
+ == pvp->memBase[i] + (1 << (pvp->size[i])) - 1) {
+ prt = i;
+ break;
+ }
+ break;
+ case ResIo:
+ for (i = 0 ; i < 6; i++)
+ if (pRes->block_begin == pvp->ioBase[i]/*@@@*/
+ && pRes->block_end
+ == pvp->ioBase[i] + (1 << (pvp->size[i])) - 1) {
+ prt = i;
+ break;
+ }
+ break;
+ }
+
+ if (!prt) return pRes;
+
+ pResTmp = pRes->next;
+ if (! fixPciResource(prt, 0, pvp, pRes->res_type)) {
+ pRes->next = pBad;
+ pBad = pRes;
+ } else
+ xfree(pRes);
+
+ pRes = pResTmp;
+ }
+ return pBad;
+}
+
+/*
+ * BIOS releated
+ */
+
+memType
+getValidBIOSBase(PCITAG tag, int num)
+{
+ pciVideoPtr pvp = NULL;
+ PciBusPtr pbp, pbp1;
+ memType start_mp = 0, start_m = 0;
+ memType end_mp, end_m;
+ resPtr tmp, avoid;
+ resRange range;
+ int n = 0;
+ int maxnum = 5;
+ CARD32 biosSize, alignment;
+
+ if (!xf86PciVideoInfo) return 0;
+
+ while ((pvp = xf86PciVideoInfo[n++])) {
+ if (pciTag(pvp->bus,pvp->device,pvp->func) == tag)
+ break;
+ }
+ if (!pvp) return 0;
+
+ biosSize = pvp->biosSize;
+ alignment = (1 << biosSize) - 1;
+ if (biosSize > 24)
+ biosSize = 1 << 24;
+ avoid = NULL;
+ end_m = end_mp = PCI_MEM32_LENGTH_MAX;
+ pbp = pbp1 = xf86PciBus;
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if (pbp->pmem) {
+ start_mp = pbp->pmem->block_begin;
+ end_mp = MIN(end_mp,pbp->pmem->block_end);
+ }
+ if (pbp->mem) {
+ start_m = pbp->mem->block_begin;
+ end_m = MIN(end_m,pbp->mem->block_end);
+ }
+ }
+ while (pbp1) {
+ if (pbp1->primary == pvp->bus) {
+ tmp = xf86DupResList(pbp1->pmem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ tmp = xf86DupResList(pbp1->mem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ }
+ pbp1 = pbp1->next;
+ }
+ pbp = pbp->next;
+ }
+
+ if (pvp->biosBase) { /* try biosBase first */
+ RANGE(range, pvp->biosBase,/*@@@*/
+ pvp->biosBase + (1 << biosSize) - 1,
+ ResExcMemBlock);
+ if (((range.rBegin >= start_m && range.rEnd <= end_m) ||
+ (range.rBegin >= start_mp && range.rEnd <= end_mp))
+ && ! ChkConflict(&range,avoid,SETUP)) {
+ xf86FreeResList(avoid);
+ return pvp->biosBase;
+ }
+ }
+#if 1
+ if (num >= 0 && num <= 5 && pvp->memBase[num])
+ maxnum = num;
+ else {
+ num = 0;
+ }
+ for (; num <= maxnum; num++) {
+ /* then try suggested memBase */
+ RANGE(range, pvp->memBase[num],/*@@@*/
+ pvp->memBase[num] + (1 << biosSize) - 1,
+ ResExcMemBlock); /* keep bios size ! */
+ if ( pvp->size[num] >= biosSize
+ && ((range.rBegin >= start_m && range.rEnd <= end_m)
+ || (range.rBegin >= start_mp && range.rEnd <= end_mp))
+ && ! ChkConflict(&range,avoid,SETUP)) {
+ xf86FreeResList(avoid);
+ return pvp->memBase[num];
+ }
+ }
+#endif
+ range = xf86GetBlock(ResExcMemBlock, (1 << biosSize),start_m,end_m,
+ alignment, avoid);
+ xf86FreeResList(avoid);
+ return range.rBase;/*@@@*/
+}
+
+/*
+ * xf86Bus.c interface
+ */
+
+void
+xf86PciProbe(void)
+{
+#ifdef XFree86LOADER
+ /*
+ * we need to get the pointer to the pci data structures initialized
+ */
+ xf86PCIVendorNameInfo =
+ (SymTabPtr)LoaderSymbol("xf86PCIVendorNameInfoData");
+ xf86PCIVendorInfo =
+ (pciVendorDeviceInfo*)LoaderSymbol("xf86PCIVendorInfoData");
+ xf86PCICardInfo =
+ (pciVendorCardInfo*)LoaderSymbol("xf86PCICardInfoData");
+#else
+ xf86PCIVendorNameInfo = xf86PCIVendorNameInfoData;
+ xf86PCIVendorInfo = xf86PCIVendorInfoData;
+ xf86PCICardInfo = xf86PCICardInfoData;
+#endif
+ FindPCIVideoInfo();
+}
+
+static void alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary);
+
+PciBusPtr
+xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo)
+{
+ const pciConfigPtr *pcrpp;
+ pciConfigPtr pcrp;
+ resRange range;
+ PciBusPtr PciBus, PciBusBase = NULL;
+ PciBusPtr *pnPciBus = &PciBusBase;
+ int MaxBus = 0;
+ int i;
+
+ if (pciInfo == NULL) return NULL;
+
+ /* Add each PCI-PCI bridge */
+ for (pcrpp = pciInfo, pcrp = *pcrpp; pcrp; pcrp = *(++pcrpp)) {
+ if (pcrp->busnum > MaxBus)
+ MaxBus = pcrp->busnum;
+ if (pcrp->pci_base_class == PCI_CLASS_BRIDGE)
+ switch (pcrp->pci_sub_class) {
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->secondary = pcrp->pci_secondary_bus_number;
+ PciBus->primary = pcrp->pci_primary_bus_number;
+ PciBus->subordinate = pcrp->pci_subordinate_bus_number;
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+ PciBus->subclass = pcrp->pci_sub_class;
+ PciBus->brcontrol = pcrp->pci_bridge_control;
+ if (pcrp->pci_io_base <= pcrp->pci_io_limit
+ && (pcrp->pci_command & PCI_CMD_IO_ENABLE)) {
+ RANGE(range,pcrp->pci_io_base << 8
+ | (pcrp->pci_upper_io_base << 16),/*@@@*/
+ (pcrp->pci_io_limit << 8)
+ | (pcrp->pci_upper_io_limit << 16) | 0xfff,
+ ResIo | ResBlock | ResExclusive);
+ PciBus->io = xf86AddResToList(NULL, &range, -1);
+ }
+ if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
+ if (pcrp->pci_mem_base <= pcrp->pci_mem_limit) {
+ RANGE(range,pcrp->pci_mem_base << 16,/*@@@*/
+ (pcrp->pci_mem_limit << 16) | 0xfffff,
+ ResMem | ResBlock | ResExclusive);
+ PciBus->mem = xf86AddResToList(NULL, &range, -1);
+ }
+ if (pcrp->pci_prefetch_mem_base
+ <= pcrp->pci_prefetch_mem_limit) {
+#if !defined(LONG64) && !defined(WORD64)
+ RANGE(range,pcrp->pci_prefetch_mem_base << 16,
+ (pcrp->pci_prefetch_mem_limit << 16) | 0xfffff,
+ ResMem | ResBlock | ResExclusive);
+#else
+ RANGE(range,pcrp->pci_prefetch_mem_base << 16
+ | ((memType)pcrp->pci_prefetch_upper_mem_base
+ << 32),/*@@@*/
+ (pcrp->pci_prefetch_mem_limit
+ << 16) | 0xfffff
+ | ((memType)pcrp->pci_prefetch_upper_mem_limit
+ << 32),
+ ResMem | ResBlock | ResExclusive);
+#endif
+ PciBus->pmem = xf86AddResToList(NULL, &range, -1);
+ }
+ }
+ break;
+ case PCI_SUBCLASS_BRIDGE_ISA:
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->primary = 0;
+ PciBus->secondary = -1;
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+ PciBus->subclass = pcrp->pci_sub_class;
+ break;
+ case PCI_SUBCLASS_BRIDGE_HOST:
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->primary = -1;
+ PciBus->secondary = 0;
+ PciBus->subclass = pcrp->pci_sub_class;
+ RANGE(range, 0, 0xFFFFFFFF, ResIo | ResBlock | ResExclusive);
+ PciBus->io = xf86AddResToList(NULL, &range, -1);
+ RANGE(range, 0, ~(memType)0, ResMem | ResBlock | ResExclusive);
+ PciBus->mem = xf86AddResToList(NULL, &range, -1);
+ PciBus->pmem = xf86AddResToList(NULL, &range, -1);
+ break;
+ default:
+ break;
+ }
+ }
+ for (i = 0; i <= MaxBus; i++) { /* find PCI buses not attached to bridge */
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
+ if (PciBus->secondary) break;
+ if (!PciBus) { /* We assume it's behind a HOST-PCI bridge */
+ int minTag = 0xFFFFFF; /*find the 'smallest' free HOST-PCI bridge*/
+ int tag; /*'small' is in the order of pciTag() */
+ PciBusPtr PciBusFound = NULL;
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
+ if ((PciBus->subclass == PCI_SUBCLASS_BRIDGE_HOST) &&
+ (PciBus->secondary == -1) &&
+ ((tag = pciTag(PciBus->brbus,PciBus->brdev,PciBus->brfunc))
+ < minTag) ) {
+ minTag = tag;
+ PciBusFound = PciBus;
+ }
+ if (PciBusFound)
+ PciBusFound->secondary = i;
+ else { /* if nothing found it may not be visible: create new */
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->primary = -1;
+ PciBus->secondary = i;
+ PciBus->subclass = PCI_SUBCLASS_BRIDGE_HOST;
+ RANGE(range, 0, 0xFFFFFFFF, ResIo | ResBlock | ResExclusive);
+ PciBus->io = xf86AddResToList(NULL, &range, -1);
+ RANGE(range, 0, ~(memType)0, ResMem | ResBlock | ResExclusive);
+ PciBus->mem = xf86AddResToList(NULL, &range, -1);
+ PciBus->pmem = xf86AddResToList(NULL, &range, -1);
+ }
+ }
+ }
+
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
+ if (PciBus->subclass == PCI_SUBCLASS_BRIDGE_HOST) {
+ alignBridgeRanges(PciBusBase, PciBus);
+ }
+ }
+
+ return PciBusBase;
+
+}
+
+static void
+alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary)
+{
+ PciBusPtr PciBus;
+
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
+ if ((PciBus->primary == primary->secondary)
+ && (PciBus->subclass == PCI_SUBCLASS_BRIDGE_PCI)) {
+ resPtr tmp;
+ tmp = xf86FindIntersectOfLists(primary->io,PciBus->io);
+ xf86FreeResList(PciBus->io);
+ PciBus->io = tmp;
+ tmp = xf86FindIntersectOfLists(primary->pmem,PciBus->pmem);
+ xf86FreeResList(PciBus->pmem);
+ PciBus->pmem = tmp;
+ tmp = xf86FindIntersectOfLists(primary->mem,PciBus->mem);
+ xf86FreeResList(PciBus->mem);
+ PciBus->mem = tmp;
+ xf86MsgVerb(X_INFO, 3, "Bus %d: bridge is at (%d:%d:%d), "
+ "(%d,%d,%d), BCTRL: 0x%02x (VGA_EN is %s)\n",
+ PciBus->secondary,PciBus->brbus, PciBus->brdev,
+ PciBus->brfunc, PciBus->primary,
+ PciBus->secondary, PciBus->subordinate,
+ PciBus->brcontrol,
+ (PciBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN)
+ ? "set" : "cleared");
+ xf86MsgVerb(X_INFO, 3, "Bus %d I/O range:\n",
+ PciBus->secondary);
+ xf86PrintResList(3, PciBus->io);
+ xf86MsgVerb(X_INFO, 3,
+ "Bus %d non-prefetchable memory range:\n",
+ PciBus->secondary);
+ xf86PrintResList(3, PciBus->mem);
+ xf86MsgVerb(X_INFO, 3, "Bus %d prefetchable memory range:"
+ "\n",PciBus->secondary);
+ xf86PrintResList(3, PciBus->pmem);
+ alignBridgeRanges(PciBusBase, PciBus);
+ }
+ }
+}
+
+void
+ValidatePci(void)
+{
+ pciVideoPtr pvp, pvp1;
+ PciBusPtr pbp, pbp1;
+ pciConfigPtr pcrp, *pcrpp;
+ CARD32 *basep;
+ resPtr Sys;
+ resPtr Fix;
+ resRange range;
+ int n = 0, m, i;
+
+ if (!xf86PciVideoInfo) return;
+
+ /*
+ * Mark all pciInfoRecs that need to be validated. These are
+ * the ones which have been assigned to a screen.
+ */
+ Sys = NULL;
+ for (i=0; i<xf86NumScreens; i++) {
+ for (m = 0; m < xf86Screens[i]->numEntities; m++)
+ if ((pvp = xf86GetPciInfoForEntity(xf86Screens[i]->entityList[m])))
+ pvp->validate = TRUE;
+ }
+
+ /*
+ * Collect all background PCI resources we need to validate against.
+ * These are all resources which don't belong to PCINONSYSTEMCLASSES
+ * and which have not been assigned to an entity.
+ */
+ /* First get the PCIINFOCLASSES */
+ m = 0;
+ while ((pvp = xf86PciVideoInfo[m++])) {
+ /* is it a PCINONSYSTEMCLASS? */
+ if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
+ continue;
+ /* has it an Entity assigned to it? */
+ for (i=0; i<xf86NumEntities; i++) {
+ EntityPtr p = xf86Entities[i];
+ if (p->busType != BUS_PCI)
+ continue;
+ if (p->pciBusId.bus == pvp->bus
+ && p->pciBusId.device == pvp->device
+ && p->pciBusId.func == pvp->func)
+ break;
+ }
+ if (i != xf86NumEntities) /* found an Entity for this one */
+ continue;
+
+ for (i = 0; i<6; i++) {
+ if (pvp->ioBase[i]) {
+ RANGE(range,pvp->ioBase[i],/*@@@*/
+ pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcIoBlock);
+ Sys = xf86AddResToList(Sys,&range,-1);
+ } else if (pvp->memBase[i]) {
+ RANGE(range,pvp->memBase[i],/*@@@*/
+ pvp->memBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcMemBlock);
+ Sys = xf86AddResToList(Sys,&range,-1);
+ }
+ }
+ }
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+
+ if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
+ continue;
+
+ if ((pcrp->pci_header_type & 0x7f) != 0)
+ continue;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ if (basep[i]) {
+ if (PCI_MAP_IS_IO(basep[i]))
+ RANGE(range,PCIGETIO(basep[i]),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[i]) - 1,
+ ResExcIoBlock)
+ else if (!PCI_MAP_IS64BITMEM(basep[i]))
+ RANGE(range,PCIGETMEMORY(basep[i]),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[i]) - 1,
+ ResExcMemBlock)
+ else {
+ i++;
+#if defined LONG64 || defined WORD64
+ RANGE(range,PCIGETMEMORY(basep[i-1])/*@@@*/
+ | ((memType)basep[i] << 32),
+ range.rBegin + (1<<pcrp->basesize[i-1]) - 1,
+ ResExcMemBlock)
+#else
+ continue;
+#endif
+ }
+ Sys = xf86AddResToList(Sys, &range, -1);
+ }
+ }
+ if (pcrp->pci_baserom) {
+ RANGE(range,PCIGETROM(pcrp->pci_baserom),/*@@@*/
+ range.rBegin + (1 << pcrp->basesize[6]) - 1,
+ ResExcMemBlock);
+ Sys = xf86AddResToList(Sys, &range, -1);
+ }
+ }
+
+ /*
+ * The order the video devices are listed in is
+ * just right: the lower buses come first.
+ * This way we attempt to fix a conflict of
+ * a lower bus device with a higher bus device
+ * where we have more room to find different
+ * resources.
+ */
+ while ((pvp = xf86PciVideoInfo[n++])) {
+ resPtr res_mp = NULL, res_m_io = NULL;
+ resPtr NonSys = NULL;
+ resPtr tmp, avoid = NULL;
+
+ if (!pvp->validate) continue;
+ NonSys = xf86DupResList(Sys);
+ m = n;
+ while ((pvp1 = xf86PciVideoInfo[m++])) {
+ if (!pvp1->validate) continue;
+ for (i = 0; i<6; i++) {
+ if (pvp1->ioBase[i]) {
+ RANGE(range,pvp1->ioBase[i],/*@@@*/
+ pvp1->ioBase[i] + (1 << pvp1->size[i]) - 1,
+ ResExcIoBlock);
+ NonSys = xf86AddResToList(NonSys,&range,-1);
+ } else if (pvp1->memBase[i]) {
+ RANGE(range,pvp1->memBase[i],/*@@@*/
+ pvp1->memBase[i] + (1 << pvp1->size[i]) - 1,
+ ResExcMemBlock);
+ NonSys = xf86AddResToList(NonSys,&range,-1);
+ }
+ }
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"NonSys:\n");
+ xf86PrintResList(3,NonSys);
+#endif
+ avoid = NULL;
+ pbp = pbp1 = xf86PciBus;
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if (pbp->pmem) {
+ /* keep prefetchable separate */
+ res_mp = xf86FindIntersectOfLists(pbp->pmem,ResRange);
+ }
+ if (pbp->mem) {
+ res_m_io = xf86FindIntersectOfLists(pbp->mem,ResRange);
+ }
+ if (pbp->io) {
+ res_m_io = xf86JoinResLists(res_m_io,
+ xf86FindIntersectOfLists(pbp->io,ResRange));
+ }
+ }
+ while (pbp1) {
+ if (pbp1->primary == pvp->bus) {
+ tmp = xf86DupResList(pbp1->pmem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ tmp = xf86DupResList(pbp1->mem);
+ avoid = xf86JoinResLists(avoid,tmp);
+ tmp = xf86DupResList(pbp1->io);
+ avoid = xf86JoinResLists(avoid,tmp);
+ }
+ pbp1 = pbp1->next;
+ }
+ pbp = pbp->next;
+ }
+ if (res_m_io == NULL)
+ res_m_io = xf86DupResList(ResRange);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"avoid:\n");
+ xf86PrintResList(3,avoid);
+ xf86MsgVerb(X_INFO, 3,"prefetchable Memory:\n");
+ xf86PrintResList(3,res_mp);
+ xf86MsgVerb(X_INFO, 3,"MEM/IO:\n");
+ xf86PrintResList(3,res_m_io);
+#endif
+ Fix = NULL;
+ for (i = 0; i < 6; i++) {
+ int j;
+ resPtr own = NULL;
+ for (j = i+1; j < 6; j++) {
+ if (pvp->ioBase[j]) {
+ RANGE(range,pvp->ioBase[j],/*@@@*/
+ pvp->ioBase[j] + (1 << pvp->size[j]) - 1,
+ ResExcIoBlock);
+ own = xf86AddResToList(own,&range,-1);
+ } else if (pvp->memBase[j]) {/*@@@*/
+ RANGE(range,pvp->memBase[j],
+ pvp->memBase[j] + (1 << pvp->size[j]) - 1,
+ ResExcMemBlock);
+ own = xf86AddResToList(own,&range,-1);
+ }
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"own:\n");
+ xf86PrintResList(3,own);
+#endif
+ if (pvp->ioBase[i]) {
+ RANGE(range,pvp->ioBase[i],/*@@@*/
+ pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcIoBlock);
+ if (isSubsetOf(range,res_m_io)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP))
+ continue;
+ xf86MsgVerb(X_WARNING, 0,
+ "****INVALID IO ALLOCATION**** b: 0x%lx e: 0x%lx "
+ "correcting\a\n", range.rBegin,range.rEnd);
+#ifdef DEBUG
+ sleep(2);
+#endif
+ fixPciResource(i, 0, pvp, range.type);
+ } else if (pvp->memBase[i]) {
+ RANGE(range,pvp->memBase[i],/*@@@*/
+ pvp->memBase[i] + (1 << pvp->size[i]) - 1,
+ ResExcMemBlock);
+ if (pvp->type[i] & PCI_MAP_MEMORY_CACHABLE) {
+ if (isSubsetOf(range,res_mp)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP))
+ continue;
+ }
+ if (isSubsetOf(range,res_m_io)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP))
+ continue;
+ xf86MsgVerb(X_WARNING, 0,
+ "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx "
+ "correcting\a\n", range.rBegin,range.rEnd);
+ if (ChkConflict(&range,own,SETUP)) {
+ ErrorF("own\n");
+ xf86PrintResList(0,own);
+ }
+ if (ChkConflict(&range,avoid,SETUP)) {
+ ErrorF("avoid\n");
+ xf86PrintResList(0,avoid);
+ }
+ if (ChkConflict(&range,NonSys,SETUP)) {
+ ErrorF("NonSys\n");
+ xf86PrintResList(0,NonSys);
+ }
+
+#ifdef DEBUG
+ sleep(2);
+#endif
+ fixPciResource(i, 0, pvp, range.type);
+ }
+ xf86FreeResList(own);
+ }
+ xf86FreeResList(avoid);
+ xf86FreeResList(NonSys);
+ xf86FreeResList(res_mp);
+ xf86FreeResList(res_m_io);
+ }
+ xf86FreeResList(Sys);
+ return;
+}
+
+resList
+GetImplicitPciResources(int entityIndex)
+{
+ pciVideoPtr pvp;
+ int i;
+ resList list = NULL;
+ int num = 0;
+
+ if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return NULL;
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->ioBase[i]) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ RANGE(list[num - 1],pvp->ioBase[i],/*@@@*/
+ pvp->ioBase[i] + (1 << pvp->size[i]) - 1,
+ ResShrIoBlock | ResBios);
+ } else if (pvp->memBase[i]) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ RANGE(list[num - 1],pvp->memBase[i],/*@@@*/
+ pvp->memBase[i] + (1 << pvp->size[i]) - 1,
+ ResShrMemBlock | ResBios);
+ }
+ }
+#if 0
+ if (pvp->biosBase) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ RANGE(list[num - 1], pvp->biosBase,
+ pvp->biosBase + (1 << pvp->biosSize) - 1,
+ ResShrMemBlock | ResBios);
+ }
+#endif
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ list[num - 1].type = ResEnd;
+
+ return list;
+}
+
+void
+initPciState(void)
+{
+ int i = 0;
+ int j = 0;
+ pciVideoPtr pvp;
+ pciAccPtr pcaccp;
+
+ if (xf86PciAccInfo != NULL)
+ return;
+
+ if (xf86PciVideoInfo == NULL)
+ return;
+
+ while ((pvp = xf86PciVideoInfo[i]) != NULL) {
+ i++;
+ j++;
+ xf86PciAccInfo = xnfrealloc(xf86PciAccInfo,
+ sizeof(pciAccPtr) * (j + 1));
+ xf86PciAccInfo[j] = NULL;
+ pcaccp = xf86PciAccInfo[j - 1] = xnfalloc(sizeof(pciAccRec));
+ pcaccp->busnum = pvp->bus;
+ pcaccp->devnum = pvp->device;
+ pcaccp->funcnum = pvp->func;
+ pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func);
+ pcaccp->arg.func =
+ (SetBitsProcPtr)pciLongFunc(pcaccp->arg.tag,SET_BITS);
+ pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
+ pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
+ pcaccp->ioAccess.arg = &pcaccp->arg;
+ pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable;
+ pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable;
+ pcaccp->io_memAccess.arg = &pcaccp->arg;
+ pcaccp->memAccess.AccessDisable = pciMemAccessDisable;
+ pcaccp->memAccess.AccessEnable = pciMemAccessEnable;
+ pcaccp->memAccess.arg = &pcaccp->arg;
+ if (PCISHAREDIOCLASSES(pvp->class, pvp->subclass))
+ pcaccp->ctrl = TRUE;
+ else
+ pcaccp->ctrl = FALSE;
+ savePciState(pcaccp->arg.tag, &pcaccp->save);
+ }
+}
+
+/*
+ * initPciBusState() - fill out the BusAccRec for a PCI bus.
+ * Theory: each bus is associated with one bridge connecting it
+ * to its parent bus. The address of a bridge is therefore stored
+ * in the BusAccRec of the bus it connects to. Each bus can
+ * have several bridges connecting secondary buses to it. Only one
+ * of these bridges can be open. Therefore the status of a bridge
+ * associated with a bus is stored in the BusAccRec of the parent
+ * the bridge connects to. The first member of the structure is
+ * a pointer to a function that open access to this bus. This function
+ * receives a pointer to the structure itself as argument. This
+ * design should be common to BusAccRecs of any type of buses we
+ * support. The remeinder of the structure is bus type specific.
+ * In this case it contains a pointer to the structure of the
+ * parent bus. Thus enabling access to a specific bus is simple:
+ * 1. Close any bridge going to secondary buses.
+ * 2. Climb down the ladder and enable any bridge on buses
+ * on the path from the CPU to this bus.
+ */
+
+void
+initPciBusState(void)
+{
+ BusAccPtr pbap, pbap_tmp;
+ PciBusPtr pbp = xf86PciBus;
+
+ while (pbp) {
+ pbap = xnfcalloc(1,sizeof(BusAccRec));
+ pbap->busdep.pci.bus = pbp->secondary;
+ pbap->busdep.pci.primary_bus = pbp->primary;
+ pbap->busdep_type = BUS_PCI;
+ pbap->busdep.pci.acc = PCITAG_SPECIAL;
+ switch (pbp->subclass) {
+ case PCI_SUBCLASS_BRIDGE_HOST:
+#ifdef DEBUG
+ ErrorF("setting up HOST: %i\n",pbap->busdep.pci.bus);
+#endif
+ pbap->type = BUS_PCI;
+ pbap->set_f = pciSetBusAccess;
+ break;
+ case PCI_SUBCLASS_BRIDGE_PCI:
+#ifdef DEBUG
+ ErrorF("setting up PCI: %i\n",pbap->busdep.pci.bus);
+#endif
+ pbap->type = BUS_PCI;
+ pbap->save_f = savePciBusState;
+ pbap->restore_f = restorePciBusState;
+ pbap->set_f = pciSetBusAccess;
+ pbap->enable_f = pciBusAccessEnable;
+ pbap->disable_f = pciBusAccessDisable;
+ pbap->busdep.pci.acc = pciTag(pbp->brbus,pbp->brdev,pbp->brfunc);
+ pbap->busdep.pci.func =
+ (SetBitsProcPtr)pciLongFunc(pbap->busdep.pci.acc,SET_BITS);
+ savePciBusState(pbap);
+ break;
+ case PCI_SUBCLASS_BRIDGE_ISA:
+#ifdef DEBUG
+ ErrorF("setting up ISA: %i\n",pbap->busdep.pci.bus);
+#endif
+ pbap->type = BUS_ISA;
+ pbap->set_f = pciSetBusAccess;
+ break;
+ }
+ pbap->next = xf86BusAccInfo;
+ xf86BusAccInfo = pbap;
+ pbp = pbp->next;
+ }
+
+ pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ pbap->primary = NULL;
+ if (pbap->busdep_type == BUS_PCI
+ && pbap->busdep.pci.primary_bus > -1) {
+ pbap_tmp = xf86BusAccInfo;
+ while (pbap_tmp) {
+ if (pbap_tmp->busdep_type == BUS_PCI &&
+ pbap_tmp->busdep.pci.bus == pbap->busdep.pci.primary_bus) {
+ pbap->primary = pbap_tmp;
+ break;
+ }
+ pbap_tmp = pbap_tmp->next;
+ }
+ }
+ pbap = pbap->next;
+ }
+}
+
+void
+PciStateEnter(void)
+{
+ pciAccPtr paccp;
+ int i = 0;
+
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl)
+ continue;
+ savePciState(paccp->arg.tag, &paccp->save);
+ restorePciState(paccp->arg.tag, &paccp->restore);
+ }
+}
+
+void
+PciBusStateEnter(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->save_f)
+ pbap->save_f(pbap);
+ pbap = pbap->next;
+ }
+}
+
+void
+PciStateLeave(void)
+{
+ pciAccPtr paccp;
+ int i = 0;
+
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl)
+ continue;
+ savePciState(paccp->arg.tag, &paccp->restore);
+ restorePciState(paccp->arg.tag, &paccp->save);
+ }
+}
+
+void
+PciBusStateLeave(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->restore_f)
+ pbap->restore_f(pbap);
+ pbap = pbap->next;
+ }
+}
+
+void
+DisablePciAccess(void)
+{
+ int i = 0;
+ pciAccPtr paccp;
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl) /* disable devices that are under control initially*/
+ continue;
+ pciIo_MemAccessDisable(paccp->io_memAccess.arg);
+ }
+}
+
+void
+DisablePciBusAccess(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->disable_f)
+ pbap->disable_f(pbap);
+ if (pbap->primary)
+ pbap->primary->current = NULL;
+ pbap = pbap->next;
+ }
+}
+
+/*
+ * Public functions
+ */
+
+Bool
+xf86IsPciDevPresent(int bus, int dev, int func)
+{
+ int i = 0;
+ pciConfigPtr pcp;
+
+ while ((pcp = xf86PciInfo[i]) != NULL) {
+ if ((pcp->busnum == bus)
+ && (pcp->devnum == dev)
+ && (pcp->funcnum == func))
+ return TRUE;
+ i++;
+ }
+ return FALSE;
+}
+
+/*
+ * If the slot requested is already in use, return -1.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p = NULL;
+ pciAccPtr *ppaccp = xf86PciAccInfo;
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ int num;
+
+ if (xf86CheckPciSlot(bus, device, func)) {
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->busType = BUS_PCI;
+ p->device = dev;
+ p->pciBusId.bus = bus;
+ p->pciBusId.device = device;
+ p->pciBusId.func = func;
+ p->active = active;
+ p->inUse = FALSE;
+ /* Here we initialize the access structure */
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ while (ppaccp && *ppaccp) {
+ if ((*ppaccp)->busnum == bus
+ && (*ppaccp)->devnum == device
+ && (*ppaccp)->funcnum == func) {
+ p->access->fallback = &(*ppaccp)->io_memAccess;
+ p->access->pAccess = &(*ppaccp)->io_memAccess;
+ (*ppaccp)->ctrl = TRUE; /* mark control if not already */
+ break;
+ }
+ ppaccp++;
+ }
+ if (!ppaccp || !*ppaccp) {
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ }
+
+ p->busAcc = NULL;
+ while (pbap) {
+ if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == bus)
+ p->busAcc = pbap;
+ pbap = pbap->next;
+ }
+ fixPciSizeInfo(num);
+
+ /* in case bios is enabled disable it */
+ disablePciBios(pciTag(bus,device,func));
+
+ return num;
+ } else
+ return -1;
+}
+
+/*
+ * Get xf86PciVideoInfo for a driver.
+ */
+pciVideoPtr *
+xf86GetPciVideoInfo(void)
+{
+ return xf86PciVideoInfo;
+}
+
+/* --- Used by ATI driver, but also more generally useful */
+
+/*
+ * Get the full xf86scanpci data.
+ */
+pciConfigPtr *
+xf86GetPciConfigInfo(void)
+{
+ return xf86PciInfo;
+}
+
+/*
+ * Enable a device and route VGA to it. This is intended for a driver's
+ * Probe(), before creating EntityRec's. Only one device can be thus enabled
+ * at any one time, and should be disabled when the driver is done with it.
+ *
+ * The following special calls are also available:
+ *
+ * pvp == NULL && rt == NONE disable previously enabled device
+ * pvp != NULL && rt == NONE ensure device is disabled
+ * pvp == NULL && rt != NONE disable >all< subsequent calls to this function
+ * (done from xf86PostProbe())
+ * The last combination has been removed! To do this cleanly we have
+ * to implement stages and need to test at each stage dependent function
+ * if it is allowed to execute.
+ *
+ * The device represented by pvp may not have been previously claimed.
+ */
+void
+xf86SetPciVideo(pciVideoPtr pvp, resType rt)
+{
+ static BusAccPtr pbap = NULL;
+ static xf86AccessPtr pAcc = NULL;
+ static Bool DoneProbes = FALSE;
+ pciAccPtr pcaccp;
+ int i;
+
+ if (DoneProbes)
+ return;
+
+ /* Disable previous access */
+ if (pAcc) {
+ if (pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pAcc = NULL;
+ }
+ if (pbap) {
+ while (pbap->primary) {
+ if (pbap->disable_f)
+ (*pbap->disable_f)(pbap);
+ pbap->primary->current = NULL;
+ pbap = pbap->primary;
+ }
+ pbap = NULL;
+ }
+
+ /* Check for xf86PostProbe's magic combo */
+ if (!pvp) {
+ if (rt != NONE)
+ DoneProbes = TRUE;
+ return;
+ }
+
+ /* Validate device */
+ if (!xf86PciVideoInfo || !xf86PciAccInfo || !xf86BusAccInfo)
+ return;
+
+ for (i = 0; pvp != xf86PciVideoInfo[i]; i++)
+ if (!xf86PciVideoInfo[i])
+ return;
+
+ /* Ignore request for claimed adapters */
+ if (!xf86CheckPciSlot(pvp->bus, pvp->device, pvp->func))
+ return;
+
+ /* Find pciAccRec structure */
+ for (i = 0; ; i++) {
+ if (!(pcaccp = xf86PciAccInfo[i]))
+ return;
+ if ((pvp->bus == pcaccp->busnum) &&
+ (pvp->device == pcaccp->devnum) &&
+ (pvp->func == pcaccp->funcnum))
+ break;
+ }
+
+ if (rt == NONE) {
+ /* This is a call to ensure the adapter is disabled */
+ if (pcaccp->io_memAccess.AccessDisable)
+ (*pcaccp->io_memAccess.AccessDisable)(pcaccp->io_memAccess.arg);
+ return;
+ }
+
+ /* Find BusAccRec structure */
+ for (pbap = xf86BusAccInfo; ; pbap = pbap->next) {
+ if (!pbap)
+ return;
+ if (pvp->bus == pbap->busdep.pci.bus)
+ break;
+ }
+
+ /* Route VGA */
+ if (pbap->set_f)
+ (*pbap->set_f)(pbap);
+
+ /* Enable device */
+ switch (rt) {
+ case IO:
+ pAcc = &pcaccp->ioAccess;
+ break;
+ case MEM_IO:
+ pAcc = &pcaccp->io_memAccess;
+ break;
+ case MEM:
+ pAcc = &pcaccp->memAccess;
+ break;
+ default: /* no compiler noise */
+ break;
+ }
+
+ if (pAcc && pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+}
+
+/*
+ * Parse a BUS ID string, and return the PCI bus parameters if it was
+ * in the correct format for a PCI bus id.
+ */
+
+Bool
+xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
+{
+ /*
+ * The format is assumed to be "bus:device:func", where bus, device
+ * and func are decimal integers. func may be omitted and assumed to
+ * be zero, although it doing this isn't encouraged.
+ */
+
+ char *p, *s;
+ const char *id;
+ int i;
+
+ if (StringToBusType(busID, &id) != BUS_PCI)
+ return FALSE;
+
+ s = xstrdup(id);
+ p = strtok(s, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return FALSE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *bus = atoi(p);
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return FALSE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *device = atoi(p);
+ *func = 0;
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return TRUE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *func = atoi(p);
+ xfree(s);
+ return TRUE;
+}
+
+/*
+ * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
+ */
+
+Bool
+xf86ComparePciBusString(const char *busID, int bus, int device, int func)
+{
+ int ibus, idevice, ifunc;
+
+ if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
+ return bus == ibus && device == idevice && func == ifunc;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * xf86IsPrimaryPci() -- return TRUE if primary device
+ * is PCI and bus, dev and func numbers match.
+ */
+
+Bool
+xf86IsPrimaryPci(pciVideoPtr pPci)
+{
+ if (primaryBus.type != BUS_PCI) return FALSE;
+ return (pPci->bus == primaryBus.id.pci.bus &&
+ pPci->device == primaryBus.id.pci.device &&
+ pPci->func == primaryBus.id.pci.func);
+}
+
+/*
+ * xf86CheckPciGAType() -- return type of PCI graphics adapter.
+ */
+int
+xf86CheckPciGAType(pciVideoPtr pPci)
+{
+ int i = 0;
+ pciConfigPtr pcp;
+
+ while ((pcp = xf86PciInfo[i]) != NULL) {
+ if (pPci->bus == pcp->busnum && pPci->device == pcp->devnum
+ && pPci->func == pcp->funcnum) {
+ if (pcp->pci_base_class == PCI_CLASS_PREHISTORIC &&
+ pcp->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA)
+ return PCI_CHIP_VGA ;
+ if (pcp->pci_base_class == PCI_CLASS_DISPLAY &&
+ pcp->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA) {
+ if (pcp->pci_prog_if == 0)
+ return PCI_CHIP_VGA ;
+ if (pcp->pci_prog_if == 1)
+ return PCI_CHIP_8514;
+ }
+ return -1;
+ }
+ i++;
+ }
+ return -1;
+}
+
+/*
+ * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
+ */
+pciVideoPtr
+xf86GetPciInfoForEntity(int entityIndex)
+{
+ pciVideoPtr *ppPci;
+ EntityPtr p = xf86Entities[entityIndex];
+
+ if (entityIndex >= xf86NumEntities
+ || p->busType != BUS_PCI) return NULL;
+
+ for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
+ if (p->pciBusId.bus == (*ppPci)->bus &&
+ p->pciBusId.device == (*ppPci)->device &&
+ p->pciBusId.func == (*ppPci)->func)
+ return (*ppPci);
+ }
+ return NULL;
+}
+
+/*
+ * xf86CheckPciMemBase() checks that the memory base value matches one of the
+ * PCI base address register values for the given PCI device.
+ */
+Bool
+xf86CheckPciMemBase(pciVideoPtr pPci, memType base)
+{
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (base == pPci->memBase[i])
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Check if the slot requested is free. If it is already in use, return FALSE.
+ */
+
+Bool
+xf86CheckPciSlot(int bus, int device, int func)
+{
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ p = xf86Entities[i];
+ /* Check if this PCI slot is taken */
+ if (p->busType == BUS_PCI && p->pciBusId.bus == bus &&
+ p->pciBusId.device == device && p->pciBusId.func == func)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h
new file mode 100644
index 000000000..ca5fe747a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h
@@ -0,0 +1,57 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h,v 3.2 1999/12/06 03:52:41 robin Exp $ */
+
+#ifndef _XF86_PCI_BUS_H
+#define _XF86_PCI_BUS_H
+
+#define PCITAG_SPECIAL pciTag(0xFF,0xFF,0xFF)
+
+typedef struct {
+ CARD32 command;
+ CARD32 base[6];
+ CARD32 biosBase;
+} pciSave, *pciSavePtr;
+
+typedef void (*SetBitsProcPtr)(PCITAG, int, CARD32, CARD32);
+
+typedef struct {
+ PCITAG tag;
+ SetBitsProcPtr func;
+} pciArg;
+
+typedef struct pci_io {
+ int busnum;
+ int devnum;
+ int funcnum;
+ pciArg arg;
+ xf86AccessRec ioAccess;
+ xf86AccessRec io_memAccess;
+ xf86AccessRec memAccess;
+ pciSave save;
+ pciSave restore;
+ Bool ctrl;
+} pciAccRec, *pciAccPtr;
+
+typedef struct {
+ CARD16 io;
+ CARD32 mem;
+ CARD32 pmem;
+ CARD8 control;
+} pciBridgeSave, *pciBridgeSavePtr;
+
+void xf86PciProbe(void);
+PciBusPtr xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo);
+void ValidatePci(void);
+resList GetImplicitPciResources(int entityIndex);
+void initPciState(void);
+void initPciBusState(void);
+void DisablePciAccess(void);
+void DisablePciBusAccess(void);
+void PciStateEnter(void);
+void PciBusStateEnter(void);
+void PciStateLeave(void);
+void PciBusStateLeave(void);
+resPtr ResourceBrokerInitPci(resPtr *osRes);
+
+extern pciAccPtr * xf86PciAccInfo;
+
+#endif /* _XF86_PCI_BUS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86str.h b/xc/programs/Xserver/hw/xfree86/common/xf86str.h
index e6e69ab4c..3cee2acfe 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86str.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86str.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.47 1999/08/22 05:57:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.58 1999/12/13 01:39:47 robin Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -45,6 +45,11 @@ typedef enum {
INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
} CrtcAdjustFlags;
+/* Flags passed to ChipValidMode() */
+typedef enum {
+ MODECHECK_INITIAL = 0,
+ MODECHECK_FINAL = 1
+} ModeCheckFlags;
/* These are possible return values for xf86CheckMode() and ValidMode() */
typedef enum {
@@ -78,6 +83,7 @@ typedef enum {
MODE_VBLANK_NARROW, /* vertical blanking too narrow */
MODE_VBLANK_WIDE, /* vertical blanking too wide */
MODE_PANEL, /* exceeds panel dimensions */
+ MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
MODE_BAD = -2, /* unspecified reason */
MODE_ERROR = -1 /* error condition */
} ModeStatus;
@@ -88,8 +94,8 @@ typedef enum {
# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
/* built-in mode - configure CRTC and clock */
# define M_T_DEFAULT 0x10 /* (VESA) default modes */
-/* Video mode */
+/* Video mode */
typedef struct _DisplayModeRec {
struct _DisplayModeRec * prev;
struct _DisplayModeRec * next;
@@ -133,6 +139,8 @@ typedef struct _DisplayModeRec {
int PrivSize;
INT32 * Private;
int PrivFlags;
+
+ float HSync, VRefresh;
} DisplayModeRec, *DisplayModePtr;
/* The monitor description */
@@ -181,6 +189,20 @@ typedef struct x_ClockRange {
int PrivFlags;
} ClockRange, *ClockRangePtr;
+/* Need to store the strategy with clockRange for VidMode extension */
+typedef struct x_ClockRanges {
+ struct x_ClockRanges *next;
+ int minClock;
+ int maxClock;
+ int clockIndex; /* -1 for programmable clocks */
+ Bool interlaceAllowed;
+ Bool doubleScanAllowed;
+ int ClockMulFactor;
+ int ClockDivFactor;
+ int PrivFlags;
+ int strategy;
+} ClockRanges, *ClockRangesPtr;
+
/*
* The driver list struct. This contains the information required for each
* driver before a ScrnInfoRec has been allocated.
@@ -288,6 +310,7 @@ typedef struct {
memType biosBase;
int biosSize;
pointer thisCard;
+ Bool validSize;
Bool validate;
} pciVideoRec, *pciVideoPtr;
@@ -333,12 +356,31 @@ typedef struct _confscreenrec {
pointer options;
} confScreenRec, *confScreenPtr;
+typedef enum {
+ PosObsolete = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
typedef struct _screenlayoutrec {
confScreenPtr screen;
+ char * topname;
confScreenPtr top;
+ char * bottomname;
confScreenPtr bottom;
+ char * leftname;
confScreenPtr left;
+ char * rightname;
confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char * refname;
+ confScreenPtr refscreen;
} screenLayoutRec, *screenLayoutPtr;
typedef struct _serverlayoutrec {
@@ -495,9 +537,11 @@ typedef struct {
memType b;
} resRange, *resList;
-#define RANGE(r,u,v,t) (r).a = (u);\
+#define RANGE(r,u,v,t) {\
+ (r).a = (u);\
(r).b = (v);\
- (r).type = t;
+ (r).type = t;\
+ }
#define rBase a
#define rMask b
@@ -586,6 +630,13 @@ typedef struct {
} DGADeviceRec, *DGADevicePtr;
/*
+ * Flags for driver Probe() functions.
+ */
+#define PROBE_DEFAULT 0x00
+#define PROBE_DETECT 0x01
+#define PROBE_TRYHARD 0x02
+
+/*
* ScrnInfoRec
*
* There is one of these for each screen, and it holds all the screen-specific
@@ -693,8 +744,18 @@ typedef struct _ScrnInfoRec {
xf86CurrentAccessPtr CurrentAccess;
resType resourceType;
pointer busAccess;
+
/* Allow screens to be enabled/disabled individually */
Bool vtSema;
+ PixmapPtr ppix; /* Previous screen root pixmap
+ * while switched out */
+ /* hw cursor moves at SIGIO time */
+ Bool silkenMouse;
+
+ /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
+ ClockRangesPtr clockRanges;
+ int adjustFlags;
+
/*
* These can be used when the minor ABI version is incremented.
* The NUM_* parameters must be reduced appropriately to keep the
@@ -776,22 +837,14 @@ typedef struct {
} SymTabRec, *SymTabPtr;
-/* These are the possible flags for ValidMode */
-typedef enum {
- MODE_USED, /* this mode is really being used in the */
- /* modes line of the Display Subsection */
- MODE_SUGGESTED, /* this mode is included in the available*/
- /* modes in the Monitor Section */
- MODE_VID /* this is called from the VidMode extension */
-} ValidModeFlags;
-
/* flags for xf86LookupMode */
typedef enum {
LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
- LOOKUP_CLKDIV2 = 0x0100 /* Allow half clocks */
+ LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
+ LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
} LookupModeFlags;
#define NoDepth24Support 0x00
@@ -802,38 +855,6 @@ typedef enum {
#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
-#ifndef NEW_INPUT
-/*
- * mouse protocol types
- */
-typedef enum {
- PROT_OSMOUSE = -1,
- PROT_MS = 0, /* Microsoft */
- PROT_MSC, /* Mouse Systems Corp */
- PROT_MM, /* MMseries */
- PROT_LOGI, /* Logitech */
- PROT_BM, /* BusMouse ??? */
- PROT_LOGIMAN, /* MouseMan / TrackMan */
- PROT_PS2, /* PS/2 mouse */
- PROT_MMHIT, /* MM_HitTab */
- PROT_GLIDEPOINT, /* ALPS serial GlidePoint */
- PROT_IMSERIAL, /* Microsoft serial IntelliMouse */
- PROT_THINKING, /* Kensington serial ThinkingMouse */
- PROT_IMPS2, /* Microsoft PS/2 IntelliMouse */
- PROT_THINKINGPS2, /* Kensington PS/2 ThinkingMouse */
- PROT_MMANPLUSPS2, /* Logitech PS/2 MouseMan+ */
- PROT_GLIDEPOINTPS2, /* ALPS PS/2 GlidePoint */
- PROT_NETPS2, /* Genius PS/2 NetMouse */
- PROT_NETSCROLLPS2, /* Genius PS/2 NetScroll */
- PROT_SYSMOUSE, /* SysMouse */
- PROT_WSMOUSE, /* wsmouse (NetBSD) */
- PROT_SUN, /* Sun Microsystems */
- PROT_AUTO, /* automatic */
- PROT_ACECAD, /* Acecad tablets */
- NUM_PROTOCOLS /* MUST BE LAST */
-} MouseProtocol;
-#endif
-
/* For DPMS */
typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86xv.c b/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
index 642d886f3..ecbaea0c9 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
@@ -1,12 +1,12 @@
/*
- XFree86 Xv DDX written by Mark Vojkovich (mvojkovi@ucsd.edu)
+ XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
Copyright (C) 1998, 1999 - The XFree86 Project Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.12 1999/05/23 06:33:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.16 1999/12/17 02:45:37 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -60,14 +60,19 @@ static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
CARD16, CARD16,CARD16, CARD16,
unsigned int*, unsigned int*);
+static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, char*, Bool, CARD16, CARD16);
+static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+ CARD16*, CARD16*, int*, int*);
+
/* ScreenRec fields */
-static void xf86XVWindowExposures(WindowPtr, RegionPtr, RegionPtr);
static Bool xf86XVCreateWindow(WindowPtr pWin);
-static Bool xf86XVUnrealizeWindow(WindowPtr pWin);
+static Bool xf86XVDestroyWindow(WindowPtr pWin);
static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
-static void xf86XVCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
/* ScrnInfoRec functions */
@@ -175,19 +180,15 @@ xf86XVScreenInit(
ScreenPriv->ClipNotify = pScreen->ClipNotify;
- ScreenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
- ScreenPriv->WindowExposures = pScreen->WindowExposures;
ScreenPriv->CreateWindow = pScreen->CreateWindow;
- ScreenPriv->CopyWindow = pScreen->CopyWindow;
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
ScreenPriv->EnterVT = pScrn->EnterVT;
ScreenPriv->LeaveVT = pScrn->LeaveVT;
pScreen->ClipNotify = xf86XVClipNotify;
- pScreen->UnrealizeWindow = xf86XVUnrealizeWindow;
- pScreen->WindowExposures = xf86XVWindowExposures;
pScreen->CreateWindow = xf86XVCreateWindow;
- pScreen->CopyWindow = xf86XVCopyWindow;
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
pScrn->EnterVT = xf86XVEnterVT;
pScrn->LeaveVT = xf86XVLeaveVT;
@@ -234,6 +235,19 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
xfree(pAdaptor->pPorts);
}
+ if(pAdaptor->nAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
+ if(pAttribute->name) xfree(pAttribute->name);
+ }
+
+ xfree(pAdaptor->pAttributes);
+ }
+
+ if(pAdaptor->nImages)
+ xfree(pAdaptor->pImages);
+
if(pAdaptor->devPriv.ptr)
xfree(pAdaptor->devPriv.ptr);
}
@@ -247,41 +261,66 @@ xf86XVInitAdaptors(
XvScreenPtr pxvs = (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XF86VideoAdaptorPtr adaptorPtr;
- XF86VideoEncodingPtr encodingPtr;
- XF86VideoFormatPtr formatPtr;
- XF86AttributeListPtr attributePtr;
- XvAdaptorRecPrivatePtr adaptorPriv;
- XvPortRecPrivatePtr portPriv;
XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
int na, numAdaptor;
- XvEncodingPtr pEncode, pe;
- int ne, numEncode;
- XvFormatPtr pFormat, pf;
- int nf, numFormat, totFormat;
+ XvPortRecPrivatePtr portPriv;
XvPortPtr pPort, pp;
- int np, numPort;
- XvAttributePtr pAttribute;
- int nat, numAttribute;
-
+ int numPort;
+ XF86AttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ XF86VideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ XF86VideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ XF86ImagePtr imagePtr;
+ XvImagePtr pImage, pi;
int numVisuals;
VisualPtr pVisual;
+ int i;
pxvs->nAdaptors = 0;
pxvs->pAdaptors = NULL;
- pAdaptor = xcalloc(number, sizeof(XvAdaptorRec));
- if(!pAdaptor) return FALSE;
-
- for(pa = pAdaptor, na = 0, numAdaptor = 0;
- na < number;
- na++) {
+ if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+ for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
adaptorPtr = infoPtr[na];
- if(!adaptorPtr->type) continue;
+ if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
- pa->pScreen = pScreen;
pa->type = adaptorPtr->type;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
pa->ddAllocatePort = xf86XVAllocatePort;
pa->ddFreePort = xf86XVFreePort;
pa->ddPutVideo = xf86XVPutVideo;
@@ -289,55 +328,92 @@ xf86XVInitAdaptors(
pa->ddGetVideo = xf86XVGetVideo;
pa->ddGetStill = xf86XVGetStill;
pa->ddStopVideo = xf86XVStopVideo;
+ pa->ddPutImage = xf86XVPutImage;
pa->ddSetPortAttribute = xf86XVSetPortAttribute;
pa->ddGetPortAttribute = xf86XVGetPortAttribute;
pa->ddQueryBestSize = xf86XVQueryBestSize;
+ pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
if((pa->name = xalloc(strlen(adaptorPtr->name) + 1)))
strcpy(pa->name, adaptorPtr->name);
- pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec));
- if(!pEncode) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pe = pEncode, ne = 0, numEncode = 0;
- ne < adaptorPtr->nEncodings;
- ne++) {
-
- encodingPtr = &adaptorPtr->pEncodings[ne];
-
- pe->id = encodingPtr->id;
- pe->pScreen = pScreen;
- if((pe->name = xalloc(strlen(encodingPtr->name) + 1)))
- strcpy(pe->name, encodingPtr->name);
- pe->width = encodingPtr->width;
- pe->height = encodingPtr->height;
- pe->rate.numerator = encodingPtr->rate.numerator;
- pe->rate.denominator = encodingPtr->rate.denominator;
-
- pe++;
- numEncode++;
- }
- pa->nEncodings = numEncode;
- pa->pEncodings = pEncode;
- if(!numEncode) {
- xf86XVFreeAdaptor(pa);
- continue;
+ if(adaptorPtr->nEncodings &&
+ (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
+ {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ if((pe->name = xalloc(strlen(encodingPtr->name) + 1)))
+ strcpy(pe->name, encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if(adaptorPtr->nImages &&
+ (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++)
+ {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
}
+ if(adaptorPtr->nAttributes &&
+ (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
+ {
+ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
+ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
+ {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ if((pat->name = xalloc(strlen(attributePtr->name) + 1)))
+ strcpy(pat->name, attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+
totFormat = adaptorPtr->nFormats;
- pFormat = xcalloc(totFormat, sizeof(XvFormatRec));
- if(!pFormat) {
+ if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) {
xf86XVFreeAdaptor(pa);
continue;
}
- for(pf = pFormat, nf = 0, numFormat = 0;
- nf < adaptorPtr->nFormats;
- nf++) {
-
- formatPtr = &adaptorPtr->pFormats[nf];
-
+ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
+ i < adaptorPtr->nFormats; i++, formatPtr++)
+ {
numVisuals = pScreen->numVisuals;
pVisual = pScreen->visuals;
@@ -348,7 +424,8 @@ xf86XVInitAdaptors(
if(numFormat >= totFormat) {
void *moreSpace;
totFormat *= 2;
- moreSpace = xrealloc(pFormat, totFormat * sizeof(XvFormatRec));
+ moreSpace = xrealloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
if(!moreSpace) break;
pFormat = moreSpace;
pf = pFormat + numFormat;
@@ -370,9 +447,7 @@ xf86XVInitAdaptors(
continue;
}
-
- adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate));
- if(!adaptorPriv) {
+ if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) {
xf86XVFreeAdaptor(pa);
continue;
}
@@ -386,72 +461,40 @@ xf86XVInitAdaptors(
adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
pa->devPriv.ptr = (pointer)adaptorPriv;
- if(pa->type & XvInputMask) {
- if(!adaptorPtr->PutVideo || !adaptorPtr->PutStill ||
- !adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
- !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
+ if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
}
+ for(pp = pPort, i = 0, numPort = 0;
+ i < adaptorPtr->nPorts; i++) {
- if(pa->type & XvOutputMask) {
- if(!adaptorPtr->GetVideo || !adaptorPtr->GetStill ||
- !adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
- !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize) {
- xf86XVFreeAdaptor(pa);
+ if(!(pp->id = FakeClientID(0)))
continue;
- }
- }
- pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec));
- if(!pPort) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pp = pPort, np = 0, numPort = 0;
- np < adaptorPtr->nPorts;
- np++) {
+ if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate))))
+ continue;
- pp->numAttributes = 0;
- pp->attributes = NULL;
- if(adaptorPtr->pAttributes) {
- if((numAttribute = adaptorPtr->pAttributes[np].number)) {
- attributePtr = &adaptorPtr->pAttributes[np];
- pp->attributes = xcalloc(numAttribute, sizeof(XvAttributeRec));
- if(!pp->attributes) continue;
-
- pp->numAttributes = numAttribute;
- for(pAttribute = pp->attributes, nat = 0;
- nat < numAttribute;
- nat++, pAttribute++) {
- pAttribute->flags = attributePtr->flags[nat];
- pAttribute->name = attributePtr->names[nat];
- }
- }
+ if(!AddResource(pp->id, PortResource, pp)) {
+ xfree(portPriv);
+ continue;
}
- if(!(pp->id = FakeClientID(0))) continue;
- if(!AddResource(pp->id, PortResource, pp)) continue;
-
pp->pAdaptor = pa;
pp->pNotify = (XvPortNotifyPtr)NULL;
pp->pDraw = (DrawablePtr)NULL;
pp->client = (ClientPtr)NULL;
pp->grab.client = (ClientPtr)NULL;
pp->time = currentTime;
-
-
- portPriv = xcalloc(1, sizeof(XvPortRecPrivate));
pp->devPriv.ptr = portPriv;
- if(!portPriv) continue;
portPriv->pScrn = pScrn;
portPriv->AdaptorRec = adaptorPriv;
- portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[np].ptr;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
pp++;
numPort++;
@@ -491,17 +534,23 @@ xf86XVInitAdaptors(
even if the client clip was different from the one the video was
initialized with. If the original GC was destroyed, they had to stop
the video. I like the new method better (MArk).
+
+ This function only works for windows. Will need to rewrite when
+ (if) we support pixmap rendering.
*/
-static void
-xf86XVUpdateCompositeClip(
- DrawablePtr pDraw,
- XvPortRecPrivatePtr portPriv
-){
+static void
+xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
+{
RegionPtr pregWin, pCompositeClip;
- WindowPtr pWin = (WindowPtr)pDraw;
+ WindowPtr pWin;
Bool freeCompClip = FALSE;
+ if(portPriv->pCompositeClip)
+ return;
+
+ pWin = (WindowPtr)portPriv->pDraw;
+
/* get window clip list */
if(portPriv->subWindowMode == IncludeInferiors) {
pregWin = NotClippedByChildren(pWin);
@@ -509,22 +558,17 @@ xf86XVUpdateCompositeClip(
} else
pregWin = &pWin->clipList;
- if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- REGION_DESTROY(pWin->pScreen, portPriv->pCompositeClip);
- }
-
if(!portPriv->clientClip) {
portPriv->pCompositeClip = pregWin;
portPriv->FreeCompositeClip = freeCompClip;
return;
}
-
pCompositeClip = REGION_CREATE(pWin->pScreen, NullBox, 1);
REGION_COPY(pWin->pScreen, pCompositeClip, portPriv->clientClip);
REGION_TRANSLATE(pWin->pScreen, pCompositeClip,
- pDraw->x + portPriv->clipOrg.x,
- pDraw->y + portPriv->clipOrg.y);
+ portPriv->pDraw->x + portPriv->clipOrg.x,
+ portPriv->pDraw->y + portPriv->clipOrg.y);
REGION_INTERSECT(pWin->pScreen, pCompositeClip, pregWin, pCompositeClip);
portPriv->pCompositeClip = pCompositeClip;
@@ -532,7 +576,7 @@ xf86XVUpdateCompositeClip(
if(freeCompClip) {
REGION_DESTROY(pWin->pScreen, pregWin);
- }
+ }
}
/* Save the current clientClip and update the CompositeClip whenever
@@ -543,17 +587,15 @@ xf86XVCopyClip(
XvPortRecPrivatePtr portPriv,
GCPtr pGC
){
- /* free the old clientClip */
- if(portPriv->clientClip) {
- REGION_DESTROY(pGC->pScreen, portPriv->clientClip);
- portPriv->clientClip = NULL;
- }
-
- /* copy the new one if it exists */
+ /* copy the new clip if it exists */
if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
- portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
+ if(!portPriv->clientClip)
+ portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
/* Note: this is in window coordinates */
REGION_COPY(pGC->pScreen, portPriv->clientClip, pGC->clientClip);
+ } else if(portPriv->clientClip) { /* free the old clientClip */
+ REGION_DESTROY(pGC->pScreen, portPriv->clientClip);
+ portPriv->clientClip = NULL;
}
/* get rid of the old clip list */
@@ -564,6 +606,7 @@ xf86XVCopyClip(
portPriv->clipOrg = pGC->clipOrg;
portPriv->pCompositeClip = pGC->pCompositeClip;
portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
}
static int
@@ -571,10 +614,12 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
{
RegionRec WinRegion;
RegionRec ClipRegion;
- RegionRec ScreenRegion;
- BoxRec WinBox, ScreenBox;
+ BoxRec WinBox;
ScreenPtr pScreen = portPriv->pDraw->pScreen;
int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
@@ -582,79 +627,50 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+ /* clip to the window composite clip */
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-
- if(portPriv->AdaptorRec->flags & VIDEO_EXPOSE) {
- ScreenBox.x1 = 0;
- ScreenBox.y1 = 0;
- ScreenBox.x2 = portPriv->pScrn->virtualX;
- ScreenBox.y2 = portPriv->pScrn->virtualY;
- REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, &ScreenRegion);
- } else
- /* clip to the window composite clip */
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
-#if 0
- /* that's all if it's totally obscured and video already off */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion) && !portPriv->isOn)
+ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
-#endif
-
- /* turn off the video if it's on */
- if(portPriv->isOn) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = FALSE;
}
-#if 1
- /* if you wanted VIDEO_NO_CLIPPING hardware to grab the window area
- if part of it was visible rather than just failing, you could
- comment out this section. There may be security problems
- with that though. */
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- goto CLIP_VIDEO_BAILOUT;
- }
-
-#endif
-
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
portPriv->vid_x, portPriv->vid_y,
- portPriv->pDraw->x + portPriv->drw_x,
- portPriv->pDraw->y + portPriv->drw_y,
+ WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
portPriv->drw_w, portPriv->drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
- if(ret == Success) {
- /* the driver had a chance to lower the curtain,
- that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion))
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- else
- portPriv->isOn = TRUE;
- }
+
+ if(ret == Success)
+ portPriv->isOn = TRUE;
CLIP_VIDEO_BAILOUT:
+ if((clippedAway || (ret != Success)) && portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = FALSE;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
REGION_UNINIT(pScreen, &WinRegion);
REGION_UNINIT(pScreen, &ClipRegion);
-
+
return ret;
}
+
static int
xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
{
@@ -663,6 +679,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
BoxRec WinBox;
ScreenPtr pScreen = portPriv->pDraw->pScreen;
int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
@@ -675,44 +694,64 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
- /* turn off the video if it's on */
- if(portPriv->isOn) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = FALSE;
- }
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion))
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
-
+ }
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = REGION_RECTS(&ClipRegion);
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- goto CLIP_VIDEO_BAILOUT;
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
}
-
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
portPriv->vid_x, portPriv->vid_y,
- portPriv->pDraw->x + portPriv->drw_x,
- portPriv->pDraw->y + portPriv->drw_y,
+ WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
portPriv->drw_w, portPriv->drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
- if(ret == Success)
- portPriv->isOn = TRUE;
+
+ if(ret == Success) portPriv->isOn = TRUE;
CLIP_VIDEO_BAILOUT:
+ if((clippedAway || (ret != Success)) && portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = FALSE;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
REGION_UNINIT(pScreen, &WinRegion);
REGION_UNINIT(pScreen, &ClipRegion);
@@ -726,7 +765,6 @@ xf86XVReputAllVideo(WindowPtr pWin, pointer data)
(XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
while(WinPriv) {
- xf86XVUpdateCompositeClip((DrawablePtr)pWin, WinPriv->PortRec);
if(WinPriv->PortRec->type == XvInputMask)
xf86XVReputVideo(WinPriv->PortRec);
else
@@ -783,6 +821,7 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
prevPriv = winPriv;
winPriv = winPriv->next;
}
+ portPriv->pDraw = NULL;
}
/**** ScreenRec fields ****/
@@ -791,119 +830,107 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
static Bool
xf86XVCreateWindow(WindowPtr pWin)
{
- XvScreenPtr pxvs =
- (XvScreenPtr) pWin->drawable.pScreen->devPrivates[XF86XvScreenIndex].ptr;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
int ret;
- ret = (*ScreenPriv->CreateWindow)(pWin);
+ pScreen->CreateWindow = ScreenPriv->CreateWindow;
+ ret = (*pScreen->CreateWindow)(pWin);
+ pScreen->CreateWindow = xf86XVCreateWindow;
if(ret) pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
return ret;
}
-static void
-xf86XVWindowExposures(
- WindowPtr pWin,
- RegionPtr pReg,
- RegionPtr pOtherReg
-){
- XvScreenPtr pxvs =
- (XvScreenPtr) pWin->drawable.pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
- XF86XVWindowPtr WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
-
- (*ScreenPriv->WindowExposures)(pWin, pReg, pOtherReg);
-
- while(WinPriv) {
- xf86XVUpdateCompositeClip((DrawablePtr)pWin, WinPriv->PortRec);
- if(WinPriv->PortRec->type == XvInputMask)
- xf86XVReputVideo(WinPriv->PortRec);
- else
- xf86XVRegetVideo(WinPriv->PortRec);
- WinPriv = WinPriv->next;
- }
-}
static Bool
-xf86XVUnrealizeWindow(WindowPtr pWin)
+xf86XVDestroyWindow(WindowPtr pWin)
{
- XvScreenPtr pxvs =
- (XvScreenPtr) pWin->drawable.pScreen->devPrivates[XF86XvScreenIndex].ptr;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
- XF86XVWindowPtr WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
- XvPortRecPrivatePtr pPriv;
+ XF86XVWindowPtr tmp, WinPriv =
+ (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
+ int ret;
+ /* The DI layer only stops and removes video not transient stills/images */
while(WinPriv) {
- pPriv = WinPriv->PortRec;
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
- if(pPriv->isOn) {
+ if(pPriv->isOn) {
(*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
pPriv->isOn = FALSE;
- }
- WinPriv = WinPriv->next;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
}
- return((* ScreenPriv->UnrealizeWindow)(pWin));
+ pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow)(pWin);
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+
+ return ret;
}
+
static void
xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
{
- XvScreenPtr pxvs =
- (XvScreenPtr) pWin->drawable.pScreen->devPrivates[XF86XvScreenIndex].ptr;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
XF86XVWindowPtr WinPriv =
(XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
- XvPortRecPrivatePtr pPriv;
-
+ XF86XVWindowPtr tmp, pPrev = NULL;
+
while(WinPriv) {
- pPriv = WinPriv->PortRec;
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
- if(pPriv->isOn) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = FALSE;
- }
- WinPriv = WinPriv->next;
- }
-
- if(ScreenPriv->ClipNotify)
- (* ScreenPriv->ClipNotify)(pWin, dx, dy);
-}
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
-static void
-xf86XVCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc
-){
- XvScreenPtr pxvs =
- (XvScreenPtr) pWin->drawable.pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
- XF86XVWindowPtr WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
- XvPortRecPrivatePtr pPriv;
+ pPriv->pCompositeClip = NULL;
- while(WinPriv) {
- pPriv = WinPriv->PortRec;
-
- if(pPriv->isOn) {
+ if(!pPriv->type) { /* overlaid still/image */
(*pPriv->AdaptorRec->StopVideo)(
pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = FALSE;
- }
- WinPriv = WinPriv->next;
- }
- (*ScreenPriv->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+ pPriv->pDraw = NULL;
+ if(!pPrev)
+ pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)(WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ continue;
+ } else {
+ if(pPriv->type == XvInputMask)
+ xf86XVReputVideo(pPriv);
+ else
+ xf86XVRegetVideo(pPriv);
+ }
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+
+ if(ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+ pScreen->ClipNotify = xf86XVClipNotify;
+ }
}
+
/**** Required XvScreenRec fields ****/
static Bool
@@ -918,10 +945,8 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen)
if(!ScreenPriv) return TRUE;
pScreen->CreateWindow = ScreenPriv->CreateWindow;
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
pScreen->ClipNotify = ScreenPriv->ClipNotify;
- pScreen->UnrealizeWindow = ScreenPriv->UnrealizeWindow;
- pScreen->CopyWindow = ScreenPriv->CopyWindow;
pScrn->EnterVT = ScreenPriv->EnterVT;
pScrn->LeaveVT = ScreenPriv->LeaveVT;
@@ -994,6 +1019,15 @@ xf86XVLeaveVT(int index, int flags)
(*pPriv->AdaptorRec->StopVideo)(
pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
pPriv->isOn = FALSE;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if(!pPriv->type && pPriv->pDraw) { /* still */
+ xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
+ }
}
}
}
@@ -1047,8 +1081,6 @@ xf86XVPutVideo(
if(portPriv->pDraw && (portPriv->pDraw != pDraw))
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- portPriv->pDraw = NULL;
-
/* Register our port with the new window */
result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(result != Success) return result;
@@ -1089,8 +1121,8 @@ xf86XVPutStill(
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- Bool WasOn = FALSE;
int ret = Success;
+ Bool clippedAway = FALSE;
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
@@ -1106,14 +1138,27 @@ xf86XVPutStill(
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion))
- goto PUT_STILL_BAILOUT;
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
- if(portPriv->isOn) {
- WasOn = TRUE;
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = FALSE;
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
@@ -1121,32 +1166,42 @@ xf86XVPutStill(
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- goto PUT_STILL_BAILOUT;
+ {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
}
-
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn, vid_x, vid_y,
- pDraw->x + drw_x, pDraw->y + drw_y,
+ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = TRUE;
+ portPriv->pDraw = pDraw;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ }
+
PUT_STILL_BAILOUT:
+ if((clippedAway || (ret != Success)) && portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = FALSE;
+ }
+
REGION_UNINIT(pScreen, &WinRegion);
REGION_UNINIT(pScreen, &ClipRegion);
- /* If this port was in use, reinstate it */
- if(portPriv->pDraw && WasOn) {
- if(portPriv->type == XvInputMask)
- xf86XVReputVideo(portPriv);
- else
- xf86XVRegetVideo(portPriv);
- }
-
return ret;
}
@@ -1174,8 +1229,6 @@ xf86XVGetVideo(
if(portPriv->pDraw && (portPriv->pDraw != pDraw))
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- portPriv->pDraw = NULL;
-
/* Register our port with the new window */
result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(result != Success) return result;
@@ -1215,10 +1268,9 @@ xf86XVGetStill(
ScreenPtr pScreen = pDraw->pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
- RegionRec ScreenRegion;
- BoxRec WinBox, ScreenBox;
- Bool WasOn = FALSE;
+ BoxRec WinBox;
int ret = Success;
+ Bool clippedAway = FALSE;
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
@@ -1232,69 +1284,41 @@ xf86XVGetStill(
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
- if(portPriv->AdaptorRec->flags & VIDEO_EXPOSE) {
- ScreenBox.x1 = 0;
- ScreenBox.y1 = 0;
- ScreenBox.x2 = pScreen->width;
- ScreenBox.y2 = pScreen->height;
- REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, &ScreenRegion);
- } else
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion))
- goto GET_STILL_BAILOUT;
-
- if(portPriv->isOn) {
- WasOn = TRUE;
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = FALSE;
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
-
-#if 1
- /* if you wanted VIDEO_NO_CLIPPING hardware to grab the window area
- if part of it was visible rather than just failing, you could
- comment out this section. There may be security problems
- with that though. */
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- goto GET_STILL_BAILOUT;
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
}
-#endif
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn, vid_x, vid_y,
- pDraw->x + drw_x, pDraw->y + drw_y,
+ ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
GET_STILL_BAILOUT:
+ if((clippedAway || (ret != Success)) && portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = FALSE;
+ }
+
REGION_UNINIT(pScreen, &WinRegion);
REGION_UNINIT(pScreen, &ClipRegion);
- /* If this port was in use, reinstate it */
- if(portPriv->pDraw && WasOn) {
- if(portPriv->type == XvInputMask)
- xf86XVReputVideo(portPriv);
- else
- xf86XVRegetVideo(portPriv);
- }
-
return ret;
}
-
+
static int
xf86XVStopVideo(
@@ -1309,16 +1333,15 @@ xf86XVStopVideo(
xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
- portPriv->pDraw = NULL;
- portPriv->type = 0;
-
if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
/* Must free resources. */
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
- portPriv->isOn = FALSE;
+ if(portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = FALSE;
+ }
return Success;
}
@@ -1371,5 +1394,125 @@ xf86XVQueryBestSize(
}
+static int
+xf86XVPutImage(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ char* data,
+ Bool sync,
+ CARD16 width, CARD16 height
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
+ src_x, src_y, WinBox.x1, WinBox.y1,
+ src_w, src_h, drw_w, drw_h, format->id, data, width, height,
+ sync, &ClipRegion, portPriv->DevPriv.ptr);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = TRUE;
+ portPriv->pDraw = pDraw;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ }
+
+PUT_IMAGE_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && portPriv->isOn) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = FALSE;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVQueryImageAttributes(
+ ClientPtr client,
+ XvPortPtr pPort,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height,
+ int *pitches,
+ int *offsets
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn,
+ format->id, width, height, pitches, offsets);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
index 9aaa8a8ba..362c2e01c 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.5 1999/05/23 06:33:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.8 1999/12/11 19:25:06 mvojkovi Exp $ */
#ifndef _XVDIX_H_
#define _XVDIX_H_
@@ -8,14 +8,45 @@
#define VIDEO_NO_CLIPPING 0x00000001
#define VIDEO_INVERT_CLIPLIST 0x00000002
-#define VIDEO_EXPOSE 0x00000004
+#define VIDEO_OVERLAID_IMAGES 0x00000004
+#define VIDEO_OVERLAID_STILLS 0x00000008
+#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
-
-typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} XF86ImageRec, *XF86ImagePtr;
+
+
+typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
-typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
+typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
@@ -35,7 +66,14 @@ typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion,
short vid_w, short vid_h, short drw_w, short drw_h,
unsigned int *p_w, unsigned int *p_h, pointer data);
-
+typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
+ short src_x, short src_y, short drw_x, short drw_y,
+ short src_w, short src_h, short drw_w, short drw_h,
+ int image, char* buf, short width, short height, Bool sync,
+ RegionPtr clipBoxes, pointer data );
+typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn,
+ int image, short *width, short *height,
+ int *pitches, int *offsets);
/*** this is what the driver needs to fill out ***/
@@ -46,20 +84,20 @@ typedef struct {
XvRationalRec rate;
} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
-
typedef struct {
char depth;
short class;
} XF86VideoFormatRec, *XF86VideoFormatPtr;
typedef struct {
- int number;
- int *flags;
- char **names;
-} XF86AttributeListRec, *XF86AttributeListPtr;
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} XF86AttributeRec, *XF86AttributePtr;
typedef struct {
- unsigned char type;
+ unsigned int type;
int flags;
char *name;
int nEncodings;
@@ -67,8 +105,11 @@ typedef struct {
int nFormats;
XF86VideoFormatPtr pFormats;
int nPorts;
- XF86AttributeListPtr pAttributes;
DevUnion *pPortPrivates;
+ int nAttributes;
+ XF86AttributePtr pAttributes;
+ int nImages;
+ XF86ImagePtr pImages;
PutVideoFuncPtr PutVideo;
PutStillFuncPtr PutStill;
GetVideoFuncPtr GetVideo;
@@ -77,6 +118,8 @@ typedef struct {
SetPortAttributeFuncPtr SetPortAttribute;
GetPortAttributeFuncPtr GetPortAttribute;
QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
@@ -104,10 +147,8 @@ xf86XVListGenericAdaptors(
typedef struct {
CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify;
- UnrealizeWindowProcPtr UnrealizeWindow;
- WindowExposuresProcPtr WindowExposures;
- CopyWindowProcPtr CopyWindow;
Bool (*EnterVT)(int, int);
void (*LeaveVT)(int, int);
} XF86XVScreenRec, *XF86XVScreenPtr;
@@ -122,6 +163,8 @@ typedef struct {
SetPortAttributeFuncPtr SetPortAttribute;
GetPortAttributeFuncPtr GetPortAttribute;
QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
typedef struct {