pax_global_header00006660000000000000000000000064110327543600014513gustar00rootroot0000000000000052 comment=2cba02334e948e215ab32635763e739c8c4a2f56 libXxf86vm-1.0.2/000075500000000000000000000000001103275436000134665ustar00rootroot00000000000000libXxf86vm-1.0.2/.gitignore000064400000000000000000000002731103275436000154600ustar00rootroot00000000000000aclocal.m4 autom4te.cache compile config.guess config.log config.status config.sub configure depcomp install-sh libtool ltmain.sh Makefile Makefile.in missing mkinstalldirs xxf86vm.pc *~ libXxf86vm-1.0.2/COPYING000064400000000000000000000024251103275436000145240ustar00rootroot00000000000000Copyright (c) 1995 Kaleb S. Keithley All Rights Reserved. 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, sublicence, 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. libXxf86vm-1.0.2/Makefile.am000064400000000000000000000006631103275436000155270ustar00rootroot00000000000000SUBDIRS = src man pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = xxf86vm.pc EXTRA_DIST = xxf86vm.pc.in autogen.sh EXTRA_DIST += ChangeLog MAINTAINERCLEANFILES = ChangeLog .PHONY: ChangeLog ChangeLog: (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) dist-hook: ChangeLog libXxf86vm-1.0.2/autogen.sh000075500000000000000000000003041103275436000154640ustar00rootroot00000000000000#! /bin/sh srcdir=`dirname $0` test -z "$srcdir" && srcdir=. ORIGDIR=`pwd` cd $srcdir autoreconf -v --install || exit 1 cd $ORIGDIR || exit $? $srcdir/configure --enable-maintainer-mode "$@" libXxf86vm-1.0.2/configure.ac000064400000000000000000000007611103275436000157600ustar00rootroot00000000000000AC_PREREQ([2.57]) AC_INIT(libXxf86vm, 1.0.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], libXxf86vm) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE AM_CONFIG_HEADER(src/config.h) # Check for progs AC_PROG_CC AC_PROG_LIBTOOL # Checks for pkg-config packages PKG_CHECK_MODULES(XXF86VM, xproto x11 xextproto xext xf86vidmodeproto) XORG_CHECK_MALLOC_ZERO XORG_MANPAGE_SECTIONS XORG_RELEASE_VERSION AC_OUTPUT([Makefile src/Makefile man/Makefile xxf86vm.pc]) libXxf86vm-1.0.2/man/000075500000000000000000000000001103275436000142415ustar00rootroot00000000000000libXxf86vm-1.0.2/man/.gitignore000064400000000000000000000000321103275436000162240ustar00rootroot00000000000000Makefile Makefile.in *.3* libXxf86vm-1.0.2/man/Makefile.am000064400000000000000000000063301103275436000162770ustar00rootroot00000000000000# # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # # 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. # # 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 THE OPEN GROUP 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 the copyright holders shall # not be used in advertising or otherwise to promote the sale, use or # other dealings in this Software without prior written authorization # from the copyright holders. # libmandir = $(LIB_MAN_DIR) LIB_MAN_DIR_SUFFIX = $(LIB_MAN_DIR:@mandir@/man%=%) libman_PRE = XF86VM.man BUILT_SOURCES = shadows.DONE EXTRA_DIST = $(libman_PRE) CLEANFILES = $(libman_DATA) $(BUILT_SOURCES) libman_DATA = $(libman_PRE:man=@LIB_MAN_SUFFIX@) \ $(XF86VM_shadows:=.@LIB_MAN_SUFFIX@) SED = sed # Strings to replace in man pages XORGRELSTRING = @PACKAGE_STRING@ XORGMANNAME = X Version 11 MAN_SUBSTS = \ -e 's/__vendorversion__/"$(XORGRELSTRING)" "$(XORGMANNAME)"/' \ -e 's/__xservername__/Xorg/g' \ -e 's/__xconfigfile__/xorg.conf/g' \ -e 's/__appmansuffix__/$(APP_MAN_SUFFIX)/g' \ -e 's/__libmansuffix__/$(LIB_MAN_SUFFIX)/g' \ -e 's/__filemansuffix__/$(FILE_MAN_SUFFIX)/g' SUFFIXES = .$(LIB_MAN_SUFFIX) .man .man.$(LIB_MAN_SUFFIX): sed $(MAN_SUBSTS) < $< > $@ # Generate man page shadow files (Replaces InstallManPageAliases from Imake) XF86VM_shadows = \ XF86VidModeQueryExtension \ XF86VidModeQueryVersion \ XF86VidModeGetModeLine \ XF86VidModeGetAllModeLines \ XF86VidModeDeleteModeLine \ XF86VidModeModModeLine \ XF86VidModeSwitchMode \ XF86VidModeSwitchToMode \ XF86VidModeLockModeSwitch \ XF86VidModeGetMonitor \ XF86VidModeGetViewPort \ XF86VidModeSetViewPort \ XF86VidModeValidateModeLine \ XF86VidModeSetClientVersion \ XF86VidModeGetDotClocks \ XF86VidModeGetGamma \ XF86VidModeSetGamma \ XF86VidModeSetGammaRamp \ XF86VidModeGetGammaRamp \ XF86VidModeGetGammaRampSize \ XF86VidModeGetPermissions shadows.DONE: -rm -f $(XF86VM_shadows:=.@LIB_MAN_SUFFIX@) (for i in $(XF86VM_shadows:=.@LIB_MAN_SUFFIX@) ; do \ echo .so man$(LIB_MAN_DIR_SUFFIX)/XF86VM.$(LIB_MAN_SUFFIX) > $$i; \ done) libXxf86vm-1.0.2/man/XF86VM.man000064400000000000000000000325511103275436000157020ustar00rootroot00000000000000.\" $XdotOrg: lib/Xxf86vm/man/XF86VM.man,v 1.2 2004/04/23 19:23:08 eich Exp $ .\" $TOG: XF86VM.man /main/6 1997/07/19 10:30:39 kaleb $ .\" .\" .\" .\" .\" Copyright (c) 1996 Joe Moss, The XFree86 Project .\" $XFree86: xc/programs/Xserver/hw/xfree86/doc/man/XF86VM.man,v 3.14 2003/10/02 13:29:56 eich Exp $ .\" .de ZN .ie t \fB\^\\$1\^\fR\\$2 .el \fI\^\\$1\^\fP\\$2 .. .TH XF86VIDMODE __libmansuffix__ __vendorversion__ .SH NAME XF86VidModeQueryExtension, XF86VidModeQueryVersion, XF86VidModeSetClientVersion, XF86VidModeGetModeLine, XF86VidModeGetAllModeLines, XF86VidModeDeleteModeLine, XF86VidModeModModeLine, XF86VidModeValidateModeLine, XF86VidModeSwitchMode, XF86VidModeSwitchToMode, XF86VidModeLockModeSwitch, XF86VidModeGetMonitor, XF86VidModeGetViewPort, XF86VidModeSetViewPort, XF86VidModeGetDotClocks, XF86VidModeGetGamma, XF86VidModeSetGamma, XF86VidModeGetGammaRamp, XF86VidModeSetGammaRamp, XF86VidModeGetGammaRampSize, XF86VidModeGetPermissions \- Extension library for the XFree86-VidMode X extension .SH SYNTAX .nf .LP \&#include .LP Bool XF86VidModeQueryExtension( Display *\fIdisplay\fP\^, int *\fIevent_base_return\fP\^, int *\fIerror_base_return\fP\^); .LP Bool XF86VidModeQueryVersion( Display *\fIdisplay\fP\^, int *\fImajor_version_return\fP\^, int *\fIminor_version_return\fP\^); .LP Bool XF86VidModeSetClientVersion( Display *\fIdisplay\fP\^); .LP Bool XF86VidModeGetModeLine( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int *\fIdotclock_return\fP\^, XF86VidModeModeLine *\fImodeline\fP\^); .LP Bool XF86VidModeGetAllModeLines( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int *\fImodecount_return\fP\^, XF86VidModeModeInfo ***\fImodesinfo\fP\^); .ig .LP Bool XF86VidModeAddModeLine( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeModeInfo *\fImodeline\fP\, XF86VidModeModeInfo *\fIaftermode\fP\^); .. .LP Bool XF86VidModeDeleteModeLine( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeModeInfo *\fImodeline\fP\^); .LP Bool XF86VidModeModModeLine( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeModeLine *\fImodeline\fP\^); .LP Status XF86VidModeValidateModeLine( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeModeLine *\fImodeline\fP\^); .LP Bool XF86VidModeSwitchMode( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int \fIzoom\fP\^); .LP Bool XF86VidModeSwitchToMode( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeModeInfo *\fImodeline\fP\^); .LP Bool XF86VidModeLockModeSwitch( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int \fIlock\fP\^); .LP Bool XF86VidModeGetMonitor( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeMonitor *\fImonitor\fP\^); .LP Bool XF86VidModeGetViewPort( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int *\fIx_return\fP\^, int *\fIy_return\fP\^); .LP Bool XF86VidModeSetViewPort( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int \fIx\fP\^, int \fIy\fP\^); .LP XF86VidModeGetDotClocks( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int *\fIflags return\fP\^, int *\fInumber of clocks return\fP\^, int *\fImax dot clock return\fP\^, int **\fIclocks return\fP\^); .LP XF86VidModeGetGamma( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeGamma *\fIGamma\fP\^); .LP XF86VidModeSetGamma( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, XF86VidModeGamma *\fIGamma\fP\^); .LP XF86VidModeGetGammaRamp( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int \fIsize\fP\^, unsigned short *\fIred array\fP\^, unsigned short *\fIgreen array\fP\^, unsigned short *\fIblue array\fP\^); .LP XF86VidModeSetGammaRamp( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int \fIsize\fP\^, unsigned short *\fIred array\fP\^, unsigned short *\fIgreen array\fP\^, unsigned short *\fIblue array\fP\^); .LP XF86VidModeGetGammaRampSize( Display *\fIdisplay\fP\^, int \fIscreen\fP\^, int *\fIsize\fP\^); .fi .SH ARGUMENTS .IP \fIdisplay\fP 2i Specifies the connection to the X server. .IP \fIscreen\fP 2i Specifies which screen number the setting apply to. .IP \fIevent_base_return\fP 2i Returns the base event number for the extension. .IP \fIerror_base_return\fP 2i Returns the base error number for the extension. .IP \fImajor_version_return\fP 2i Returns the major version number of the extension. .IP \fIminor_version_return\fP 2i Returns the minor version number of the extension. .IP \fIdotclock_return\fP 2i Returns the clock for the mode line. .IP \fImodecount_return\fP 2i Returns the number of video modes available in the server. .IP \fIzoom\fP 2i If greater than zero, indicates that the server should switch to the next mode, otherwise switch to the previous mode. .IP \fIlock\fP 2i Indicates that mode switching should be locked, if non-zero. .IP \fImodeline\fP 2i Specifies or returns the timing values for a video mode. .ig .IP \fIaftermode\fP 2i Specifies the timing values for the video mode after which the new mode will added. .. .IP \fImodesinfo\fP 2i Returns the timing values and dotclocks for all of the available video modes. .IP \fImonitor\fP 2i Returns information about the monitor. .IP \fIx\fP 2i Specifies the desired X location for the viewport. .IP \fIx_return\fP 2i Returns the current X location of the viewport. .IP \fIy\fP 2i Specifies the desired Y location for the viewport. .IP \fIy_return\fP 2i Returns the current Y location of the viewport. .SH STRUCTURES .nf .ta 2.25i 3.5i \fIVideo Mode Settings:\fP typedef struct { unsigned short hdisplay; /\(** Number of display pixels horizontally */ unsigned short hsyncstart; /\(** Horizontal sync start */ unsigned short hsyncend; /\(** Horizontal sync end */ unsigned short htotal; /\(** Total horizontal pixels */ unsigned short vdisplay; /\(** Number of display pixels vertically */ unsigned short vsyncstart; /\(** Vertical sync start */ unsigned short vsyncend; /\(** Vertical sync start */ unsigned short vtotal; /\(** Total vertical pixels */ unsigned int flags; /\(** Mode flags */ int privsize; /\(** Size of private */ INT32 *private; /\(** Server privates */ } XF86VidModeModeLine; .sp typedef struct { unsigned int dotclock; /\(** Pixel clock */ unsigned short hdisplay; /\(** Number of display pixels horizontally */ unsigned short hsyncstart; /\(** Horizontal sync start */ unsigned short hsyncend; /\(** Horizontal sync end */ unsigned short htotal; /\(** Total horizontal pixels */ unsigned short vdisplay; /\(** Number of display pixels vertically */ unsigned short vsyncstart; /\(** Vertical sync start */ unsigned short vsyncend; /\(** Vertical sync start */ unsigned short vtotal; /\(** Total vertical pixels */ unsigned int flags; /\(** Mode flags */ int privsize; /\(** Size of private */ INT32 *private; /\(** Server privates */ } XF86VidModeModeInfo; .LP \fIMonitor information:\fP typedef struct { char* vendor; /\(** Name of manufacturer */ char* model; /\(** Model name */ float EMPTY; /\(** unused, for backward compatibility */ unsigned char nhsync; /\(** Number of horiz sync ranges */ XF86VidModeSyncRange* hsync; /\(** Horizontal sync ranges */ unsigned char nvsync; /\(** Number of vert sync ranges */ XF86VidModeSyncRange* vsync; /\(** Vertical sync ranges */ } XF86VidModeMonitor; .sp typedef struct { float hi; /\(** Top of range */ float lo; /\(** Bottom of range */ } XF86VidModeSyncRange; .LP typedef struct { int type; /\(** of event */ unsigned long serial; /\(** # of last request processed by server */ Bool send_event; /\(** true if this came from a SendEvent req */ Display *display; /\(** Display the event was read from */ Window root; /\(** root window of event screen */ int state; /\(** What happened */ int kind; /\(** What happened */ Bool forced; /\(** extents of new region */ Time time; /\(** event timestamp */ } XF86VidModeNotifyEvent; .LP typedef struct { float red; /\(** Red Gamma value */ float green; /\(** Green Gamma value */ float blue; /\(** Blue Gamma value */ } XF86VidModeGamma; .fi .SH DESCRIPTION These functions provide an interface to the server extension \fIXFree86-VidModeExtension\fP which allows the video modes to be queried and adjusted dynamically and mode switching to be controlled. Applications that use these functions must be linked with .ZN -lXxf86vm .SS "MODELINE FUNCTIONS" The .ZN XF86VidModeGetModeLine function is used to query the settings for the currently selected video mode. The calling program should pass a pointer to a .ZN XF86VidModeModeLine structure that it has already allocated. The function fills in the fields of the structure. .PP If there are any server private values (currently only applicable to the S3 server) the function will allocate storage for them. Therefore, if the .ZN privsize field is non-zero, the calling program should call .ZN Xfree(private) to free the storage. .PP .ZN XF86VidModeGetAllModeLines returns the settings for all video modes. The calling program supplies the address of a pointer which will be set by the function to point to an array of .ZN XF86VidModeModeInfo structures. The memory occupied by the array is dynamically allocated by the .ZN XF86VidModeGetAllModeLines function and should be freed by the caller. The first element of the array corresponds to the current video mode. .PP The .ZN XF86VidModeModModeLine function can be used to change the settings of the current video mode provided the requested settings are valid (e.g. they don't exceed the capabilities of the monitor). .PP .ig To add a mode to the list of available modes, the .ZN XF86VidModeAddModeLine function can be used. Assuming the settings are valid, the video mode will be added after the existing mode which matches the timings specified by the .ZN aftermode parameter. To be considered a match, all of the fields of the given .ZN XF86VidModeModeInfo structure must match, except the .ZN privsize and .ZN private fields. If the .ZN aftermode parameter is zero, the mode will be added after the current mode. .PP .. Modes can be deleted with the .ZN XF86VidModeDeleteModeLine function. The specified mode must match an existing mode. To be considered a match, all of the fields of the given .ZN XF86VidModeModeInfo structure must match, except the .ZN privsize and .ZN private fields. If the mode to be deleted is the current mode, a mode switch to the next mode will occur first. The last remaining mode can not be deleted. .PP The validity of a mode can be checked with the .ZN XF86VidModeValidateModeLine function. If the specified mode can be used by the server (i.e. meets all the constraints placed upon a mode by the combination of the server, card, and monitor) the function returns .ZN MODE_OK , otherwise it returns a value indicating the reason why the mode is invalid (as defined in \fIxf86.h\fP) .SS "MODE SWITCH FUNCTIONS" When the function .ZN XF86VidModeSwitchMode is called, the server will change the video mode to next (or previous) video mode. The .ZN XF86VidModeSwitchToMode function can be used to switch directly to the specified mode. Matching is as specified in the description of the .ZN XF86VidModeAddModeLine function above. The .ZN XF86VidModeLockModeSwitch function can be used to allow or disallow mode switching whether the request to switch modes comes from a call to the .ZN XF86VidModeSwitchMode or .ZN XF86VidModeSwitchToMode functions or from one of the mode switch key sequences. .PP .RB Note: Because of the asynchronous nature of the X protocol, a call to .ZN XFlush is needed if the application wants to see the mode change immediately. To be informed of the execution status of the request, a custom error handler should be installed using .ZN XSetErrorHandler before calling the mode switching function. .SS "MONITOR FUNCTIONS" Information known to the server about the monitor is returned by the .ZN XF86VidModeGetMonitor function. The .ZN hsync and .ZN vsync fields each point to an array of .ZN XF86VidModeSyncRange structures. The arrays contain .ZN nhsync and .ZN nvsync elements, respectively. The .ZN hi and .ZN low values will be equal if a discreate value was given in the .ZN XF86Config file. .PP The .ZN vendor , .ZN model , .ZN hsync , and .ZN vsync fields point to dynamically allocated storage that should be freed by the caller. .SS "VIEWPORT FUNCTIONS" The .ZN XF86VidModeGetViewPort and .ZN XF86VidModeSetViewPort functions can be used to, respectively, query and change the location of the upper left corner of the viewport into the virtual screen. .SS "OTHER FUNCTIONS" The .ZN XF86VidModeQueryVersion function can be used to determine the version of the extension built into the server. .PP The function .ZN XF86VidModeQueryExtension returns the lowest numbered error and event values assigned to the extension. .SH BUGS The XF86VidModeSetClientVersion, XF86VidModeGetDotClocks, XF86VidModeGetGamma, XF86VidModeSetGamma, XF86VidModeSetGammaRamp, XF86VidModeGetGammaRamp, XF86VidModeGetGammaRampSize, and XF86VidModeGetPermissions functions need to be documented. In the meantime, check the source code for information about how to use them. .SH SEE ALSO __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), XFlush(__libmansuffix__), XSetErrorHandler(__libmansuffix__), xvidtune(__appmansuffix__) .SH AUTHORS Kaleb Keithley, Jon Tombs, David Dawes, and Joe Moss libXxf86vm-1.0.2/src/000075500000000000000000000000001103275436000142555ustar00rootroot00000000000000libXxf86vm-1.0.2/src/.gitignore000064400000000000000000000001221103275436000162400ustar00rootroot00000000000000config.h config.h.in .deps .libs libXxf86vm.la *.lo Makefile Makefile.in stamp-h1 libXxf86vm-1.0.2/src/Makefile.am000064400000000000000000000003171103275436000163120ustar00rootroot00000000000000lib_LTLIBRARIES = libXxf86vm.la libXxf86vm_la_SOURCES = XF86VMode.c AM_CFLAGS = $(XXF86VM_CFLAGS) $(MALLOC_ZERO_CFLAGS) libXxf86vm_la_LIBADD = $(XXF86VM_LIBS) libXxf86vm_la_LDFLAGS = -version-number 1:0:0 libXxf86vm-1.0.2/src/XF86VMode.c000064400000000000000000001107761103275436000160630ustar00rootroot00000000000000/* Copyright (c) 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 */ #define NEED_EVENTS #define NEED_REPLIES #include #include #include #include #ifdef DEBUG #include #endif #ifndef MODE_BAD #define MODE_BAD 255 #endif static XExtensionInfo _xf86vidmode_info_data; static XExtensionInfo *xf86vidmode_info = &_xf86vidmode_info_data; static char *xf86vidmode_extension_name = XF86VIDMODENAME; #define XF86VidModeCheckExtension(dpy,i,val) \ XextCheckExtension (dpy, i, xf86vidmode_extension_name, val) /***************************************************************************** * * * private utility routines * * * *****************************************************************************/ static XEXT_CLOSE_DISPLAY_PROTO(close_display); static /* const */ XExtensionHooks xf86vidmode_extension_hooks = { NULL, /* create_gc */ NULL, /* copy_gc */ NULL, /* flush_gc */ NULL, /* free_gc */ NULL, /* create_font */ NULL, /* free_font */ close_display, /* close_display */ NULL, /* wire_to_event */ NULL, /* event_to_wire */ NULL, /* error */ NULL, /* error_string */ }; static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86vidmode_info, xf86vidmode_extension_name, &xf86vidmode_extension_hooks, 0, NULL) static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86vidmode_info) /***************************************************************************** * * * public XFree86-VidMode Extension routines * * * *****************************************************************************/ Bool XF86VidModeQueryExtension (dpy, event_basep, error_basep) Display *dpy; int *event_basep, *error_basep; { XExtDisplayInfo *info = find_display (dpy); if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; return True; } else { return False; } } Bool XF86VidModeQueryVersion(dpy, majorVersion, minorVersion) Display* dpy; int* majorVersion; int* minorVersion; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeQueryVersionReply rep; xXF86VidModeQueryVersionReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeQueryVersion, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *majorVersion = rep.majorVersion; *minorVersion = rep.minorVersion; UnlockDisplay(dpy); SyncHandle(); if (*majorVersion >= 2) XF86VidModeSetClientVersion(dpy); return True; } Bool XF86VidModeSetClientVersion(Display *dpy) { XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetClientVersionReq *req; XF86VidModeCheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeSetClientVersion, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetClientVersion; req->major = XF86VIDMODE_MAJOR_VERSION; req->minor = XF86VIDMODE_MINOR_VERSION; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeSetGamma(Display *dpy, int screen, XF86VidModeGamma *Gamma) { XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetGammaReq *req; XF86VidModeCheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeSetGamma, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetGamma; req->screen = screen; req->red = (CARD32)(Gamma->red * 10000.); req->green = (CARD32)(Gamma->green * 10000.); req->blue = (CARD32)(Gamma->blue * 10000.); UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetGamma(Display *dpy, int screen, XF86VidModeGamma *Gamma) { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetGammaReply rep; xXF86VidModeGetGammaReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetGamma, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGamma; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } Gamma->red = ((float)rep.red) / 10000.; Gamma->green = ((float)rep.green) / 10000.; Gamma->blue = ((float)rep.blue) / 10000.; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetModeLine(dpy, screen, dotclock, modeline) Display* dpy; int screen; int* dotclock; XF86VidModeModeLine* modeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetModeLineReply rep; xXF86OldVidModeGetModeLineReply oldrep; xXF86VidModeGetModeLineReq *req; int majorVersion, minorVersion; XF86VidModeCheckExtension (dpy, info, False); XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); LockDisplay(dpy); GetReq(XF86VidModeGetModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; req->screen = screen; if (majorVersion < 2) { if (!_XReply(dpy, (xReply *)&oldrep, (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *dotclock = oldrep.dotclock; modeline->hdisplay = oldrep.hdisplay; modeline->hsyncstart = oldrep.hsyncstart; modeline->hsyncend = oldrep.hsyncend; modeline->htotal = oldrep.htotal; modeline->hskew = 0; modeline->vdisplay = oldrep.vdisplay; modeline->vsyncstart = oldrep.vsyncstart; modeline->vsyncend = oldrep.vsyncend; modeline->vtotal = oldrep.vtotal; modeline->flags = oldrep.flags; modeline->privsize = oldrep.privsize; } else { if (!_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *dotclock = rep.dotclock; modeline->hdisplay = rep.hdisplay; modeline->hsyncstart = rep.hsyncstart; modeline->hsyncend = rep.hsyncend; modeline->htotal = rep.htotal; modeline->hskew = rep.hskew; modeline->vdisplay = rep.vdisplay; modeline->vsyncstart = rep.vsyncstart; modeline->vsyncend = rep.vsyncend; modeline->vtotal = rep.vtotal; modeline->flags = rep.flags; modeline->privsize = rep.privsize; } if (modeline->privsize > 0) { if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); Xfree(modeline->private); return False; } _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); } else { modeline->private = NULL; } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetAllModeLines(dpy, screen, modecount, modelinesPtr) Display* dpy; int screen; int* modecount; XF86VidModeModeInfo ***modelinesPtr; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetAllModeLinesReply rep; xXF86VidModeGetAllModeLinesReq *req; XF86VidModeModeInfo *mdinfptr, **modelines; xXF86VidModeModeInfo xmdline; xXF86OldVidModeModeInfo oldxmdline; int i; int majorVersion, minorVersion; Bool protocolBug = False; XF86VidModeCheckExtension (dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions * 0.x with x < 8 (the .private field wasn't being passed over the wire). * Check the server's version, and accept the old format if appropriate. */ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG fprintf(stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is" "running an old version (%d.%d)\n", majorVersion, minorVersion); #endif } LockDisplay(dpy); GetReq(XF86VidModeGetAllModeLines, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *modecount = rep.modecount; if (!(modelines = (XF86VidModeModeInfo **) Xcalloc(rep.modecount, sizeof(XF86VidModeModeInfo *) +sizeof(XF86VidModeModeInfo)))) { if (majorVersion < 2) _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); else _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); Xfree(modelines); return False; } mdinfptr = (XF86VidModeModeInfo *) ( (char *) modelines + rep.modecount*sizeof(XF86VidModeModeInfo *) ); for (i = 0; i < rep.modecount; i++) { modelines[i] = mdinfptr++; if (majorVersion < 2) { _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); modelines[i]->dotclock = oldxmdline.dotclock; modelines[i]->hdisplay = oldxmdline.hdisplay; modelines[i]->hsyncstart = oldxmdline.hsyncstart; modelines[i]->hsyncend = oldxmdline.hsyncend; modelines[i]->htotal = oldxmdline.htotal; modelines[i]->hskew = 0; modelines[i]->vdisplay = oldxmdline.vdisplay; modelines[i]->vsyncstart = oldxmdline.vsyncstart; modelines[i]->vsyncend = oldxmdline.vsyncend; modelines[i]->vtotal = oldxmdline.vtotal; modelines[i]->flags = oldxmdline.flags; if (protocolBug) { modelines[i]->privsize = 0; modelines[i]->private = NULL; } else { modelines[i]->privsize = oldxmdline.privsize; if (oldxmdline.privsize > 0) { if (!(modelines[i]->private = Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); Xfree(modelines[i]->private); } else { _XRead(dpy, (char*)modelines[i]->private, oldxmdline.privsize * sizeof(INT32)); } } else { modelines[i]->private = NULL; } } } else { _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); modelines[i]->dotclock = xmdline.dotclock; modelines[i]->hdisplay = xmdline.hdisplay; modelines[i]->hsyncstart = xmdline.hsyncstart; modelines[i]->hsyncend = xmdline.hsyncend; modelines[i]->htotal = xmdline.htotal; modelines[i]->hskew = xmdline.hskew; modelines[i]->vdisplay = xmdline.vdisplay; modelines[i]->vsyncstart = xmdline.vsyncstart; modelines[i]->vsyncend = xmdline.vsyncend; modelines[i]->vtotal = xmdline.vtotal; modelines[i]->flags = xmdline.flags; if (protocolBug) { modelines[i]->privsize = 0; modelines[i]->private = NULL; } else { modelines[i]->privsize = xmdline.privsize; if (xmdline.privsize > 0) { if (!(modelines[i]->private = Xcalloc(xmdline.privsize, sizeof(INT32)))) { _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); Xfree(modelines[i]->private); } else { _XRead(dpy, (char*)modelines[i]->private, xmdline.privsize * sizeof(INT32)); } } else { modelines[i]->private = NULL; } } } } *modelinesPtr = modelines; UnlockDisplay(dpy); SyncHandle(); return True; } /* * GetReq replacement for use with VidMode protocols earlier than 2.0 */ #if !defined(UNIXCPP) || defined(ANSICPP) #define GetOldReq(name, oldname, req) \ WORD64ALIGN\ if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ _XFlush(dpy);\ req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ req->reqType = X_##name;\ req->length = (SIZEOF(x##oldname##Req))>>2;\ dpy->bufptr += SIZEOF(x##oldname##Req);\ dpy->request++ #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ #define GetOldReq(name, oldname, req) \ WORD64ALIGN\ if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ _XFlush(dpy);\ req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ req->reqType = X_/**/name;\ req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\ dpy->request++ #endif Bool XF86VidModeAddModeLine (dpy, screen, newmodeline, aftermodeline) Display *dpy; int screen; XF86VidModeModeInfo* newmodeline; XF86VidModeModeInfo* aftermodeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeAddModeLineReq *req; xXF86OldVidModeAddModeLineReq *oldreq; int majorVersion, minorVersion; XF86VidModeCheckExtension (dpy, info, False); XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); LockDisplay(dpy); if (majorVersion < 2) { GetOldReq(XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeAddModeLine; oldreq->screen = screen; oldreq->dotclock = newmodeline->dotclock; oldreq->hdisplay = newmodeline->hdisplay; oldreq->hsyncstart = newmodeline->hsyncstart; oldreq->hsyncend = newmodeline->hsyncend; oldreq->htotal = newmodeline->htotal; oldreq->vdisplay = newmodeline->vdisplay; oldreq->vsyncstart = newmodeline->vsyncstart; oldreq->vsyncend = newmodeline->vsyncend; oldreq->vtotal = newmodeline->vtotal; oldreq->flags = newmodeline->flags; oldreq->privsize = newmodeline->privsize; if (aftermodeline != NULL) { oldreq->after_dotclock = aftermodeline->dotclock; oldreq->after_hdisplay = aftermodeline->hdisplay; oldreq->after_hsyncstart = aftermodeline->hsyncstart; oldreq->after_hsyncend = aftermodeline->hsyncend; oldreq->after_htotal = aftermodeline->htotal; oldreq->after_vdisplay = aftermodeline->vdisplay; oldreq->after_vsyncstart = aftermodeline->vsyncstart; oldreq->after_vsyncend = aftermodeline->vsyncend; oldreq->after_vtotal = aftermodeline->vtotal; oldreq->after_flags = aftermodeline->flags; } else { oldreq->after_dotclock = 0; oldreq->after_hdisplay = 0; oldreq->after_hsyncstart = 0; oldreq->after_hsyncend = 0; oldreq->after_htotal = 0; oldreq->after_vdisplay = 0; oldreq->after_vsyncstart = 0; oldreq->after_vsyncend = 0; oldreq->after_vtotal = 0; oldreq->after_flags = 0; } if (newmodeline->privsize) { oldreq->length += newmodeline->privsize; Data32(dpy, (long *) newmodeline->private, newmodeline->privsize * sizeof(INT32)); } } else { GetReq(XF86VidModeAddModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeAddModeLine; req->screen = screen; req->dotclock = newmodeline->dotclock; req->hdisplay = newmodeline->hdisplay; req->hsyncstart = newmodeline->hsyncstart; req->hsyncend = newmodeline->hsyncend; req->htotal = newmodeline->htotal; req->hskew = newmodeline->hskew; req->vdisplay = newmodeline->vdisplay; req->vsyncstart = newmodeline->vsyncstart; req->vsyncend = newmodeline->vsyncend; req->vtotal = newmodeline->vtotal; req->flags = newmodeline->flags; req->privsize = newmodeline->privsize; if (aftermodeline != NULL) { req->after_dotclock = aftermodeline->dotclock; req->after_hdisplay = aftermodeline->hdisplay; req->after_hsyncstart = aftermodeline->hsyncstart; req->after_hsyncend = aftermodeline->hsyncend; req->after_htotal = aftermodeline->htotal; req->after_hskew = aftermodeline->hskew; req->after_vdisplay = aftermodeline->vdisplay; req->after_vsyncstart = aftermodeline->vsyncstart; req->after_vsyncend = aftermodeline->vsyncend; req->after_vtotal = aftermodeline->vtotal; req->after_flags = aftermodeline->flags; } else { req->after_dotclock = 0; req->after_hdisplay = 0; req->after_hsyncstart = 0; req->after_hsyncend = 0; req->after_htotal = 0; req->after_hskew = 0; req->after_vdisplay = 0; req->after_vsyncstart = 0; req->after_vsyncend = 0; req->after_vtotal = 0; req->after_flags = 0; } if (newmodeline->privsize) { req->length += newmodeline->privsize; Data32(dpy, (long *) newmodeline->private, newmodeline->privsize * sizeof(INT32)); } } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeDeleteModeLine (dpy, screen, modeline) Display *dpy; int screen; XF86VidModeModeInfo* modeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeDeleteModeLineReq *req; xXF86OldVidModeDeleteModeLineReq *oldreq; int majorVersion, minorVersion; XF86VidModeCheckExtension (dpy, info, 0); XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); LockDisplay(dpy); if (majorVersion < 2) { GetOldReq(XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; oldreq->screen = screen; oldreq->dotclock = modeline->dotclock; oldreq->hdisplay = modeline->hdisplay; oldreq->hsyncstart = modeline->hsyncstart; oldreq->hsyncend = modeline->hsyncend; oldreq->htotal = modeline->htotal; oldreq->vdisplay = modeline->vdisplay; oldreq->vsyncstart = modeline->vsyncstart; oldreq->vsyncend = modeline->vsyncend; oldreq->vtotal = modeline->vtotal; oldreq->flags = modeline->flags; oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } else { GetReq(XF86VidModeDeleteModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; req->screen = screen; req->dotclock = modeline->dotclock; req->hdisplay = modeline->hdisplay; req->hsyncstart = modeline->hsyncstart; req->hsyncend = modeline->hsyncend; req->htotal = modeline->htotal; req->hskew = modeline->hskew; req->vdisplay = modeline->vdisplay; req->vsyncstart = modeline->vsyncstart; req->vsyncend = modeline->vsyncend; req->vtotal = modeline->vtotal; req->flags = modeline->flags; req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeModModeLine (dpy, screen, modeline) Display *dpy; int screen; XF86VidModeModeLine* modeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeModModeLineReq *req; xXF86OldVidModeModModeLineReq *oldreq; int majorVersion, minorVersion; XF86VidModeCheckExtension (dpy, info, 0); XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); LockDisplay(dpy); if (majorVersion < 2) { GetOldReq(XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeModModeLine; oldreq->screen = screen; oldreq->hdisplay = modeline->hdisplay; oldreq->hsyncstart = modeline->hsyncstart; oldreq->hsyncend = modeline->hsyncend; oldreq->htotal = modeline->htotal; oldreq->vdisplay = modeline->vdisplay; oldreq->vsyncstart = modeline->vsyncstart; oldreq->vsyncend = modeline->vsyncend; oldreq->vtotal = modeline->vtotal; oldreq->flags = modeline->flags; oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } else { GetReq(XF86VidModeModModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeModModeLine; req->screen = screen; req->hdisplay = modeline->hdisplay; req->hsyncstart = modeline->hsyncstart; req->hsyncend = modeline->hsyncend; req->htotal = modeline->htotal; req->hskew = modeline->hskew; req->vdisplay = modeline->vdisplay; req->vsyncstart = modeline->vsyncstart; req->vsyncend = modeline->vsyncend; req->vtotal = modeline->vtotal; req->flags = modeline->flags; req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } UnlockDisplay(dpy); SyncHandle(); return True; } Status XF86VidModeValidateModeLine (dpy, screen, modeline) Display *dpy; int screen; XF86VidModeModeInfo* modeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeValidateModeLineReq *req; xXF86OldVidModeValidateModeLineReq *oldreq; xXF86VidModeValidateModeLineReply rep; int majorVersion, minorVersion; XF86VidModeCheckExtension (dpy, info, 0); XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); LockDisplay(dpy); if (majorVersion < 2) { GetOldReq(XF86VidModeValidateModeLine, XF86OldVidModeValidateModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; oldreq->screen = screen; oldreq->dotclock = modeline->dotclock; oldreq->hdisplay = modeline->hdisplay; oldreq->hsyncstart = modeline->hsyncstart; oldreq->hsyncend = modeline->hsyncend; oldreq->htotal = modeline->htotal; oldreq->vdisplay = modeline->vdisplay; oldreq->vsyncstart = modeline->vsyncstart; oldreq->vsyncend = modeline->vsyncend; oldreq->vtotal = modeline->vtotal; oldreq->flags = modeline->flags; oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } else { GetReq(XF86VidModeValidateModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; req->screen = screen; req->dotclock = modeline->dotclock; req->hdisplay = modeline->hdisplay; req->hsyncstart = modeline->hsyncstart; req->hsyncend = modeline->hsyncend; req->htotal = modeline->htotal; req->hskew = modeline->hskew; req->vdisplay = modeline->vdisplay; req->vsyncstart = modeline->vsyncstart; req->vsyncend = modeline->vsyncend; req->vtotal = modeline->vtotal; req->flags = modeline->flags; req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return MODE_BAD; } UnlockDisplay(dpy); SyncHandle(); return rep.status; } Bool XF86VidModeSwitchMode(dpy, screen, zoom) Display* dpy; int screen; int zoom; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeSwitchModeReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeSwitchMode, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSwitchMode; req->screen = screen; req->zoom = zoom; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeSwitchToMode(dpy, screen, modeline) Display* dpy; int screen; XF86VidModeModeInfo* modeline; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeSwitchToModeReq *req; xXF86OldVidModeSwitchToModeReq *oldreq; int majorVersion, minorVersion; Bool protocolBug = False; XF86VidModeCheckExtension (dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions * 0.x with x < 8 (the .private field wasn't expected to be sent over * the wire). Check the server's version, and accept the old format * if appropriate. */ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG fprintf(stderr, "XF86VidModeSwitchToMode: Warning: Xserver is" "running an old version (%d.%d)\n", majorVersion, minorVersion); #endif } LockDisplay(dpy); if (majorVersion < 2) { GetOldReq(XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; oldreq->screen = screen; oldreq->dotclock = modeline->dotclock; oldreq->hdisplay = modeline->hdisplay; oldreq->hsyncstart = modeline->hsyncstart; oldreq->hsyncend = modeline->hsyncend; oldreq->htotal = modeline->htotal; oldreq->vdisplay = modeline->vdisplay; oldreq->vsyncstart = modeline->vsyncstart; oldreq->vsyncend = modeline->vsyncend; oldreq->vtotal = modeline->vtotal; oldreq->flags = modeline->flags; if (protocolBug) { oldreq->privsize = 0; } else { oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } } else { GetReq(XF86VidModeSwitchToMode, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; req->screen = screen; req->dotclock = modeline->dotclock; req->hdisplay = modeline->hdisplay; req->hsyncstart = modeline->hsyncstart; req->hsyncend = modeline->hsyncend; req->htotal = modeline->htotal; req->hskew = modeline->hskew; req->vdisplay = modeline->vdisplay; req->vsyncstart = modeline->vsyncstart; req->vsyncend = modeline->vsyncend; req->vtotal = modeline->vtotal; req->flags = modeline->flags; if (protocolBug) { req->privsize = 0; } else { req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; Data32(dpy, (long *) modeline->private, modeline->privsize * sizeof(INT32)); } } } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeLockModeSwitch(dpy, screen, lock) Display* dpy; int screen; int lock; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeLockModeSwitchReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeLockModeSwitch, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeLockModeSwitch; req->screen = screen; req->lock = lock; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetMonitor(dpy, screen, monitor) Display* dpy; int screen; XF86VidModeMonitor* monitor; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetMonitorReply rep; xXF86VidModeGetMonitorReq *req; CARD32 syncrange; int i; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetMonitor, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } monitor->nhsync = rep.nhsync; monitor->nvsync = rep.nvsync; #if 0 monitor->bandwidth = (float)rep.bandwidth / 1e6; #endif if (rep.vendorLength) { if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) { _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); return False; } } else { monitor->vendor = NULL; } if (rep.modelLength) { if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) Xfree(monitor->vendor); return False; } } else { monitor->model = NULL; } if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(XF86VidModeSyncRange)))) { _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) Xfree(monitor->vendor); if (monitor->model) Xfree(monitor->model); return False; } if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(XF86VidModeSyncRange)))) { _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) Xfree(monitor->vendor); if (monitor->model) Xfree(monitor->model); Xfree(monitor->hsync); return False; } for (i = 0; i < rep.nhsync; i++) { _XRead(dpy, (char *)&syncrange, 4); monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0; } for (i = 0; i < rep.nvsync; i++) { _XRead(dpy, (char *)&syncrange, 4); monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0; } if (rep.vendorLength) _XReadPad(dpy, monitor->vendor, rep.vendorLength); if (rep.modelLength) _XReadPad(dpy, monitor->model, rep.modelLength); UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetViewPort(dpy, screen, x, y) Display* dpy; int screen; int *x, *y; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetViewPortReply rep; xXF86VidModeGetViewPortReq *req; int majorVersion, minorVersion; Bool protocolBug = False; XF86VidModeCheckExtension (dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions * 0.x with x < 8 (no reply was sent, so the client would hang) * Check the server's version, and don't wait for a reply with older * versions. */ XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG fprintf(stderr, "XF86VidModeGetViewPort: Warning: Xserver is" "running an old version (%d.%d)\n", majorVersion, minorVersion); #endif } LockDisplay(dpy); GetReq(XF86VidModeGetViewPort, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetViewPort; req->screen = screen; if (protocolBug) { *x = 0; *y = 0; } else { if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *x = rep.x; *y = rep.y; } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeSetViewPort(dpy, screen, x, y) Display* dpy; int screen; int x, y; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeSetViewPortReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeSetViewPort, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetViewPort; req->screen = screen; req->x = x; req->y = y; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetDotClocks(dpy, screen, flagsPtr, numclocksPtr, maxclocksPtr, clocksPtr) Display* dpy; int screen; int *flagsPtr, *numclocksPtr, *maxclocksPtr, *clocksPtr[]; { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetDotClocksReply rep; xXF86VidModeGetDotClocksReq *req; int i, *dotclocks; CARD32 dotclk; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetDotClocks, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *numclocksPtr = rep.clocks; *maxclocksPtr = rep.maxclocks; *flagsPtr = rep.flags; if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { _XEatData(dpy, (rep.clocks) * 4); Xfree(dotclocks); return False; } for (i = 0; i < rep.clocks; i++) { _XRead(dpy, (char*)&dotclk, 4); dotclocks[i] = dotclk; } *clocksPtr = dotclocks; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeSetGammaRamp ( Display *dpy, int screen, int size, unsigned short *red, unsigned short *green, unsigned short *blue ) { int length = (size + 1) & ~1; XExtDisplayInfo *info = find_display (dpy); xXF86VidModeSetGammaRampReq *req; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeSetGammaRamp, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; req->screen = screen; req->length += (length >> 1) * 3; req->size = size; _XSend(dpy, (char*)red, size * 2); _XSend(dpy, (char*)green, size * 2); _XSend(dpy, (char*)blue, size * 2); UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetGammaRamp ( Display *dpy, int screen, int size, unsigned short *red, unsigned short *green, unsigned short *blue ) { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetGammaRampReq *req; xXF86VidModeGetGammaRampReply rep; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetGammaRamp, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; req->screen = screen; req->size = size; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return False; } if(rep.size) { _XRead(dpy, (char*)red, rep.size << 1); _XRead(dpy, (char*)green, rep.size << 1); _XRead(dpy, (char*)blue, rep.size << 1); } UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetGammaRampSize( Display *dpy, int screen, int *size ) { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetGammaRampSizeReq *req; xXF86VidModeGetGammaRampSizeReply rep; *size = 0; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetGammaRampSize, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; req->screen = screen; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return False; } *size = rep.size; UnlockDisplay(dpy); SyncHandle(); return True; } Bool XF86VidModeGetPermissions( Display *dpy, int screen, int *permissions ) { XExtDisplayInfo *info = find_display (dpy); xXF86VidModeGetPermissionsReq *req; xXF86VidModeGetPermissionsReply rep; *permissions = 0; XF86VidModeCheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86VidModeGetPermissions, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetPermissions; req->screen = screen; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return False; } *permissions = rep.permissions; UnlockDisplay(dpy); SyncHandle(); return True; } libXxf86vm-1.0.2/xxf86vm.pc.in000064400000000000000000000004201103275436000157410ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: Xxf86vm Description: XFree86 Video Mode Extension Library Version: @VERSION@ Requires: xf86vidmodeproto Requires.private: x11 xext Cflags: -I${includedir} Libs: -L${libdir} -lXxf86vm