aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/common')
-rw-r--r--xorg-server/hw/xfree86/common/Makefile.am14
-rw-r--r--xorg-server/hw/xfree86/common/dgaproc.h110
-rw-r--r--xorg-server/hw/xfree86/common/vidmodeproc.h2
-rw-r--r--xorg-server/hw/xfree86/common/xaarop.h311
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h6
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c13
-rw-r--r--xorg-server/hw/xfree86/common/xf86DGA.c1160
-rw-r--r--xorg-server/hw/xfree86/common/xf86Extensions.c142
-rw-r--r--xorg-server/hw/xfree86/common/xf86Extensions.h55
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c11
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h17
-rw-r--r--xorg-server/hw/xfree86/common/xf86platformBus.c9
-rw-r--r--xorg-server/hw/xfree86/common/xf86str.h1
-rw-r--r--xorg-server/hw/xfree86/common/xf86vmode.c2165
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c13
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.h4
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.h3
18 files changed, 3910 insertions, 132 deletions
diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am
index 65d98e694..f8fcde956 100644
--- a/xorg-server/hw/xfree86/common/Makefile.am
+++ b/xorg-server/hw/xfree86/common/Makefile.am
@@ -20,6 +20,7 @@ endif
if DGA
DGASOURCES = xf86DGA.c
+DGA_SDK = dgaproc.h
endif
if XORG_BUS_PLATFORM
@@ -45,7 +46,8 @@ libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
xf86Option.c xf86Init.c \
xf86VidMode.c xf86fbman.c xf86cmap.c \
xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
- xf86Mode.c xorgHelper.c \
+ xf86Mode.c xorgHelper.c xf86Extensions.h \
+ xf86Extensions.c xf86vmode.c \
$(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
@@ -54,13 +56,14 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
-I$(srcdir)/../loader -I$(srcdir)/../parser \
-I$(srcdir)/../vbe -I$(srcdir)/../int10 \
-I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \
- -I$(srcdir)/../modes -I$(srcdir)/../ramdac
+ -I$(srcdir)/../modes -I$(srcdir)/../ramdac -I$(srcdir)/../dri2
sdk_HEADERS = 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 \
- $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \
- xf86sbusBus.h xf86VGAarbiter.h xf86Optionstr.h xf86platformBus.h
+ $(XVSDKINCS) $(XF86VMODE_SDK) $(DGA_SDK) xorgVersion.h \
+ xf86sbusBus.h xf86VGAarbiter.h xf86Optionstr.h xf86platformBus.h \
+ xaarop.h
DISTCLEANFILES = xf86Build.h
CLEANFILES = $(BUILT_SOURCES)
@@ -92,7 +95,8 @@ EXTRA_DIST = \
modeline2c.awk \
xf86VGAarbiter.h \
xf86VGAarbiterPriv.h \
- $(DISTKBDSOURCES)
+ $(DISTKBDSOURCES) \
+ xaarop.h
if LNXACPI
XORG_CFLAGS += -DHAVE_ACPI
diff --git a/xorg-server/hw/xfree86/common/dgaproc.h b/xorg-server/hw/xfree86/common/dgaproc.h
new file mode 100644
index 000000000..e824d3094
--- /dev/null
+++ b/xorg-server/hw/xfree86/common/dgaproc.h
@@ -0,0 +1,110 @@
+
+#ifndef __DGAPROC_H
+#define __DGAPROC_H
+
+#include <X11/Xproto.h>
+#include "pixmap.h"
+
+#define DGA_CONCURRENT_ACCESS 0x00000001
+#define DGA_FILL_RECT 0x00000002
+#define DGA_BLIT_RECT 0x00000004
+#define DGA_BLIT_RECT_TRANS 0x00000008
+#define DGA_PIXMAP_AVAILABLE 0x00000010
+
+#define DGA_INTERLACED 0x00010000
+#define DGA_DOUBLESCAN 0x00020000
+
+#define DGA_FLIP_IMMEDIATE 0x00000001
+#define DGA_FLIP_RETRACE 0x00000002
+
+#define DGA_COMPLETED 0x00000000
+#define DGA_PENDING 0x00000001
+
+#define DGA_NEED_ROOT 0x00000001
+
+typedef struct {
+ int num; /* A unique identifier for the mode (num > 0) */
+ char *name; /* name of mode given in the XF86Config */
+ int VSync_num;
+ int VSync_den;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset;
+ int reserved1;
+ int reserved2;
+} XDGAModeRec, *XDGAModePtr;
+
+/* 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);
+
+#endif /* __DGAPROC_H */
diff --git a/xorg-server/hw/xfree86/common/vidmodeproc.h b/xorg-server/hw/xfree86/common/vidmodeproc.h
index aa43237d4..311d35c7b 100644
--- a/xorg-server/hw/xfree86/common/vidmodeproc.h
+++ b/xorg-server/hw/xfree86/common/vidmodeproc.h
@@ -39,7 +39,7 @@ typedef union {
float f;
} vidMonitorValue;
-extern _X_EXPORT void XFree86VidModeExtensionInit(void);
+extern Bool VidModeExtensionInit(ScreenPtr pScreen);
extern _X_EXPORT Bool VidModeAvailable(int scrnIndex);
extern _X_EXPORT Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode,
diff --git a/xorg-server/hw/xfree86/common/xaarop.h b/xorg-server/hw/xfree86/common/xaarop.h
new file mode 100644
index 000000000..f2acde075
--- /dev/null
+++ b/xorg-server/hw/xfree86/common/xaarop.h
@@ -0,0 +1,311 @@
+/*
+
+ int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
+
+ For use with solid fills emulated by solid 8x8 patterns. You
+ give it the foreground, planemask and X rop and it will replace
+ the foreground with a new one and the rop with the appropriate
+ MS triadic raster op. The function will return which components
+ (S-P) need to be enabled.
+
+ int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
+
+ For use with 8x8 opaque pattern fills. You give it the foreground,
+ and background, planemask and X rop and it will replace the
+ foreground and background with new ones and the rop with the
+ appropriate MS triadic raster op. The function will return which
+ components (S-P) need to be enabled.
+
+ ROP_PAT - Means to enable 8x8 mono patterns (all bits
+ set for solid patterns). Set the foreground and
+ background as returned by the function.
+
+ ROP_SRC - Means a source of color == planemask should be used.
+
+
+*/
+
+#ifndef _XAAROP_H
+#define _XAAROP_H
+
+#define ROP_DST 0x00000001
+#define ROP_SRC 0x00000002
+#define ROP_PAT 0x00000004
+
+#define ROP_0 0x00
+#define ROP_DPSoon 0x01
+#define ROP_DPSona 0x02
+#define ROP_PSon 0x03
+#define ROP_SDPona 0x04
+#define ROP_DPon 0x05
+#define ROP_PDSxnon 0x06
+#define ROP_PDSaon 0x07
+#define ROP_SDPnaa 0x08
+#define ROP_PDSxon 0x09
+#define ROP_DPna 0x0A
+#define ROP_PSDnaon 0x0B
+#define ROP_SPna 0x0C
+#define ROP_PDSnaon 0x0D
+#define ROP_PDSonon 0x0E
+#define ROP_Pn 0x0F
+#define ROP_PDSona 0x10
+#define ROP_DSon 0x11
+#define ROP_SDPxnon 0x12
+#define ROP_SDPaon 0x13
+#define ROP_DPSxnon 0x14
+#define ROP_DPSaon 0x15
+#define ROP_PSDPSanaxx 0x16
+#define ROP_SSPxDSxaxn 0x17
+#define ROP_SPxPDxa 0x18
+#define ROP_SDPSanaxn 0x19
+#define ROP_PDSPaox 0x1A
+#define ROP_SDPSxaxn 0x1B
+#define ROP_PSDPaox 0x1C
+#define ROP_DSPDxaxn 0x1D
+#define ROP_PDSox 0x1E
+#define ROP_PDSoan 0x1F
+#define ROP_DPSnaa 0x20
+#define ROP_SDPxon 0x21
+#define ROP_DSna 0x22
+#define ROP_SPDnaon 0x23
+#define ROP_SPxDSxa 0x24
+#define ROP_PDSPanaxn 0x25
+#define ROP_SDPSaox 0x26
+#define ROP_SDPSxnox 0x27
+#define ROP_DPSxa 0x28
+#define ROP_PSDPSaoxxn 0x29
+#define ROP_DPSana 0x2A
+#define ROP_SSPxPDxaxn 0x2B
+#define ROP_SPDSoax 0x2C
+#define ROP_PSDnox 0x2D
+#define ROP_PSDPxox 0x2E
+#define ROP_PSDnoan 0x2F
+#define ROP_PSna 0x30
+#define ROP_SDPnaon 0x31
+#define ROP_SDPSoox 0x32
+#define ROP_Sn 0x33
+#define ROP_SPDSaox 0x34
+#define ROP_SPDSxnox 0x35
+#define ROP_SDPox 0x36
+#define ROP_SDPoan 0x37
+#define ROP_PSDPoax 0x38
+#define ROP_SPDnox 0x39
+#define ROP_SPDSxox 0x3A
+#define ROP_SPDnoan 0x3B
+#define ROP_PSx 0x3C
+#define ROP_SPDSonox 0x3D
+#define ROP_SPDSnaox 0x3E
+#define ROP_PSan 0x3F
+#define ROP_PSDnaa 0x40
+#define ROP_DPSxon 0x41
+#define ROP_SDxPDxa 0x42
+#define ROP_SPDSanaxn 0x43
+#define ROP_SDna 0x44
+#define ROP_DPSnaon 0x45
+#define ROP_DSPDaox 0x46
+#define ROP_PSDPxaxn 0x47
+#define ROP_SDPxa 0x48
+#define ROP_PDSPDaoxxn 0x49
+#define ROP_DPSDoax 0x4A
+#define ROP_PDSnox 0x4B
+#define ROP_SDPana 0x4C
+#define ROP_SSPxDSxoxn 0x4D
+#define ROP_PDSPxox 0x4E
+#define ROP_PDSnoan 0x4F
+#define ROP_PDna 0x50
+#define ROP_DSPnaon 0x51
+#define ROP_DPSDaox 0x52
+#define ROP_SPDSxaxn 0x53
+#define ROP_DPSonon 0x54
+#define ROP_Dn 0x55
+#define ROP_DPSox 0x56
+#define ROP_DPSoan 0x57
+#define ROP_PDSPoax 0x58
+#define ROP_DPSnox 0x59
+#define ROP_DPx 0x5A
+#define ROP_DPSDonox 0x5B
+#define ROP_DPSDxox 0x5C
+#define ROP_DPSnoan 0x5D
+#define ROP_DPSDnaox 0x5E
+#define ROP_DPan 0x5F
+#define ROP_PDSxa 0x60
+#define ROP_DSPDSaoxxn 0x61
+#define ROP_DSPDoax 0x62
+#define ROP_SDPnox 0x63
+#define ROP_SDPSoax 0x64
+#define ROP_DSPnox 0x65
+#define ROP_DSx 0x66
+#define ROP_SDPSonox 0x67
+#define ROP_DSPDSonoxxn 0x68
+#define ROP_PDSxxn 0x69
+#define ROP_DPSax 0x6A
+#define ROP_PSDPSoaxxn 0x6B
+#define ROP_SDPax 0x6C
+#define ROP_PDSPDoaxxn 0x6D
+#define ROP_SDPSnoax 0x6E
+#define ROP_PDSxnan 0x6F
+#define ROP_PDSana 0x70
+#define ROP_SSDxPDxaxn 0x71
+#define ROP_SDPSxox 0x72
+#define ROP_SDPnoan 0x73
+#define ROP_DSPDxox 0x74
+#define ROP_DSPnoan 0x75
+#define ROP_SDPSnaox 0x76
+#define ROP_DSan 0x77
+#define ROP_PDSax 0x78
+#define ROP_DSPDSoaxxn 0x79
+#define ROP_DPSDnoax 0x7A
+#define ROP_SDPxnan 0x7B
+#define ROP_SPDSnoax 0x7C
+#define ROP_DPSxnan 0x7D
+#define ROP_SPxDSxo 0x7E
+#define ROP_DPSaan 0x7F
+#define ROP_DPSaa 0x80
+#define ROP_SPxDSxon 0x81
+#define ROP_DPSxna 0x82
+#define ROP_SPDSnoaxn 0x83
+#define ROP_SDPxna 0x84
+#define ROP_PDSPnoaxn 0x85
+#define ROP_DSPDSoaxx 0x86
+#define ROP_PDSaxn 0x87
+#define ROP_DSa 0x88
+#define ROP_SDPSnaoxn 0x89
+#define ROP_DSPnoa 0x8A
+#define ROP_DSPDxoxn 0x8B
+#define ROP_SDPnoa 0x8C
+#define ROP_SDPSxoxn 0x8D
+#define ROP_SSDxPDxax 0x8E
+#define ROP_PDSanan 0x8F
+#define ROP_PDSxna 0x90
+#define ROP_SDPSnoaxn 0x91
+#define ROP_DPSDPoaxx 0x92
+#define ROP_SPDaxn 0x93
+#define ROP_PSDPSoaxx 0x94
+#define ROP_DPSaxn 0x95
+#define ROP_DPSxx 0x96
+#define ROP_PSDPSonoxx 0x97
+#define ROP_SDPSonoxn 0x98
+#define ROP_DSxn 0x99
+#define ROP_DPSnax 0x9A
+#define ROP_SDPSoaxn 0x9B
+#define ROP_SPDnax 0x9C
+#define ROP_DSPDoaxn 0x9D
+#define ROP_DSPDSaoxx 0x9E
+#define ROP_PDSxan 0x9F
+#define ROP_DPa 0xA0
+#define ROP_PDSPnaoxn 0xA1
+#define ROP_DPSnoa 0xA2
+#define ROP_DPSDxoxn 0xA3
+#define ROP_PDSPonoxn 0xA4
+#define ROP_PDxn 0xA5
+#define ROP_DSPnax 0xA6
+#define ROP_PDSPoaxn 0xA7
+#define ROP_DPSoa 0xA8
+#define ROP_DPSoxn 0xA9
+#define ROP_D 0xAA
+#define ROP_DPSono 0xAB
+#define ROP_SPDSxax 0xAC
+#define ROP_DPSDaoxn 0xAD
+#define ROP_DSPnao 0xAE
+#define ROP_DPno 0xAF
+#define ROP_PDSnoa 0xB0
+#define ROP_PDSPxoxn 0xB1
+#define ROP_SSPxDSxox 0xB2
+#define ROP_SDPanan 0xB3
+#define ROP_PSDnax 0xB4
+#define ROP_DPSDoaxn 0xB5
+#define ROP_DPSDPaoxx 0xB6
+#define ROP_SDPxan 0xB7
+#define ROP_PSDPxax 0xB8
+#define ROP_DSPDaoxn 0xB9
+#define ROP_DPSnao 0xBA
+#define ROP_DSno 0xBB
+#define ROP_SPDSanax 0xBC
+#define ROP_SDxPDxan 0xBD
+#define ROP_DPSxo 0xBE
+#define ROP_DPSano 0xBF
+#define ROP_Psa 0xC0
+#define ROP_SPDSnaoxn 0xC1
+#define ROP_SPDSonoxn 0xC2
+#define ROP_PSxn 0xC3
+#define ROP_SPDnoa 0xC4
+#define ROP_SPDSxoxn 0xC5
+#define ROP_SDPnax 0xC6
+#define ROP_PSDPoaxn 0xC7
+#define ROP_SDPoa 0xC8
+#define ROP_SPDoxn 0xC9
+#define ROP_DPSDxax 0xCA
+#define ROP_SPDSaoxn 0xCB
+#define ROP_S 0xCC
+#define ROP_SDPono 0xCD
+#define ROP_SDPnao 0xCE
+#define ROP_SPno 0xCF
+#define ROP_PSDnoa 0xD0
+#define ROP_PSDPxoxn 0xD1
+#define ROP_PDSnax 0xD2
+#define ROP_SPDSoaxn 0xD3
+#define ROP_SSPxPDxax 0xD4
+#define ROP_DPSanan 0xD5
+#define ROP_PSDPSaoxx 0xD6
+#define ROP_DPSxan 0xD7
+#define ROP_PDSPxax 0xD8
+#define ROP_SDPSaoxn 0xD9
+#define ROP_DPSDanax 0xDA
+#define ROP_SPxDSxan 0xDB
+#define ROP_SPDnao 0xDC
+#define ROP_SDno 0xDD
+#define ROP_SDPxo 0xDE
+#define ROP_SDPano 0xDF
+#define ROP_PDSoa 0xE0
+#define ROP_PDSoxn 0xE1
+#define ROP_DSPDxax 0xE2
+#define ROP_PSDPaoxn 0xE3
+#define ROP_SDPSxax 0xE4
+#define ROP_PDSPaoxn 0xE5
+#define ROP_SDPSanax 0xE6
+#define ROP_SPxPDxan 0xE7
+#define ROP_SSPxDSxax 0xE8
+#define ROP_DSPDSanaxxn 0xE9
+#define ROP_DPSao 0xEA
+#define ROP_DPSxno 0xEB
+#define ROP_SDPao 0xEC
+#define ROP_SDPxno 0xED
+#define ROP_DSo 0xEE
+#define ROP_SDPnoo 0xEF
+#define ROP_P 0xF0
+#define ROP_PDSono 0xF1
+#define ROP_PDSnao 0xF2
+#define ROP_PSno 0xF3
+#define ROP_PSDnao 0xF4
+#define ROP_PDno 0xF5
+#define ROP_PDSxo 0xF6
+#define ROP_PDSano 0xF7
+#define ROP_PDSao 0xF8
+#define ROP_PDSxno 0xF9
+#define ROP_DPo 0xFA
+#define ROP_DPSnoo 0xFB
+#define ROP_PSo 0xFC
+#define ROP_PSDnoo 0xFD
+#define ROP_DPSoo 0xFE
+#define ROP_1 0xFF
+
+#define NO_SRC_ROP(rop) \
+ ((rop == GXnoop) || (rop == GXset) || (rop == GXclear) || (rop == GXinvert))
+
+extern _X_EXPORT int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm,
+ int *rop);
+extern _X_EXPORT int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg,
+ int pm, int *rop);
+
+/* XXX These four should be static, but it breaks the 6.7.0 ABI. */
+extern _X_EXPORT int XAACopyROP[16];
+extern _X_EXPORT int XAACopyROP_PM[16];
+extern _X_EXPORT int XAAPatternROP[16];
+extern _X_EXPORT int XAAPatternROP_PM[16];
+
+extern _X_EXPORT int XAAGetCopyROP(int i);
+extern _X_EXPORT int XAAGetCopyROP_PM(int i);
+extern _X_EXPORT int XAAGetPatternROP(int i);
+extern _X_EXPORT int XAAGetPatternROP_PM(int i);
+
+#endif /* _XAAROP_H */
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index 61169857f..8dc7dcccf 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -449,10 +449,8 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
Bool resetMode);
#endif
-/* xf86VidModeExtentionInit.c */
-
-extern _X_EXPORT Bool
-VidModeExtensionInit(ScreenPtr pScreen);
+/* xf86Extensions.c */
+extern void xf86ExtensionInit(void);
/* convert ScreenPtr to ScrnInfoPtr */
extern _X_EXPORT ScrnInfoPtr xf86ScreenToScrn(ScreenPtr pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 6b806a372..486752b07 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -109,22 +109,9 @@
#endif
static ModuleDefault ModuleDefaults[] = {
- {.name = "extmod",.toLoad = TRUE,.load_opt = NULL},
-#ifdef DBE
- {.name = "dbe",.toLoad = TRUE,.load_opt = NULL},
-#endif
#ifdef GLXEXT
{.name = "glx",.toLoad = TRUE,.load_opt = NULL},
#endif
-#ifdef XRECORD
- {.name = "record",.toLoad = TRUE,.load_opt = NULL},
-#endif
-#ifdef XF86DRI
- {.name = "dri",.toLoad = TRUE,.load_opt = NULL},
-#endif
-#ifdef DRI2
- {.name = "dri2",.toLoad = TRUE,.load_opt = NULL},
-#endif
#ifdef __CYGWIN__
/* load DIX modules used by drivers first */
{.name = "fb",.toLoad = TRUE,.load_opt = NULL},
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c
index 64163721f..a441dee99 100644
--- a/xorg-server/hw/xfree86/common/xf86DGA.c
+++ b/xorg-server/hw/xfree86/common/xf86DGA.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 1995 Jon Tombs
+ * Copyright (c) 1995, 1996, 1999 XFree86 Inc
* Copyright (c) 1998-2002 by The XFree86 Project, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -27,10 +29,20 @@
* Written by Mark Vojkovich
*/
+/*
+ * This is quite literally just two files glued together:
+ * hw/xfree86/common/xf86DGA.c is the first part, and
+ * hw/xfree86/dixmods/extmod/xf86dga2.c is the second part. One day, if
+ * someone actually cares about DGA, it'd be nice to clean this up. But trust
+ * me, I am not that person.
+ */
+
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
#include "xf86.h"
#include "xf86str.h"
#include "xf86Priv.h"
@@ -48,9 +60,24 @@
#include "exevents.h"
#include "eventstr.h"
#include "eventconvert.h"
+#include "xf86Extensions.h"
#include "mi.h"
+#include "misc.h"
+#include "dixstruct.h"
+#include "dixevents.h"
+#include "extnsionst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "swaprep.h"
+#include "dgaproc.h"
+#include "protocol-versions.h"
+
+#include <string.h>
+
+#define DGA_PROTOCOL_OLD_SUPPORT 1
+
static DevPrivateKeyRec DGAScreenKeyRec;
#define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
@@ -66,7 +93,9 @@ static void DGAHandleEvent(int screen_num, InternalEvent *event,
static void
DGACopyModeInfo(DGAModePtr mode, XDGAModePtr xmode);
-int *XDGAEventBase = NULL;
+static unsigned char DGAReqCode = 0;
+static int DGAErrorBase;
+static int DGAEventBase;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
@@ -521,18 +550,27 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
}
Bool
-DGAAvailable(int index)
+DGAScreenAvailable(ScreenPtr pScreen)
{
if (!DGAScreenKeyRegistered)
return FALSE;
- if (DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
+ if (DGA_GET_SCREEN_PRIV(pScreen))
return TRUE;
-
return FALSE;
}
Bool
+DGAAvailable(int index)
+{
+ ScreenPtr pScreen;
+
+ assert(index < MAXSCREENS);
+ pScreen = screenInfo.screens[index];
+ return DGAScreenAvailable(pScreen);
+}
+
+Bool
DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
@@ -891,15 +929,16 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
if (!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
return FALSE;
- memset(&event, 0, sizeof(event));
- event.header = ET_Internal;
- event.type = ET_DGAEvent;
- event.length = sizeof(event);
- event.time = GetTimeInMillis();
- event.subtype = (is_down ? ET_KeyPress : ET_KeyRelease);
- event.detail = key_code;
- event.dx = 0;
- event.dy = 0;
+ event = (DGAEvent) {
+ .header = ET_Internal,
+ .type = ET_DGAEvent,
+ .length = sizeof(event),
+ .time = GetTimeInMillis(),
+ .subtype = (is_down ? ET_KeyPress : ET_KeyRelease),
+ .detail = key_code,
+ .dx = 0,
+ .dy = 0
+ };
mieqEnqueue(dev, (InternalEvent *) &event);
return TRUE;
@@ -919,15 +958,16 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
if (!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
return FALSE;
- memset(&event, 0, sizeof(event));
- event.header = ET_Internal;
- event.type = ET_DGAEvent;
- event.length = sizeof(event);
- event.time = GetTimeInMillis();
- event.subtype = ET_Motion;
- event.detail = 0;
- event.dx = dx;
- event.dy = dy;
+ event = (DGAEvent) {
+ .header = ET_Internal,
+ .type = ET_DGAEvent,
+ .length = sizeof(event),
+ .time = GetTimeInMillis(),
+ .subtype = ET_Motion,
+ .detail = 0,
+ .dx = dx,
+ .dy = dy
+ };
mieqEnqueue(dev, (InternalEvent *) &event);
return TRUE;
}
@@ -946,15 +986,16 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
if (!pScreenPriv || !pScreenPriv->grabMouse)
return FALSE;
- memset(&event, 0, sizeof(event));
- event.header = ET_Internal;
- event.type = ET_DGAEvent;
- event.length = sizeof(event);
- event.time = GetTimeInMillis();
- event.subtype = (is_down ? ET_ButtonPress : ET_ButtonRelease);
- event.detail = button;
- event.dx = 0;
- event.dy = 0;
+ event = (DGAEvent) {
+ .header = ET_Internal,
+ .type = ET_DGAEvent,
+ .length = sizeof(event),
+ .time = GetTimeInMillis(),
+ .subtype = (is_down ? ET_ButtonPress : ET_ButtonRelease),
+ .detail = button,
+ .dx = 0,
+ .dy = 0
+ };
mieqEnqueue(dev, (InternalEvent *) &event);
return TRUE;
@@ -979,16 +1020,15 @@ DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
KeyClassPtr keyc = keybd->key;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
DeviceIntPtr pointer = GetMaster(keybd, POINTER_OR_FLOAT);
- DeviceEvent ev;
-
- memset(&ev, 0, sizeof(ev));
- ev.header = ET_Internal;
- ev.length = sizeof(ev);
- ev.detail.key = event->detail;
- ev.type = event->subtype;
- ev.root_x = 0;
- ev.root_y = 0;
- ev.corestate = XkbStateFieldFromRec(&keyc->xkbInfo->state);
+ DeviceEvent ev = {
+ .header = ET_Internal,
+ .length = sizeof(ev),
+ .detail.key = event->detail,
+ .type = event->subtype,
+ .root_x = 0,
+ .root_y = 0,
+ .corestate = XkbStateFieldFromRec(&keyc->xkbInfo->state)
+ };
ev.corestate |= pointer->button->state;
UpdateDeviceState(keybd, &ev);
@@ -997,15 +1037,15 @@ DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
* Deliver the DGA event
*/
if (pScreenPriv->client) {
- dgaEvent de;
-
- de.u.u.type = *XDGAEventBase + GetCoreType(ev.type);
+ dgaEvent de = {
+ .u.event.time = event->time,
+ .u.event.dx = event->dx,
+ .u.event.dy = event->dy,
+ .u.event.screen = pScreen->myNum,
+ .u.event.state = ev.corestate
+ };
+ de.u.u.type = DGAEventBase + GetCoreType(ev.type);
de.u.u.detail = event->detail;
- de.u.event.time = event->time;
- de.u.event.dx = event->dx;
- de.u.event.dy = event->dy;
- de.u.event.screen = pScreen->myNum;
- de.u.event.state = ev.corestate;
/* If the DGA client has selected input, then deliver based on the usual filter */
TryClientEvents(pScreenPriv->client, keybd, (xEvent *) &de, 1,
@@ -1030,14 +1070,14 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
{
ButtonClassPtr butc = mouse->button;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- DeviceEvent ev;
DeviceIntPtr master = GetMaster(mouse, MASTER_KEYBOARD);
+ DeviceEvent ev = {
+ .header = ET_Internal,
+ .length = sizeof(ev),
+ .type = event->subtype,
+ .corestate = butc ? butc->state : 0
+ };
- memset(&ev, 0, sizeof(ev));
- ev.header = ET_Internal;
- ev.length = sizeof(ev);
- ev.type = event->subtype;
- ev.corestate = butc ? butc->state : 0;
if (master && master->key)
ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state);
@@ -1047,18 +1087,16 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
* Deliver the DGA event
*/
if (pScreenPriv->client) {
- dgaEvent de;
- int coreEquiv;
-
- coreEquiv = GetCoreType(ev.type);
-
- de.u.u.type = *XDGAEventBase + coreEquiv;
+ int coreEquiv = GetCoreType(ev.type);
+ dgaEvent de = {
+ .u.event.time = event->time,
+ .u.event.dx = event->dx,
+ .u.event.dy = event->dy,
+ .u.event.screen = pScreen->myNum,
+ .u.event.state = ev.corestate
+ };
+ de.u.u.type = DGAEventBase + coreEquiv;
de.u.u.detail = event->detail;
- de.u.event.time = event->time;
- de.u.event.dx = event->dx;
- de.u.event.dy = event->dy;
- de.u.event.screen = pScreen->myNum;
- de.u.event.state = ev.corestate;
/* If the DGA client has selected input, then deliver based on the usual filter */
TryClientEvents(pScreenPriv->client, mouse, (xEvent *) &de, 1,
@@ -1144,8 +1182,8 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
DGAScreenPtr pScreenPriv;
/* no DGA */
- if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
- return;
+ if (!DGAScreenKeyRegistered || noXFree86DGAExtension)
+ return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
/* DGA not initialized on this screen */
@@ -1169,3 +1207,989 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
break;
}
}
+
+static void XDGAResetProc(ExtensionEntry * extEntry);
+
+static void DGAClientStateChange(CallbackListPtr *, pointer, pointer);
+
+static DevPrivateKeyRec DGAScreenPrivateKeyRec;
+
+#define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
+#define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
+static DevPrivateKeyRec DGAClientPrivateKeyRec;
+
+#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
+static int DGACallbackRefCount = 0;
+
+/* This holds the client's version information */
+typedef struct {
+ int major;
+ int minor;
+} DGAPrivRec, *DGAPrivPtr;
+
+#define DGA_GETCLIENT(idx) ((ClientPtr) \
+ dixLookupPrivate(&screenInfo.screens[idx]->devPrivates, DGAScreenPrivateKey))
+#define DGA_SETCLIENT(idx,p) \
+ dixSetPrivate(&screenInfo.screens[idx]->devPrivates, DGAScreenPrivateKey, p)
+
+#define DGA_GETPRIV(c) ((DGAPrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey))
+#define DGA_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p)
+
+static void
+XDGAResetProc(ExtensionEntry * extEntry)
+{
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ DGACallbackRefCount = 0;
+}
+
+static int
+ProcXDGAQueryVersion(ClientPtr client)
+{
+ xXDGAQueryVersionReply rep;
+
+ REQUEST_SIZE_MATCH(xXDGAQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_XDGA_MAJOR_VERSION;
+ rep.minorVersion = SERVER_XDGA_MINOR_VERSION;
+
+ WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXDGAOpenFramebuffer(ClientPtr client)
+{
+ REQUEST(xXDGAOpenFramebufferReq);
+ xXDGAOpenFramebufferReply rep;
+ char *deviceName;
+ int nameSize;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAOpenFramebuffer(stuff->screen, &deviceName,
+ (unsigned char **) (&rep.mem1),
+ (int *) &rep.size, (int *) &rep.offset,
+ (int *) &rep.extra)) {
+ return BadAlloc;
+ }
+
+ nameSize = deviceName ? (strlen(deviceName) + 1) : 0;
+ rep.length = bytes_to_int32(nameSize);
+
+ WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *) &rep);
+ if (rep.length)
+ WriteToClient(client, nameSize, deviceName);
+
+ return Success;
+}
+
+static int
+ProcXDGACloseFramebuffer(ClientPtr client)
+{
+ REQUEST(xXDGACloseFramebufferReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq);
+
+ DGACloseFramebuffer(stuff->screen);
+
+ return Success;
+}
+
+static int
+ProcXDGAQueryModes(ClientPtr client)
+{
+ int i, num, size;
+
+ REQUEST(xXDGAQueryModesReq);
+ xXDGAQueryModesReply rep;
+ xXDGAModeInfo info;
+ XDGAModePtr mode;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXDGAQueryModesReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.number = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen)) {
+ rep.number = 0;
+ rep.length = 0;
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+ return Success;
+ }
+
+ if (!(num = DGAGetModes(stuff->screen))) {
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+ return Success;
+ }
+
+ if (!(mode = (XDGAModePtr) malloc(num * sizeof(XDGAModeRec))))
+ return BadAlloc;
+
+ for (i = 0; i < num; i++)
+ DGAGetModeInfo(stuff->screen, mode + i, i + 1);
+
+ size = num * sz_xXDGAModeInfo;
+ for (i = 0; i < num; i++)
+ size += pad_to_int32(strlen(mode[i].name) + 1); /* plus NULL */
+
+ rep.number = num;
+ rep.length = bytes_to_int32(size);
+
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+
+ for (i = 0; i < num; i++) {
+ size = strlen(mode[i].name) + 1;
+
+ info.byte_order = mode[i].byteOrder;
+ info.depth = mode[i].depth;
+ info.num = mode[i].num;
+ info.bpp = mode[i].bitsPerPixel;
+ info.name_size = (size + 3) & ~3L;
+ info.vsync_num = mode[i].VSync_num;
+ info.vsync_den = mode[i].VSync_den;
+ info.flags = mode[i].flags;
+ info.image_width = mode[i].imageWidth;
+ info.image_height = mode[i].imageHeight;
+ info.pixmap_width = mode[i].pixmapWidth;
+ info.pixmap_height = mode[i].pixmapHeight;
+ info.bytes_per_scanline = mode[i].bytesPerScanline;
+ info.red_mask = mode[i].red_mask;
+ info.green_mask = mode[i].green_mask;
+ info.blue_mask = mode[i].blue_mask;
+ info.visual_class = mode[i].visualClass;
+ info.viewport_width = mode[i].viewportWidth;
+ info.viewport_height = mode[i].viewportHeight;
+ info.viewport_xstep = mode[i].xViewportStep;
+ info.viewport_ystep = mode[i].yViewportStep;
+ info.viewport_xmax = mode[i].maxViewportX;
+ info.viewport_ymax = mode[i].maxViewportY;
+ info.viewport_flags = mode[i].viewportFlags;
+ info.reserved1 = mode[i].reserved1;
+ info.reserved2 = mode[i].reserved2;
+
+ WriteToClient(client, sz_xXDGAModeInfo, (char *) (&info));
+ WriteToClient(client, size, mode[i].name);
+ }
+
+ free(mode);
+
+ return Success;
+}
+
+static void
+DGAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *) calldata;
+ ClientPtr client = NULL;
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (DGA_GETCLIENT(i) == pci->client) {
+ client = pci->client;
+ break;
+ }
+ }
+
+ if (client &&
+ ((client->clientState == ClientStateGone) ||
+ (client->clientState == ClientStateRetained))) {
+ XDGAModeRec mode;
+ PixmapPtr pPix;
+
+ DGA_SETCLIENT(i, NULL);
+ DGASelectInput(i, NULL, 0);
+ DGASetMode(i, 0, &mode, &pPix);
+
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+}
+
+static int
+ProcXDGASetMode(ClientPtr client)
+{
+ REQUEST(xXDGASetModeReq);
+ xXDGASetModeReply rep;
+ XDGAModeRec mode;
+ xXDGAModeInfo info;
+ PixmapPtr pPix;
+ ClientPtr owner;
+ int size;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+ owner = DGA_GETCLIENT(stuff->screen);
+
+ REQUEST_SIZE_MATCH(xXDGASetModeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.offset = 0;
+ rep.flags = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (owner && owner != client)
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (!stuff->mode) {
+ if (owner) {
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange,
+ NULL);
+ }
+ DGA_SETCLIENT(stuff->screen, NULL);
+ DGASelectInput(stuff->screen, NULL, 0);
+ DGASetMode(stuff->screen, 0, &mode, &pPix);
+ WriteToClient(client, sz_xXDGASetModeReply, (char *) &rep);
+ return Success;
+ }
+
+ if (Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix))
+ return BadValue;
+
+ if (!owner) {
+ if (DGACallbackRefCount++ == 0)
+ AddCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGA_SETCLIENT(stuff->screen, client);
+
+ if (pPix) {
+ if (AddResource(stuff->pid, RT_PIXMAP, (pointer) (pPix))) {
+ pPix->drawable.id = (int) stuff->pid;
+ rep.flags = DGA_PIXMAP_AVAILABLE;
+ }
+ }
+
+ size = strlen(mode.name) + 1;
+
+ info.byte_order = mode.byteOrder;
+ info.depth = mode.depth;
+ info.num = mode.num;
+ info.bpp = mode.bitsPerPixel;
+ info.name_size = (size + 3) & ~3L;
+ info.vsync_num = mode.VSync_num;
+ info.vsync_den = mode.VSync_den;
+ info.flags = mode.flags;
+ info.image_width = mode.imageWidth;
+ info.image_height = mode.imageHeight;
+ info.pixmap_width = mode.pixmapWidth;
+ info.pixmap_height = mode.pixmapHeight;
+ info.bytes_per_scanline = mode.bytesPerScanline;
+ info.red_mask = mode.red_mask;
+ info.green_mask = mode.green_mask;
+ info.blue_mask = mode.blue_mask;
+ info.visual_class = mode.visualClass;
+ info.viewport_width = mode.viewportWidth;
+ info.viewport_height = mode.viewportHeight;
+ info.viewport_xstep = mode.xViewportStep;
+ info.viewport_ystep = mode.yViewportStep;
+ info.viewport_xmax = mode.maxViewportX;
+ info.viewport_ymax = mode.maxViewportY;
+ info.viewport_flags = mode.viewportFlags;
+ info.reserved1 = mode.reserved1;
+ info.reserved2 = mode.reserved2;
+
+ rep.length = bytes_to_int32(sz_xXDGAModeInfo + info.name_size);
+
+ WriteToClient(client, sz_xXDGASetModeReply, (char *) &rep);
+ WriteToClient(client, sz_xXDGAModeInfo, (char *) (&info));
+ WriteToClient(client, size, mode.name);
+
+ return Success;
+}
+
+static int
+ProcXDGASetViewport(ClientPtr client)
+{
+ REQUEST(xXDGASetViewportReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASetViewportReq);
+
+ DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags);
+
+ return Success;
+}
+
+static int
+ProcXDGAInstallColormap(ClientPtr client)
+{
+ ColormapPtr cmap;
+ int rc;
+
+ REQUEST(xXDGAInstallColormapReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
+
+ rc = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc != Success)
+ return rc;
+ DGAInstallCmap(cmap);
+ return Success;
+}
+
+static int
+ProcXDGASelectInput(ClientPtr client)
+{
+ REQUEST(xXDGASelectInputReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASelectInputReq);
+
+ if (DGA_GETCLIENT(stuff->screen) == client)
+ DGASelectInput(stuff->screen, client, stuff->mask);
+
+ return Success;
+}
+
+static int
+ProcXDGAFillRectangle(ClientPtr client)
+{
+ REQUEST(xXDGAFillRectangleReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAFillRectangleReq);
+
+ if (Success != DGAFillRect(stuff->screen, stuff->x, stuff->y,
+ stuff->width, stuff->height, stuff->color))
+ return BadMatch;
+
+ return Success;
+}
+
+static int
+ProcXDGACopyArea(ClientPtr client)
+{
+ REQUEST(xXDGACopyAreaReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACopyAreaReq);
+
+ if (Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx,
+ stuff->dsty))
+ return BadMatch;
+
+ return Success;
+}
+
+static int
+ProcXDGACopyTransparentArea(ClientPtr client)
+{
+ REQUEST(xXDGACopyTransparentAreaReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq);
+
+ if (Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx,
+ stuff->dsty, stuff->key))
+ return BadMatch;
+
+ return Success;
+}
+
+static int
+ProcXDGAGetViewportStatus(ClientPtr client)
+{
+ REQUEST(xXDGAGetViewportStatusReq);
+ xXDGAGetViewportStatusReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.status = DGAGetViewportStatus(stuff->screen);
+
+ WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXDGASync(ClientPtr client)
+{
+ REQUEST(xXDGASyncReq);
+ xXDGASyncReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASyncReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ DGASync(stuff->screen);
+
+ WriteToClient(client, sizeof(xXDGASyncReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXDGASetClientVersion(ClientPtr client)
+{
+ REQUEST(xXDGASetClientVersionReq);
+
+ DGAPrivPtr pPriv;
+
+ REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
+ if ((pPriv = DGA_GETPRIV(client)) == NULL) {
+ pPriv = malloc(sizeof(DGAPrivRec));
+ /* XXX Need to look into freeing this */
+ if (!pPriv)
+ return BadAlloc;
+ DGA_SETPRIV(client, pPriv);
+ }
+ pPriv->major = stuff->major;
+ pPriv->minor = stuff->minor;
+
+ return Success;
+}
+
+static int
+ProcXDGAChangePixmapMode(ClientPtr client)
+{
+ REQUEST(xXDGAChangePixmapModeReq);
+ xXDGAChangePixmapModeReply rep;
+ int x, y;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ x = stuff->x;
+ y = stuff->y;
+
+ if (!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags))
+ return BadMatch;
+
+ rep.x = x;
+ rep.y = y;
+ WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *) &rep);
+
+ return Success;
+}
+
+static int
+ProcXDGACreateColormap(ClientPtr client)
+{
+ REQUEST(xXDGACreateColormapReq);
+ int result;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACreateColormapReq);
+
+ if (!stuff->mode)
+ return BadValue;
+
+ result = DGACreateColormap(stuff->screen, client, stuff->id,
+ stuff->mode, stuff->alloc);
+ if (result != Success)
+ return result;
+
+ return Success;
+}
+
+/*
+ *
+ * Support for the old DGA protocol, used to live in xf86dga.c
+ *
+ */
+
+#ifdef DGA_PROTOCOL_OLD_SUPPORT
+
+static int
+ProcXF86DGAGetVideoLL(ClientPtr client)
+{
+ REQUEST(xXF86DGAGetVideoLLReq);
+ xXF86DGAGetVideoLLReply rep;
+ XDGAModeRec mode;
+ int num, offset, flags;
+ char *name;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ /* get the parameters for the mode that best matches */
+ DGAGetModeInfo(stuff->screen, &mode, num);
+
+ if (!DGAOpenFramebuffer(stuff->screen, &name,
+ (unsigned char **) (&rep.offset),
+ (int *) (&rep.bank_size), &offset, &flags))
+ return BadAlloc;
+
+ rep.offset += mode.offset;
+ rep.width = mode.bytesPerScanline / (mode.bitsPerPixel >> 3);
+ rep.ram_size = rep.bank_size >> 10;
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXF86DGADirectVideo(ClientPtr client)
+{
+ int num;
+ PixmapPtr pix;
+ XDGAModeRec mode;
+ ClientPtr owner;
+
+ REQUEST(xXF86DGADirectVideoReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+ REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ owner = DGA_GETCLIENT(stuff->screen);
+
+ if (owner && owner != client)
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (stuff->enable & XF86DGADirectGraphics) {
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+ }
+ else
+ num = 0;
+
+ if (Success != DGASetMode(stuff->screen, num, &mode, &pix))
+ return DGAErrorBase + XF86DGAScreenNotActive;
+
+ DGASetInputMode(stuff->screen,
+ (stuff->enable & XF86DGADirectKeyb) != 0,
+ (stuff->enable & XF86DGADirectMouse) != 0);
+
+ /* We need to track the client and attach the teardown callback */
+ if (stuff->enable &
+ (XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse)) {
+ if (!owner) {
+ if (DGACallbackRefCount++ == 0)
+ AddCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGA_SETCLIENT(stuff->screen, client);
+ }
+ else {
+ if (owner) {
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange,
+ NULL);
+ }
+
+ DGA_SETCLIENT(stuff->screen, NULL);
+ }
+
+ return Success;
+}
+
+static int
+ProcXF86DGAGetViewPortSize(ClientPtr client)
+{
+ int num;
+ XDGAModeRec mode;
+
+ REQUEST(xXF86DGAGetViewPortSizeReq);
+ xXF86DGAGetViewPortSizeReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ DGAGetModeInfo(stuff->screen, &mode, num);
+
+ rep.width = mode.viewportWidth;
+ rep.height = mode.viewportHeight;
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXF86DGASetViewPort(ClientPtr client)
+{
+ REQUEST(xXF86DGASetViewPortReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (!DGAActive(stuff->screen))
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE)
+ != Success)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ return Success;
+}
+
+static int
+ProcXF86DGAGetVidPage(ClientPtr client)
+{
+ REQUEST(xXF86DGAGetVidPageReq);
+ xXF86DGAGetVidPageReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.vpage = 0; /* silently fail */
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXF86DGASetVidPage(ClientPtr client)
+{
+ REQUEST(xXF86DGASetVidPageReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq);
+
+ /* silently fail */
+
+ return Success;
+}
+
+static int
+ProcXF86DGAInstallColormap(ClientPtr client)
+{
+ ColormapPtr pcmp;
+ int rc;
+
+ REQUEST(xXF86DGAInstallColormapReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
+
+ if (!DGAActive(stuff->screen))
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ rc = dixLookupResourceByType((pointer *) &pcmp, stuff->id, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc == Success) {
+ DGAInstallCmap(pcmp);
+ return Success;
+ }
+ else {
+ return rc;
+ }
+}
+
+static int
+ProcXF86DGAQueryDirectVideo(ClientPtr client)
+{
+ REQUEST(xXF86DGAQueryDirectVideoReq);
+ xXF86DGAQueryDirectVideoReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.flags = 0;
+
+ if (DGAAvailable(stuff->screen))
+ rep.flags = XF86DGADirectPresent;
+
+ WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcXF86DGAViewPortChanged(ClientPtr client)
+{
+ REQUEST(xXF86DGAViewPortChangedReq);
+ xXF86DGAViewPortChangedReply rep;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (DGA_GETCLIENT(stuff->screen) != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
+
+ if (!DGAActive(stuff->screen))
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.result = 1;
+
+ WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *) &rep);
+ return Success;
+}
+
+#endif /* DGA_PROTOCOL_OLD_SUPPORT */
+
+static int
+SProcXDGADispatch(ClientPtr client)
+{
+ return DGAErrorBase + XF86DGAClientNotLocal;
+}
+
+#if 0
+#define DGA_REQ_DEBUG
+#endif
+
+#ifdef DGA_REQ_DEBUG
+static char *dgaMinor[] = {
+ "QueryVersion",
+ "GetVideoLL",
+ "DirectVideo",
+ "GetViewPortSize",
+ "SetViewPort",
+ "GetVidPage",
+ "SetVidPage",
+ "InstallColormap",
+ "QueryDirectVideo",
+ "ViewPortChanged",
+ "10",
+ "11",
+ "QueryModes",
+ "SetMode",
+ "SetViewport",
+ "InstallColormap",
+ "SelectInput",
+ "FillRectangle",
+ "CopyArea",
+ "CopyTransparentArea",
+ "GetViewportStatus",
+ "Sync",
+ "OpenFramebuffer",
+ "CloseFramebuffer",
+ "SetClientVersion",
+ "ChangePixmapMode",
+ "CreateColormap",
+};
+#endif
+
+static int
+ProcXDGADispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (!LocalClient(client))
+ return DGAErrorBase + XF86DGAClientNotLocal;
+
+#ifdef DGA_REQ_DEBUG
+ if (stuff->data <= X_XDGACreateColormap)
+ fprintf(stderr, " DGA %s\n", dgaMinor[stuff->data]);
+#endif
+
+ switch (stuff->data) {
+ /*
+ * DGA2 Protocol
+ */
+ case X_XDGAQueryVersion:
+ return ProcXDGAQueryVersion(client);
+ case X_XDGAQueryModes:
+ return ProcXDGAQueryModes(client);
+ case X_XDGASetMode:
+ return ProcXDGASetMode(client);
+ case X_XDGAOpenFramebuffer:
+ return ProcXDGAOpenFramebuffer(client);
+ case X_XDGACloseFramebuffer:
+ return ProcXDGACloseFramebuffer(client);
+ case X_XDGASetViewport:
+ return ProcXDGASetViewport(client);
+ case X_XDGAInstallColormap:
+ return ProcXDGAInstallColormap(client);
+ case X_XDGASelectInput:
+ return ProcXDGASelectInput(client);
+ case X_XDGAFillRectangle:
+ return ProcXDGAFillRectangle(client);
+ case X_XDGACopyArea:
+ return ProcXDGACopyArea(client);
+ case X_XDGACopyTransparentArea:
+ return ProcXDGACopyTransparentArea(client);
+ case X_XDGAGetViewportStatus:
+ return ProcXDGAGetViewportStatus(client);
+ case X_XDGASync:
+ return ProcXDGASync(client);
+ case X_XDGASetClientVersion:
+ return ProcXDGASetClientVersion(client);
+ case X_XDGAChangePixmapMode:
+ return ProcXDGAChangePixmapMode(client);
+ case X_XDGACreateColormap:
+ return ProcXDGACreateColormap(client);
+ /*
+ * Old DGA Protocol
+ */
+#ifdef DGA_PROTOCOL_OLD_SUPPORT
+ case X_XF86DGAGetVideoLL:
+ return ProcXF86DGAGetVideoLL(client);
+ case X_XF86DGADirectVideo:
+ return ProcXF86DGADirectVideo(client);
+ case X_XF86DGAGetViewPortSize:
+ return ProcXF86DGAGetViewPortSize(client);
+ case X_XF86DGASetViewPort:
+ return ProcXF86DGASetViewPort(client);
+ case X_XF86DGAGetVidPage:
+ return ProcXF86DGAGetVidPage(client);
+ case X_XF86DGASetVidPage:
+ return ProcXF86DGASetVidPage(client);
+ case X_XF86DGAInstallColormap:
+ return ProcXF86DGAInstallColormap(client);
+ case X_XF86DGAQueryDirectVideo:
+ return ProcXF86DGAQueryDirectVideo(client);
+ case X_XF86DGAViewPortChanged:
+ return ProcXF86DGAViewPortChanged(client);
+#endif /* DGA_PROTOCOL_OLD_SUPPORT */
+ default:
+ return BadRequest;
+ }
+}
+
+void
+XFree86DGAExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+
+ if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
+ if ((extEntry = AddExtension(XF86DGANAME,
+ XF86DGANumberEvents,
+ XF86DGANumberErrors,
+ ProcXDGADispatch,
+ SProcXDGADispatch,
+ XDGAResetProc, StandardMinorOpcode))) {
+ int i;
+
+ DGAReqCode = (unsigned char) extEntry->base;
+ DGAErrorBase = extEntry->errorBase;
+ DGAEventBase = extEntry->eventBase;
+ for (i = KeyPress; i <= MotionNotify; i++)
+ SetCriticalEvent(DGAEventBase + i);
+ }
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Extensions.c b/xorg-server/hw/xfree86/common/xf86Extensions.c
new file mode 100644
index 000000000..d5309d558
--- /dev/null
+++ b/xorg-server/hw/xfree86/common/xf86Extensions.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2011 Daniel Stone
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "extension.h"
+#include "globals.h"
+
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86Module.h"
+#include "xf86Extensions.h"
+#include "xf86Opt.h"
+#include "optionstr.h"
+
+#ifdef XSELINUX
+#include "xselinux.h"
+#endif
+
+#ifdef XFreeXDGA
+#include <X11/extensions/xf86dgaproto.h>
+#endif
+
+#ifdef XF86VIDMODE
+#include <X11/extensions/xf86vmproto.h>
+#include "vidmodeproc.h"
+#endif
+
+/*
+ * DDX-specific extensions.
+ */
+static ExtensionModule extensionModules[] = {
+#ifdef XF86VIDMODE
+ {
+ XFree86VidModeExtensionInit,
+ XF86VIDMODENAME,
+ &noXFree86VidModeExtension
+ },
+#endif
+#ifdef XFreeXDGA
+ {
+ XFree86DGAExtensionInit,
+ XF86DGANAME,
+ &noXFree86DGAExtension
+ },
+#endif
+#ifdef XF86DRI
+ {
+ XFree86DRIExtensionInit,
+ "XFree86-DRI",
+ &noXFree86DRIExtension
+ },
+#endif
+#ifdef DRI2
+ {
+ DRI2ExtensionInit,
+ DRI2_NAME,
+ &noDRI2Extension
+ }
+#endif
+};
+
+static void
+load_extension_config(void)
+{
+ XF86ConfModulePtr mod_con = xf86configptr->conf_modules;
+ XF86LoadPtr modp;
+ int i;
+
+ /* Only the best. */
+ if (!mod_con)
+ return;
+
+ nt_list_for_each_entry(modp, mod_con->mod_load_lst, list.next) {
+ InputOption *opt;
+
+ if (strcasecmp(modp->load_name, "extmod") != 0)
+ continue;
+
+ /* extmod options are of the form "omit <extension-name>" */
+ nt_list_for_each_entry(opt, modp->load_opt, list.next) {
+ const char *key = input_option_get_key(opt);
+ if (strncasecmp(key, "omit", 4) != 0 || strlen(key) < 5)
+ continue;
+ if (EnableDisableExtension(key + 4, FALSE))
+ xf86MarkOptionUsed(opt);
+ }
+
+#ifdef XSELINUX
+ if ((opt = xf86FindOption(modp->load_opt,
+ "SELinux mode disabled"))) {
+ xf86MarkOptionUsed(opt);
+ selinuxEnforcingState = SELINUX_MODE_DISABLED;
+ }
+ if ((opt = xf86FindOption(modp->load_opt,
+ "SELinux mode permissive"))) {
+ xf86MarkOptionUsed(opt);
+ selinuxEnforcingState = SELINUX_MODE_PERMISSIVE;
+ }
+ if ((opt = xf86FindOption(modp->load_opt,
+ "SELinux mode enforcing"))) {
+ xf86MarkOptionUsed(opt);
+ selinuxEnforcingState = SELINUX_MODE_ENFORCING;
+ }
+#endif
+ }
+}
+
+void
+xf86ExtensionInit(void)
+{
+ int i;
+
+ load_extension_config();
+
+ for (i = 0; i < ARRAY_SIZE(extensionModules); i++)
+ LoadExtension(&extensionModules[i], TRUE);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Extensions.h b/xorg-server/hw/xfree86/common/xf86Extensions.h
new file mode 100644
index 000000000..9b8448d64
--- /dev/null
+++ b/xorg-server/hw/xfree86/common/xf86Extensions.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2011 Daniel Stone
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ */
+
+#ifndef XF86EXTENSIONS_H
+#define XF86EXTENSIONS_H
+
+#include "extnsionst.h"
+
+#ifdef XF86DRI
+extern Bool noXFree86DRIExtension;
+extern void XFree86DRIExtensionInit(void);
+#endif
+
+#ifdef DRI2
+#include <X11/extensions/dri2proto.h>
+extern Bool noDRI2Extension;
+extern void DRI2ExtensionInit(void);
+#endif
+
+#ifdef XF86VIDMODE
+#include <X11/extensions/xf86vmproto.h>
+extern Bool noXFree86VidModeExtension;
+extern void XFree86VidModeExtensionInit(void);
+#endif
+
+#ifdef XFreeXDGA
+#include <X11/extensions/xf86dgaproto.h>
+extern Bool noXFree86DGAExtension;
+extern void XFree86DGAExtensionInit(void);
+extern void XFree86DGARegister(void);
+#endif
+
+#endif
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index aa17a58fd..e4a6b8613 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -401,6 +401,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
MessageType pix24From = X_DEFAULT;
Bool pix24Fail = FALSE;
Bool autoconfig = FALSE;
+ Bool sigio_blocked = FALSE;
GDevPtr configured_device;
xf86Initialising = TRUE;
@@ -471,6 +472,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
xf86OSPMClose = xf86OSPMOpen();
#endif
+ xf86ExtensionInit();
+
/* Load all modules specified explicitly in the config file */
if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
xf86LoadModules(modulelist, optionlist);
@@ -819,6 +822,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
#endif
xf86AccessEnter();
OsBlockSIGIO();
+ sigio_blocked = TRUE;
}
}
@@ -920,8 +924,12 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
#endif
}
+ for (i = 0; i < xf86NumGPUScreens; i++)
+ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
+
xf86VGAarbiterWrapFunctions();
- OsReleaseSIGIO();
+ if (sigio_blocked)
+ OsReleaseSIGIO();
xf86InitOrigins();
@@ -1006,7 +1014,6 @@ OsVendorInit(void)
}
#endif
#endif
- OsReleaseSIGIO();
beenHere = TRUE;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index 7671cea5d..d93405e3c 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -42,6 +42,7 @@
#define _XF86MODULE_H
#include "misc.h"
+#include "extension.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
@@ -55,9 +56,6 @@ typedef enum {
#define DEFAULT_LIST ((char *)-1)
-/* This indicates a special module that doesn't have the usual entry point */
-#define EXTERN_MODULE ((pointer)-1)
-
/* Built-in ABI classes. These definitions must not be changed. */
#define ABI_CLASS_NONE NULL
#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation"
@@ -171,18 +169,6 @@ typedef struct {
#define INITARGS void
-typedef void (*InitExtension) (INITARGS);
-
-typedef struct {
- InitExtension initFunc;
- const char *name;
- Bool *disablePtr;
- InitExtension setupFunc;
- const char **initDependencies;
-} ExtensionModule;
-
-extern _X_EXPORT ExtensionModule *ExtensionModuleList;
-
/* Prototypes for Loader functions that are exported to modules */
extern _X_EXPORT pointer LoadSubModule(pointer, const char *, const char **,
const char **, pointer,
@@ -193,7 +179,6 @@ extern _X_EXPORT pointer LoaderSymbol(const char *);
extern _X_EXPORT char **LoaderListDirs(const char **, const char **);
extern _X_EXPORT void LoaderFreeDirList(char **);
extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int);
-extern _X_EXPORT void LoadExtension(ExtensionModule *, Bool);
extern _X_EXPORT void LoaderGetOS(const char **name, int *major, int *minor,
int *teeny);
extern _X_EXPORT Bool LoaderShouldIgnoreABI(void);
diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c
index 3bfb22e83..24b947326 100644
--- a/xorg-server/hw/xfree86/common/xf86platformBus.c
+++ b/xorg-server/hw/xfree86/common/xf86platformBus.c
@@ -432,14 +432,17 @@ xf86platformAddDevice(int index)
xf86DeleteScreen(xf86GPUScreens[i]);
return -1;
}
-
+
scr_index = AddGPUScreen(xf86GPUScreens[i]->ScreenInit, 0, NULL);
-
+
dixSetPrivate(&xf86GPUScreens[i]->pScreen->devPrivates,
xf86ScreenKey, xf86GPUScreens[i]);
CreateScratchPixmapsForScreen(xf86GPUScreens[i]->pScreen);
-
+
+ /* attach unbound to 0 protocol screen */
+ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
+
return 0;
}
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index 6bd6a6218..059026243 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -814,6 +814,7 @@ typedef struct _ScrnInfoRec {
funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
Bool is_gpu;
+ uint32_t capabilities;
} ScrnInfoRec;
typedef struct {
diff --git a/xorg-server/hw/xfree86/common/xf86vmode.c b/xorg-server/hw/xfree86/common/xf86vmode.c
new file mode 100644
index 000000000..7cd2eedb3
--- /dev/null
+++ b/xorg-server/hw/xfree86/common/xf86vmode.c
@@ -0,0 +1,2165 @@
+
+/*
+
+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(pointer 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
+ };
+ pointer 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;
+ pointer 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;
+ pointer 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;
+ pointer 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;
+ pointer 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;
+ pointer 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;
+ pointer 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;
+ pointer 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() || LocalClient(client))) {
+ 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() || LocalClient(client)) {
+ 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() || LocalClient(client)) {
+ 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/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index 1a964d270..92d0f6da2 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -117,10 +117,6 @@ DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
-DevPrivateKey (*XvGetScreenKeyProc) (void) = NULL;
-unsigned long (*XvGetRTPortProc) (void) = NULL;
-int (*XvScreenInitProc) (ScreenPtr) = NULL;
-
#define GET_XV_SCREEN(pScreen) \
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
@@ -238,19 +234,18 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
XF86XVScreenPtr ScreenPriv;
XvScreenPtr pxvs;
- if (num <= 0 ||
- !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
+ if (num <= 0 || noXvExtension)
return FALSE;
- if (Success != (*XvScreenInitProc) (pScreen))
+ if (Success != XvScreenInit(pScreen))
return FALSE;
if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
- XF86XvScreenKey = (*XvGetScreenKeyProc) ();
+ XF86XvScreenKey = XvGetScreenKey();
- PortResource = (*XvGetRTPortProc) ();
+ PortResource = XvGetRTPort();
pxvs = GET_XV_SCREEN(pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86xv.h b/xorg-server/hw/xfree86/common/xf86xv.h
index 2db00a83f..091efcaa9 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.h
+++ b/xorg-server/hw/xfree86/common/xf86xv.h
@@ -263,8 +263,4 @@ extern _X_EXPORT void
xf86XVCopyPacked(const void *src,
void *dst, int srcPitch, int dstPitch, int h, int w);
-extern _X_EXPORT DevPrivateKey (*XvGetScreenKeyProc) (void);
-extern _X_EXPORT unsigned long (*XvGetRTPortProc) (void);
-extern _X_EXPORT int (*XvScreenInitProc) (ScreenPtr);
-
#endif /* _XF86XV_H_ */
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c
index 2e529dd92..78a32bfe1 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.c
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.c
@@ -43,8 +43,6 @@
#include "xf86xvpriv.h"
#include "xf86xvmc.h"
-XvMCScreenInitProcPtr XvMCScreenInitProc = NULL;
-
typedef struct {
CloseScreenProcPtr CloseScreen;
int num_adaptors;
@@ -154,7 +152,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
XF86XvScreenKey);
int i, j;
- if (!XvMCScreenInitProc)
+ if (noXvExtension)
return FALSE;
if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
@@ -203,7 +201,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
adaptors++;
}
- if (Success != (*XvMCScreenInitProc) (pScreen, num_adaptors, pAdapt))
+ if (Success != XvMCScreenInit(pScreen, num_adaptors, pAdapt))
return FALSE;
return TRUE;
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.h b/xorg-server/hw/xfree86/common/xf86xvmc.h
index ff32379fe..2478fe344 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.h
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.h
@@ -138,7 +138,4 @@ extern _X_EXPORT Bool xf86XvMCScreenInit(ScreenPtr pScreen,
extern _X_EXPORT XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec(void);
extern _X_EXPORT void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor);
-typedef int (*XvMCScreenInitProcPtr) (ScreenPtr, int, XvMCAdaptorPtr);
-extern _X_EXPORT XvMCScreenInitProcPtr XvMCScreenInitProc;
-
#endif /* _XF86XVMC_H */