diff options
Diffstat (limited to 'xorg-server/hw/xfree86/dixmods/extmod')
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/Makefile.am | 38 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/Makefile.in | 733 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h | 144 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/modinit.c | 286 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/modinit.h | 151 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h | 77 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c | 309 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c | 754 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h | 10 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c | 821 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h | 69 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c | 2186 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xvmod.c | 23 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h | 13 |
14 files changed, 5614 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am new file mode 100644 index 000000000..f90e144ea --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am @@ -0,0 +1,38 @@ +sdk_HEADERS = dgaproc.h + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = libextmod.la + +if DGA +DGA_SRCS = xf86dga.c xf86dga2.c dgaproc.h xf86dgaext.h +endif + +if XV +XV_SRCS = xvmod.c xvmodproc.h +endif + +if XF86MISC +XF86MISC_SRCS = xf86misc.c xf86miscproc.h +endif + +if XF86VIDMODE +XF86VMODE_SRCS = xf86vmode.c vidmodeproc.h +endif + +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/afb \ + -I$(top_srcdir)/mfb \ + -I$(top_srcdir)/cfb \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow + +libextmod_la_LDFLAGS = -avoid-version +libextmod_la_SOURCES = modinit.c \ + modinit.h \ + $(DGA_SRCS) \ + $(XF86MISC_SRCS) \ + $(XF86VMODE_SRCS) \ + $(XV_SRCS) +libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in new file mode 100644 index 000000000..157358c47 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in @@ -0,0 +1,733 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dixmods/extmod +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(extsmoduledir)" "$(DESTDIR)$(sdkdir)" +extsmoduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(extsmodule_LTLIBRARIES) +libextmod_la_DEPENDENCIES = $(top_builddir)/Xext/libXextmodule.la +am__libextmod_la_SOURCES_DIST = modinit.c modinit.h xf86dga.c \ + xf86dga2.c dgaproc.h xf86dgaext.h xf86misc.c xf86miscproc.h \ + xf86vmode.c vidmodeproc.h xvmod.c xvmodproc.h +@DGA_TRUE@am__objects_1 = xf86dga.lo xf86dga2.lo +@XF86MISC_TRUE@am__objects_2 = xf86misc.lo +@XF86VIDMODE_TRUE@am__objects_3 = xf86vmode.lo +@XV_TRUE@am__objects_4 = xvmod.lo +am_libextmod_la_OBJECTS = modinit.lo $(am__objects_1) $(am__objects_2) \ + $(am__objects_3) $(am__objects_4) +libextmod_la_OBJECTS = $(am_libextmod_la_OBJECTS) +libextmod_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libextmod_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libextmod_la_SOURCES) +DIST_SOURCES = $(am__libextmod_la_SOURCES_DIST) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +sdk_HEADERS = dgaproc.h +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = libextmod.la +@DGA_TRUE@DGA_SRCS = xf86dga.c xf86dga2.c dgaproc.h xf86dgaext.h +@XV_TRUE@XV_SRCS = xvmod.c xvmodproc.h +@XF86MISC_TRUE@XF86MISC_SRCS = xf86misc.c xf86miscproc.h +@XF86VIDMODE_TRUE@XF86VMODE_SRCS = xf86vmode.c vidmodeproc.h +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/afb \ + -I$(top_srcdir)/mfb \ + -I$(top_srcdir)/cfb \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow + +libextmod_la_LDFLAGS = -avoid-version +libextmod_la_SOURCES = modinit.c \ + modinit.h \ + $(DGA_SRCS) \ + $(XF86MISC_SRCS) \ + $(XF86VMODE_SRCS) \ + $(XV_SRCS) + +libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dixmods/extmod/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dixmods/extmod/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-extsmoduleLTLIBRARIES: $(extsmodule_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(extsmoduledir)" || $(MKDIR_P) "$(DESTDIR)$(extsmoduledir)" + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(extsmoduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(extsmoduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-extsmoduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(extsmoduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(extsmoduledir)/$$p"; \ + done + +clean-extsmoduleLTLIBRARIES: + -test -z "$(extsmodule_LTLIBRARIES)" || rm -f $(extsmodule_LTLIBRARIES) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libextmod.la: $(libextmod_la_OBJECTS) $(libextmod_la_DEPENDENCIES) + $(libextmod_la_LINK) -rpath $(extsmoduledir) $(libextmod_la_OBJECTS) $(libextmod_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modinit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86dga.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86dga2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86vmode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xvmod.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(extsmoduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-extsmoduleLTLIBRARIES clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-extsmoduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-extsmoduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-extsmoduleLTLIBRARIES clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-extsmoduleLTLIBRARIES install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-extsmoduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h new file mode 100644 index 000000000..aaea4e20c --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h @@ -0,0 +1,144 @@ + +#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 */ + +int +DGASetMode( + int Index, + int num, + XDGAModePtr mode, + PixmapPtr *pPix +); + +void +DGASetInputMode( + int Index, + Bool keyboard, + Bool mouse +); + +void +DGASelectInput( + int Index, + ClientPtr client, + long mask +); + +Bool DGAAvailable(int Index); +Bool DGAActive(int Index); +void DGAShutdown(void); +void DGAInstallCmap(ColormapPtr cmap); +int DGAGetViewportStatus(int Index); +int DGASync(int Index); + +int +DGAFillRect( + int Index, + int x, int y, int w, int h, + unsigned long color +); + +int +DGABlitRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +); + +int +DGABlitTransRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +); + +int +DGASetViewport( + int Index, + int x, int y, + int mode +); + +int DGAGetModes(int Index); +int DGAGetOldDGAMode(int Index); + +int DGAGetModeInfo(int Index, XDGAModePtr mode, int num); + +Bool DGAVTSwitch(void); +Bool DGAStealButtonEvent(int Index, int button, int is_down); +Bool DGAStealMotionEvent(int Index, int dx, int dy); +Bool DGAStealKeyEvent(int Index, int key_code, int is_down); +Bool DGAIsDgaEvent (xEvent *e); + +Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e); + +Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem, + int *size, int *offset, int *flags); +void DGACloseFramebuffer(int Index); +Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode); +int DGACreateColormap(int Index, ClientPtr client, int id, int mode, + int alloc); + +extern unsigned char DGAReqCode; +extern int DGAErrorBase; +extern int DGAEventBase; +extern int *XDGAEventBase; + + + +#endif /* __DGAPROC_H */ diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c new file mode 100644 index 000000000..8c8a4ceeb --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c @@ -0,0 +1,286 @@ +/* + * Copyright (c) 1997 Matthieu Herrb + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Matthieu Herrb not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Matthieu Herrb makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" +#include "xf86Opt.h" + +#include <X11/Xproto.h> + +#include "modinit.h" +#include "globals.h" + +static MODULESETUPPROTO(extmodSetup); + +/* + * Array describing extensions to be initialized + */ +static ExtensionModule extensionModules[] = { +#ifdef XSELINUX + { + SELinuxExtensionInit, + SELINUX_EXTENSION_NAME, + &noSELinuxExtension, + NULL, + NULL + }, +#endif +#ifdef SHAPE + { + ShapeExtensionInit, + SHAPENAME, + &noShapeExtension, + NULL, + NULL + }, +#endif +#ifdef MULTIBUFFER + { + MultibufferExtensionInit, + MULTIBUFFER_PROTOCOL_NAME, + &noMultibufferExtension, + NULL, + NULL + }, +#endif +#ifdef MITMISC + { + MITMiscExtensionInit, + MITMISCNAME, + &noMITMiscExtension, + NULL, + NULL + }, +#endif +#ifdef notyet + { + XTestExtensionInit, + XTestExtensionName, + &noTestExtensions, + NULL, + NULL + }, +#endif +#ifdef BIGREQS + { + BigReqExtensionInit, + XBigReqExtensionName, + &noBigReqExtension, + NULL, + NULL + }, +#endif +#ifdef XSYNC + { + SyncExtensionInit, + SYNC_NAME, + &noSyncExtension, + NULL, + NULL + }, +#endif +#ifdef SCREENSAVER + { + ScreenSaverExtensionInit, + ScreenSaverName, + &noScreenSaverExtension, + NULL, + NULL + }, +#endif +#ifdef XCMISC + { + XCMiscExtensionInit, + XCMiscExtensionName, + &noXCMiscExtension, + NULL, + NULL + }, +#endif +#ifdef XF86VIDMODE + { + XFree86VidModeExtensionInit, + XF86VIDMODENAME, + &noXFree86VidModeExtension, + NULL, + NULL + }, +#endif +#ifdef XF86MISC + { + XFree86MiscExtensionInit, + XF86MISCNAME, + &noXFree86MiscExtension, + NULL, + NULL + }, +#endif +#ifdef XFreeXDGA + { + XFree86DGAExtensionInit, + XF86DGANAME, + &noXFree86DGAExtension, + XFree86DGARegister, + NULL + }, +#endif +#ifdef DPMSExtension + { + DPMSExtensionInit, + DPMSExtensionName, + &noDPMSExtension, + NULL, + NULL + }, +#endif +#ifdef FONTCACHE + { + FontCacheExtensionInit, + FONTCACHENAME, + &noFontCacheExtension, + NULL, + NULL + }, +#endif +#ifdef TOGCUP + { + XcupExtensionInit, + XCUPNAME, + &noXcupExtension, + NULL, + NULL + }, +#endif +#ifdef EVI + { + EVIExtensionInit, + EVINAME, + &noEVIExtension, + NULL, + NULL + }, +#endif +#ifdef XV + { + XvExtensionInit, + XvName, + &noXvExtension, + XvRegister, + NULL + }, + { + XvMCExtensionInit, + XvMCName, + &noXvExtension, + NULL, + NULL + }, +#endif +#ifdef RES + { + ResExtensionInit, + XRES_NAME, + &noResExtension, + NULL, + NULL + }, +#endif + { /* DON'T delete this entry ! */ + NULL, + NULL, + NULL, + NULL, + NULL + } +}; + +static XF86ModuleVersionInfo VersRec = +{ + "extmod", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +/* + * Data for the loader + */ +_X_EXPORT XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL }; + +static pointer +extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + int i; + + /* XXX the option stuff here is largely a sample/test case */ + + for (i = 0; extensionModules[i].name != NULL; i++) { + if (opts) { + char *s; + s = (char *)xalloc(strlen(extensionModules[i].name) + 5); + if (s) { + pointer o; + strcpy(s, "omit"); + strcat(s, extensionModules[i].name); + o = xf86FindOption(opts, s); + xfree(s); + if (o) { + xf86MarkOptionUsed(o); + continue; + } + } + } + +#ifdef XSELINUX + if (! strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) { + pointer o; + selinuxEnforcingState = SELINUX_MODE_DEFAULT; + + if ((o = xf86FindOption(opts, "SELinux mode disabled"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_DISABLED; + } + if ((o = xf86FindOption(opts, "SELinux mode permissive"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_PERMISSIVE; + } + if ((o = xf86FindOption(opts, "SELinux mode enforcing"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_ENFORCING; + } + } +#endif + + LoadExtension(&extensionModules[i], FALSE); + } + /* Need a non-NULL return */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h new file mode 100644 index 000000000..3c2e2022a --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h @@ -0,0 +1,151 @@ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef INITARGS +#define INITARGS void +#endif + +#ifdef SHAPE +#define _SHAPE_SERVER_ /* don't want Xlib structures */ +#include <X11/extensions/shapestr.h> +#endif + +#ifdef MULTIBUFFER +extern void MultibufferExtensionInit(INITARGS); +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#include <X11/extensions/multibufst.h> +#endif + +#ifdef MITMISC +extern void MITMiscExtensionInit(INITARGS); +#define _MITMISC_SERVER_ +#include <X11/extensions/mitmiscstr.h> +#endif + +#ifdef XTEST +extern void XTestExtensionInit(INITARGS); +#define _XTEST_SERVER_ +#include <X11/extensions/XTest.h> +#include <X11/extensions/xteststr.h> +#endif + +#if 1 +extern void XTestExtension1Init(INITARGS); +#endif + +#ifdef BIGREQS +extern void BigReqExtensionInit(INITARGS); +#include <X11/extensions/bigreqstr.h> +#endif + +#ifdef XSYNC +extern void SyncExtensionInit(INITARGS); +#define _SYNC_SERVER +#include <X11/extensions/sync.h> +#include <X11/extensions/syncstr.h> +#endif + +#ifdef SCREENSAVER +extern void ScreenSaverExtensionInit (INITARGS); +#include <X11/extensions/saver.h> +#endif + +#ifdef XCMISC +extern void XCMiscExtensionInit(INITARGS); +#include <X11/extensions/xcmiscstr.h> +#endif + +#ifdef XF86VIDMODE +extern void XFree86VidModeExtensionInit(INITARGS); +#define _XF86VIDMODE_SERVER_ +#include <X11/extensions/xf86vmstr.h> +#endif + +#ifdef XF86MISC +extern void XFree86MiscExtensionInit(INITARGS); +#define _XF86MISC_SERVER_ +#define _XF86MISC_SAVER_COMPAT_ +#include <X11/extensions/xf86mscstr.h> +#endif + +#ifdef XFreeXDGA +extern void XFree86DGAExtensionInit(INITARGS); +extern void XFree86DGARegister(INITARGS); +#define _XF86DGA_SERVER_ +#include <X11/extensions/xf86dgastr.h> +#endif + +#ifdef DPMSExtension +extern void DPMSExtensionInit(INITARGS); +#include <X11/extensions/dpmsstr.h> +#endif + +#ifdef FONTCACHE +extern void FontCacheExtensionInit(INITARGS); +#define _FONTCACHE_SERVER_ +#include "fontcacheP.h" +#include "fontcachstr.h" +#endif + +#ifdef TOGCUP +extern void XcupExtensionInit(INITARGS); +#define _XCUP_SERVER_ +#include <X11/extensions/Xcupstr.h> +#endif + +#ifdef EVI +extern void EVIExtensionInit(INITARGS); +#define _XEVI_SERVER_ +#include <X11/extensions/XEVIstr.h> +#endif + +#ifdef XV +extern void XvExtensionInit(INITARGS); +extern void XvMCExtensionInit(INITARGS); +extern void XvRegister(INITARGS); +#include <X11/extensions/Xv.h> +#include <X11/extensions/XvMC.h> +#endif + +#ifdef RES +extern void ResExtensionInit(INITARGS); +#include <X11/extensions/XResproto.h> +#endif + +#ifdef SHM +extern void ShmExtensionInit(INITARGS); +#include <X11/extensions/shmstr.h> +extern void ShmSetPixmapFormat( + ScreenPtr pScreen, + int format); +extern void ShmRegisterFuncs( + ScreenPtr pScreen, + ShmFuncsPtr funcs); +#endif + +#ifdef XSELINUX +extern void SELinuxExtensionInit(INITARGS); +#include "xselinux.h" +#endif + +#if 1 +extern void SecurityExtensionInit(INITARGS); +#endif + +#if 1 +extern void XagExtensionInit(INITARGS); +#endif + +#if 1 +extern void XpExtensionInit(INITARGS); +#endif + +#if 1 +extern void PanoramiXExtensionInit(int argc, char *argv[]); +#endif + +#if 1 +extern void XkbExtensionInit(INITARGS); +#endif diff --git a/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h b/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h new file mode 100644 index 000000000..c5ad03af2 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h @@ -0,0 +1,77 @@ + +/* Prototypes for DGA functions that the DDX must provide */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _VIDMODEPROC_H_ +#define _VIDMODEPROC_H_ + + +typedef enum { + VIDMODE_H_DISPLAY, + VIDMODE_H_SYNCSTART, + VIDMODE_H_SYNCEND, + VIDMODE_H_TOTAL, + VIDMODE_H_SKEW, + VIDMODE_V_DISPLAY, + VIDMODE_V_SYNCSTART, + VIDMODE_V_SYNCEND, + VIDMODE_V_TOTAL, + VIDMODE_FLAGS, + VIDMODE_CLOCK +} VidModeSelectMode; + +typedef enum { + VIDMODE_MON_VENDOR, + VIDMODE_MON_MODEL, + VIDMODE_MON_NHSYNC, + VIDMODE_MON_NVREFRESH, + VIDMODE_MON_HSYNC_LO, + VIDMODE_MON_HSYNC_HI, + VIDMODE_MON_VREFRESH_LO, + VIDMODE_MON_VREFRESH_HI +} VidModeSelectMonitor; + +typedef union { + pointer ptr; + int i; + float f; +} vidMonitorValue; + +void XFree86VidModeExtensionInit(void); + +Bool VidModeAvailable(int scrnIndex); +Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeDeleteModeline(int scrnIndex, pointer mode); +Bool VidModeZoomViewport(int scrnIndex, int zoom); +Bool VidModeGetViewPort(int scrnIndex, int *x, int *y); +Bool VidModeSetViewPort(int scrnIndex, int x, int y); +Bool VidModeSwitchMode(int scrnIndex, pointer mode); +Bool VidModeLockZoom(int scrnIndex, Bool lock); +Bool VidModeGetMonitor(int scrnIndex, pointer *monitor); +int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock); +Bool VidModeGetClocks(int scrnIndex, int *Clocks); +ModeStatus VidModeCheckModeForMonitor(int scrnIndex, pointer mode); +ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode); +void VidModeSetCrtcForMode(int scrnIndex, pointer mode); +Bool VidModeAddModeline(int scrnIndex, pointer mode); +int VidModeGetDotClock(int scrnIndex, int Clock); +int VidModeGetNumOfModes(int scrnIndex); +Bool VidModeSetGamma(int scrnIndex, float red, float green, float blue); +Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue); +pointer VidModeCreateMode(void); +void VidModeCopyMode(pointer modefrom, pointer modeto); +int VidModeGetModeValue(pointer mode, int valtyp); +void VidModeSetModeValue(pointer mode, int valtyp, int val); +vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx); +Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +int VidModeGetGammaRampSize(int scrnIndex); + +#endif + + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c new file mode 100644 index 000000000..c66bca26b --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c @@ -0,0 +1,309 @@ + +/* + +Copyright (c) 1995 Jon Tombs +Copyright (c) 1995, 1996, 1999 XFree86 Inc + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include <X11/extensions/xf86dga.h> +#include <X11/extensions/xf86dgastr.h> +#include "swaprep.h" +#include "dgaproc.h" + +#include "xf86dgaext.h" + + +static DISPATCH_PROC(ProcXF86DGADirectVideo); +static DISPATCH_PROC(ProcXF86DGAGetVidPage); +static DISPATCH_PROC(ProcXF86DGAGetVideoLL); +static DISPATCH_PROC(ProcXF86DGAGetViewPortSize); +static DISPATCH_PROC(ProcXF86DGASetVidPage); +static DISPATCH_PROC(ProcXF86DGASetViewPort); +static DISPATCH_PROC(ProcXF86DGAInstallColormap); +static DISPATCH_PROC(ProcXF86DGAQueryDirectVideo); +static DISPATCH_PROC(ProcXF86DGAViewPortChanged); + + +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 (client->noClientException); +} + +static int +ProcXF86DGADirectVideo(ClientPtr client) +{ + int num; + PixmapPtr pix; + XDGAModeRec mode; + REQUEST(xXF86DGADirectVideoReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq); + + if (!DGAAvailable(stuff->screen)) + 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); + + return (client->noClientException); +} + +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 (client->noClientException); +} + +static int +ProcXF86DGASetViewPort(ClientPtr client) +{ + REQUEST(xXF86DGASetViewPortReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq); + + if (!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if (!DGAActive(stuff->screen)) + { + int num; + PixmapPtr pix; + XDGAModeRec mode; + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + if(Success != DGASetMode(stuff->screen, num, &mode, &pix)) + return (DGAErrorBase + XF86DGAScreenNotActive); + } + + if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE) + != Success) + return DGAErrorBase + XF86DGADirectNotActivated; + + return (client->noClientException); +} + +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 (client->noClientException); +} + + +static int +ProcXF86DGASetVidPage(ClientPtr client) +{ + REQUEST(xXF86DGASetVidPageReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq); + + /* silently fail */ + + return (client->noClientException); +} + + +static int +ProcXF86DGAInstallColormap(ClientPtr client) +{ + ColormapPtr pcmp; + REQUEST(xXF86DGAInstallColormapReq); + + REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq); + + if (!DGAActive(stuff->screen)) + return (DGAErrorBase + XF86DGADirectNotActivated); + + pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP); + if (pcmp) { + DGAInstallCmap(pcmp); + return (client->noClientException); + } else { + client->errorValue = stuff->id; + return (BadColor); + } +} + +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 (client->noClientException); +} + +static int +ProcXF86DGAViewPortChanged(ClientPtr client) +{ + REQUEST(xXF86DGAViewPortChangedReq); + xXF86DGAViewPortChangedReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + 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 (client->noClientException); +} + +int +ProcXF86DGADispatch(register ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + 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); + default: + return BadRequest; + } +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c new file mode 100644 index 000000000..295e05e9e --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -0,0 +1,754 @@ +/* + Copyright (c) 1999 - The XFree86 Project Inc. + + Written by Mark Vojkovich +*/ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "dixstruct.h" +#include "dixevents.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include <X11/extensions/xf86dga.h> +#include <X11/extensions/xf86dgastr.h> +#include "swaprep.h" +#include "dgaproc.h" +#include "xf86dgaext.h" + +#include <string.h> + +#include "modinit.h" + +static DISPATCH_PROC(ProcXDGADispatch); +static DISPATCH_PROC(SProcXDGADispatch); +static DISPATCH_PROC(ProcXDGAQueryVersion); +static DISPATCH_PROC(ProcXDGAQueryModes); +static DISPATCH_PROC(ProcXDGASetMode); +static DISPATCH_PROC(ProcXDGAOpenFramebuffer); +static DISPATCH_PROC(ProcXDGACloseFramebuffer); +static DISPATCH_PROC(ProcXDGASetViewport); +static DISPATCH_PROC(ProcXDGAInstallColormap); +static DISPATCH_PROC(ProcXDGASelectInput); +static DISPATCH_PROC(ProcXDGAFillRectangle); +static DISPATCH_PROC(ProcXDGACopyArea); +static DISPATCH_PROC(ProcXDGACopyTransparentArea); +static DISPATCH_PROC(ProcXDGAGetViewportStatus); +static DISPATCH_PROC(ProcXDGASync); +static DISPATCH_PROC(ProcXDGASetClientVersion); +static DISPATCH_PROC(ProcXDGAChangePixmapMode); +static DISPATCH_PROC(ProcXDGACreateColormap); + +static void XDGAResetProc(ExtensionEntry *extEntry); + +static void DGAClientStateChange (CallbackListPtr*, pointer, pointer); + +static ClientPtr DGAClients[MAXSCREENS]; + +unsigned char DGAReqCode = 0; +int DGAErrorBase; +int DGAEventBase; + +static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey; +static int DGACallbackRefCount = 0; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} DGAPrivRec, *DGAPrivPtr; + +#define DGA_GETPRIV(c) ((DGAPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey)) +#define DGA_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p) + + +void +XFree86DGAExtensionInit(INITARGS) +{ + ExtensionEntry* extEntry; + + if ((extEntry = AddExtension(XF86DGANAME, + XF86DGANumberEvents, + XF86DGANumberErrors, + ProcXDGADispatch, + SProcXDGADispatch, + XDGAResetProc, + StandardMinorOpcode))) { + int i; + + for(i = 0; i < MAXSCREENS; i++) + DGAClients[i] = NULL; + + DGAReqCode = (unsigned char)extEntry->base; + DGAErrorBase = extEntry->errorBase; + DGAEventBase = extEntry->eventBase; + for (i = KeyPress; i <= MotionNotify; i++) + SetCriticalEvent (DGAEventBase + i); + } +} + + + +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 = XDGA_MAJOR_VERSION; + rep.minorVersion = XDGA_MINOR_VERSION; + + WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + + +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 = (nameSize + 3) >> 2; + + WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep); + if(rep.length) + WriteToClient(client, nameSize, deviceName); + + return (client->noClientException); +} + + +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 (client->noClientException); +} + +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 (client->noClientException); + } + + if(!(num = DGAGetModes(stuff->screen))) { + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + return (client->noClientException); + } + + if(!(mode = (XDGAModePtr)xalloc(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 += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */ + + rep.number = num; + rep.length = size >> 2; + + 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); + } + + xfree(mode); + + return (client->noClientException); +} + + +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(DGAClients[i] == pci->client) { + client = pci->client; + break; + } + } + + if(client && + ((client->clientState == ClientStateGone) || + (client->clientState == ClientStateRetained))) { + XDGAModeRec mode; + PixmapPtr pPix; + + DGAClients[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; + int size; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + 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(DGAClients[stuff->screen] && + (DGAClients[stuff->screen] != client)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if(!stuff->mode) { + if(DGAClients[stuff->screen]) { + if(--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } + DGAClients[stuff->screen] = NULL; + DGASelectInput(stuff->screen, NULL, 0); + DGASetMode(stuff->screen, 0, &mode, &pPix); + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + return (client->noClientException); + } + + if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix)) + return BadValue; + + if(!DGAClients[stuff->screen]) { + if(DGACallbackRefCount++ == 0) + AddCallback (&ClientStateCallback, DGAClientStateChange, NULL); + } + + DGAClients[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 = (sz_xXDGAModeInfo + info.name_size) >> 2; + + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); + WriteToClient(client, size, mode.name); + + return (client->noClientException); +} + +static int +ProcXDGASetViewport(ClientPtr client) +{ + REQUEST(xXDGASetViewportReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASetViewportReq); + + DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags); + + return (client->noClientException); +} + +static int +ProcXDGAInstallColormap(ClientPtr client) +{ + ColormapPtr cmap; + REQUEST(xXDGAInstallColormapReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAInstallColormapReq); + + cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP); + if (cmap) { + DGAInstallCmap(cmap); + return (client->noClientException); + } else { + client->errorValue = stuff->cmap; + return (BadColor); + } + + return (client->noClientException); +} + + +static int +ProcXDGASelectInput(ClientPtr client) +{ + REQUEST(xXDGASelectInputReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASelectInputReq); + + if(DGAClients[stuff->screen] == client) + DGASelectInput(stuff->screen, client, stuff->mask); + + return (client->noClientException); +} + + +static int +ProcXDGAFillRectangle(ClientPtr client) +{ + REQUEST(xXDGAFillRectangleReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + +static int +ProcXDGACopyArea(ClientPtr client) +{ + REQUEST(xXDGACopyAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + + +static int +ProcXDGACopyTransparentArea(ClientPtr client) +{ + REQUEST(xXDGACopyTransparentAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + + +static int +ProcXDGAGetViewportStatus(ClientPtr client) +{ + REQUEST(xXDGAGetViewportStatusReq); + xXDGAGetViewportStatusReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + +static int +ProcXDGASync(ClientPtr client) +{ + REQUEST(xXDGASyncReq); + xXDGASyncReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + +static int +ProcXDGASetClientVersion(ClientPtr client) +{ + REQUEST(xXDGASetClientVersionReq); + + DGAPrivPtr pPriv; + + REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); + if ((pPriv = DGA_GETPRIV(client)) == NULL) { + pPriv = xalloc(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 (client->noClientException); +} + +static int +ProcXDGAChangePixmapMode(ClientPtr client) +{ + REQUEST(xXDGAChangePixmapModeReq); + xXDGAChangePixmapModeReply rep; + int x, y; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + + +static int +ProcXDGACreateColormap(ClientPtr client) +{ + REQUEST(xXDGACreateColormapReq); + int result; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[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 (client->noClientException); +} + + +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 + + /* divert old protocol */ +#if 1 + if( (stuff->data <= X_XF86DGAViewPortChanged) && + (stuff->data >= X_XF86DGAGetVideoLL)) + return ProcXF86DGADispatch(client); +#endif + + switch (stuff->data){ + 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); + default: + return BadRequest; + } +} + +void +XFree86DGARegister(INITARGS) +{ + XDGAEventBase = &DGAEventBase; +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h b/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h new file mode 100644 index 000000000..2b1737305 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h @@ -0,0 +1,10 @@ +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _XF86DGAEXT_H_ +#define _XF86DGAEXT_H_ + +extern DISPATCH_PROC(ProcXF86DGADispatch); + +#endif /* _XF86DGAEXT_H_ */ diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c new file mode 100644 index 000000000..8127afdff --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c @@ -0,0 +1,821 @@ + +/* + * Copyright (c) 1995, 1996 The XFree86 Project, Inc + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "inputstr.h" +#include "servermd.h" +#define _XF86MISC_SERVER_ +#undef _XF86MISC_SAVER_COMPAT_ +#include <X11/extensions/xf86mscstr.h> +#include "swaprep.h" +#include "xf86.h" +#include <X11/Xfuncproto.h> +#include "xf86miscproc.h" + +#if 0 +#include <X11/Xtrans/Xtrans.h> +#include "../os/osdep.h" +#include <X11/Xauth.h> +#ifndef USL +#ifndef Lynx +#include <sys/socket.h> +#else +#include <socket.h> +#endif +#endif /* USL */ +#endif + +static int miscErrorBase; +static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} MiscPrivRec, *MiscPrivPtr; + +#define M_GETPRIV(c) ((MiscPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey)) +#define M_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p) + +static void XF86MiscResetProc( + ExtensionEntry* /* extEntry */ +); + +static void +ClientVersion(ClientPtr client, int *major, int *minor) +{ + MiscPrivPtr pPriv; + + pPriv = M_GETPRIV(client); + if (!pPriv) { + if (major) *major = 0; + if (minor) *minor = 0; + return; + } + + if (major) *major = pPriv->major; + if (minor) *minor = pPriv->minor; +} + +static DISPATCH_PROC(ProcXF86MiscDispatch); +static DISPATCH_PROC(ProcXF86MiscQueryVersion); +static DISPATCH_PROC(ProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(ProcXF86MiscSetClientVersion); +static DISPATCH_PROC(ProcXF86MiscGetFilePaths); +static DISPATCH_PROC(ProcXF86MiscPassMessage); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(ProcXF86MiscGetSaver); +static DISPATCH_PROC(ProcXF86MiscSetSaver); +#endif +static DISPATCH_PROC(SProcXF86MiscDispatch); +static DISPATCH_PROC(SProcXF86MiscQueryVersion); +static DISPATCH_PROC(SProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(SProcXF86MiscSetClientVersion); +static DISPATCH_PROC(SProcXF86MiscGetFilePaths); +static DISPATCH_PROC(SProcXF86MiscPassMessage); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(SProcXF86MiscGetSaver); +static DISPATCH_PROC(SProcXF86MiscSetSaver); +#endif + +#if 0 +static unsigned char XF86MiscReqCode = 0; +#endif + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF x; +#else +# define DEBUG_P(x) do {} while (0) +#endif + +#define MISCERR(x) (miscErrorBase + x) + +void +XFree86MiscExtensionInit(void) +{ + ExtensionEntry* extEntry; + + if (!xf86GetModInDevEnabled()) + return; + + if ( + (extEntry = AddExtension(XF86MISCNAME, + XF86MiscNumberEvents, + XF86MiscNumberErrors, + ProcXF86MiscDispatch, + SProcXF86MiscDispatch, + XF86MiscResetProc, + StandardMinorOpcode))) { +#if 0 + XF86MiscReqCode = (unsigned char)extEntry->base; +#endif + miscErrorBase = extEntry->errorBase; + } +} + +/*ARGSUSED*/ +static void +XF86MiscResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +static int +ProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + xXF86MiscQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xXF86MiscQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86MISC_MAJOR_VERSION; + rep.minorVersion = XF86MISC_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86MiscQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +/* THESE HAVE NOT BEEN CONVERTED TO THE NEW DESIGN */ + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscSetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscSetSaverReq); + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); + + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + + if (stuff->suspendTime < 0) + return BadValue; + if (stuff->offTime < 0) + return BadValue; + + return (client->noClientException); +} + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscGetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscGetSaverReq); + xXF86MiscGetSaverReply rep; + register int n; + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); + + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.suspendTime = 0; + rep.offTime = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.suspendTime, n); + swapl(&rep.offTime, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetSaverReply), (char *)&rep); + return (client->noClientException); +} + +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +ProcXF86MiscGetMouseSettings(client) + register ClientPtr client; +{ + xXF86MiscGetMouseSettingsReply rep; + char *devname; + pointer mouse; + register int n; + int devnamelen; + + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetMouseSettings(&mouse, &devname)) + return BadValue; + + rep.mousetype = MiscExtGetMouseValue(mouse, MISC_MSE_PROTO); + rep.baudrate = MiscExtGetMouseValue(mouse, MISC_MSE_BAUDRATE); + rep.samplerate = MiscExtGetMouseValue(mouse, MISC_MSE_SAMPLERATE); + rep.resolution = MiscExtGetMouseValue(mouse, MISC_MSE_RESOLUTION); + rep.buttons = MiscExtGetMouseValue(mouse, MISC_MSE_BUTTONS); + rep.emulate3buttons = MiscExtGetMouseValue(mouse, MISC_MSE_EM3BUTTONS); + rep.emulate3timeout = MiscExtGetMouseValue(mouse, MISC_MSE_EM3TIMEOUT); + rep.chordmiddle = MiscExtGetMouseValue(mouse, MISC_MSE_CHORDMIDDLE); + rep.flags = MiscExtGetMouseValue(mouse, MISC_MSE_FLAGS); + devnamelen = rep.devnamelen = (devname? strlen(devname): 0); + rep.length = (sizeof(xXF86MiscGetMouseSettingsReply) - + sizeof(xGenericReply) + ((rep.devnamelen+3) & ~3)) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.mousetype, n); + swapl(&rep.baudrate, n); + swapl(&rep.samplerate, n); + swapl(&rep.resolution, n); + swapl(&rep.buttons, n); + swapl(&rep.emulate3buttons, n); + swapl(&rep.emulate3timeout, n); + swapl(&rep.chordmiddle, n); + swapl(&rep.flags, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetMouseSettingsReply), (char *)&rep); + MiscExtDestroyStruct(mouse, MISC_POINTER); + + if (devnamelen) + WriteToClient(client, devnamelen, devname); + return (client->noClientException); +} + +static int +ProcXF86MiscGetKbdSettings(client) + register ClientPtr client; +{ + xXF86MiscGetKbdSettingsReply rep; + pointer kbd; + register int n; + + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (!MiscExtGetKbdSettings(&kbd)) + return BadValue; + + rep.kbdtype = MiscExtGetKbdValue(kbd, MISC_KBD_TYPE); + rep.rate = MiscExtGetKbdValue(kbd, MISC_KBD_RATE); + rep.delay = MiscExtGetKbdValue(kbd, MISC_KBD_DELAY); + rep.servnumlock = MiscExtGetKbdValue(kbd, MISC_KBD_SERVNUMLOCK); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.kbdtype, n); + swapl(&rep.rate, n); + swapl(&rep.delay, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetKbdSettingsReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86MiscSetMouseSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer mouse; + char *devname = NULL; + int major, minor; + + REQUEST(xXF86MiscSetMouseSettingsReq); + + REQUEST_AT_LEAST_SIZE(xXF86MiscSetMouseSettingsReq); + + ClientVersion(client, &major, &minor); + + if (xf86GetVerbosity() > 1) { + DEBUG_P(("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n", + (int)stuff->mousetype, (int)stuff->baudrate, + (int)stuff->samplerate, stuff->chordmiddle)); + DEBUG_P((" em3but: %d em3tim: %d res: %d flags: %ld\n", + stuff->emulate3buttons, (int)stuff->emulate3timeout, + (int)stuff->resolution, (unsigned long)stuff->flags)); + } + + if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0) + return BadAlloc; + + MiscExtSetMouseValue(mouse, MISC_MSE_PROTO, stuff->mousetype); + MiscExtSetMouseValue(mouse, MISC_MSE_BAUDRATE, stuff->baudrate); + MiscExtSetMouseValue(mouse, MISC_MSE_SAMPLERATE, stuff->samplerate); + MiscExtSetMouseValue(mouse, MISC_MSE_RESOLUTION, stuff->resolution); + MiscExtSetMouseValue(mouse, MISC_MSE_BUTTONS, stuff->buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3BUTTONS, stuff->emulate3buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3TIMEOUT, stuff->emulate3timeout); + MiscExtSetMouseValue(mouse, MISC_MSE_CHORDMIDDLE, stuff->chordmiddle); + MiscExtSetMouseValue(mouse, MISC_MSE_FLAGS, stuff->flags); + + if ((major > 0 || minor > 5) && stuff->devnamelen) { + int size = sizeof(xXF86MiscSetMouseSettingsReq) + stuff->devnamelen; + size = (size + 3) >> 2; + if (client->req_len < size) + return BadLength; + if (stuff->devnamelen) { + if (!(devname = xalloc(stuff->devnamelen))) + return BadAlloc; + strncpy(devname,(char*)(&stuff[1]),stuff->devnamelen); + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetMouseSettings - device: %s\n",devname)); + MiscExtSetMouseDevice(mouse, devname); + } + } + + ret = MiscExtApply(mouse, MISC_POINTER); + + if (devname) + xfree(devname); + + switch ((ret)) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADMSEPROTO: return MISCERR(XF86MiscBadMouseProtocol); + case MISC_RET_BADBAUDRATE: return MISCERR(XF86MiscBadMouseBaudRate); + case MISC_RET_BADFLAGS: return MISCERR(XF86MiscBadMouseFlags); + case MISC_RET_BADCOMBO: return MISCERR(XF86MiscBadMouseCombo); + case MISC_RET_NOMODULE: return MISCERR(XF86MiscNoModule); + default: + DEBUG_P(("Unexpected return from MiscExtApply(POINTER) = %d\n", ret)); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetMouseSettings - Succeeded\n")); + return (client->noClientException); +} + +static int +ProcXF86MiscSetKbdSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer kbd; + REQUEST(xXF86MiscSetKbdSettingsReq); + + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n", + (int)stuff->kbdtype, (int)stuff->rate, + (int)stuff->delay, stuff->servnumlock)); + + if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0) + return BadAlloc; + + MiscExtSetKbdValue(kbd, MISC_KBD_TYPE, stuff->kbdtype); + MiscExtSetKbdValue(kbd, MISC_KBD_RATE, stuff->rate); + MiscExtSetKbdValue(kbd, MISC_KBD_DELAY, stuff->delay); + MiscExtSetKbdValue(kbd, MISC_KBD_SERVNUMLOCK, stuff->servnumlock); + + switch ((ret = MiscExtApply(kbd, MISC_KEYBOARD))) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADKBDTYPE: return MISCERR(XF86MiscBadKbdType); + default: + DEBUG_P(("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret)); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetKbdSettings - Succeeded\n")); + return (client->noClientException); +} + +static int +ProcXF86MiscSetGrabKeysState(client) + register ClientPtr client; +{ + int n, status; + xXF86MiscSetGrabKeysStateReply rep; + REQUEST(xXF86MiscSetGrabKeysStateReq); + + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + + if ((status = MiscExtSetGrabKeysState(client, stuff->enable)) == 0) { + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetGrabKeysState - %s\n", + stuff->enable ? "enabled" : "disabled")); + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, SIZEOF(xXF86MiscSetGrabKeysStateReply), (char *)&rep); + + return (client->noClientException); +} + +static int +ProcXF86MiscSetClientVersion(ClientPtr client) +{ + REQUEST(xXF86MiscSetClientVersionReq); + + MiscPrivPtr pPriv; + + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + + if ((pPriv = M_GETPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(MiscPrivRec)); + if (!pPriv) + return BadAlloc; + M_SETPRIV(client, pPriv); + } + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetClientVersion: %i %i\n",stuff->major,stuff->minor)); + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXF86MiscGetFilePaths(client) + register ClientPtr client; +{ + xXF86MiscGetFilePathsReply rep; + const char *configfile; + const char *modulepath; + const char *logfile; + register int n; + int configlen, modulelen, loglen; + + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetFilePaths(&configfile, &modulepath, &logfile)) + return BadValue; + + configlen = rep.configlen = (configfile? strlen(configfile): 0); + modulelen = rep.modulelen = (modulepath? strlen(modulepath): 0); + loglen = rep.loglen = (logfile? strlen(logfile): 0); + rep.length = (SIZEOF(xXF86MiscGetFilePathsReply) - SIZEOF(xGenericReply) + + ((rep.configlen + 3) & ~3) + + ((rep.modulelen + 3) & ~3) + + ((rep.loglen + 3) & ~3) ) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.configlen, n); + swaps(&rep.modulelen, n); + swaps(&rep.loglen, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetFilePathsReply), (char *)&rep); + + if (configlen) + WriteToClient(client, configlen, (char *)configfile); + if (modulelen) + WriteToClient(client, modulelen, (char *)modulepath); + if (loglen) + WriteToClient(client, loglen, (char *)logfile); + + return (client->noClientException); +} + +static int +ProcXF86MiscPassMessage(client) + register ClientPtr client; +{ + xXF86MiscPassMessageReply rep; + char *msgtype, *msgval, *retstr; + int retval, size; + register int n; + int mesglen; + + REQUEST(xXF86MiscPassMessageReq); + + REQUEST_AT_LEAST_SIZE(xXF86MiscPassMessageReq); + size = (sizeof(xXF86MiscPassMessageReq) + 3) >> 2; + size+= (stuff->typelen + 3) >> 2; + size+= (stuff->vallen + 3) >> 2; + if (client->req_len < size) + return BadLength; + if (stuff->typelen) { + if (!(msgtype = xalloc(stuff->typelen))) + return BadAlloc; + strncpy(msgtype,(char*)(&stuff[1]),stuff->typelen); + } else return BadValue; + if (stuff->vallen) { + if (!(msgval = xalloc(stuff->vallen))) { + xfree(msgtype); + return BadAlloc; + } + strncpy(msgval,(char*)((char*)&stuff[1] + ((stuff->typelen + 3) & ~3)), + stuff->vallen); + } else { + xfree(msgtype); + return BadValue; + } + + if ((retval = MiscExtPassMessage(stuff->screen,msgtype,msgval,&retstr)) != 0) { + xfree(msgtype); + xfree(msgval); + return retval; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + mesglen = rep.mesglen = (retstr? strlen(retstr): 0); + rep.length = (SIZEOF(xXF86MiscPassMessageReply) - SIZEOF(xGenericReply) + + ((rep.mesglen + 3) & ~3)) >> 2; + rep.status = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.mesglen, n); + } + WriteToClient(client, SIZEOF(xXF86MiscPassMessageReply), (char *)&rep); + + if (mesglen) + WriteToClient(client, mesglen, (char *)retstr); + + xfree(msgtype); + xfree(msgval); + + return (client->noClientException); +} + +static int +ProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return ProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return ProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return ProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return ProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return ProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return ProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return ProcXF86MiscGetFilePaths(client); + case X_XF86MiscPassMessage: + return ProcXF86MiscPassMessage(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return ProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return ProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return ProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + +static int +SProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86MiscQueryVersion(client); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +static int +SProcXF86MiscGetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + swaps(&stuff->screen, n); + return ProcXF86MiscGetSaver(client); +} + +static int +SProcXF86MiscSetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + swaps(&stuff->screen, n); + swapl(&stuff->suspendTime, n); + swapl(&stuff->offTime, n); + return ProcXF86MiscSetSaver(client); +} +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +SProcXF86MiscGetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + return ProcXF86MiscGetMouseSettings(client); +} + +static int +SProcXF86MiscGetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + return ProcXF86MiscGetKbdSettings(client); +} + +static int +SProcXF86MiscSetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetMouseSettingsReq); + swapl(&stuff->mousetype, n); + swapl(&stuff->baudrate, n); + swapl(&stuff->samplerate, n); + swapl(&stuff->resolution, n); + swapl(&stuff->buttons, n); + swapl(&stuff->emulate3timeout, n); + swapl(&stuff->flags, n); + return ProcXF86MiscSetMouseSettings(client); +} + +static int +SProcXF86MiscSetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + swapl(&stuff->kbdtype, n); + swapl(&stuff->rate, n); + swapl(&stuff->delay, n); + return ProcXF86MiscSetKbdSettings(client); +} + +static int +SProcXF86MiscSetGrabKeysState(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->enable, n); + return ProcXF86MiscSetGrabKeysState(client); +} + +static int +SProcXF86MiscSetClientVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86MiscSetClientVersionReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + swaps(&stuff->major, n); + swaps(&stuff->minor, n); + return ProcXF86MiscSetClientVersion(client); +} + +static int +SProcXF86MiscGetFilePaths(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetFilePathsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + return ProcXF86MiscGetFilePaths(client); +} + +static int +SProcXF86MiscPassMessage(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscPassMessageReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscPassMessageReq); + return ProcXF86MiscPassMessage(client); +} + +static int +SProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return SProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return SProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return SProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return SProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return SProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return SProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return SProcXF86MiscGetFilePaths(client); + case X_XF86MiscPassMessage: + return SProcXF86MiscPassMessage(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return SProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return SProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return SProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h b/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h new file mode 100644 index 000000000..93b193ca7 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h @@ -0,0 +1,69 @@ + +/* Prototypes for Pointer/Keyboard functions that the DDX must provide */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _XF86MISCPROC_H_ +#define _XF86MISCPROC_H_ + +typedef enum { + MISC_MSE_PROTO, + MISC_MSE_BAUDRATE, + MISC_MSE_SAMPLERATE, + MISC_MSE_RESOLUTION, + MISC_MSE_BUTTONS, + MISC_MSE_EM3BUTTONS, + MISC_MSE_EM3TIMEOUT, + MISC_MSE_CHORDMIDDLE, + MISC_MSE_FLAGS +} MiscExtMseValType; + +typedef enum { + MISC_KBD_TYPE, + MISC_KBD_RATE, + MISC_KBD_DELAY, + MISC_KBD_SERVNUMLOCK +} MiscExtKbdValType; + +typedef enum { + MISC_RET_SUCCESS, + MISC_RET_BADVAL, + MISC_RET_BADMSEPROTO, + MISC_RET_BADBAUDRATE, + MISC_RET_BADFLAGS, + MISC_RET_BADCOMBO, + MISC_RET_BADKBDTYPE, + MISC_RET_NOMODULE +} MiscExtReturn; + +typedef enum { + MISC_POINTER, + MISC_KEYBOARD +} MiscExtStructType; + +#define MISC_MSEFLAG_CLEARDTR 1 +#define MISC_MSEFLAG_CLEARRTS 2 +#define MISC_MSEFLAG_REOPEN 128 + +void XFree86MiscExtensionInit(void); + +Bool MiscExtGetMouseSettings(pointer *mouse, char **devname); +int MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype); +Bool MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value); +Bool MiscExtGetKbdSettings(pointer *kbd); +int MiscExtGetKbdValue(pointer kbd, MiscExtKbdValType valtype); +Bool MiscExtSetKbdValue(pointer kbd, MiscExtKbdValType valtype, int value); +int MiscExtSetGrabKeysState(ClientPtr client, int enable); +pointer MiscExtCreateStruct(MiscExtStructType mse_or_kbd); +void MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd); +MiscExtReturn MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd); +Bool MiscExtSetMouseDevice(pointer mouse, char* device); +Bool MiscExtGetFilePaths(const char **configfile, const char **modulepath, + const char **logfile); +int MiscExtPassMessage(int scrn, const char *msgtype, const char *msgval, + char **retstr); + +#endif + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c new file mode 100644 index 000000000..718d40fbd --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -0,0 +1,2186 @@ + +/* + +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 + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86VIDMODE_SERVER_ +#include <X11/extensions/xf86vmstr.h> +#include "swaprep.h" +#include "xf86.h" +#include "vidmodeproc.h" + +#define DEFAULT_XF86VIDMODE_VERBOSITY 3 + +static int VidModeErrorBase; +static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey; + +/* 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) + +static void XF86VidModeResetProc( + ExtensionEntry* /* extEntry */ +); + +static DISPATCH_PROC(ProcXF86VidModeDispatch); +static DISPATCH_PROC(ProcXF86VidModeGetAllModeLines); +static DISPATCH_PROC(ProcXF86VidModeGetModeLine); +static DISPATCH_PROC(ProcXF86VidModeGetMonitor); +static DISPATCH_PROC(ProcXF86VidModeLockModeSwitch); +static DISPATCH_PROC(ProcXF86VidModeAddModeLine); +static DISPATCH_PROC(ProcXF86VidModeDeleteModeLine); +static DISPATCH_PROC(ProcXF86VidModeModModeLine); +static DISPATCH_PROC(ProcXF86VidModeValidateModeLine); +static DISPATCH_PROC(ProcXF86VidModeQueryVersion); +static DISPATCH_PROC(ProcXF86VidModeSwitchMode); +static DISPATCH_PROC(ProcXF86VidModeSwitchToMode); +static DISPATCH_PROC(ProcXF86VidModeGetViewPort); +static DISPATCH_PROC(ProcXF86VidModeSetViewPort); +static DISPATCH_PROC(ProcXF86VidModeGetDotClocks); +static DISPATCH_PROC(ProcXF86VidModeSetGamma); +static DISPATCH_PROC(ProcXF86VidModeGetGamma); +static DISPATCH_PROC(ProcXF86VidModeSetClientVersion); +static DISPATCH_PROC(ProcXF86VidModeGetGammaRamp); +static DISPATCH_PROC(ProcXF86VidModeSetGammaRamp); +static DISPATCH_PROC(ProcXF86VidModeGetGammaRampSize); +static DISPATCH_PROC(SProcXF86VidModeDispatch); +static DISPATCH_PROC(SProcXF86VidModeGetAllModeLines); +static DISPATCH_PROC(SProcXF86VidModeGetModeLine); +static DISPATCH_PROC(SProcXF86VidModeGetMonitor); +static DISPATCH_PROC(SProcXF86VidModeLockModeSwitch); +static DISPATCH_PROC(SProcXF86VidModeAddModeLine); +static DISPATCH_PROC(SProcXF86VidModeDeleteModeLine); +static DISPATCH_PROC(SProcXF86VidModeModModeLine); +static DISPATCH_PROC(SProcXF86VidModeValidateModeLine); +static DISPATCH_PROC(SProcXF86VidModeQueryVersion); +static DISPATCH_PROC(SProcXF86VidModeSwitchMode); +static DISPATCH_PROC(SProcXF86VidModeSwitchToMode); +static DISPATCH_PROC(SProcXF86VidModeGetViewPort); +static DISPATCH_PROC(SProcXF86VidModeSetViewPort); +static DISPATCH_PROC(SProcXF86VidModeGetDotClocks); +static DISPATCH_PROC(SProcXF86VidModeSetGamma); +static DISPATCH_PROC(SProcXF86VidModeGetGamma); +static DISPATCH_PROC(SProcXF86VidModeSetClientVersion); +static DISPATCH_PROC(SProcXF86VidModeGetGammaRamp); +static DISPATCH_PROC(SProcXF86VidModeSetGammaRamp); +static DISPATCH_PROC(SProcXF86VidModeGetGammaRampSize); + +#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 */ +); + +extern WindowPtr *WindowTable; + +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 DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey; + +#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) (xalloc (sizeof (t))) +#endif + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF(x"\n"); +#else +# define DEBUG_P(x) /**/ +#endif + +void +XFree86VidModeExtensionInit(void) +{ + ExtensionEntry* extEntry; + ScreenPtr pScreen; + int i; + Bool enabled = FALSE; + + DEBUG_P("XFree86VidModeExtensionInit"); + +#ifdef XF86VIDMODE_EVENTS + EventType = CreateNewResourceType(XF86VidModeFreeEvents); +#endif + + for(i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + if (VidModeExtensionInit(pScreen)) + enabled = TRUE; +#ifdef XF86VIDMODE_EVENTS + SetScreenPrivate (pScreen, NULL); +#endif + } + /* 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, + XF86VidModeResetProc, + StandardMinorOpcode))) { +#if 0 + XF86VidModeReqCode = (unsigned char)extEntry->base; +#endif + VidModeErrorBase = extEntry->errorBase; +#ifdef XF86VIDMODE_EVENTS + XF86VidModeEventBase = extEntry->eventBase; + EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent; +#endif + } +} + +/*ARGSUSED*/ +static void +XF86VidModeResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +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) { + xfree (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; + xfree (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; + xfree (pEv); + CheckScreenPrivate (pScreen); + return TRUE; +} + +static void +SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) +{ + XF86VidModeScreenPrivatePtr pPriv; + XF86VidModeEventPtr pEv; + unsigned long mask; + xXF86VidModeNotifyEvent ev; + ClientPtr client; + 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) + { + client = pEv->client; + if (client->clientGone) + continue; + if (!(pEv->mask & mask)) + continue; + ev.type = XF86VidModeNotify + XF86VidModeEventBase; + ev.state = state; + ev.sequenceNumber = client->sequence; + ev.timestamp = currentTime.milliseconds; + ev.root = WindowTable[pScreen->myNum]->drawable.id; + ev.kind = kind; + ev.forced = forced; + WriteEventsToClient (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; + register int n; + + DEBUG_P("XF86VidModeQueryVersion"); + + REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86VIDMODE_MAJOR_VERSION; + rep.minorVersion = XF86VIDMODE_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86VidModeGetModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeGetModeLineReq); + xXF86VidModeGetModeLineReply rep; + xXF86OldVidModeGetModeLineReply oldrep; + pointer mode; + register int n; + int dotClock; + int ver; + + DEBUG_P("XF86VidModeGetModeline"); + + ver = ClientMajorVersion(client); + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + rep.type = X_Reply; + if (ver < 2) { + rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) - + SIZEOF(xGenericReply)) >> 2; + } else { + rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - + SIZEOF(xGenericReply)) >> 2; + } + rep.sequenceNumber = client->sequence; + + 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, n); + swapl(&rep.length, n); + swapl(&rep.dotclock, n); + swaps(&rep.hdisplay, n); + swaps(&rep.hsyncstart, n); + swaps(&rep.hsyncend, n); + swaps(&rep.htotal, n); + swaps(&rep.hskew, n); + swaps(&rep.vdisplay, n); + swaps(&rep.vsyncstart, n); + swaps(&rep.vsyncend, n); + swaps(&rep.vtotal, n); + swapl(&rep.flags, n); + swapl(&rep.privsize, n); + } + if (ver < 2) { + oldrep.type = rep.type; + oldrep.sequenceNumber = rep.sequenceNumber; + oldrep.length = rep.length; + oldrep.dotclock = rep.dotclock; + oldrep.hdisplay = rep.hdisplay; + oldrep.hsyncstart = rep.hsyncstart; + oldrep.hsyncend = rep.hsyncend; + oldrep.htotal = rep.htotal; + oldrep.vdisplay = rep.vdisplay; + oldrep.vsyncstart = rep.vsyncstart; + oldrep.vsyncend = rep.vsyncend; + oldrep.vtotal = rep.vtotal; + oldrep.flags = rep.flags; + oldrep.privsize = rep.privsize; + WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), + (char *)&oldrep); + } else { + WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), + (char *)&rep); + } + return (client->noClientException); +} + +static int +ProcXF86VidModeGetAllModeLines(ClientPtr client) +{ + REQUEST(xXF86VidModeGetAllModeLinesReq); + xXF86VidModeGetAllModeLinesReply rep; + xXF86VidModeModeInfo mdinf; + xXF86OldVidModeModeInfo oldmdinf; + pointer mode; + int modecount, dotClock; + register int n; + 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.type = X_Reply; + rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) - + SIZEOF(xGenericReply); + if (ver < 2) + rep.length += modecount * sizeof(xXF86OldVidModeModeInfo); + else + rep.length += modecount * sizeof(xXF86VidModeModeInfo); + rep.length >>= 2; + rep.sequenceNumber = client->sequence; + rep.modecount = modecount; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.modecount, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep); + + do { + mdinf.dotclock = dotClock; + mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY); + mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART); + mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND); + mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL); + mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW); + mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY); + mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART); + mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND); + mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL); + mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS); + mdinf.privsize = 0; + if (client->swapped) { + swapl(&mdinf.dotclock, n); + swaps(&mdinf.hdisplay, n); + swaps(&mdinf.hsyncstart, n); + swaps(&mdinf.hsyncend, n); + swaps(&mdinf.htotal, n); + swaps(&mdinf.hskew, n); + swaps(&mdinf.vdisplay, n); + swaps(&mdinf.vsyncstart, n); + swaps(&mdinf.vsyncend, n); + swaps(&mdinf.vtotal, n); + swapl(&mdinf.flags, n); + swapl(&mdinf.privsize, n); + } + if (ver < 2) { + oldmdinf.dotclock = mdinf.dotclock; + oldmdinf.hdisplay = mdinf.hdisplay; + oldmdinf.hsyncstart = mdinf.hsyncstart; + oldmdinf.hsyncend = mdinf.hsyncend; + oldmdinf.htotal = mdinf.htotal; + oldmdinf.vdisplay = mdinf.vdisplay; + oldmdinf.vsyncstart = mdinf.vsyncstart; + oldmdinf.vsyncend = mdinf.vsyncend; + oldmdinf.vtotal = mdinf.vtotal; + oldmdinf.flags = mdinf.flags; + oldmdinf.privsize = mdinf.privsize; + WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), + (char *)&oldmdinf); + } else { + WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf); + } + + } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); + + return (client->noClientException); +} + +#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 - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2); + } + 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: + xfree(mode); + return VidModeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + case MODE_V_ILLEGAL: + xfree(mode); + return VidModeErrorBase + XF86VidModeBadVTimings; + default: + xfree(mode); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + /* Check that the driver is happy with the mode */ + if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) { + xfree(mode); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + VidModeSetCrtcForMode(stuff->screen, mode); + + VidModeAddModeline(stuff->screen, mode); + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("AddModeLine - Succeeded\n"); + return client->noClientException; +} + +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 - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2); + } + 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(client->noClientException); + } + } 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 - (sizeof(xXF86OldVidModeModModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2); + } + 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: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + case MODE_V_ILLEGAL: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeBadVTimings; + default: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + /* Check that the driver is happy with the mode */ + if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) { + xfree(modetmp); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + xfree(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(client->noClientException); +} + +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 - + (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2); + } + 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: + if(modetmp) + xfree(modetmp); + + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply) + - SIZEOF(xGenericReply)) >> 2; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep); + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status); + return(client->noClientException); +} + +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 (client->noClientException); +} + +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 - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq); + len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2); + } + 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 (client->noClientException); + + 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(client->noClientException); + } + } 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 (client->noClientException); +} + +static int +ProcXF86VidModeGetMonitor(ClientPtr client) +{ + REQUEST(xXF86VidModeGetMonitorReq); + xXF86VidModeGetMonitorReply rep; + register int n; + 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; + + rep.type = X_Reply; + 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 = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) + + (nHsync + nVrefresh) * sizeof(CARD32) + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)) >> 2; + rep.sequenceNumber = client->sequence; + rep.nhsync = nHsync; + rep.nvsync = nVrefresh; + hsyncdata = xalloc(nHsync * sizeof(CARD32)); + if (!hsyncdata) { + return BadAlloc; + } + + vsyncdata = xalloc(nVrefresh * sizeof(CARD32)); + if (!vsyncdata) { + xfree(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, n); + swapl(&rep.length, n); + } + WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep); + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; + WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), + hsyncdata); + WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), + vsyncdata); + if (rep.vendorLength) + WriteToClient(client, rep.vendorLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr); + if (rep.modelLength) + WriteToClient(client, rep.modelLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr); + + xfree(hsyncdata); + xfree(vsyncdata); + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetViewPort(ClientPtr client) +{ + REQUEST(xXF86VidModeGetViewPortReq); + xXF86VidModeGetViewPortReply rep; + int x, y, n; + + DEBUG_P("XF86VidModeGetViewPort"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + VidModeGetViewPort(stuff->screen, &x, &y); + rep.x = x; + rep.y = y; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.x, n); + swapl(&rep.y, n); + } + WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *)&rep); + return (client->noClientException); +} + +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 (client->noClientException); +} + +static int +ProcXF86VidModeGetDotClocks(ClientPtr client) +{ + REQUEST(xXF86VidModeGetDotClocksReq); + xXF86VidModeGetDotClocksReply rep; + register 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.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply) + - SIZEOF(xGenericReply) + numClocks) >> 2; + rep.sequenceNumber = client->sequence; + rep.clocks = numClocks; + rep.maxclocks = MAXCLOCKS; + rep.flags = 0; + + if (!ClockProg) { + Clocks = xalloc(numClocks * sizeof(int)); + if (!Clocks) + return BadValue; + if (!VidModeGetClocks(stuff->screen, Clocks)) { + xfree(Clocks); + return BadValue; + } + } + + if (ClockProg) { + rep.flags |= CLKFLAG_PROGRAMABLE; + } + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.clocks, n); + swapl(&rep.maxclocks, n); + swapl(&rep.flags, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *)&rep); + if (!ClockProg) { + for (n = 0; n < numClocks; n++) { + dotclock = *Clocks++; + if (client->swapped) { + WriteSwappedDataToClient(client, 4, (char *)&dotclock); + } else { + WriteToClient(client, 4, (char *)&dotclock); + } + } + } + + xfree(Clocks); + return (client->noClientException); +} + +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 (client->noClientException); +} + +static int +ProcXF86VidModeGetGamma(ClientPtr client) +{ + REQUEST(xXF86VidModeGetGammaReq); + xXF86VidModeGetGammaReply rep; + register int n; + float red, green, blue; + + DEBUG_P("XF86VidModeGetGamma"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (!VidModeGetGamma(stuff->screen, &red, &green, &blue)) + return BadValue; + rep.red = (CARD32)(red * 10000.); + rep.green = (CARD32)(green * 10000.); + rep.blue = (CARD32)(blue * 10000.); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.red, n); + swapl(&rep.green, n); + swapl(&rep.blue, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *)&rep); + return (client->noClientException); +} + +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 (client->noClientException); +} + +static int +ProcXF86VidModeGetGammaRamp(ClientPtr client) +{ + CARD16 *ramp = NULL; + int n, length, i; + xXF86VidModeGetGammaRampReply rep; + REQUEST(xXF86VidModeGetGammaRampReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if(stuff->size != VidModeGetGammaRampSize(stuff->screen)) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); + + length = (stuff->size + 1) & ~1; + + if(stuff->size) { + if(!(ramp = xalloc(length * 3 * sizeof(CARD16)))) + return BadAlloc; + + if (!VidModeGetGammaRamp(stuff->screen, stuff->size, + ramp, ramp + length, ramp + (length * 2))) { + xfree(ramp); + return BadValue; + } + } + + rep.type = X_Reply; + rep.length = (length >> 1) * 3; + rep.sequenceNumber = client->sequence; + rep.size = stuff->size; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.size, n); + for(i = 0; i < length * 3; i++) + swaps(&ramp[i],n); + } + WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep); + + if(stuff->size) { + WriteToClient(client, rep.length << 2, (char*)ramp); + xfree(ramp); + } + + return (client->noClientException); +} + + +static int +ProcXF86VidModeGetGammaRampSize(ClientPtr client) +{ + xXF86VidModeGetGammaRampSizeReply rep; + int n; + REQUEST(xXF86VidModeGetGammaRampSizeReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.size = VidModeGetGammaRampSize(stuff->screen); + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.size, n); + } + WriteToClient(client,sizeof(xXF86VidModeGetGammaRampSizeReply),(char*)&rep); + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetPermissions(ClientPtr client) +{ + xXF86VidModeGetPermissionsReply rep; + int n; + REQUEST(xXF86VidModeGetPermissionsReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.permissions = XF86VM_READ_PERMISSION; + if (xf86GetVidModeEnabled() && + (xf86GetVidModeAllowNonLocal() || LocalClient (client))) { + rep.permissions |= XF86VM_WRITE_PERMISSION; + } + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.permissions, n); + } + WriteToClient(client,sizeof(xXF86VidModeGetPermissionsReply),(char*)&rep); + + return (client->noClientException); +} + + +static int +ProcXF86VidModeSetClientVersion(ClientPtr client) +{ + REQUEST(xXF86VidModeSetClientVersionReq); + + VidModePrivPtr pPriv; + + DEBUG_P("XF86VidModeSetClientVersion"); + + REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); + + if ((pPriv = VM_GETPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(VidModePrivRec)); + if (!pPriv) + return BadAlloc; + VM_SETPRIV(client, pPriv); + } + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +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) +{ + register int n; + REQUEST(xXF86VidModeQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86VidModeQueryVersion(client); +} + +static int +SProcXF86VidModeGetModeLine(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetModeLineReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetModeLine(client); +} + +static int +SProcXF86VidModeGetAllModeLines(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetAllModeLines(client); +} + +static int +SProcXF86VidModeAddModeLine(ClientPtr client) +{ + xXF86OldVidModeAddModeLineReq *oldstuff = + (xXF86OldVidModeAddModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeAddModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeAddModeLine(client); +} + +static int +SProcXF86VidModeDeleteModeLine(ClientPtr client) +{ + xXF86OldVidModeDeleteModeLineReq *oldstuff = + (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeDeleteModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeDeleteModeLine(client); +} + +static int +SProcXF86VidModeModModeLine(ClientPtr client) +{ + xXF86OldVidModeModModeLineReq *oldstuff = + (xXF86OldVidModeModModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeModModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeModModeLine(client); +} + +static int +SProcXF86VidModeValidateModeLine(ClientPtr client) +{ + xXF86OldVidModeValidateModeLineReq *oldstuff = + (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeValidateModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeValidateModeLine(client); +} + +static int +SProcXF86VidModeSwitchMode(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSwitchModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); + swaps(&stuff->screen, n); + swaps(&stuff->zoom, n); + return ProcXF86VidModeSwitchMode(client); +} + +static int +SProcXF86VidModeSwitchToMode(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSwitchToModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeSwitchToMode(client); +} + +static int +SProcXF86VidModeLockModeSwitch(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->screen, n); + swaps(&stuff->lock, n); + return ProcXF86VidModeLockModeSwitch(client); +} + +static int +SProcXF86VidModeGetMonitor(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetMonitorReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetMonitor(client); +} + +static int +SProcXF86VidModeGetViewPort(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetViewPort(client); +} + +static int +SProcXF86VidModeSetViewPort(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); + swaps(&stuff->screen, n); + swapl(&stuff->x, n); + swapl(&stuff->y, n); + return ProcXF86VidModeSetViewPort(client); +} + +static int +SProcXF86VidModeGetDotClocks(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetDotClocksReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetDotClocks(client); +} + +static int +SProcXF86VidModeSetClientVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetClientVersionReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); + swaps(&stuff->major, n); + swaps(&stuff->minor, n); + return ProcXF86VidModeSetClientVersion(client); +} + +static int +SProcXF86VidModeSetGamma(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetGammaReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq); + swaps(&stuff->screen, n); + swapl(&stuff->red, n); + swapl(&stuff->green, n); + swapl(&stuff->blue, n); + return ProcXF86VidModeSetGamma(client); +} + +static int +SProcXF86VidModeGetGamma(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetGammaReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGamma(client); +} + +static int +SProcXF86VidModeSetGammaRamp(ClientPtr client) +{ + CARD16 *ramp; + int length, n; + REQUEST(xXF86VidModeSetGammaRampReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq); + swaps(&stuff->size, n); + swaps(&stuff->screen, n); + length = ((stuff->size + 1) & ~1) * 6; + REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length); + ramp = (CARD16*)&stuff[1]; + while(length--) { + swaps(ramp, n); + ramp++; + } + return ProcXF86VidModeSetGammaRamp(client); +} + +static int +SProcXF86VidModeGetGammaRamp(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetGammaRampReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); + swaps(&stuff->size, n); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGammaRamp(client); +} + +static int +SProcXF86VidModeGetGammaRampSize(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetGammaRampSizeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGammaRampSize(client); +} + +static int +SProcXF86VidModeGetPermissions(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetPermissionsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq); + swaps(&stuff->screen, n); + 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; + } +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c b/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c new file mode 100644 index 000000000..6b3f1149a --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c @@ -0,0 +1,23 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "misc.h" +#include "scrnintstr.h" +#include "gc.h" +#include <X11/extensions/Xv.h> +#include <X11/extensions/Xvproto.h> +#include "xvdix.h" +#include "xvmodproc.h" + +void +XvRegister() +{ + XvScreenInitProc = XvScreenInit; + XvGetScreenKeyProc = XvGetScreenKey; + XvGetRTPortProc = XvGetRTPort; + XvMCScreenInitProc = XvMCScreenInit; +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h b/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h new file mode 100644 index 000000000..b39c915b4 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h @@ -0,0 +1,13 @@ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "xvmcext.h" + +extern DevPrivateKey (*XvGetScreenKeyProc)(void); +extern unsigned long (*XvGetRTPortProc)(void); +extern int (*XvScreenInitProc)(ScreenPtr); +extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); + +extern void XvRegister(void); |