summaryrefslogtreecommitdiff
path: root/xserver/hw/xfree86/common
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/hw/xfree86/common')
-rw-r--r--xserver/hw/xfree86/common/Makefile.am6
-rw-r--r--xserver/hw/xfree86/common/Makefile.in38
-rw-r--r--xserver/hw/xfree86/common/compiler.h64
-rw-r--r--xserver/hw/xfree86/common/dgaproc.h62
-rw-r--r--xserver/hw/xfree86/common/vidmodeproc.h84
-rw-r--r--xserver/hw/xfree86/common/xf86.h11
-rw-r--r--xserver/hw/xfree86/common/xf86AutoConfig.c2
-rw-r--r--xserver/hw/xfree86/common/xf86Bus.c23
-rw-r--r--xserver/hw/xfree86/common/xf86Config.c117
-rw-r--r--xserver/hw/xfree86/common/xf86Configure.c6
-rw-r--r--xserver/hw/xfree86/common/xf86DGA.c38
-rw-r--r--xserver/hw/xfree86/common/xf86Events.c4
-rw-r--r--xserver/hw/xfree86/common/xf86Extensions.c3
-rw-r--r--xserver/hw/xfree86/common/xf86Helper.c51
-rw-r--r--xserver/hw/xfree86/common/xf86Init.c1
-rw-r--r--xserver/hw/xfree86/common/xf86Mode.c11
-rw-r--r--xserver/hw/xfree86/common/xf86Module.h4
-rw-r--r--xserver/hw/xfree86/common/xf86Privstr.h10
-rw-r--r--xserver/hw/xfree86/common/xf86VidMode.c582
-rw-r--r--xserver/hw/xfree86/common/xf86Xinput.c55
-rw-r--r--xserver/hw/xfree86/common/xf86Xinput.h13
-rw-r--r--xserver/hw/xfree86/common/xf86cmap.c6
-rw-r--r--xserver/hw/xfree86/common/xf86fbman.c11
-rw-r--r--xserver/hw/xfree86/common/xf86pciBus.c10
-rw-r--r--xserver/hw/xfree86/common/xf86platformBus.c9
-rw-r--r--xserver/hw/xfree86/common/xf86sbusBus.c10
-rw-r--r--xserver/hw/xfree86/common/xf86str.h102
-rw-r--r--xserver/hw/xfree86/common/xf86vmode.c2165
-rw-r--r--xserver/hw/xfree86/common/xf86xv.c10
-rw-r--r--xserver/hw/xfree86/common/xf86xvmc.c2
30 files changed, 438 insertions, 3072 deletions
diff --git a/xserver/hw/xfree86/common/Makefile.am b/xserver/hw/xfree86/common/Makefile.am
index 54e7f4d0a..caae7fd97 100644
--- a/xserver/hw/xfree86/common/Makefile.am
+++ b/xserver/hw/xfree86/common/Makefile.am
@@ -14,11 +14,6 @@ XVSOURCES = xf86xv.c xf86xvmc.c
XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
endif
-if XF86VIDMODE
-XF86VMODESOURCES = xf86vmode.c
-XF86VMODE_SDK = vidmodeproc.h
-endif
-
if DGA
DGASOURCES = xf86DGA.c
DGA_SDK = dgaproc.h
@@ -72,7 +67,6 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
compiler.h \
fourcc.h \
- vidmodeproc.h \
xf86.h \
xf86Bus.h \
xf86Config.h \
diff --git a/xserver/hw/xfree86/common/Makefile.in b/xserver/hw/xfree86/common/Makefile.in
index b30bd2bd8..3e018db98 100644
--- a/xserver/hw/xfree86/common/Makefile.in
+++ b/xserver/hw/xfree86/common/Makefile.in
@@ -61,8 +61,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/xorg-tls.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -83,26 +82,25 @@ am__libcommon_la_SOURCES_DIST = xf86Configure.c xf86Bus.c xf86Config.c \
xf86AutoConfig.c xf86Option.c xf86Init.c xf86VidMode.c \
xf86fbman.c xf86cmap.c xf86Helper.c xf86PM.c xf86Xinput.c \
xisb.c xf86Mode.c xorgHelper.c xf86Extensions.h \
- xf86Extensions.c xf86vmode.c xf86xv.c xf86xvmc.c xf86fbBus.c \
- xf86noBus.c xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \
+ xf86Extensions.c xf86xv.c xf86xvmc.c xf86fbBus.c xf86noBus.c \
+ xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \
xf86VGAarbiterPriv.h xf86sbusBus.c xf86platformBus.c \
xf86RandR.c
@DGA_TRUE@am__objects_1 = xf86DGA.lo
-@XF86VIDMODE_TRUE@am__objects_2 = xf86vmode.lo
-@XV_TRUE@am__objects_3 = xf86xv.lo xf86xvmc.lo
-@XORG_BUS_PCI_TRUE@am__objects_4 = xf86pciBus.lo xf86VGAarbiter.lo
-@XORG_BUS_SPARC_TRUE@am__objects_5 = xf86sbusBus.lo
-@XORG_BUS_PLATFORM_TRUE@am__objects_6 = xf86platformBus.lo
-am__objects_7 = xf86fbBus.lo xf86noBus.lo $(am__objects_4) \
- $(am__objects_5) $(am__objects_6)
-am__objects_8 = xf86RandR.lo
+@XV_TRUE@am__objects_2 = xf86xv.lo xf86xvmc.lo
+@XORG_BUS_PCI_TRUE@am__objects_3 = xf86pciBus.lo xf86VGAarbiter.lo
+@XORG_BUS_SPARC_TRUE@am__objects_4 = xf86sbusBus.lo
+@XORG_BUS_PLATFORM_TRUE@am__objects_5 = xf86platformBus.lo
+am__objects_6 = xf86fbBus.lo xf86noBus.lo $(am__objects_3) \
+ $(am__objects_4) $(am__objects_5)
+am__objects_7 = xf86RandR.lo
am_libcommon_la_OBJECTS = xf86Configure.lo xf86Bus.lo xf86Config.lo \
xf86Cursor.lo $(am__objects_1) xf86DPMS.lo xf86Events.lo \
xf86Globals.lo xf86AutoConfig.lo xf86Option.lo xf86Init.lo \
xf86VidMode.lo xf86fbman.lo xf86cmap.lo xf86Helper.lo \
xf86PM.lo xf86Xinput.lo xisb.lo xf86Mode.lo xorgHelper.lo \
- xf86Extensions.lo $(am__objects_2) $(am__objects_3) \
- $(am__objects_7) $(am__objects_8)
+ xf86Extensions.lo $(am__objects_2) $(am__objects_6) \
+ $(am__objects_7)
nodist_libcommon_la_OBJECTS = xf86DefModeSet.lo
libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) \
$(nodist_libcommon_la_OBJECTS)
@@ -154,9 +152,8 @@ am__can_run_installinfo = \
am__sdk_HEADERS_DIST = compiler.h fourcc.h xf86.h xf86Module.h \
xf86Opt.h xf86PciInfo.h xf86Priv.h xf86Privstr.h xf86cmap.h \
xf86fbman.h xf86str.h xf86Xinput.h xisb.h xf86xv.h xf86xvmc.h \
- xf86xvpriv.h vidmodeproc.h dgaproc.h xorgVersion.h \
- xf86sbusBus.h xf86VGAarbiter.h xf86Optionstr.h \
- xf86platformBus.h xaarop.h
+ xf86xvpriv.h dgaproc.h xorgVersion.h xf86sbusBus.h \
+ xf86VGAarbiter.h xf86Optionstr.h xf86platformBus.h xaarop.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -280,7 +277,6 @@ GLAMOR_LIBS = @GLAMOR_LIBS@
GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
GLX_SYS_LIBS = @GLX_SYS_LIBS@
-GLX_TLS = @GLX_TLS@
GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@
GREP = @GREP@
@@ -410,8 +406,6 @@ XEPHYR_INCS = @XEPHYR_INCS@
XEPHYR_LIBS = @XEPHYR_LIBS@
XF86CONFIGDIR = @XF86CONFIGDIR@
XF86CONFIGFILE = @XF86CONFIGFILE@
-XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
-XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
@@ -542,8 +536,6 @@ noinst_LTLIBRARIES = libcommon.la
@XORG_BUS_SPARC_TRUE@SBUS_SOURCES = xf86sbusBus.c
@XV_TRUE@XVSOURCES = xf86xv.c xf86xvmc.c
@XV_TRUE@XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
-@XF86VIDMODE_TRUE@XF86VMODESOURCES = xf86vmode.c
-@XF86VIDMODE_TRUE@XF86VMODE_SDK = vidmodeproc.h
@DGA_TRUE@DGASOURCES = xf86DGA.c
@DGA_TRUE@DGA_SDK = dgaproc.h
@XORG_BUS_PLATFORM_TRUE@PLATSOURCES = xf86platformBus.c
@@ -582,7 +574,6 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
compiler.h \
fourcc.h \
- vidmodeproc.h \
xf86.h \
xf86Bus.h \
xf86Config.h \
@@ -694,7 +685,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86pciBus.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86platformBus.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86sbusBus.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86vmode.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86xv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86xvmc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xisb.Plo@am__quote@
diff --git a/xserver/hw/xfree86/common/compiler.h b/xserver/hw/xfree86/common/compiler.h
index e355926b5..4e50a935d 100644
--- a/xserver/hw/xfree86/common/compiler.h
+++ b/xserver/hw/xfree86/common/compiler.h
@@ -286,7 +286,7 @@ extern _X_EXPORT unsigned int inl(unsigned int port);
#include <machine/pio.h>
#endif /* __NetBSD__ */
-#elif defined(__amd64__)
+#elif defined(__amd64__) || defined(__i386__) || defined(__ia64__)
#include <inttypes.h>
@@ -967,53 +967,6 @@ inl(unsigned PORT_SIZE port)
#endif /* NDS32_MMIO_SWAP */
-#elif defined(__i386__) || defined(__ia64__)
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("out%B0 (%1)"::"a"(val), "d"(port));
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("out%W0 (%1)"::"a"(val), "d"(port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("out%L0 (%1)"::"a"(val), "d"(port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("in%B0 (%1)":"=a"(ret):"d"(port));
-
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("in%W0 (%1)":"=a"(ret):"d"(port));
-
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("in%L0 (%1)":"=a"(ret):"d"(port));
-
- return ret;
-}
-
#endif /* arch madness */
#else /* !GNUC */
@@ -1036,18 +989,7 @@ inl(unsigned short port)
/* entry points for Mmio memory access routines */
extern _X_EXPORT int (*xf86ReadMmio8) (void *, unsigned long);
extern _X_EXPORT int (*xf86ReadMmio16) (void *, unsigned long);
-
-#ifndef STANDALONE_MMIO
extern _X_EXPORT int (*xf86ReadMmio32) (void *, unsigned long);
-#else
-/* Some DRI 3D drivers need MMIO_IN32. */
-static __inline__ int
-xf86ReadMmio32(void *Base, unsigned long Offset)
-{
- mem_barrier();
- return *(volatile unsigned int *) ((unsigned long) Base + (Offset));
-}
-#endif
extern _X_EXPORT void (*xf86WriteMmio8) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio16) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio32) (int, void *, unsigned long);
@@ -1059,11 +1001,7 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
/* Changed to kill noise generated by gcc's -Wcast-align */
#define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
#define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
-#ifndef STANDALONE_MMIO
#define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
-#else
-#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-#endif
#define MMIO_OUT32(base, offset, val) \
do { \
diff --git a/xserver/hw/xfree86/common/dgaproc.h b/xserver/hw/xfree86/common/dgaproc.h
index 87e923f26..7925bd483 100644
--- a/xserver/hw/xfree86/common/dgaproc.h
+++ b/xserver/hw/xfree86/common/dgaproc.h
@@ -54,57 +54,15 @@ typedef struct {
/* DDX interface */
-extern _X_EXPORT int
- DGASetMode(int Index, int num, XDGAModePtr mode, PixmapPtr *pPix);
-
-extern _X_EXPORT void
- DGASetInputMode(int Index, Bool keyboard, Bool mouse);
-
-extern _X_EXPORT void
- DGASelectInput(int Index, ClientPtr client, long mask);
-
-extern _X_EXPORT Bool DGAAvailable(int Index);
-extern _X_EXPORT Bool DGAScreenAvailable(ScreenPtr pScreen);
-extern _X_EXPORT Bool DGAActive(int Index);
-extern _X_EXPORT void DGAShutdown(void);
-extern _X_EXPORT void DGAInstallCmap(ColormapPtr cmap);
-extern _X_EXPORT int DGAGetViewportStatus(int Index);
-extern _X_EXPORT int DGASync(int Index);
-
-extern _X_EXPORT int
- DGAFillRect(int Index, int x, int y, int w, int h, unsigned long color);
-
-extern _X_EXPORT int
- DGABlitRect(int Index, int srcx, int srcy, int w, int h, int dstx, int dsty);
-
-extern _X_EXPORT int
-
-DGABlitTransRect(int Index,
- int srcx, int srcy,
- int w, int h, int dstx, int dsty, unsigned long color);
-
-extern _X_EXPORT int
- DGASetViewport(int Index, int x, int y, int mode);
-
-extern _X_EXPORT int DGAGetModes(int Index);
-extern _X_EXPORT int DGAGetOldDGAMode(int Index);
-
-extern _X_EXPORT int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
-
-extern _X_EXPORT Bool DGAVTSwitch(void);
-extern _X_EXPORT Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index,
- int button, int is_down);
-extern _X_EXPORT Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx,
- int dy);
-extern _X_EXPORT Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index,
- int key_code, int is_down);
-
-extern _X_EXPORT Bool DGAOpenFramebuffer(int Index, char **name,
- unsigned char **mem, int *size,
- int *offset, int *flags);
-extern _X_EXPORT void DGACloseFramebuffer(int Index);
-extern _X_EXPORT Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode);
-extern _X_EXPORT int DGACreateColormap(int Index, ClientPtr client, int id,
- int mode, int alloc);
+extern Bool DGAScreenAvailable(ScreenPtr pScreen);
+extern Bool DGAActive(int Index);
+extern void DGAShutdown(void);
+
+extern Bool DGAVTSwitch(void);
+extern Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index,
+ int button, int is_down);
+extern Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
+extern Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index,
+ int key_code, int is_down);
#endif /* __DGAPROC_H */
diff --git a/xserver/hw/xfree86/common/vidmodeproc.h b/xserver/hw/xfree86/common/vidmodeproc.h
deleted file mode 100644
index cff340c47..000000000
--- a/xserver/hw/xfree86/common/vidmodeproc.h
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/* Prototypes for DGA functions that the DDX must provide */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _VIDMODEPROC_H_
-#define _VIDMODEPROC_H_
-
-typedef enum {
- VIDMODE_H_DISPLAY,
- VIDMODE_H_SYNCSTART,
- VIDMODE_H_SYNCEND,
- VIDMODE_H_TOTAL,
- VIDMODE_H_SKEW,
- VIDMODE_V_DISPLAY,
- VIDMODE_V_SYNCSTART,
- VIDMODE_V_SYNCEND,
- VIDMODE_V_TOTAL,
- VIDMODE_FLAGS,
- VIDMODE_CLOCK
-} VidModeSelectMode;
-
-typedef enum {
- VIDMODE_MON_VENDOR,
- VIDMODE_MON_MODEL,
- VIDMODE_MON_NHSYNC,
- VIDMODE_MON_NVREFRESH,
- VIDMODE_MON_HSYNC_LO,
- VIDMODE_MON_HSYNC_HI,
- VIDMODE_MON_VREFRESH_LO,
- VIDMODE_MON_VREFRESH_HI
-} VidModeSelectMonitor;
-
-typedef union {
- const void *ptr;
- int i;
- float f;
-} vidMonitorValue;
-
-extern Bool VidModeExtensionInit(ScreenPtr pScreen);
-
-extern _X_EXPORT Bool VidModeAvailable(int scrnIndex);
-extern _X_EXPORT Bool VidModeGetCurrentModeline(int scrnIndex, void **mode,
- int *dotClock);
-extern _X_EXPORT Bool VidModeGetFirstModeline(int scrnIndex, void **mode,
- int *dotClock);
-extern _X_EXPORT Bool VidModeGetNextModeline(int scrnIndex, void **mode,
- int *dotClock);
-extern _X_EXPORT Bool VidModeDeleteModeline(int scrnIndex, void *mode);
-extern _X_EXPORT Bool VidModeZoomViewport(int scrnIndex, int zoom);
-extern _X_EXPORT Bool VidModeGetViewPort(int scrnIndex, int *x, int *y);
-extern _X_EXPORT Bool VidModeSetViewPort(int scrnIndex, int x, int y);
-extern _X_EXPORT Bool VidModeSwitchMode(int scrnIndex, void *mode);
-extern _X_EXPORT Bool VidModeLockZoom(int scrnIndex, Bool lock);
-extern _X_EXPORT Bool VidModeGetMonitor(int scrnIndex, void **monitor);
-extern _X_EXPORT int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock);
-extern _X_EXPORT Bool VidModeGetClocks(int scrnIndex, int *Clocks);
-extern _X_EXPORT ModeStatus VidModeCheckModeForMonitor(int scrnIndex,
- void *mode);
-extern _X_EXPORT ModeStatus VidModeCheckModeForDriver(int scrnIndex,
- void *mode);
-extern _X_EXPORT void VidModeSetCrtcForMode(int scrnIndex, void *mode);
-extern _X_EXPORT Bool VidModeAddModeline(int scrnIndex, void *mode);
-extern _X_EXPORT int VidModeGetDotClock(int scrnIndex, int Clock);
-extern _X_EXPORT int VidModeGetNumOfModes(int scrnIndex);
-extern _X_EXPORT Bool VidModeSetGamma(int scrnIndex, float red, float green,
- float blue);
-extern _X_EXPORT Bool VidModeGetGamma(int scrnIndex, float *red, float *green,
- float *blue);
-extern _X_EXPORT void *VidModeCreateMode(void);
-extern _X_EXPORT void VidModeCopyMode(void *modefrom, void *modeto);
-extern _X_EXPORT int VidModeGetModeValue(void *mode, int valtyp);
-extern _X_EXPORT void VidModeSetModeValue(void *mode, int valtyp, int val);
-extern _X_EXPORT vidMonitorValue VidModeGetMonitorValue(void *monitor,
- int valtyp, int indx);
-extern _X_EXPORT Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *,
- CARD16 *);
-extern _X_EXPORT Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *,
- CARD16 *);
-extern _X_EXPORT int VidModeGetGammaRampSize(int scrnIndex);
-
-#endif
diff --git a/xserver/hw/xfree86/common/xf86.h b/xserver/hw/xfree86/common/xf86.h
index 49ff35b86..1cde47873 100644
--- a/xserver/hw/xfree86/common/xf86.h
+++ b/xserver/hw/xfree86/common/xf86.h
@@ -368,22 +368,11 @@ xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
/* xf86Mode.c */
-extern _X_EXPORT int
-xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int DivFactor, int MulFactor, int *divider);
extern _X_EXPORT const char *
xf86ModeStatusToString(ModeStatus status);
extern _X_EXPORT ModeStatus
-xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy);
-extern _X_EXPORT ModeStatus
xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
extern _X_EXPORT ModeStatus
-xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- ClockRangePtr clockRanges,
- LookupModeFlags strategy,
- int maxPitch, int virtualX, int virtualY);
-extern _X_EXPORT ModeStatus
xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags);
extern _X_EXPORT int
xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
diff --git a/xserver/hw/xfree86/common/xf86AutoConfig.c b/xserver/hw/xfree86/common/xf86AutoConfig.c
index b0e036058..117e5d7ab 100644
--- a/xserver/hw/xfree86/common/xf86AutoConfig.c
+++ b/xserver/hw/xfree86/common/xf86AutoConfig.c
@@ -105,7 +105,7 @@ AppendToList(const char *s, const char ***list, int *lines)
str = xnfstrdup(s);
for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
(*lines)++;
- *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+ *list = xnfreallocarray(*list, *lines + 1, sizeof(**list));
newstr = xnfalloc(strlen(p) + 2);
strcpy(newstr, p);
strcat(newstr, "\n");
diff --git a/xserver/hw/xfree86/common/xf86Bus.c b/xserver/hw/xfree86/common/xf86Bus.c
index ad255aeed..2b412fa2f 100644
--- a/xserver/hw/xfree86/common/xf86Bus.c
+++ b/xserver/hw/xfree86/common/xf86Bus.c
@@ -256,11 +256,11 @@ int
xf86AllocateEntity(void)
{
xf86NumEntities++;
- xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities = xnfreallocarray(xf86Entities,
+ xf86NumEntities, sizeof(EntityPtr));
xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ xnfcalloc(xf86EntityPrivateCount, sizeof(DevUnion));
return xf86NumEntities - 1;
}
@@ -326,12 +326,13 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
}
pScrn->numEntities++;
- pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
+ pScrn->entityList = xnfreallocarray(pScrn->entityList,
+ pScrn->numEntities, sizeof(int));
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
xf86Entities[entityIndex]->inUse = TRUE;
- pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
+ pScrn->entityInstanceList = xnfreallocarray(pScrn->entityInstanceList,
+ pScrn->numEntities,
+ sizeof(int));
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
}
@@ -427,8 +428,8 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
pEnt = xf86Entities[entityIndex];
pEnt->numInstances++;
- pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->devices = xnfreallocarray(pEnt->devices,
+ pEnt->numInstances, sizeof(GDevPtr));
pEnt->devices[pEnt->numInstances - 1] = dev;
dev->claimed = TRUE;
}
@@ -670,8 +671,8 @@ xf86AllocateEntityPrivateIndex(void)
idx = xf86EntityPrivateCount++;
for (i = 0; i < xf86NumEntities; i++) {
pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pEnt->entityPrivates,
+ xf86EntityPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pEnt->entityPrivates = nprivs;
diff --git a/xserver/hw/xfree86/common/xf86Config.c b/xserver/hw/xfree86/common/xf86Config.c
index e6ac49a48..8e6b2edb1 100644
--- a/xserver/hw/xfree86/common/xf86Config.c
+++ b/xserver/hw/xfree86/common/xf86Config.c
@@ -46,10 +46,8 @@
#include <xorg-config.h>
#endif
-#ifdef XF86DRI
#include <sys/types.h>
#include <grp.h>
-#endif
#include "xf86.h"
#include "xf86Modes.h"
@@ -123,18 +121,16 @@ static ModuleDefault ModuleDefaults[] = {
/* Forward declarations */
static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
- int scrnum, MessageType from);
+ int scrnum, MessageType from, Bool auto_gpu_device);
static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
- Bool active);
+ Bool active, Bool gpu);
static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
MessageType from);
static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
static Bool addDefaultModes(MonPtr monitorp);
-#ifdef XF86DRI
static void configDRI(XF86ConfDRIPtr drip);
-#endif
static void configExtensions(XF86ConfExtensionsPtr conf_ext);
/*
@@ -363,8 +359,8 @@ xf86ModulelistFromConfig(void ***optlist)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
- optarray = xnfalloc((count + 1) * sizeof(void *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
+ optarray = xnfallocarray(count + 1, sizeof(void *));
count = 0;
if (xf86configptr->conf_modules) {
modp = xf86configptr->conf_modules->mod_load_lst;
@@ -390,7 +386,7 @@ const char **
xf86DriverlistFromConfig(void)
{
int count = 0;
- int j;
+ int j, k;
const char **modulearray;
screenLayoutPtr slp;
@@ -411,8 +407,10 @@ xf86DriverlistFromConfig(void)
*/
if (xf86ConfigLayout.screens) {
slp = xf86ConfigLayout.screens;
- while ((slp++)->screen) {
+ while (slp->screen) {
count++;
+ count += slp->screen->num_gpu_devices;
+ slp++;
}
}
@@ -429,12 +427,16 @@ xf86DriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
count = 0;
slp = xf86ConfigLayout.screens;
while (slp->screen) {
modulearray[count] = slp->screen->device->driver;
count++;
+ for (k = 0; k < slp->screen->num_gpu_devices; k++) {
+ modulearray[count] = slp->screen->gpu_devices[k]->driver;
+ count++;
+ }
slp++;
}
@@ -493,7 +495,7 @@ xf86InputDriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
count = 0;
idp = xf86ConfigLayout.inputs;
while (idp && *idp) {
@@ -696,6 +698,7 @@ typedef enum {
FLAG_DRI2,
FLAG_USE_SIGIO,
FLAG_AUTO_ADD_GPU,
+ FLAG_MAX_CLIENTS,
} FlagValues;
/**
@@ -755,6 +758,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE},
{FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
{0}, FALSE},
+ {FLAG_MAX_CLIENTS, "MaxClients", OPTV_INTEGER,
+ {0}, FALSE },
{-1, NULL, OPTV_NONE,
{0}, FALSE},
};
@@ -1045,6 +1050,19 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.dri2From = X_CONFIG;
}
#endif
+
+ from = X_DEFAULT;
+ if (LimitClients != LIMITCLIENTS)
+ from = X_CMDLINE;
+ i = -1;
+ if (xf86GetOptValInteger(FlagOptions, FLAG_MAX_CLIENTS, &i)) {
+ if (i != 64 && i != 128 && i != 256 && i != 512)
+ ErrorF("MaxClients must be one of 64, 128, 256 or 512\n");
+ from = X_CONFIG;
+ LimitClients = i;
+ }
+ xf86Msg(from, "Max clients allowed: %i, resource mask: 0x%x\n",
+ LimitClients, RESOURCE_ID_MASK);
}
Bool
@@ -1085,7 +1103,7 @@ addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
for (devs = list; devs && *devs; devs++)
count++;
- list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr));
+ list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr));
list[count] = NULL;
list[count - 1] = pInfo;
@@ -1501,7 +1519,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
if (!count) /* alloc enough storage even if no screen is specified */
count = 1;
- slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+ slp = xnfcalloc((count + 1), sizeof(screenLayoutRec));
slp[count].screen = NULL;
/*
* now that we have storage, loop over the list again and fill in our
@@ -1517,7 +1535,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
else
scrnum = adjp->adj_scrnum;
if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
- X_CONFIG)) {
+ X_CONFIG, (scrnum == 0 && !adjp->list.next))) {
do {
free(slp[count].screen);
} while (count--);
@@ -1567,7 +1585,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
if (!configScreen(slp[0].screen, screen,
- 0, X_CONFIG)) {
+ 0, X_CONFIG, TRUE)) {
free(slp[0].screen);
free(slp);
return FALSE;
@@ -1625,12 +1643,12 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
}
DebugF("Found %d inactive devices in the layout section %s\n",
count, conf_layout->lay_identifier);
- gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+ gdp = xnfallocarray(count + 1, sizeof(GDevRec));
gdp[count].identifier = NULL;
idp = conf_layout->lay_inactive_lst;
count = 0;
while (idp) {
- if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE, FALSE))
goto bail;
count++;
idp = (XF86ConfInactivePtr) idp->list.next;
@@ -1696,7 +1714,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
slp[1].screen = NULL;
- if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
+ if (!configScreen(slp[0].screen, conf_screen, 0, from, TRUE)) {
free(slp);
return FALSE;
}
@@ -1745,7 +1763,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
count++;
conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
}
- adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+ adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec));
adaptor->numports = count;
count = 0;
conf_port = conf_adaptor->va_port_lst;
@@ -1761,13 +1779,14 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
static Bool
configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
- MessageType from)
+ MessageType from, Bool auto_gpu_device)
{
int count = 0;
XF86ConfDisplayPtr dispptr;
XF86ConfAdaptorLinkPtr conf_adaptor;
Bool defaultMonitor = FALSE;
XF86ConfScreenRec local_conf_screen;
+ int i;
if (!conf_screen) {
memset(&local_conf_screen, 0, sizeof(local_conf_screen));
@@ -1810,12 +1829,42 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
"\tUsing the first device section listed.\n", screenp->id);
}
- if (configDevice(screenp->device, conf_screen->scrn_device, TRUE)) {
+ if (configDevice(screenp->device, conf_screen->scrn_device, TRUE, FALSE)) {
screenp->device->myScreenSection = screenp;
}
else {
screenp->device = NULL;
}
+
+ if (auto_gpu_device && conf_screen->num_gpu_devices == 0 &&
+ xf86configptr->conf_device_lst) {
+ XF86ConfDevicePtr sdevice = xf86configptr->conf_device_lst->list.next;
+
+ for (i = 0; i < MAX_GPUDEVICES; i++) {
+ if (!sdevice)
+ break;
+
+ FIND_SUITABLE (XF86ConfDevicePtr, sdevice, conf_screen->scrn_gpu_devices[i]);
+ if (!conf_screen->scrn_gpu_devices[i])
+ break;
+ screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec));
+ if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) {
+ screenp->gpu_devices[i]->myScreenSection = screenp;
+ }
+ sdevice = conf_screen->scrn_gpu_devices[i]->list.next;
+ }
+ screenp->num_gpu_devices = i;
+
+ } else {
+ for (i = 0; i < conf_screen->num_gpu_devices; i++) {
+ screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec));
+ if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) {
+ screenp->gpu_devices[i]->myScreenSection = screenp;
+ }
+ }
+ screenp->num_gpu_devices = conf_screen->num_gpu_devices;
+ }
+
screenp->options = conf_screen->scrn_option_lst;
/*
@@ -1826,7 +1875,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
}
- screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->displays = xnfallocarray(count, sizeof(DispRec));
screenp->numdisplays = count;
/* Fill in the default Virtual size, if any */
@@ -1856,7 +1905,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
}
- screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+ screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec));
screenp->numxvadaptors = 0;
conf_adaptor = conf_screen->scrn_adaptor_lst;
while (conf_adaptor) {
@@ -2095,7 +2144,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
count++;
modep = (XF86ModePtr) modep->list.next;
}
- displayp->modes = xnfalloc((count + 1) * sizeof(char *));
+ displayp->modes = xnfallocarray(count + 1, sizeof(char *));
modep = conf_display->disp_mode_lst;
count = 0;
while (modep) {
@@ -2109,7 +2158,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
}
static Bool
-configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active, Bool gpu)
{
int i;
@@ -2117,10 +2166,14 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
return FALSE;
}
- if (active)
- xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
- conf_device->dev_identifier);
- else
+ if (active) {
+ if (gpu)
+ xf86Msg(X_CONFIG, "| |-->GPUDevice \"%s\"\n",
+ conf_device->dev_identifier);
+ else
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
+ } else
xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
conf_device->dev_identifier);
@@ -2160,7 +2213,6 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
return TRUE;
}
-#ifdef XF86DRI
static void
configDRI(XF86ConfDRIPtr drip)
{
@@ -2181,7 +2233,6 @@ configDRI(XF86ConfDRIPtr drip)
xf86ConfigDRI.mode = drip->dri_mode;
}
}
-#endif
static void
configExtensions(XF86ConfExtensionsPtr conf_ext)
@@ -2474,9 +2525,7 @@ xf86HandleConfigFile(Bool autoconfig)
configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options);
configFiles(xf86configptr->conf_files);
configExtensions(xf86configptr->conf_extensions);
-#ifdef XF86DRI
configDRI(xf86configptr->conf_dri);
-#endif
checkInput(&xf86ConfigLayout, implicit_layout);
diff --git a/xserver/hw/xfree86/common/xf86Configure.c b/xserver/hw/xfree86/common/xf86Configure.c
index f37f22445..44758bcc7 100644
--- a/xserver/hw/xfree86/common/xf86Configure.c
+++ b/xserver/hw/xfree86/common/xf86Configure.c
@@ -109,7 +109,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
/* Allocate new structure occurrence */
i = nDevToConfig++;
DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+ xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec));
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
DevToConfig[i].GDev.chipID =
@@ -645,10 +645,10 @@ DoConfigure(void)
xf86DoConfigurePass1 = FALSE;
- dev2screen = xnfcalloc(1, xf86NumDrivers * sizeof(int));
+ dev2screen = xnfcalloc(xf86NumDrivers, sizeof(int));
{
- Bool *driverProbed = xnfcalloc(1, xf86NumDrivers * sizeof(Bool));
+ Bool *driverProbed = xnfcalloc(xf86NumDrivers, sizeof(Bool));
for (screennum = 0; screennum < nDevToConfig; screennum++) {
int k, l, n, oldNumScreens;
diff --git a/xserver/hw/xfree86/common/xf86DGA.c b/xserver/hw/xfree86/common/xf86DGA.c
index b9e1e3f88..c689dcb73 100644
--- a/xserver/hw/xfree86/common/xf86DGA.c
+++ b/xserver/hw/xfree86/common/xf86DGA.c
@@ -471,7 +471,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet)
/*********** exported ones ***************/
-void
+static void
DGASetInputMode(int index, Bool keyboard, Bool mouse)
{
ScreenPtr pScreen = screenInfo.screens[index];
@@ -488,7 +488,7 @@ DGASetInputMode(int index, Bool keyboard, Bool mouse)
}
}
-Bool
+static Bool
DGAChangePixmapMode(int index, int *x, int *y, int mode)
{
DGAScreenPtr pScreenPriv;
@@ -560,7 +560,7 @@ DGAScreenAvailable(ScreenPtr pScreen)
return FALSE;
}
-Bool
+static Bool
DGAAvailable(int index)
{
ScreenPtr pScreen;
@@ -606,7 +606,7 @@ DGAShutdown(void)
/* Called by the extension to initialize a mode */
-int
+static int
DGASetMode(int index, int num, XDGAModePtr mode, PixmapPtr *pPix)
{
ScrnInfoPtr pScrn = xf86Screens[index];
@@ -626,7 +626,7 @@ DGASetMode(int index, int num, XDGAModePtr mode, PixmapPtr *pPix)
/* Called from the extension to let the DDX know which events are requested */
-void
+static void
DGASelectInput(int index, ClientPtr client, long mask)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -636,7 +636,7 @@ DGASelectInput(int index, ClientPtr client, long mask)
pScreenPriv->input = mask;
}
-int
+static int
DGAGetViewportStatus(int index)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -649,7 +649,7 @@ DGAGetViewportStatus(int index)
return (*pScreenPriv->funcs->GetViewport) (pScreenPriv->pScrn);
}
-int
+static int
DGASetViewport(int index, int x, int y, int mode)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -675,7 +675,7 @@ BitsClear(CARD32 data)
return bits;
}
-int
+static int
DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
{
ScreenPtr pScreen = screenInfo.screens[index];
@@ -744,7 +744,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
/* Called by the extension to install a colormap on DGA active screens */
-void
+static void
DGAInstallCmap(ColormapPtr cmap)
{
ScreenPtr pScreen = cmap->pScreen;
@@ -760,7 +760,7 @@ DGAInstallCmap(ColormapPtr cmap)
(*pScreen->InstallColormap) (cmap);
}
-int
+static int
DGASync(int index)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -773,7 +773,7 @@ DGASync(int index)
return Success;
}
-int
+static int
DGAFillRect(int index, int x, int y, int w, int h, unsigned long color)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -789,7 +789,7 @@ DGAFillRect(int index, int x, int y, int w, int h, unsigned long color)
return BadMatch;
}
-int
+static int
DGABlitRect(int index, int srcx, int srcy, int w, int h, int dstx, int dsty)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -806,7 +806,7 @@ DGABlitRect(int index, int srcx, int srcy, int w, int h, int dstx, int dsty)
return BadMatch;
}
-int
+static int
DGABlitTransRect(int index,
int srcx, int srcy,
int w, int h, int dstx, int dsty, unsigned long color)
@@ -826,7 +826,7 @@ DGABlitTransRect(int index,
return BadMatch;
}
-int
+static int
DGAGetModes(int index)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -836,7 +836,7 @@ DGAGetModes(int index)
return pScreenPriv->numModes;
}
-int
+static int
DGAGetModeInfo(int index, XDGAModePtr mode, int num)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1126,7 +1126,7 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
}
}
-Bool
+static Bool
DGAOpenFramebuffer(int index,
char **name,
unsigned char **mem, int *size, int *offset, int *flags)
@@ -1140,7 +1140,7 @@ DGAOpenFramebuffer(int index,
flags);
}
-void
+static void
DGACloseFramebuffer(int index)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1152,7 +1152,7 @@ DGACloseFramebuffer(int index)
/* For DGA 1.0 backwards compatibility only */
-int
+static int
DGAGetOldDGAMode(int index)
{
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1349,7 +1349,7 @@ ProcXDGAQueryModes(ClientPtr client)
return Success;
}
- if (!(mode = (XDGAModePtr) malloc(num * sizeof(XDGAModeRec))))
+ if (!(mode = xallocarray(num, sizeof(XDGAModeRec))))
return BadAlloc;
for (i = 0; i < num; i++)
diff --git a/xserver/hw/xfree86/common/xf86Events.c b/xserver/hw/xfree86/common/xf86Events.c
index 2b84d8669..6570f0be9 100644
--- a/xserver/hw/xfree86/common/xf86Events.c
+++ b/xserver/hw/xfree86/common/xf86Events.c
@@ -180,7 +180,7 @@ ProcessInputEvents(void)
void
xf86ProcessActionEvent(ActionEvent action, void *arg)
{
- DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
+ DebugF("ProcessActionEvent(%d,%p)\n", (int) action, arg);
switch (action) {
case ACTION_TERMINATE:
if (!xf86Info.dontZap) {
@@ -403,7 +403,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
i < keyc->xkbInfo->desc->max_key_code; i++) {
if (key_is_down(pDev, i, KEY_POSTED)) {
OsBlockSIGIO();
- QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
+ QueueKeyboardEvents(pDev, KeyRelease, i);
OsReleaseSIGIO();
}
}
diff --git a/xserver/hw/xfree86/common/xf86Extensions.c b/xserver/hw/xfree86/common/xf86Extensions.c
index 25b2bc3d0..1b8b78505 100644
--- a/xserver/hw/xfree86/common/xf86Extensions.c
+++ b/xserver/hw/xfree86/common/xf86Extensions.c
@@ -28,6 +28,7 @@
#endif
#include "extension.h"
+#include "extinit.h"
#include "globals.h"
#include "xf86.h"
@@ -47,7 +48,7 @@
#ifdef XF86VIDMODE
#include <X11/extensions/xf86vmproto.h>
-#include "vidmodeproc.h"
+#include "vidmodestr.h"
#endif
/*
diff --git a/xserver/hw/xfree86/common/xf86Helper.c b/xserver/hw/xfree86/common/xf86Helper.c
index e2b32a074..3b01a49b5 100644
--- a/xserver/hw/xfree86/common/xf86Helper.c
+++ b/xserver/hw/xfree86/common/xf86Helper.c
@@ -77,8 +77,8 @@ xf86AddDriver(DriverPtr driver, void *module, int flags)
xf86NumDrivers = 0;
xf86NumDrivers++;
- xf86DriverList = xnfrealloc(xf86DriverList,
- xf86NumDrivers * sizeof(DriverPtr));
+ xf86DriverList = xnfreallocarray(xf86DriverList,
+ xf86NumDrivers, sizeof(DriverPtr));
xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
if (flags & HaveDriverFuncs)
*xf86DriverList[xf86NumDrivers - 1] = *driver;
@@ -117,9 +117,9 @@ xf86AddInputDriver(InputDriverPtr driver, void *module, int flags)
xf86NumInputDrivers = 0;
xf86NumInputDrivers++;
- xf86InputDriverList = xnfrealloc(xf86InputDriverList,
- xf86NumInputDrivers *
- sizeof(InputDriverPtr));
+ xf86InputDriverList = xnfreallocarray(xf86InputDriverList,
+ xf86NumInputDrivers,
+ sizeof(InputDriverPtr));
xf86InputDriverList[xf86NumInputDrivers - 1] =
xnfalloc(sizeof(InputDriverRec));
*xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
@@ -173,7 +173,8 @@ xf86AllocateScreen(DriverPtr drv, int flags)
if (xf86GPUScreens == NULL)
xf86NumGPUScreens = 0;
i = xf86NumGPUScreens++;
- xf86GPUScreens = xnfrealloc(xf86GPUScreens, xf86NumGPUScreens * sizeof(ScrnInfoPtr));
+ xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens,
+ sizeof(ScrnInfoPtr));
xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
pScrn = xf86GPUScreens[i];
pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */
@@ -183,7 +184,8 @@ xf86AllocateScreen(DriverPtr drv, int flags)
xf86NumScreens = 0;
i = xf86NumScreens++;
- xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
+ xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens,
+ sizeof(ScrnInfoPtr));
xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
pScrn = xf86Screens[i];
@@ -293,16 +295,16 @@ xf86AllocateScrnInfoPrivateIndex(void)
idx = xf86ScrnInfoPrivateCount++;
for (i = 0; i < xf86NumScreens; i++) {
pScr = xf86Screens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pScr->privates,
+ xf86ScrnInfoPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
}
for (i = 0; i < xf86NumGPUScreens; i++) {
pScr = xf86GPUScreens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pScr->privates,
+ xf86ScrnInfoPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
@@ -636,8 +638,8 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
if (i == scrp->confScreen->numdisplays) {
scrp->confScreen->numdisplays++;
scrp->confScreen->displays =
- xnfrealloc(scrp->confScreen->displays,
- scrp->confScreen->numdisplays * sizeof(DispRec));
+ xnfreallocarray(scrp->confScreen->displays,
+ scrp->confScreen->numdisplays, sizeof(DispRec));
xf86DrvMsg(scrp->scrnIndex, X_INFO,
"Creating default Display subsection in Screen section\n"
"\t\"%s\" for depth/fbbpp %d/%d\n",
@@ -1074,14 +1076,14 @@ xf86EnableDisableFBAccess(ScrnInfoPtr pScrnInfo, Bool enable)
* Restore all of the clip lists on the screen
*/
if (!xf86Resetting)
- SetRootClip(pScreen, TRUE);
+ SetRootClip(pScreen, ROOT_CLIP_FULL);
}
else {
/*
* Empty all of the clip lists on the screen
*/
- SetRootClip(pScreen, FALSE);
+ SetRootClip(pScreen, ROOT_CLIP_NONE);
}
}
@@ -1367,7 +1369,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
{
GDevPtr gdp, *pgdp = NULL;
confScreenPtr screensecptr;
- int i, j;
+ int i, j, k;
if (sectlist)
*sectlist = NULL;
@@ -1408,9 +1410,20 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
/*
* we have a matching driver that wasn't claimed, yet
*/
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
pgdp[i++] = screensecptr->device;
}
+ for (k = 0; k < screensecptr->num_gpu_devices; k++) {
+ if ((screensecptr->gpu_devices[k]->driver != NULL)
+ && (xf86NameCmp(screensecptr->gpu_devices[k]->driver, drivername) == 0)
+ && (!screensecptr->gpu_devices[k]->claimed)) {
+ /*
+ * we have a matching driver that wasn't claimed, yet
+ */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = screensecptr->gpu_devices[k];
+ }
+ }
}
/* Then handle the inactive devices */
@@ -1420,7 +1433,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
if (gdp->driver && !gdp->claimed &&
!xf86NameCmp(gdp->driver, drivername)) {
/* we have a matching driver that wasn't claimed yet */
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
pgdp[i++] = gdp;
}
j++;
@@ -1818,7 +1831,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
Bool existing = FALSE;
DebugF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n",
- ScrnIndex, property, type, format, len, value);
+ ScrnIndex, (long)property, (long)type, format, len, value);
if (ScrnIndex < 0 || ScrnIndex >= xf86NumScreens) {
return BadMatch;
diff --git a/xserver/hw/xfree86/common/xf86Init.c b/xserver/hw/xfree86/common/xf86Init.c
index 1c37b9e85..8785ef307 100644
--- a/xserver/hw/xfree86/common/xf86Init.c
+++ b/xserver/hw/xfree86/common/xf86Init.c
@@ -72,6 +72,7 @@
#include "mipointer.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+#include "xf86Extensions.h"
#include "xf86DDC.h"
#include "xf86Xinput.h"
#include "xf86InPriv.h"
diff --git a/xserver/hw/xfree86/common/xf86Mode.c b/xserver/hw/xfree86/common/xf86Mode.c
index 9a5550faf..3f446ae3b 100644
--- a/xserver/hw/xfree86/common/xf86Mode.c
+++ b/xserver/hw/xfree86/common/xf86Mode.c
@@ -112,11 +112,10 @@ printModeRejectMessage(int index, DisplayModePtr p, int status)
}
/*
- * xf86GetNearestClock --
- * Find closest clock to given frequency (in kHz). This assumes the
- * number of clocks is greater than zero.
+ * Find closest clock to given frequency (in kHz). This assumes the
+ * number of clocks is greater than zero.
*/
-int
+static int
xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
int DivFactor, int MulFactor, int *divider)
{
@@ -451,7 +450,7 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
* reason.
*/
-ModeStatus
+static ModeStatus
xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
ClockRangePtr clockRanges, LookupModeFlags strategy)
{
@@ -845,7 +844,7 @@ xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
* maxVValue maximum vertical timing value
*/
-ModeStatus
+static ModeStatus
xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
ClockRangePtr clockRanges,
LookupModeFlags strategy,
diff --git a/xserver/hw/xfree86/common/xf86Module.h b/xserver/hw/xfree86/common/xf86Module.h
index e68fe9cba..9e5dc6dad 100644
--- a/xserver/hw/xfree86/common/xf86Module.h
+++ b/xserver/hw/xfree86/common/xf86Module.h
@@ -80,8 +80,8 @@ typedef enum {
* mask is 0xFFFF0000.
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(19, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(21, 0)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(20, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(22, 1)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(9, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/xserver/hw/xfree86/common/xf86Privstr.h b/xserver/hw/xfree86/common/xf86Privstr.h
index cffa14d01..58d5a0f13 100644
--- a/xserver/hw/xfree86/common/xf86Privstr.h
+++ b/xserver/hw/xfree86/common/xf86Privstr.h
@@ -115,16 +115,6 @@ typedef struct {
} DPMSRec, *DPMSPtr;
#endif
-#ifdef XF86VIDMODE
-/* Private info for Video Mode Extentsion */
-typedef struct {
- DisplayModePtr First;
- DisplayModePtr Next;
- int Flags;
- CloseScreenProcPtr CloseScreen;
-} VidModeRec, *VidModePtr;
-#endif
-
/* Information for root window properties. */
typedef struct _RootWinProp {
struct _RootWinProp *next;
diff --git a/xserver/hw/xfree86/common/xf86VidMode.c b/xserver/hw/xfree86/common/xf86VidMode.c
index e708b2792..7e12ea2cc 100644
--- a/xserver/hw/xfree86/common/xf86VidMode.c
+++ b/xserver/hw/xfree86/common/xf86VidMode.c
@@ -42,113 +42,62 @@
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
+#include "extinit.h"
#ifdef XF86VIDMODE
-#include "vidmodeproc.h"
+#include "vidmodestr.h"
+#include "xf86Privstr.h"
+#include "xf86Extensions.h"
#include "xf86cmap.h"
-static DevPrivateKeyRec VidModeKeyRec;
-static DevPrivateKey VidModeKey;
-static int VidModeCount = 0;
-static Bool VidModeClose(ScreenPtr pScreen);
-
-#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey))
-
-#endif
-
-Bool
-VidModeExtensionInit(ScreenPtr pScreen)
-{
-#ifdef XF86VIDMODE
- VidModePtr pVidMode;
-
- if (!xf86GetVidModeEnabled()) {
- DebugF("!xf86GetVidModeEnabled()\n");
- return FALSE;
- }
-
- VidModeKey = &VidModeKeyRec;
-
- if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- pVidMode = calloc(sizeof(VidModeRec), 1);
- if (!pVidMode)
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
-
- pVidMode->Flags = 0;
- pVidMode->Next = NULL;
- pVidMode->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = VidModeClose;
- VidModeCount++;
- return TRUE;
-#else
- DebugF("no vidmode extension\n");
- return FALSE;
-#endif
-}
-
-#ifdef XF86VIDMODE
-
-static Bool
-VidModeClose(ScreenPtr pScreen)
-{
- VidModePtr pVidMode = VMPTR(pScreen);
-
- /* This shouldn't happen */
- if (!pVidMode)
- return FALSE;
-
- pScreen->CloseScreen = pVidMode->CloseScreen;
-
- if (--VidModeCount == 0) {
- free(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
- dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
- VidModeKey = NULL;
- }
- return pScreen->CloseScreen(pScreen);
-}
-
-Bool
-VidModeAvailable(int scrnIndex)
+static vidMonitorValue
+xf86VidModeGetMonitorValue(ScreenPtr pScreen, int valtyp, int indx)
{
+ vidMonitorValue ret = { NULL, };
+ MonPtr monitor;
ScrnInfoPtr pScrn;
- VidModePtr pVidMode;
- if (VidModeKey == NULL) {
- DebugF("VidModeKey == NULL\n");
- return FALSE;
- }
+ pScrn = xf86ScreenToScrn(pScreen);
+ monitor = pScrn->monitor;
- pScrn = xf86Screens[scrnIndex];
- if (pScrn == NULL) {
- DebugF("pScrn == NULL\n");
- return FALSE;
- }
-
- pVidMode = VMPTR(pScrn->pScreen);
- if (pVidMode)
- return TRUE;
- else {
- DebugF("pVidMode == NULL\n");
- return FALSE;
+ switch (valtyp) {
+ case VIDMODE_MON_VENDOR:
+ ret.ptr = monitor->vendor;
+ break;
+ case VIDMODE_MON_MODEL:
+ ret.ptr = monitor->model;
+ break;
+ case VIDMODE_MON_NHSYNC:
+ ret.i = monitor->nHsync;
+ break;
+ case VIDMODE_MON_NVREFRESH:
+ ret.i = monitor->nVrefresh;
+ break;
+ case VIDMODE_MON_HSYNC_LO:
+ ret.f = (100.0 * monitor->hsync[indx].lo);
+ break;
+ case VIDMODE_MON_HSYNC_HI:
+ ret.f = (100.0 * monitor->hsync[indx].hi);
+ break;
+ case VIDMODE_MON_VREFRESH_LO:
+ ret.f = (100.0 * monitor->vrefresh[indx].lo);
+ break;
+ case VIDMODE_MON_VREFRESH_HI:
+ ret.f = (100.0 * monitor->vrefresh[indx].hi);
+ break;
}
+ return ret;
}
-Bool
-VidModeGetCurrentModeline(int scrnIndex, void **mode, int *dotClock)
+static Bool
+xf86VidModeGetCurrentModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
if (pScrn->currentMode) {
- *mode = (void *) (pScrn->currentMode);
+ *mode = pScrn->currentMode;
*dotClock = pScrn->currentMode->Clock;
return TRUE;
@@ -156,30 +105,24 @@ VidModeGetCurrentModeline(int scrnIndex, void **mode, int *dotClock)
return FALSE;
}
-int
-VidModeGetDotClock(int scrnIndex, int Clock)
+static int
+xf86VidModeGetDotClock(ScreenPtr pScreen, int Clock)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return 0;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
if ((pScrn->progClock) || (Clock >= MAXCLOCKS))
return Clock;
else
return pScrn->clock[Clock];
}
-int
-VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
+static int
+xf86VidModeGetNumOfClocks(ScreenPtr pScreen, Bool *progClock)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return 0;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
if (pScrn->progClock) {
*progClock = TRUE;
return 0;
@@ -190,16 +133,13 @@ VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
}
}
-Bool
-VidModeGetClocks(int scrnIndex, int *Clocks)
+static Bool
+xf86VidModeGetClocks(ScreenPtr pScreen, int *Clocks)
{
ScrnInfoPtr pScrn;
int i;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
if (pScrn->progClock)
return FALSE;
@@ -210,92 +150,75 @@ VidModeGetClocks(int scrnIndex, int *Clocks)
return TRUE;
}
-Bool
-VidModeGetFirstModeline(int scrnIndex, void **mode, int *dotClock)
+static Bool
+xf86VidModeGetNextModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
{
- ScrnInfoPtr pScrn;
VidModePtr pVidMode;
+ DisplayModePtr p;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
- if (pScrn->modes == NULL)
- return FALSE;
-
- pVidMode = VMPTR(pScrn->pScreen);
- pVidMode->First = pScrn->modes;
- pVidMode->Next = pVidMode->First->next;
+ pVidMode = VidModeGetPtr(pScreen);
- if (pVidMode->First->status == MODE_OK) {
- *mode = (void *) (pVidMode->First);
- *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock);
- return TRUE;
+ for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
+ if (p->status == MODE_OK) {
+ pVidMode->Next = p->next;
+ *mode = p;
+ *dotClock = xf86VidModeGetDotClock(pScreen, p->Clock);
+ return TRUE;
+ }
}
- return VidModeGetNextModeline(scrnIndex, mode, dotClock);
+ return FALSE;
}
-Bool
-VidModeGetNextModeline(int scrnIndex, void **mode, int *dotClock)
+static Bool
+xf86VidModeGetFirstModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
{
ScrnInfoPtr pScrn;
VidModePtr pVidMode;
- DisplayModePtr p;
- if (!VidModeAvailable(scrnIndex))
+ pScrn = xf86ScreenToScrn(pScreen);
+ if (pScrn->modes == NULL)
return FALSE;
- pScrn = xf86Screens[scrnIndex];
- pVidMode = VMPTR(pScrn->pScreen);
+ pVidMode = VidModeGetPtr(pScreen);
+ pVidMode->First = pScrn->modes;
+ pVidMode->Next = pVidMode->First->next;
- for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
- if (p->status == MODE_OK) {
- pVidMode->Next = p->next;
- *mode = (void *) p;
- *dotClock = VidModeGetDotClock(scrnIndex, p->Clock);
- return TRUE;
- }
+ if (pVidMode->First->status == MODE_OK) {
+ *mode = pVidMode->First;
+ *dotClock = xf86VidModeGetDotClock(pScreen, pVidMode->First->Clock);
+ return TRUE;
}
- return FALSE;
+ return xf86VidModeGetNextModeline(pScreen, mode, dotClock);
}
-Bool
-VidModeDeleteModeline(int scrnIndex, void *mode)
+static Bool
+xf86VidModeDeleteModeline(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ if (mode == NULL)
return FALSE;
- pScrn = xf86Screens[scrnIndex];
- xf86DeleteMode(&(pScrn->modes), (DisplayModePtr) mode);
+ pScrn = xf86ScreenToScrn(pScreen);
+ xf86DeleteMode(&(pScrn->modes), mode);
return TRUE;
}
-Bool
-VidModeZoomViewport(int scrnIndex, int zoom)
+static Bool
+xf86VidModeZoomViewport(ScreenPtr pScreen, int zoom)
{
- ScrnInfoPtr pScrn;
-
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
- xf86ZoomViewport(pScrn->pScreen, zoom);
+ xf86ZoomViewport(pScreen, zoom);
return TRUE;
}
-Bool
-VidModeSetViewPort(int scrnIndex, int x, int y)
+static Bool
+xf86VidModeSetViewPort(ScreenPtr pScreen, int x, int y)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
pScrn->frameX0 = min(max(x, 0),
pScrn->virtualX - pScrn->currentMode->HDisplay);
pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1;
@@ -308,31 +231,25 @@ VidModeSetViewPort(int scrnIndex, int x, int y)
return TRUE;
}
-Bool
-VidModeGetViewPort(int scrnIndex, int *x, int *y)
+static Bool
+xf86VidModeGetViewPort(ScreenPtr pScreen, int *x, int *y)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
*x = pScrn->frameX0;
*y = pScrn->frameY0;
return TRUE;
}
-Bool
-VidModeSwitchMode(int scrnIndex, void *mode)
+static Bool
+xf86VidModeSwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
DisplayModePtr pTmpMode;
Bool retval;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
/* save in case we fail */
pTmpMode = pScrn->currentMode;
/* Force a mode switch */
@@ -344,326 +261,203 @@ VidModeSwitchMode(int scrnIndex, void *mode)
return retval;
}
-Bool
-VidModeLockZoom(int scrnIndex, Bool lock)
+static Bool
+xf86VidModeLockZoom(ScreenPtr pScreen, Bool lock)
{
- ScrnInfoPtr pScrn;
-
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
-
if (xf86Info.dontZoom)
return FALSE;
- xf86LockZoom(pScrn->pScreen, lock);
+ xf86LockZoom(pScreen, lock);
return TRUE;
}
-Bool
-VidModeGetMonitor(int scrnIndex, void **monitor)
+static ModeStatus
+xf86VidModeCheckModeForMonitor(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
- *monitor = (void *) (pScrn->monitor);
-
- return TRUE;
-}
-
-ModeStatus
-VidModeCheckModeForMonitor(int scrnIndex, void *mode)
-{
- ScrnInfoPtr pScrn;
-
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ if (mode == NULL)
return MODE_ERROR;
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
- return xf86CheckModeForMonitor((DisplayModePtr) mode, pScrn->monitor);
+ return xf86CheckModeForMonitor(mode, pScrn->monitor);
}
-ModeStatus
-VidModeCheckModeForDriver(int scrnIndex, void *mode)
+static ModeStatus
+xf86VidModeCheckModeForDriver(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ if (mode == NULL)
return MODE_ERROR;
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
- return xf86CheckModeForDriver(pScrn, (DisplayModePtr) mode, 0);
+ return xf86CheckModeForDriver(pScrn, mode, 0);
}
-void
-VidModeSetCrtcForMode(int scrnIndex, void *mode)
+static void
+xf86VidModeSetCrtcForMode(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
DisplayModePtr ScreenModes;
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ if (mode == NULL)
return;
/* Ugly hack so that the xf86Mode.c function can be used without change */
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
ScreenModes = pScrn->modes;
- pScrn->modes = (DisplayModePtr) mode;
+ pScrn->modes = mode;
xf86SetCrtcForModes(pScrn, pScrn->adjustFlags);
pScrn->modes = ScreenModes;
return;
}
-Bool
-VidModeAddModeline(int scrnIndex, void *mode)
+static Bool
+xf86VidModeAddModeline(ScreenPtr pScreen, DisplayModePtr mode)
{
ScrnInfoPtr pScrn;
- if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ if (mode == NULL)
return FALSE;
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
- ((DisplayModePtr) mode)->name = strdup(""); /* freed by deletemode */
- ((DisplayModePtr) mode)->status = MODE_OK;
- ((DisplayModePtr) mode)->next = pScrn->modes->next;
- ((DisplayModePtr) mode)->prev = pScrn->modes;
- pScrn->modes->next = (DisplayModePtr) mode;
- if (((DisplayModePtr) mode)->next != NULL)
- ((DisplayModePtr) mode)->next->prev = (DisplayModePtr) mode;
+ mode->name = strdup(""); /* freed by deletemode */
+ mode->status = MODE_OK;
+ mode->next = pScrn->modes->next;
+ mode->prev = pScrn->modes;
+ pScrn->modes->next = mode;
+ if (mode->next != NULL)
+ mode->next->prev = mode;
return TRUE;
}
-int
-VidModeGetNumOfModes(int scrnIndex)
+static int
+xf86VidModeGetNumOfModes(ScreenPtr pScreen)
{
- void *mode = NULL;
+ DisplayModePtr mode = NULL;
int dotClock = 0, nummodes = 0;
- if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
+ if (!xf86VidModeGetFirstModeline(pScreen, &mode, &dotClock))
return nummodes;
do {
nummodes++;
- if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock))
+ if (!xf86VidModeGetNextModeline(pScreen, &mode, &dotClock))
return nummodes;
} while (TRUE);
}
-Bool
-VidModeSetGamma(int scrnIndex, float red, float green, float blue)
+static Bool
+xf86VidModeSetGamma(ScreenPtr pScreen, float red, float green, float blue)
{
- ScrnInfoPtr pScrn;
Gamma gamma;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
gamma.red = red;
gamma.green = green;
gamma.blue = blue;
- if (xf86ChangeGamma(pScrn->pScreen, gamma) != Success)
+ if (xf86ChangeGamma(pScreen, gamma) != Success)
return FALSE;
else
return TRUE;
}
-Bool
-VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
+static Bool
+xf86VidModeGetGamma(ScreenPtr pScreen, float *red, float *green, float *blue)
{
ScrnInfoPtr pScrn;
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
+ pScrn = xf86ScreenToScrn(pScreen);
*red = pScrn->gamma.red;
*green = pScrn->gamma.green;
*blue = pScrn->gamma.blue;
return TRUE;
}
-Bool
-VidModeSetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+static Bool
+xf86VidModeSetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
{
- ScrnInfoPtr pScrn;
-
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
- xf86ChangeGammaRamp(pScrn->pScreen, size, r, g, b);
+ xf86ChangeGammaRamp(pScreen, size, r, g, b);
return TRUE;
}
-Bool
-VidModeGetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+static Bool
+xf86VidModeGetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
{
- ScrnInfoPtr pScrn;
-
- if (!VidModeAvailable(scrnIndex))
- return FALSE;
-
- pScrn = xf86Screens[scrnIndex];
- xf86GetGammaRamp(pScrn->pScreen, size, r, g, b);
+ xf86GetGammaRamp(pScreen, size, r, g, b);
return TRUE;
}
-int
-VidModeGetGammaRampSize(int scrnIndex)
+static Bool
+xf86VidModeInit(ScreenPtr pScreen)
{
- if (!VidModeAvailable(scrnIndex))
- return 0;
-
- return xf86GetGammaRampSize(xf86Screens[scrnIndex]->pScreen);
-}
+ VidModePtr pVidMode;
-void *
-VidModeCreateMode(void)
-{
- DisplayModePtr mode;
-
- mode = malloc(sizeof(DisplayModeRec));
- if (mode != NULL) {
- mode->name = "";
- mode->VScan = 1; /* divides refresh rate. default = 1 */
- mode->Private = NULL;
- mode->next = mode;
- mode->prev = mode;
+ if (!xf86GetVidModeEnabled()) {
+ DebugF("!xf86GetVidModeEnabled()\n");
+ return FALSE;
}
- return mode;
-}
-void
-VidModeCopyMode(void *modefrom, void *modeto)
-{
- memcpy(modeto, modefrom, sizeof(DisplayModeRec));
-}
+ pVidMode = VidModeInit(pScreen);
+ if (!pVidMode)
+ return FALSE;
-int
-VidModeGetModeValue(void *mode, int valtyp)
-{
- int ret = 0;
+ pVidMode->Flags = 0;
+ pVidMode->Next = NULL;
- switch (valtyp) {
- case VIDMODE_H_DISPLAY:
- ret = ((DisplayModePtr) mode)->HDisplay;
- break;
- case VIDMODE_H_SYNCSTART:
- ret = ((DisplayModePtr) mode)->HSyncStart;
- break;
- case VIDMODE_H_SYNCEND:
- ret = ((DisplayModePtr) mode)->HSyncEnd;
- break;
- case VIDMODE_H_TOTAL:
- ret = ((DisplayModePtr) mode)->HTotal;
- break;
- case VIDMODE_H_SKEW:
- ret = ((DisplayModePtr) mode)->HSkew;
- break;
- case VIDMODE_V_DISPLAY:
- ret = ((DisplayModePtr) mode)->VDisplay;
- break;
- case VIDMODE_V_SYNCSTART:
- ret = ((DisplayModePtr) mode)->VSyncStart;
- break;
- case VIDMODE_V_SYNCEND:
- ret = ((DisplayModePtr) mode)->VSyncEnd;
- break;
- case VIDMODE_V_TOTAL:
- ret = ((DisplayModePtr) mode)->VTotal;
- break;
- case VIDMODE_FLAGS:
- ret = ((DisplayModePtr) mode)->Flags;
- break;
- case VIDMODE_CLOCK:
- ret = ((DisplayModePtr) mode)->Clock;
- break;
- }
- return ret;
+ pVidMode->GetMonitorValue = xf86VidModeGetMonitorValue;
+ pVidMode->GetCurrentModeline = xf86VidModeGetCurrentModeline;
+ pVidMode->GetFirstModeline = xf86VidModeGetFirstModeline;
+ pVidMode->GetNextModeline = xf86VidModeGetNextModeline;
+ pVidMode->DeleteModeline = xf86VidModeDeleteModeline;
+ pVidMode->ZoomViewport = xf86VidModeZoomViewport;
+ pVidMode->GetViewPort = xf86VidModeGetViewPort;
+ pVidMode->SetViewPort = xf86VidModeSetViewPort;
+ pVidMode->SwitchMode = xf86VidModeSwitchMode;
+ pVidMode->LockZoom = xf86VidModeLockZoom;
+ pVidMode->GetNumOfClocks = xf86VidModeGetNumOfClocks;
+ pVidMode->GetClocks = xf86VidModeGetClocks;
+ pVidMode->CheckModeForMonitor = xf86VidModeCheckModeForMonitor;
+ pVidMode->CheckModeForDriver = xf86VidModeCheckModeForDriver;
+ pVidMode->SetCrtcForMode = xf86VidModeSetCrtcForMode;
+ pVidMode->AddModeline = xf86VidModeAddModeline;
+ pVidMode->GetDotClock = xf86VidModeGetDotClock;
+ pVidMode->GetNumOfModes = xf86VidModeGetNumOfModes;
+ pVidMode->SetGamma = xf86VidModeSetGamma;
+ pVidMode->GetGamma = xf86VidModeGetGamma;
+ pVidMode->SetGammaRamp = xf86VidModeSetGammaRamp;
+ pVidMode->GetGammaRamp = xf86VidModeGetGammaRamp;
+ pVidMode->GetGammaRampSize = xf86GetGammaRampSize; /* use xf86cmap API directly */
+
+ return TRUE;
}
void
-VidModeSetModeValue(void *mode, int valtyp, int val)
+XFree86VidModeExtensionInit(void)
{
- switch (valtyp) {
- case VIDMODE_H_DISPLAY:
- ((DisplayModePtr) mode)->HDisplay = val;
- break;
- case VIDMODE_H_SYNCSTART:
- ((DisplayModePtr) mode)->HSyncStart = val;
- break;
- case VIDMODE_H_SYNCEND:
- ((DisplayModePtr) mode)->HSyncEnd = val;
- break;
- case VIDMODE_H_TOTAL:
- ((DisplayModePtr) mode)->HTotal = val;
- break;
- case VIDMODE_H_SKEW:
- ((DisplayModePtr) mode)->HSkew = val;
- break;
- case VIDMODE_V_DISPLAY:
- ((DisplayModePtr) mode)->VDisplay = val;
- break;
- case VIDMODE_V_SYNCSTART:
- ((DisplayModePtr) mode)->VSyncStart = val;
- break;
- case VIDMODE_V_SYNCEND:
- ((DisplayModePtr) mode)->VSyncEnd = val;
- break;
- case VIDMODE_V_TOTAL:
- ((DisplayModePtr) mode)->VTotal = val;
- break;
- case VIDMODE_FLAGS:
- ((DisplayModePtr) mode)->Flags = val;
- break;
- case VIDMODE_CLOCK:
- ((DisplayModePtr) mode)->Clock = val;
- break;
- }
- return;
-}
+ int i;
+ Bool enabled = FALSE;
-vidMonitorValue
-VidModeGetMonitorValue(void *monitor, int valtyp, int indx)
-{
- vidMonitorValue ret = { NULL, };
+ DebugF("XFree86VidModeExtensionInit");
- switch (valtyp) {
- case VIDMODE_MON_VENDOR:
- ret.ptr = (((MonPtr) monitor)->vendor);
- break;
- case VIDMODE_MON_MODEL:
- ret.ptr = (((MonPtr) monitor)->model);
- break;
- case VIDMODE_MON_NHSYNC:
- ret.i = ((MonPtr) monitor)->nHsync;
- break;
- case VIDMODE_MON_NVREFRESH:
- ret.i = ((MonPtr) monitor)->nVrefresh;
- break;
- case VIDMODE_MON_HSYNC_LO:
- ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].lo);
- break;
- case VIDMODE_MON_HSYNC_HI:
- ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].hi);
- break;
- case VIDMODE_MON_VREFRESH_LO:
- ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].lo);
- break;
- case VIDMODE_MON_VREFRESH_HI:
- ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].hi);
- break;
+ /* This means that the DDX doesn't want the vidmode extension enabled */
+ if (!xf86GetVidModeEnabled())
+ return;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (xf86VidModeInit (screenInfo.screens[i]))
+ enabled = TRUE;
}
- return ret;
+ /* This means that the DDX doesn't want the vidmode extension enabled */
+ if (!enabled)
+ return;
+
+ VidModeAddExtension(xf86GetVidModeAllowNonLocal());
}
#endif /* XF86VIDMODE */
diff --git a/xserver/hw/xfree86/common/xf86Xinput.c b/xserver/hw/xfree86/common/xf86Xinput.c
index 1fb5b1635..c56a2b9a3 100644
--- a/xserver/hw/xfree86/common/xf86Xinput.c
+++ b/xserver/hw/xfree86/common/xf86Xinput.c
@@ -843,7 +843,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
DeviceIntPtr dev = NULL;
Bool paused;
int rval;
- const char *path;
+ char *path = NULL;
/* Memory leak for every attached device if we don't
* test if the module is already loaded first */
@@ -867,11 +867,13 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
if (fd != -1) {
if (paused) {
/* Put on new_input_devices list for delayed probe */
- new_input_devices = xnfrealloc(new_input_devices,
- sizeof(pInfo) * (new_input_devices_count + 1));
+ new_input_devices = xnfreallocarray(new_input_devices,
+ new_input_devices_count + 1,
+ sizeof(pInfo));
new_input_devices[new_input_devices_count] = pInfo;
new_input_devices_count++;
systemd_logind_release_fd(pInfo->major, pInfo->minor, fd);
+ free(path);
return BadMatch;
}
pInfo->fd = fd;
@@ -880,6 +882,8 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
}
}
+ free(path);
+
xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName,
pInfo->name);
@@ -1137,12 +1141,16 @@ xf86CheckMotionEvent4DGA(DeviceIntPtr device, int is_absolute,
dx = valuator_mask_get(mask, 0);
if (is_absolute)
dx -= device->last.valuators[0];
+ else if (valuator_mask_has_unaccelerated(mask))
+ dx = valuator_mask_get_unaccelerated(mask, 0);
}
if (valuator_mask_isset(mask, 1)) {
dy = valuator_mask_get(mask, 1);
if (is_absolute)
dy -= device->last.valuators[1];
+ else if (valuator_mask_has_unaccelerated(mask))
+ dy = valuator_mask_get_unaccelerated(mask, 1);
}
if (DGAStealMotionEvent(device, idx, dx, dy))
@@ -1326,47 +1334,21 @@ xf86PostButtonEventM(DeviceIntPtr device,
}
void
-xf86PostKeyEvent(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute, int first_valuator, int num_valuators, ...)
+xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down)
{
- va_list var;
- int i = 0;
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_zero(&mask);
-
- va_start(var, num_valuators);
- for (i = 0; i < num_valuators; i++)
- valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
-
- va_end(var);
-
- xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
+ xf86PostKeyEventM(device, key_code, is_down);
}
void
xf86PostKeyEventP(DeviceIntPtr device,
unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator, int num_valuators, const int *valuators)
+ int is_down)
{
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
- xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
+ xf86PostKeyEventM(device, key_code, is_down);
}
void
-xf86PostKeyEventM(DeviceIntPtr device,
- unsigned int key_code,
- int is_down, int is_absolute, const ValuatorMask *mask)
+xf86PostKeyEventM(DeviceIntPtr device, unsigned int key_code, int is_down)
{
#if XFreeXDGA
DeviceIntPtr pointer;
@@ -1382,8 +1364,7 @@ xf86PostKeyEventM(DeviceIntPtr device,
}
#endif
- QueueKeyboardEvents(device,
- is_down ? KeyPress : KeyRelease, key_code, mask);
+ QueueKeyboardEvents(device, is_down ? KeyPress : KeyRelease, key_code);
}
void
@@ -1392,7 +1373,7 @@ xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code, int is_down)
ValuatorMask mask;
valuator_mask_zero(&mask);
- xf86PostKeyEventM(device, key_code, is_down, 0, &mask);
+ xf86PostKeyEventM(device, key_code, is_down);
}
InputInfoPtr
diff --git a/xserver/hw/xfree86/common/xf86Xinput.h b/xserver/hw/xfree86/common/xf86Xinput.h
index 42d66d22e..0024053c7 100644
--- a/xserver/hw/xfree86/common/xf86Xinput.h
+++ b/xserver/hw/xfree86/common/xf86Xinput.h
@@ -148,18 +148,11 @@ extern _X_EXPORT void xf86PostButtonEventM(DeviceIntPtr device, int is_absolute,
int button, int is_down,
const ValuatorMask *mask);
extern _X_EXPORT void xf86PostKeyEvent(DeviceIntPtr device,
- unsigned int key_code, int is_down,
- int is_absolute, int first_valuator,
- int num_valuators, ...);
+ unsigned int key_code, int is_down);
extern _X_EXPORT void xf86PostKeyEventM(DeviceIntPtr device,
- unsigned int key_code, int is_down,
- int is_absolute,
- const ValuatorMask *mask);
+ unsigned int key_code, int is_down);
extern _X_EXPORT void xf86PostKeyEventP(DeviceIntPtr device,
- unsigned int key_code, int is_down,
- int is_absolute, int first_valuator,
- int num_valuators,
- const int *valuators);
+ unsigned int key_code, int is_down);
extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device,
unsigned int key_code, int is_down);
extern _X_EXPORT void xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid,
diff --git a/xserver/hw/xfree86/common/xf86cmap.c b/xserver/hw/xfree86/common/xf86cmap.c
index ab51f9603..704e35358 100644
--- a/xserver/hw/xfree86/common/xf86cmap.c
+++ b/xserver/hw/xfree86/common/xf86cmap.c
@@ -166,10 +166,10 @@ xf86HandleColormaps(ScreenPtr pScreen,
elements = 1 << sigRGBbits;
- if (!(gamma = malloc(elements * sizeof(LOCO))))
+ if (!(gamma = xallocarray(elements, sizeof(LOCO))))
return FALSE;
- if (!(indices = malloc(maxColors * sizeof(int)))) {
+ if (!(indices = xallocarray(maxColors, sizeof(int)))) {
free(gamma);
return FALSE;
}
@@ -270,7 +270,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
else
numColors = 1 << pmap->pVisual->nplanes;
- if (!(colors = malloc(numColors * sizeof(LOCO))))
+ if (!(colors = xallocarray(numColors, sizeof(LOCO))))
return FALSE;
if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) {
diff --git a/xserver/hw/xfree86/common/xf86fbman.c b/xserver/hw/xfree86/common/xf86fbman.c
index 1b2cb5704..91ddedc29 100644
--- a/xserver/hw/xfree86/common/xf86fbman.c
+++ b/xserver/hw/xfree86/common/xf86fbman.c
@@ -317,16 +317,17 @@ localRegisterFreeBoxCallback(ScreenPtr pScreen,
offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- newCallbacks = realloc(offman->FreeBoxesUpdateCallback,
- sizeof(FreeBoxCallbackProcPtr) *
- (offman->NumCallbacks + 1));
+ newCallbacks = reallocarray(offman->FreeBoxesUpdateCallback,
+ offman->NumCallbacks + 1,
+ sizeof(FreeBoxCallbackProcPtr));
if (!newCallbacks)
return FALSE;
else
offman->FreeBoxesUpdateCallback = newCallbacks;
- newPrivates = realloc(offman->devPrivates,
- sizeof(DevUnion) * (offman->NumCallbacks + 1));
+ newPrivates = reallocarray(offman->devPrivates,
+ offman->NumCallbacks + 1,
+ sizeof(DevUnion));
if (!newPrivates)
return FALSE;
else
diff --git a/xserver/hw/xfree86/common/xf86pciBus.c b/xserver/hw/xfree86/common/xf86pciBus.c
index 9cbf7fb21..c0fda4a7a 100644
--- a/xserver/hw/xfree86/common/xf86pciBus.c
+++ b/xserver/hw/xfree86/common/xf86pciBus.c
@@ -103,9 +103,9 @@ xf86PciProbe(void)
while ((info = pci_device_next(iter)) != NULL) {
if (PCIINFOCLASSES(info->device_class)) {
num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- (sizeof(struct pci_device *)
- * (num + 1)));
+ xf86PciVideoInfo = xnfreallocarray(xf86PciVideoInfo,
+ num + 1,
+ sizeof(struct pci_device *));
xf86PciVideoInfo[num] = NULL;
xf86PciVideoInfo[num - 1] = info;
@@ -679,7 +679,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
pci_iterator_destroy(iter);
- instances = xnfalloc(max_entries * sizeof(struct Inst));
+ instances = xnfallocarray(max_entries, sizeof(struct Inst));
}
iter = pci_slot_match_iterator_create(NULL);
@@ -976,7 +976,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
/* Allocate an entry in the lists to be returned */
numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp,
instances[i].chip,
instances[i].dev,
diff --git a/xserver/hw/xfree86/common/xf86platformBus.c b/xserver/hw/xfree86/common/xf86platformBus.c
index c1aaba41a..96895a6e1 100644
--- a/xserver/hw/xfree86/common/xf86platformBus.c
+++ b/xserver/hw/xfree86/common/xf86platformBus.c
@@ -59,9 +59,9 @@ struct xf86_platform_device *xf86_platform_devices;
int
xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned)
{
- xf86_platform_devices = xnfrealloc(xf86_platform_devices,
- (sizeof(struct xf86_platform_device)
- * (xf86_num_platform_devices + 1)));
+ xf86_platform_devices = xnfreallocarray(xf86_platform_devices,
+ xf86_num_platform_devices + 1,
+ sizeof(struct xf86_platform_device));
xf86_platform_devices[xf86_num_platform_devices].attribs = attribs;
xf86_platform_devices[xf86_num_platform_devices].pdev = NULL;
@@ -477,6 +477,9 @@ xf86platformAddDevice(int index)
screenLayoutPtr layout;
static const char *hotplug_driver_name = "modesetting";
+ if (!xf86Info.autoAddGPU)
+ return -1;
+
/* force load the driver for now */
xf86LoadOneModule(hotplug_driver_name, NULL);
diff --git a/xserver/hw/xfree86/common/xf86sbusBus.c b/xserver/hw/xfree86/common/xf86sbusBus.c
index 07eb71ed8..119211dc5 100644
--- a/xserver/hw/xfree86/common/xf86sbusBus.c
+++ b/xserver/hw/xfree86/common/xf86sbusBus.c
@@ -68,7 +68,7 @@ CheckSbusDevice(const char *device, int fbNum)
if (!sbusDeviceTable[i].devId)
return;
xf86SbusInfo =
- xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1));
+ xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp));
xf86SbusInfo[xf86nSbusInfo] = NULL;
xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1);
psdp->devId = sbusDeviceTable[i].devId;
@@ -406,8 +406,8 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
if (psdp->fd == -2)
continue;
++allocatedInstances;
- instances = xnfrealloc(instances,
- allocatedInstances * sizeof(struct Inst));
+ instances = xnfreallocarray(instances,
+ allocatedInstances, sizeof(struct Inst));
instances[allocatedInstances - 1].sbus = psdp;
instances[allocatedInstances - 1].dev = NULL;
instances[allocatedInstances - 1].claimed = FALSE;
@@ -532,7 +532,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
/* Allocate an entry in the lists to be returned */
numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
retEntities[numFound - 1]
= xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,
instances[i].dev->active ? TRUE : FALSE);
@@ -648,7 +648,7 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
return;
fbcmap.count = 0;
fbcmap.index = indices[0];
- fbcmap.red = data = malloc(numColors * 3);
+ fbcmap.red = data = xallocarray(numColors, 3);
if (!data)
return;
fbcmap.green = data + numColors;
diff --git a/xserver/hw/xfree86/common/xf86str.h b/xserver/hw/xfree86/common/xf86str.h
index 643a65db1..5e6e97778 100644
--- a/xserver/hw/xfree86/common/xf86str.h
+++ b/xserver/hw/xfree86/common/xf86str.h
@@ -41,6 +41,7 @@
#include "colormapst.h"
#include "xf86Module.h"
#include "xf86Opt.h"
+#include "displaymode.h"
/**
* Integer type that is of the size of the addressable memory (machine size).
@@ -84,48 +85,6 @@ typedef enum {
MODECHECK_FINAL = 1
} ModeCheckFlags;
-/* These are possible return values for xf86CheckMode() and ValidMode() */
-typedef enum {
- MODE_OK = 0, /* Mode OK */
- MODE_HSYNC, /* hsync out of range */
- MODE_VSYNC, /* vsync out of range */
- MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_BAD_WIDTH, /* requires an unsupported linepitch */
- MODE_NOMODE, /* no mode with a maching name */
- MODE_NO_INTERLACE, /* interlaced mode not supported */
- MODE_NO_DBLESCAN, /* doublescan mode not supported */
- MODE_NO_VSCAN, /* multiscan mode not supported */
- MODE_MEM, /* insufficient video memory */
- MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
- MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
- MODE_MEM_VIRT, /* insufficient video memory given virtual size */
- MODE_NOCLOCK, /* no fixed clock available */
- MODE_CLOCK_HIGH, /* clock required is too high */
- MODE_CLOCK_LOW, /* clock required is too low */
- MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
- MODE_BAD_HVALUE, /* horizontal timing was out of range */
- MODE_BAD_VVALUE, /* vertical timing was out of range */
- MODE_BAD_VSCAN, /* VScan value out of range */
- MODE_HSYNC_NARROW, /* horizontal sync too narrow */
- MODE_HSYNC_WIDE, /* horizontal sync too wide */
- MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
- MODE_HBLANK_WIDE, /* horizontal blanking too wide */
- MODE_VSYNC_NARROW, /* vertical sync too narrow */
- MODE_VSYNC_WIDE, /* vertical sync too wide */
- 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_ONE_WIDTH, /* only one width is supported */
- MODE_ONE_HEIGHT, /* only one height is supported */
- MODE_ONE_SIZE, /* only one resolution is supported */
- MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
- MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
- MODE_BAD = -2, /* unspecified reason */
- MODE_ERROR = -1 /* error condition */
-} ModeStatus;
-
/*
* The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
* Preferred will bubble a mode to the top within a set.
@@ -141,54 +100,6 @@ typedef enum {
#define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
#define M_T_USERPREF 0x80 /* mode preferred by the user config */
-/* Video mode */
-typedef struct _DisplayModeRec {
- struct _DisplayModeRec *prev;
- struct _DisplayModeRec *next;
- const char *name; /* identifier for the mode */
- ModeStatus status;
- int type;
-
- /* These are the values that the user sees/provides */
- int Clock; /* pixel clock freq (kHz) */
- int HDisplay; /* horizontal timing */
- int HSyncStart;
- int HSyncEnd;
- int HTotal;
- int HSkew;
- int VDisplay; /* vertical timing */
- int VSyncStart;
- int VSyncEnd;
- int VTotal;
- int VScan;
- int Flags;
-
- /* These are the values the hardware uses */
- int ClockIndex;
- int SynthClock; /* Actual clock freq to
- * be programmed (kHz) */
- int CrtcHDisplay;
- int CrtcHBlankStart;
- int CrtcHSyncStart;
- int CrtcHSyncEnd;
- int CrtcHBlankEnd;
- int CrtcHTotal;
- int CrtcHSkew;
- int CrtcVDisplay;
- int CrtcVBlankStart;
- int CrtcVSyncStart;
- int CrtcVSyncEnd;
- int CrtcVBlankEnd;
- int CrtcVTotal;
- Bool CrtcHAdjusted;
- Bool CrtcVAdjusted;
- int PrivSize;
- INT32 *Private;
- int PrivFlags;
-
- float HSync, VRefresh;
-} DisplayModeRec, *DisplayModePtr;
-
/* The monitor description */
#define MAX_HSYNC 8
@@ -377,7 +288,6 @@ typedef struct _bus {
} id;
} BusRec, *BusPtr;
-#define MAXCLOCKS 128
typedef enum {
DAC_BPP8 = 0,
DAC_BPP16,
@@ -440,6 +350,7 @@ typedef struct _confxvadaptrec {
void *options;
} confXvAdaptorRec, *confXvAdaptorPtr;
+#define MAX_GPUDEVICES 4
typedef struct _confscreenrec {
const char *id;
int screennum;
@@ -453,6 +364,9 @@ typedef struct _confscreenrec {
int numxvadaptors;
confXvAdaptorPtr xvadaptors;
void *options;
+
+ int num_gpu_devices;
+ GDevPtr gpu_devices[MAX_GPUDEVICES];
} confScreenRec, *confScreenPtr;
typedef enum {
@@ -512,6 +426,9 @@ typedef struct _confdrirec {
#define NUM_RESERVED_POINTERS 14
#define NUM_RESERVED_FUNCS 10
+/* let clients know they can use this */
+#define XF86_SCRN_HAS_PREFER_CLONE 1
+
typedef void *(*funcPointer) (void);
/* flags for depth 24 pixmap options */
@@ -768,6 +685,9 @@ typedef struct _ScrnInfoRec {
ClockRangePtr clockRanges;
int adjustFlags;
+ /* initial rightof support disable */
+ int preferClone;
+
/*
* These can be used when the minor ABI version is incremented.
* The NUM_* parameters must be reduced appropriately to keep the
diff --git a/xserver/hw/xfree86/common/xf86vmode.c b/xserver/hw/xfree86/common/xf86vmode.c
deleted file mode 100644
index 0ce58e365..000000000
--- a/xserver/hw/xfree86/common/xf86vmode.c
+++ /dev/null
@@ -1,2165 +0,0 @@
-
-/*
-
-Copyright 1995 Kaleb S. KEITHLEY
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
-OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Kaleb S. KEITHLEY
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-from Kaleb S. KEITHLEY
-
-*/
-/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "xf86Extensions.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#include <X11/extensions/xf86vmproto.h>
-#include "swaprep.h"
-#include "xf86.h"
-#include "vidmodeproc.h"
-#include "globals.h"
-#include "protocol-versions.h"
-
-#define DEFAULT_XF86VIDMODE_VERBOSITY 3
-
-static int VidModeErrorBase;
-static DevPrivateKeyRec VidModeClientPrivateKeyRec;
-
-#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
-
-/* This holds the client's version information */
-typedef struct {
- int major;
- int minor;
-} VidModePrivRec, *VidModePrivPtr;
-
-#define VM_GETPRIV(c) ((VidModePrivPtr) \
- dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey))
-#define VM_SETPRIV(c,p) \
- dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
-
-#if 0
-static unsigned char XF86VidModeReqCode = 0;
-#endif
-
-/* The XF86VIDMODE_EVENTS code is far from complete */
-
-#ifdef XF86VIDMODE_EVENTS
-static int XF86VidModeEventBase = 0;
-
-static void SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent * /* to */
- );
-
-static RESTYPE EventType; /* resource type for event masks */
-
-typedef struct _XF86VidModeEvent *XF86VidModeEventPtr;
-
-typedef struct _XF86VidModeEvent {
- XF86VidModeEventPtr next;
- ClientPtr client;
- ScreenPtr screen;
- XID resource;
- CARD32 mask;
-} XF86VidModeEventRec;
-
-static int XF86VidModeFreeEvents();
-
-typedef struct _XF86VidModeScreenPrivate {
- XF86VidModeEventPtr events;
- Bool hasWindow;
-} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
-
-static DevPrivateKeyRec ScreenPrivateKeyRec;
-
-#define ScreenPrivateKey (&ScreenPrivateKeyRec)
-
-#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
- dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
-#define SetScreenPrivate(s,v) \
- dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v)
-#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
-
-#define New(t) (malloc(sizeof (t)))
-#endif
-
-#ifdef DEBUG
-#define DEBUG_P(x) ErrorF(x"\n");
-#else
-#define DEBUG_P(x) /**/
-#endif
- static int
-ClientMajorVersion(ClientPtr client)
-{
- VidModePrivPtr pPriv;
-
- pPriv = VM_GETPRIV(client);
- if (!pPriv)
- return 0;
- else
- return pPriv->major;
-}
-
-#ifdef XF86VIDMODE_EVENTS
-static void
-CheckScreenPrivate(pScreen)
-ScreenPtr
- pScreen;
-{
- SetupScreen(pScreen);
-
- if (!pPriv)
- return;
- if (!pPriv->events && !pPriv->hasWindow) {
- free(pPriv);
- SetScreenPrivate(pScreen, NULL);
- }
-}
-
-static XF86VidModeScreenPrivatePtr
-MakeScreenPrivate(pScreen)
-ScreenPtr
- pScreen;
-{
- SetupScreen(pScreen);
-
- if (pPriv)
- return pPriv;
- pPriv = New(XF86VidModeScreenPrivateRec);
- if (!pPriv)
- return 0;
- pPriv->events = 0;
- pPriv->hasWindow = FALSE;
- SetScreenPrivate(pScreen, pPriv);
- return pPriv;
-}
-
-static unsigned long
-getEventMask(ScreenPtr pScreen, ClientPtr client)
-{
- SetupScreen(pScreen);
- XF86VidModeEventPtr pEv;
-
- if (!pPriv)
- return 0;
- for (pEv = pPriv->events; pEv; pEv = pEv->next)
- if (pEv->client == client)
- return pEv->mask;
- return 0;
-}
-
-static Bool
-setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
-{
- SetupScreen(pScreen);
- XF86VidModeEventPtr pEv, *pPrev;
-
- if (getEventMask(pScreen, client) == mask)
- return TRUE;
- if (!pPriv) {
- pPriv = MakeScreenPrivate(pScreen);
- if (!pPriv)
- return FALSE;
- }
- for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
- if (pEv->client == client)
- break;
- if (mask == 0) {
- *pPrev = pEv->next;
- free(pEv);
- CheckScreenPrivate(pScreen);
- }
- else {
- if (!pEv) {
- pEv = New(ScreenSaverEventRec);
- if (!pEv) {
- CheckScreenPrivate(pScreen);
- return FALSE;
- }
- *pPrev = pEv;
- pEv->next = NULL;
- pEv->client = client;
- pEv->screen = pScreen;
- pEv->resource = FakeClientID(client->index);
- }
- pEv->mask = mask;
- }
- return TRUE;
-}
-
-static int
-XF86VidModeFreeEvents(void *value, XID id)
-{
- XF86VidModeEventPtr pOld = (XF86VidModeEventPtr) value;
- ScreenPtr pScreen = pOld->screen;
-
- SetupScreen(pScreen);
- XF86VidModeEventPtr pEv, *pPrev;
-
- if (!pPriv)
- return TRUE;
- for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
- if (pEv == pOld)
- break;
- if (!pEv)
- return TRUE;
- *pPrev = pEv->next;
- free(pEv);
- CheckScreenPrivate(pScreen);
- return TRUE;
-}
-
-static void
-SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
-{
- XF86VidModeScreenPrivatePtr pPriv;
- unsigned long mask;
- xXF86VidModeNotifyEvent ev;
- int kind;
-
- UpdateCurrentTimeIf();
- mask = XF86VidModeNotifyMask;
- pScreen = screenInfo.screens[pScreen->myNum];
- pPriv = GetScreenPrivate(pScreen);
- if (!pPriv)
- return;
- kind = XF86VidModeModeChange;
- for (pEv = pPriv->events; pEv; pEv = pEv->next) {
- if (pEv->mask & mask) {
- XF86VidModeEventPtr pEv = {
- .type = XF86VidModeNotify + XF86VidModeEventBase,
- .state = state,
- .timestamp = currentTime.milliseconds,
- .root = pScreen->root->drawable.id,
- .kind = kind,
- .forced = forced
- };
- WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
- }
- }
-}
-
-static void
-SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
- xXF86VidModeNotifyEvent * to)
-{
- to->type = from->type;
- to->state = from->state;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->timestamp, to->timestamp);
- cpswapl(from->root, to->root);
- to->kind = from->kind;
- to->forced = from->forced;
-}
-#endif
-
-static int
-ProcXF86VidModeQueryVersion(ClientPtr client)
-{
- xXF86VidModeQueryVersionReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION,
- .minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION
- };
-
- DEBUG_P("XF86VidModeQueryVersion");
-
- REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.majorVersion);
- swaps(&rep.minorVersion);
- }
- WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), &rep);
- return Success;
-}
-
-static int
-ProcXF86VidModeGetModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetModeLineReq);
- xXF86VidModeGetModeLineReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence
- };
- void *mode;
- int dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeGetModeline");
-
- ver = ClientMajorVersion(client);
- REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
-
- if (ver < 2) {
- rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
- SIZEOF(xGenericReply));
- }
- else {
- rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) -
- SIZEOF(xGenericReply));
- }
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- rep.dotclock = dotClock;
- rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
- rep.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
- rep.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
- rep.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
- rep.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
- rep.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
- rep.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
- rep.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
- rep.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
- rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("GetModeLine - scrn: %d clock: %ld\n",
- stuff->screen, (unsigned long) rep.dotclock);
- ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
- rep.hdisplay, rep.hsyncstart, rep.hsyncend, rep.htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- rep.vdisplay, rep.vsyncstart, rep.vsyncend,
- rep.vtotal, (unsigned long) rep.flags);
- }
-
- /*
- * Older servers sometimes had server privates that the VidMode
- * extention made available. So to be compatiable pretend that
- * there are no server privates to pass to the client
- */
- rep.privsize = 0;
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.dotclock);
- swaps(&rep.hdisplay);
- swaps(&rep.hsyncstart);
- swaps(&rep.hsyncend);
- swaps(&rep.htotal);
- swaps(&rep.hskew);
- swaps(&rep.vdisplay);
- swaps(&rep.vsyncstart);
- swaps(&rep.vsyncend);
- swaps(&rep.vtotal);
- swapl(&rep.flags);
- swapl(&rep.privsize);
- }
- if (ver < 2) {
- xXF86OldVidModeGetModeLineReply oldrep = {
- .type = rep.type,
- .sequenceNumber = rep.sequenceNumber,
- .length = rep.length,
- .dotclock = rep.dotclock,
- .hdisplay = rep.hdisplay,
- .hsyncstart = rep.hsyncstart,
- .hsyncend = rep.hsyncend,
- .htotal = rep.htotal,
- .vdisplay = rep.vdisplay,
- .vsyncstart = rep.vsyncstart,
- .vsyncend = rep.vsyncend,
- .vtotal = rep.vtotal,
- .flags = rep.flags,
- .privsize = rep.privsize
- };
- WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), &oldrep);
- }
- else {
- WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), &rep);
- }
- return Success;
-}
-
-static int
-ProcXF86VidModeGetAllModeLines(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetAllModeLinesReq);
- xXF86VidModeGetAllModeLinesReply rep;
- void *mode;
- int modecount, dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeGetAllModelines");
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- ver = ClientMajorVersion(client);
-
- modecount = VidModeGetNumOfModes(stuff->screen);
- if (modecount < 1)
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
-
- if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- rep = (xXF86VidModeGetAllModeLinesReply) {
- .type = X_Reply,
- .length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
- SIZEOF(xGenericReply),
- .sequenceNumber = client->sequence,
- .modecount = modecount
- };
- if (ver < 2)
- rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
- else
- rep.length += modecount * sizeof(xXF86VidModeModeInfo);
- rep.length >>= 2;
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.modecount);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep);
-
- do {
- xXF86VidModeModeInfo mdinf = {
- .dotclock = dotClock,
- .hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- .hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- .hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- .htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL),
- .hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW),
- .vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- .vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- .vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- .vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- .flags = VidModeGetModeValue(mode, VIDMODE_FLAGS),
- .privsize = 0
- };
- if (client->swapped) {
- swapl(&mdinf.dotclock);
- swaps(&mdinf.hdisplay);
- swaps(&mdinf.hsyncstart);
- swaps(&mdinf.hsyncend);
- swaps(&mdinf.htotal);
- swapl(&mdinf.hskew);
- swaps(&mdinf.vdisplay);
- swaps(&mdinf.vsyncstart);
- swaps(&mdinf.vsyncend);
- swaps(&mdinf.vtotal);
- swapl(&mdinf.flags);
- swapl(&mdinf.privsize);
- }
- if (ver < 2) {
- xXF86OldVidModeModeInfo oldmdinf = {
- .dotclock = mdinf.dotclock,
- .hdisplay = mdinf.hdisplay,
- .hsyncstart = mdinf.hsyncstart,
- .hsyncend = mdinf.hsyncend,
- .htotal = mdinf.htotal,
- .vdisplay = mdinf.vdisplay,
- .vsyncstart = mdinf.vsyncstart,
- .vsyncend = mdinf.vsyncend,
- .vtotal = mdinf.vtotal,
- .flags = mdinf.flags,
- .privsize = mdinf.privsize
- };
- WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), &oldmdinf);
- }
- else {
- WriteToClient(client, sizeof(xXF86VidModeModeInfo), &mdinf);
- }
-
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
-
- return Success;
-}
-
-#define MODEMATCH(mode,stuff) \
- (VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \
- && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \
- && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \
- && VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \
- && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \
- && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \
- && VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \
- && VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \
- && VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
-
-static int
-ProcXF86VidModeAddModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeAddModeLineReq);
- xXF86OldVidModeAddModeLineReq *oldstuff =
- (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
- xXF86VidModeAddModeLineReq newstuff;
- void *mode;
- int len;
- int dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeAddModeline");
-
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- stuff->after_dotclock = oldstuff->after_dotclock;
- stuff->after_hdisplay = oldstuff->after_hdisplay;
- stuff->after_hsyncstart = oldstuff->after_hsyncstart;
- stuff->after_hsyncend = oldstuff->after_hsyncend;
- stuff->after_htotal = oldstuff->after_htotal;
- stuff->after_hskew = 0;
- stuff->after_vdisplay = oldstuff->after_vdisplay;
- stuff->after_vsyncstart = oldstuff->after_vsyncstart;
- stuff->after_vsyncend = oldstuff->after_vsyncend;
- stuff->after_vtotal = oldstuff->after_vtotal;
- stuff->after_flags = oldstuff->after_flags;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("AddModeLine - scrn: %d clock: %ld\n",
- (int) stuff->screen, (unsigned long) stuff->dotclock);
- ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long) stuff->flags);
- ErrorF(" after - scrn: %d clock: %ld\n",
- (int) stuff->screen, (unsigned long) stuff->after_dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->after_hdisplay, stuff->after_hsyncstart,
- stuff->after_hsyncend, stuff->after_htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->after_vdisplay, stuff->after_vsyncstart,
- stuff->after_vsyncend, stuff->after_vtotal,
- (unsigned long) stuff->after_flags);
- }
-
- if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
- }
- else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
- }
- if (len != stuff->privsize)
- return BadLength;
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
- return BadValue;
-
- if (stuff->after_hsyncstart < stuff->after_hdisplay ||
- stuff->after_hsyncend < stuff->after_hsyncstart ||
- stuff->after_htotal < stuff->after_hsyncend ||
- stuff->after_vsyncstart < stuff->after_vdisplay ||
- stuff->after_vsyncend < stuff->after_vsyncstart ||
- stuff->after_vtotal < stuff->after_vsyncend)
- return BadValue;
-
- if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
- Bool found = FALSE;
-
- if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
- do {
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
- == dotClock) && MODEMATCH(mode, stuff)) {
- found = TRUE;
- break;
- }
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
- }
- if (!found)
- return BadValue;
- }
-
- mode = VidModeCreateMode();
- if (mode == NULL)
- return BadValue;
-
- VidModeSetModeValue(mode, VIDMODE_CLOCK, stuff->dotclock);
- VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
- VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
- VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
- VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
- VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
- VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
-
- if (stuff->privsize)
- ErrorF("AddModeLine - Privates in request have been ignored\n");
-
- /* Check that the mode is consistent with the monitor specs */
- switch (VidModeCheckModeForMonitor(stuff->screen, mode)) {
- case MODE_OK:
- break;
- case MODE_HSYNC:
- case MODE_H_ILLEGAL:
- free(mode);
- return VidModeErrorBase + XF86VidModeBadHTimings;
- case MODE_VSYNC:
- case MODE_V_ILLEGAL:
- free(mode);
- return VidModeErrorBase + XF86VidModeBadVTimings;
- default:
- free(mode);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
- }
-
- /* Check that the driver is happy with the mode */
- if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) {
- free(mode);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
- }
-
- VidModeSetCrtcForMode(stuff->screen, mode);
-
- VidModeAddModeline(stuff->screen, mode);
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("AddModeLine - Succeeded\n");
- return Success;
-}
-
-static int
-ProcXF86VidModeDeleteModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeDeleteModeLineReq);
- xXF86OldVidModeDeleteModeLineReq *oldstuff =
- (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
- xXF86VidModeDeleteModeLineReq newstuff;
- void *mode;
- int len, dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeDeleteModeline");
-
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
- (int) stuff->screen, (unsigned long) stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
- }
-
- if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
- }
- else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
- }
- if (len != stuff->privsize) {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
- "len = %d, length = %d\n",
- (unsigned long) client->req_len,
- (int) sizeof(xXF86VidModeDeleteModeLineReq) >> 2,
- (unsigned long) stuff->privsize, len, stuff->length);
- }
- return BadLength;
- }
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
- }
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff))
- return BadValue;
-
- if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- do {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
- }
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff)) {
- VidModeDeleteModeline(stuff->screen, mode);
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("DeleteModeLine - Succeeded\n");
- return Success;
- }
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
-
- return BadValue;
-}
-
-static int
-ProcXF86VidModeModModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeModModeLineReq);
- xXF86OldVidModeModModeLineReq *oldstuff =
- (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
- xXF86VidModeModModeLineReq newstuff;
- void *mode, *modetmp;
- int len, dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeModModeline");
-
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
- (int) stuff->screen, stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long) stuff->flags);
- }
-
- if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
- }
- else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
- }
- if (len != stuff->privsize)
- return BadLength;
-
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
- return BadValue;
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- modetmp = VidModeCreateMode();
- VidModeCopyMode(mode, modetmp);
-
- VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
- VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
- VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
- VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
- VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
- VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
-
- if (stuff->privsize)
- ErrorF("ModModeLine - Privates in request have been ignored\n");
-
- /* Check that the mode is consistent with the monitor specs */
- switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) {
- case MODE_OK:
- break;
- case MODE_HSYNC:
- case MODE_H_ILLEGAL:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeBadHTimings;
- case MODE_VSYNC:
- case MODE_V_ILLEGAL:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeBadVTimings;
- default:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
- }
-
- /* Check that the driver is happy with the mode */
- if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) {
- free(modetmp);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
- }
- free(modetmp);
-
- VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
- VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
- VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
- VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
- VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
- VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
-
- VidModeSetCrtcForMode(stuff->screen, mode);
- VidModeSwitchMode(stuff->screen, mode);
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("ModModeLine - Succeeded\n");
- return Success;
-}
-
-static int
-ProcXF86VidModeValidateModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeValidateModeLineReq);
- xXF86OldVidModeValidateModeLineReq *oldstuff =
- (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
- xXF86VidModeValidateModeLineReq newstuff;
- xXF86VidModeValidateModeLineReply rep;
- void *mode, *modetmp = NULL;
- int len, status, dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeValidateModeline");
-
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
- (int) stuff->screen, (unsigned long) stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
- }
-
- if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
- len = client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
- }
- else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
- }
- if (len != stuff->privsize)
- return BadLength;
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- status = MODE_OK;
-
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart ||
- stuff->vtotal < stuff->vsyncend) {
- status = MODE_BAD;
- goto status_reply;
- }
-
- if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- modetmp = VidModeCreateMode();
- VidModeCopyMode(mode, modetmp);
-
- VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
- VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
- VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
- VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
- VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
- VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
- if (stuff->privsize)
- ErrorF("ValidateModeLine - Privates in request have been ignored\n");
-
- /* Check that the mode is consistent with the monitor specs */
- if ((status =
- VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
- goto status_reply;
-
- /* Check that the driver is happy with the mode */
- status = VidModeCheckModeForDriver(stuff->screen, modetmp);
-
- status_reply:
- free(modetmp);
-
- rep = (xXF86VidModeValidateModeLineReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
- - SIZEOF(xGenericReply)),
- .status = status
- };
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.status);
- }
- WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), &rep);
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
- return Success;
-}
-
-static int
-ProcXF86VidModeSwitchMode(ClientPtr client)
-{
- REQUEST(xXF86VidModeSwitchModeReq);
-
- DEBUG_P("XF86VidModeSwitchMode");
-
- REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- VidModeZoomViewport(stuff->screen, (short) stuff->zoom);
-
- return Success;
-}
-
-static int
-ProcXF86VidModeSwitchToMode(ClientPtr client)
-{
- REQUEST(xXF86VidModeSwitchToModeReq);
- xXF86OldVidModeSwitchToModeReq *oldstuff =
- (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
- xXF86VidModeSwitchToModeReq newstuff;
- void *mode;
- int len, dotClock;
- int ver;
-
- DEBUG_P("XF86VidModeSwitchToMode");
-
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
- (int) stuff->screen, (unsigned long) stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
- }
-
- if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
- }
- else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
- len =
- client->req_len -
- bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
- }
- if (len != stuff->privsize)
- return BadLength;
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock)
- && MODEMATCH(mode, stuff))
- return Success;
-
- if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- do {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF
- (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
- }
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff)) {
-
- if (!VidModeSwitchMode(stuff->screen, mode))
- return BadValue;
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("SwitchToMode - Succeeded\n");
- return Success;
- }
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
-
- return BadValue;
-}
-
-static int
-ProcXF86VidModeLockModeSwitch(ClientPtr client)
-{
- REQUEST(xXF86VidModeLockModeSwitchReq);
-
- REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
-
- DEBUG_P("XF86VidModeLockModeSwitch");
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeLockZoom(stuff->screen, (short) stuff->lock))
- return VidModeErrorBase + XF86VidModeZoomLocked;
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetMonitor(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetMonitorReq);
- xXF86VidModeGetMonitorReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence
- };
- CARD32 *hsyncdata, *vsyncdata;
- int i, nHsync, nVrefresh;
- void *monitor;
-
- DEBUG_P("XF86VidModeGetMonitor");
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetMonitor(stuff->screen, &monitor))
- return BadValue;
-
- nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
- nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
-
- if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
- rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
- VIDMODE_MON_VENDOR,
- 0)).ptr);
- else
- rep.vendorLength = 0;
- if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
- rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
- VIDMODE_MON_MODEL,
- 0)).ptr);
- else
- rep.modelLength = 0;
- rep.length =
- bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) -
- SIZEOF(xGenericReply) + (nHsync +
- nVrefresh) * sizeof(CARD32) +
- pad_to_int32(rep.vendorLength) +
- pad_to_int32(rep.modelLength));
- rep.nhsync = nHsync;
- rep.nvsync = nVrefresh;
- hsyncdata = malloc(nHsync * sizeof(CARD32));
- if (!hsyncdata) {
- return BadAlloc;
- }
- vsyncdata = malloc(nVrefresh * sizeof(CARD32));
-
- if (!vsyncdata) {
- free(hsyncdata);
- return BadAlloc;
- }
-
- for (i = 0; i < nHsync; i++) {
- hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
- VIDMODE_MON_HSYNC_LO,
- i)).f |
- (unsigned
- short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
- i)).f << 16;
- }
- for (i = 0; i < nVrefresh; i++) {
- vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
- VIDMODE_MON_VREFRESH_LO,
- i)).f |
- (unsigned
- short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VREFRESH_HI,
- i)).f << 16;
- }
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- }
- WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), &rep);
- client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
- WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), hsyncdata);
- WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), vsyncdata);
- if (rep.vendorLength)
- WriteToClient(client, rep.vendorLength,
- (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr);
- if (rep.modelLength)
- WriteToClient(client, rep.modelLength,
- (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr);
-
- free(hsyncdata);
- free(vsyncdata);
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetViewPort(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetViewPortReq);
- xXF86VidModeGetViewPortReply rep;
- int x, y;
-
- DEBUG_P("XF86VidModeGetViewPort");
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- VidModeGetViewPort(stuff->screen, &x, &y);
-
- rep = (xXF86VidModeGetViewPortReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .x = x,
- .y = y
- };
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.x);
- swapl(&rep.y);
- }
- WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), &rep);
- return Success;
-}
-
-static int
-ProcXF86VidModeSetViewPort(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetViewPortReq);
-
- DEBUG_P("XF86VidModeSetViewPort");
-
- REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y))
- return BadValue;
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetDotClocks(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetDotClocksReq);
- xXF86VidModeGetDotClocksReply rep;
- int n;
- int numClocks;
- CARD32 dotclock;
- int *Clocks = NULL;
- Bool ClockProg;
-
- DEBUG_P("XF86VidModeGetDotClocks");
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
-
- rep = (xXF86VidModeGetDotClocksReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
- - SIZEOF(xGenericReply) + numClocks),
- .clocks = numClocks,
- .maxclocks = MAXCLOCKS,
- .flags = 0
- };
-
- if (!ClockProg) {
- Clocks = calloc(numClocks, sizeof(int));
- if (!Clocks)
- return BadValue;
- if (!VidModeGetClocks(stuff->screen, Clocks)) {
- free(Clocks);
- return BadValue;
- }
- }
- if (ClockProg) {
- rep.flags |= CLKFLAG_PROGRAMABLE;
- }
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.clocks);
- swapl(&rep.maxclocks);
- swapl(&rep.flags);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep);
- if (!ClockProg) {
- for (n = 0; n < numClocks; n++) {
- dotclock = *Clocks++;
- if (client->swapped) {
- WriteSwappedDataToClient(client, 4, (char *) &dotclock);
- }
- else {
- WriteToClient(client, 4, &dotclock);
- }
- }
- }
-
- free(Clocks);
- return Success;
-}
-
-static int
-ProcXF86VidModeSetGamma(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetGammaReq);
-
- DEBUG_P("XF86VidModeSetGamma");
-
- REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeSetGamma(stuff->screen, ((float) stuff->red) / 10000.,
- ((float) stuff->green) / 10000.,
- ((float) stuff->blue) / 10000.))
- return BadValue;
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetGamma(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetGammaReq);
- xXF86VidModeGetGammaReply rep;
- float red, green, blue;
-
- DEBUG_P("XF86VidModeGetGamma");
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
- return BadValue;
- rep = (xXF86VidModeGetGammaReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .red = (CARD32) (red * 10000.),
- .green = (CARD32) (green * 10000.),
- .blue = (CARD32) (blue * 10000.)
- };
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.red);
- swapl(&rep.green);
- swapl(&rep.blue);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), &rep);
-
- return Success;
-}
-
-static int
-ProcXF86VidModeSetGammaRamp(ClientPtr client)
-{
- CARD16 *r, *g, *b;
- int length;
-
- REQUEST(xXF86VidModeSetGammaRampReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
- return BadValue;
-
- length = (stuff->size + 1) & ~1;
-
- REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
-
- r = (CARD16 *) &stuff[1];
- g = r + length;
- b = g + length;
-
- if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
- return BadValue;
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetGammaRamp(ClientPtr client)
-{
- CARD16 *ramp = NULL;
- int length;
- size_t ramplen = 0;
- xXF86VidModeGetGammaRampReply rep;
-
- REQUEST(xXF86VidModeGetGammaRampReq);
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
- return BadValue;
-
- length = (stuff->size + 1) & ~1;
-
- if (stuff->size) {
- ramplen = length * 3 * sizeof(CARD16);
- if (!(ramp = malloc(ramplen)))
- return BadAlloc;
-
- if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
- ramp, ramp + length, ramp + (length * 2))) {
- free(ramp);
- return BadValue;
- }
- }
- rep = (xXF86VidModeGetGammaRampReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = (length >> 1) * 3,
- .size = stuff->size
- };
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.size);
- SwapShorts((short *) ramp, length * 3);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), &rep);
-
- if (stuff->size) {
- WriteToClient(client, ramplen, ramp);
- free(ramp);
- }
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetGammaRampSize(ClientPtr client)
-{
- xXF86VidModeGetGammaRampSizeReply rep;
-
- REQUEST(xXF86VidModeGetGammaRampSizeReq);
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- rep = (xXF86VidModeGetGammaRampSizeReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .size = VidModeGetGammaRampSize(stuff->screen)
- };
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.size);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply), &rep);
-
- return Success;
-}
-
-static int
-ProcXF86VidModeGetPermissions(ClientPtr client)
-{
- xXF86VidModeGetPermissionsReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .permissions = XF86VM_READ_PERMISSION
- };
-
- REQUEST(xXF86VidModeGetPermissionsReq);
-
- REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (xf86GetVidModeEnabled() &&
- (xf86GetVidModeAllowNonLocal() || client->local)) {
- rep.permissions |= XF86VM_WRITE_PERMISSION;
- }
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.permissions);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply), &rep);
-
- return Success;
-}
-
-static int
-ProcXF86VidModeSetClientVersion(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetClientVersionReq);
-
- VidModePrivPtr pPriv;
-
- DEBUG_P("XF86VidModeSetClientVersion");
-
- REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
-
- if ((pPriv = VM_GETPRIV(client)) == NULL) {
- pPriv = malloc(sizeof(VidModePrivRec));
- if (!pPriv)
- return BadAlloc;
- VM_SETPRIV(client, pPriv);
- }
- pPriv->major = stuff->major;
-
- pPriv->minor = stuff->minor;
-
- return Success;
-}
-
-static int
-ProcXF86VidModeDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data) {
- case X_XF86VidModeQueryVersion:
- return ProcXF86VidModeQueryVersion(client);
- case X_XF86VidModeGetModeLine:
- return ProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetMonitor:
- return ProcXF86VidModeGetMonitor(client);
- case X_XF86VidModeGetAllModeLines:
- return ProcXF86VidModeGetAllModeLines(client);
- case X_XF86VidModeValidateModeLine:
- return ProcXF86VidModeValidateModeLine(client);
- case X_XF86VidModeGetViewPort:
- return ProcXF86VidModeGetViewPort(client);
- case X_XF86VidModeGetDotClocks:
- return ProcXF86VidModeGetDotClocks(client);
- case X_XF86VidModeSetClientVersion:
- return ProcXF86VidModeSetClientVersion(client);
- case X_XF86VidModeGetGamma:
- return ProcXF86VidModeGetGamma(client);
- case X_XF86VidModeGetGammaRamp:
- return ProcXF86VidModeGetGammaRamp(client);
- case X_XF86VidModeGetGammaRampSize:
- return ProcXF86VidModeGetGammaRampSize(client);
- case X_XF86VidModeGetPermissions:
- return ProcXF86VidModeGetPermissions(client);
- default:
- if (!xf86GetVidModeEnabled())
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86GetVidModeAllowNonLocal() || client->local) {
- switch (stuff->data) {
- case X_XF86VidModeAddModeLine:
- return ProcXF86VidModeAddModeLine(client);
- case X_XF86VidModeDeleteModeLine:
- return ProcXF86VidModeDeleteModeLine(client);
- case X_XF86VidModeModModeLine:
- return ProcXF86VidModeModModeLine(client);
- case X_XF86VidModeSwitchMode:
- return ProcXF86VidModeSwitchMode(client);
- case X_XF86VidModeSwitchToMode:
- return ProcXF86VidModeSwitchToMode(client);
- case X_XF86VidModeLockModeSwitch:
- return ProcXF86VidModeLockModeSwitch(client);
- case X_XF86VidModeSetViewPort:
- return ProcXF86VidModeSetViewPort(client);
- case X_XF86VidModeSetGamma:
- return ProcXF86VidModeSetGamma(client);
- case X_XF86VidModeSetGammaRamp:
- return ProcXF86VidModeSetGammaRamp(client);
- default:
- return BadRequest;
- }
- }
- else
- return VidModeErrorBase + XF86VidModeClientNotLocal;
- }
-}
-
-static int
-SProcXF86VidModeQueryVersion(ClientPtr client)
-{
- REQUEST(xXF86VidModeQueryVersionReq);
- swaps(&stuff->length);
- return ProcXF86VidModeQueryVersion(client);
-}
-
-static int
-SProcXF86VidModeGetModeLine(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetModeLineReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetModeLine(client);
-}
-
-static int
-SProcXF86VidModeGetAllModeLines(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetAllModeLinesReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetAllModeLines(client);
-}
-
-static int
-SProcXF86VidModeAddModeLine(ClientPtr client)
-{
- xXF86OldVidModeAddModeLineReq *oldstuff =
- (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
- int ver;
-
- REQUEST(xXF86VidModeAddModeLineReq);
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- }
- else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
- }
- return ProcXF86VidModeAddModeLine(client);
-}
-
-static int
-SProcXF86VidModeDeleteModeLine(ClientPtr client)
-{
- xXF86OldVidModeDeleteModeLineReq *oldstuff =
- (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
- int ver;
-
- REQUEST(xXF86VidModeDeleteModeLineReq);
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- }
- else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
- }
- return ProcXF86VidModeDeleteModeLine(client);
-}
-
-static int
-SProcXF86VidModeModModeLine(ClientPtr client)
-{
- xXF86OldVidModeModModeLineReq *oldstuff =
- (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
- int ver;
-
- REQUEST(xXF86VidModeModModeLineReq);
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- }
- else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
- }
- return ProcXF86VidModeModModeLine(client);
-}
-
-static int
-SProcXF86VidModeValidateModeLine(ClientPtr client)
-{
- xXF86OldVidModeValidateModeLineReq *oldstuff =
- (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
- int ver;
-
- REQUEST(xXF86VidModeValidateModeLineReq);
- ver = ClientMajorVersion(client);
- if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- }
- else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
- }
- return ProcXF86VidModeValidateModeLine(client);
-}
-
-static int
-SProcXF86VidModeSwitchMode(ClientPtr client)
-{
- REQUEST(xXF86VidModeSwitchModeReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
- swaps(&stuff->screen);
- swaps(&stuff->zoom);
- return ProcXF86VidModeSwitchMode(client);
-}
-
-static int
-SProcXF86VidModeSwitchToMode(ClientPtr client)
-{
- REQUEST(xXF86VidModeSwitchToModeReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
- swapl(&stuff->screen);
- return ProcXF86VidModeSwitchToMode(client);
-}
-
-static int
-SProcXF86VidModeLockModeSwitch(ClientPtr client)
-{
- REQUEST(xXF86VidModeLockModeSwitchReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
- swaps(&stuff->screen);
- swaps(&stuff->lock);
- return ProcXF86VidModeLockModeSwitch(client);
-}
-
-static int
-SProcXF86VidModeGetMonitor(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetMonitorReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetMonitor(client);
-}
-
-static int
-SProcXF86VidModeGetViewPort(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetViewPortReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetViewPort(client);
-}
-
-static int
-SProcXF86VidModeSetViewPort(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetViewPortReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
- swaps(&stuff->screen);
- swapl(&stuff->x);
- swapl(&stuff->y);
- return ProcXF86VidModeSetViewPort(client);
-}
-
-static int
-SProcXF86VidModeGetDotClocks(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetDotClocksReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetDotClocks(client);
-}
-
-static int
-SProcXF86VidModeSetClientVersion(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetClientVersionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
- swaps(&stuff->major);
- swaps(&stuff->minor);
- return ProcXF86VidModeSetClientVersion(client);
-}
-
-static int
-SProcXF86VidModeSetGamma(ClientPtr client)
-{
- REQUEST(xXF86VidModeSetGammaReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
- swaps(&stuff->screen);
- swapl(&stuff->red);
- swapl(&stuff->green);
- swapl(&stuff->blue);
- return ProcXF86VidModeSetGamma(client);
-}
-
-static int
-SProcXF86VidModeGetGamma(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetGammaReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetGamma(client);
-}
-
-static int
-SProcXF86VidModeSetGammaRamp(ClientPtr client)
-{
- int length;
-
- REQUEST(xXF86VidModeSetGammaRampReq);
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
- swaps(&stuff->size);
- swaps(&stuff->screen);
- length = ((stuff->size + 1) & ~1) * 6;
- REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
- SwapRestS(stuff);
- return ProcXF86VidModeSetGammaRamp(client);
-}
-
-static int
-SProcXF86VidModeGetGammaRamp(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetGammaRampReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
- swaps(&stuff->size);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetGammaRamp(client);
-}
-
-static int
-SProcXF86VidModeGetGammaRampSize(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetGammaRampSizeReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetGammaRampSize(client);
-}
-
-static int
-SProcXF86VidModeGetPermissions(ClientPtr client)
-{
- REQUEST(xXF86VidModeGetPermissionsReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
- swaps(&stuff->screen);
- return ProcXF86VidModeGetPermissions(client);
-}
-
-static int
-SProcXF86VidModeDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data) {
- case X_XF86VidModeQueryVersion:
- return SProcXF86VidModeQueryVersion(client);
- case X_XF86VidModeGetModeLine:
- return SProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetMonitor:
- return SProcXF86VidModeGetMonitor(client);
- case X_XF86VidModeGetAllModeLines:
- return SProcXF86VidModeGetAllModeLines(client);
- case X_XF86VidModeGetViewPort:
- return SProcXF86VidModeGetViewPort(client);
- case X_XF86VidModeValidateModeLine:
- return SProcXF86VidModeValidateModeLine(client);
- case X_XF86VidModeGetDotClocks:
- return SProcXF86VidModeGetDotClocks(client);
- case X_XF86VidModeSetClientVersion:
- return SProcXF86VidModeSetClientVersion(client);
- case X_XF86VidModeGetGamma:
- return SProcXF86VidModeGetGamma(client);
- case X_XF86VidModeGetGammaRamp:
- return SProcXF86VidModeGetGammaRamp(client);
- case X_XF86VidModeGetGammaRampSize:
- return SProcXF86VidModeGetGammaRampSize(client);
- case X_XF86VidModeGetPermissions:
- return SProcXF86VidModeGetPermissions(client);
- default:
- if (!xf86GetVidModeEnabled())
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86GetVidModeAllowNonLocal() || client->local) {
- switch (stuff->data) {
- case X_XF86VidModeAddModeLine:
- return SProcXF86VidModeAddModeLine(client);
- case X_XF86VidModeDeleteModeLine:
- return SProcXF86VidModeDeleteModeLine(client);
- case X_XF86VidModeModModeLine:
- return SProcXF86VidModeModModeLine(client);
- case X_XF86VidModeSwitchMode:
- return SProcXF86VidModeSwitchMode(client);
- case X_XF86VidModeSwitchToMode:
- return SProcXF86VidModeSwitchToMode(client);
- case X_XF86VidModeLockModeSwitch:
- return SProcXF86VidModeLockModeSwitch(client);
- case X_XF86VidModeSetViewPort:
- return SProcXF86VidModeSetViewPort(client);
- case X_XF86VidModeSetGamma:
- return SProcXF86VidModeSetGamma(client);
- case X_XF86VidModeSetGammaRamp:
- return SProcXF86VidModeSetGammaRamp(client);
- default:
- return BadRequest;
- }
- }
- else
- return VidModeErrorBase + XF86VidModeClientNotLocal;
- }
-}
-
-void
-XFree86VidModeExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- ScreenPtr pScreen;
- int i;
- Bool enabled = FALSE;
-
- DEBUG_P("XFree86VidModeExtensionInit");
-
- if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
- return;
-#ifdef XF86VIDMODE_EVENTS
- if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return;
-#endif
-
-#ifdef XF86VIDMODE_EVENTS
- EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
-#endif
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- pScreen = screenInfo.screens[i];
- if (VidModeExtensionInit(pScreen))
- enabled = TRUE;
- }
- /* This means that the DDX doesn't want the vidmode extension enabled */
- if (!enabled)
- return;
-
- if (
-#ifdef XF86VIDMODE_EVENTS
- EventType &&
-#endif
- (extEntry = AddExtension(XF86VIDMODENAME,
- XF86VidModeNumberEvents,
- XF86VidModeNumberErrors,
- ProcXF86VidModeDispatch,
- SProcXF86VidModeDispatch,
- NULL, StandardMinorOpcode))) {
-#if 0
- XF86VidModeReqCode = (unsigned char) extEntry->base;
-#endif
- VidModeErrorBase = extEntry->errorBase;
-#ifdef XF86VIDMODE_EVENTS
- XF86VidModeEventBase = extEntry->eventBase;
- EventSwapVector[XF86VidModeEventBase] =
- (EventSwapPtr) SXF86VidModeNotifyEvent;
-#endif
- }
-}
diff --git a/xserver/hw/xfree86/common/xf86xv.c b/xserver/hw/xfree86/common/xf86xv.c
index b974cd212..d613d712c 100644
--- a/xserver/hw/xfree86/common/xf86xv.c
+++ b/xserver/hw/xfree86/common/xf86xv.c
@@ -131,8 +131,8 @@ xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc)
{
xf86XVInitGenericAdaptorPtr *newdrivers;
- newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
- (1 + NumGenDrivers));
+ newdrivers = reallocarray(GenDrivers, 1 + NumGenDrivers,
+ sizeof(xf86XVInitGenericAdaptorPtr));
if (!newdrivers)
return 0;
GenDrivers = newdrivers;
@@ -159,7 +159,7 @@ xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** adaptors)
n = (*GenDrivers[i]) (pScrn, &DrivAdap);
if (0 == n)
continue;
- new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num + n));
+ new = reallocarray(*adaptors, num + n, sizeof(XF86VideoAdaptorPtr));
if (NULL == new)
continue;
*adaptors = new;
@@ -436,8 +436,8 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
void *moreSpace;
totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
+ moreSpace = reallocarray(pFormat, totFormat,
+ sizeof(XvFormatRec));
if (!moreSpace)
break;
pFormat = moreSpace;
diff --git a/xserver/hw/xfree86/common/xf86xvmc.c b/xserver/hw/xfree86/common/xf86xvmc.c
index 3169c054c..a0a94c74b 100644
--- a/xserver/hw/xfree86/common/xf86xvmc.c
+++ b/xserver/hw/xfree86/common/xf86xvmc.c
@@ -155,7 +155,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
if (noXvExtension)
return FALSE;
- if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
+ if (!(pAdapt = xallocarray(num_adaptors, sizeof(XvMCAdaptorRec))))
return FALSE;
if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) {